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
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
90 additions
and
38 deletions
+90
-38
public/app/features/dashboard/dashboard_model.ts
+42
-28
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,46 +404,60 @@ export class DashboardModel {
...
@@ -404,46 +404,60 @@ export class DashboardModel {
}
}
}
}
toggleRow
(
row
)
{
toggleRow
(
row
:
PanelModel
)
{
let
rowPanels
=
[];
let
rowIndex
=
_
.
indexOf
(
this
.
panels
,
row
);
let
rowFound
=
false
;
// if already collapsed
if
(
row
.
collapsed
)
{
if
(
row
.
collapse
)
{
row
.
collapsed
=
false
;
row
.
collapse
=
false
;
for
(
let
panel
of
row
.
panels
)
{
if
(
row
.
panels
.
length
>
0
)
{
this
.
panels
.
push
(
new
PanelModel
(
panel
));
// 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
)
{
// 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
=
[];
}
}
row
.
panels
=
[];
// sort panels
this
.
sortPanelsByGridPos
();
}
else
{
// emit change event
this
.
events
.
emit
(
'row-expanded'
);
return
;
}
for
(
let
index
=
0
;
index
<
this
.
panels
.
length
;
index
++
)
{
let
rowPanels
=
[];
let
panel
=
this
.
panels
[
index
];
if
(
rowFound
)
{
for
(
let
index
=
rowIndex
+
1
;
index
<
this
.
panels
.
length
;
index
++
)
{
// break when encountering another row
let
panel
=
this
.
panels
[
index
];
if
(
panel
.
type
===
'row'
)
{
break
;
}
// this panel must belong to row
// break when encountering another row
rowPanels
.
push
(
panel
);
if
(
panel
.
type
===
'row'
)
{
}
else
if
(
panel
===
row
)
{
break
;
rowFound
=
true
;
}
}
}
// remove panels
_
.
pull
(
this
.
panels
,
...
rowPanels
);
// this panel must belong to row
// save panel models inside row panel
rowPanels
.
push
(
panel
);
row
.
panels
=
_
.
map
(
rowPanels
,
panel
=>
panel
.
getSaveModel
());
row
.
collapse
=
true
;
}
}
// remove panels
_
.
pull
(
this
.
panels
,
...
rowPanels
);
// save panel models inside row panel
row
.
panels
=
_
.
map
(
rowPanels
,
panel
=>
panel
.
getSaveModel
());
row
.
collapsed
=
true
;
// emit change event
// emit change event
this
.
events
.
emit
(
'row-collapse
-change
d'
);
this
.
events
.
emit
(
'row-collapsed'
);
}
}
on
(
eventName
,
callback
)
{
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> {
...
@@ -70,7 +70,8 @@ export class DashboardGrid extends React.Component<DashboardGridProps, any> {
this
.
dashboard
.
on
(
'panel-removed'
,
this
.
triggerForceUpdate
.
bind
(
this
));
this
.
dashboard
.
on
(
'panel-removed'
,
this
.
triggerForceUpdate
.
bind
(
this
));
this
.
dashboard
.
on
(
'repeats-processed'
,
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
(
'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
()
{
buildLayout
()
{
...
@@ -98,7 +99,7 @@ export class DashboardGrid extends React.Component<DashboardGridProps, any> {
...
@@ -98,7 +99,7 @@ export class DashboardGrid extends React.Component<DashboardGridProps, any> {
panelPos
.
w
=
GRID_COLUMN_COUNT
;
panelPos
.
w
=
GRID_COLUMN_COUNT
;
panelPos
.
h
=
1
;
panelPos
.
h
=
1
;
panelPos
.
isResizable
=
false
;
panelPos
.
isResizable
=
false
;
panelPos
.
isDraggable
=
panel
.
collapse
;
panelPos
.
isDraggable
=
panel
.
collapse
d
;
}
}
layout
.
push
(
panelPos
);
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> {
...
@@ -13,7 +13,7 @@ export class DashboardRow extends React.Component<DashboardRowProps, any> {
super
(
props
);
super
(
props
);
this
.
state
=
{
this
.
state
=
{
collapse
:
this
.
props
.
panel
.
collapse
,
collapse
d
:
this
.
props
.
panel
.
collapsed
,
};
};
this
.
toggle
=
this
.
toggle
.
bind
(
this
);
this
.
toggle
=
this
.
toggle
.
bind
(
this
);
...
@@ -27,15 +27,15 @@ export class DashboardRow extends React.Component<DashboardRowProps, any> {
...
@@ -27,15 +27,15 @@ export class DashboardRow extends React.Component<DashboardRowProps, any> {
dashboard
.
toggleRow
(
this
.
props
.
panel
);
dashboard
.
toggleRow
(
this
.
props
.
panel
);
this
.
setState
(
prevState
=>
{
this
.
setState
(
prevState
=>
{
return
{
collapse
:
!
prevState
.
collapse
};
return
{
collapse
d
:
!
prevState
.
collapsed
};
});
});
}
}
openSettings
()
{}
openSettings
()
{}
render
()
{
render
()
{
const
classes
=
classNames
({
'dashboard-row'
:
true
,
'dashboard-row--collapse
'
:
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
,
'fa-chevron-right'
:
this
.
state
.
collapse
});
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
;
const
hiddenPanels
=
this
.
props
.
panel
.
panels
?
this
.
props
.
panel
.
panels
.
length
:
0
;
return
(
return
(
...
...
public/app/features/dashboard/dashnav/dashnav.ts
View file @
bc8c2409
...
@@ -146,14 +146,14 @@ export class DashNavCtrl {
...
@@ -146,14 +146,14 @@ export class DashNavCtrl {
}
}
addPanel
()
{
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
]);
this
.
dashboard
.
removePanel
(
this
.
dashboard
.
panels
[
0
]);
return
;
return
;
}
}
this
.
dashboard
.
addPanel
({
this
.
dashboard
.
addPanel
({
type
:
'add-panel'
,
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'
,
title
:
'New Graph'
,
});
});
}
}
...
...
public/app/features/dashboard/panel_model.ts
View file @
bc8c2409
...
@@ -27,7 +27,7 @@ export class PanelModel {
...
@@ -27,7 +27,7 @@ export class PanelModel {
repeatPanelId
?:
number
;
repeatPanelId
?:
number
;
repeatDirection
?:
string
;
repeatDirection
?:
string
;
minSpan
?:
number
;
minSpan
?:
number
;
collapse
?:
boolean
;
collapse
d
?:
boolean
;
panels
?:
any
;
panels
?:
any
;
// non persisted
// non persisted
...
...
public/app/features/dashboard/specs/dashboard_model_specs.ts
View file @
bc8c2409
...
@@ -583,4 +583,41 @@ describe('DashboardModel', function() {
...
@@ -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 @@
...
@@ -4,7 +4,7 @@
height
:
100%
;
height
:
100%
;
&
--collapse
{
&
--collapse
d
{
background
:
$panel-bg
;
background
:
$panel-bg
;
.dashboard-row__panel_count
{
.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