forked from AkkomaGang/admin-fe
Implement types ['map', 'string'] and ['map', ['list', 'string']]
This commit is contained in:
parent
6577376642
commit
5ae214fbbe
4 changed files with 25 additions and 24 deletions
|
@ -93,7 +93,7 @@ export const parseTuples = (tuples, key) => {
|
|||
return [...acc, { [mascot.tuple[0]]: { ...mascot.tuple[1], id: `f${(~~(Math.random() * 1e8)).toString(16)}` }}]
|
||||
}, [])
|
||||
} else if (Array.isArray(item.tuple[1]) &&
|
||||
(item.tuple[0] === ':groups' || item.tuple[0] === ':replace' || item.tuple[0] === ':retries' || item.tuple[0] === ':headers' || item.tuple[0] === ':params' || item.tuple[0] === ':crontab')) {
|
||||
(item.tuple[0] === ':groups' || item.tuple[0] === ':replace' || item.tuple[0] === ':retries' || item.tuple[0] === ':headers' || item.tuple[0] === ':params' || item.tuple[0] === ':crontab' || item.tuple[0] === ':match_actor')) {
|
||||
if (item.tuple[0] === ':crontab') {
|
||||
accum[item.tuple[0]] = item.tuple[1].reduce((acc, group) => {
|
||||
return [...acc, { [group.tuple[1]]: { value: group.tuple[0], id: `f${(~~(Math.random() * 1e8)).toString(16)}` }}]
|
||||
|
@ -103,10 +103,6 @@ export const parseTuples = (tuples, key) => {
|
|||
return [...acc, { [group.tuple[0]]: { value: group.tuple[1], id: `f${(~~(Math.random() * 1e8)).toString(16)}` }}]
|
||||
}, [])
|
||||
}
|
||||
} else if (item.tuple[0] === ':match_actor') {
|
||||
accum[item.tuple[0]] = Object.keys(item.tuple[1]).reduce((acc, regex) => {
|
||||
return [...acc, { [regex]: { value: item.tuple[1][regex], id: `f${(~~(Math.random() * 1e8)).toString(16)}` }}]
|
||||
}, [])
|
||||
} else if (item.tuple[0] === ':icons') {
|
||||
accum[item.tuple[0]] = item.tuple[1].map(icon => {
|
||||
return Object.keys(icon).map(name => {
|
||||
|
@ -240,8 +236,10 @@ const wrapValues = (settings, currentState) => {
|
|||
if (
|
||||
type === 'keyword' ||
|
||||
type.includes('keyword') ||
|
||||
type.includes('tuple') && type.includes('list') ||
|
||||
setting === ':replace'
|
||||
(type.includes('tuple') && type.includes('list')) ||
|
||||
setting === ':replace' ||
|
||||
(type.includes('map') && type.includes('string')) ||
|
||||
type.includes('map') && type.findIndex(el => el.includes('list') && el.includes('string')) !== -1
|
||||
) {
|
||||
return { 'tuple': [setting, wrapValues(value, currentState)] }
|
||||
} else if (type === 'atom' && value.length > 0) {
|
||||
|
@ -254,15 +252,10 @@ const wrapValues = (settings, currentState) => {
|
|||
return { 'tuple': [value, setting] }
|
||||
} else if (type === 'map') {
|
||||
const mapValue = Object.keys(value).reduce((acc, key) => {
|
||||
acc[key] = setting === ':match_actor' ? value[key] : value[key][1]
|
||||
acc[key] = value[key][1]
|
||||
return acc
|
||||
}, {})
|
||||
const mapCurrentState = setting === ':match_actor'
|
||||
? currentState[setting].reduce((acc, element) => {
|
||||
return { ...acc, ...{ [Object.keys(element)[0]]: Object.values(element)[0].value }}
|
||||
}, {})
|
||||
: currentState[setting]
|
||||
return { 'tuple': [setting, { ...mapCurrentState, ...mapValue }] }
|
||||
return { 'tuple': [setting, { ...currentState[setting], ...mapValue }] }
|
||||
} else if (setting === ':ip') {
|
||||
const ip = value.split('.').map(s => parseInt(s, 10))
|
||||
return { 'tuple': [setting, { 'tuple': ip }] }
|
||||
|
|
|
@ -281,11 +281,14 @@ export default {
|
|||
},
|
||||
methods: {
|
||||
editableKeyword(key, type) {
|
||||
return type === 'map' ||
|
||||
(Array.isArray(type) && type.includes('keyword') && type.includes('integer')) ||
|
||||
(Array.isArray(type) && type.includes('keyword') && type.includes('string')) ||
|
||||
(Array.isArray(type) && type.includes('tuple') && type.includes('list')) ||
|
||||
(Array.isArray(type) && type.includes('keyword') && type.findIndex(el => el.includes('list') && el.includes('string')) !== -1)
|
||||
return Array.isArray(type) && (
|
||||
(type.includes('map') && type.includes('string')) ||
|
||||
(type.includes('map') && type.findIndex(el => el.includes('list') && el.includes('string')) !== -1) ||
|
||||
(type.includes('keyword') && type.includes('integer')) ||
|
||||
(type.includes('keyword') && type.includes('string')) ||
|
||||
(type.includes('tuple') && type.includes('list')) ||
|
||||
(type.includes('keyword') && type.findIndex(el => el.includes('list') && el.includes('string')) !== -1)
|
||||
)
|
||||
},
|
||||
getFormattedDescription(desc) {
|
||||
return marked(desc)
|
||||
|
|
|
@ -121,7 +121,8 @@ export default {
|
|||
compound({ type, key, children }) {
|
||||
return type === 'keyword' ||
|
||||
type === 'map' ||
|
||||
type.includes('keyword')
|
||||
type.includes('keyword') ||
|
||||
type.includes('map')
|
||||
},
|
||||
divideSetting(key) {
|
||||
return [':sslopts', ':tlsopts', ':adapter', ':poll_limits', ':queues', ':styling', ':invalidation', ':multi_factor_authentication'].includes(key)
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
</div>
|
||||
<el-button :size="isDesktop ? 'medium' : 'mini'" icon="el-icon-plus" circle @click="addRowToEditableKeyword"/>
|
||||
</div>
|
||||
<div v-else :data-search="setting.key || setting.group">
|
||||
<div v-else-if="editableKeywordWithSelect" :data-search="setting.key || setting.group">
|
||||
<div v-for="element in data" :key="getId(element)" class="setting-input">
|
||||
<el-input :value="getKey(element)" placeholder="key" class="name-input" @input="parseEditableKeyword($event, 'key', element)"/> :
|
||||
<el-select :value="getValue(element)" multiple filterable allow-create class="value-input" @change="parseEditableKeyword($event, 'value', element)"/>
|
||||
|
@ -70,12 +70,16 @@ export default {
|
|||
},
|
||||
computed: {
|
||||
editableKeywordWithInteger() {
|
||||
return Array.isArray(this.setting.type) && this.setting.type.includes('keyword') && this.setting.type.includes('integer')
|
||||
return this.setting.type.includes('keyword') && this.setting.type.includes('integer')
|
||||
},
|
||||
editableKeywordWithSelect() {
|
||||
return this.setting.type.includes('map') && this.setting.type.findIndex(el => el.includes('list') && el.includes('string')) !== -1
|
||||
},
|
||||
editableKeywordWithString() {
|
||||
return Array.isArray(this.setting.type) && this.setting.key !== ':crontab' && (
|
||||
return this.setting.key !== ':crontab' && (
|
||||
(this.setting.type.includes('keyword') && this.setting.type.includes('string')) ||
|
||||
(this.setting.type.includes('tuple') && this.setting.type.includes('list'))
|
||||
(this.setting.type.includes('tuple') && this.setting.type.includes('list')) ||
|
||||
(this.setting.type.includes('map') && this.setting.type.includes('string'))
|
||||
)
|
||||
},
|
||||
isDesktop() {
|
||||
|
|
Loading…
Reference in a new issue