π A self-hostable personal dashboard built for you. Includes status-checking, widgets, themes, icon packs, a UI editor and tons more!
Vue awesomedashboarddockerhomelabhomepagemitnodejsorganizationproductivitypwaself-hostedstartpagevue
:zap: Adds option to prevent saving changes locally (#485)
Alicia Sykesa65c3c569ec3
diff --git a/src/components/Configuration/JsonEditor.vue b/src/components/Configuration/JsonEditor.vueindex 62d0a279..1fea286d 100644--- a/src/components/Configuration/JsonEditor.vue+++ b/src/components/Configuration/JsonEditor.vue@@ -8,11 +8,11 @@:label="$t('config-editor.save-location-label')":options="saveOptions":initialOption="initialSaveMode"- :disabled="!allowWriteToDisk"+ :disabled="!allowWriteToDisk || !allowSaveLocally"/><!-- Save Buttons --><div :class="`btn-container ${!isValid ? 'err' : ''}`">- <Button :click="save">+ <Button :click="save" :disallow="!allowWriteToDisk && !allowSaveLocally">{{ $t('config-editor.save-button') }}</Button><Button :click="startPreview">@@ -101,8 +101,14 @@ export default {const { appConfig } = this.config;return !appConfig.preventWriteToDisk && appConfig.allowConfigEdit !== false && isUserAdmin();},+ allowSaveLocally() {+ if (this.config.appConfig.preventLocalSave) return false;+ return true;+ },initialSaveMode() {- return this.allowWriteToDisk ? 'file' : 'local';+ if (this.allowWriteToDisk) return 'file';+ if (this.allowSaveLocally) return 'local';+ return '';},},mounted() {@@ -166,6 +172,10 @@ export default {},/* Saves config to local browser storage */saveConfigLocally() {+ if (!this.allowSaveLocally) {+ ErrorHandler('Unable to save changes locally, this feature has been disabled');+ return;+ }const data = this.jsonData;if (data.sections) {localStorage.setItem(localStorageKeys.CONF_SECTIONS, JSON.stringify(data.sections));@@ -180,7 +190,7 @@ export default {if (data.appConfig.theme) {localStorage.setItem(localStorageKeys.THEME, data.appConfig.theme);}- InfoHandler('Config has succesfully been saved in browser storage', InfoKeys.RAW_EDITOR);+ InfoHandler('Config has successfully been saved in browser storage', InfoKeys.RAW_EDITOR);this.showToast(this.$t('config-editor.success-msg-local'), true);},/* Clears config from browser storage, only removing relevant items */diff --git a/src/components/FormElements/Button.vue b/src/components/FormElements/Button.vueindex d2da7a7c..11a4ba29 100644--- a/src/components/FormElements/Button.vue+++ b/src/components/FormElements/Button.vue@@ -3,7 +3,7 @@@click="click ? click() : () => null":class="disallow ? 'disallowed': ''":type="type || 'button'"- :disabled="disabled"+ :disabled="disabled || disallow"v-tooltip="hoverText":title="tooltip">@@ -68,7 +68,7 @@ button {background: var(--background);border: 1px solid var(--primary);border-radius: var(--curve-factor);- &:hover:not(:disabled) {+ &:hover:not(:disabled):not(.disallowed) {color: var(--background);background: var(--primary);border-color: var(--background);diff --git a/src/components/InteractiveEditor/EditModeSaveMenu.vue b/src/components/InteractiveEditor/EditModeSaveMenu.vueindex 7cbdbcbc..bc1ef09c 100644--- a/src/components/InteractiveEditor/EditModeSaveMenu.vue+++ b/src/components/InteractiveEditor/EditModeSaveMenu.vue@@ -17,6 +17,7 @@</p><Button:click="saveLocally"+ :disallow="!allowSaveLocally"v-tooltip="tooltip($t('interactive-editor.menu.save-locally-tooltip'))">{{ $t('interactive-editor.menu.save-locally-btn') }}@@ -24,7 +25,7 @@</Button><Button:click="writeToDisk"- :disabled="!allowWriteToDisk"+ :disallow="!allowWriteToDisk"v-tooltip="tooltip($t('interactive-editor.menu.save-disk-tooltip'))">{{ $t('interactive-editor.menu.save-disk-btn') }}@@ -115,6 +116,10 @@ export default {if (!isUserAdmin()) return false; // If auth configured, but user NOT adminreturn true;},+ allowSaveLocally() {+ if (this.config.appConfig.preventLocalSave) return false;+ return true;+ },},data() {return {@@ -152,6 +157,10 @@ export default {localStorage.removeItem(localStorageKeys.CONF_SECTIONS);},saveLocally() {+ if (!this.allowSaveLocally) {+ ErrorHandler('Unable to save changes locally, this feature has been disabled');+ return;+ }const data = this.config;localStorage.setItem(localStorageKeys.CONF_SECTIONS, JSON.stringify(data.sections));localStorage.setItem(localStorageKeys.PAGE_INFO, JSON.stringify(data.pageInfo));@@ -277,7 +286,7 @@ div.edit-mode-bottom-banner {color: var(--interactive-editor-color);border-color: var(--interactive-editor-color);background: var(--interactive-editor-background);- &:hover {+ &:hover:not(.disallowed) {color: var(--interactive-editor-background);border-color: var(--interactive-editor-color);background: var(--interactive-editor-color);