Commit 3410fb44 by lzd Committed by Torkel Ödegaard

Annotations: check if the name exists before creating a new annotation (#18880)

parent 490a1d6f
...@@ -4,6 +4,7 @@ import $ from 'jquery'; ...@@ -4,6 +4,7 @@ import $ from 'jquery';
import coreModule from 'app/core/core_module'; import coreModule from 'app/core/core_module';
import { DashboardModel } from 'app/features/dashboard/state'; import { DashboardModel } from 'app/features/dashboard/state';
import DatasourceSrv from '../plugins/datasource_srv'; import DatasourceSrv from '../plugins/datasource_srv';
import appEvents from 'app/core/app_events';
export class AnnotationsEditorCtrl { export class AnnotationsEditorCtrl {
mode: any; mode: any;
...@@ -97,6 +98,11 @@ export class AnnotationsEditorCtrl { ...@@ -97,6 +98,11 @@ export class AnnotationsEditorCtrl {
} }
add() { add() {
const sameName: any = _.find(this.annotations, { name: this.currentAnnotation.name });
if (sameName) {
appEvents.emit('alert-warning', ['Validation', 'Annotations with the same name already exists']);
return;
}
this.annotations.push(this.currentAnnotation); this.annotations.push(this.currentAnnotation);
this.reset(); this.reset();
this.mode = 'list'; this.mode = 'list';
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment