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
58121d89
Commit
58121d89
authored
Jan 27, 2016
by
utkarshcmu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated http_api docs
parent
6a119217
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
33 additions
and
31 deletions
+33
-31
docs/sources/reference/http_api.md
+4
-2
pkg/api/dashboard.go
+16
-16
pkg/api/dtos/models.go
+1
-1
pkg/models/dashboards.go
+8
-8
pkg/services/sqlstore/migrations/dashboard_mig.go
+4
-4
No files found.
docs/sources/reference/http_api.md
View file @
58121d89
...
...
@@ -70,13 +70,15 @@ Creates a new dashboard or updates an existing dashboard.
"schemaVersion": 6,
"version": 0
},
"overwrite": false
"overwrite": false,
"userId:": 3
}
JSON Body schema:
-
**dashboard**
– The complete dashboard model, id = null to create a new dashboard
-
**dashboard**
– The complete dashboard model, id = null to create a new dashboard
.
-
**overwrite**
– Set to true if you want to overwrite existing dashboard with newer version or with same dashboard title.
-
**userId**
- Set userId if you want to record who created or updated a dashboard.
**Example Response**
:
...
...
pkg/api/dashboard.go
View file @
58121d89
...
...
@@ -52,11 +52,11 @@ func GetDashboard(c *middleware.Context) {
// Finding the last creator and updater of the dashboard
updater
,
creator
:=
"Anonymous"
,
"Anonymous"
if
dash
.
UpdatedBy
>
0
{
updater
=
getUserLogin
(
dash
.
UpdatedBy
)
}
if
dash
.
CreatedBy
>
0
{
creator
=
getUserLogin
(
dash
.
CreatedBy
)
}
updater
=
getUserLogin
(
dash
.
UpdatedBy
)
}
if
dash
.
CreatedBy
>
0
{
creator
=
getUserLogin
(
dash
.
CreatedBy
)
}
dto
:=
dtos
.
DashboardFullWithMeta
{
Dashboard
:
dash
.
Data
,
...
...
@@ -70,7 +70,7 @@ func GetDashboard(c *middleware.Context) {
Created
:
dash
.
Created
,
Updated
:
dash
.
Updated
,
UpdatedBy
:
updater
,
CreatedBy
:
creator
,
CreatedBy
:
creator
,
},
}
...
...
@@ -78,14 +78,14 @@ func GetDashboard(c *middleware.Context) {
}
func
getUserLogin
(
userId
int64
)
string
{
query
:=
m
.
GetUserByIdQuery
{
Id
:
userId
}
err
:=
bus
.
Dispatch
(
&
query
)
if
err
!=
nil
{
return
"Anonymous"
}
else
{
user
:=
query
.
Result
return
user
.
Login
}
query
:=
m
.
GetUserByIdQuery
{
Id
:
userId
}
err
:=
bus
.
Dispatch
(
&
query
)
if
err
!=
nil
{
return
"Anonymous"
}
else
{
user
:=
query
.
Result
return
user
.
Login
}
}
func
DeleteDashboard
(
c
*
middleware
.
Context
)
{
...
...
@@ -114,8 +114,8 @@ func PostDashboard(c *middleware.Context, cmd m.SaveDashboardCommand) {
if
!
c
.
IsSignedIn
{
cmd
.
UserId
=
-
1
}
else
{
cmd
.
UserId
=
c
.
UserId
}
cmd
.
UserId
=
c
.
UserId
}
dash
:=
cmd
.
GetDashboardModel
()
if
dash
.
Id
==
0
{
...
...
pkg/api/dtos/models.go
View file @
58121d89
...
...
@@ -42,7 +42,7 @@ type DashboardMeta struct {
Created
time
.
Time
`json:"created"`
Updated
time
.
Time
`json:"updated"`
UpdatedBy
string
`json:"updatedBy"`
CreatedBy
string
`json:"createdBy"`
CreatedBy
string
`json:"createdBy"`
}
type
DashboardFullWithMeta
struct
{
...
...
pkg/models/dashboards.go
View file @
58121d89
...
...
@@ -34,7 +34,7 @@ type Dashboard struct {
Updated
time
.
Time
UpdatedBy
int64
CreatedBy
int64
CreatedBy
int64
Title
string
Data
map
[
string
]
interface
{}
...
...
@@ -67,7 +67,7 @@ func (dash *Dashboard) GetTags() []string {
return
b
}
func
NewDashboardFromJson
(
data
map
[
string
]
interface
{})
*
Dashboard
{
func
NewDashboardFromJson
(
data
map
[
string
]
interface
{})
*
Dashboard
{
dash
:=
&
Dashboard
{}
dash
.
Data
=
data
dash
.
Title
=
dash
.
Data
[
"title"
]
.
(
string
)
...
...
@@ -93,10 +93,10 @@ func NewDashboardFromJson(data map[string]interface {}) *Dashboard {
func
(
cmd
*
SaveDashboardCommand
)
GetDashboardModel
()
*
Dashboard
{
dash
:=
NewDashboardFromJson
(
cmd
.
Dashboard
)
if
dash
.
Data
[
"version"
]
==
0
{
dash
.
CreatedBy
=
cmd
.
UserId
}
dash
.
UpdatedBy
=
cmd
.
UserId
dash
.
OrgId
=
cmd
.
OrgId
dash
.
CreatedBy
=
cmd
.
UserId
}
dash
.
UpdatedBy
=
cmd
.
UserId
dash
.
OrgId
=
cmd
.
OrgId
dash
.
UpdateSlug
()
return
dash
}
...
...
@@ -118,9 +118,9 @@ func (dash *Dashboard) UpdateSlug() {
type
SaveDashboardCommand
struct
{
Dashboard
map
[
string
]
interface
{}
`json:"dashboard" binding:"Required"`
UserId
int64
`json:"userId"`
UserId
int64
`json:"userId"`
OrgId
int64
`json:"-"`
Overwrite
bool
`json:"overwrite"`
Overwrite
bool
`json:"overwrite"`
Result
*
Dashboard
}
...
...
pkg/services/sqlstore/migrations/dashboard_mig.go
View file @
58121d89
...
...
@@ -98,8 +98,8 @@ func addDashboardMigration(mg *Migrator) {
Name
:
"updated_by"
,
Type
:
DB_Int
,
Nullable
:
true
,
}))
// add column to store creator of a dashboard
mg
.
AddMigration
(
"Add column created_by in dashboard - v2"
,
NewAddColumnMigration
(
dashboardV2
,
&
Column
{
Name
:
"created_by"
,
Type
:
DB_Int
,
Nullable
:
true
,
}))
// add column to store creator of a dashboard
mg
.
AddMigration
(
"Add column created_by in dashboard - v2"
,
NewAddColumnMigration
(
dashboardV2
,
&
Column
{
Name
:
"created_by"
,
Type
:
DB_Int
,
Nullable
:
true
,
}))
}
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