mirror of
https://github.com/Lissy93/dashy.git
synced 2025-07-23 21:55:30 +02:00
⚡ Improved handling of unexpected events
This commit is contained in:
parent
affff262d3
commit
e9aa2bb7fc
@ -66,6 +66,7 @@ import IconBackup from '@/assets/interface-icons/config-backup.svg';
|
|||||||
import IconRestore from '@/assets/interface-icons/config-restore.svg';
|
import IconRestore from '@/assets/interface-icons/config-restore.svg';
|
||||||
import { backup, update, restore } from '@/utils/CloudBackup';
|
import { backup, update, restore } from '@/utils/CloudBackup';
|
||||||
import { localStorageKeys } from '@/utils/defaults';
|
import { localStorageKeys } from '@/utils/defaults';
|
||||||
|
import ErrorHandler, { InfoHandler } from '@/utils/ErrorHandler';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'CloudBackupRestore',
|
name: 'CloudBackupRestore',
|
||||||
@ -160,9 +161,11 @@ export default {
|
|||||||
this.backupPassword = '';
|
this.backupPassword = '';
|
||||||
},
|
},
|
||||||
showErrorMsg(errorMsg) {
|
showErrorMsg(errorMsg) {
|
||||||
|
ErrorHandler(errorMsg);
|
||||||
this.$toasted.show(errorMsg, { className: 'toast-error' });
|
this.$toasted.show(errorMsg, { className: 'toast-error' });
|
||||||
},
|
},
|
||||||
showSuccessMsg(msg) {
|
showSuccessMsg(msg) {
|
||||||
|
InfoHandler(msg, 'Cloud Backup');
|
||||||
this.$toasted.show(msg, { className: 'toast-success' });
|
this.$toasted.show(msg, { className: 'toast-success' });
|
||||||
},
|
},
|
||||||
makeHash(pass) {
|
makeHash(pass) {
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
import CustomThemeMaker from '@/components/Settings/CustomThemeMaker';
|
import CustomThemeMaker from '@/components/Settings/CustomThemeMaker';
|
||||||
import { getTheme } from '@/utils/ConfigHelpers';
|
import { getTheme } from '@/utils/ConfigHelpers';
|
||||||
import { localStorageKeys } from '@/utils/defaults';
|
import { localStorageKeys } from '@/utils/defaults';
|
||||||
|
import { InfoHandler } from '@/utils/ErrorHandler';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'StyleEditor',
|
name: 'StyleEditor',
|
||||||
@ -49,10 +50,12 @@ export default {
|
|||||||
appConfig.customCss = this.customCss;
|
appConfig.customCss = this.customCss;
|
||||||
localStorage.setItem(localStorageKeys.APP_CONFIG, JSON.stringify(appConfig));
|
localStorage.setItem(localStorageKeys.APP_CONFIG, JSON.stringify(appConfig));
|
||||||
msg = 'Changes saved successfully';
|
msg = 'Changes saved successfully';
|
||||||
|
InfoHandler('User syles has been saved', 'Custom CSS Update');
|
||||||
this.inject(this.customCss);
|
this.inject(this.customCss);
|
||||||
if (this.customCss === '') setTimeout(() => { location.reload(); }, 1500); // eslint-disable-line no-restricted-globals
|
if (this.customCss === '') setTimeout(() => { location.reload(); }, 1500); // eslint-disable-line no-restricted-globals
|
||||||
} else {
|
} else {
|
||||||
msg = 'Error - Invalid CSS';
|
msg = 'Error - Invalid CSS';
|
||||||
|
InfoHandler(msg, 'Custom CSS Update');
|
||||||
}
|
}
|
||||||
this.$toasted.show(msg);
|
this.$toasted.show(msg);
|
||||||
},
|
},
|
||||||
|
@ -61,9 +61,10 @@
|
|||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import ProgressBar from 'rsup-progress';
|
import ProgressBar from 'rsup-progress';
|
||||||
import VJsoneditor from 'v-jsoneditor';
|
import VJsoneditor from 'v-jsoneditor';
|
||||||
import { localStorageKeys } from '@/utils/defaults';
|
import ErrorHandler, { InfoHandler } from '@/utils/ErrorHandler';
|
||||||
import configSchema from '@/utils/ConfigSchema.json';
|
import configSchema from '@/utils/ConfigSchema.json';
|
||||||
import JsonToYaml from '@/utils/JsonToYaml';
|
import JsonToYaml from '@/utils/JsonToYaml';
|
||||||
|
import { localStorageKeys } from '@/utils/defaults';
|
||||||
import { isUserAdmin } from '@/utils/Auth';
|
import { isUserAdmin } from '@/utils/Auth';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
@ -135,12 +136,14 @@ export default {
|
|||||||
} else {
|
} else {
|
||||||
this.showToast(this.$t('config-editor.error-msg-cannot-save'), false);
|
this.showToast(this.$t('config-editor.error-msg-cannot-save'), false);
|
||||||
}
|
}
|
||||||
|
InfoHandler('Config has been written to disk succesfully', 'Config Update');
|
||||||
this.progress.end();
|
this.progress.end();
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
this.saveSuccess = false;
|
this.saveSuccess = false;
|
||||||
this.responseText = error;
|
this.responseText = error;
|
||||||
this.showToast(error, false);
|
this.showToast(error, false);
|
||||||
|
ErrorHandler(`Failed to save config. ${error}`);
|
||||||
this.progress.end();
|
this.progress.end();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@ -159,6 +162,7 @@ export default {
|
|||||||
if (data.appConfig.theme) {
|
if (data.appConfig.theme) {
|
||||||
localStorage.setItem(localStorageKeys.THEME, 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);
|
this.showToast(this.$t('config-editor.success-msg-local'), true);
|
||||||
},
|
},
|
||||||
carefullyClearLocalStorage() {
|
carefullyClearLocalStorage() {
|
||||||
|
@ -57,7 +57,7 @@ export default {
|
|||||||
makeText() {
|
makeText() {
|
||||||
if (this.userType === userStateEnum.loggedIn) {
|
if (this.userType === userStateEnum.loggedIn) {
|
||||||
const username = localStorage[localStorageKeys.USERNAME];
|
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) {
|
if (this.userType === userStateEnum.guestAccess) {
|
||||||
return this.$t('settings.sign-in-tooltip');
|
return this.$t('settings.sign-in-tooltip');
|
||||||
|
@ -76,6 +76,7 @@ import router from '@/router';
|
|||||||
import Button from '@/components/FormElements/Button';
|
import Button from '@/components/FormElements/Button';
|
||||||
import Input from '@/components/FormElements/Input';
|
import Input from '@/components/FormElements/Input';
|
||||||
import Defaults, { localStorageKeys } from '@/utils/defaults';
|
import Defaults, { localStorageKeys } from '@/utils/defaults';
|
||||||
|
import { InfoHandler } from '@/utils/ErrorHandler';
|
||||||
import {
|
import {
|
||||||
checkCredentials,
|
checkCredentials,
|
||||||
login,
|
login,
|
||||||
@ -157,6 +158,9 @@ export default {
|
|||||||
if (response.correct) { // Yay, credentials were correct :)
|
if (response.correct) { // Yay, credentials were correct :)
|
||||||
login(this.username, this.password, timeout); // Login, to set the cookie
|
login(this.username, this.password, timeout); // Login, to set the cookie
|
||||||
this.goHome();
|
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 */
|
/* Calls function to double-check guest access enabled, then log in as guest */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user