-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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 more predefined options to Date and Date Range parameters #3009
Comments
Surprised their is not more demand for this. To me its a fundamental requirement of any Dashboarding solution. |
The first part (more predefined options) is easy. The tricky part is how to persist those selections as defaults. One idea I had is to save them as values for start/end, i.e. when you pick "Last 7 Days" the value we pass for param.start/param.end will be something like A more generic solution will be to pass datetime deltas as values, i.e. when you pick "Last 7 Days" what we pass for start will be "-7 days" and for end "-0 days". |
UX/UI
This is sort of the draft of what I thought for UX/UI, @ranbena can give magic ideas here :) Implementantion I think it's sort of a workaround doing in the frontend as deep down it loads a static value. Also there's the case for Scheduled Queries. From the backend I guess my concern is that I haven't seen any of these "translations" in there 😬 |
How about we put the default value setting in the Parameter settings dialog? Also, we can do the translation from the default value to actual date value when loading the parameter and from this point forward (in the current execution) it will behave as a regular date time picker. No need for special handling when communicating with the backend. Only special handling on the backend is needed when handling scheduled queries, but we need to see if de-duplicating this logic is worth the extra complexity in implementation. |
I must say I like it! |
The default value ("dynamic value") is part of the parameter configuration. Shouldn't it be along with the other parameter configuration values? |
I'm misunderstanding sth - why would this be called a "default value"? It's a value like any other, but dynamically set, no? |
The problem I see with the parameter configuration is that you limit the scope to when you are editing a query, you wouldn't be able to set it in the Dashboard page for example. An specific button for it felt like an extension to Date Parameters. @ranbena, I considered the 🔽 it seems to go better with a Dropdown. I did some quick experiments with it and it presented some issues (dropdown inside a date picker 😅), I'll turn those changes into a draft PR so this can be better experienced. |
@gabrieldutra forget it - leave it as a bolt. It works! ⚡ |
I actually just realized that there's a limitation for this: change and persist the parameter options requires 'edit_query' permissions and that you save the query afterwards. So my idea comes with a few limitations too:
Considering this, please lmk if you see other possible conflicting scenarios I haven't. Alternative options that I considered:
|
I had the opportunity to discuss this with @ranbena and we came up with the following:
As for what I mentioned about setting the default value from the parameter settings dialog, I think we should implement this for all parameters but considering 7 above, we can wait with it -- I will open a separate issue for it, once we feel the above is the right approach. @gabrieldutra , this is a lot to unpack -- if it's unclear, let me know and maybe we can schedule a call to discuss this.
@gabrieldutra why do you need to persist it when just setting the current value? |
As a side note, here's a nice UX for picking date ranges: (from Baremetrics) What I liked here is the fact that next to the range name it shows the actual dates. |
Not final design, just meant to clarify the vision: Empty stateStatic value selectedClicked dynamic value buttonHelpTrigger: "Guide: Setting Dynamic Dates and Ranges".Regarding "Custom" option - not a must for this feature. Dynamic value selectedOpen dynamic value options by clicking the bolt. |
@arikfr the only "problem" I see here is that a dynamic value would revoke its original input type. So time won't be at all relevant here (unless we have a "This Minute" option). |
@ranbena I'm not sure I understand? When it's a date you will onyl have "Today", when it's a data range you will get the other options. |
Thanks @arikfr and @ranbena, regarding UI/UX this follows what I had in mind and adds some nice touches to it.
That seemed necessary when considering dashboard global parameters, because their values come from the url, all the parameter information (such as the "dynamic" property) come from the query. Also, I was first with the idea that once those "dynamic" values were set, they would stay dynamic on reload. On a second thought after reading what you said and realizing the current Redash behavior for parameters, there are other ways to solve the above. I was hoping to have something more consistent before opening the WIP PR, though it will be better to share the possible limitations (Netlify ftw), so I decided to open it from the draft I had in here to shape this feature while checking what can be the issues in the implementation. |
Oh ok, I thought we would always show all dynamic options but your approach makes sense. |
@ranbena Antd's DatePicker doesn't seem to support custom Nodes on the inputs (actually it just supports moment values in this case 😬). Do you have any simpler idea on how to implement this one? (It seems possible to do it by recreating the DatePicker using Calendar, but perhaps you have a simpler idea 😆) |
How about hijacking the placeholder? 😈 |
Interesting haha, the placeholder passed through my mind too, won't be showing the specific dates, but is the best so far indeed. Thanks! 😁 |
The Date Picker we use has support for Presetted Ranges, so we can add some useful short hands like: last month, last week, last 7 days, last 30 days, etc.
The text was updated successfully, but these errors were encountered: