Parse ip values and clear updated settings after submit

This commit is contained in:
Angelina Filippova 2019-12-06 15:50:23 +09:00
parent 242f26fa67
commit c388d42d40
4 changed files with 15 additions and 9 deletions

View file

@ -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] }
}

View file

@ -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

View file

@ -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',

View file

@ -0,0 +1 @@
export { default as AutoLinkerInput } from './AutoLinkerInput'