-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add time navigation buttons #9253
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
7e1932f
Add time navigation buttons
jgowdyelastic ad58aaa
changing vars to const
jgowdyelastic 4e976af
Address some review points
jgowdyelastic efad64d
fixing typo in function name
jgowdyelastic 412f7a9
Merge branch 'master' into add-time-nav-buttons
lukasolson 2299d7b
Remove unused variables
lukasolson aacde2b
[timepicker] Simplify zoom in/out and forward/back and remove getter …
lukasolson 50b4f75
[timepicker] Move time navigation calculations to own class and write…
lukasolson 55d1ae9
[timepicker] Remove unused styling and classes
lukasolson 3feda24
[timepicker] Change from i to span, add more explanatory comments
lukasolson 315739e
[timepicker] Remove unused variable
lukasolson 89cb1b6
Merge branch 'master' into add-time-nav-buttons
lukasolson 371dede
Merge branch 'master' into add-time-nav-buttons
lukasolson a5497d1
Remove zoom in/out buttons from timepicker nav
lukasolson e5db5be
Merge branch 'master' into add-time-nav-buttons
lukasolson 91646df
Change step forward/back timepicker nav button icons
lukasolson File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import expect from 'expect.js'; | ||
import moment from 'moment'; | ||
import timeNavigation from '../time_navigation'; | ||
|
||
describe('timeNavigation', () => { | ||
let bounds; | ||
|
||
beforeEach(() => { | ||
bounds = { | ||
min: moment('2016-01-01T00:00:00.000Z'), | ||
max: moment('2016-01-01T00:15:00.000Z') | ||
}; | ||
}); | ||
|
||
it('should step forward by the amount of the duration', () => { | ||
const {from, to} = timeNavigation.stepForward(bounds); | ||
expect(from).to.be('2016-01-01T00:15:00.000Z'); | ||
expect(to).to.be('2016-01-01T00:30:00.000Z'); | ||
}); | ||
|
||
it('should step backward by the amount of the duration', () => { | ||
const {from, to} = timeNavigation.stepBackward(bounds); | ||
expect(from).to.be('2015-12-31T23:45:00.000Z'); | ||
expect(to).to.be('2016-01-01T00:00:00.000Z'); | ||
}); | ||
|
||
it('should zoom out to be double the original duration', () => { | ||
const {from, to} = timeNavigation.zoomOut(bounds); | ||
expect(from).to.be('2015-12-31T23:52:30.000Z'); | ||
expect(to).to.be('2016-01-01T00:22:30.000Z'); | ||
}); | ||
|
||
it('should zoom in to be half the original duration', () => { | ||
const {from, to} = timeNavigation.zoomIn(bounds); | ||
expect(from).to.be('2016-01-01T00:03:45.000Z'); | ||
expect(to).to.be('2016-01-01T00:11:15.000Z'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import moment from 'moment'; | ||
|
||
export default { | ||
// travel forward in time based on the interval between from and to | ||
stepForward({min, max}) { | ||
const diff = max.diff(min); | ||
return { | ||
from: max.toISOString(), | ||
to: moment(max).add(diff).toISOString() | ||
}; | ||
}, | ||
|
||
// travel backwards in time based on the interval between from and to | ||
stepBackward({min, max}) { | ||
const diff = max.diff(min); | ||
return { | ||
from: moment(min).subtract(diff).toISOString(), | ||
to: min.toISOString() | ||
}; | ||
}, | ||
|
||
// zoom out, doubling the difference between start and end, keeping the same time range center | ||
zoomOut({min, max}) { | ||
const diff = max.diff(min); | ||
return { | ||
from: moment(min).subtract(diff / 2).toISOString(), | ||
to: moment(max).add(diff / 2).toISOString() | ||
}; | ||
}, | ||
|
||
// zoom in, halving the difference between start and end, keeping the same time range center | ||
zoomIn({min, max}) { | ||
const diff = max.diff(min); | ||
return { | ||
from: moment(min).add(diff / 4).toISOString(), | ||
to: moment(max).subtract(diff / 4).toISOString() | ||
}; | ||
} | ||
}; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I read this it took me a few seconds to figure out the meaning of this test, i.e. how much time is being stepped. Can we change the description to read:
should step forward by the amount of the duration
?