FastGridTemplate save_layout under a custom key
Problem I am facing
I am currently making a fairly advanced dashboard using panel, and its FastGridTemplate. In this dashboard (url=/dashboard), users can add additional panels, and save the 'page' for viewing later. A query parameter is used to determine which page to load (url=/dashboard?page_name='saved_page1'). Basically, a query parameter is used to determine how many panels will be on the grid in FastGridTemplate.
In FastGridTemplate, the page URL is used to determine what key the layout is saved under. In this example, the layout would be saved under the "/dashboard" key. This 1:1 mapping of URL -> layout is simply not valid in my particular case, since a query parameter is used to change how many panels are on the grid.
Potential Solution
I would imagine the easiest way to fix this issue is have it so the save_layout parameter accept either a boolean, or a string. If save_layout is a boolean, it behaves like normal. If save_layout is a string, that string overrides the key the layout is saved under.
An alternative API would be to add a 'save_key' parameter to the FastGridTemplate. The parameters data type would be a string, or None (default=None). If save_key is None, it would behave as it currently does. If save_key is set to a string, that string would override the key the layout is saved under. The parameter is only valid when save_layout=True. I personally like the first option, since it would limit the number of parameters a new user would have to learn.
Both suggested API's fully maintain backwards compatibility.
To Implement this, the FastGridTemplate jinja template would need to be modified to follow this behavior. The FastGridTemplate class would also need to be modified, to accept the string.
Conclusion
Overall, I would imagine this would be a relatively small change, and would be a huge feature for those wanting to build more customizable dashboards, such as myself.
Thanks for all your hard work building this project.
This seems like a perfectly reasonable feature request. This should be implemented on the ReactTemplate and then applied to both the React and FastGrid HTML templates. It would be kind of nice to be able to include different parts of the window.location in the key, e.g. by default it's ['origin', 'pathname'] but you can easily include ['origin', 'pathname', 'search'] to include the query parameters. It's probably a bit more work but if you could specify that as a string with some templating syntax like so that would be best: @{origin}-@{pathname}-@{search} and also let you specify an explicit key if you want. On balance I also favor adding a layout_key parameter instead of overloading save_layout.