Browse Source

Analytic units' fields are not saved to db #240 (#241)

master
rozetko 6 years ago committed by GitHub
parent
commit
aaed6c7dc6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      src/panel/graph_panel/controllers/analytic_controller.ts
  2. 2
      src/panel/graph_panel/models/analytic_unit.ts
  3. 14
      src/panel/graph_panel/services/analytic_service.ts
  4. 2
      tests/setup_tests.ts

2
src/panel/graph_panel/controllers/analytic_controller.ts

@ -106,7 +106,7 @@ export class AnalyticController {
async saveNew(metric: MetricExpanded, datasource: DatasourceRequest) { async saveNew(metric: MetricExpanded, datasource: DatasourceRequest) {
this._savingNewAnalyticUnit = true; this._savingNewAnalyticUnit = true;
this._newAnalyticUnit.id = await this._analyticService.postNewItem( this._newAnalyticUnit.id = await this._analyticService.postNewAnalyticUnit(
this._newAnalyticUnit, metric, datasource, this._grafanaUrl, this._panelId this._newAnalyticUnit, metric, datasource, this._grafanaUrl, this._panelId
); );
if(this._newAnalyticUnit.detectorType === 'threshold') { if(this._newAnalyticUnit.detectorType === 'threshold') {

2
src/panel/graph_panel/models/analytic_unit.ts

@ -52,7 +52,7 @@ export class AnalyticUnit {
alert: false, alert: false,
id: null, id: null,
visible: true visible: true
} };
if(_serverObject === undefined) { if(_serverObject === undefined) {
this._serverObject = defaults; this._serverObject = defaults;

14
src/panel/graph_panel/services/analytic_service.ts

@ -53,8 +53,8 @@ export class AnalyticService {
return this.patch('/threshold', threshold); return this.patch('/threshold', threshold);
} }
async postNewItem( async postNewAnalyticUnit(
newItem: AnalyticUnit, analyticUnit: AnalyticUnit,
metric: MetricExpanded, metric: MetricExpanded,
datasource: DatasourceRequest, datasource: DatasourceRequest,
grafanaUrl: string, grafanaUrl: string,
@ -63,8 +63,14 @@ export class AnalyticService {
const response = await this.post('/analyticUnits', { const response = await this.post('/analyticUnits', {
grafanaUrl, grafanaUrl,
panelId, panelId,
type: newItem.type, // TODO: serialize analytic unit
name: newItem.name, name: analyticUnit.name,
type: analyticUnit.type,
alert: analyticUnit.alert,
labeledColor: analyticUnit.labeledColor,
deletedColor: analyticUnit.deletedColor,
detectorType: analyticUnit.detectorType,
visible: analyticUnit.visible,
metric: metric.toJSON(), metric: metric.toJSON(),
datasource datasource
}); });

2
tests/setup_tests.ts

@ -17,7 +17,7 @@ function $http() {
} }
const analyticService = new AnalyticService('', $http); const analyticService = new AnalyticService('', $http);
analyticService.postNewItem = async function ( analyticService.postNewAnalyticUnit = async function (
newItem: AnalyticUnit, metric: MetricExpanded, newItem: AnalyticUnit, metric: MetricExpanded,
datasource: DatasourceRequest, panelUrl: string datasource: DatasourceRequest, panelUrl: string
): Promise<AnalyticUnitId> { ): Promise<AnalyticUnitId> {

Loading…
Cancel
Save