Skip to content

armgit / dashy

Public Imported from GitHub
0

πŸš€ A self-hostable personal dashboard built for you. Includes status-checking, widgets, themes, icon packs, a UI editor and tons more!

✨ Improved update support for iframe widget, plus shows loader (#992)

Alicia Sykesbb8419f0775a
diff --git a/src/components/Widgets/IframeWidget.vue b/src/components/Widgets/IframeWidget.vue
index 01d101d4..da04445c 100644
--- a/src/components/Widgets/IframeWidget.vue
+++ b/src/components/Widgets/IframeWidget.vue
@@ -15,6 +15,9 @@ import WidgetMixin from '@/mixins/WidgetMixin';
export default {
mixins: [WidgetMixin],
+ data: () => ({
+ updateCount: 0,
+ }),
computed: {
/* Gets users specified URL to load into the iframe */
frameUrl() {
@@ -23,7 +26,7 @@ export default {
this.error('Iframe widget expects a URL');
return null;
}
- return usersChoice;
+ return `${usersChoice}${this.updatePathParam}`;
},
frameHeight() {
return this.options.frameHeight;
@@ -32,11 +35,16 @@ export default {
frameId() {
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: {
/* Refreshes iframe contents, called by parent */
update() {
this.startLoading();
+ this.updateCount += 1;
(document.getElementById(this.frameId) || {}).src = this.frameUrl;
this.finishLoading();
},
diff --git a/src/components/Widgets/ImageWidget.vue b/src/components/Widgets/ImageWidget.vue
index 8bbf22c8..a80407b7 100644
--- a/src/components/Widgets/ImageWidget.vue
+++ b/src/components/Widgets/ImageWidget.vue
@@ -32,10 +32,6 @@ export default {
return userVal;
}
};
- console.log(`
- width: ${makeDimensionsUnit(this.options.imageWidth)};
- height: ${makeDimensionsUnit(this.options.imageHeight)};
- `);
// Return CSS values for width and height
return `
width: ${makeDimensionsUnit(this.options.imageWidth)};
@@ -50,7 +46,9 @@ export default {
methods: {
/* In order to re-fetch the image, we much update the URL with an arbitrary hash */
update() {
+ this.startLoading();
this.updateCount += 1;
+ this.finishLoading();
},
},
};