Browse Source

"Export analytic units" button (#403)

master
rozetko 4 years ago committed by GitHub
parent
commit
a85326f17e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      src/panel/graph_panel/controllers/analytic_controller.ts
  2. 11
      src/panel/graph_panel/graph_ctrl.ts
  3. 8
      src/panel/graph_panel/services/analytic_service.ts

4
src/panel/graph_panel/controllers/analytic_controller.ts

@ -115,6 +115,10 @@ export class AnalyticController {
this._creatingNewAnalyticUnit = false; this._creatingNewAnalyticUnit = false;
} }
async exportAnalyticUnits(): Promise<object> {
return this._analyticService.exportAnalyticUnits(this._panelId);
}
async saveNew(metric: MetricExpanded, datasource: DatasourceRequest) { async saveNew(metric: MetricExpanded, datasource: DatasourceRequest) {
this._savingNewAnalyticUnit = true; this._savingNewAnalyticUnit = true;
const newAnalyticUnit = createAnalyticUnit(this._newAnalyticUnit.toJSON()); const newAnalyticUnit = createAnalyticUnit(this._newAnalyticUnit.toJSON());

11
src/panel/graph_panel/graph_ctrl.ts

@ -302,9 +302,10 @@ class GraphCtrl extends MetricsPanelCtrl {
this.subTabIndex = 0; this.subTabIndex = 0;
} }
onInitPanelActions(actions) { onInitPanelActions(actions: { text: string, click: string }[]): void {
actions.push({ text: 'Export CSV', click: 'ctrl.exportCsv()' }); actions.push({ text: 'Export CSV', click: 'ctrl.exportCsv()' });
actions.push({ text: 'Toggle legend', click: 'ctrl.toggleLegend()' }); actions.push({ text: 'Toggle legend', click: 'ctrl.toggleLegend()' });
actions.push({ text: 'Export analytic units', click: 'ctrl.exportAnalyticUnits()' });
} }
async onHasticDatasourceChange() { async onHasticDatasourceChange() {
@ -552,6 +553,14 @@ class GraphCtrl extends MetricsPanelCtrl {
}); });
} }
async exportAnalyticUnits(): Promise<void> {
const json = await this.analyticsController.exportAnalyticUnits();
this.publishAppEvent('show-modal', {
src: 'public/app/partials/edit_json.html',
model: { object: json, enableCopy: true }
});
}
// getAnnotationsByTag(tag) { // getAnnotationsByTag(tag) {
// var res = []; // var res = [];
// for (var annotation of this.annotations) { // for (var annotation of this.annotations) {

8
src/panel/graph_panel/services/analytic_service.ts

@ -61,6 +61,14 @@ export class AnalyticService {
return resp.analyticUnits; return resp.analyticUnits;
} }
async exportAnalyticUnits(panelId: string): Promise<object> {
const resp = await this.get('/panels/template', { panelId });
if(resp === undefined) {
return {};
}
return resp;
}
async postNewAnalyticUnit( async postNewAnalyticUnit(
analyticUnit: AnalyticUnit, analyticUnit: AnalyticUnit,
metric: MetricExpanded, metric: MetricExpanded,

Loading…
Cancel
Save