Skip to content
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

Merged
merged 16 commits into from
Jan 22, 2018

Conversation

nreese
Copy link
Contributor

@nreese nreese commented Jan 5, 2018

fixes #1785

Store time history in local storage. Cached values selectable under Recent tab.

screen shot 2018-01-18 at 11 55 19 am

Copy link
Member

@lukasolson lukasolson left a 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:

  1. Now there are two different places where default time intervals are stored (local storage and the advanced setting). Which should take precedence?
  2. 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".
  3. 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);
Copy link
Member

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.

@Bargs
Copy link
Contributor

Bargs commented Jan 9, 2018

I'll add a couple thoughts here too so I don't forget during the zoom:

  • I think history would probably be useful in the relative mode as well, so I'm wondering if it should just be a log of all recent time ranges, regardless of what mode it came from.
  • We've talked with Dave in the past about moving the timepicker into the query bar, so everything affecting the query is in one place. Once we do that, I'm not sure it would make sense for the timepicker to have it's own independent history. Its history would probably just get tracked in the query bar's history. So that's something to consider before implementing a separate history mechanism here.

@nreese
Copy link
Contributor Author

nreese commented Jan 12, 2018

@lukasolson @Bargs @snide @cjcenizal As discussed, I have updated the PR to insert the time history into the quick timepicker select. What do you think? Is this a better UI?

@cjcenizal
Copy link
Contributor

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.

@nreese
Copy link
Contributor Author

nreese commented Jan 13, 2018

@cjcenizal I have moved the time history to its own tab in the time picker. Does this help solve some of the spacing issues?

Copy link
Contributor

@cjcenizal cjcenizal left a 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:

image

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) {
Copy link
Contributor

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 {
Copy link
Contributor

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 () {
Copy link
Contributor

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.

@nreese
Copy link
Contributor Author

nreese commented Jan 16, 2018

@cjcenizal Added a message for when time history is empty

screen shot 2018-01-16 at 9 38 36 am

@nreese
Copy link
Contributor Author

nreese commented Jan 16, 2018

@lukasolson @Bargs Other then some tests, this PR is ready for review

@gchaps
Copy link
Contributor

gchaps commented Jan 16, 2018

@nreese @cjcenizal

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


When you have a time range, you’ll see it here


No time history

Your most recently used time ranges show up here so you can view them later

@nreese
Copy link
Contributor Author

nreese commented Jan 16, 2018

@gchaps Thanks for suggestions. I used the last option provided.

screen shot 2018-01-16 at 12 02 52 pm

@cjcenizal
Copy link
Contributor

@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."

@gchaps
Copy link
Contributor

gchaps commented Jan 16, 2018

@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.

@nreese
Copy link
Contributor Author

nreese commented Jan 16, 2018

@gchaps @cjcenizal Thanks

screen shot 2018-01-16 at 3 55 04 pm

Copy link
Member

@lukasolson lukasolson left a 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.

image

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];
Copy link
Member

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.

Copy link
Contributor

@cjcenizal cjcenizal Jan 17, 2018

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.

@cjcenizal
Copy link
Contributor

@lukasolson Sounds good to me. How about "Recent", which will reinforce the reference to "recent ranges"? "History" sounds a bit ambiguous.

@gchaps
Copy link
Contributor

gchaps commented Jan 17, 2018

@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.

@nreese
Copy link
Contributor Author

nreese commented Jan 17, 2018

@lukasolson Great suggestion to mirror the timepicker time range display. Now the recent panel and the timepicker share the same logic for generating the display strings. This makes the recent panel look much nicer.

screen shot 2018-01-17 at 12 45 22 pm

@Bargs
Copy link
Contributor

Bargs commented Jan 17, 2018

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.

@Bargs
Copy link
Contributor

Bargs commented Jan 17, 2018

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.

@cjcenizal
Copy link
Contributor

cjcenizal commented Jan 17, 2018

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.

@cjcenizal
Copy link
Contributor

@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.

@Bargs
Copy link
Contributor

Bargs commented Jan 18, 2018

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.

@cjcenizal
Copy link
Contributor

@Bargs Sounds good. I don't feel strongly about this. I'll let you and Nathan work it out.

@nreese
Copy link
Contributor Author

nreese commented Jan 18, 2018

@Bargs I have updated the recent panel to be displayed in a single column. This should avoid all wrapping concerns.

screen shot 2018-01-18 at 11 55 19 am

Copy link
Contributor

@Bargs Bargs left a 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) {
Copy link
Contributor

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.

Copy link
Contributor Author

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

Copy link
Member

@lukasolson lukasolson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks!

@nreese
Copy link
Contributor Author

nreese commented Jan 22, 2018

jenkins, test this

@nreese nreese merged commit dc55138 into elastic:master Jan 22, 2018
nreese added a commit to nreese/kibana that referenced this pull request Jan 22, 2018
* 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
nreese added a commit that referenced this pull request Jan 22, 2018
* 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
@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Timepicker - add 'recently selected' range option
6 participants