From ab0fc5786c1c815a8b5e9cf3316c09d314ffc053 Mon Sep 17 00:00:00 2001 From: Angelina Filippova Date: Mon, 11 Nov 2019 22:47:54 +0900 Subject: [PATCH] Render JobQueue tab form descriprion data from API --- src/store/modules/normalizers.js | 9 ++- src/views/settings/components/Inputs.vue | 51 +++++++++++++++- src/views/settings/components/JobQueue.vue | 70 ++++++++-------------- 3 files changed, 79 insertions(+), 51 deletions(-) diff --git a/src/store/modules/normalizers.js b/src/store/modules/normalizers.js index 5913197c..ce08b328 100644 --- a/src/store/modules/normalizers.js +++ b/src/store/modules/normalizers.js @@ -105,15 +105,20 @@ export const parseTuples = (tuples, key) => { return tuples.reduce((accum, item) => { if (key === 'rate_limit') { accum[item.tuple[0]] = item.tuple[1] + } else if ((item.tuple[0] === ':sslopts' && item.tuple[1].length === 0) || // should be removed + (item.tuple[0] === ':tlsopts' && item.tuple[1].length === 0)) { + accum[item.tuple[0]] = {} } else if (Array.isArray(item.tuple[1]) && - (typeof item.tuple[1][0] === 'object' && !Array.isArray(item.tuple[1][0])) && item.tuple[1][0]['tuple']) { + (typeof item.tuple[1][0] === 'object' && !Array.isArray(item.tuple[1][0])) && item.tuple[1][0]['tuple']) { nonAtomsTuples.includes(item.tuple[0]) ? accum[item.tuple[0]] = parseNonAtomTuples(item.tuple[1]) : accum[item.tuple[0]] = parseTuples(item.tuple[1]) } else if (Array.isArray(item.tuple[1])) { accum[item.tuple[0]] = item.tuple[1] + } else if (item.tuple[0] === ':ip') { + accum[item.tuple[0]] = item.tuple[1].tuple.join('.') } else if (item.tuple[1] && typeof item.tuple[1] === 'object' && 'tuple' in item.tuple[1]) { - accum[item.tuple[0]] = item.tuple[1]['tuple'].join('.') + accum[item.tuple[0]] = { [item.tuple[1].tuple[0]]: item.tuple[1].tuple[1] } } else if (item.tuple[1] && typeof item.tuple[1] === 'object') { nonAtomsObjects.includes(item.tuple[0]) ? accum[item.tuple[0]] = parseNonAtomObject(item.tuple[1]) diff --git a/src/views/settings/components/Inputs.vue b/src/views/settings/components/Inputs.vue index 417f67c9..ae3a4b25 100644 --- a/src/views/settings/components/Inputs.vue +++ b/src/views/settings/components/Inputs.vue @@ -13,7 +13,6 @@ v-if="setting.type === 'integer'" :value="data[setting.key]" :placeholder="setting.suggestions[0].toString()" - :step="100" :min="0" size="large" class="top-margin" @@ -69,7 +68,7 @@ @input="updateSetting($event, settingsGroup.key, setting.key)"> -
+
: @@ -77,6 +76,39 @@
+
+
+ : + + +
+ +
+
+ + Disabled + Limit-based + Time-based + + + + + + + +

{{ setting.description }}

@@ -119,6 +151,11 @@ export default { set: function(value) { this.processNestedData([value], this.settingsGroup.key, this.setting.key, this.data[this.setting.key]) } + }, + prune() { + return this.data[this.setting.key] === ':disabled' + ? ':disabled' + : Object.keys(this.data[this.setting.key])[0] } }, methods: { @@ -137,7 +174,12 @@ export default { console.log(updatedValue) this.updateSetting(updatedValue, this.settingsGroup.key, this.setting.key) }, - editableKeyword(type) { + editableKeywordWithInteger(type) { + return Array.isArray(type) + ? type.includes('keyword') && type.includes('integer') + : false + }, + editableKeywordWithSelect(type) { return Array.isArray(type) ? type.includes('keyword') && type.findIndex(el => el.includes('list') && el.includes('string')) !== -1 : false @@ -159,6 +201,9 @@ export default { const updatedValue = { ...this.$store.state.settings.settings[tab][inputName], ...{ [childName]: value }} this.updateSetting(updatedValue, tab, inputName) }, + toggleAtomTuple(value, tab, input) { + console.log(value) + }, updateSetting(value, tab, input) { this.$store.dispatch('UpdateSettings', { tab, data: { [input]: value }}) } diff --git a/src/views/settings/components/JobQueue.vue b/src/views/settings/components/JobQueue.vue index f18cc853..f3791892 100644 --- a/src/views/settings/components/JobQueue.vue +++ b/src/views/settings/components/JobQueue.vue @@ -1,48 +1,10 @@