Commit 74fcb249 by Torkel Ödegaard

prometheus: fixed unsaved changes warning when changing time range due to step…

prometheus: fixed unsaved changes warning when changing time range due to step option on query model was changed in datasource.query code, fixes #9675
parent 77331e92
...@@ -7,14 +7,15 @@ export class DeltaCtrl { ...@@ -7,14 +7,15 @@ export class DeltaCtrl {
observer: any; observer: any;
/** @ngInject */ /** @ngInject */
constructor($rootScope) { constructor(private $rootScope) {
const waitForCompile = function(mutations) {
const waitForCompile = (mutations) => {
if (mutations.length === 1) { if (mutations.length === 1) {
this.$rootScope.appEvent('json-diff-ready'); this.$rootScope.appEvent('json-diff-ready');
} }
}; };
this.observer = new MutationObserver(waitForCompile.bind(this)); this.observer = new MutationObserver(waitForCompile);
const observerConfig = { const observerConfig = {
attributes: true, attributes: true,
......
import _ from 'lodash'; import _ from 'lodash';
import coreModule from 'app/core/core_module'; import coreModule from 'app/core/core_module';
// This service really just tracks a list of $timeout promises to give us a
// method for cancelling them all when we need to
export class Timer { export class Timer {
timers = []; timers = [];
...@@ -14,7 +16,6 @@ export class Timer { ...@@ -14,7 +16,6 @@ export class Timer {
} }
cancel(promise) { cancel(promise) {
console.log(promise);
this.timers = _.without(this.timers, promise); this.timers = _.without(this.timers, promise);
this.$timeout.cancel(promise); this.$timeout.cancel(promise);
} }
...@@ -28,5 +29,3 @@ export class Timer { ...@@ -28,5 +29,3 @@ export class Timer {
} }
coreModule.service('timer', Timer); coreModule.service('timer', Timer);
// This service really just tracks a list of $timeout promises to give us a
// method for cancelling them all when we need to
...@@ -35,7 +35,6 @@ export class DashboardModel { ...@@ -35,7 +35,6 @@ export class DashboardModel {
gnetId: any; gnetId: any;
meta: any; meta: any;
events: any; events: any;
editMode: boolean;
constructor(data, meta?) { constructor(data, meta?) {
if (!data) { if (!data) {
......
...@@ -73,7 +73,6 @@ function(angular, _) { ...@@ -73,7 +73,6 @@ function(angular, _) {
dash.time = 0; dash.time = 0;
dash.refresh = 0; dash.refresh = 0;
dash.schemaVersion = 0; dash.schemaVersion = 0;
dash.editMode = false;
// filter row and panels properties that should be ignored // filter row and panels properties that should be ignored
dash.rows = _.filter(dash.rows, function(row) { dash.rows = _.filter(dash.rows, function(row) {
......
...@@ -155,7 +155,6 @@ function (angular, _, $, config) { ...@@ -155,7 +155,6 @@ function (angular, _, $, config) {
ctrl.editMode = false; ctrl.editMode = false;
ctrl.fullscreen = false; ctrl.fullscreen = false;
ctrl.dashboard.editMode = this.oldDashboardEditMode;
this.$scope.appEvent('panel-fullscreen-exit', {panelId: ctrl.panel.id}); this.$scope.appEvent('panel-fullscreen-exit', {panelId: ctrl.panel.id});
...@@ -177,10 +176,8 @@ function (angular, _, $, config) { ...@@ -177,10 +176,8 @@ function (angular, _, $, config) {
ctrl.editMode = this.state.edit && this.dashboard.meta.canEdit; ctrl.editMode = this.state.edit && this.dashboard.meta.canEdit;
ctrl.fullscreen = true; ctrl.fullscreen = true;
this.oldDashboardEditMode = this.dashboard.editMode;
this.oldTimeRange = ctrl.range; this.oldTimeRange = ctrl.range;
this.fullscreenPanel = panelScope; this.fullscreenPanel = panelScope;
this.dashboard.editMode = false;
$(window).scrollTop(0); $(window).scrollTop(0);
......
///<reference path="../../../headers/common.d.ts" />
import _ from 'lodash'; import _ from 'lodash';
import kbn from 'app/core/utils/kbn'; import kbn from 'app/core/utils/kbn';
...@@ -122,7 +120,7 @@ export class PrometheusDatasource { ...@@ -122,7 +120,7 @@ export class PrometheusDatasource {
} else { } else {
for (let metricData of response.data.data.result) { for (let metricData of response.data.data.result) {
if (response.data.data.resultType === 'matrix') { if (response.data.data.resultType === 'matrix') {
result.push(self.transformMetricData(metricData, activeTargets[index], start, end)); result.push(self.transformMetricData(metricData, activeTargets[index], start, end, queries[index].step));
} else if (response.data.data.resultType === 'vector') { } else if (response.data.data.resultType === 'vector') {
result.push(self.transformInstantMetricData(metricData, activeTargets[index])); result.push(self.transformInstantMetricData(metricData, activeTargets[index]));
} }
...@@ -144,7 +142,6 @@ export class PrometheusDatasource { ...@@ -144,7 +142,6 @@ export class PrometheusDatasource {
var intervalFactor = target.intervalFactor || 1; var intervalFactor = target.intervalFactor || 1;
// Adjust the interval to take into account any specified minimum and interval factor plus Prometheus limits // Adjust the interval to take into account any specified minimum and interval factor plus Prometheus limits
var adjustedInterval = this.adjustInterval(interval, minInterval, range, intervalFactor); var adjustedInterval = this.adjustInterval(interval, minInterval, range, intervalFactor);
var scopedVars = options.scopedVars; var scopedVars = options.scopedVars;
// If the interval was adjusted, make a shallow copy of scopedVars with updated interval vars // If the interval was adjusted, make a shallow copy of scopedVars with updated interval vars
if (interval !== adjustedInterval) { if (interval !== adjustedInterval) {
...@@ -154,7 +151,7 @@ export class PrometheusDatasource { ...@@ -154,7 +151,7 @@ export class PrometheusDatasource {
"__interval_ms": {text: interval * 1000, value: interval * 1000}, "__interval_ms": {text: interval * 1000, value: interval * 1000},
}); });
} }
target.step = query.step = interval; query.step = interval;
// Only replace vars in expression after having (possibly) updated interval vars // Only replace vars in expression after having (possibly) updated interval vars
query.expr = this.templateSrv.replace(target.expr, scopedVars, this.interpolateQueryExpr); query.expr = this.templateSrv.replace(target.expr, scopedVars, this.interpolateQueryExpr);
...@@ -272,13 +269,13 @@ export class PrometheusDatasource { ...@@ -272,13 +269,13 @@ export class PrometheusDatasource {
}); });
} }
transformMetricData(md, options, start, end) { transformMetricData(md, options, start, end, step) {
var dps = [], var dps = [],
metricLabel = null; metricLabel = null;
metricLabel = this.createMetricLabel(md.metric, options); metricLabel = this.createMetricLabel(md.metric, options);
var stepMs = parseInt(options.step) * 1000; var stepMs = step * 1000;
var baseTimestamp = start * 1000; var baseTimestamp = start * 1000;
for (let value of md.values) { for (let value of md.values) {
var dp_value = parseFloat(value[1]); var dp_value = parseFloat(value[1]);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment