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
2e21613b
Commit
2e21613b
authored
Oct 11, 2016
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(templating): fixed issues with dynamic dashboard srv (panel/row) repeats, fixes #6237
parent
4df379f9
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
28 additions
and
25 deletions
+28
-25
public/app/features/dashboard/dashboard_ctrl.ts
+4
-2
public/app/features/dashboard/dynamic_dashboard_srv.ts
+11
-15
public/app/features/dashboard/export/exporter.ts
+2
-1
public/app/features/dashboard/specs/dynamic_dashboard_srv_specs.ts
+11
-7
No files found.
public/app/features/dashboard/dashboard_ctrl.ts
View file @
2e21613b
...
@@ -51,7 +51,9 @@ export class DashboardCtrl {
...
@@ -51,7 +51,9 @@ export class DashboardCtrl {
.
catch
(
$scope
.
onInitFailed
.
bind
(
this
,
'Templating init failed'
,
false
))
.
catch
(
$scope
.
onInitFailed
.
bind
(
this
,
'Templating init failed'
,
false
))
// continue
// continue
.
finally
(
function
()
{
.
finally
(
function
()
{
dynamicDashboardSrv
.
init
(
dashboard
);
dynamicDashboardSrv
.
init
(
dashboard
,
variableSrv
);
dynamicDashboardSrv
.
process
();
unsavedChangesSrv
.
init
(
dashboard
,
$scope
);
unsavedChangesSrv
.
init
(
dashboard
,
$scope
);
$scope
.
dashboard
=
dashboard
;
$scope
.
dashboard
=
dashboard
;
...
@@ -87,7 +89,7 @@ export class DashboardCtrl {
...
@@ -87,7 +89,7 @@ export class DashboardCtrl {
};
};
$scope
.
templateVariableUpdated
=
function
()
{
$scope
.
templateVariableUpdated
=
function
()
{
dynamicDashboardSrv
.
update
(
$scope
.
dashboard
);
dynamicDashboardSrv
.
process
(
);
};
};
$scope
.
updateSubmenuVisibility
=
function
()
{
$scope
.
updateSubmenuVisibility
=
function
()
{
...
...
public/app/features/dashboard/dynamic_dashboard_srv.ts
View file @
2e21613b
...
@@ -9,23 +9,21 @@ import coreModule from 'app/core/core_module';
...
@@ -9,23 +9,21 @@ import coreModule from 'app/core/core_module';
export
class
DynamicDashboardSrv
{
export
class
DynamicDashboardSrv
{
iteration
:
number
;
iteration
:
number
;
dashboard
:
any
;
dashboard
:
any
;
variables
:
any
;
init
(
dashboard
)
{
init
(
dashboard
,
variableSrv
)
{
if
(
dashboard
.
snapshot
)
{
return
;
}
this
.
dashboard
=
dashboard
;
this
.
process
(
dashboard
,
{});
this
.
variables
=
variableSrv
.
variables
;
}
update
(
dashboard
)
{
if
(
dashboard
.
snapshot
)
{
return
;
}
this
.
process
(
dashboard
,
{});
}
}
process
(
dashboard
,
options
)
{
process
(
options
)
{
if
(
dashboard
.
templating
.
list
.
length
===
0
)
{
return
;
}
if
(
this
.
dashboard
.
snapshot
||
this
.
variables
.
length
===
0
)
{
return
;
}
this
.
dashboard
=
dashboard
;
this
.
iteration
=
(
this
.
iteration
||
new
Date
().
getTime
())
+
1
;
this
.
iteration
=
(
this
.
iteration
||
new
Date
().
getTime
())
+
1
;
options
=
options
||
{};
var
cleanUpOnly
=
options
.
cleanUpOnly
;
var
cleanUpOnly
=
options
.
cleanUpOnly
;
var
i
,
j
,
row
,
panel
;
var
i
,
j
,
row
,
panel
;
...
@@ -105,8 +103,7 @@ export class DynamicDashboardSrv {
...
@@ -105,8 +103,7 @@ export class DynamicDashboardSrv {
// returns a new row clone or reuses a clone from previous iteration
// returns a new row clone or reuses a clone from previous iteration
repeatRow
(
row
,
rowIndex
)
{
repeatRow
(
row
,
rowIndex
)
{
var
variables
=
this
.
dashboard
.
templating
.
list
;
var
variable
=
_
.
find
(
this
.
variables
,
{
name
:
row
.
repeat
});
var
variable
=
_
.
find
(
variables
,
{
name
:
row
.
repeat
});
if
(
!
variable
)
{
if
(
!
variable
)
{
return
;
return
;
}
}
...
@@ -166,8 +163,7 @@ export class DynamicDashboardSrv {
...
@@ -166,8 +163,7 @@ export class DynamicDashboardSrv {
}
}
repeatPanel
(
panel
,
row
)
{
repeatPanel
(
panel
,
row
)
{
var
variables
=
this
.
dashboard
.
templating
.
list
;
var
variable
=
_
.
find
(
this
.
variables
,
{
name
:
panel
.
repeat
});
var
variable
=
_
.
find
(
variables
,
{
name
:
panel
.
repeat
});
if
(
!
variable
)
{
return
;
}
if
(
!
variable
)
{
return
;
}
var
selected
;
var
selected
;
...
...
public/app/features/dashboard/export/exporter.ts
View file @
2e21613b
...
@@ -13,7 +13,8 @@ export class DashboardExporter {
...
@@ -13,7 +13,8 @@ export class DashboardExporter {
makeExportable
(
dash
)
{
makeExportable
(
dash
)
{
var
dynSrv
=
new
DynamicDashboardSrv
();
var
dynSrv
=
new
DynamicDashboardSrv
();
dynSrv
.
process
(
dash
,
{
cleanUpOnly
:
true
});
dynSrv
.
init
(
dash
,
{
variables
:
dash
.
templating
.
list
});
dynSrv
.
process
({
cleanUpOnly
:
true
});
dash
.
id
=
null
;
dash
.
id
=
null
;
...
...
public/app/features/dashboard/specs/dynamic_dashboard_srv_specs.ts
View file @
2e21613b
...
@@ -20,6 +20,8 @@ function dynamicDashScenario(desc, func) {
...
@@ -20,6 +20,8 @@ function dynamicDashScenario(desc, func) {
beforeEach
(
angularMocks
.
inject
(
function
(
dashboardSrv
)
{
beforeEach
(
angularMocks
.
inject
(
function
(
dashboardSrv
)
{
ctx
.
dashboardSrv
=
dashboardSrv
;
ctx
.
dashboardSrv
=
dashboardSrv
;
ctx
.
variableSrv
=
{};
var
model
=
{
var
model
=
{
rows
:
[],
rows
:
[],
templating
:
{
list
:
[]
}
templating
:
{
list
:
[]
}
...
@@ -27,8 +29,10 @@ function dynamicDashScenario(desc, func) {
...
@@ -27,8 +29,10 @@ function dynamicDashScenario(desc, func) {
setupFunc
(
model
);
setupFunc
(
model
);
ctx
.
dash
=
ctx
.
dashboardSrv
.
create
(
model
);
ctx
.
dash
=
ctx
.
dashboardSrv
.
create
(
model
);
ctx
.
variableSrv
.
variables
=
ctx
.
dash
.
templating
.
list
;
ctx
.
dynamicDashboardSrv
=
new
DynamicDashboardSrv
();
ctx
.
dynamicDashboardSrv
=
new
DynamicDashboardSrv
();
ctx
.
dynamicDashboardSrv
.
init
(
ctx
.
dash
);
ctx
.
dynamicDashboardSrv
.
init
(
ctx
.
dash
,
ctx
.
variableSrv
);
ctx
.
dynamicDashboardSrv
.
process
();
ctx
.
rows
=
ctx
.
dash
.
rows
;
ctx
.
rows
=
ctx
.
dash
.
rows
;
}));
}));
};
};
...
@@ -78,7 +82,7 @@ dynamicDashScenario('given dashboard with panel repeat', function(ctx) {
...
@@ -78,7 +82,7 @@ dynamicDashScenario('given dashboard with panel repeat', function(ctx) {
beforeEach
(
function
()
{
beforeEach
(
function
()
{
repeatedPanelAfterIteration1
=
ctx
.
rows
[
0
].
panels
[
1
];
repeatedPanelAfterIteration1
=
ctx
.
rows
[
0
].
panels
[
1
];
ctx
.
rows
[
0
].
panels
[
0
].
fill
=
10
;
ctx
.
rows
[
0
].
panels
[
0
].
fill
=
10
;
ctx
.
dynamicDashboardSrv
.
update
(
ctx
.
dash
);
ctx
.
dynamicDashboardSrv
.
process
(
);
});
});
it
(
'should have reused same panel instances'
,
function
()
{
it
(
'should have reused same panel instances'
,
function
()
{
...
@@ -102,7 +106,7 @@ dynamicDashScenario('given dashboard with panel repeat', function(ctx) {
...
@@ -102,7 +106,7 @@ dynamicDashScenario('given dashboard with panel repeat', function(ctx) {
options
:
[{
text
:
'se1'
,
value
:
'se1'
,
selected
:
true
}]
options
:
[{
text
:
'se1'
,
value
:
'se1'
,
selected
:
true
}]
});
});
ctx
.
rows
[
0
].
panels
[
0
].
repeat
=
"server"
;
ctx
.
rows
[
0
].
panels
[
0
].
repeat
=
"server"
;
ctx
.
dynamicDashboardSrv
.
update
(
ctx
.
dash
);
ctx
.
dynamicDashboardSrv
.
process
(
);
});
});
it
(
'should remove scopedVars value for last variable'
,
function
()
{
it
(
'should remove scopedVars value for last variable'
,
function
()
{
...
@@ -117,7 +121,7 @@ dynamicDashScenario('given dashboard with panel repeat', function(ctx) {
...
@@ -117,7 +121,7 @@ dynamicDashScenario('given dashboard with panel repeat', function(ctx) {
describe
(
'After a second iteration and selected values reduced'
,
function
()
{
describe
(
'After a second iteration and selected values reduced'
,
function
()
{
beforeEach
(
function
()
{
beforeEach
(
function
()
{
ctx
.
dash
.
templating
.
list
[
0
].
options
[
1
].
selected
=
false
;
ctx
.
dash
.
templating
.
list
[
0
].
options
[
1
].
selected
=
false
;
ctx
.
dynamicDashboardSrv
.
update
(
ctx
.
dash
);
ctx
.
dynamicDashboardSrv
.
process
(
);
});
});
it
(
'should clean up repeated panel'
,
function
()
{
it
(
'should clean up repeated panel'
,
function
()
{
...
@@ -128,7 +132,7 @@ dynamicDashScenario('given dashboard with panel repeat', function(ctx) {
...
@@ -128,7 +132,7 @@ dynamicDashScenario('given dashboard with panel repeat', function(ctx) {
describe
(
'After a second iteration and panel repeat is turned off'
,
function
()
{
describe
(
'After a second iteration and panel repeat is turned off'
,
function
()
{
beforeEach
(
function
()
{
beforeEach
(
function
()
{
ctx
.
rows
[
0
].
panels
[
0
].
repeat
=
null
;
ctx
.
rows
[
0
].
panels
[
0
].
repeat
=
null
;
ctx
.
dynamicDashboardSrv
.
update
(
ctx
.
dash
);
ctx
.
dynamicDashboardSrv
.
process
(
);
});
});
it
(
'should clean up repeated panel'
,
function
()
{
it
(
'should clean up repeated panel'
,
function
()
{
...
@@ -199,7 +203,7 @@ dynamicDashScenario('given dashboard with row repeat', function(ctx) {
...
@@ -199,7 +203,7 @@ dynamicDashScenario('given dashboard with row repeat', function(ctx) {
beforeEach
(
function
()
{
beforeEach
(
function
()
{
repeatedRowAfterFirstIteration
=
ctx
.
rows
[
1
];
repeatedRowAfterFirstIteration
=
ctx
.
rows
[
1
];
ctx
.
rows
[
0
].
height
=
500
;
ctx
.
rows
[
0
].
height
=
500
;
ctx
.
dynamicDashboardSrv
.
update
(
ctx
.
dash
);
ctx
.
dynamicDashboardSrv
.
process
(
);
});
});
it
(
'should still only have 2 rows'
,
function
()
{
it
(
'should still only have 2 rows'
,
function
()
{
...
@@ -218,7 +222,7 @@ dynamicDashScenario('given dashboard with row repeat', function(ctx) {
...
@@ -218,7 +222,7 @@ dynamicDashScenario('given dashboard with row repeat', function(ctx) {
describe
(
'After a second iteration and selected values reduced'
,
function
()
{
describe
(
'After a second iteration and selected values reduced'
,
function
()
{
beforeEach
(
function
()
{
beforeEach
(
function
()
{
ctx
.
dash
.
templating
.
list
[
0
].
options
[
1
].
selected
=
false
;
ctx
.
dash
.
templating
.
list
[
0
].
options
[
1
].
selected
=
false
;
ctx
.
dynamicDashboardSrv
.
update
(
ctx
.
dash
);
ctx
.
dynamicDashboardSrv
.
process
(
);
});
});
it
(
'should remove repeated second row'
,
function
()
{
it
(
'should remove repeated second row'
,
function
()
{
...
...
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