diff --git a/src/MetricQWebView.js b/src/MetricQWebView.js index 59f9f73..e6a2394 100644 --- a/src/MetricQWebView.js +++ b/src/MetricQWebView.js @@ -74,8 +74,12 @@ class MetricQWebView { updateMetricUrl () { let encodedStr = '.' + this.handler.startTime.getValue() + '*' + this.handler.stopTime.getValue() - for (const metricKey of this.store.getters['metrics/getAllKeys']()) { - encodedStr += '*' + metricKey + for (const metric of this.store.getters['metrics/getAll']()) { + if (metric.factor !== 1 && metric.factor !== undefined) { + encodedStr += '*(' + metric.key + '~' + metric.factor + ')' + } else { + encodedStr += '*' + metric.key + } } encodedStr = encodeURIComponent(encodedStr) window.location.href = @@ -108,7 +112,13 @@ class MetricQWebView { async addMetric (metricBase, description = undefined, oldMetric = undefined) { try { - await this.store.dispatch('metrics/create', { metric: { ...oldMetric, name: metricBase, description: description, traces: [] } }) + if (metricBase.startsWith('(') && metricBase.endsWith(')')) { + const [metric, factorStr] = metricBase.substring(1, metricBase.length - 1).split('~') + const factor = Number.parseFloat(factorStr) + await this.store.dispatch('metrics/create', { metric: { ...oldMetric, name: metric, description: description, traces: [], factor: factor } }) + } else { + await this.store.dispatch('metrics/create', { metric: { ...oldMetric, name: metricBase, description: description, traces: [] } }) + } return true } catch (error) { if (error instanceof Error.DuplicateMetricError) { diff --git a/src/data-handling.js b/src/data-handling.js index eff3a9e..1e3223b 100644 --- a/src/data-handling.js +++ b/src/data-handling.js @@ -205,7 +205,7 @@ export class DataCache { class MetricCache { constructor (paramMetricQReference, paramMetricName) { this.name = paramMetricName - this.factor = 1 + this.factor = store.getters['metrics/getFactor'](this.name) this.color = store.getters['metrics/getColor'](this.name) this.series = { min: undefined, diff --git a/src/store/metrics.js b/src/store/metrics.js index e13f76c..ddf4bb8 100644 --- a/src/store/metrics.js +++ b/src/store/metrics.js @@ -47,6 +47,9 @@ export default { getUnit: (state) => (metric) => { return state.metrics[metric].unit }, + getFactor: (state) => (metric) => { + return state.metrics[metric].factor + }, getPeakedMetric: (state) => () => { return state.peakedMetric } @@ -169,7 +172,8 @@ export default { drawMax, drawAvg, pointsAgg, - pointsRaw + pointsRaw, + factor } }) { if (state.metrics[name] !== undefined) { @@ -193,6 +197,7 @@ export default { // maybe we changed the globale draw state? dispatch('checkGlobalDrawState') dispatch('updateUnit', { metricKey: name, unit, metadataObj }) + dispatch('updateFactor', { metricKey: name, factor }) } }, updateDescription ({ commit }, { metricKey, description, metadataObj }) { diff --git a/src/ui/metric-popup.vue b/src/ui/metric-popup.vue index 3705ccf..27e77b3 100644 --- a/src/ui/metric-popup.vue +++ b/src/ui/metric-popup.vue @@ -224,6 +224,7 @@ export default { factor = 1 } this.$store.dispatch('metrics/updateFactor', { metricKey: this.metric.key, factor }) + window.MetricQWebView.updateMetricUrl() }, changeDraw (evt) { if (this.metric.drawMin === false && this.metric.drawAvg === false && this.metric.drawMax === false) {