-
Great plugin, but I have one problem. I'm embedding an image from an external server which changes every 15 minutes. My problem is that the image is loaded from the browser cache until I Ctrl+F5 load the entire panel page. I already tried the usual trick to append a timestamp to the image's URL, but this doesn't work:
Then in either onRender or inInit:
both show a TypeError: image is null Add the 3 lines JS in a <script> block in the HTML markup doesn't do anything. Any ideas how to solve this? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
You are using ExampleCode used to serve the image: https://github.com/ZuperZee/serve-refresh-images
<img id="myimage" src="plain/url/image.png">
const image = htmlNode.querySelector("img");
const currentTime = new Date().getTime();
image.src = "http://localhost:3000?timestamp=" + currentTime;
{
"calcsMutation": "standard",
"reduceOptions": {
"calcs": [
"lastNotNull",
"last",
"firstNotNull",
"first",
"min",
"max",
"mean",
"sum",
"count",
"range",
"delta",
"step",
"diff",
"logmin",
"allIsZero",
"allIsNull",
"diffperc"
]
},
"add100Percentage": true,
"centerAlignContent": true,
"overflow": "visible",
"useGrafanaScrollbar": true,
"SVGBaseFix": true,
"codeData": "{\n \"text\": \"Random text\"\n}",
"rootCSS": "",
"css": "* {\n font-family: Open Sans;\n}\n",
"html": "<img id=\"myimage\" src=\"plain/url/image.png\">\n",
"renderOnMount": true,
"onRender": "const image = htmlNode.querySelector(\"img\");\nconst currentTime = new Date().getTime();\nimage.src = \"http://localhost:3000?timestamp=\" + currentTime;\n",
"panelupdateOnMount": true,
"dynamicHtmlGraphics": false,
"dynamicData": false,
"dynamicFieldDisplayValues": false,
"dynamicProps": false,
"onInitOnResize": false,
"onInit": ""
} |
Beta Was this translation helpful? Give feedback.
You are using
document.getElementById
, which is usually not what you want. To get elements in the panel, you should use thehtmlNode
instead ofdocument
.Example
Code used to serve the image: https://github.com/ZuperZee/serve-refresh-images
HTML
onInit
Panel options
(https://gapit-htmlgraphics-panel.gapit.io/docs/guides/how-to-import-export/)