Browse Source

Get analytic unit types from server #112 (#116)

master
sanke1 5 years ago committed by rozetko
parent
commit
8604e66b45
  1. 21
      src/module.ts
  2. 4
      src/partials/tab_analytics.html
  3. 4
      src/services/analytic_service.ts

21
src/module.ts

@ -54,6 +54,8 @@ class GraphCtrl extends MetricsPanelCtrl {
_panelInfo: PanelInfo; _panelInfo: PanelInfo;
private _analyticUnitTypes: any;
panelDefaults = { panelDefaults = {
// datasource name, null = default datasource // datasource name, null = default datasource
datasource: null, datasource: null,
@ -137,14 +139,6 @@ class GraphCtrl extends MetricsPanelCtrl {
seriesOverrides: [], seriesOverrides: [],
thresholds: [], thresholds: [],
anomalyType: '', anomalyType: '',
analyticUnitTypes: [
{ name: 'General', value: 'GENERAL' },
{ name: 'Peaks', value: 'PEAK' },
{ name: 'Troughs', value: 'TROUGH' },
{ name: 'Jumps', value: 'JUMP' },
{ name: 'Drops', value: 'DROP' },
{ name: 'Custom', value: 'CUSTOM' }
]
}; };
/** @ngInject */ /** @ngInject */
@ -168,6 +162,8 @@ class GraphCtrl extends MetricsPanelCtrl {
this.analyticService = new AnalyticService(this.backendURL, $http, this.backendSrv, this.alertSrv); this.analyticService = new AnalyticService(this.backendURL, $http, this.backendSrv, this.alertSrv);
this.updateAnalyticUnitTypes();
this.runBackendConnectivityCheck(); this.runBackendConnectivityCheck();
this.analyticsController = new AnalyticController(this.panel, this.analyticService, this.events); this.analyticsController = new AnalyticController(this.panel, this.analyticService, this.events);
@ -219,6 +215,15 @@ class GraphCtrl extends MetricsPanelCtrl {
return val; return val;
} }
async updateAnalyticUnitTypes(){
const analyticUnitTypes = await this.analyticService.getAnalyticUnitTypes();
this._analyticUnitTypes = analyticUnitTypes;
}
get analyticUnitTypes() {
return this._analyticUnitTypes;
}
async runBackendConnectivityCheck() { async runBackendConnectivityCheck() {
if(this.backendURL === '' || this.backendURL === undefined) { if(this.backendURL === '' || this.backendURL === undefined) {
this.alertSrv.set( this.alertSrv.set(

4
src/partials/tab_analytics.html

@ -22,7 +22,7 @@
<div class="gf-form-select-wrapper"> <div class="gf-form-select-wrapper">
<select class="gf-form-input width-12" <select class="gf-form-input width-12"
ng-model="analyticUnit.type" ng-model="analyticUnit.type"
ng-options="type.value as type.name for type in ctrl.panel.analyticUnitTypes" ng-options="type.value as type.name for type in ctrl.analyticUnitTypes.pattern"
ng-disabled="true" ng-disabled="true"
/> />
</div> </div>
@ -118,7 +118,7 @@
<div class="gf-form-select-wrapper"> <div class="gf-form-select-wrapper">
<select class="gf-form-input width-12" <select class="gf-form-input width-12"
ng-model="ctrl.analyticsController.newAnalyticUnit.type" ng-model="ctrl.analyticsController.newAnalyticUnit.type"
ng-options="type.value as type.name for type in ctrl.panel.analyticUnitTypes" ng-options="type.value as type.name for type in ctrl.analyticUnitTypes.pattern"
/> />
</div> </div>

4
src/services/analytic_service.ts

@ -20,6 +20,10 @@ export class AnalyticService {
this.isBackendOk(); this.isBackendOk();
} }
async getAnalyticUnitTypes() {
return await this.get('/analyticUnits/types');
}
async postNewItem( async postNewItem(
metric: MetricExpanded, datasourceRequest: DatasourceRequest, metric: MetricExpanded, datasourceRequest: DatasourceRequest,
newItem: AnalyticUnit, panelId: number newItem: AnalyticUnit, panelId: number

Loading…
Cancel
Save