-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
Timepicker - add 'recently selected' range option #15868
Conversation
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.
Let me first just say thanks for taking this on! This is awesome.
I think it would be worthwhile to hop on a video chat with @snide and @Bargs and chat about these changes. I'm concerned with a couple things:
- Now there are two different places where default time intervals are stored (local storage and the advanced setting). Which should take precedence?
- I think the UI for selecting a previous time interval is a tad confusing, because a user might expect that hitting "Go" is no longer how to apply the interval you've selected (since now there's a drop-down next to the button that says "Select a previously selected interval".
- I'm not sure we need to use three different local storage keys to accomplish this... what if we just had a log, and if we wanted to default to the most recent, just grab the most recent from the log?
I'd love to have a quick 30-60 min meeting and discuss these things so we can all be on the same page.
|
||
class TimeHistory { | ||
constructor() { | ||
this.storage = new Storage(window.localStorage); |
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.
Instead of using the Storage
class, it might make more sense to use the PersistedLog
class, which already takes care of duplicates.
I'll add a couple thoughts here too so I don't forget during the zoom:
|
8e91a21
to
d45ebad
Compare
@lukasolson @Bargs @snide @cjcenizal As discussed, I have updated the PR to insert the time history into the |
My initial reaction is that this becomes cramped and difficult to read. The ranges themselves are so long that they wrap, so its hard to tell one range from another. Also, it's hard to tell at a glance where the static "quick" options end and the dynamic "cached" ranges begin. I think we should add a fourth tab called "Recent ranges" and move this content there. |
5891fea
to
3fbdb67
Compare
@cjcenizal I have moved the time history to its own tab in the time picker. Does this help solve some of the spacing issues? |
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.
Nice work! I had a few suggestions for you, all optional. I also noticed that when there are no recent ranges, it looks a bit broken:
How about adding an empty state? Just some text saying, "When you specify new time changes they'll be saved here." CC @gchaps for better suggestions on this copy.
const localStorage = new Storage(window.localStorage); | ||
|
||
export class PersistedLog { | ||
constructor(name, options, storage) { |
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.
We can specify defaults like this to be more efficient:
constructor(name, options = {}, storage = localStorage) {
A bit outside the scope of the PR but not that big a change.
import { PersistedLog } from 'ui/persisted_log'; | ||
import { TIME_MODES } from 'ui/timepicker/modes'; | ||
|
||
class TimeHistory { |
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.
Want to add tests for this? They could be written with Jest.
PersistedLog = $injector.get('PersistedLog'); | ||
}); | ||
} | ||
|
||
describe('PersistedLog', function () { |
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.
Perhaps outside the scope of this PR, but this test can be converted to Jest by renaming it persisted_log.test.js
and moving it out of this directory into the same directory as persisted_log.js
. And then all the it
calls can be renamed to be test
, which is purely cosmetic.
7b847f8
to
35ceb58
Compare
@cjcenizal Added a message for when time history is empty |
@lukasolson @Bargs Other then some tests, this PR is ready for review |
How about making the text a little more concise? I'm wondering if the wording about absolute/relative and 10 views might be too much detail for an empty state. They are typically short. When you specify a relative or absolute time range, it shows up here. or Time ranges show up here, so you can easily view them later Other options to consider To add a time range, click the New button above — — Your most recently used time ranges show up here so you can view them later |
@gchaps Thanks for suggestions. I used the last option provided. |
@gchaps I love the wording. The hierarchy of the text looks a little odd to me since there's no title treatment on the first sentence. But do we need a title? Can this just be two sentence on one line? "No time history. Your most recently used time ranges show up here so you can view them later." |
@cjcenizal Yes, one line works. @nreese Can I tweak it a bit? I missed a comma. I also tweaked it a bit to make the two lines read better together. No time history. Your most recent time ranges show up here, so you can easily view them later. |
@gchaps @cjcenizal Thanks |
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.
Could we update the text to always mirror what shows in the timepicker? For example, I've selected a relative range of now-20m to now. The timepicker says "Last 20m". Can we show that text instead of "now-20m to now"? I think it makes more sense, and that seems to be the behavior for the absolute ranges.
Also, I'd rather it just say "Recent" or "History" and it would make more sense to me to add it to the far right or far left, but I could live with it as-is. Thoughts, @cjcenizal?
@@ -35,10 +37,10 @@ module.directive('kbnTimepicker', function (timeUnits, refreshIntervals) { | |||
template: html, | |||
controller: function ($scope) { | |||
$scope.format = 'MMMM Do YYYY, HH:mm:ss.SSS'; | |||
$scope.modes = ['quick', 'relative', 'absolute']; | |||
$scope.modes = [TIME_MODES.QUICK, TIME_MODES.RECENT, TIME_MODES.RELATIVE, TIME_MODES.ABSOLUTE]; |
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.
I'd prefer the following:
$scope.modes = Object.values(TIME_MODES);
Then, if someone adds a new mode for some reason, this line doesn't have to change, and it's more concise.
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.
Good idea, we're using a similar pattern in EUI.
@lukasolson Sounds good to me. How about "Recent", which will reinforce the reference to "recent ranges"? "History" sounds a bit ambiguous. |
@lukasolson I agree with @cjcenizal to use "Recent" . "History" sounds like it will show everything where I think this will only show the top 10. |
99c5f54
to
e7af3b7
Compare
@lukasolson Great suggestion to mirror the timepicker time range display. Now the |
Any idea how we could visually distinguish each entry? With long absolute ranges wrapping I find it a little difficult to see where one entry ends and the next begins. |
Maybe an easy solution would be to display the recently used dates in a single column instead of a two column layout, that way the absolute dates wouldn't have to wrap? Just a thought I had immediately after posting the previous comment, maybe there are better solutions. |
I think we need to adjust the line-height so that the vertical space between multiple lines in a single entry is smaller than the space between entries. Let me try something out locally. |
@Bargs Are you referring to the column width and the odd line-wrapping? I think the only that stands out to me as solvable in that screenshot is the column width. The column widths should definitely be the same. In terms of odd line-wrapping (e.g. orphans being left on the last line), I think that's unavoidable. |
I'm mainly talking about the odd line wrapping. It's only unavoidable if we stick to a two column layout. What is the advantage of having two columns? It's not really saving much vertical space since most lines will wrap with two columns. And if we cap the history at some limit (say, the last 10 entries), it's never going to take too much vertical space. |
@Bargs Sounds good. I don't feel strongly about this. I'll let you and Nathan work it out. |
54818ab
to
ee409e2
Compare
@Bargs I have updated the |
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.
I left one suggestion for the feature itself, but all the code LGTM!
} | ||
|
||
add(time) { | ||
if (!time || time.mode === TIME_MODES.QUICK) { |
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.
I'd argue it makes sense to include quick times in the history for the sake of consistency. When I first pulled down the PR and started playing with it I started switching between Quick options and I thought something was broken because they weren't showing up in the Recent list. I think a user might want to be able to flip back and forth between a couple quick options without having to find it in the giant Quick list each time. Might just be me though, if others disagree I won't be insistent.
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.
That makes sense. I will remove this check
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.
LGTM! Thanks!
jenkins, test this |
…can be shared by recent history view
69dec42
to
908efb6
Compare
* store time filter history in localStorage * allow selection of relative history * use persisted log for storage * display time history in quick list * add recent timepicker panel * set timehistory mode to recent * add message to display when no time history exists yet * migrate persisted_logs tests from mocha to jest * reword text for no history * better wording * move logic from pretty-duration directive into its own file so logic can be shared by recent history view * some small changes * fix list styling * make recent be a single column * store quick times in history * set default timezone for moment in pretty_duration tests
* store time filter history in localStorage * allow selection of relative history * use persisted log for storage * display time history in quick list * add recent timepicker panel * set timehistory mode to recent * add message to display when no time history exists yet * migrate persisted_logs tests from mocha to jest * reword text for no history * better wording * move logic from pretty-duration directive into its own file so logic can be shared by recent history view * some small changes * fix list styling * make recent be a single column * store quick times in history * set default timezone for moment in pretty_duration tests
💚 Build Succeeded |
fixes #1785
Store time history in local storage. Cached values selectable under
Recent
tab.