diff --git a/pkg/api/annotations.go b/pkg/api/annotations.go index af72b9d3876..88e8c955497 100644 --- a/pkg/api/annotations.go +++ b/pkg/api/annotations.go @@ -39,6 +39,7 @@ func GetAnnotations(c *middleware.Context) Response { Text: item.Text, Metric: item.Metric, Title: item.Title, + PanelId: item.PanelId, }) } @@ -55,6 +56,8 @@ func PostAnnotation(c *middleware.Context, cmd dtos.PostAnnotationsCmd) Response Epoch: cmd.Time / 1000, Title: cmd.Title, Text: cmd.Text, + CategoryId: cmd.CategoryId, + Type: annotations.EventType, } err := repo.Save(&item) diff --git a/pkg/api/api.go b/pkg/api/api.go index 0b9a8acf851..6dcc900c16f 100644 --- a/pkg/api/api.go +++ b/pkg/api/api.go @@ -277,8 +277,10 @@ func (hs *HttpServer) registerRoutes() { }, reqEditorRole) r.Get("/annotations", wrap(GetAnnotations)) - r.Post("/annotations", bind(dtos.PostAnnotationsCmd{}), wrap(PostAnnotation)) - r.Post("/annotations/mass-delete", reqOrgAdmin, bind(dtos.DeleteAnnotationsCmd{}), wrap(DeleteAnnotations)) + + r.Group("/annotations", func() { + r.Post("/", bind(dtos.PostAnnotationsCmd{}), wrap(PostAnnotation)) + }, reqEditorRole) // error test r.Get("/metrics/error", wrap(GenerateError)) diff --git a/pkg/api/dtos/annotations.go b/pkg/api/dtos/annotations.go index cd8c0c1d523..28e048db3ec 100644 --- a/pkg/api/dtos/annotations.go +++ b/pkg/api/dtos/annotations.go @@ -19,6 +19,7 @@ type Annotation struct { type PostAnnotationsCmd struct { DashboardId int64 `json:"dashboardId"` PanelId int64 `json:"panelId"` + CategoryId int64 `json:"categoryId"` Time int64 `json:"time"` Title string `json:"title"` Text string `json:"text"` diff --git a/pkg/services/annotations/annotations.go b/pkg/services/annotations/annotations.go index a308f546c8a..a3b4eacc0c3 100644 --- a/pkg/services/annotations/annotations.go +++ b/pkg/services/annotations/annotations.go @@ -49,6 +49,7 @@ type ItemType string const ( AlertType ItemType = "alert" + EventType ItemType = "event" ) type Item struct { diff --git a/public/app/features/annotations/annotations_srv.ts b/public/app/features/annotations/annotations_srv.ts index d3b83982f51..691153b197b 100644 --- a/public/app/features/annotations/annotations_srv.ts +++ b/public/app/features/annotations/annotations_srv.ts @@ -35,6 +35,13 @@ export class AnnotationsSrv { // combine the annotations and flatten results var annotations = _.flattenDeep([results[0], results[1]]); + // filter out annotations that do not belong to requesting panel + annotations = _.filter(annotations, item => { + if (item.panelId && options.panel.id !== item.panelId) { + return false; + } + return true; + }); // look for alert state for this panel var alertState = _.find(results[2], {panelId: options.panel.id}); diff --git a/public/app/features/dashboard/addAnnotationModalCtrl.ts b/public/app/features/dashboard/addAnnotationModalCtrl.ts index 7c3962074cf..789d24bdbee 100644 --- a/public/app/features/dashboard/addAnnotationModalCtrl.ts +++ b/public/app/features/dashboard/addAnnotationModalCtrl.ts @@ -61,7 +61,6 @@ export class AddAnnotationModalCtrl { } close() { - this.graphCtrl.inAddAnnotationMode = false; this.$scope.dismiss(); } } diff --git a/public/app/plugins/datasource/grafana/partials/annotations.editor.html b/public/app/plugins/datasource/grafana/partials/annotations.editor.html index a1528a6d708..24a06a2abd6 100644 --- a/public/app/plugins/datasource/grafana/partials/annotations.editor.html +++ b/public/app/plugins/datasource/grafana/partials/annotations.editor.html @@ -4,7 +4,7 @@