Browse Source

Move analytic unit types to panel.json (#60)

master
sanke1 6 years ago committed by rozetko
parent
commit
b05fb676b7
  1. 28
      src/module.ts
  2. 4
      src/partials/tab_analytics.html

28
src/module.ts

@ -26,14 +26,6 @@ const BACKEND_VARIABLE_NAME = 'HASTIC_SERVER_URL';
class GraphCtrl extends MetricsPanelCtrl {
static template = template;
ANALYTIC_TYPES: Array<{name: string, value: string}> = [
{ name: 'General', value: 'GENERAL' },
{ name: 'Peaks', value: 'PEAK' },
{ name: 'Troughs', value: 'TROUGH' },
{ name: 'Jumps', value: 'JUMP' },
{ name: 'Drops', value: 'DROP' },
{ name: 'Custom', value: 'CUSTOM' }
];
hiddenSeries: any = {};
seriesList: any = [];
@ -51,7 +43,7 @@ class GraphCtrl extends MetricsPanelCtrl {
processor: DataProcessor;
datasourceRequest: DatasourceRequest;
anomalyTypes = []; // TODO: remove it later. Only for alert tab
analyticsController: AnalyticController;
@ -141,6 +133,14 @@ 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 */
@ -159,9 +159,9 @@ class GraphCtrl extends MetricsPanelCtrl {
this.processor = new DataProcessor(this.panel);
var anomalyService = new AnalyticService(this.backendURL, backendSrv as BackendSrv);
this.runBackendConnectivityCheck();
this.analyticsController = new AnalyticController(this.panel, anomalyService, this.events);
@ -212,8 +212,8 @@ class GraphCtrl extends MetricsPanelCtrl {
async runBackendConnectivityCheck() {
if(this.backendURL === '' || this.backendURL === undefined) {
this.alertSrv.set(
`Dashboard variable $${BACKEND_VARIABLE_NAME} is missing`,
`Please set $${BACKEND_VARIABLE_NAME}`,
`Dashboard variable $${BACKEND_VARIABLE_NAME} is missing`,
`Please set $${BACKEND_VARIABLE_NAME}`,
'warning', 4000
);
return;
@ -225,7 +225,7 @@ class GraphCtrl extends MetricsPanelCtrl {
this.alertSrv.set(
'Can`t connect to Hastic server', `Hastic server: "${this.backendURL}"`, 'warning', 4000
);
}
}
}
link(scope, elem, attrs, ctrl) {

4
src/partials/tab_analytics.html

@ -13,7 +13,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.ANALYTIC_TYPES"
ng-options="type.value as type.name for type in ctrl.panel.analyticUnitTypes"
ng-disabled="true"
/>
</div>
@ -127,7 +127,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.ANALYTIC_TYPES"
ng-options="type.value as type.name for type in ctrl.panel.analyticUnitTypes"
/>
</div>

Loading…
Cancel
Save