Feature Request: Refer to the current fava filters (time, account, filter) in link field
ileodo opened this issue · 5 comments
as per above, is that possible to refer to the fava's current filters, including time, account and filter?
Thanks
hi @ileodo, yes that's possible, take a look at the example dashboard:
fava-dashboards/example/dashboards.yaml
Line 592 in 4d6340b
You can access the account and filter in the same way.
thanks @andreasgerstmayr, it would be great to just support a special variable name in the link filed which will be replaced with the time instead of manually do it in js.
I'd like to keep the extension as simple as possible, and don't plan to support this for now.
@ileodo: Related to this, just wanted to share this snippet of code that makes the above request pretty easy to implement within the new utils
configuration:
# dashboards.yml
utils:
inline: |
const linkReplacer = () => {
const windowUrl = new URL(window.location.href);
window.document.querySelectorAll('h2 a').forEach(function (el) {
const linkUrl = new URL(el.href);
linkUrl.searchParams.set('time', windowUrl.searchParams.get('time'));
linkUrl.searchParams.set('conversion', windowUrl.searchParams.get('conversion'));
el.href = linkUrl;
});
}
linkReplacer();
This JS snippet runs after each page load, loops through all the dashboard's panel headlines, and updates their href
with the current page's time
and conversion
parameters. It's easy to extend with other dynamic parts as well.
@mattmattmatt thanks for the snippet!
I've added a generic way to copy Fava's filter parameters to all links in #41.