Improved handling of unexpected events

This commit is contained in:
Alicia Sykes 2021-09-12 16:33:29 +01:00
parent affff262d3
commit e9aa2bb7fc
5 changed files with 16 additions and 2 deletions

View File

@ -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) {

View File

@ -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);
},

View File

@ -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() {

View File

@ -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');

View File

@ -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 */