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
bc8c2409
Commit
bc8c2409
authored
Oct 17, 2017
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ux: work on rows
parent
e375159e
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
78 additions
and
26 deletions
+78
-26
public/app/features/dashboard/dashboard_model.ts
+30
-16
public/app/features/dashboard/dashgrid/DashboardGrid.tsx
+3
-2
public/app/features/dashboard/dashgrid/DashboardRow.tsx
+4
-4
public/app/features/dashboard/dashnav/dashnav.ts
+2
-2
public/app/features/dashboard/panel_model.ts
+1
-1
public/app/features/dashboard/specs/dashboard_model_specs.ts
+37
-0
public/sass/components/_row.scss
+1
-1
No files found.
public/app/features/dashboard/dashboard_model.ts
View file @
bc8c2409
...
...
@@ -404,26 +404,43 @@ export class DashboardModel {
}
}
toggleRow
(
row
)
{
let
rowPanels
=
[];
let
rowFound
=
false
;
toggleRow
(
row
:
PanelModel
)
{
let
rowIndex
=
_
.
indexOf
(
this
.
panels
,
row
);
if
(
row
.
collapsed
)
{
row
.
collapsed
=
false
;
// if already collapsed
if
(
row
.
collapse
)
{
row
.
collapse
=
false
;
if
(
row
.
panels
.
length
>
0
)
{
// Use first panel to figure out if it was moved or pushed
let
firstPanel
=
row
.
panels
[
0
];
let
yDiff
=
firstPanel
.
gridPos
.
y
-
(
row
.
gridPos
.
y
+
row
.
gridPos
.
h
);
// start inserting after row
let
insertPos
=
rowIndex
+
1
;
for
(
let
panel
of
row
.
panels
)
{
this
.
panels
.
push
(
new
PanelModel
(
panel
));
// make sure y is adjusted (in case row moved while collapsed)
panel
.
gridPos
.
y
-=
yDiff
;
// insert after row
this
.
panels
.
splice
(
insertPos
,
0
,
new
PanelModel
(
panel
));
insertPos
+=
1
;
}
row
.
panels
=
[];
}
}
else
{
// sort panels
this
.
sortPanelsByGridPos
();
for
(
let
index
=
0
;
index
<
this
.
panels
.
length
;
index
++
)
{
// emit change event
this
.
events
.
emit
(
'row-expanded'
);
return
;
}
let
rowPanels
=
[];
for
(
let
index
=
rowIndex
+
1
;
index
<
this
.
panels
.
length
;
index
++
)
{
let
panel
=
this
.
panels
[
index
];
if
(
rowFound
)
{
// break when encountering another row
if
(
panel
.
type
===
'row'
)
{
break
;
...
...
@@ -431,19 +448,16 @@ export class DashboardModel {
// this panel must belong to row
rowPanels
.
push
(
panel
);
}
else
if
(
panel
===
row
)
{
rowFound
=
true
;
}
}
// remove panels
_
.
pull
(
this
.
panels
,
...
rowPanels
);
// save panel models inside row panel
row
.
panels
=
_
.
map
(
rowPanels
,
panel
=>
panel
.
getSaveModel
());
row
.
collapse
=
true
;
}
row
.
collapsed
=
true
;
// emit change event
this
.
events
.
emit
(
'row-collapse
-change
d'
);
this
.
events
.
emit
(
'row-collapsed'
);
}
on
(
eventName
,
callback
)
{
...
...
public/app/features/dashboard/dashgrid/DashboardGrid.tsx
View file @
bc8c2409
...
...
@@ -70,7 +70,8 @@ export class DashboardGrid extends React.Component<DashboardGridProps, any> {
this
.
dashboard
.
on
(
'panel-removed'
,
this
.
triggerForceUpdate
.
bind
(
this
));
this
.
dashboard
.
on
(
'repeats-processed'
,
this
.
triggerForceUpdate
.
bind
(
this
));
this
.
dashboard
.
on
(
'view-mode-changed'
,
this
.
triggerForceUpdate
.
bind
(
this
));
this
.
dashboard
.
on
(
'row-collapse-changed'
,
this
.
triggerForceUpdate
.
bind
(
this
));
this
.
dashboard
.
on
(
'row-collapsed'
,
this
.
triggerForceUpdate
.
bind
(
this
));
this
.
dashboard
.
on
(
'row-expanded'
,
this
.
triggerForceUpdate
.
bind
(
this
));
}
buildLayout
()
{
...
...
@@ -98,7 +99,7 @@ export class DashboardGrid extends React.Component<DashboardGridProps, any> {
panelPos
.
w
=
GRID_COLUMN_COUNT
;
panelPos
.
h
=
1
;
panelPos
.
isResizable
=
false
;
panelPos
.
isDraggable
=
panel
.
collapse
;
panelPos
.
isDraggable
=
panel
.
collapse
d
;
}
layout
.
push
(
panelPos
);
...
...
public/app/features/dashboard/dashgrid/DashboardRow.tsx
View file @
bc8c2409
...
...
@@ -13,7 +13,7 @@ export class DashboardRow extends React.Component<DashboardRowProps, any> {
super
(
props
);
this
.
state
=
{
collapse
:
this
.
props
.
panel
.
collapse
,
collapse
d
:
this
.
props
.
panel
.
collapsed
,
};
this
.
toggle
=
this
.
toggle
.
bind
(
this
);
...
...
@@ -27,15 +27,15 @@ export class DashboardRow extends React.Component<DashboardRowProps, any> {
dashboard
.
toggleRow
(
this
.
props
.
panel
);
this
.
setState
(
prevState
=>
{
return
{
collapse
:
!
prevState
.
collapse
};
return
{
collapse
d
:
!
prevState
.
collapsed
};
});
}
openSettings
()
{}
render
()
{
const
classes
=
classNames
({
'dashboard-row'
:
true
,
'dashboard-row--collapse
'
:
this
.
state
.
collapse
});
const
chevronClass
=
classNames
({
'fa'
:
true
,
'fa-chevron-down'
:
!
this
.
state
.
collapse
,
'fa-chevron-right'
:
this
.
state
.
collapse
});
const
classes
=
classNames
({
'dashboard-row'
:
true
,
'dashboard-row--collapse
d'
:
this
.
state
.
collapsed
});
const
chevronClass
=
classNames
({
'fa'
:
true
,
'fa-chevron-down'
:
!
this
.
state
.
collapse
d
,
'fa-chevron-right'
:
this
.
state
.
collapsed
});
const
hiddenPanels
=
this
.
props
.
panel
.
panels
?
this
.
props
.
panel
.
panels
.
length
:
0
;
return
(
...
...
public/app/features/dashboard/dashnav/dashnav.ts
View file @
bc8c2409
...
...
@@ -146,14 +146,14 @@ export class DashNavCtrl {
}
addPanel
()
{
if
(
this
.
dashboard
.
panels
[
0
].
type
===
'add-panel'
)
{
if
(
this
.
dashboard
.
panels
.
length
>
0
&&
this
.
dashboard
.
panels
[
0
].
type
===
'add-panel'
)
{
this
.
dashboard
.
removePanel
(
this
.
dashboard
.
panels
[
0
]);
return
;
}
this
.
dashboard
.
addPanel
({
type
:
'add-panel'
,
gridPos
:
{
x
:
0
,
y
:
0
,
w
:
12
,
h
:
9
,
static
:
true
},
gridPos
:
{
x
:
0
,
y
:
0
,
w
:
12
,
h
:
9
},
title
:
'New Graph'
,
});
}
...
...
public/app/features/dashboard/panel_model.ts
View file @
bc8c2409
...
...
@@ -27,7 +27,7 @@ export class PanelModel {
repeatPanelId
?:
number
;
repeatDirection
?:
string
;
minSpan
?:
number
;
collapse
?:
boolean
;
collapse
d
?:
boolean
;
panels
?:
any
;
// non persisted
...
...
public/app/features/dashboard/specs/dashboard_model_specs.ts
View file @
bc8c2409
...
...
@@ -583,4 +583,41 @@ describe('DashboardModel', function() {
});
describe
(
'When expanding row'
,
function
(
ctx
)
{
var
dashboard
;
beforeEach
(
function
()
{
dashboard
=
new
DashboardModel
({
panels
:
[
{
id
:
1
,
type
:
'graph'
,
gridPos
:
{
x
:
0
,
y
:
0
,
w
:
24
,
h
:
6
}},
{
id
:
2
,
type
:
'row'
,
gridPos
:
{
x
:
0
,
y
:
6
,
w
:
24
,
h
:
2
},
collapsed
:
true
,
panels
:
[
{
id
:
3
,
type
:
'graph'
,
gridPos
:
{
x
:
0
,
y
:
2
,
w
:
12
,
h
:
2
}},
{
id
:
4
,
type
:
'graph'
,
gridPos
:
{
x
:
12
,
y
:
2
,
w
:
12
,
h
:
2
}},
]
},
],
});
dashboard
.
toggleRow
(
dashboard
.
panels
[
1
]);
});
it
(
'should add panels back'
,
function
()
{
expect
(
dashboard
.
panels
.
length
).
to
.
eql
(
4
);
});
it
(
'should add them below row in array'
,
function
()
{
expect
(
dashboard
.
panels
[
2
].
id
).
to
.
eql
(
3
);
expect
(
dashboard
.
panels
[
3
].
id
).
to
.
eql
(
4
);
});
it
(
'should position them below row'
,
function
()
{
expect
(
dashboard
.
panels
[
2
].
gridPos
).
to
.
eql
({
x
:
0
,
y
:
8
,
w
:
12
,
h
:
2
});
});
});
});
public/sass/components/_row.scss
View file @
bc8c2409
...
...
@@ -4,7 +4,7 @@
height
:
100%
;
&
--collapse
{
&
--collapse
d
{
background
:
$panel-bg
;
.dashboard-row__panel_count
{
...
...
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