From e9aa2bb7fc31883663ca8d42ef00f789376347a1 Mon Sep 17 00:00:00 2001 From: Alicia Sykes Date: Sun, 12 Sep 2021 16:33:29 +0100 Subject: [PATCH] :zap: Improved handling of unexpected events --- src/components/Configuration/CloudBackupRestore.vue | 3 +++ src/components/Configuration/CustomCss.vue | 3 +++ src/components/Configuration/JsonEditor.vue | 6 +++++- src/components/Settings/AuthButtons.vue | 2 +- src/views/Login.vue | 4 ++++ 5 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/components/Configuration/CloudBackupRestore.vue b/src/components/Configuration/CloudBackupRestore.vue index b0341cd9..83b303f4 100644 --- a/src/components/Configuration/CloudBackupRestore.vue +++ b/src/components/Configuration/CloudBackupRestore.vue @@ -66,6 +66,7 @@ import IconBackup from '@/assets/interface-icons/config-backup.svg'; import IconRestore from '@/assets/interface-icons/config-restore.svg'; import { backup, update, restore } from '@/utils/CloudBackup'; import { localStorageKeys } from '@/utils/defaults'; +import ErrorHandler, { InfoHandler } from '@/utils/ErrorHandler'; export default { name: 'CloudBackupRestore', @@ -160,9 +161,11 @@ export default { this.backupPassword = ''; }, showErrorMsg(errorMsg) { + ErrorHandler(errorMsg); this.$toasted.show(errorMsg, { className: 'toast-error' }); }, showSuccessMsg(msg) { + InfoHandler(msg, 'Cloud Backup'); this.$toasted.show(msg, { className: 'toast-success' }); }, makeHash(pass) { diff --git a/src/components/Configuration/CustomCss.vue b/src/components/Configuration/CustomCss.vue index 535c7f8c..8b3b6262 100644 --- a/src/components/Configuration/CustomCss.vue +++ b/src/components/Configuration/CustomCss.vue @@ -21,6 +21,7 @@ import CustomThemeMaker from '@/components/Settings/CustomThemeMaker'; import { getTheme } from '@/utils/ConfigHelpers'; import { localStorageKeys } from '@/utils/defaults'; +import { InfoHandler } from '@/utils/ErrorHandler'; export default { name: 'StyleEditor', @@ -49,10 +50,12 @@ export default { appConfig.customCss = this.customCss; localStorage.setItem(localStorageKeys.APP_CONFIG, JSON.stringify(appConfig)); msg = 'Changes saved successfully'; + InfoHandler('User syles has been saved', 'Custom CSS Update'); this.inject(this.customCss); if (this.customCss === '') setTimeout(() => { location.reload(); }, 1500); // eslint-disable-line no-restricted-globals } else { msg = 'Error - Invalid CSS'; + InfoHandler(msg, 'Custom CSS Update'); } this.$toasted.show(msg); }, diff --git a/src/components/Configuration/JsonEditor.vue b/src/components/Configuration/JsonEditor.vue index 35ee10a6..e0123d9f 100644 --- a/src/components/Configuration/JsonEditor.vue +++ b/src/components/Configuration/JsonEditor.vue @@ -61,9 +61,10 @@ import axios from 'axios'; import ProgressBar from 'rsup-progress'; import VJsoneditor from 'v-jsoneditor'; -import { localStorageKeys } from '@/utils/defaults'; +import ErrorHandler, { InfoHandler } from '@/utils/ErrorHandler'; import configSchema from '@/utils/ConfigSchema.json'; import JsonToYaml from '@/utils/JsonToYaml'; +import { localStorageKeys } from '@/utils/defaults'; import { isUserAdmin } from '@/utils/Auth'; export default { @@ -135,12 +136,14 @@ export default { } else { this.showToast(this.$t('config-editor.error-msg-cannot-save'), false); } + InfoHandler('Config has been written to disk succesfully', 'Config Update'); this.progress.end(); }) .catch((error) => { this.saveSuccess = false; this.responseText = error; this.showToast(error, false); + ErrorHandler(`Failed to save config. ${error}`); this.progress.end(); }); }, @@ -159,6 +162,7 @@ export default { if (data.appConfig.theme) { localStorage.setItem(localStorageKeys.THEME, data.appConfig.theme); } + InfoHandler('Config has succesfully been saved in browser storage', 'Config Update'); this.showToast(this.$t('config-editor.success-msg-local'), true); }, carefullyClearLocalStorage() { diff --git a/src/components/Settings/AuthButtons.vue b/src/components/Settings/AuthButtons.vue index 29e082cb..ddacc2c1 100644 --- a/src/components/Settings/AuthButtons.vue +++ b/src/components/Settings/AuthButtons.vue @@ -57,7 +57,7 @@ export default { makeText() { if (this.userType === userStateEnum.loggedIn) { const username = localStorage[localStorageKeys.USERNAME]; - return this.$t('settings.sign-in-welcome', { username }); + return username ? this.$t('settings.sign-in-welcome', { username }) : ''; } if (this.userType === userStateEnum.guestAccess) { return this.$t('settings.sign-in-tooltip'); diff --git a/src/views/Login.vue b/src/views/Login.vue index fd9f6a17..0b159f2c 100644 --- a/src/views/Login.vue +++ b/src/views/Login.vue @@ -76,6 +76,7 @@ import router from '@/router'; import Button from '@/components/FormElements/Button'; import Input from '@/components/FormElements/Input'; import Defaults, { localStorageKeys } from '@/utils/defaults'; +import { InfoHandler } from '@/utils/ErrorHandler'; import { checkCredentials, login, @@ -157,6 +158,9 @@ export default { if (response.correct) { // Yay, credentials were correct :) login(this.username, this.password, timeout); // Login, to set the cookie this.goHome(); + InfoHandler(`Succesfully signed in as ${this.username}`, 'Authentication'); + } else { + InfoHandler(`Unable to Sign In - ${this.message}`, 'Authentication'); } }, /* Calls function to double-check guest access enabled, then log in as guest */