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
16e1640b
Commit
16e1640b
authored
Feb 01, 2018
by
Alexander Zobnin
Committed by
Torkel Ödegaard
Feb 01, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
repeat panel: process repeats when row is expanding (#10712)
parent
50bd9eee
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
55 additions
and
6 deletions
+55
-6
public/app/features/dashboard/dashboard_model.ts
+36
-6
public/app/features/dashboard/specs/repeat.jest.ts
+19
-0
No files found.
public/app/features/dashboard/dashboard_model.ts
View file @
16e1640b
...
...
@@ -279,6 +279,40 @@ export class DashboardModel {
this
.
events
.
emit
(
'repeats-processed'
);
}
cleanUpRowRepeats
(
rowPanels
)
{
let
panelsToRemove
=
[];
for
(
let
i
=
0
;
i
<
rowPanels
.
length
;
i
++
)
{
let
panel
=
rowPanels
[
i
];
if
(
!
panel
.
repeat
&&
panel
.
repeatPanelId
)
{
panelsToRemove
.
push
(
panel
);
}
}
_
.
pull
(
rowPanels
,
...
panelsToRemove
);
_
.
pull
(
this
.
panels
,
...
panelsToRemove
);
}
processRowRepeats
(
row
:
PanelModel
)
{
if
(
this
.
snapshot
||
this
.
templating
.
list
.
length
===
0
)
{
return
;
}
let
rowPanels
=
row
.
panels
;
if
(
!
row
.
collapsed
)
{
let
rowPanelIndex
=
_
.
findIndex
(
this
.
panels
,
p
=>
p
.
id
===
row
.
id
);
rowPanels
=
this
.
getRowPanels
(
rowPanelIndex
);
}
this
.
cleanUpRowRepeats
(
rowPanels
);
for
(
let
i
=
0
;
i
<
rowPanels
.
length
;
i
++
)
{
let
panel
=
rowPanels
[
i
];
if
(
panel
.
repeat
)
{
let
panelIndex
=
_
.
findIndex
(
this
.
panels
,
p
=>
p
.
id
===
panel
.
id
);
this
.
repeatPanel
(
panel
,
panelIndex
);
}
}
}
getPanelRepeatClone
(
sourcePanel
,
valueIndex
,
sourcePanelIndex
)
{
// if first clone return source
if
(
valueIndex
===
0
)
{
...
...
@@ -569,7 +603,7 @@ export class DashboardModel {
if
(
row
.
collapsed
)
{
row
.
collapsed
=
false
;
let
hasRepeat
=
false
;
let
hasRepeat
=
_
.
some
(
row
.
panels
,
p
=>
p
.
repeat
)
;
if
(
row
.
panels
.
length
>
0
)
{
// Use first panel to figure out if it was moved or pushed
...
...
@@ -590,10 +624,6 @@ export class DashboardModel {
// update insert post and y max
insertPos
+=
1
;
yMax
=
Math
.
max
(
yMax
,
panel
.
gridPos
.
y
+
panel
.
gridPos
.
h
);
if
(
panel
.
repeat
)
{
hasRepeat
=
true
;
}
}
const
pushDownAmount
=
yMax
-
row
.
gridPos
.
y
;
...
...
@@ -606,7 +636,7 @@ export class DashboardModel {
row
.
panels
=
[];
if
(
hasRepeat
)
{
this
.
processR
epeats
(
);
this
.
processR
owRepeats
(
row
);
}
}
...
...
public/app/features/dashboard/specs/repeat.jest.ts
View file @
16e1640b
...
...
@@ -629,4 +629,23 @@ describe('given dashboard with row and panel repeat', () => {
region
:
{
text
:
'reg2'
,
value
:
'reg2'
},
});
});
it
(
'should repeat panels when row is expanding'
,
function
()
{
dashboard
=
new
DashboardModel
(
dashboardJSON
);
dashboard
.
processRepeats
();
expect
(
dashboard
.
panels
.
length
).
toBe
(
6
);
// toggle row
dashboard
.
toggleRow
(
dashboard
.
panels
[
0
]);
dashboard
.
toggleRow
(
dashboard
.
panels
[
1
]);
expect
(
dashboard
.
panels
.
length
).
toBe
(
2
);
// change variable
dashboard
.
templating
.
list
[
1
].
current
.
value
=
[
'se1'
,
'se2'
,
'se3'
];
// toggle row back
dashboard
.
toggleRow
(
dashboard
.
panels
[
1
]);
expect
(
dashboard
.
panels
.
length
).
toBe
(
4
);
});
});
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