From 979a776b687647f145706b69356bc48aa36f0a9f Mon Sep 17 00:00:00 2001 From: Alicia Sykes Date: Sun, 27 Mar 2022 21:21:59 +0100 Subject: [PATCH] :sparkles: Adds option for request timeout in widgets --- src/components/Widgets/WidgetBase.vue | 5 ++++- src/mixins/WidgetMixin.js | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/components/Widgets/WidgetBase.vue b/src/components/Widgets/WidgetBase.vue index 63b13be5..e6f80c3a 100644 --- a/src/components/Widgets/WidgetBase.vue +++ b/src/components/Widgets/WidgetBase.vue @@ -476,10 +476,13 @@ export default { /* Returns users specified widget options, or empty object */ widgetOptions() { const options = this.widget.options || {}; + const timeout = this.widget.timeout || 500; const useProxy = this.appConfig.widgetsAlwaysUseProxy || !!this.widget.useProxy; const updateInterval = this.widget.updateInterval !== undefined ? this.widget.updateInterval : null; - return { useProxy, updateInterval, ...options }; + return { + timeout, useProxy, updateInterval, ...options, + }; }, /* A unique string to reference the widget by */ widgetRef() { diff --git a/src/mixins/WidgetMixin.js b/src/mixins/WidgetMixin.js index 6ac2ede4..48e74c85 100644 --- a/src/mixins/WidgetMixin.js +++ b/src/mixins/WidgetMixin.js @@ -106,8 +106,9 @@ const WidgetMixin = { const CustomHeaders = options || null; const headers = this.useProxy ? { 'Target-URL': endpoint, CustomHeaders: JSON.stringify(CustomHeaders) } : CustomHeaders; + const timeout = this.options.timeout || 500; const requestConfig = { - method, url, headers, data, + method, url, headers, data, timeout, }; // Make request return new Promise((resolve, reject) => {