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
08a4317b
Unverified
Commit
08a4317b
authored
Feb 09, 2020
by
Ryan McKinley
Committed by
GitHub
Feb 09, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
DashNavTimeControls: remove $injector and rootScope from time picker (#22041)
parent
17287420
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
19 deletions
+11
-19
public/app/features/dashboard/components/DashNav/DashNav.tsx
+2
-7
public/app/features/dashboard/components/DashNav/DashNavTimeControls.tsx
+9
-12
No files found.
public/app/features/dashboard/components/DashNav/DashNav.tsx
View file @
08a4317b
...
...
@@ -170,7 +170,7 @@ export class DashNav extends PureComponent<Props> {
}
render
()
{
const
{
dashboard
,
onAddPanel
,
location
,
$injector
}
=
this
.
props
;
const
{
dashboard
,
onAddPanel
,
location
}
=
this
.
props
;
const
{
canStar
,
canSave
,
canShare
,
showSettings
,
isStarred
}
=
dashboard
.
meta
;
const
{
snapshot
}
=
dashboard
;
const
snapshotUrl
=
snapshot
&&
snapshot
.
originalUrl
;
...
...
@@ -264,12 +264,7 @@ export class DashNav extends PureComponent<Props> {
{
!
dashboard
.
timepicker
.
hidden
&&
(
<
div
className=
"navbar-buttons"
>
<
DashNavTimeControls
$injector=
{
$injector
}
dashboard=
{
dashboard
}
location=
{
location
}
updateLocation=
{
updateLocation
}
/>
<
DashNavTimeControls
dashboard=
{
dashboard
}
location=
{
location
}
updateLocation=
{
updateLocation
}
/>
</
div
>
)
}
</
div
>
...
...
public/app/features/dashboard/components/DashNav/DashNavTimeControls.tsx
View file @
08a4317b
...
...
@@ -16,7 +16,8 @@ import { RefreshPicker, withTheme, stylesFactory, Themeable } from '@grafana/ui'
import
{
TimePickerWithHistory
}
from
'app/core/components/TimePicker/TimePickerWithHistory'
;
// Utils & Services
import
{
getTimeSrv
,
TimeSrv
}
from
'app/features/dashboard/services/TimeSrv'
;
import
{
getTimeSrv
}
from
'app/features/dashboard/services/TimeSrv'
;
import
{
appEvents
}
from
'app/core/core'
;
const
getStyles
=
stylesFactory
((
theme
:
GrafanaTheme
)
=>
{
return
{
...
...
@@ -29,15 +30,11 @@ const getStyles = stylesFactory((theme: GrafanaTheme) => {
});
export
interface
Props
extends
Themeable
{
$injector
:
any
;
dashboard
:
DashboardModel
;
updateLocation
:
typeof
updateLocation
;
location
:
LocationState
;
}
class
UnthemedDashNavTimeControls
extends
Component
<
Props
>
{
timeSrv
:
TimeSrv
=
getTimeSrv
();
$rootScope
=
this
.
props
.
$injector
.
get
(
'$rootScope'
);
componentDidMount
()
{
// Only reason for this is that sometimes time updates can happen via redux location changes
// and this happens before timeSrv has had chance to update state (as it listens to angular route-updated)
...
...
@@ -58,20 +55,20 @@ class UnthemedDashNavTimeControls extends Component<Props> {
}
onChangeRefreshInterval
=
(
interval
:
string
)
=>
{
this
.
timeSrv
.
setAutoRefresh
(
interval
);
getTimeSrv
()
.
setAutoRefresh
(
interval
);
this
.
forceUpdate
();
};
onRefresh
=
()
=>
{
this
.
timeSrv
.
refreshDashboard
();
getTimeSrv
()
.
refreshDashboard
();
return
Promise
.
resolve
();
};
onMoveBack
=
()
=>
{
this
.
$rootScope
.
appEven
t
(
CoreEvents
.
shiftTime
,
-
1
);
appEvents
.
emi
t
(
CoreEvents
.
shiftTime
,
-
1
);
};
onMoveForward
=
()
=>
{
this
.
$rootScope
.
appEven
t
(
CoreEvents
.
shiftTime
,
1
);
appEvents
.
emi
t
(
CoreEvents
.
shiftTime
,
1
);
};
onChangeTimePicker
=
(
timeRange
:
TimeRange
)
=>
{
...
...
@@ -86,17 +83,17 @@ class UnthemedDashNavTimeControls extends Component<Props> {
to
:
hasDelay
?
'now-'
+
panel
.
nowDelay
:
adjustedTo
,
};
this
.
timeSrv
.
setTime
(
nextRange
);
getTimeSrv
()
.
setTime
(
nextRange
);
};
onZoom
=
()
=>
{
this
.
$rootScope
.
appEven
t
(
CoreEvents
.
zoomOut
,
2
);
appEvents
.
emi
t
(
CoreEvents
.
zoomOut
,
2
);
};
render
()
{
const
{
dashboard
,
theme
}
=
this
.
props
;
const
intervals
=
dashboard
.
timepicker
.
refresh_intervals
;
const
timePickerValue
=
this
.
timeSrv
.
timeRange
();
const
timePickerValue
=
getTimeSrv
()
.
timeRange
();
const
timeZone
=
dashboard
.
getTimezone
();
const
styles
=
getStyles
(
theme
);
...
...
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