From 0a4d021b4ecd78e616c7059a907685c047506772 Mon Sep 17 00:00:00 2001 From: Alicia Sykes Date: Mon, 13 Dec 2021 21:40:13 +0000 Subject: [PATCH] :goal_net: Adds graceful error hadling to widgets --- src/components/Widgets/CryptoPriceChart.vue | 9 ++- src/components/Widgets/CryptoWatchList.vue | 19 ++++-- src/components/Widgets/ExchangeRates.vue | 7 ++- src/components/Widgets/IframeWidget.vue | 5 +- src/components/Widgets/Jokes.vue | 9 ++- src/components/Widgets/StockPriceChart.vue | 11 ++-- src/components/Widgets/TflStatus.vue | 9 ++- src/components/Widgets/Weather.vue | 15 ++--- src/components/Widgets/WeatherForecast.vue | 21 +++---- src/components/Widgets/WidgetBase.vue | 67 ++++++++++++++++++--- src/components/Widgets/WidgetGroup.vue | 30 --------- src/components/Widgets/XkcdComic.vue | 7 ++- src/mixins/WidgetMixin.js | 18 ++++++ 13 files changed, 148 insertions(+), 79 deletions(-) delete mode 100644 src/components/Widgets/WidgetGroup.vue diff --git a/src/components/Widgets/CryptoPriceChart.vue b/src/components/Widgets/CryptoPriceChart.vue index e8a07bdd..33531e28 100644 --- a/src/components/Widgets/CryptoPriceChart.vue +++ b/src/components/Widgets/CryptoPriceChart.vue @@ -6,7 +6,6 @@ import { Chart } from 'frappe-charts/dist/frappe-charts.min.esm'; import axios from 'axios'; import WidgetMixin from '@/mixins/WidgetMixin'; -import ErrorHandler from '@/utils/ErrorHandler'; import { widgetApiEndpoints } from '@/utils/defaults'; export default { @@ -67,6 +66,7 @@ export default { methods: { /* Extends mixin, and updates data. Called by parent component */ update() { + this.startLoading(); this.fetchData(); }, /* Create new chart, using the crypto data */ @@ -98,11 +98,14 @@ export default { try { this.lineStatuses = this.processData(response.data); } catch (chartingError) { - ErrorHandler('Unable to plot results on chart', chartingError); + this.error('Unable to plot results on chart', chartingError); } }) .catch((dataFetchError) => { - ErrorHandler('Unable to fetch crypto data', dataFetchError); + this.error('Unable to fetch crypto data', dataFetchError); + }) + .finally(() => { + this.finishLoading(); }); }, /* Generate price history in a format that can be consumed by the chart diff --git a/src/components/Widgets/CryptoWatchList.vue b/src/components/Widgets/CryptoWatchList.vue index 47dd8adc..da603b35 100644 --- a/src/components/Widgets/CryptoWatchList.vue +++ b/src/components/Widgets/CryptoWatchList.vue @@ -21,7 +21,6 @@ @@ -129,15 +162,14 @@ export default { .widget-base { position: relative; padding-top: 0.75rem; - button.update-btn { - height: 1.5rem; + button.action-btn { + height: 1rem; min-width: auto; - width: 2rem; + width: 1.75rem; margin: 0; padding: 0.1rem 0; position: absolute; - right: -0.25rem; - top: -0.25rem; + top: 0; border: none; opacity: var(--dimming-factor); color: var(--widget-text-color); @@ -145,6 +177,27 @@ export default { opacity: 1; color: var(--widget-background-color); } + &.update-btn { + right: -0.25rem; + } + &.open-btn { + right: 1.75rem; + } + } + + .widget-error { + p.error-msg { + color: var(--warning); + font-weight: bold; + font-size: 1rem; + margin: 0 auto 0.5rem auto; + } + p.error-output { + font-family: var(--font-monospace); + color: var(--widget-text-color); + font-size: 0.85rem; + margin: 0.5rem auto; + } } } diff --git a/src/components/Widgets/WidgetGroup.vue b/src/components/Widgets/WidgetGroup.vue deleted file mode 100644 index 7efcebf2..00000000 --- a/src/components/Widgets/WidgetGroup.vue +++ /dev/null @@ -1,30 +0,0 @@ - - - - - diff --git a/src/components/Widgets/XkcdComic.vue b/src/components/Widgets/XkcdComic.vue index 3831f985..9674f4ee 100644 --- a/src/components/Widgets/XkcdComic.vue +++ b/src/components/Widgets/XkcdComic.vue @@ -10,7 +10,6 @@