Browse Source

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

master
sanke1 6 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;
private _analyticUnitTypes: any;
panelDefaults = {
// datasource name, null = default datasource
datasource: null,
@ -137,14 +139,6 @@ class GraphCtrl extends MetricsPanelCtrl {
seriesOverrides: [],
thresholds: [],
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 */
@ -168,6 +162,8 @@ class GraphCtrl extends MetricsPanelCtrl {
this.analyticService = new AnalyticService(this.backendURL, $http, this.backendSrv, this.alertSrv);
this.updateAnalyticUnitTypes();
this.runBackendConnectivityCheck();
this.analyticsController = new AnalyticController(this.panel, this.analyticService, this.events);
@ -219,6 +215,15 @@ class GraphCtrl extends MetricsPanelCtrl {
return val;
}
async updateAnalyticUnitTypes(){
const analyticUnitTypes = await this.analyticService.getAnalyticUnitTypes();
this._analyticUnitTypes = analyticUnitTypes;
}
get analyticUnitTypes() {
return this._analyticUnitTypes;
}
async runBackendConnectivityCheck() {
if(this.backendURL === '' || this.backendURL === undefined) {
this.alertSrv.set(

4
src/partials/tab_analytics.html

@ -22,7 +22,7 @@
<div class="gf-form-select-wrapper">
<select class="gf-form-input width-12"
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"
/>
</div>
@ -118,7 +118,7 @@
<div class="gf-form-select-wrapper">
<select class="gf-form-input width-12"
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>

4
src/services/analytic_service.ts

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

Loading…
Cancel
Save