Hello,
I’m trying to control the time scale of my Grafana plots into HabPanel using different buttons for 1h,1d,1w and so on, but I don’t know how to pass a variable to the iframe. For now my code looks like that:
A solution could be to have an item to hold your URL, with rules responding to commands and use HABPanel’s built-in “frame” widget which automatically sets URLs as trusted (which I now realize might not even be the best thing security-wise since items can easily be updated with the API).
Something like this:
<!-- You need to have server-side rules to update the Grafana_URL item
when the Grafana_Period item receives commands/updates -->
<div ng-init="model={ 'url_source': 'item', 'item': 'Grafana_URL' }"></div>
<table>
<tr>
<th> <button type="button" ng-click="sendCmd('Grafana_Period', '1h')">1h</button></th>
<th> <button type="button" ng-click="sendCmd('Grafana_Period', '1d')">1d</button></th>
<th> <button type="button" ng-click="sendCmd('Grafana_Period', '1w')">1w</button></th>
<th> <button type="button" ng-click="sendCmd('Grafana_Period', '1m')">1m</button></th>
<th> <button type="button" ng-click="sendCmd('Grafana_Period', '6m')">6m</button></th>
</tr>
</table>
<widget-frame ng-model="model"></widget-frame>
@ysc Hmm, can you think of any better way to allow time-period selection on grafana graphs. It’s quite an overhead to create an item, a rule and an iframe for each graph!
Had a similar issue, the filter method a similar to the one as shown here works
at present as a general filter for all sce related issues.
Generating a grafana diagram by code, means i generate a link to grafana by
the subject of the diagram and time values additional to the static link, let fail the proposal as shown here.
e.g. http://xxx.xxx.xxx.xx:yyyy/dashboard-solo/db/luft?orgId=1&panelId=1&kiosk&from=now-6h&to=now
The diagram gets opened as a modal window, see here the descriptions how to open a modal window.
Important is to address the oc-lazy-load in the outer div. It looks oc-lazy-load has an integrative div and as consequence the diagram didn’t achieve a height of 100 %.
Spoken easy…needed three weeks to get a understanding of the root cause as doing the same in a frame-widget worked pretty perfect from the beginning.
Ok, but now i have the luxury of a scaleable time range by a mouse click and a modal window to “zoom” diagrams if i like.