Add ready property to home

This commit is contained in:
Torjus Håkestad 2021-04-11 11:54:37 +02:00
parent b52b519c5e
commit 0e6679d628

View File

@ -1,6 +1,6 @@
<template> <template>
<div class="home"> <div class="home">
<b-container v-if="totalStats"> <b-container v-if="ready">
<b-row> <b-row>
<b-col class="total-title"> <b-col class="total-title">
<h2>Total login attempts</h2> <h2>Total login attempts</h2>
@ -57,6 +57,8 @@ interface TotalStatsResult {
export default class Home extends Vue { export default class Home extends Vue {
totalStats?: TotalStatsResult[]; totalStats?: TotalStatsResult[];
ready = false;
@Watch('totalStats', { immediate: true, deep: true }) @Watch('totalStats', { immediate: true, deep: true })
getStat(key: TotalStatsHeaders): string | undefined { getStat(key: TotalStatsHeaders): string | undefined {
const result = this.totalStats?.find((elem) => elem.name === key); const result = this.totalStats?.find((elem) => elem.name === key);
@ -72,6 +74,7 @@ export default class Home extends Vue {
.get<TotalStatsResult[]>(url) .get<TotalStatsResult[]>(url)
.then((resp) => { .then((resp) => {
this.totalStats = resp.data; this.totalStats = resp.data;
this.ready = true;
console.log(this.totalStats); console.log(this.totalStats);
}) })
.catch((e) => { .catch((e) => {