|
|
|
@ -10,6 +10,7 @@ export class AddAnnotationModalCtrl { |
|
|
|
|
annotationTitle: string; |
|
|
|
|
annotationTextFrom: string; |
|
|
|
|
annotationTextTo: string; |
|
|
|
|
annotation: any; |
|
|
|
|
graphCtrl: any; |
|
|
|
|
|
|
|
|
|
/** @ngInject */ |
|
|
|
@ -17,39 +18,30 @@ export class AddAnnotationModalCtrl { |
|
|
|
|
this.graphCtrl = $scope.ctrl; |
|
|
|
|
$scope.ctrl = this; |
|
|
|
|
|
|
|
|
|
this.annotationTimeFrom = moment($scope.annotationTimeRange.from).format(this.annotationTimeFormat); |
|
|
|
|
if ($scope.annotationTimeRange.to) { |
|
|
|
|
this.annotationTimeTo = moment($scope.annotationTimeRange.to).format(this.annotationTimeFormat); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
addAnnotation() { |
|
|
|
|
let dashboardId = this.graphCtrl.dashboard.id; |
|
|
|
|
let panelId = this.graphCtrl.panel.id; |
|
|
|
|
let timeFrom = moment(this.annotationTimeFrom, this.annotationTimeFormat).valueOf(); |
|
|
|
|
|
|
|
|
|
let annotationFrom = { |
|
|
|
|
this.annotation = { |
|
|
|
|
dashboardId: dashboardId, |
|
|
|
|
panelId: panelId, |
|
|
|
|
time: timeFrom, |
|
|
|
|
title: this.annotationTitle, |
|
|
|
|
text: this.annotationTextFrom |
|
|
|
|
time: null, |
|
|
|
|
timeTo: null, |
|
|
|
|
title: "", |
|
|
|
|
text: "" |
|
|
|
|
}; |
|
|
|
|
let annotations = [annotationFrom]; |
|
|
|
|
|
|
|
|
|
if (this.annotationTimeTo) { |
|
|
|
|
let timeTo = moment(this.annotationTimeTo, this.annotationTimeFormat).valueOf(); |
|
|
|
|
let annotationTo = { |
|
|
|
|
dashboardId: dashboardId, |
|
|
|
|
panelId: panelId, |
|
|
|
|
time: timeTo, |
|
|
|
|
title: this.annotationTitle, |
|
|
|
|
text: this.annotationTextTo |
|
|
|
|
}; |
|
|
|
|
annotations.push(annotationTo); |
|
|
|
|
this.annotation.time = moment($scope.annotationTimeRange.from).format(this.annotationTimeFormat); |
|
|
|
|
if ($scope.annotationTimeRange.to) { |
|
|
|
|
this.annotation.timeTo = moment($scope.annotationTimeRange.to).format(this.annotationTimeFormat); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
addAnnotation() { |
|
|
|
|
this.annotation.time = moment(this.annotation.time, this.annotationTimeFormat).valueOf(); |
|
|
|
|
if (this.annotation.timeTo) { |
|
|
|
|
this.annotation.timeTo = moment(this.annotation.timeTo, this.annotationTimeFormat).valueOf(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
this.graphCtrl.pushAnnotations(annotations) |
|
|
|
|
this.graphCtrl.pushAnnotation(this.annotation) |
|
|
|
|
.then(response => { |
|
|
|
|
console.log(response); |
|
|
|
|
this.close(); |
|
|
|
|