annotations: you can now read annoations via manually created annoation query

This commit is contained in:
Torkel Ödegaard
2017-04-12 15:46:41 +02:00
parent 78f4bd2de9
commit 0156a94a49
9 changed files with 21 additions and 11 deletions
+3
View File
@@ -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)
+4 -2
View File
@@ -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))
+1
View File
@@ -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"`