VolkovLabs / business-forms

The Business Forms panel is a conceptually new plugin for Grafana. It is the first plugin that allows inserting and updating application data, as well as modifying configuration directly from your Grafana dashboard.
https://docs.volkovlabs.io
Apache License 2.0
86 stars 10 forks source link

Setting Dashboard Variables And Time Range Picker #537

Closed bliu13 closed 3 weeks ago

bliu13 commented 3 weeks ago

I am trying to see if the Business Forms plugin can be used to set or reset the Dashboard Variables and Time Range Picker values to specific values to the default. I am trying to use the Business Form's Reset Button functionality, but I don't see a way for me to set the variables and time range in the context. The documentation seems to indicate that I can set the dashboard variables, but I don't know if that is possible with the Reset Button.

I've attached an example dashboard configuration and a screenshot. example_reset_variables.json

example_variable_reset

mikhail-vl commented 3 weeks ago

@bliu13 You can use locationService to set dashboard variables or to and from time range values.

Check out the blog for details: https://volkovlabs.io/blog/form-panel-use-variables-20240301/

bliu13 commented 3 weeks ago

Hi @mikhail-vl! I was able to set the Time Range picker, but I was wondering if it's possible to set QueryA and QueryB using the Reset Button? Sorry for the trouble. I've tried to test a specific number of keys, but for some reason I couldn't set the dashboard's variables.

mikhail-vl commented 3 weeks ago

@bliu13 Did you check the blog post? var- in front of the variable is important to indicate that it's dashboard variable. Is it your issue?


if (context.element.id === "facility") {
  context.grafana.locationService.partial({
    "var-facility": context.element.value,
  });
}
``
bliu13 commented 3 weeks ago

@mikhail-vl That was it! Thank you! I really appreciate you taking the time to point that out to me!

mikhail-vl commented 3 weeks ago

@bliu13 Glad we resolved it!