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

4
src/partials/tab_analytics.html

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

Loading…
Cancel
Save