Changeset View
Changeset View
Standalone View
Standalone View
src/resources/vue/Dashboard.vue
Show All 18 Lines | <div class="container" dusk="dashboard-component"> | ||||
<svg-icon icon="user-cog"></svg-icon><span class="name">Your profile</span> | <svg-icon icon="user-cog"></svg-icon><span class="name">Your profile</span> | ||||
</router-link> | </router-link> | ||||
<router-link class="card link-domains" :to="{ name: 'domains' }"> | <router-link class="card link-domains" :to="{ name: 'domains' }"> | ||||
<svg-icon icon="globe"></svg-icon><span class="name">Domains</span> | <svg-icon icon="globe"></svg-icon><span class="name">Domains</span> | ||||
</router-link> | </router-link> | ||||
<router-link class="card link-users" :to="{ name: 'users' }"> | <router-link class="card link-users" :to="{ name: 'users' }"> | ||||
<svg-icon icon="users"></svg-icon><span class="name">User accounts</span> | <svg-icon icon="users"></svg-icon><span class="name">User accounts</span> | ||||
</router-link> | </router-link> | ||||
<router-link class="card link-wallet disabled" :to="{ name: 'users' }"> | <router-link class="card link-wallet" :to="{ name: 'wallet' }"> | ||||
<svg-icon icon="wallet"></svg-icon><span class="name">Wallet</span> | <svg-icon icon="wallet"></svg-icon><span class="name">Wallet</span> | ||||
<span v-if="balance < 0" class="badge badge-danger">{{ $root.price(balance) }}</span> | |||||
</router-link> | </router-link> | ||||
</div> | </div> | ||||
</div> | </div> | ||||
</template> | </template> | ||||
<script> | <script> | ||||
export default { | export default { | ||||
data() { | data() { | ||||
return { | return { | ||||
statusProcess: [], | statusProcess: [], | ||||
request: null | request: null, | ||||
balance: 0 | |||||
} | } | ||||
}, | }, | ||||
mounted() { | mounted() { | ||||
const authInfo = this.$store.state.isLoggedIn ? this.$store.state.authInfo : null | const authInfo = this.$store.state.isLoggedIn ? this.$store.state.authInfo : null | ||||
clearTimeout(window.infoRequest) | clearTimeout(window.infoRequest) | ||||
if (authInfo) { | if (authInfo) { | ||||
this.parseStatusInfo(authInfo.statusInfo) | this.parseStatusInfo(authInfo.statusInfo) | ||||
this.getBalance(authInfo) | |||||
} else { | } else { | ||||
this.$root.startLoading() | this.$root.startLoading() | ||||
axios.get('/api/auth/info') | axios.get('/api/auth/info') | ||||
.then(response => { | .then(response => { | ||||
this.$store.state.authInfo = response.data | this.$store.state.authInfo = response.data | ||||
this.parseStatusInfo(response.data.statusInfo) | this.parseStatusInfo(response.data.statusInfo) | ||||
this.getBalance(response.data) | |||||
this.$root.stopLoading() | this.$root.stopLoading() | ||||
}) | }) | ||||
.catch(this.$root.errorHandler) | .catch(this.$root.errorHandler) | ||||
} | } | ||||
}, | }, | ||||
methods: { | methods: { | ||||
// Displays account status information | // Displays account status information | ||||
parseStatusInfo(info) { | parseStatusInfo(info) { | ||||
Show All 14 Lines | export default { | ||||
this.$store.state.authInfo = response.data | this.$store.state.authInfo = response.data | ||||
this.parseStatusInfo(response.data.statusInfo) | this.parseStatusInfo(response.data.statusInfo) | ||||
}) | }) | ||||
.catch(error => { | .catch(error => { | ||||
this.parseStatusInfo(info) | this.parseStatusInfo(info) | ||||
}) | }) | ||||
}, 10000); | }, 10000); | ||||
} | } | ||||
}, | |||||
getBalance(authInfo) { | |||||
this.balance = 0; | |||||
// TODO: currencies, multi-wallets, accounts | |||||
authInfo.wallets.forEach(wallet => { | |||||
this.balance += wallet.balance | |||||
}) | |||||
} | } | ||||
} | } | ||||
} | } | ||||
</script> | </script> |