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
a007730f
Commit
a007730f
authored
Dec 18, 2018
by
Johannes Schill
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Another take on resizing the panel, now using react-draggable
parent
a4091813
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
114 additions
and
38 deletions
+114
-38
public/app/features/dashboard/dashgrid/DashboardPanel.tsx
+16
-4
public/app/features/dashboard/dashgrid/PanelResizer.tsx
+69
-0
public/sass/_variables.dark.scss
+4
-0
public/sass/_variables.light.scss
+4
-0
public/sass/components/_panel_editor.scss
+21
-34
No files found.
public/app/features/dashboard/dashgrid/DashboardPanel.tsx
View file @
a007730f
...
@@ -14,6 +14,7 @@ import { PanelEditor } from './PanelEditor';
...
@@ -14,6 +14,7 @@ import { PanelEditor } from './PanelEditor';
import
{
PanelModel
}
from
'../panel_model'
;
import
{
PanelModel
}
from
'../panel_model'
;
import
{
DashboardModel
}
from
'../dashboard_model'
;
import
{
DashboardModel
}
from
'../dashboard_model'
;
import
{
PanelPlugin
}
from
'app/types'
;
import
{
PanelPlugin
}
from
'app/types'
;
import
{
PanelResizer
}
from
'./PanelResizer'
;
export
interface
Props
{
export
interface
Props
{
panel
:
PanelModel
;
panel
:
PanelModel
;
...
@@ -158,10 +159,21 @@ export class DashboardPanel extends PureComponent<Props, State> {
...
@@ -158,10 +159,21 @@ export class DashboardPanel extends PureComponent<Props, State> {
return
(
return
(
<
div
className=
{
containerClass
}
>
<
div
className=
{
containerClass
}
>
<
div
className=
{
panelWrapperClass
}
onMouseEnter=
{
this
.
onMouseEnter
}
onMouseLeave=
{
this
.
onMouseLeave
}
>
<
PanelResizer
{
plugin
.
exports
.
Panel
&&
this
.
renderReactPanel
()
}
isEditing=
{
!!
isEditing
}
{
plugin
.
exports
.
PanelCtrl
&&
this
.
renderAngularPanel
()
}
panel=
{
panel
}
</
div
>
render=
{
(
panelHeight
:
number
|
'inherit'
)
=>
(
<
div
className=
{
panelWrapperClass
}
onMouseEnter=
{
this
.
onMouseEnter
}
onMouseLeave=
{
this
.
onMouseLeave
}
style=
{
{
height
:
panelHeight
}
}
>
{
plugin
.
exports
.
Panel
&&
this
.
renderReactPanel
()
}
{
plugin
.
exports
.
PanelCtrl
&&
this
.
renderAngularPanel
()
}
</
div
>
)
}
/>
{
panel
.
isEditing
&&
(
{
panel
.
isEditing
&&
(
<
PanelEditor
<
PanelEditor
panel=
{
panel
}
panel=
{
panel
}
...
...
public/app/features/dashboard/dashgrid/PanelResizer.tsx
0 → 100644
View file @
a007730f
import
React
,
{
PureComponent
}
from
'react'
;
import
{
debounce
,
throttle
}
from
'lodash'
;
import
Draggable
from
'react-draggable'
;
import
{
PanelModel
}
from
'../panel_model'
;
interface
Props
{
isEditing
:
boolean
;
render
:
(
height
:
number
|
'inherit'
)
=>
JSX
.
Element
;
panel
:
PanelModel
;
}
interface
State
{
editorHeight
:
number
;
}
export
class
PanelResizer
extends
PureComponent
<
Props
,
State
>
{
initialHeight
:
number
=
Math
.
floor
(
document
.
documentElement
.
scrollHeight
*
0.4
);
prevEditorHeight
:
number
;
debouncedChangeHeight
:
(
height
:
number
)
=>
void
;
debouncedResizeDone
:
()
=>
void
;
constructor
(
props
)
{
super
(
props
);
const
{
panel
}
=
this
.
props
;
this
.
state
=
{
editorHeight
:
this
.
initialHeight
,
};
this
.
debouncedChangeHeight
=
throttle
(
this
.
changeHeight
,
20
,
{
trailing
:
true
});
this
.
debouncedResizeDone
=
debounce
(()
=>
{
panel
.
resizeDone
();
},
200
);
}
changeHeight
=
height
=>
{
this
.
prevEditorHeight
=
this
.
state
.
editorHeight
;
this
.
setState
({
editorHeight
:
height
,
});
};
onDrag
=
(
evt
,
data
)
=>
{
const
newHeight
=
this
.
state
.
editorHeight
+
data
.
y
;
this
.
debouncedChangeHeight
(
newHeight
);
this
.
debouncedResizeDone
();
};
render
()
{
const
{
render
,
isEditing
}
=
this
.
props
;
const
{
editorHeight
}
=
this
.
state
;
return
(
<>
{
render
(
isEditing
?
editorHeight
:
'inherit'
)
}
{
isEditing
&&
(
<
div
className=
"panel-editor-container__resizer"
>
<
Draggable
axis=
"y"
grid=
{
[
100
,
1
]
}
onDrag=
{
this
.
onDrag
}
position=
{
{
x
:
0
,
y
:
0
}
}
>
<
div
className=
"panel-editor-resizer"
>
<
div
className=
"panel-editor-resizer__handle"
/>
</
div
>
</
Draggable
>
</
div
>
)
}
</>
);
}
}
public/sass/_variables.dark.scss
View file @
a007730f
...
@@ -400,3 +400,7 @@ $logs-color-unkown: $gray-2;
...
@@ -400,3 +400,7 @@ $logs-color-unkown: $gray-2;
$button-toggle-group-btn-active-bg
:
linear-gradient
(
90deg
,
$orange
,
$red
);
$button-toggle-group-btn-active-bg
:
linear-gradient
(
90deg
,
$orange
,
$red
);
$button-toggle-group-btn-active-shadow
:
inset
0
0
4px
$black
;
$button-toggle-group-btn-active-shadow
:
inset
0
0
4px
$black
;
$button-toggle-group-btn-seperator-border
:
1px
solid
$page-bg
;
$button-toggle-group-btn-seperator-border
:
1px
solid
$page-bg
;
$vertical-resize-handle-bg
:
$dark-5
;
$vertical-resize-handle-dots
:
$gray-1
;
$vertical-resize-handle-dots-hover
:
$gray-2
;
public/sass/_variables.light.scss
View file @
a007730f
...
@@ -409,3 +409,7 @@ $logs-color-unkown: $gray-5;
...
@@ -409,3 +409,7 @@ $logs-color-unkown: $gray-5;
$button-toggle-group-btn-active-bg
:
$brand-primary
;
$button-toggle-group-btn-active-bg
:
$brand-primary
;
$button-toggle-group-btn-active-shadow
:
inset
0
0
4px
$white
;
$button-toggle-group-btn-active-shadow
:
inset
0
0
4px
$white
;
$button-toggle-group-btn-seperator-border
:
1px
solid
$gray-6
;
$button-toggle-group-btn-seperator-border
:
1px
solid
$gray-6
;
$vertical-resize-handle-bg
:
$gray-4
;
$vertical-resize-handle-dots
:
$gray-3
;
$vertical-resize-handle-dots-hover
:
$gray-2
;
public/sass/components/_panel_editor.scss
View file @
a007730f
...
@@ -84,46 +84,34 @@
...
@@ -84,46 +84,34 @@
}
}
}
}
.panel-editor-resizer
{
.panel-editor-container__resizer
{
position
:
absolute
;
position
:
relative
;
height
:
2px
;
margin-top
:
-3px
;
width
:
100%
;
top
:
-23px
;
text-align
:
center
;
border-bottom
:
2px
dashed
transparent
;
&
:hover
{
transition
:
border-color
0
.2s
ease-in
0
.4s
;
transition-delay
:
0
.2s
;
border-color
:
$text-color-faint
;
}
}
}
.panel-editor-resizer__handle
{
.panel-editor-resizer__handle
{
display
:
inline-block
;
width
:
180px
;
position
:
relative
;
position
:
relative
;
border-radius
:
2px
;
display
:
block
;
height
:
7px
;
background
:
$vertical-resize-handle-bg
;
cursor
:
grabbing
;
width
:
150px
;
background
:
$input-label-bg
;
margin-left
:
-75px
;
top
:
-9px
;
height
:
6px
;
cursor
:
ns-resize
;
border-radius
:
3px
;
margin
:
0
auto
;
&
:hover
{
&
:
:
before
{
transition
:
background
0
.2s
ease-in
0
.4s
;
content
:
' '
;
transition-delay
:
0
.2s
;
position
:
absolute
;
background
:
linear-gradient
(
90deg
,
$orange
,
$red
);
left
:
10px
;
.panel-editor-resizer__handle-dots
{
right
:
10px
;
transition
:
opacity
0
.2s
ease-in
;
top
:
2px
;
opacity
:
0
;
border-top
:
2px
dotted
$vertical-resize-handle-dots
;
}
}
}
}
.panel-editor-resizer__handle-dots
{
&
:hover::before
{
border-top
:
2px
dashed
$text-color-faint
;
border-color
:
$vertical-resize-handle-dots-hover
;
position
:
relative
;
}
top
:
4px
;
}
}
.viz-picker
{
.viz-picker
{
...
@@ -149,7 +137,6 @@
...
@@ -149,7 +137,6 @@
display
:
flex
;
display
:
flex
;
margin-right
:
10px
;
margin-right
:
10px
;
margin-bottom
:
10px
;
margin-bottom
:
10px
;
//border: 1px solid transparent;
align-items
:
center
;
align-items
:
center
;
justify-content
:
center
;
justify-content
:
center
;
padding-bottom
:
6px
;
padding-bottom
:
6px
;
...
...
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