Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
d553498a
Commit
d553498a
authored
Apr 10, 2017
by
Alexander Zobnin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
graph(add annotation): initial backend implementation #1286
parent
362860f6
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
47 additions
and
4 deletions
+47
-4
pkg/api/annotations.go
+21
-0
pkg/api/api.go
+1
-0
pkg/api/dtos/annotations.go
+8
-0
pkg/services/annotations/annotations.go
+8
-0
public/app/features/annotations/annotations_srv.ts
+9
-4
No files found.
pkg/api/annotations.go
View file @
d553498a
...
...
@@ -45,6 +45,27 @@ func GetAnnotations(c *middleware.Context) Response {
return
Json
(
200
,
result
)
}
func
PostAnnotation
(
c
*
middleware
.
Context
,
cmd
dtos
.
PostAnnotationsCmd
)
Response
{
repo
:=
annotations
.
GetRepository
()
item
:=
annotations
.
Item
{
OrgId
:
c
.
OrgId
,
DashboardId
:
cmd
.
DashboardId
,
PanelId
:
cmd
.
PanelId
,
Epoch
:
cmd
.
Time
/
1000
,
Title
:
cmd
.
Title
,
Text
:
cmd
.
Text
,
}
err
:=
repo
.
Save
(
&
item
)
if
err
!=
nil
{
return
ApiError
(
500
,
"Failed to save annotation"
,
err
)
}
return
ApiSuccess
(
"Annotation added"
)
}
func
DeleteAnnotations
(
c
*
middleware
.
Context
,
cmd
dtos
.
DeleteAnnotationsCmd
)
Response
{
repo
:=
annotations
.
GetRepository
()
...
...
pkg/api/api.go
View file @
d553498a
...
...
@@ -277,6 +277,7 @@ 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
))
// error test
...
...
pkg/api/dtos/annotations.go
View file @
d553498a
...
...
@@ -16,6 +16,14 @@ type Annotation struct {
Data
*
simplejson
.
Json
`json:"data"`
}
type
PostAnnotationsCmd
struct
{
DashboardId
int64
`json:"dashboardId"`
PanelId
int64
`json:"panelId"`
Time
int64
`json:"time"`
Title
string
`json:"title"`
Text
string
`json:"text"`
}
type
DeleteAnnotationsCmd
struct
{
AlertId
int64
`json:"alertId"`
DashboardId
int64
`json:"dashboardId"`
...
...
pkg/services/annotations/annotations.go
View file @
d553498a
...
...
@@ -21,6 +21,14 @@ type ItemQuery struct {
Limit
int64
`json:"limit"`
}
type
PostParams
struct
{
DashboardId
int64
`json:"dashboardId"`
PanelId
int64
`json:"panelId"`
Epoch
int64
`json:"epoch"`
Title
string
`json:"title"`
Text
string
`json:"text"`
}
type
DeleteParams
struct
{
AlertId
int64
`json:"alertId"`
DashboardId
int64
`json:"dashboardId"`
...
...
public/app/features/annotations/annotations_srv.ts
View file @
d553498a
...
...
@@ -126,13 +126,18 @@ export class AnnotationsSrv {
return
this
.
globalAnnotationsPromise
;
}
postAnnotation
(
annotation
)
{
console
.
log
(
"POST /api/annotations
\
n"
,
annotation
);
postAnnotation
(
annotation
s
)
{
console
.
log
(
"POST /api/annotations
\
n"
,
annotation
s
);
// Not implemented yet
let
implemented
=
fals
e
;
let
implemented
=
tru
e
;
if
(
implemented
)
{
return
this
.
backendSrv
.
post
(
'/api/annotations'
,
annotation
);
return
Promise
.
all
(
_
.
map
(
annotations
,
annotation
=>
{
return
this
.
backendSrv
.
post
(
'/api/annotations'
,
annotation
);
}))
.
catch
(
error
=>
{
console
.
log
(
error
);
});
}
else
{
return
Promise
.
resolve
(
"Not implemented"
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment