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

Support multiline Timelion queries #11972

Conversation

cjcenizal
Copy link
Contributor

@cjcenizal cjcenizal commented May 23, 2017

Supersedes #11164 with a cleaner history.

Addresses #8881 and #11449.

image

image

image

image

image

@cjcenizal cjcenizal force-pushed the 8881/improvement/timelion-multiline-query-clean-history branch from 571ad8f to 9248f15 Compare May 23, 2017 15:59
@@ -21,7 +25,7 @@
}

start
= tree:series {
= space? tree:series {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This allows white space before the initial es call:

         .es(*)

@@ -87,7 +91,7 @@ function_name
= first:[a-zA-Z]+ rest:[.a-zA-Z0-9_-]* { return first.join('') + rest.join('') }

function "function"
= space? '.' name:function_name space? '(' space? arg_list:arg_list? space? ')' {
= space? '.' name:function_name space? '(' space? arg_list:arg_list? space? ')' space? {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This allows whitespace between chained functions:

.add(1)      .add(1)
           .add(1)

@cjcenizal
Copy link
Contributor Author

CC @snide

@cjcenizal cjcenizal added Team:Platform-Design Team Label for Kibana Design Team. Support the Analyze group of plugins. Feature:Timelion Timelion app and visualization Feature:Visualizations Generic visualization features (in case no more specific feature label is available) release_note:enhancement review v6.0.0 v6.0.0-alpha2 labels May 23, 2017
@cjcenizal
Copy link
Contributor Author

The first commit introduces UI Framework styles which support an expandable query bar. These styles aren't ultimately used by the changes to the Timelion UI in this PR. We can remove these UI Framework changes, but first I want to check with the Discovery team to make sure they won't actually be useful.

* 3. Cap the height so that we can offer auto-completion suggestions below the input.
* 4. When the input is collapsed, we want text input to be truncated with an ellipsis.
*/
.kuiLocalSearchInput--expandable {
Copy link
Member

Choose a reason for hiding this comment

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

i see quite some duplication between this and _local_search.scss ... whats the idea behind this ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the auto-generated CSS file, so we can ignore it during review.

}
}

export function suggest(expression, caretOffset, functionList, Parser) {
Copy link
Member

Choose a reason for hiding this comment

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

could you fix this function so it also shows the suggestion after you start writing your arguments in ?
.es ... shows me the doc for es function with all the arguments
after i type .es( the arguments disappear which is supper annoying.

i understand if you want to do it in separate pr but it might be a small change ....
maybe storing last valid caret position and in just showing the doc for that ?

Copy link
Member

@ppisljar ppisljar left a comment

Choose a reason for hiding this comment

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

this is working nice! some small bugs, nothing major.

@@ -53,6 +58,38 @@
}

/**
* 1. When it expands, the search input should lie on top of the content.
Copy link
Member

Choose a reason for hiding this comment

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

i guess this comments are no longer completely relevant ?

* 2. Expand as the user enters text.
* 3. Cap the height so that we can offer auto-completion suggestions below the input.
* 4. When the input is collapsed, we want text input to be truncated with an ellipsis.
* 5. Prevent textarea from being resized.
Copy link
Member

Choose a reason for hiding this comment

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

not sure if you wanted to prevent from resizing textarea by height ... i can still expand it

@@ -53,6 +58,38 @@
}

/**
* 1. When it expands, the search input should lie on top of the content.
* 2. Expand as the user enters text.
Copy link
Member

Choose a reason for hiding this comment

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

input does not auto grow for me

@@ -53,6 +58,38 @@
}

/**
* 1. When it expands, the search input should lie on top of the content.
* 2. Expand as the user enters text.
* 3. Cap the height so that we can offer auto-completion suggestions below the input.
Copy link
Member

Choose a reason for hiding this comment

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

i can expand the textarea as far as i want (multiple pages) .. the cap does not seem to be working

* 1. When it expands, the search input should lie on top of the content.
* 2. Expand as the user enters text.
* 3. Cap the height so that we can offer auto-completion suggestions below the input.
* 4. When the input is collapsed, we want text input to be truncated with an ellipsis.
Copy link
Member

Choose a reason for hiding this comment

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

no ellipsis, just the scrollbars

@@ -1915,6 +1932,43 @@ body {
/* 1 */ }

/**
* 1. When it expands, the search input should lie on top of the content.
Copy link
Member

Choose a reason for hiding this comment

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

this seems to be duplicated code ? or ?

@@ -125,6 +128,29 @@ export default props => (
</GuideSection>
Copy link
Member

Choose a reason for hiding this comment

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

irrelevant ... any idea why does github color this lines red ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My guess is that it doesn't recognize JSX or, if it does, it's trying to highlight invalid syntax because of the closing tag at the top?

@cjcenizal cjcenizal force-pushed the 8881/improvement/timelion-multiline-query-clean-history branch from 9248f15 to 57cd126 Compare May 23, 2017 17:38
@cjcenizal
Copy link
Contributor Author

@ppisljar I updated the PR so the suggestions don't disappear until the expression's been completed. Can you take another look?

@alexfrancoeur
Copy link

@cjcenizal I had a chance to take this PR for a spin. Some thoughts and comments below:

  • I had attempted to copy and paste a lengthy Timelion request from the new getting started guide:
    .es(index=metricbeat*, timefield=@timestamp, metric=max:system.network.in.bytes).derivative().divide(1048576).lines(fill=2, width=1).color(green).label("Inbound traffic").title("Network traffic (MB/s)"), .es(index=metricbeat*, timefield=@timestamp, metric=max:system.network.out.bytes).derivative().multiply(-1).divide(1048576).lines(fill=2, width=1).color(blue).label("Outbound traffic").legend(columns=2, position=nw)
    When copy and pasting, I would have expected the Timelion query bar to dynamically expand for the content that was in it.

screen shot 2017-05-24 at 8 17 57 am

  • This is somewhat related and the result is shown above. If I save the workspace, return to it and click into a visualization - I only see the last portion of the expression. What would be nice is if I could see the first portion of the expression with a ... or some other indicator that there is more.
    .es(index=metricbeat*, timefield=@timestamp, metric=max:system.network.in.bytes).derivative().divide(1048576).lines(fill=2, width=1)...
    If I then decide to click into this expression, the input box would automatically expand. What do you think?

  • Multi-line editing can get a bit complicated. It won't be possible to create a query similar to the one in Improved input editor for Timelion #8881 directly in this timelion editor. When I attempt to move to a new line, I actually submit the query to execute. I need to use shift+enter to move to a new line.
    may-24-2017 08-29-14
    We could switch the submit key combination to match dev console and be cmd+enter? That may be inconsistent with our other query bar though. The only other idea I had was to differentiate single line vs. multi-line editing. If in the multi-line edit "mode", do not treat enter as submit.

  • Is there any way we can get rid of that extra gray space between the query bar and the top menu?

  • Whitespace fix seems to be working!

screen shot 2017-05-24 at 8 40 11 am

I'll continue to play around with this but please let me know you'd like to discuss any of these in more detail. Regardless of my feedback, what we have here is already a significant improvement for lengthy queries 😄

@ppisljar
Copy link
Member

@cjcenizal what about my other comments ?

@cjcenizal
Copy link
Contributor Author

After talking with @ppisljar, I just want to clarify that the original code he commented on has been removed from this branch and now lives in #11975.

@ppisljar
Copy link
Member

the auto expand/collapse functionality would make this much more user friendly imo. As far as i notice this is pretty much the biggest difference from the previous implementation with div.

However looking in the future it would be nice if at some point this would be much more like the 'console' editor .... (seems the suggestions work well there as well) so i am having second thoughts on the textarea.

I agree with Alex that, in any case, we should make this feel more like the console (same key shortcuts)

Copy link
Contributor

@thomasneirynck thomasneirynck left a comment

Choose a reason for hiding this comment

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

Pretty nice, I like it! No major comments so far.

wrt. @ppisljar However looking in the future it would be nice if at some point this would be much more like the 'console' editor .... (seems the suggestions work well there as well) so i am having second thoughts on the textarea.

I assume this refers to things like syntax color-coding, inline-autosuggest. If so, IMO that doesn't need to be part of this PR as multi-line addition is already quite nice, and full-fledged editor support can come later.

I do agree with this earlier feedback from @alexf and @ppisljar.

  • autoexpanding the textarea-box as-you-type
  • using the cmd-enter combo to match the console

@cjcenizal
Copy link
Contributor Author

cjcenizal commented May 24, 2017

This is great feedback, peeps! I'll implement the following:

  • Change the input to be submitted on cmd+enter, to match Console. This seems like a good thing to teach the user, though we may need to surface some help content somewhere.
  • Auto-expand the input when you click into it.
  • When the input is collapsed and content is truncated, show some indicator in the UI.

@cjcenizal
Copy link
Contributor Author

cjcenizal commented May 24, 2017

OK, so I ran into a couple issues trying to get the "peeking" behavior @alexfrancoeur suggested (i.e. expanding the textarea when you focus it). You can see my attempt in 95f602d.

First of all, I think we want to disable this behavior once the user has resized the textarea, my assumption being that you resize the textarea so you can see its contents better and it'd be really annoying for it to expand and collapse as you focus and blur it. However, because there's no default "resize" event, I had to hack together a way of deriving whether the user has resized the textarea or not.

I got that figured out, but then there's a ridiculous Chrome bug which prevents the textarea from being resized below the "peek" height, but only if you resize it while its focused. This only happens in Chrome and at first I thought I was going crazy. Not only does Chrome provide the incorrect UX, it does so consistently, because it will work fine if you resize the textarea before you've clicked on it, but it will not work correctly if you resize it after you've clicked on it.

If our goal is simply to teach users that they can enter multiline expressions, I figure why not just use the UI to communicate that without getting too fancy?

image

Thoughts?

@alexfrancoeur Let's wait on adjusting the empty gray area in the local nav until we've merged @snide's color contrast changes in #11610. It will be easier to make adjustments after we get those changes in because the local nav's height will no longer correspond to the height of the logo in the side nav. If we adjust the height of that local nav now, it will look a little weird and inconsistent, due to the way those two heights are currently visually related. Changing local nav code will also affect all apps, so we should do that in a separate PR.

@cjcenizal cjcenizal force-pushed the 8881/improvement/timelion-multiline-query-clean-history branch from 86d7504 to bd23f2c Compare May 25, 2017 03:49
@ppisljar
Copy link
Member

@thomasneirynck i agree that doesn't need to be part of this PR, i was just saying that it would be nice that when we decide to do that we don't need to throw all this work away, so keeping that in mind here and not locking us down to much is important imo.

@cjcenizal i like what you did there!

@alexfrancoeur
Copy link

@cjcenizal regarding the console-like submit - this definitely makes it easier to add multiple lines, so ++ on this. Should we add "keyboard tips" in the docs here similar to console? I don't think we'd have as much but an indent option would be nice to have here as well

screen shot 2017-05-25 at 11 42 29 am

Making the input box multiple lines makes it more obvious that you can enter a longer query, but I still prefer something along the lines of #11975 for the user experience. What about something like this example? We could add a limit of 5 - 10 rows for auto-expand but a user can always drag further if they'd like. If a user clicks on a timelion panel that has a long query or if a user copy and pastes a long query, the input box will update to the appropriate or default maximum height. They would still have the ability to expand further by dragging and dropping.

Also I think it's fine to wait for #11610 before improving the top menu.

@cjcenizal cjcenizal force-pushed the 8881/improvement/timelion-multiline-query-clean-history branch from f879b32 to 35fefff Compare May 25, 2017 20:15
Copy link
Contributor

@thomasneirynck thomasneirynck left a comment

Choose a reason for hiding this comment

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

Nice! Some minor comments for your consideration.

I've googled some example of auto-resize and, similar to @alexfrancoeur's link, on Chrome, all of them stayed expanded, and none of them allowed users to shrink the box back. This is an interesting problem, but will this genuinely impact our users? The visualization does not disappear, it just gets pushed lower and lower on the screen. This appears to me a fair trade-off.

So I don't think the inability to shrink the textarea back to a size smaller than the content, would actually be problematic for our users.

I don't feel strongly about either though, so I'll go with the majority opinion on this one.

template: timelionExpressionInputTemplate,
link: function (scope, elem) {
const expressionInput = elem.find('[data-expression-input]');

Copy link
Contributor

Choose a reason for hiding this comment

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

consider extracting this enumeration to new module. we have the exact same enumeration in https://github.com/elastic/kibana/blob/master/src/ui/public/typeahead/typeahead.js#L10.

}

function setCaretOffset(caretOffset) {
// Wait for Angular to can update the input with the new expression and *then* we can set
Copy link
Contributor

Choose a reason for hiding this comment

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

language

@mixin formControl($borderRadius: $globalBorderRadius) {
@include formControlBase;
background-color: #ffffff;
border: 1px solid $globalFormControlBorderColor;
border-radius: $borderRadius;
transition: border-color $globalInputTransitionTiming;
min-height: 30px; /* 1 */
Copy link
Contributor

Choose a reason for hiding this comment

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

not an expert on sass and the kui, but since this height is interdependent, can this 30px be made a variable?

@ppisljar
Copy link
Member

UX wise: this is possible to use and gives you something you didn't have before (multiline editor) ... but, the editor doesn't give you really good experience ... so not sure if this counts as 'baseline satisfactory UX' ... it does solve the issue, so it could be. I personally would love to see it improved, but i am having doubts if its worth the effort.

UI wise: this might look a bit 'less cool' that the rest of kibana (specially the new parts the design team is improving on !!) however it falls quite well into the whole timelion look&feel

@alexfrancoeur
Copy link

@cjcenizal the keyboard section looks great! I'd almost say it's fair to use the when auto-complete is visible section as well. This seems to be applicable for timelion functions when auto-complete is triggered.

screen shot 2017-05-26 at 8 57 45 am

If the input box doesn't have the ability to shrink back then switching between panels can become a awkward. You could imagine switching between a 10 line expression and a single line expression. As I see it, this could behave in two ways. We either push the panels down based on the length of the query and transform the sheet each time you focus on a panel or we have a ton of empty space on the 1 line expression to keep the sheet consistent. Neither of which seem like a good solution to me.

I'm with Peter here. I think it stops the bleeding but isn't necessarily the best UX. This is my last pitch I swear 😄 What if we restricted this a bit more and made it an opt-in experience? Rather than allowing for a custom / dynamic input box, what if we defined a minimum and maximum height - giving the user the option to keep it collapsed or expand. To me, this gives me the feeling that I'm entering a workspace for creating timelion expressions.

The control is no good here but I thought this might help visualize my idea.
collapsed

expand

@cjcenizal
Copy link
Contributor Author

@thomasneirynck @ppisljar @snide I met up with @alexfrancoeur and we agreed that there's room for improvement in the UX, but because a) this PR provides functionality users have been asking for, b) the UX improvements depend upon a hack, and c) this PR targets and alpha release, we should merge this and get user feedback while I work on implementing the hack for improving the UX.

So my next steps will be: implementing Thomas's feedback and securing code review approvals from him and Peter, creating an issue to define the improved UX and identify the hack needed to implement it, and then merging this PR.

@cjcenizal
Copy link
Contributor Author

@thomasneirynck I've addressed your feedback, and @alexfrancoeur I added the Help tips you suggested:

image

Could you please re-review?

@alexfrancoeur
Copy link

@cjcenizal LGTM - let's make sure to reference the issue that will tackle the improved UX here as well. Maybe update the description once it's created?

Copy link
Member

@ppisljar ppisljar left a comment

Choose a reason for hiding this comment

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

LGTM

@cjcenizal cjcenizal merged commit 4c7022a into elastic:master May 30, 2017
@cjcenizal cjcenizal deleted the 8881/improvement/timelion-multiline-query-clean-history branch May 30, 2017 16:23
@ddavidebor
Copy link

Thanks so much for this PR!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:Timelion Timelion app and visualization Feature:Visualizations Generic visualization features (in case no more specific feature label is available) release_note:enhancement review Team:Platform-Design Team Label for Kibana Design Team. Support the Analyze group of plugins. v6.0.0-alpha2 v6.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants