I want to get some dashboard service (timeSrv for example), but there is no such servise in the @grafana/runtime/services. What is the legal way to get them to my plugin code?
And one more spesific question:
I want to set up dashboard time range from within my panel plugin so I’m going to use timeSrv.setTime(). Is this a legal way to change dashboard taime range with new plugin API?
Found a working solution for my case, needed to set “disable_sanitize_html = true” in grfana.ini
I found a script and did some small modifications. This needs to be placed in a “Text” Visualization and the mode set to “html” to let it work.
<div id="time_range_info">
Time window:
</div>
<script>
function getDashboardTimeRange(){
var f = (new Date($__from) + '').split(' ');
fWeekDay = f[0];
fMonth = f[1];
fDay = [f[2], ','].join('');t
fYear = f[3];
var from = [fWeekDay, fMonth, fDay, fYear].join(' ');
var t = (new Date($__to) + '').split(' ');
tWeekDay = t[0];
tMonth = t[1];
tDay = [t[2], ','].join('');
tYear = t[3];
var to = [tWeekDay, tMonth, tDay, tYear].join(' ');
return ['from', from, ' to ', to].join(' ');
// if you only need month and year for instance
// return [tMonth, tYear].join(' ');
}
$('#time_range_info').append(getDashboardTimeRange());
</script>
indent preformatted text by 4 spaces