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
83e49660
Commit
83e49660
authored
Oct 12, 2017
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed dashboard sorting
parent
770a21b3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
23 deletions
+27
-23
public/app/features/dashboard/DashboardModel.ts
+24
-21
public/app/features/dashboard/specs/dashboard_model_specs.ts
+2
-2
public/app/features/dashboard/specs/exporter_specs.ts
+1
-0
No files found.
public/app/features/dashboard/DashboardModel.ts
View file @
83e49660
...
...
@@ -40,6 +40,13 @@ export class DashboardModel {
folderId
:
number
;
panels
:
PanelModel
[];
static
nonPersistedProperties
:
{[
str
:
string
]:
boolean
}
=
{
"events"
:
true
,
"meta"
:
true
,
"panels"
:
true
,
// needs special handling
"templating"
:
true
,
// needs special handling
};
constructor
(
data
,
meta
?)
{
if
(
!
data
)
{
data
=
{};
...
...
@@ -118,30 +125,26 @@ export class DashboardModel {
// cleans meta data and other non peristent state
getSaveModelClone
()
{
// temp remove stuff
var
events
=
this
.
events
;
var
meta
=
this
.
meta
;
var
variables
=
this
.
templating
.
list
;
var
panels
=
this
.
panels
;
// make clone
var
copy
:
any
=
{};
for
(
var
property
in
this
)
{
if
(
DashboardModel
.
nonPersistedProperties
[
property
]
||
!
this
.
hasOwnProperty
(
property
))
{
continue
;
}
delete
this
.
events
;
delete
this
.
meta
;
delete
this
.
panels
;
copy
[
property
]
=
_
.
cloneDeep
(
this
[
property
]);
}
// prepare save model
this
.
templating
.
list
=
_
.
map
(
variables
,
variable
=>
variable
.
getSaveModel
?
variable
.
getSaveModel
()
:
variable
);
this
.
panels
=
_
.
map
(
panels
,
panel
=>
panel
.
getSaveModel
());
// get variable save models
copy
.
templating
=
{
list
:
_
.
map
(
this
.
templating
.
list
,
variable
=>
variable
.
getSaveModel
?
variable
.
getSaveModel
()
:
variable
),
};
// make clone
var
copy
=
_
.
cloneDeep
(
this
);
// sort clone
copy
=
sortByKeys
(
copy
);
// get panel save models
copy
.
panels
=
_
.
map
(
this
.
panels
,
panel
=>
panel
.
getSaveModel
());
// restore properties
this
.
events
=
events
;
this
.
meta
=
meta
;
this
.
templating
.
list
=
variables
;
this
.
panels
=
panels
;
// sort by keys
copy
=
sortByKeys
(
copy
);
return
copy
;
}
...
...
@@ -188,7 +191,7 @@ export class DashboardModel {
addPanel
(
panel
)
{
panel
.
id
=
this
.
getNextPanelId
();
this
.
panels
.
push
(
new
PanelModel
(
panel
));
this
.
panels
.
unshift
(
new
PanelModel
(
panel
));
// make sure it's sorted by pos
this
.
panels
.
sort
(
function
(
panelA
,
panelB
)
{
...
...
public/app/features/dashboard/specs/dashboard_model_specs.ts
View file @
83e49660
...
...
@@ -47,8 +47,8 @@ describe('DashboardModel', function() {
var
saveModel
=
model
.
getSaveModelClone
();
var
keys
=
_
.
keys
(
saveModel
);
expect
(
keys
[
0
]).
to
.
be
(
'a
utoUpdate
'
);
expect
(
keys
[
1
]).
to
.
be
(
'
revision
'
);
expect
(
keys
[
0
]).
to
.
be
(
'a
nnotations
'
);
expect
(
keys
[
1
]).
to
.
be
(
'
autoUpdate
'
);
});
});
...
...
public/app/features/dashboard/specs/exporter_specs.ts
View file @
83e49660
...
...
@@ -103,6 +103,7 @@ describe('given dashboard with repeated panels', function() {
};
dash
=
new
DashboardModel
(
dash
,
{});
dash
.
getSaveModelClone
();
var
exporter
=
new
DashboardExporter
(
datasourceSrvStub
);
exporter
.
makeExportable
(
dash
).
then
(
clean
=>
{
exported
=
clean
;
...
...
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