Skip to content

Commit

Permalink
feat(ui): add skeleton loaders while initing
Browse files Browse the repository at this point in the history
Fixes #3733
  • Loading branch information
robertsLando committed May 31, 2024
1 parent a603a22 commit 94d5410
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
34 changes: 33 additions & 1 deletion src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -271,12 +271,21 @@
<main style="height: 100%">
<v-main style="height: 100%">
<router-view
v-if="auth !== undefined"
v-if="auth !== undefined && inited"
@import="importFile"
@export="exportConfiguration"
@showConfirm="confirm"
:socket="socket"
/>
<v-container v-else-if="auth !== undefined && !inited">
<!-- put some skeleton loaders while loading settings -->
<v-skeleton-loader
v-for="(s, i) in skeletons"
:key="`skeleton-${i}`"
:type="s"
:loading="true"
></v-skeleton-loader>
</v-container>
<v-row
style="height: 100%"
align="center"
Expand Down Expand Up @@ -455,11 +464,34 @@ export default {
'zniffer',
'zwave',
'znifferState',
'inited',
]),
...mapState(useBaseStore, {
darkMode: (store) => store.ui.darkMode,
navTabs: (store) => store.ui.navTabs,
}),
skeletons() {
// return the skeletons array based on actual route
const route = this.$route.path
switch (route) {
case Routes.controlPanel:
return ['actions', 'table']
case Routes.settings:
return ['list-item-two-line@10']
case Routes.store:
return ['list-item-two-line@10', 'divider']
case Routes.mesh:
return ['list-item-two-line, image']
case Routes.zniffer:
case Routes.debug:
case Routes.scenes:
case Routes.smartStart:
return ['table']
default:
return ['']
}
},
pages() {
const pages = [
{ icon: 'settings', title: 'Settings', path: Routes.settings },
Expand Down
3 changes: 3 additions & 0 deletions src/stores/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const log = logger.get('Store:Base')

const useBaseStore = defineStore('base', {
state: () => ({
inited: false,
auth: undefined,
controllerId: undefined,
serial_ports: [],
Expand Down Expand Up @@ -556,6 +557,8 @@ const useBaseStore = defineStore('base', {
this.initPorts(data.serial_ports)
this.initScales(data.scales)
this.initDevices(data.devices)

this.inited = true
}
},
setDarkMode(value) {
Expand Down

0 comments on commit 94d5410

Please sign in to comment.