Call kbnUrl.change() and pass a query value as $routeParams


#1

Hi all, can I use .change() method of kbnUrl service to navigate to a saved dashboard and pass a parameter to query on state enter?
I can navigate to the dashboard passing the url but can't figure out how paramObj works.
Thank you.


(Jim Unger) #2

The paramObj is a key/value mapping used for string replacements in the url parameter. If you're trying to load a dashboard and set the query to a value, try this:

 const url = '/dashboard/{{myId}}?_a=(query:(query_string:(query:{{myQuery}})))';
 const paramObj = {
   myId: '120d5d30-efdf-11e6-a9e8-417ea42ccca8',
   myQuery: 'geo-dest=TEST'
 };
 kbnUrl.change(url, paramObj);

kibana urls store state as rison-encoded values in the url, including the search query.


#3

Thank you BigFunger.
Now it works, but I'm searching something that it's not stricktly bound to the Url.
If I save a dashboard with some visualizations, than set the url variable to match with the one of my dashboard, and then I change my dashboard adding more vis I've to change the url to match again the new dash.
Is it right?
Thanks


(Jim Unger) #4

I don't know what you mean by this.

AFAIK, the code I shared above should load the latest version that has been saved.


#5

Sorry my fault, You are right!
It works like a charm. :slight_smile:
Thank you so much!


(Jim Unger) #6

You're welcome! Glad I could help


(system) #7

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.