From be7c9da40ce40a52b480e2ccfaadabd9202237c4 Mon Sep 17 00:00:00 2001 From: Mark Herwege Date: Sat, 25 Nov 2023 22:17:18 +0100 Subject: [PATCH 1/4] sitemap period config Signed-off-by: Mark Herwege --- .../pagedesigner/sitemap/widget-details.vue | 23 +------------------ .../__tests__/sitemap-edit_jest.spec.js | 12 ++++++++-- .../settings/pages/sitemap/sitemap-edit.vue | 2 +- 3 files changed, 12 insertions(+), 25 deletions(-) diff --git a/bundles/org.openhab.ui/web/src/components/pagedesigner/sitemap/widget-details.vue b/bundles/org.openhab.ui/web/src/components/pagedesigner/sitemap/widget-details.vue index 9bae258b01..4a17b03b3c 100644 --- a/bundles/org.openhab.ui/web/src/components/pagedesigner/sitemap/widget-details.vue +++ b/bundles/org.openhab.ui/web/src/components/pagedesigner/sitemap/widget-details.vue @@ -23,13 +23,7 @@ - - - + @@ -97,21 +91,6 @@ export default { Input: ['inputHint'], Default: ['height'] }, - periodDefs: [ - { key: 'h', value: 'Hour' }, - { key: '4h', value: '4 Hours' }, - { key: '8h', value: '8 Hours' }, - { key: '12h', value: '12 Hours' }, - { key: 'D', value: 'Day' }, - { key: '2D', value: '2 Days' }, - { key: '3D', value: '3 Days' }, - { key: 'W', value: 'Week' }, - { key: '2W', value: '2 Weeks' }, - { key: 'M', value: 'Month' }, - { key: '2M', value: '2 Months' }, - { key: '4M', value: '4 Months' }, - { key: 'Y', value: 'Year' } - ], inputHintDefs: [ { key: 'text', value: 'Text' }, { key: 'number', value: 'Number' }, diff --git a/bundles/org.openhab.ui/web/src/pages/settings/pages/sitemap/__tests__/sitemap-edit_jest.spec.js b/bundles/org.openhab.ui/web/src/pages/settings/pages/sitemap/__tests__/sitemap-edit_jest.spec.js index 9fcf0eee99..543ac6fcd9 100644 --- a/bundles/org.openhab.ui/web/src/pages/settings/pages/sitemap/__tests__/sitemap-edit_jest.spec.js +++ b/bundles/org.openhab.ui/web/src/pages/settings/pages/sitemap/__tests__/sitemap-edit_jest.spec.js @@ -187,10 +187,10 @@ describe('SitemapEdit', () => { lastDialogConfig = null wrapper.vm.selectWidget([wrapper.vm.sitemap.slots.widgets[0], wrapper.vm.sitemap]) await wrapper.vm.$nextTick() - localVue.set(wrapper.vm.selectedWidget.config, 'period', '5h') + localVue.set(wrapper.vm.selectedWidget.config, 'period', '5d') wrapper.vm.validateWidgets() expect(lastDialogConfig).toBeTruthy() - expect(lastDialogConfig.content).toMatch(/Chart widget Chart Test, invalid period configured: 5h/) + expect(lastDialogConfig.content).toMatch(/Chart widget Chart Test, invalid period configured: 5d/) // configure a period for the Chart and check that there are no validation errors anymore lastDialogConfig = null @@ -199,6 +199,14 @@ describe('SitemapEdit', () => { localVue.set(wrapper.vm.selectedWidget.config, 'period', '4h') wrapper.vm.validateWidgets() expect(lastDialogConfig).toBeFalsy() + + // configure an ISO-8601 period for the Chart and check that there are no validation errors + lastDialogConfig = null + wrapper.vm.selectWidget([wrapper.vm.sitemap.slots.widgets[0], wrapper.vm.sitemap]) + await wrapper.vm.$nextTick() + localVue.set(wrapper.vm.selectedWidget.config, 'period', 'P10M2W1DT12H30M') + wrapper.vm.validateWidgets() + expect(lastDialogConfig).toBeFalsy() }) it('validates step is positive', async () => { diff --git a/bundles/org.openhab.ui/web/src/pages/settings/pages/sitemap/sitemap-edit.vue b/bundles/org.openhab.ui/web/src/pages/settings/pages/sitemap/sitemap-edit.vue index bd691eda49..efeaca18d5 100644 --- a/bundles/org.openhab.ui/web/src/pages/settings/pages/sitemap/sitemap-edit.vue +++ b/bundles/org.openhab.ui/web/src/pages/settings/pages/sitemap/sitemap-edit.vue @@ -427,7 +427,7 @@ export default { } }) widgetList.filter(widget => widget.component === 'Chart').forEach(widget => { - if (!(widget.config && widget.config.period && ['h', '4h', '8h', '12h', 'D', '2D', '3D', 'W', '2W', 'M', '2M', '4M', 'Y'].includes(widget.config.period))) { + if (!(widget.config && widget.config.period && /^(P(\d*Y)?(\d*M)?(\d*W)?(\d*D)?(T(\d*H)?(\d*M)?(\d*S)?)?)|(\d*[YMWDh])$/.test(widget.config.period))) { let label = widget.config && widget.config.label ? widget.config.label : 'without label' validationWarnings.push(widget.component + ' widget ' + label + ', invalid period configured: ' + widget.config.period) } From 5075f44cb037634c9721460cb17467df26ea2edb Mon Sep 17 00:00:00 2001 From: Mark Herwege Date: Sat, 25 Nov 2023 22:45:58 +0100 Subject: [PATCH 2/4] fixes Signed-off-by: Mark Herwege --- .../web/src/components/pagedesigner/sitemap/widget-details.vue | 2 +- .../web/src/pages/settings/pages/sitemap/sitemap-edit.vue | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bundles/org.openhab.ui/web/src/components/pagedesigner/sitemap/widget-details.vue b/bundles/org.openhab.ui/web/src/components/pagedesigner/sitemap/widget-details.vue index 4a17b03b3c..c1f09f69e9 100644 --- a/bundles/org.openhab.ui/web/src/components/pagedesigner/sitemap/widget-details.vue +++ b/bundles/org.openhab.ui/web/src/components/pagedesigner/sitemap/widget-details.vue @@ -23,7 +23,7 @@ - + diff --git a/bundles/org.openhab.ui/web/src/pages/settings/pages/sitemap/sitemap-edit.vue b/bundles/org.openhab.ui/web/src/pages/settings/pages/sitemap/sitemap-edit.vue index efeaca18d5..4c22765e80 100644 --- a/bundles/org.openhab.ui/web/src/pages/settings/pages/sitemap/sitemap-edit.vue +++ b/bundles/org.openhab.ui/web/src/pages/settings/pages/sitemap/sitemap-edit.vue @@ -427,7 +427,7 @@ export default { } }) widgetList.filter(widget => widget.component === 'Chart').forEach(widget => { - if (!(widget.config && widget.config.period && /^(P(\d*Y)?(\d*M)?(\d*W)?(\d*D)?(T(\d*H)?(\d*M)?(\d*S)?)?)|(\d*[YMWDh])$/.test(widget.config.period))) { + if (!(widget.config && widget.config.period && /^P(\d+Y)?(\d+M)?(\d+W)?(\d+D)?(T(\d+H)?(\d+M)?(\d+S)?)?$|^\d*[YMWDh]$/.test(widget.config.period))) { let label = widget.config && widget.config.label ? widget.config.label : 'without label' validationWarnings.push(widget.component + ' widget ' + label + ', invalid period configured: ' + widget.config.period) } From c2363f453302951ddd8969f3700eb48bb99a1b6b Mon Sep 17 00:00:00 2001 From: Mark Herwege Date: Sun, 26 Nov 2023 17:39:22 +0100 Subject: [PATCH 3/4] validation Signed-off-by: Mark Herwege --- .../src/components/pagedesigner/sitemap/widget-details.vue | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bundles/org.openhab.ui/web/src/components/pagedesigner/sitemap/widget-details.vue b/bundles/org.openhab.ui/web/src/components/pagedesigner/sitemap/widget-details.vue index c1f09f69e9..829462130a 100644 --- a/bundles/org.openhab.ui/web/src/components/pagedesigner/sitemap/widget-details.vue +++ b/bundles/org.openhab.ui/web/src/components/pagedesigner/sitemap/widget-details.vue @@ -23,7 +23,9 @@ - + From 3056db524a0036ef43d96fd36afa60fa62ad0640 Mon Sep 17 00:00:00 2001 From: Florian Hotze Date: Sun, 26 Nov 2023 23:24:06 +0100 Subject: [PATCH 4/4] Minor improvement Signed-off-by: Florian Hotze --- .../web/src/components/pagedesigner/sitemap/widget-details.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bundles/org.openhab.ui/web/src/components/pagedesigner/sitemap/widget-details.vue b/bundles/org.openhab.ui/web/src/components/pagedesigner/sitemap/widget-details.vue index 829462130a..c6d870144a 100644 --- a/bundles/org.openhab.ui/web/src/components/pagedesigner/sitemap/widget-details.vue +++ b/bundles/org.openhab.ui/web/src/components/pagedesigner/sitemap/widget-details.vue @@ -24,7 +24,7 @@