From f5d33f16987ba4b80e2e0d45f158c40d9c122bde Mon Sep 17 00:00:00 2001 From: Angelina Filippova Date: Fri, 6 Mar 2020 21:30:11 +0300 Subject: [PATCH 1/4] 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; From 7aae515678cc7be7fc507f5a076e8f6aa547d89b Mon Sep 17 00:00:00 2001 From: Angelina Filippova Date: Fri, 6 Mar 2020 23:11:49 +0300 Subject: [PATCH 2/4] Add input processor for crontab inputs --- src/store/modules/normalizers.js | 4 +- .../inputComponents/CrontabInput.vue | 41 ++++++++++++++++--- 2 files changed, 38 insertions(+), 7 deletions(-) diff --git a/src/store/modules/normalizers.js b/src/store/modules/normalizers.js index 7e843710..ba4bea81 100644 --- a/src/store/modules/normalizers.js +++ b/src/store/modules/normalizers.js @@ -87,8 +87,8 @@ export const parseTuples = (tuples, key) => { }, []) } else if (item.tuple[0] === ':crontab') { accum[item.tuple[0]] = item.tuple[1].reduce((acc, group) => { - return [...acc, { [group.tuple[1]]: group.tuple[0] }] - }, []) + 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/inputComponents/CrontabInput.vue b/src/views/settings/components/inputComponents/CrontabInput.vue index a38340ad..9bf3f5ec 100644 --- a/src/views/settings/components/inputComponents/CrontabInput.vue +++ b/src/views/settings/components/inputComponents/CrontabInput.vue @@ -1,11 +1,14 @@ @@ -15,7 +18,7 @@ export default { name: 'CrontabInput', props: { data: { - type: Array, + type: Object, default: function() { return {} } @@ -34,6 +37,22 @@ export default { } }, computed: { + isDesktop() { + return this.$store.state.app.device === 'desktop' + }, + isMobile() { + return this.$store.state.app.device === 'mobile' + }, + isTablet() { + return this.$store.state.app.device === 'tablet' + }, + labelWidth() { + if (this.isMobile) { + return '120px' + } else { + return '380px' + } + }, workers() { return this.setting.suggestions.map(worker => worker[1]) } @@ -41,6 +60,18 @@ export default { methods: { getSuggestion(worker) { return this.setting.suggestions.find(suggestion => suggestion[1] === worker)[0] + }, + update(value, worker) { + const updatedValue = { + ...this.$store.state.settings.settings[this.settingGroup.group][this.settingGroup.key][this.setting.key], + [worker]: value + } + this.$store.dispatch('UpdateSettings', + { group: this.settingGroup.group, key: this.settingGroup.key, input: this.setting.key, value: updatedValue, type: 'reversed_tuple' } + ) + this.$store.dispatch('UpdateState', + { group: this.settingGroup.group, key: this.settingGroup.key, input: this.setting.key, value: updatedValue } + ) } } } From 1ad4cc277cd168975e294feed52f3b1b8534d328 Mon Sep 17 00:00:00 2001 From: Angelina Filippova Date: Sat, 7 Mar 2020 01:08:48 +0300 Subject: [PATCH 3/4] Fix styles for desktop, tablet and mobile versions --- .../components/inputComponents/CrontabInput.vue | 13 +++++-------- src/views/settings/styles/main.scss | 10 ++++++++++ 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/views/settings/components/inputComponents/CrontabInput.vue b/src/views/settings/components/inputComponents/CrontabInput.vue index 9bf3f5ec..1f6f3af1 100644 --- a/src/views/settings/components/inputComponents/CrontabInput.vue +++ b/src/views/settings/components/inputComponents/CrontabInput.vue @@ -1,16 +1,13 @@