From f5d33f16987ba4b80e2e0d45f158c40d9c122bde Mon Sep 17 00:00:00 2001 From: Angelina Filippova Date: Fri, 6 Mar 2020 21:30:11 +0300 Subject: [PATCH] Change inputs for configuring Crontab --- src/store/modules/normalizers.js | 10 ++-- src/views/settings/components/Inputs.vue | 17 +++--- .../inputComponents/CrontabInput.vue | 52 +++++++++++++++++++ .../inputComponents/EditableKeywordInput.vue | 20 ++----- .../components/inputComponents/index.js | 1 + src/views/settings/styles/main.scss | 10 ---- 6 files changed, 68 insertions(+), 42 deletions(-) create mode 100644 src/views/settings/components/inputComponents/CrontabInput.vue diff --git a/src/store/modules/normalizers.js b/src/store/modules/normalizers.js index 8be6220d..7e843710 100644 --- a/src/store/modules/normalizers.js +++ b/src/store/modules/normalizers.js @@ -81,14 +81,14 @@ export const parseTuples = (tuples, key) => { return [...acc, { [mascot.tuple[0]]: { ...mascot.tuple[1], id: `f${(~~(Math.random() * 1e8)).toString(16)}` }}] }, []) } else if ( - item.tuple[0] === ':groups' || - item.tuple[0] === ':replace' || - item.tuple[0] === ':retries' || - item.tuple[0] === ':crontab' - ) { + item.tuple[0] === ':groups' || item.tuple[0] === ':replace' || item.tuple[0] === ':retries') { accum[item.tuple[0]] = item.tuple[1].reduce((acc, group) => { return [...acc, { [group.tuple[0]]: { value: group.tuple[1], id: `f${(~~(Math.random() * 1e8)).toString(16)}` }}] }, []) + } else if (item.tuple[0] === ':crontab') { + accum[item.tuple[0]] = item.tuple[1].reduce((acc, group) => { + return [...acc, { [group.tuple[1]]: group.tuple[0] }] + }, []) } 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)}` }}] diff --git a/src/views/settings/components/Inputs.vue b/src/views/settings/components/Inputs.vue index d99871b2..300f09c7 100644 --- a/src/views/settings/components/Inputs.vue +++ b/src/views/settings/components/Inputs.vue @@ -84,11 +84,12 @@ - + - + + @@ -106,7 +107,7 @@ + + diff --git a/src/views/settings/components/inputComponents/EditableKeywordInput.vue b/src/views/settings/components/inputComponents/EditableKeywordInput.vue index a6ecde4d..fe5b9c7b 100644 --- a/src/views/settings/components/inputComponents/EditableKeywordInput.vue +++ b/src/views/settings/components/inputComponents/EditableKeywordInput.vue @@ -8,14 +8,6 @@ -
-
- : - - -
- -
: @@ -109,19 +101,13 @@ export default { this.$store.dispatch('UpdateState', { group, key, input, value }) }, wrapUpdatedSettings(value, input, type) { - if (type === 'map') { - return value.reduce((acc, element) => { + return type === 'map' + ? value.reduce((acc, element) => { return { ...acc, [Object.keys(element)[0]]: Object.values(element)[0].value } }, {}) - } else if (input === ':crontab') { - return value.reduce((acc, element) => { - return { ...acc, [Object.values(element)[0].value]: ['reversed_tuple', Object.keys(element)[0]] } - }, {}) - } else { - return value.reduce((acc, element) => { + : value.reduce((acc, element) => { return { ...acc, [Object.keys(element)[0]]: ['list', Object.values(element)[0].value] } }, {}) - } } } } diff --git a/src/views/settings/components/inputComponents/index.js b/src/views/settings/components/inputComponents/index.js index 389b304e..788d1f99 100644 --- a/src/views/settings/components/inputComponents/index.js +++ b/src/views/settings/components/inputComponents/index.js @@ -1,5 +1,6 @@ export { default as AutoLinkerInput } from './AutoLinkerInput' export { default as EditableKeywordInput } from './EditableKeywordInput' +export { default as CrontabInput } from './CrontabInput' export { default as IconsInput } from './IconsInput' export { default as MascotsInput } from './MascotsInput' export { default as MultipleSelect } from './MultipleSelect' diff --git a/src/views/settings/styles/main.scss b/src/views/settings/styles/main.scss index fd8e69d2..5b68e0c6 100644 --- a/src/views/settings/styles/main.scss +++ b/src/views/settings/styles/main.scss @@ -14,15 +14,6 @@ font-family: monospace; padding: 0 3px 0 3px; } - .crontab-name-input { - width: 30%; - margin-left: 8px; - margin-right: 10px - } - .crontab-value-input { - width: 70%; - margin-right: 8px - } .delete-setting-button { margin-left: 5px; } @@ -334,7 +325,6 @@ margin-right: 10px } - @media only screen and (min-width: 1824px) { .submit-button-container { max-width: 1637px;