Skip to content

Commit b6fb9d4

Browse files
committed
fix app info request in dashboard view
1 parent 780d44c commit b6fb9d4

File tree

1 file changed

+18
-17
lines changed

1 file changed

+18
-17
lines changed

webui/src/views/DashboardView.vue

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import { useFetch, type Response } from '@/composables/fetch'
3939
import { useRoute } from 'vue-router'
4040
import { useRefreshManager } from '@/composables/refresh-manager'
4141
import { useDashboard, getRouteName } from '@/composables/dashboard'
42+
import type { AppInfoResponse } from '@/types/dashboard'
4243
4344
const configs: Ref<Response | undefined> = ref<Response>()
4445
@@ -49,15 +50,8 @@ const transitionRefresh = computed(() => {
4950
const count = ref<number>(0);
5051
const { dashboard, setMode, getMode } = useDashboard();
5152
52-
const appInfo = dashboard.value.getAppInfo()
53-
onUnmounted(() => {
54-
appInfo.close()
55-
if (configs.value) {
56-
configs.value.close()
57-
}
58-
})
59-
6053
const route = useRoute()
54+
const appInfo = ref<AppInfoResponse | undefined>()
6155
onMounted(() => {
6256
if (route.name === 'configs' && configs.value == null) {
6357
configs.value = useFetch('/api/configs')
@@ -68,21 +62,28 @@ onMounted(() => {
6862
if (route.meta.mode) {
6963
setMode(route.meta.mode as 'live' | 'demo')
7064
}
65+
appInfo.value = dashboard.value.getAppInfo()
66+
onUnmounted(() => {
67+
appInfo.value?.close()
68+
if (configs.value) {
69+
configs.value.close()
70+
}
71+
})
7172
})
7273
7374
function isServiceAvailable(service: string): boolean{
74-
if (!appInfo.data || !appInfo.data.activeServices){
75+
if (!appInfo.value?.data || !appInfo.value?.data.activeServices){
7576
return false
7677
}
77-
return appInfo.data.activeServices.includes(service)
78+
return appInfo.value?.data.activeServices.includes(service)
7879
}
7980
8081
function isAnyServiceAvailable() {
81-
return appInfo.data.activeServices && appInfo.data.activeServices.length> 0
82+
return appInfo.value?.data.activeServices && appInfo.value?.data.activeServices.length> 0
8283
}
8384
8485
function isInitLoading() {
85-
return appInfo.isLoading && !appInfo.data
86+
return appInfo.value?.isLoading && !appInfo.value?.data
8687
}
8788
8889
function hasJobs() {
@@ -112,7 +113,7 @@ useMeta('Dashboard | mokapi.io', description, '')
112113
</p>
113114
</div>
114115

115-
<div class="dashboard-tabs" v-if="appInfo.data" :class="{ demo: getMode() === 'demo' }">
116+
<div class="dashboard-tabs" v-if="appInfo?.data" :class="{ demo: getMode() === 'demo' }">
116117
<nav class="navbar navbar-expand pb-1" aria-label="Services">
117118
<div>
118119
<ul class="navbar-nav me-auto mb-0">
@@ -140,15 +141,15 @@ useMeta('Dashboard | mokapi.io', description, '')
140141
<li class="nav-item">
141142
<router-link class="nav-link" :to="{ name: getRouteName('tree').value }">Faker</router-link>
142143
</li>
143-
<li class="nav-item" v-if="appInfo.data.search.enabled">
144+
<li class="nav-item" v-if="appInfo?.data.search.enabled">
144145
<router-link class="nav-link" :to="{ name: getRouteName('search').value }">Search</router-link>
145146
</li>
146147
</ul>
147148
</div>
148149
</nav>
149150
</div>
150-
<div v-if="appInfo.data" class="dashboard-content" :class="{ demo: getMode() === 'demo' }">
151-
<div v-if="$route.name === getRouteName('dashboard').value && appInfo.data">
151+
<div v-if="appInfo?.data" class="dashboard-content" :class="{ demo: getMode() === 'demo' }">
152+
<div v-if="$route.name === getRouteName('dashboard').value && appInfo?.data">
152153
<div class="card-group">
153154
<app-start-card />
154155
<memory-usage-card />
@@ -251,7 +252,7 @@ useMeta('Dashboard | mokapi.io', description, '')
251252
</div>
252253
</div>
253254

254-
<message :message="appInfo.error" v-if="!appInfo.data && !appInfo.isLoading"></message>
255+
<message :message="appInfo.error" v-if="!appInfo?.data && !appInfo?.isLoading && appInfo?.error"></message>
255256
<loading v-if="isInitLoading()"></loading>
256257
</main>
257258
</template>

0 commit comments

Comments
 (0)