Browse Source

basic name fetch

master
Coin de Gamma 6 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); 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() { async updateThresholds() {
const ids = _.map(this._panelObject.analyticUnits, (analyticUnit: any) => analyticUnit.id); const ids = _.map(this._panelObject.analyticUnits, (analyticUnit: any) => analyticUnit.id);
const thresholds = await this._analyticService.getThresholds(ids); const thresholds = await this._analyticService.getThresholds(ids);

9
src/module.ts

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

2
src/partials/tab_analytics.html

@ -15,7 +15,7 @@
<input <input
type="text" class="gf-form-input max-width-15" type="text" class="gf-form-input max-width-15"
ng-model="analyticUnit.name" ng-model="analyticUnit.name"
ng-disabled="true" ng-change="ctrl.onAnalyticUnitNameChange(analyticUnit)"
> >
<label class="gf-form-label width-8"> Type </label> <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) { private async _analyticRequest(method: string, url: string, data?: any) {
try { try {
method = method.toUpperCase(); method = method.toUpperCase();

Loading…
Cancel
Save