refine stats ui

This commit is contained in:
2021-01-25 19:31:54 +11:00
parent bb28be7408
commit 263fce425d
5 changed files with 52 additions and 5 deletions
+24
View File
@@ -44,6 +44,21 @@
<a href="mailto:me@toozhao.com" class="contact">Contact me</a>
</b-col>
</b-row>
<template #overlay>
<div class="text-center" v-if="hasError">
<b-icon icon="stopwatch" font-scale="3" animation="cylon"></b-icon>
<p id="error-detail">{{error}}</p>
<b-button
ref="cancel"
variant="outline-light"
size="sm"
aria-describedby="cancel-label"
href="/"
>
Back to homepage
</b-button>
</div>
</template>
</b-overlay>
</template>
@@ -77,6 +92,12 @@ export default Vue.extend({
isLoading() {
return this.$store.state.loading.loading;
},
hasError() {
return this.$store.state.error.error !== "";
},
error(){
return this.$store.state.error.error;
},
isProduction() {
return this.$config.env === "production";
},
@@ -141,4 +162,7 @@ html {
box-sizing: border-box;
margin: 0;
}
#error-detail {
color: #fff;
}
</style>
+3
View File
@@ -179,6 +179,9 @@ export default Vue.extend({
activeBadgeColor: "green"
};
},
mounted() {
this.$store.commit("error/setError", "")
},
computed: {
badge() {
return this.$store.state.badges.currentBadge;
+7 -1
View File
@@ -84,12 +84,18 @@ export default {
borderWidth: 2,
borderColor: 'rgb(49, 197, 83)',
fill: false,
lineTension: 1
lineTension: 0.1
}
]
};
this.$store.commit("loading/updateLoading");
this.loaded = true;
},
errorCallback: (error) => {
console.log(error.response.data.msg)
this.$store.commit("error/setError", error.response.data.msg)
// this.$store.commit("loading/updateLoading");
this.loaded = false;
}
});
},
+9
View File
@@ -0,0 +1,9 @@
export const state = () => ({
error: ""
});
export const mutations = {
setError(state, error) {
state.error = error;
}
};
+9 -4
View File
@@ -9,10 +9,15 @@ export const mutations = {
};
export const actions = {
async getBadgeStats(context, {badgeId, callback}) {
const result = await this.$axios.$get(`/api/stats/${badgeId}`);
context.commit("setStats", result);
callback(result);
async getBadgeStats(context, {badgeId, callback, errorCallback}) {
try{
const result = await this.$axios.$get(`/api/stats/${badgeId}`);
context.commit("setStats", result);
callback(result);
}catch (error) {
errorCallback(error)
}
}
};