Skip to content

Commit

Permalink
[BUGFIX] Fix promql-query Vue component rendering #516
Browse files Browse the repository at this point in the history
  • Loading branch information
kfdm authored Jun 4, 2024
2 parents 96f7900 + d283108 commit d07aa31
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
12 changes: 3 additions & 9 deletions promgen/static/js/promgen.vue.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ app.component("promql-query", {
data: function () {
return {
count: 0,
ready: false,
};
},
mixins: [mixins],
Expand All @@ -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);
},
});

Expand Down
4 changes: 2 additions & 2 deletions promgen/templates/promgen/vue/promql_query.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<span style="display: none" :title="percent(load)" :class="classes">
[[ localize(count) ]] <slot></slot>
<span v-show="ready" :title="percent(load)" :class="classes">
<slot></slot> [[ localize(count) ]]
</span>

0 comments on commit d07aa31

Please sign in to comment.