diff --git a/promgen/static/js/promgen.vue.js b/promgen/static/js/promgen.vue.js index 18b44b04e..77679d3d5 100644 --- a/promgen/static/js/promgen.vue.js +++ b/promgen/static/js/promgen.vue.js @@ -189,6 +189,7 @@ app.component("promql-query", { data: function () { return { count: 0, + ready: false, }; }, mixins: [mixins], @@ -206,19 +207,12 @@ app.component("promql-query", { }, template: '#promql-query-template', mounted() { - var this_ = this; var url = new URL(this.href); url.search = new URLSearchParams({ query: this.query }); fetch(url) .then(response => response.json()) - .then(result => Number.parseInt(result.data.result[0].value[1])) - .then(result => { - this_.count = result; - this_.$el.style.display = "inline"; - }) - .catch(error => { - this_.$el.style.display = "inline"; - }); + .then(result => this.count = Number.parseInt(result.data.result[0].value[1])) + .finally(() => this.ready = true); }, }); diff --git a/promgen/templates/promgen/vue/promql_query.html b/promgen/templates/promgen/vue/promql_query.html index e531eaac3..3c19be7ad 100644 --- a/promgen/templates/promgen/vue/promql_query.html +++ b/promgen/templates/promgen/vue/promql_query.html @@ -1,3 +1,3 @@ - - [[ localize(count) ]] + + [[ localize(count) ]]