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
bbc5dff7
Commit
bbc5dff7
authored
Feb 05, 2019
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed add panel should scroll to top
parent
fd1ef0a2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
85 additions
and
99 deletions
+85
-99
public/app/features/dashboard/components/DashNav/DashNav.tsx
+70
-83
public/app/features/dashboard/containers/DashboardPage.tsx
+15
-16
No files found.
public/app/features/dashboard/components/DashNav/DashNav.tsx
View file @
bbc5dff7
...
...
@@ -23,6 +23,7 @@ export interface Props {
isFullscreen
:
boolean
;
$injector
:
any
;
updateLocation
:
typeof
updateLocation
;
onAddPanel
:
()
=>
void
;
}
export
class
DashNav
extends
PureComponent
<
Props
>
{
...
...
@@ -39,7 +40,8 @@ export class DashNav extends PureComponent<Props> {
componentDidMount
()
{
const
loader
=
getAngularLoader
();
const
template
=
'<gf-time-picker class="gf-timepicker-nav" dashboard="dashboard" ng-if="!dashboard.timepicker.hidden" />'
;
const
template
=
'<gf-time-picker class="gf-timepicker-nav" dashboard="dashboard" ng-if="!dashboard.timepicker.hidden" />'
;
const
scopeProps
=
{
dashboard
:
this
.
props
.
dashboard
};
this
.
timepickerCmp
=
loader
.
load
(
this
.
timePickerEl
,
scopeProps
,
template
);
...
...
@@ -55,21 +57,6 @@ export class DashNav extends PureComponent<Props> {
appEvents
.
emit
(
'show-dash-search'
);
};
onAddPanel
=
()
=>
{
const
{
dashboard
}
=
this
.
props
;
// Return if the "Add panel" exists already
if
(
dashboard
.
panels
.
length
>
0
&&
dashboard
.
panels
[
0
].
type
===
'add-panel'
)
{
return
;
}
dashboard
.
addPanel
({
type
:
'add-panel'
,
gridPos
:
{
x
:
0
,
y
:
0
,
w
:
12
,
h
:
8
},
title
:
'Panel Title'
,
});
};
onClose
=
()
=>
{
if
(
this
.
props
.
editview
)
{
this
.
props
.
updateLocation
({
...
...
@@ -137,7 +124,7 @@ export class DashNav extends PureComponent<Props> {
};
render
()
{
const
{
dashboard
,
isFullscreen
,
editview
}
=
this
.
props
;
const
{
dashboard
,
isFullscreen
,
editview
,
onAddPanel
}
=
this
.
props
;
const
{
canStar
,
canSave
,
canShare
,
folderTitle
,
showSettings
,
isStarred
}
=
dashboard
.
meta
;
const
{
snapshot
}
=
dashboard
;
...
...
@@ -186,73 +173,73 @@ export class DashNav extends PureComponent<Props> {
tooltip=
"Add panel"
classSuffix=
"add-panel"
icon=
"gicon gicon-add-panel"
onClick=
{
this
.
onAddPanel
}
onClick=
{
onAddPanel
}
/>
)
}
{
canStar
&&
(
<
DashNavButton
tooltip=
"Mark as favorite"
classSuffix=
"star"
icon=
{
`${isStarred ? 'fa fa-star' : 'fa fa-star-o'}`
}
onClick=
{
this
.
onStarDashboard
}
/>
)
}
{
canShare
&&
(
<
DashNavButton
tooltip=
"Share dashboard"
classSuffix=
"share"
icon=
"fa fa-share-square-o"
onClick=
{
this
.
onOpenShare
}
/>
)
}
{
canSave
&&
(
<
DashNavButton
tooltip=
"Save dashboard"
classSuffix=
"save"
icon=
"fa fa-save"
onClick=
{
this
.
onSave
}
/>
)
}
{
snapshotUrl
&&
(
<
DashNavButton
tooltip=
"Open original dashboard"
classSuffix=
"snapshot-origin"
icon=
"fa fa-link"
href=
{
snapshotUrl
}
/>
)
}
{
showSettings
&&
(
<
DashNavButton
tooltip=
"Dashboard settings"
classSuffix=
"settings"
icon=
"fa fa-cog"
onClick=
{
this
.
onOpenSettings
}
/>
)
}
</
div
>
<
div
className=
"navbar-buttons navbar-buttons--tv"
>
<
DashNavButton
tooltip=
"Cycke view mode"
classSuffix=
"tv"
icon=
"fa fa-desktop"
onClick=
{
this
.
onToggleTVMode
}
/>
</
div
>
<
div
className=
"gf-timepicker-nav"
ref=
{
element
=>
(
this
.
timePickerEl
=
element
)
}
/>
{
(
isFullscreen
||
editview
)
&&
(
<
div
className=
"navbar-buttons navbar-buttons--close"
>
<
DashNavButton
tooltip=
"Back to dashboard"
classSuffix=
"primary"
icon=
"fa fa-reply"
onClick=
{
this
.
onClose
}
/>
</
div
>
)
}
</
div
>
)
}
{
canStar
&&
(
<
DashNavButton
tooltip=
"Mark as favorite"
classSuffix=
"star"
icon=
{
`${isStarred ? 'fa fa-star' : 'fa fa-star-o'}`
}
onClick=
{
this
.
onStarDashboard
}
/>
)
}
{
canShare
&&
(
<
DashNavButton
tooltip=
"Share dashboard"
classSuffix=
"share"
icon=
"fa fa-share-square-o"
onClick=
{
this
.
onOpenShare
}
/>
)
}
{
canSave
&&
(
<
DashNavButton
tooltip=
"Save dashboard"
classSuffix=
"save"
icon=
"fa fa-save"
onClick=
{
this
.
onSave
}
/>
)
}
{
snapshotUrl
&&
(
<
DashNavButton
tooltip=
"Open original dashboard"
classSuffix=
"snapshot-origin"
icon=
"fa fa-link"
href=
{
snapshotUrl
}
/>
)
}
{
showSettings
&&
(
<
DashNavButton
tooltip=
"Dashboard settings"
classSuffix=
"settings"
icon=
"fa fa-cog"
onClick=
{
this
.
onOpenSettings
}
/>
)
}
</
div
>
<
div
className=
"navbar-buttons navbar-buttons--tv"
>
<
DashNavButton
tooltip=
"Cycke view mode"
classSuffix=
"tv"
icon=
"fa fa-desktop"
onClick=
{
this
.
onToggleTVMode
}
/>
</
div
>
<
div
className=
"gf-timepicker-nav"
ref=
{
element
=>
(
this
.
timePickerEl
=
element
)
}
/>
{
(
isFullscreen
||
editview
)
&&
(
<
div
className=
"navbar-buttons navbar-buttons--close"
>
<
DashNavButton
tooltip=
"Back to dashboard"
classSuffix=
"primary"
icon=
"fa fa-reply"
onClick=
{
this
.
onClose
}
/>
</
div
>
)
}
</
div
>
);
}
}
...
...
public/app/features/dashboard/containers/DashboardPage.tsx
View file @
bbc5dff7
...
...
@@ -178,25 +178,23 @@ export class DashboardPage extends PureComponent<Props, State> {
this
.
setState
({
scrollTop
:
target
.
scrollTop
});
};
renderDashboard
()
{
const
{
dashboard
,
editview
}
=
this
.
props
;
const
{
isEditing
,
isFullscreen
}
=
this
.
state
;
onAddPanel
=
()
=>
{
const
{
dashboard
}
=
this
.
props
;
const
classes
=
classNames
({
'dashboard-container'
:
true
,
'dashboard-container--has-submenu'
:
dashboard
.
meta
.
submenuEnabled
,
}
);
// Return if the "Add panel" exists already
if
(
dashboard
.
panels
.
length
>
0
&&
dashboard
.
panels
[
0
].
type
===
'add-panel'
)
{
return
;
}
return
(
<
div
className=
"scroll-canvas scroll-canvas--dashboard"
>
{
dashboard
&&
editview
&&
<
DashboardSettings
dashboard=
{
dashboard
}
/>
}
dashboard
.
addPanel
({
type
:
'add-panel'
,
gridPos
:
{
x
:
0
,
y
:
0
,
w
:
12
,
h
:
8
},
title
:
'Panel Title'
,
});
<
div
className=
{
classes
}
>
<
DashboardGrid
dashboard=
{
dashboard
}
isEditing=
{
isEditing
}
isFullscreen=
{
isFullscreen
}
/>
</
div
>
</
div
>
);
}
// scroll to top after adding panel
this
.
setState
({
scrollTop
:
0
});
};
render
()
{
const
{
dashboard
,
editview
,
$injector
}
=
this
.
props
;
...
...
@@ -224,6 +222,7 @@ export class DashboardPage extends PureComponent<Props, State> {
isFullscreen=
{
isFullscreen
}
editview=
{
editview
}
$injector=
{
$injector
}
onAddPanel=
{
this
.
onAddPanel
}
/>
<
div
className=
"scroll-canvas scroll-canvas--dashboard"
>
<
CustomScrollbar
autoHeightMin=
{
'100%'
}
setScrollTop=
{
this
.
setScrollTop
}
scrollTop=
{
scrollTop
}
>
...
...
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