Add template variables to dashboards
When users build a dashboard they should be able to select specific tag keys as template variables. Ideally they could also select source, database, and retention policy as template variables. Although addressing #689 might take care of the source/database problem.
For example, if we build a dashboard to monitor a specific customer's cloud infrastructure. We'd like to set the customer tag key as something that can be selected in the title bar of the dashboard, like the date range. It should be a drop-down/text autocomplete field.
@alexpaxton can you start to think about design around this
@goller can you take a look at the query structure stuff to see if this will easily fit
I think this would be really straightforward from query structure.
- InfluxQL would be converted to queryConfig.
- The source, db, rp, tags could be changed in the queryConfig.
- queryConfig would get converted back to InfluxQL This would need a small amount of endpoint work (like a hour or two)
As for the general case of any InfluxQL... I could support db/rp template easily. As for templating tags in a where clause... we could use bind parameters (https://docs.influxdata.com/influxdb/v1.2/tools/api/#request-body)
... yeah, we could do this for sure.
Flow for creating & using Template Variables:
1. Editable dashboards will have a Variables button in the page header

- Aiming to keep the button to a single, short as possible word to keep heading clutter free
2. Template Variables panel slides in

- User can specify a type, shortcode, and label
- Types initially will be
Tag KeyMeasurementor whatever else we think is appropriate - Shortcode can only use
A-Z a-z 0-9no spaces Global Timecould exist in here as a non-editable template variable, to show users a working example
3. Completed Template Variables appear in Cell Edit
- User can click to insert (a la templates in Rule Messages)
- Error / Warning messages should be added to help guide users
4. Once a Template variable is used in a query in at least 1 cell
- Cell name gets an icon next to it to indicate that it makes use of a template variable (doesn't have to be a diamond)
- Maybe the dropdowns in the heading have the same icon?

- Dropdown only appears in the Page Heading so long as that variable is being used in at least 1 cell (prevents clutter)
- Might get gnarly if the user creates a lot of variables
Hawt. I don't think people will generally have that many variables so it might not get gnarly. One thing we also need to think about is how to show what template variables are selected if they're in presentation mode.
@pauldix oh snap, did not consider presentation mode.
Here's a quick stab at that:
This design would increase the non-cell height by 42px
Thinking that if we are to make visible the template dropdowns, might as well show the time range & auto refresh dropdowns as well. I suppose this would just be a "presentation mode header" which is likely a different chunk of work.
On second thought, a vertical side panel might not make sense if there's not going to be a ton of things in the list. Here's some different approaches that are more horizontal:

Really starting to get the feeling that the overlay is "too interrrupt" with the gradient. I'll play around more with that once it's in the app
Been avoiding placing the template variables dialog in the center because it feels too "modal-y" but realistically it's inescapable
Noting some feedback
- Need additional field in template variables panel for a query
- Need template variable dropdowns in cell edit mode, users need this play around with the feature
- Might consider moving template variables to their own "bar" (not heading, because clutter) and because the heading disappears during presentation mode
@alexpaxton in presentation mode I don't think the template variables need to be a dropdown. There just needs to be some kind of breadcrumbing or something that lets the user know what they're looking at. If they want to change the view I think it's fine to force them to drop out of presentation mode.
@pauldix sweet that should be much cleaner