Merge pull request #107 from flant/fix_edit_mode_render_for_g7

fix: render buckets in edit mode for Grafana 7.0
This commit is contained in:
Ivan Mikheykin
2020-07-03 13:25:14 +03:00
committed by GitHub
3 changed files with 54 additions and 37 deletions
+27 -17
View File
@@ -513,27 +513,38 @@ System.register(["lodash", "./color_legend", "app/core/utils/kbn", "app/plugins/
value: function onDataReceived(dataList) { value: function onDataReceived(dataList) {
var _this3 = this; var _this3 = this;
//console.log("data",dataList) this.data = dataList; // Quick workaround for 7.0+. There is no call to
this.data = dataList; // calculateInterval when enter Edit mode.
if (!this.intervalMs) {
this.calculateInterval();
}
this.bucketMatrix = this.convertDataToBuckets(dataList, this.range.from.valueOf(), this.range.to.valueOf(), this.intervalMs, true); this.bucketMatrix = this.convertDataToBuckets(dataList, this.range.from.valueOf(), this.range.to.valueOf(), this.intervalMs, true);
this.noDatapoints = this.bucketMatrix.noDatapoints; //console.log("buckets",this.bucketMatrix) this.noDatapoints = this.bucketMatrix.noDatapoints;
this.annotationsPromise.then(function (result) { if (this.annotationsPromise) {
_this3.loading = false; //this.alertState = result.alertState; this.annotationsPromise.then(function (result) {
_this3.loading = false; //this.alertState = result.alertState;
if (result.annotations && result.annotations.length > 0) { if (result.annotations && result.annotations.length > 0) {
_this3.annotations = result.annotations; _this3.annotations = result.annotations;
} else { } else {
_this3.annotations = [];
}
_this3.render();
}, function () {
_this3.loading = false;
_this3.annotations = []; _this3.annotations = [];
}
_this3.render(); _this3.render();
}, function () { });
_this3.loading = false; } else {
_this3.annotations = []; this.loading = false;
this.annotations = [];
_this3.render(); this.render();
}); }
} }
}, { }, {
key: "onInitEditMode", key: "onInitEditMode",
@@ -546,7 +557,6 @@ System.register(["lodash", "./color_legend", "app/core/utils/kbn", "app/plugins/
}, { }, {
key: "onRender", key: "onRender",
value: function onRender() { value: function onRender() {
//console.log('OnRender');
if (!this.range || !this.data) { if (!this.range || !this.data) {
this.noDatapoints = true; this.noDatapoints = true;
return; return;
+1 -1
View File
File diff suppressed because one or more lines are too long
+26 -19
View File
@@ -366,30 +366,38 @@ class StatusHeatmapCtrl extends MetricsPanelCtrl {
onDataReceived(dataList: any) { onDataReceived(dataList: any) {
//console.log("data",dataList)
this.data = dataList; this.data = dataList;
// Quick workaround for 7.0+. There is no call to
// calculateInterval when enter Edit mode.
if (!this.intervalMs) {
this.calculateInterval();
}
this.bucketMatrix = this.convertDataToBuckets(dataList, this.range.from.valueOf(), this.range.to.valueOf(), this.intervalMs, true); this.bucketMatrix = this.convertDataToBuckets(dataList, this.range.from.valueOf(), this.range.to.valueOf(), this.intervalMs, true);
this.noDatapoints = this.bucketMatrix.noDatapoints; this.noDatapoints = this.bucketMatrix.noDatapoints;
//console.log("buckets",this.bucketMatrix) if (this.annotationsPromise) {
this.annotationsPromise.then(
this.annotationsPromise.then( (result: { alertState: any; annotations: any }) => {
(result: { alertState: any; annotations: any }) => { this.loading = false;
this.loading = false; //this.alertState = result.alertState;
//this.alertState = result.alertState; if (result.annotations && result.annotations.length > 0) {
if (result.annotations && result.annotations.length > 0) { this.annotations = result.annotations;
this.annotations = result.annotations; } else {
} else { this.annotations = [];
}
this.render();
},
() => {
this.loading = false;
this.annotations = []; this.annotations = [];
this.render();
} }
this.render(); );
}, } else {
() => { this.loading = false;
this.loading = false; this.annotations = [];
this.annotations = []; this.render();
this.render(); }
}
);
} }
onInitEditMode() { onInitEditMode() {
@@ -400,7 +408,6 @@ class StatusHeatmapCtrl extends MetricsPanelCtrl {
// onRender will be called before StatusmapRenderer.onRender. // onRender will be called before StatusmapRenderer.onRender.
// Decide if warning should be displayed over cards. // Decide if warning should be displayed over cards.
onRender() { onRender() {
//console.log('OnRender');
if (!this.range || !this.data) { if (!this.range || !this.data) {
this.noDatapoints = true; this.noDatapoints = true;
return; return;