Browse Source

basic name fetch

master
Coin de Gamma 5 years ago
parent
commit
188bb2ec73
  1. 8
      src/controllers/analytic_controller.ts
  2. 9
      src/module.ts
  3. 2
      src/partials/tab_analytics.html
  4. 5
      src/services/analytic_service.ts

8
src/controllers/analytic_controller.ts

@ -350,6 +350,14 @@ export class AnalyticController {
await this._analyticService.setAnalyticUnitAlert(analyticUnit);
}
async fetchAnalyticUnitName(analyticUnit: AnalyticUnit) {
let updateObj = {
id: analyticUnit.id,
name: analyticUnit.name
}
await this._analyticService.updateAnalyticUnit(analyticUnit.id, updateObj);
}
async updateThresholds() {
const ids = _.map(this._panelObject.analyticUnits, (analyticUnit: any) => analyticUnit.id);
const thresholds = await this._analyticService.getThresholds(ids);

9
src/module.ts

@ -135,8 +135,7 @@ class GraphCtrl extends MetricsPanelCtrl {
aliasColors: {},
// other style overrides
seriesOverrides: [],
thresholds: [],
anomalyType: '',
thresholds: []
};
/** @ngInject */
@ -531,6 +530,10 @@ class GraphCtrl extends MetricsPanelCtrl {
this.analyticsController.toggleAnalyticUnitAlert(analyticUnit);
}
onAnalyticUnitNameChange(analyticUnit: AnalyticUnit) {
this.analyticsController.fetchAnalyticUnitName(analyticUnit);
}
onColorChange(id: AnalyticUnitId, value: string) {
if(id === undefined) {
throw new Error('id is undefined');
@ -549,7 +552,7 @@ class GraphCtrl extends MetricsPanelCtrl {
onCancelLabeling(id: AnalyticUnitId) {
this.$scope.$root.appEvent('confirm-modal', {
title: 'Clear anomaly labeling',
title: 'Clear labeling',
text2: 'Your changes will be lost.',
yesText: 'Clear',
icon: 'fa-warning',

2
src/partials/tab_analytics.html

@ -15,7 +15,7 @@
<input
type="text" class="gf-form-input max-width-15"
ng-model="analyticUnit.name"
ng-disabled="true"
ng-change="ctrl.onAnalyticUnitNameChange(analyticUnit)"
>
<label class="gf-form-label width-8"> Type </label>

5
src/services/analytic_service.ts

@ -156,6 +156,11 @@ export class AnalyticService {
});
}
async updateAnalyticUnit(id: AnalyticUnitId, updateObj: any) {
updateObj.id = id;
return this.patch('/analyticUnits', updateObj);
}
private async _analyticRequest(method: string, url: string, data?: any) {
try {
method = method.toUpperCase();

Loading…
Cancel
Save