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
bcf28cb7
Commit
bcf28cb7
authored
Aug 01, 2019
by
kay delaney
Committed by
Leonard Gram
Aug 01, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Shortcuts] Fixes shortcuts for moving time range backwards and forwards (#18305)
Closes #18159
parent
21f702f7
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
16 deletions
+20
-16
public/app/core/services/keybindingSrv.ts
+2
-2
public/app/features/dashboard/components/DashNav/DashNavTimeControls.tsx
+6
-13
public/app/features/dashboard/services/TimeSrv.ts
+12
-1
No files found.
public/app/core/services/keybindingSrv.ts
View file @
bcf28cb7
...
...
@@ -162,11 +162,11 @@ export class KeybindingSrv {
});
this
.
bind
(
't left'
,
()
=>
{
scope
.
appEvent
(
'shift-time
-backward'
);
scope
.
appEvent
(
'shift-time
'
,
-
1
);
});
this
.
bind
(
't right'
,
()
=>
{
scope
.
appEvent
(
'shift-time
-forward'
);
scope
.
appEvent
(
'shift-time
'
,
1
);
});
// edit panel
...
...
public/app/features/dashboard/components/DashNav/DashNavTimeControls.tsx
View file @
bcf28cb7
// Libaries
import
React
,
{
Component
}
from
'react'
;
import
{
toUtc
,
dateMath
}
from
'@grafana/data'
;
import
{
dateMath
}
from
'@grafana/data'
;
// Types
import
{
DashboardModel
}
from
'../../state'
;
...
...
@@ -16,7 +16,6 @@ import { TimePicker, RefreshPicker } from '@grafana/ui';
// Utils & Services
import
{
getTimeSrv
,
TimeSrv
}
from
'app/features/dashboard/services/TimeSrv'
;
import
{
defaultSelectOptions
}
from
'@grafana/ui/src/components/TimePicker/TimePicker'
;
import
{
getShiftedTimeRange
}
from
'app/core/utils/timePicker'
;
export
interface
Props
{
$injector
:
any
;
...
...
@@ -43,18 +42,12 @@ export class DashNavTimeControls extends Component<Props> {
return
Promise
.
resolve
();
};
onMoveTimePicker
=
(
direction
:
number
)
=>
{
const
range
=
this
.
timeSrv
.
timeRange
();
const
{
from
,
to
}
=
getShiftedTimeRange
(
direction
,
range
);
this
.
timeSrv
.
setTime
({
from
:
toUtc
(
from
),
to
:
toUtc
(
to
),
});
onMoveBack
=
()
=>
{
this
.
$rootScope
.
appEvent
(
'shift-time'
,
-
1
);
};
onMoveForward
=
()
=>
{
this
.
$rootScope
.
appEvent
(
'shift-time'
,
1
);
};
onMoveForward
=
()
=>
this
.
onMoveTimePicker
(
1
);
onMoveBack
=
()
=>
this
.
onMoveTimePicker
(
-
1
);
onChangeTimePicker
=
(
timeRange
:
TimeRange
)
=>
{
const
{
dashboard
}
=
this
.
props
;
...
...
public/app/features/dashboard/services/TimeSrv.ts
View file @
bcf28cb7
...
...
@@ -12,7 +12,7 @@ import { ITimeoutService, ILocationService } from 'angular';
import
{
ContextSrv
}
from
'app/core/services/context_srv'
;
import
{
DashboardModel
}
from
'../state/DashboardModel'
;
import
{
toUtc
,
dateTime
,
isDateTime
}
from
'@grafana/data'
;
import
{
getZoomedTimeRange
}
from
'app/core/utils/timePicker'
;
import
{
getZoomedTimeRange
,
getShiftedTimeRange
}
from
'app/core/utils/timePicker'
;
export
class
TimeSrv
{
time
:
any
;
...
...
@@ -35,6 +35,7 @@ export class TimeSrv {
this
.
time
=
{
from
:
'6h'
,
to
:
'now'
};
$rootScope
.
$on
(
'zoom-out'
,
this
.
zoomOut
.
bind
(
this
));
$rootScope
.
$on
(
'shift-time'
,
this
.
shiftTime
.
bind
(
this
));
$rootScope
.
$on
(
'$routeUpdate'
,
this
.
routeUpdated
.
bind
(
this
));
document
.
addEventListener
(
'visibilitychange'
,
()
=>
{
...
...
@@ -243,6 +244,16 @@ export class TimeSrv {
this
.
setTime
({
from
:
toUtc
(
from
),
to
:
toUtc
(
to
)
});
}
shiftTime
(
e
:
any
,
direction
:
number
)
{
const
range
=
this
.
timeRange
();
const
{
from
,
to
}
=
getShiftedTimeRange
(
direction
,
range
);
this
.
setTime
({
from
:
toUtc
(
from
),
to
:
toUtc
(
to
),
});
}
}
let
singleton
:
TimeSrv
;
...
...
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