Lissy93/dashy

[BUG] iframe widget doesn't reload

zaromarco opened this issue · 4 comments

Environment

Self-Hosted (Docker)

System

No response

Version

latest

Describe the problem

hi , i have setup an ifram widget like this:

name: Speedtest
widgets:
    type: iframe
    updateInterval: 1800
    options:
    url: http://192.168.10.148/speedtest.html
    frameHeight: 260
    id: 0_2993_iframe
    displayData:
    sortBy: default
    rows: 2
    cols: 1
    collapsed: false
    hideForGuests: false

as you can see i have setup the parameter to autoreload the html page each 1800 seconds but the page is not updated...the only way to see the change is to close the dashy board or right click on that iframe and hit reload this sub page...
i'm using the latest firefox.
please let me know

Additional info

No response

Please tick the boxes

any news ?
i do an html test page and an iframe inside of it and in a normal html page adding the tag: in the iframe it reload the iframe page.

page.htm

<script>document.write(Date().toString());</script>
<iframe src="frame.htm" title="frame title"></iframe>

iframe.htm

<script>document.write(Date().toString());</script>

with dashy will it works?

Have submitted in 07dbccc, and I'll try and get a PR open for this sometime this weekend.

Solution

I got it working, with something like this:

const iframe = document.getElementById(this.frameId);
iframe.contentWindow.location.href = this.frameUrl;
iframe.contentWindow.location.reload(true);

With the frameUrl having an extra val appended to it on each reload

  data: () => ({
    updateCount: 0,
  }),
  computed: {
    /* Generate a URL param, to be updated in order to re-fetch image */
    updatePathParam() {
      return this.updateCount ? `#dashy-update-${this.updateCount}` : '';
    },
    /* Gets users specified URL to load into the iframe */
    frameUrl() {
      return `${this.options.url}${this.updatePathParam}`;
    },
}

Hi, I bypass the problem by adding this code in the iframed html page

Because the updateInterval in the widget section , as described in your docs doesn't work