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
45d2e70b
Commit
45d2e70b
authored
Jan 06, 2017
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(dashboard): sorting dashboard model kekeys, refactoring PR #7139
parent
c472054f
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
10 additions
and
13 deletions
+10
-13
public/app/core/utils/sort_by_keys.ts
+4
-10
public/app/features/dashboard/export/exporter.ts
+1
-2
public/app/features/dashboard/model.ts
+5
-1
public/app/features/dashboard/specs/dashboard_model_specs.ts
+0
-0
public/app/features/dashboard/specs/dashboard_srv_specs.ts
+0
-0
No files found.
public/app/core/utils/sort_by_keys.ts
View file @
45d2e70b
...
...
@@ -2,20 +2,14 @@ import _ from 'lodash';
export
default
function
sortByKeys
(
input
)
{
if
(
_
.
isArray
(
input
))
{
var
newArray
=
[];
_
.
forEach
(
input
,
function
(
item
)
{
newArray
.
push
(
sortByKeys
(
item
));
}
);
return
newArray
;
return
input
.
map
(
sortByKeys
);
}
if
(
_
.
isPlainObject
(
input
))
{
var
sortedObject
=
{};
_
.
forEach
(
_
.
keys
(
input
).
sort
(),
function
(
key
)
{
sortedObject
[
key
]
=
sortByKeys
(
input
[
key
]);
}
);
for
(
let
key
of
_
.
keys
(
input
).
sort
())
{
sortedObject
[
key
]
=
sortByKeys
(
input
[
key
]);
}
return
sortedObject
;
}
...
...
public/app/features/dashboard/export/exporter.ts
View file @
45d2e70b
...
...
@@ -3,7 +3,6 @@
import
config
from
'app/core/config'
;
import
angular
from
'angular'
;
import
_
from
'lodash'
;
import
sortByKeys
from
'app/core/utils/sort_by_keys'
;
import
{
DynamicDashboardSrv
}
from
'../dynamic_dashboard_srv'
;
...
...
@@ -152,8 +151,8 @@ export class DashboardExporter {
newObj
[
"__requires"
]
=
_
.
sortBy
(
requires
,
[
'id'
]);
_
.
defaults
(
newObj
,
saveModel
);
return
newObj
;
return
sortByKeys
(
newObj
);
}).
catch
(
err
=>
{
console
.
log
(
'Export failed:'
,
err
);
return
{
...
...
public/app/features/dashboard/model.ts
View file @
45d2e70b
...
...
@@ -8,6 +8,7 @@ import $ from 'jquery';
import
{
Emitter
,
contextSrv
,
appEvents
}
from
'app/core/core'
;
import
{
DashboardRow
}
from
'./row/row_model'
;
import
sortByKeys
from
'app/core/utils/sort_by_keys'
;
export
class
DashboardModel
{
id
:
any
;
...
...
@@ -36,7 +37,7 @@ export class DashboardModel {
events
:
any
;
editMode
:
boolean
;
constructor
(
data
,
meta
)
{
constructor
(
data
,
meta
?
)
{
if
(
!
data
)
{
data
=
{};
}
...
...
@@ -107,7 +108,10 @@ export class DashboardModel {
this
.
rows
=
_
.
map
(
rows
,
row
=>
row
.
getSaveModel
());
this
.
templating
.
list
=
_
.
map
(
variables
,
variable
=>
variable
.
getSaveModel
?
variable
.
getSaveModel
()
:
variable
);
// make clone
var
copy
=
$
.
extend
(
true
,
{},
this
);
// sort clone
copy
=
sortByKeys
(
copy
);
// restore properties
this
.
events
=
events
;
...
...
public/app/features/dashboard/specs/dashboard_model_specs.ts
0 → 100644
View file @
45d2e70b
This diff is collapsed.
Click to expand it.
public/app/features/dashboard/specs/dashboard_srv_specs.ts
View file @
45d2e70b
This diff is collapsed.
Click to expand it.
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