mirror of https://github.com/Lissy93/dashy.git
✨ Improved update support for iframe widget, plus shows loader (#992)
This commit is contained in:
parent
f00132d4a3
commit
bb8419f077
|
@ -15,6 +15,9 @@ import WidgetMixin from '@/mixins/WidgetMixin';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
mixins: [WidgetMixin],
|
mixins: [WidgetMixin],
|
||||||
|
data: () => ({
|
||||||
|
updateCount: 0,
|
||||||
|
}),
|
||||||
computed: {
|
computed: {
|
||||||
/* Gets users specified URL to load into the iframe */
|
/* Gets users specified URL to load into the iframe */
|
||||||
frameUrl() {
|
frameUrl() {
|
||||||
|
@ -23,7 +26,7 @@ export default {
|
||||||
this.error('Iframe widget expects a URL');
|
this.error('Iframe widget expects a URL');
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return usersChoice;
|
return `${usersChoice}${this.updatePathParam}`;
|
||||||
},
|
},
|
||||||
frameHeight() {
|
frameHeight() {
|
||||||
return this.options.frameHeight;
|
return this.options.frameHeight;
|
||||||
|
@ -32,11 +35,16 @@ export default {
|
||||||
frameId() {
|
frameId() {
|
||||||
return `iframe-${btoa(this.frameUrl || 'empty').substring(0, 16)}`;
|
return `iframe-${btoa(this.frameUrl || 'empty').substring(0, 16)}`;
|
||||||
},
|
},
|
||||||
|
/* Generate a URL param, to be updated in order to re-fetch image */
|
||||||
|
updatePathParam() {
|
||||||
|
return this.updateCount ? `#dashy-update-${this.updateCount}` : '';
|
||||||
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
/* Refreshes iframe contents, called by parent */
|
/* Refreshes iframe contents, called by parent */
|
||||||
update() {
|
update() {
|
||||||
this.startLoading();
|
this.startLoading();
|
||||||
|
this.updateCount += 1;
|
||||||
(document.getElementById(this.frameId) || {}).src = this.frameUrl;
|
(document.getElementById(this.frameId) || {}).src = this.frameUrl;
|
||||||
this.finishLoading();
|
this.finishLoading();
|
||||||
},
|
},
|
||||||
|
|
|
@ -32,10 +32,6 @@ export default {
|
||||||
return userVal;
|
return userVal;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
console.log(`
|
|
||||||
width: ${makeDimensionsUnit(this.options.imageWidth)};
|
|
||||||
height: ${makeDimensionsUnit(this.options.imageHeight)};
|
|
||||||
`);
|
|
||||||
// Return CSS values for width and height
|
// Return CSS values for width and height
|
||||||
return `
|
return `
|
||||||
width: ${makeDimensionsUnit(this.options.imageWidth)};
|
width: ${makeDimensionsUnit(this.options.imageWidth)};
|
||||||
|
@ -50,7 +46,9 @@ export default {
|
||||||
methods: {
|
methods: {
|
||||||
/* In order to re-fetch the image, we much update the URL with an arbitrary hash */
|
/* In order to re-fetch the image, we much update the URL with an arbitrary hash */
|
||||||
update() {
|
update() {
|
||||||
|
this.startLoading();
|
||||||
this.updateCount += 1;
|
this.updateCount += 1;
|
||||||
|
this.finishLoading();
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue