Skip to content
Snippets Groups Projects
Commit c388d42d authored by Angelina Filippova's avatar Angelina Filippova
Browse files

Parse ip values and clear updated settings after submit

parent 242f26fa
No related branches found
No related tags found
No related merge requests found
......@@ -27,9 +27,7 @@ export const parseTuples = (tuples, key) => {
? accum[item.tuple[0]] = parseNonAtomObject(item.tuple[1])
: accum[item.tuple[0]] = parseObject(item.tuple[1])
} else {
key === 'mrf_user_allowlist'
? accum[item.tuple[0]] = item.tuple[1]
: accum[item.tuple[0]] = item.tuple[1]
accum[item.tuple[0]] = item.tuple[1]
}
return accum
}, {})
......@@ -79,10 +77,13 @@ export const wrapUpdatedSettings = (group, settings) => {
const wrapValues = settings => {
return Object.keys(settings).map(setting => {
const [type, value] = settings[setting]
if (type === 'keyword') {
if (type === 'keyword' || type.includes('keyword')) {
return { 'tuple': [setting, wrapValues(value)] }
} else if (type === 'atom') {
return { 'tuple': [setting, `:${value}`] }
} else if (setting === ':ip') {
const ip = value.split('.').map(s => parseInt(s, 10))
return { 'tuple': [setting, { 'tuple': ip }] }
} else {
return { 'tuple': [setting, value] }
}
......
......@@ -24,6 +24,9 @@ const settings = {
loading: true
},
mutations: {
CLEAR_UPDATED_SETTINGS: (state) => {
state.updatedSettings = {}
},
REWRITE_CONFIG: (state, { tab, data }) => {
state.settings[tab] = data
},
......@@ -77,6 +80,7 @@ const settings = {
}, [])
const response = await updateSettings(configs, getters.authHost, getters.token)
commit('SET_SETTINGS', response.data.configs)
commit('CLEAR_UPDATED_SETTINGS')
},
UpdateSettings({ commit }, { group, key, input, value, type }) {
key
......
......@@ -56,10 +56,10 @@
lang="elixir"
theme="chrome"/>
<el-input
v-if="setting.type === 'tuple'"
:placeholder="setting.key === ':ip' ? 'xxx.xxx.xxx.xx' : setting.suggestions[0]"
:value="data[setting.key]"
@input="updateSetting($event, settingGroup.group, settingGroup.key, setting.key)"/>
v-if="setting.key === ':ip'"
:value="inputValue"
placeholder="xxx.xxx.xxx.xx"
@input="update($event, settingGroup.group, settingGroup.key, settingParent, setting.key, setting.type, nested)"/>
<el-input
v-if="setting.type === 'atom'"
:value="inputValue"
......@@ -187,7 +187,7 @@
import AceEditor from 'vue2-ace-editor'
import 'brace/mode/elixir'
import 'default-passive-events'
import AutoLinkerInput from './inputComponents/AutoLinkerInput'
import { AutoLinkerInput } from './inputComponents'
export default {
name: 'Inputs',
......
export { default as AutoLinkerInput } from './AutoLinkerInput'
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment