diff options
| author | Kana <[email protected]> | 2021-06-19 02:03:57 +0900 |
|---|---|---|
| committer | GitHub <[email protected]> | 2021-06-19 02:03:57 +0900 |
| commit | 065c5221a0250838f1d1f9bb7a7922ff4f55e038 (patch) | |
| tree | 8a69a81f00e6bff2752f4f7c59dcbbf21f893b20 /src/site/store/admin.js | |
| parent | chore: docs update (diff) | |
| parent | fix: potentially fix the blocked extensions array splitting (diff) | |
| download | host.fuwn.me-065c5221a0250838f1d1f9bb7a7922ff4f55e038.tar.xz host.fuwn.me-065c5221a0250838f1d1f9bb7a7922ff4f55e038.zip | |
Merge pull request #278 from Zephyrrus/Zephyrrus-feature/database_based_settings
Zephyrrus feature/database based settings
Diffstat (limited to 'src/site/store/admin.js')
| -rw-r--r-- | src/site/store/admin.js | 37 |
1 files changed, 31 insertions, 6 deletions
diff --git a/src/site/store/admin.js b/src/site/store/admin.js index cac1cca..9b1d591 100644 --- a/src/site/store/admin.js +++ b/src/site/store/admin.js @@ -12,23 +12,38 @@ export const state = () => ({ }, file: {}, settings: {}, - statistics: {} + statistics: {}, + settingsSchema: { + type: null, + keys: {} + } }); export const actions = { async fetchSettings({ commit }) { - const response = await this.$axios.$get('service/config'); + const response = await this.$axios.$get('service/config/all'); commit('setSettings', response); return response; }, + async saveSettings({ commit }, settings) { + const response = await this.$axios.$post('service/config', { settings }); + + return response; + }, async fetchStatistics({ commit }, category) { const url = category ? `service/statistics/${category}` : 'service/statistics'; const response = await this.$axios.$get(url); - commit('setStatistics', { statistics: response.statistics, category: category }); + commit('setStatistics', { statistics: response.statistics, category }); return response; }, + async getSettingsSchema({ commit }) { + // XXX: Maybe move to the config store? + const response = await this.$axios.$get('service/config/schema'); + + commit('setSettingsSchema', response); + }, async fetchUsers({ commit }) { const response = await this.$axios.$get('admin/users'); commit('setUsers', response); @@ -95,9 +110,6 @@ export const actions = { }; export const mutations = { - setSettings(state, { config }) { - state.settings = config; - }, setStatistics(state, { statistics, category }) { if (category) { state.statistics[category] = statistics[category]; @@ -105,6 +117,12 @@ export const mutations = { state.statistics = statistics; } }, + setSettings(state, { config }) { + state.settings = config; + }, + setSettingsSchema(state, { schema }) { + state.settingsSchema = schema; + }, setUsers(state, { users }) { state.users = users; }, @@ -135,5 +153,12 @@ export const mutations = { state.user.isAdmin = isAdmin; } } + }, + populateSchemaWithValues({ settings, settingsSchema }) { + for (const [key, value] of Object.entries(settings)) { + if (settingsSchema.keys?.[key] !== undefined) { + settingsSchema.keys[key].value = value; + } + } } }; |