Show chain status

This commit is contained in:
liangping 2021-09-11 11:24:21 +08:00
parent 431629736b
commit 70ddca4693
2 changed files with 18 additions and 4 deletions

View File

@ -37,13 +37,14 @@
@click="toggleVerticalMenuActive" @click="toggleVerticalMenuActive"
> >
<b-avatar <b-avatar
v-b-tooltip.hover.bottom="tips"
variant="transparent" variant="transparent"
badge badge
rounded rounded
size="42" size="42"
:src="selected_chain.logo" :src="selected_chain.logo"
class="badge-minimal" class="badge-minimal"
badge-variant="success" :badge-variant="chainVariant"
/></b-link> /></b-link>
</b-media-aside> </b-media-aside>
<b-media-body class="my-auto"> <b-media-body class="my-auto">
@ -133,6 +134,7 @@ import Locale from '@core/layouts/components/app-navbar/components/Locale.vue'
import SearchBar from '@core/layouts/components/app-navbar/components/SearchBar.vue' import SearchBar from '@core/layouts/components/app-navbar/components/SearchBar.vue'
// import CartDropdown from '@core/layouts/components/app-navbar/components/CartDropdown.vue' // import CartDropdown from '@core/layouts/components/app-navbar/components/CartDropdown.vue'
import store from '@/store' import store from '@/store'
import { timeIn, toDay } from '@/libs/data'
// import UserDropdown from '@core/layouts/components/app-navbar/components/UserDropdown.vue' // import UserDropdown from '@core/layouts/components/app-navbar/components/UserDropdown.vue'
export default { export default {
@ -164,7 +166,8 @@ export default {
}, },
data() { data() {
return { return {
// result: {}, chainVariant: 'success',
tips: 'Synced',
} }
}, },
computed: { computed: {
@ -172,5 +175,13 @@ export default {
return store.state.chains.selected return store.state.chains.selected
}, },
}, },
created() {
this.$http.getLatestBlock().then(block => {
if (timeIn(block.block.header.time, 1, 'm')) {
this.chainVariant = 'danger'
this.tips = `Halted ${toDay(block.block.header.time, 'from')} `
}
})
},
} }
</script> </script>

View File

@ -59,10 +59,12 @@
> >
<b-avatar <b-avatar
:src="data.logo" :src="data.logo"
class="mt-1" class="mt-1 badge-minimal"
variant="light-primary" variant="light-primary"
rounded rounded
size="82" size="82"
badge
:badge-variant="data.variant"
/></b-col> /></b-col>
</b-row> </b-row>
</b-card> </b-card>
@ -93,7 +95,7 @@ import {
} from 'bootstrap-vue' } from 'bootstrap-vue'
import VuexyLogo from '@core/layouts/components/Logo.vue' import VuexyLogo from '@core/layouts/components/Logo.vue'
import store from '@/store/index' import store from '@/store/index'
import { toDay } from '@/libs/data' import { timeIn, toDay } from '@/libs/data'
import DarkToggler from '@/@core/layouts/components/app-navbar/components/DarkToggler.vue' import DarkToggler from '@/@core/layouts/components/app-navbar/components/DarkToggler.vue'
import Locale from '@/@core/layouts/components/app-navbar/components/Locale.vue' import Locale from '@/@core/layouts/components/app-navbar/components/Locale.vue'
import AppFooter from '@/@core/layouts/components/AppFooter.vue' import AppFooter from '@/@core/layouts/components/AppFooter.vue'
@ -148,6 +150,7 @@ export default {
const { header } = b.block const { header } = b.block
this.$set(chain, 'height', header.height) this.$set(chain, 'height', header.height)
this.$set(chain, 'time', toDay(header.time)) this.$set(chain, 'time', toDay(header.time))
this.$set(chain, 'variant', timeIn(header, 1, 'm') ? 'danger' : 'success')
}) })
} }
}) })