diff --git a/src/assets/DefaultUserSettings.json b/src/assets/DefaultUserSettings.json new file mode 100644 index 000000000..1ca4fb774 --- /dev/null +++ b/src/assets/DefaultUserSettings.json @@ -0,0 +1,101 @@ +[ + { + "id": "units.displayUnits", + "type": "oneOfMultiple", + "label": "Display Units", + "value": "display", + "items": [ + { + "value": "stored", + "icon": "mdi-database" + }, + { + "value": "display", + "icon": "mdi-monitor" + }, + { + "value": "custom", + "icon": "mdi-monitor-edit", + "disabled": true + } + ], + "group": "Units" + }, + { + "id": "units.parameterGroup.Discharge", + "type": "oneOfMultiple", + "label": "Discharge", + "value": "ML/d", + "disabled": true, + "items": [ + { + "value": "m³/s" + }, + { + "value": "ML/d" + } + ], + "group": "Units" + }, + { + "id": "units.parameterGroup.Volume", + "type": "oneOfMultiple", + "label": "Volume", + "value": "ML", + "disabled": true, + "items": [ + { + "value": "m³" + }, + { + "value": "ML" + } + ], + "group": "Units" + }, + { + "id": "datum.verticalDatum", + "type": "boolean", + "label": "Absolute vertical datum", + "value": true, + "group": "Datum" + }, + { + "id": "ui.theme", + "type": "oneOfMultiple", + "label": "Theme", + "value": "auto", + "items": [ + { + "value": "auto", + "icon": "mdi-theme-light-dark" + }, + { + "value": "light", + "icon": "mdi-weather-sunny" + }, + { + "value": "dark", + "icon": "mdi-weather-night" + } + ], + "group": "UI" + }, + { + "id": "locale.language", + "type": "oneOfMultiple", + "label": "Language", + "value": "en-au", + "items": [ + { + "icon": "fi-au", + "value": "en-au" + }, + { + "icon": "fi-nl", + "value": "nl-nl" + } + ], + "group": "Locale" + } +] \ No newline at end of file diff --git a/src/store/modules/user-settings/serialize.ts b/src/store/modules/user-settings/serialize.ts index cf4537bb7..20ca852fe 100644 --- a/src/store/modules/user-settings/serialize.ts +++ b/src/store/modules/user-settings/serialize.ts @@ -1,6 +1,7 @@ import { RootState } from '../../types' import { UserSettingsItem, UserSettingsState } from './types' import { state as emptyState } from './index' +import DefaultUserSettings from '@/assets/DefaultUserSettings.json' export function serializeState(state: UserSettingsState): Partial[] { const serializedSettings: Partial[] = [] @@ -17,31 +18,7 @@ export function serializeState(state: UserSettingsState): Partial { - const defaultSettings: UserSettingsItem[] = [ - { id: 'units.displayUnits', type: 'oneOfMultiple', label: 'Display Units', value: 'display', items: [ - { value: 'stored', icon: 'mdi-database'}, - { value: 'display', icon: 'mdi-monitor'}, - { value: 'custom' , icon: 'mdi-monitor-edit', disabled: true} - ], group: 'Units'}, - { id: 'units.parameterGroup.Discharge', type: 'oneOfMultiple', label: 'Discharge', value: 'ML/d', disabled: true, items: [ - { value: 'm³/s' }, - { value: 'ML/d'} - ], group: 'Units'}, - { id: 'units.parameterGroup.Volume', type: 'oneOfMultiple', label: 'Volume', value: 'ML', disabled: true, items: [ - { value: 'm³' }, - { value: 'ML' } - ], group: 'Units'}, - { id: 'datum.verticalDatum', type: 'boolean', label: 'Absolute vertical datum', value: true, group: 'Datum'}, - { id: 'ui.theme', type: 'oneOfMultiple', label: 'Theme', value: 'auto', items: [ - { value: 'auto', icon: 'mdi-theme-light-dark'}, - { value: 'light', icon: 'mdi-weather-sunny'}, - { value: 'dark' , icon: 'mdi-weather-night'} - ], group: 'UI'}, - { id: 'locale.language', type: 'oneOfMultiple', label: 'Language', value: 'en-au', items: [ - { icon: 'fi-au', value: 'en-au' }, - { icon: 'fi-nl', value: 'nl-nl' } - ], group: 'Locale'}, - ] + const defaultSettings = DefaultUserSettings as UserSettingsItem[] const defaultState = emptyState defaultState.allIds = defaultSettings.map( item => item.id) const byId: Record= {}