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
42a5aefb
Commit
42a5aefb
authored
Feb 03, 2015
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Worked on home dashboard
parent
bd470abc
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
46 additions
and
6 deletions
+46
-6
grafana
+1
-1
pkg/api/api.go
+4
-3
pkg/api/dashboard.go
+24
-0
pkg/api/dtos/models.go
+1
-0
pkg/models/dashboards.go
+2
-2
pkg/models/home_dashboard.go
+14
-0
No files found.
grafana
@
bc673fd9
Subproject commit
dfef4727b689d408b86d75c575646705bac79496
Subproject commit
bc673fd9697d5b37314ca0d75943dec68f9fffe1
pkg/api/api.go
View file @
42a5aefb
...
...
@@ -77,9 +77,10 @@ func Register(r *macaron.Macaron) {
},
reqAccountAdmin
)
// Dashboard
r
.
Group
(
"/dashboard"
,
func
()
{
r
.
Combo
(
"/:slug"
)
.
Get
(
GetDashboard
)
.
Delete
(
DeleteDashboard
)
r
.
Post
(
"/"
,
reqEditorRole
,
bind
(
m
.
SaveDashboardCommand
{}),
PostDashboard
)
r
.
Group
(
"/dashboards"
,
func
()
{
r
.
Combo
(
"/db/:slug"
)
.
Get
(
GetDashboard
)
.
Delete
(
DeleteDashboard
)
r
.
Post
(
"/db"
,
reqEditorRole
,
bind
(
m
.
SaveDashboardCommand
{}),
PostDashboard
)
r
.
Get
(
"/home"
,
GetHomeDashboard
)
})
// Search
...
...
pkg/api/dashboard.go
View file @
42a5aefb
package
api
import
(
"encoding/json"
"os"
"path"
"github.com/torkelo/grafana-pro/pkg/api/dtos"
"github.com/torkelo/grafana-pro/pkg/bus"
"github.com/torkelo/grafana-pro/pkg/middleware"
m
"github.com/torkelo/grafana-pro/pkg/models"
"github.com/torkelo/grafana-pro/pkg/setting"
"github.com/torkelo/grafana-pro/pkg/util"
)
...
...
@@ -81,3 +86,22 @@ func PostDashboard(c *middleware.Context, cmd m.SaveDashboardCommand) {
c
.
JSON
(
200
,
util
.
DynMap
{
"status"
:
"success"
,
"slug"
:
cmd
.
Result
.
Slug
})
}
func
GetHomeDashboard
(
c
*
middleware
.
Context
)
{
filePath
:=
path
.
Join
(
setting
.
StaticRootPath
,
"app/dashboards/default.json"
)
file
,
err
:=
os
.
Open
(
filePath
)
if
err
!=
nil
{
c
.
JsonApiErr
(
500
,
"Failed to load home dashboard"
,
err
)
return
}
dash
:=
dtos
.
Dashboard
{}
dash
.
Meta
.
IsHome
=
true
jsonParser
:=
json
.
NewDecoder
(
file
)
if
err
:=
jsonParser
.
Decode
(
&
dash
.
Model
);
err
!=
nil
{
c
.
JsonApiErr
(
500
,
"Failed to load home dashboard"
,
err
)
return
}
c
.
JSON
(
200
,
&
dash
)
}
pkg/api/dtos/models.go
View file @
42a5aefb
...
...
@@ -27,6 +27,7 @@ type CurrentUser struct {
type
DashboardMeta
struct
{
IsStarred
bool
`json:"isStarred"`
IsHome
bool
`json:"isHome"`
}
type
Dashboard
struct
{
...
...
pkg/models/dashboards.go
View file @
42a5aefb
...
...
@@ -15,8 +15,8 @@ var (
type
Dashboard
struct
{
Id
int64
Slug
string
`xorm:"index(IX_AccountIdSlug)"`
AccountId
int64
`xorm:"index(IX_AccountIdSlug)"`
Slug
string
AccountId
int64
Created
time
.
Time
Updated
time
.
Time
...
...
pkg/models/home_dashboard.go
0 → 100644
View file @
42a5aefb
package
models
import
"time"
type
HomeDashboard
struct
{
Id
int64
UserId
int64
AccountId
int64
Created
time
.
Time
Updated
time
.
Time
Data
map
[
string
]
interface
{}
}
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