From f52e5077bfd89aa2732c72bc3b761e69dff6e83b Mon Sep 17 00:00:00 2001 From: Werner Kramer Date: Tue, 6 Jun 2023 15:18:50 +0200 Subject: [PATCH 01/20] First version of UserSettingsView --- src/components/CogMenu.vue | 46 +++++++++++++++++----------------- src/router/index.ts | 7 ++++++ src/views/UserSettingsView.vue | 37 +++++++++++++++++++++++++++ 3 files changed, 67 insertions(+), 23 deletions(-) create mode 100644 src/views/UserSettingsView.vue diff --git a/src/components/CogMenu.vue b/src/components/CogMenu.vue index 0e3080514..9c1708b15 100644 --- a/src/components/CogMenu.vue +++ b/src/components/CogMenu.vue @@ -6,20 +6,17 @@ + Settings Theme - - - + Language - - - + @@ -32,26 +29,29 @@ diff --git a/src/router/index.ts b/src/router/index.ts index 711828eef..95008ca75 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -1,6 +1,7 @@ import Vue from 'vue' import VueRouter, { RouteConfig } from 'vue-router' import HomeView from '../views/HomeView.vue' +import UserSettingsView from '../views/UserSettingsView.vue' import SchematicStatusDisplay from '../views/SchematicStatusDisplay.vue' import SpatialDisplay from '../views/SpatialDisplay.vue' import Silent from '../views/auth/Silent.vue' @@ -33,6 +34,12 @@ const routesBase: Array = [ meta: { authorize: [] }, component: HomeView }, + { + path: '/settings', + name: 'UserSettingsView', + meta: { authorize: [] }, + component: UserSettingsView + }, { path: '/login', name: 'Login', diff --git a/src/views/UserSettingsView.vue b/src/views/UserSettingsView.vue new file mode 100644 index 000000000..b6e115fd9 --- /dev/null +++ b/src/views/UserSettingsView.vue @@ -0,0 +1,37 @@ + + + + + From f6a7b29761802ceec0e567c8bcedc92e00208d44 Mon Sep 17 00:00:00 2001 From: Werner Kramer Date: Tue, 6 Jun 2023 15:46:33 +0200 Subject: [PATCH 02/20] Move settings to store --- src/store/index.ts | 4 ++- src/store/modules/user-settings/actions.ts | 6 +++++ src/store/modules/user-settings/getters.ts | 10 ++++++++ src/store/modules/user-settings/index.ts | 27 ++++++++++++++++++++ src/store/modules/user-settings/mutations.ts | 5 ++++ src/store/modules/user-settings/types.ts | 18 +++++++++++++ src/views/UserSettingsView.vue | 20 ++++++--------- 7 files changed, 77 insertions(+), 13 deletions(-) create mode 100644 src/store/modules/user-settings/actions.ts create mode 100644 src/store/modules/user-settings/getters.ts create mode 100644 src/store/modules/user-settings/index.ts create mode 100644 src/store/modules/user-settings/mutations.ts create mode 100644 src/store/modules/user-settings/types.ts diff --git a/src/store/index.ts b/src/store/index.ts index e4ad3fcba..f1a03a5ca 100644 --- a/src/store/index.ts +++ b/src/store/index.ts @@ -4,6 +4,7 @@ import { RootState } from './types' import Alerts from '@/store/modules/alerts' import { fewsconfig } from '@/store/modules/fews-config' import { systemTime } from '@/store/modules/system-time' +import { userSettings } from '@/store/modules/user-settings' Vue.use(Vuex) @@ -17,7 +18,8 @@ const store = new Vuex.Store({ modules: { alerts: Alerts, systemTime, - fewsconfig + fewsconfig, + userSettings } }) diff --git a/src/store/modules/user-settings/actions.ts b/src/store/modules/user-settings/actions.ts new file mode 100644 index 000000000..8a3ebe1c1 --- /dev/null +++ b/src/store/modules/user-settings/actions.ts @@ -0,0 +1,6 @@ +import { ActionTree } from 'vuex' +import { RootState } from '../../types' +import { UserSettingsState } from './types' + +export const actions: ActionTree= { +} diff --git a/src/store/modules/user-settings/getters.ts b/src/store/modules/user-settings/getters.ts new file mode 100644 index 000000000..907ce4847 --- /dev/null +++ b/src/store/modules/user-settings/getters.ts @@ -0,0 +1,10 @@ + +import { GetterTree } from 'vuex'; +import { UserSettingsState } from './types'; +import { RootState } from '../../types'; + +export const getters: GetterTree = { + settingsForGroup: (state, _getters, _rootState: RootState, rootGetters) => (id: string) => { + return state.settings.filter((s) => s.group === id) + }, +} diff --git a/src/store/modules/user-settings/index.ts b/src/store/modules/user-settings/index.ts new file mode 100644 index 000000000..a8164ee5b --- /dev/null +++ b/src/store/modules/user-settings/index.ts @@ -0,0 +1,27 @@ + +import { Module } from 'vuex'; +import { UserSettingsState } from './types' +import { RootState } from '../../types'; +import { getters } from './getters'; +import { actions } from './actions'; +import { mutations } from './mutations'; + +export const state: UserSettingsState = { + settings: [ + { type: 'oneOfMultiple' , label: 'Wind speed', value: 'm/s', items: ['m/s', 'km/h', 'Bft', 'kts'], group: 'Units'}, + { type: 'oneOfMultiple', label: 'Wind direction', value: 'degree', items: ['degree', 'cardinal'], group: 'Units'}, + { type: 'oneOfMultiple', label: 'Theme', value: 'auto', items: ['auto', 'light', 'dark'], group: 'Theme'}, + { type: 'oneOfMultiple', label: 'Language', value: 'en', items: ['en', 'nl'], group: 'Locale'}, + ], + groups: ['Units', 'Theme', 'Locale'] +}; + +const namespaced: boolean = true; + +export const userSettings: Module = { + namespaced, + state, + getters, + actions, + mutations +} diff --git a/src/store/modules/user-settings/mutations.ts b/src/store/modules/user-settings/mutations.ts new file mode 100644 index 000000000..a6c46c4e6 --- /dev/null +++ b/src/store/modules/user-settings/mutations.ts @@ -0,0 +1,5 @@ +import { MutationTree } from 'vuex'; +import { UserSettingsState } from './types'; + +export const mutations: MutationTree = { +} diff --git a/src/store/modules/user-settings/types.ts b/src/store/modules/user-settings/types.ts new file mode 100644 index 000000000..ba826360e --- /dev/null +++ b/src/store/modules/user-settings/types.ts @@ -0,0 +1,18 @@ +export const UserSettingsType = { + oneOfMultiple: 'oneOfMultiple', +} as const + +export type UserSettingsType = (typeof UserSettingsType)[keyof typeof UserSettingsType]; + +export interface UserSettingsItem { + type: UserSettingsType; + label: string; + value: string; + items: string[]; + group: string; +} + +export interface UserSettingsState { + settings: UserSettingsItem[] + groups: string[] +} diff --git a/src/views/UserSettingsView.vue b/src/views/UserSettingsView.vue index b6e115fd9..ed0896a57 100644 --- a/src/views/UserSettingsView.vue +++ b/src/views/UserSettingsView.vue @@ -14,22 +14,18 @@ From 0243775c66019aa457f622445d97940e54741833 Mon Sep 17 00:00:00 2001 From: Werner Kramer Date: Wed, 7 Jun 2023 10:27:43 +0200 Subject: [PATCH 03/20] Add icon and favorite --- src/store/modules/user-settings/index.ts | 23 +++++++++++++++---- src/store/modules/user-settings/types.ts | 8 ++++++- src/views/UserSettingsView.vue | 29 +++++++++++++++++++++++- 3 files changed, 54 insertions(+), 6 deletions(-) diff --git a/src/store/modules/user-settings/index.ts b/src/store/modules/user-settings/index.ts index a8164ee5b..1d578c701 100644 --- a/src/store/modules/user-settings/index.ts +++ b/src/store/modules/user-settings/index.ts @@ -8,10 +8,25 @@ import { mutations } from './mutations'; export const state: UserSettingsState = { settings: [ - { type: 'oneOfMultiple' , label: 'Wind speed', value: 'm/s', items: ['m/s', 'km/h', 'Bft', 'kts'], group: 'Units'}, - { type: 'oneOfMultiple', label: 'Wind direction', value: 'degree', items: ['degree', 'cardinal'], group: 'Units'}, - { type: 'oneOfMultiple', label: 'Theme', value: 'auto', items: ['auto', 'light', 'dark'], group: 'Theme'}, - { type: 'oneOfMultiple', label: 'Language', value: 'en', items: ['en', 'nl'], group: 'Locale'}, + { type: 'oneOfMultiple' , label: 'Wind speed', value: 'm/s', items: [ + { value: 'm/s' }, + { value: 'km/hl'}, + { value: 'Bft' }, + { value: 'kts' } + ], group: 'Units'}, + { type: 'oneOfMultiple', label: 'Wind direction', value: 'degree', items: [ + { value: 'degree' }, + { value: 'cardinal' } + ], group: 'Units'}, + { 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: 'Theme'}, + { type: 'oneOfMultiple', label: 'Language', value: 'en', items: [ + { icon: 'fi-au', value: 'en-au' }, + { icon: 'fi-nl', value: 'nl' } + ], group: 'Locale'}, ], groups: ['Units', 'Theme', 'Locale'] }; diff --git a/src/store/modules/user-settings/types.ts b/src/store/modules/user-settings/types.ts index ba826360e..37599f82c 100644 --- a/src/store/modules/user-settings/types.ts +++ b/src/store/modules/user-settings/types.ts @@ -4,11 +4,17 @@ export const UserSettingsType = { export type UserSettingsType = (typeof UserSettingsType)[keyof typeof UserSettingsType]; +export interface UserSettingsWithIcon { + value: string; + icon?: string; +} + export interface UserSettingsItem { type: UserSettingsType; label: string; value: string; - items: string[]; + items: string[] | UserSettingsWithIcon[]; + favorite?: boolean; group: string; } diff --git a/src/views/UserSettingsView.vue b/src/views/UserSettingsView.vue index ed0896a57..b6f994a9c 100644 --- a/src/views/UserSettingsView.vue +++ b/src/views/UserSettingsView.vue @@ -1,10 +1,27 @@