From a9453448b576181202a14aa16ac5e8ae2b2803da Mon Sep 17 00:00:00 2001 From: Angelina Filippova Date: Mon, 11 Nov 2019 01:10:04 +0900 Subject: [PATCH] Configure HTTP settings with data from API description --- src/store/modules/settings.js | 13 +- src/views/settings/components/Http.vue | 174 ++++++------------------- 2 files changed, 48 insertions(+), 139 deletions(-) diff --git a/src/store/modules/settings.js b/src/store/modules/settings.js index 3120082a..abcb28dc 100644 --- a/src/store/modules/settings.js +++ b/src/store/modules/settings.js @@ -4,8 +4,7 @@ import { filterIgnored, parseTuples, valueHasTuples, wrapConfig } from './normal const settings = { state: { description: [], - settings: { - }, + settings: {}, ignoredIfNotEnabled: ['enabled', 'handler', 'password_authenticator', 'port', 'priv_dir'], loading: true }, @@ -20,9 +19,13 @@ const settings = { state.loading = status }, SET_SETTINGS: (state, data) => { - const newSettings = data.reduce((acc, { key, value }) => { - const parsedValue = valueHasTuples(key, value) ? { value } : parseTuples(value, key) - acc[key] = { ...acc[key], ...parsedValue } + const newSettings = data.reduce((acc, { group, key, value }) => { + if (group === 'cors_plug') { + acc[':cors_plug'] = { ...acc[':cors_plug'], [key]: value } + } else { + const parsedValue = valueHasTuples(key, value) ? { value } : parseTuples(value, key) + acc[key] = { ...acc[key], ...parsedValue } + } return acc }, state.settings) state.settings = newSettings diff --git a/src/views/settings/components/Http.vue b/src/views/settings/components/Http.vue index 08e8da7c..057c1948 100644 --- a/src/views/settings/components/Http.vue +++ b/src/views/settings/components/Http.vue @@ -1,126 +1,18 @@