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
6c736e00
Commit
6c736e00
authored
May 31, 2017
by
Daniel Lee
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WIP: add dummy root folder to folder picker
Can move a dash from a folder back to root level as well
parent
1e865211
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
57 additions
and
7 deletions
+57
-7
pkg/services/sqlstore/dashboard.go
+2
-2
pkg/services/sqlstore/dashboard_test.go
+40
-0
public/app/features/dashboard/folder_picker/picker.ts
+14
-4
public/app/features/dashboard/partials/settings.html
+1
-1
No files found.
pkg/services/sqlstore/dashboard.go
View file @
6c736e00
...
@@ -25,7 +25,7 @@ func init() {
...
@@ -25,7 +25,7 @@ func init() {
func
SaveDashboard
(
cmd
*
m
.
SaveDashboardCommand
)
error
{
func
SaveDashboard
(
cmd
*
m
.
SaveDashboardCommand
)
error
{
return
inTransaction
(
func
(
sess
*
DBSession
)
error
{
return
inTransaction
(
func
(
sess
*
DBSession
)
error
{
dash
:=
cmd
.
GetDashboardModel
()
dash
:=
cmd
.
GetDashboardModel
()
fmt
.
Printf
(
"ParentId: %v"
,
dash
.
ParentId
)
// try get existing dashboard
// try get existing dashboard
var
existing
,
sameTitle
m
.
Dashboard
var
existing
,
sameTitle
m
.
Dashboard
...
@@ -81,7 +81,7 @@ func SaveDashboard(cmd *m.SaveDashboardCommand) error {
...
@@ -81,7 +81,7 @@ func SaveDashboard(cmd *m.SaveDashboardCommand) error {
}
else
{
}
else
{
dash
.
Version
+=
1
dash
.
Version
+=
1
dash
.
Data
.
Set
(
"version"
,
dash
.
Version
)
dash
.
Data
.
Set
(
"version"
,
dash
.
Version
)
affectedRows
,
err
=
sess
.
Id
(
dash
.
Id
)
.
Update
(
dash
)
affectedRows
,
err
=
sess
.
MustCols
(
"parent_id"
)
.
Id
(
dash
.
Id
)
.
Update
(
dash
)
}
}
if
err
!=
nil
{
if
err
!=
nil
{
...
...
pkg/services/sqlstore/dashboard_test.go
View file @
6c736e00
...
@@ -191,6 +191,46 @@ func TestDashboardDataAccess(t *testing.T) {
...
@@ -191,6 +191,46 @@ func TestDashboardDataAccess(t *testing.T) {
So
(
err
,
ShouldNotBeNil
)
So
(
err
,
ShouldNotBeNil
)
})
})
Convey
(
"Should be able to update dashboard and remove parentId"
,
func
()
{
cmd
:=
m
.
SaveDashboardCommand
{
OrgId
:
1
,
Dashboard
:
simplejson
.
NewFromAny
(
map
[
string
]
interface
{}{
"id"
:
1
,
"title"
:
"parentId"
,
"tags"
:
[]
interface
{}{},
}),
Overwrite
:
true
,
ParentId
:
2
,
}
err
:=
SaveDashboard
(
&
cmd
)
So
(
err
,
ShouldBeNil
)
So
(
cmd
.
Result
.
ParentId
,
ShouldEqual
,
2
)
cmd
=
m
.
SaveDashboardCommand
{
OrgId
:
1
,
Dashboard
:
simplejson
.
NewFromAny
(
map
[
string
]
interface
{}{
"id"
:
1
,
"title"
:
"parentId"
,
"tags"
:
[]
interface
{}{},
}),
ParentId
:
0
,
Overwrite
:
true
,
}
err
=
SaveDashboard
(
&
cmd
)
So
(
err
,
ShouldBeNil
)
query
:=
m
.
GetDashboardQuery
{
Slug
:
cmd
.
Result
.
Slug
,
OrgId
:
1
,
}
err
=
GetDashboard
(
&
query
)
So
(
err
,
ShouldBeNil
)
So
(
query
.
Result
.
ParentId
,
ShouldEqual
,
0
)
})
Convey
(
"Should be able to get dashboard tags"
,
func
()
{
Convey
(
"Should be able to get dashboard tags"
,
func
()
{
query
:=
m
.
GetDashboardTagsQuery
{
OrgId
:
1
}
query
:=
m
.
GetDashboardTagsQuery
{
OrgId
:
1
}
...
...
public/app/features/dashboard/folder_picker/picker.ts
View file @
6c736e00
...
@@ -6,13 +6,14 @@ import _ from 'lodash';
...
@@ -6,13 +6,14 @@ import _ from 'lodash';
export
class
FolderPickerCtrl
{
export
class
FolderPickerCtrl
{
dashboard
:
any
;
dashboard
:
any
;
folders
:
any
[];
folders
:
Folder
[];
selectedFolder
:
number
;
selectedFolder
:
number
;
/** @ngInject */
/** @ngInject */
constructor
(
private
backendSrv
,
private
$scope
,
$sce
)
{
constructor
(
private
backendSrv
,
private
$scope
,
$sce
)
{
this
.
get
(
this
.
dashboard
.
id
);
this
.
get
(
this
.
dashboard
.
id
);
this
.
selectedFolder
=
this
.
dashboard
.
meta
.
parentId
;
this
.
selectedFolder
=
this
.
dashboard
.
meta
.
parentId
;
this
.
folders
=
[{
id
:
0
,
title
:
'Root'
,
type
:
'dash-folder'
}];
}
}
get
(
dashboardId
:
number
)
{
get
(
dashboardId
:
number
)
{
...
@@ -21,15 +22,24 @@ export class FolderPickerCtrl {
...
@@ -21,15 +22,24 @@ export class FolderPickerCtrl {
};
};
return
this
.
backendSrv
.
search
(
params
).
then
(
result
=>
{
return
this
.
backendSrv
.
search
(
params
).
then
(
result
=>
{
this
.
folders
=
result
;
this
.
folders
.
push
(...
result
)
;
});
});
}
}
folderChanged
()
{
folderChanged
()
{
if
(
this
.
selectedFolder
>
0
)
{
this
.
dashboard
.
parentId
=
this
.
selectedFolder
;
this
.
dashboard
.
parentId
=
this
.
selectedFolder
;
}
}
}
}
export
interface
Folder
{
id
:
number
;
title
:
string
;
uri
?:
string
;
type
:
string
;
tags
?:
string
[];
isStarred
?:
boolean
;
parentId
?:
number
;
dashboards
?:
any
;
}
}
export
function
folderPicker
()
{
export
function
folderPicker
()
{
...
...
public/app/features/dashboard/partials/settings.html
View file @
6c736e00
...
@@ -45,7 +45,7 @@
...
@@ -45,7 +45,7 @@
</div>
</div>
</div>
</div>
<folder-picker
dashboard=
"dashboard"
></folder-picker>
<folder-picker
ng-hide=
"dashboardMeta.isFolder"
dashboard=
"dashboard"
></folder-picker>
</div>
</div>
<div
class=
"section"
>
<div
class=
"section"
>
...
...
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