more work on annotations

This commit is contained in:
Torkel Ödegaard
2017-04-14 12:23:32 +02:00
parent dbe5480edc
commit ff426ae9a3
6 changed files with 36 additions and 25 deletions

View File

@@ -135,6 +135,7 @@ export class AnnotationsSrv {
}
saveAnnotationEvent(annotation) {
this.globalAnnotationsPromise = null;
return this.backendSrv.post('/api/annotations', annotation);
}

View File

@@ -2,7 +2,7 @@
import _ from 'lodash';
import moment from 'moment';
import coreModule from 'app/core/core_module';
import {coreModule} from 'app/core/core';
import {MetricsPanelCtrl} from 'app/plugins/sdk';
export class AnnotationEvent {
@@ -20,13 +20,13 @@ export class EventEditorCtrl {
annotation: AnnotationEvent;
timeRange: {from: number, to: number};
form: any;
close: any;
/** @ngInject **/
constructor(private annotationsSrv) {
this.annotation = new AnnotationEvent();
this.annotation.panelId = this.panelCtrl.panel.id;
this.annotation.dashboardId = this.panelCtrl.dashboard.id;
this.annotation.text = "hello";
this.annotation.time = moment(this.timeRange.from);
if (this.timeRange.to) {
@@ -51,7 +51,10 @@ export class EventEditorCtrl {
return;
}
this.annotationsSrv.saveAnnotationEvent(saveModel);
this.annotationsSrv.saveAnnotationEvent(saveModel).then(() => {
this.panelCtrl.refresh();
this.close();
});
}
}
@@ -65,7 +68,7 @@ export function eventEditor() {
scope: {
"panelCtrl": "=",
"timeRange": "=",
"cancel": "&",
"close": "&",
}
};
}

View File

@@ -32,7 +32,7 @@
<div class="gf-form-button-row">
<button type="submit" class="btn gf-form-btn btn-success" ng-click="ctrl.save()">Save</button>
<a class="btn-text" ng-click="ctrl.cancel();">Cancel</a>
<a class="btn-text" ng-click="ctrl.close();">Cancel</a>
</div>
</div>
</form>