Skip to content

Commit

Permalink
move webview link metric into injection
Browse files Browse the repository at this point in the history
  • Loading branch information
bmario committed Mar 19, 2024
1 parent cc98c2f commit 51b4ebc
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 6 deletions.
5 changes: 4 additions & 1 deletion components/MetricActions.vue
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
size="sm"
variant="outline-info"
title="Open in WebView"
:href="$config.metricq.webviewURL + '#.now-1h*now*' + metric.id"
:href="webviewLink()"
target="_blank"
>
<b-icon-graph-up />
Expand Down Expand Up @@ -244,6 +244,9 @@ export default {
}
}
},
webviewLink() {
return this.$webview.link([this.metric.id])
},
},
}
</script>
Expand Down
2 changes: 1 addition & 1 deletion components/Navbar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
>
Cluster Health
</b-nav-item>
<b-nav-item :href="$config.metricq.webviewURL" target="_blank">
<b-nav-item :href="$webview.link()" target="_blank">
Webview<sup><b-icon-box-arrow-up-right scale="0.6" /></sup>
</b-nav-item>
</b-navbar-nav>
Expand Down
1 change: 1 addition & 0 deletions nuxt.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export default {
'@/plugins/async-computed',
'@/plugins/chartkick',
'@/plugins/sleep',
'@/plugins/webview',
],
/*
** Nuxt.js dev-modules
Expand Down
5 changes: 1 addition & 4 deletions pages/metric/configure.vue
Original file line number Diff line number Diff line change
Expand Up @@ -586,13 +586,10 @@ export default {
}
},
webviewLink() {
return (
this.$config.metricq.webviewURL +
'#.now-1h*now*' +
return this.$webview.link(
this.selected
.filter((metric) => metric.historic === true)
.map((metric) => metric.id)
.join('*')
)
},
},
Expand Down
13 changes: 13 additions & 0 deletions plugins/webview.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
export default ({ app }, inject) => {
inject('webview', {
link(metrics) {
if (metrics === undefined || metrics.lenght === 0) {
return app.$config.metricq.webviewURL
}

return (
app.$config.metricq.webviewURL + '#.now-1h*now*' + metrics.join('*')
)
},
})
}

0 comments on commit 51b4ebc

Please sign in to comment.