- What Grafana version and what operating system are you using?
The latest grafana-oss Docker image v11.0.1 on Linux.
- What are you trying to achieve?
When the current URL has auth_token
in the query string (which happens when I’m embedding the dashboard in an iframe) I want to hide the topbar and the sidebar.
No, kiosk mode is not appropriate, because it hides the template variables (which I don’t want to hide) and because it can be closed by pressing Esc.
- How are you trying to achieve it?
Right now I enabled disable_sanitize_html
and added the following script to every dashboard, in a Text panel:
<script>
if (location.search.includes('auth_token')) {
document.querySelector('header').style.display = 'none';
document.querySelector('header').nextElementSibling.style.paddingTop = 0;
document.querySelector('main').previousElementSibling.style.display = 'none';
}
</script>
This works, but is kind of ugly, takes up space for the Text panel, and needs to be copied to every dashboard. I would rather implement the same functionality in the main application code, or at least add this script in a more generic way.
Question: how can I add this functionality or this piece of script to Grafana? Is there a plugin that allows me to write custom JS, or can I add it somewhere in the database or in the configuration files? Otherwise, should I write a plugin to do that?