|
|
@ -33,9 +33,11 @@ class GraphCtrl extends MetricsPanelCtrl { |
|
|
|
dataList: any = []; |
|
|
|
dataList: any = []; |
|
|
|
// annotations: any = [];
|
|
|
|
// annotations: any = [];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private _datasourceRequest: DatasourceRequest; |
|
|
|
|
|
|
|
private _datasources: any;
|
|
|
|
|
|
|
|
|
|
|
|
_panelPath: any; |
|
|
|
private _panelPath: any; |
|
|
|
_renderError: boolean = false; |
|
|
|
private _renderError: boolean = false; |
|
|
|
|
|
|
|
|
|
|
|
// annotationsPromise: any;
|
|
|
|
// annotationsPromise: any;
|
|
|
|
dataWarning: any; |
|
|
|
dataWarning: any; |
|
|
@ -43,8 +45,6 @@ class GraphCtrl extends MetricsPanelCtrl { |
|
|
|
subTabIndex: number; |
|
|
|
subTabIndex: number; |
|
|
|
processor: DataProcessor; |
|
|
|
processor: DataProcessor; |
|
|
|
|
|
|
|
|
|
|
|
datasourceRequest: DatasourceRequest; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
analyticsController: AnalyticController; |
|
|
|
analyticsController: AnalyticController; |
|
|
|
|
|
|
|
|
|
|
|
_graphRenderer: GraphRenderer; |
|
|
|
_graphRenderer: GraphRenderer; |
|
|
@ -186,10 +186,12 @@ class GraphCtrl extends MetricsPanelCtrl { |
|
|
|
this.$scope.$digest(); |
|
|
|
this.$scope.$digest(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this._datasources = {}; |
|
|
|
|
|
|
|
|
|
|
|
appEvents.on('ds-request-response', data => { |
|
|
|
appEvents.on('ds-request-response', data => { |
|
|
|
let requestConfig = data.config; |
|
|
|
let requestConfig = data.config; |
|
|
|
|
|
|
|
|
|
|
|
this.datasourceRequest = { |
|
|
|
this._datasourceRequest = { |
|
|
|
url: requestConfig.url, |
|
|
|
url: requestConfig.url, |
|
|
|
method: requestConfig.method, |
|
|
|
method: requestConfig.method, |
|
|
|
data: requestConfig.data, |
|
|
|
data: requestConfig.data, |
|
|
@ -220,7 +222,7 @@ class GraphCtrl extends MetricsPanelCtrl { |
|
|
|
return this._analyticUnitTypes; |
|
|
|
return this._analyticUnitTypes; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
get analyticUnitDetectorTypes () { |
|
|
|
get analyticUnitDetectorTypes() { |
|
|
|
return _.keys(this._analyticUnitTypes); |
|
|
|
return _.keys(this._analyticUnitTypes); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -503,13 +505,11 @@ class GraphCtrl extends MetricsPanelCtrl { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
async saveNew() { |
|
|
|
async saveNew() { |
|
|
|
this.refresh(); |
|
|
|
|
|
|
|
try { |
|
|
|
try { |
|
|
|
await this.analyticsController.saveNew( |
|
|
|
const panelId = this.panel.id; |
|
|
|
new MetricExpanded(this.panel.datasource, this.panel.targets), |
|
|
|
const panelUrl = window.location.origin + window.location.pathname + `?panelId=${panelId}`; |
|
|
|
this.datasourceRequest, |
|
|
|
|
|
|
|
this.panel.id |
|
|
|
await this.analyticsController.saveNew(panelUrl); |
|
|
|
); |
|
|
|
|
|
|
|
} catch(e) { |
|
|
|
} catch(e) { |
|
|
|
this.alertSrv.set( |
|
|
|
this.alertSrv.set( |
|
|
|
'Error while saving analytic unit', |
|
|
|
'Error while saving analytic unit', |
|
|
@ -541,7 +541,7 @@ class GraphCtrl extends MetricsPanelCtrl { |
|
|
|
this.render(); |
|
|
|
this.render(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
onCancelLabeling(key) { |
|
|
|
onCancelLabeling(id: AnalyticUnitId) { |
|
|
|
this.$scope.$root.appEvent('confirm-modal', { |
|
|
|
this.$scope.$root.appEvent('confirm-modal', { |
|
|
|
title: 'Clear anomaly labeling', |
|
|
|
title: 'Clear anomaly labeling', |
|
|
|
text2: 'Your changes will be lost.', |
|
|
|
text2: 'Your changes will be lost.', |
|
|
@ -549,7 +549,7 @@ class GraphCtrl extends MetricsPanelCtrl { |
|
|
|
icon: 'fa-warning', |
|
|
|
icon: 'fa-warning', |
|
|
|
altActionText: 'Save', |
|
|
|
altActionText: 'Save', |
|
|
|
onAltAction: () => { |
|
|
|
onAltAction: () => { |
|
|
|
this.onToggleLabelingMode(key); |
|
|
|
this.onToggleLabelingMode(id); |
|
|
|
}, |
|
|
|
}, |
|
|
|
onConfirm: () => { |
|
|
|
onConfirm: () => { |
|
|
|
this.analyticsController.undoLabeling(); |
|
|
|
this.analyticsController.undoLabeling(); |
|
|
@ -558,8 +558,11 @@ class GraphCtrl extends MetricsPanelCtrl { |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
async onToggleLabelingMode(key) { |
|
|
|
async onToggleLabelingMode(id: AnalyticUnitId) { |
|
|
|
await this.analyticsController.toggleUnitTypeLabelingMode(key as AnalyticUnitId); |
|
|
|
this.refresh(); |
|
|
|
|
|
|
|
const datasource = await this._getDatasourceRequest(); |
|
|
|
|
|
|
|
const metric = new MetricExpanded(this.panel.datasource, this.panel.targets); |
|
|
|
|
|
|
|
await this.analyticsController.toggleUnitTypeLabelingMode(id, metric, datasource); |
|
|
|
this.$scope.$digest(); |
|
|
|
this.$scope.$digest(); |
|
|
|
this.render(); |
|
|
|
this.render(); |
|
|
|
} |
|
|
|
} |
|
|
@ -578,13 +581,30 @@ class GraphCtrl extends MetricsPanelCtrl { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private async _updatePanelInfo() { |
|
|
|
private async _updatePanelInfo() { |
|
|
|
const datasource = await this.backendSrv.get(`/api/datasources/name/${this.panel.datasource}`); |
|
|
|
const datasource = await this._getDatasourceByName(this.panel.datasource); |
|
|
|
|
|
|
|
|
|
|
|
this._panelInfo = { |
|
|
|
this._panelInfo = { |
|
|
|
grafanaVersion: this.contextSrv.version, |
|
|
|
grafanaVersion: this.contextSrv.version, |
|
|
|
grafanaUrl: window.location.host, |
|
|
|
grafanaUrl: window.location.host, |
|
|
|
datasourceType: datasource.type, |
|
|
|
datasourceType: datasource.type, |
|
|
|
hasticServerUrl: this.backendURL |
|
|
|
hasticServerUrl: this.backendURL |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private async _getDatasourceRequest() { |
|
|
|
|
|
|
|
if(this._datasourceRequest.type === undefined) { |
|
|
|
|
|
|
|
const datasource = await this._getDatasourceByName(this.panel.datasource); |
|
|
|
|
|
|
|
this._datasourceRequest.type = datasource.type; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return this._datasourceRequest; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private async _getDatasourceByName(name: string) { |
|
|
|
|
|
|
|
if(this._datasources[name] === undefined) { |
|
|
|
|
|
|
|
const datasource = await this.backendSrv.get(`/api/datasources/name/${name}`); |
|
|
|
|
|
|
|
return datasource; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
return this._datasources[name]; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|