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
1c95da8f
Commit
1c95da8f
authored
Jan 30, 2018
by
ilgizar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix horizontal panel repeat. Fix #10672.
parent
0573545d
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
104 additions
and
7 deletions
+104
-7
public/app/features/dashboard/dashboard_model.ts
+12
-7
public/app/features/dashboard/specs/repeat.jest.ts
+92
-0
No files found.
public/app/features/dashboard/dashboard_model.ts
View file @
1c95da8f
...
@@ -342,6 +342,7 @@ export class DashboardModel {
...
@@ -342,6 +342,7 @@ export class DashboardModel {
let
minWidth
=
panel
.
minSpan
||
6
;
let
minWidth
=
panel
.
minSpan
||
6
;
let
xPos
=
0
;
let
xPos
=
0
;
let
yPos
=
panel
.
gridPos
.
y
;
let
yPos
=
panel
.
gridPos
.
y
;
let
yOffset
=
0
;
for
(
let
index
=
0
;
index
<
selectedOptions
.
length
;
index
++
)
{
for
(
let
index
=
0
;
index
<
selectedOptions
.
length
;
index
++
)
{
let
option
=
selectedOptions
[
index
];
let
option
=
selectedOptions
[
index
];
...
@@ -354,13 +355,8 @@ export class DashboardModel {
...
@@ -354,13 +355,8 @@ export class DashboardModel {
if
(
panel
.
repeatDirection
===
REPEAT_DIR_VERTICAL
)
{
if
(
panel
.
repeatDirection
===
REPEAT_DIR_VERTICAL
)
{
copy
.
gridPos
.
y
=
yPos
;
copy
.
gridPos
.
y
=
yPos
;
yPos
+=
copy
.
gridPos
.
h
;
yPos
+=
copy
.
gridPos
.
h
;
if
(
index
>
0
)
{
// Update gridPos for panels below
yOffset
+=
copy
.
gridPos
.
h
;
let
panelBelowIndex
=
panelIndex
+
index
+
1
;
for
(
let
i
=
panelBelowIndex
;
i
<
this
.
panels
.
length
;
i
++
)
{
if
(
this
.
panels
[
i
].
gridPos
.
y
<
yPos
)
{
this
.
panels
[
i
].
gridPos
.
y
+=
copy
.
gridPos
.
h
;
}
}
}
}
else
{
}
else
{
// set width based on how many are selected
// set width based on how many are selected
...
@@ -375,8 +371,17 @@ export class DashboardModel {
...
@@ -375,8 +371,17 @@ export class DashboardModel {
if
(
xPos
+
copy
.
gridPos
.
w
>
GRID_COLUMN_COUNT
)
{
if
(
xPos
+
copy
.
gridPos
.
w
>
GRID_COLUMN_COUNT
)
{
xPos
=
0
;
xPos
=
0
;
yPos
+=
copy
.
gridPos
.
h
;
yPos
+=
copy
.
gridPos
.
h
;
yOffset
+=
copy
.
gridPos
.
h
;
}
}
}
}
}
// Update gridPos for panels below
if
(
yOffset
>
0
)
{
let
panelBelowIndex
=
panelIndex
+
selectedOptions
.
length
;
for
(
let
i
=
panelBelowIndex
;
i
<
this
.
panels
.
length
;
i
++
)
{
this
.
panels
[
i
].
gridPos
.
y
+=
yOffset
;
}
}
}
}
}
...
...
public/app/features/dashboard/specs/repeat.jest.ts
View file @
1c95da8f
...
@@ -178,6 +178,98 @@ describe('given dashboard with panel repeat in vertical direction', function() {
...
@@ -178,6 +178,98 @@ describe('given dashboard with panel repeat in vertical direction', function() {
});
});
});
});
describe
(
'given dashboard with row repeat and panel repeat in horizontal direction'
,
()
=>
{
let
dashboard
,
dashboardJSON
;
beforeEach
(()
=>
{
dashboardJSON
=
{
panels
:
[
{
id
:
1
,
type
:
'row'
,
repeat
:
'region'
,
gridPos
:
{
x
:
0
,
y
:
0
,
h
:
1
,
w
:
24
},
},
{
id
:
2
,
type
:
'graph'
,
repeat
:
'app'
,
gridPos
:
{
x
:
0
,
y
:
1
,
h
:
2
,
w
:
6
},
},
],
templating
:
{
list
:
[
{
name
:
'region'
,
current
:
{
text
:
'reg1, reg2'
,
value
:
[
'reg1'
,
'reg2'
],
},
options
:
[{
text
:
'reg1'
,
value
:
'reg1'
,
selected
:
true
},
{
text
:
'reg2'
,
value
:
'reg2'
,
selected
:
true
}],
},
{
name
:
'app'
,
current
:
{
text
:
'se1, se2, se3, se4, se5, se6'
,
value
:
[
'se1'
,
'se2'
,
'se3'
,
'se4'
,
'se5'
,
'se6'
],
},
options
:
[
{
text
:
'se1'
,
value
:
'se1'
,
selected
:
true
},
{
text
:
'se2'
,
value
:
'se2'
,
selected
:
true
},
{
text
:
'se3'
,
value
:
'se3'
,
selected
:
true
},
{
text
:
'se4'
,
value
:
'se4'
,
selected
:
true
},
{
text
:
'se5'
,
value
:
'se5'
,
selected
:
true
},
{
text
:
'se6'
,
value
:
'se6'
,
selected
:
true
},
],
},
],
},
};
dashboard
=
new
DashboardModel
(
dashboardJSON
);
dashboard
.
processRepeats
(
false
);
});
it
(
'should panels in self row'
,
()
=>
{
const
panel_types
=
_
.
map
(
dashboard
.
panels
,
'type'
);
expect
(
panel_types
).
toEqual
([
'row'
,
'graph'
,
'graph'
,
'graph'
,
'graph'
,
'graph'
,
'graph'
,
'row'
,
'graph'
,
'graph'
,
'graph'
,
'graph'
,
'graph'
,
'graph'
,
]);
});
it
(
'should be placed in their places'
,
function
()
{
expect
(
dashboard
.
panels
[
0
].
gridPos
).
toMatchObject
({
x
:
0
,
y
:
0
,
h
:
1
,
w
:
24
});
expect
(
dashboard
.
panels
[
1
].
gridPos
).
toMatchObject
({
x
:
0
,
y
:
1
,
h
:
2
,
w
:
6
});
expect
(
dashboard
.
panels
[
2
].
gridPos
).
toMatchObject
({
x
:
6
,
y
:
1
,
h
:
2
,
w
:
6
});
expect
(
dashboard
.
panels
[
3
].
gridPos
).
toMatchObject
({
x
:
12
,
y
:
1
,
h
:
2
,
w
:
6
});
expect
(
dashboard
.
panels
[
4
].
gridPos
).
toMatchObject
({
x
:
18
,
y
:
1
,
h
:
2
,
w
:
6
});
expect
(
dashboard
.
panels
[
5
].
gridPos
).
toMatchObject
({
x
:
0
,
y
:
3
,
h
:
2
,
w
:
6
});
expect
(
dashboard
.
panels
[
6
].
gridPos
).
toMatchObject
({
x
:
6
,
y
:
3
,
h
:
2
,
w
:
6
});
expect
(
dashboard
.
panels
[
7
].
gridPos
).
toMatchObject
({
x
:
0
,
y
:
5
,
h
:
1
,
w
:
24
});
expect
(
dashboard
.
panels
[
8
].
gridPos
).
toMatchObject
({
x
:
0
,
y
:
6
,
h
:
2
,
w
:
6
});
expect
(
dashboard
.
panels
[
9
].
gridPos
).
toMatchObject
({
x
:
6
,
y
:
6
,
h
:
2
,
w
:
6
});
expect
(
dashboard
.
panels
[
10
].
gridPos
).
toMatchObject
({
x
:
12
,
y
:
6
,
h
:
2
,
w
:
6
});
expect
(
dashboard
.
panels
[
11
].
gridPos
).
toMatchObject
({
x
:
18
,
y
:
6
,
h
:
2
,
w
:
6
});
expect
(
dashboard
.
panels
[
12
].
gridPos
).
toMatchObject
({
x
:
0
,
y
:
8
,
h
:
2
,
w
:
6
});
expect
(
dashboard
.
panels
[
13
].
gridPos
).
toMatchObject
({
x
:
6
,
y
:
8
,
h
:
2
,
w
:
6
});
});
});
describe
(
'given dashboard with row repeat'
,
function
()
{
describe
(
'given dashboard with row repeat'
,
function
()
{
let
dashboard
,
dashboardJSON
;
let
dashboard
,
dashboardJSON
;
...
...
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