Browse Source

Choose pattern type in hastic panel (#5)

* add pattern field to anomaly type

* select pattern type in editor
master
rozetko 7 years ago committed by Alexey Velikiy
parent
commit
9f4f3739af
  1. 5
      src/model/anomaly.ts
  2. 1
      src/module.ts
  3. 5
      src/partials/tab_analytics.html
  4. 3
      src/services/anomaly_service.ts

5
src/model/anomaly.ts

@ -35,7 +35,7 @@ export class AnomalyType {
this._panelObject = {}; this._panelObject = {};
} }
_.defaults(this._panelObject, { _.defaults(this._panelObject, {
name: 'anomaly_name', confidence: 0.2, color: 'red' name: 'anomaly_name', confidence: 0.2, color: 'red', pattern: 'Peaks'
}); });
//this._metric = new Metric(_panelObject.metric); //this._metric = new Metric(_panelObject.metric);
@ -46,6 +46,9 @@ export class AnomalyType {
set name(value: string) { this._panelObject.name = value; } set name(value: string) { this._panelObject.name = value; }
get name(): string { return this._panelObject.name; } get name(): string { return this._panelObject.name; }
set pattern(value: string) { this._panelObject.pattern = value; }
get pattern(): string { return this._panelObject.pattern; }
set confidence(value: number) { this._panelObject.confidence = value; } set confidence(value: number) { this._panelObject.confidence = value; }
get confidence(): number { return this._panelObject.confidence; } get confidence(): number { return this._panelObject.confidence; }

1
src/module.ts

@ -43,6 +43,7 @@ class GraphCtrl extends MetricsPanelCtrl {
datasourceRequest: DatasourceRequest; datasourceRequest: DatasourceRequest;
analyticsTypes: Array<String> = ['Anomaly detection', 'Pattern Detection (not implemented yet)']; analyticsTypes: Array<String> = ['Anomaly detection', 'Pattern Detection (not implemented yet)'];
patterns: Array<String> = ['Peaks', 'Jumps', 'Drops', 'General approach'];
anomalyTypes = []; // TODO: remove it later. Only for alert tab anomalyTypes = []; // TODO: remove it later. Only for alert tab
anomalyController: AnomalyController; anomalyController: AnomalyController;

5
src/partials/tab_analytics.html

@ -130,6 +130,11 @@
ng-change="ctrl.onAnomalyNameChange()" ng-change="ctrl.onAnomalyNameChange()"
> >
<label class="gf-form-label width-8"> Pattern type </label>
<div class="gf-form-select-wrapper">
<select class="gf-form-input width-12" ng-model="ctrl.anomalyController.newAnomalyType.pattern" ng-options="pattern as pattern for pattern in ctrl.patterns"/>
</div>
<label class="gf-form-label"> <label class="gf-form-label">
<a class="pointer" tabindex="1" ng-click="ctrl.saveAnomalyType()"> <a class="pointer" tabindex="1" ng-click="ctrl.saveAnomalyType()">
<b ng-if="!ctrl.anomalyController.savingAnomalyType"> create </b> <b ng-if="!ctrl.anomalyController.savingAnomalyType"> create </b>

3
src/services/anomaly_service.ts

@ -19,7 +19,8 @@ export class AnomalyService {
name: newAnomalyType.name, name: newAnomalyType.name,
metric: metric.toJSON(), metric: metric.toJSON(),
panelUrl: window.location.origin + window.location.pathname + `?panelId=${panelId}&fullscreen`, panelUrl: window.location.origin + window.location.pathname + `?panelId=${panelId}&fullscreen`,
datasource: datasourceRequest datasource: datasourceRequest,
pattern: newAnomalyType.pattern
} }
) )
}; };

Loading…
Cancel
Save