From dab86ba567db5fe5d120f720c659743e76de6a5f Mon Sep 17 00:00:00 2001 From: Gautier Taravella Date: Mon, 8 Mar 2021 21:01:44 +0100 Subject: [PATCH] Addition of a plan layout for floorplan-like page, in addition to responsive and grid layouts. Supports system and user-defined widgets. Signed-off-by: Gautier Taravella --- bundles/org.openhab.ui/web/package-lock.json | 5 + bundles/org.openhab.ui/web/package.json | 1 + .../definitions/widgets/layout/index.js | 28 ++ .../src/components/widgets/layout/index.js | 2 + .../widgets/layout/oh-canvas-item.vue | 232 ++++++++++++++++ .../widgets/layout/oh-canvas-layout.vue | 260 ++++++++++++++++++ .../widgets/layout/oh-layout-page.vue | 14 +- bundles/org.openhab.ui/web/src/js/app.js | 5 + .../settings/pages/layout/layout-edit.vue | 48 +++- .../settings/pages/pagedesigner-mixin.js | 23 +- 10 files changed, 595 insertions(+), 23 deletions(-) create mode 100644 bundles/org.openhab.ui/web/src/components/widgets/layout/oh-canvas-item.vue create mode 100644 bundles/org.openhab.ui/web/src/components/widgets/layout/oh-canvas-layout.vue diff --git a/bundles/org.openhab.ui/web/package-lock.json b/bundles/org.openhab.ui/web/package-lock.json index 049c879d0b..1bbd021a58 100644 --- a/bundles/org.openhab.ui/web/package-lock.json +++ b/bundles/org.openhab.ui/web/package-lock.json @@ -18392,6 +18392,11 @@ "diff-match-patch": "^1.0.0" } }, + "vue-draggable-resizable": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/vue-draggable-resizable/-/vue-draggable-resizable-2.3.0.tgz", + "integrity": "sha512-77CLRj1TPwB30pwsjOf3pkd1UzYanCdKXbqhILJ0Oo5QQl50lvBfyQCXxMFzwWwTc3sbBbQH3FfWSV+BkoSElA==" + }, "vue-echarts": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/vue-echarts/-/vue-echarts-4.1.0.tgz", diff --git a/bundles/org.openhab.ui/web/package.json b/bundles/org.openhab.ui/web/package.json index 99cca105d3..480d47c32b 100644 --- a/bundles/org.openhab.ui/web/package.json +++ b/bundles/org.openhab.ui/web/package.json @@ -88,6 +88,7 @@ "vue": "^2.6.12", "vue-async-computed": "^3.9.0", "vue-codemirror": "^4.0.6", + "vue-draggable-resizable": "^2.3.0", "vue-echarts": "^4.1.0", "vue-fragment": "^1.5.1", "vue-fullscreen": "^2.2.0", diff --git a/bundles/org.openhab.ui/web/src/assets/definitions/widgets/layout/index.js b/bundles/org.openhab.ui/web/src/assets/definitions/widgets/layout/index.js index 992c16d3d0..794939911d 100644 --- a/bundles/org.openhab.ui/web/src/assets/definitions/widgets/layout/index.js +++ b/bundles/org.openhab.ui/web/src/assets/definitions/widgets/layout/index.js @@ -67,3 +67,31 @@ export function OhGridLayoutDefinition () { pb('showFullscreenIcon', 'Show Fullscreen Icon', 'Show a fullscreen icon on the top right corner (default false)') ]) } + +export function OhCanvasItemDefinition () { + return new WidgetDefinition('oh-canvas-item', 'Canvas Item', 'Specific attributes to display widgets on a canvas.') + .paramGroup(pg('appearance', 'Layout Settings'), [ + pb('notStyled', 'Preserve classic style', 'Preserve classic appearance of widgets as in standard layout pages.'), + pb('noCanvasShadow', 'No elements shadow', 'Do not shadow inner elements of standard widgets') + .v((value, configuration, configDescription, parameters) => { return configuration.notStyled !== true }) + ]) +} + +export function OhCanvasLayoutDefinition () { + return new WidgetDefinition('oh-canvas-layout', 'Canvas Layout', 'Position widgets on a canvas layout with arbitrary position and size down to pixel resolution') + .paramGroup(pg('layout', 'Layout Settings'), [ + pn('grid', 'Grid size', 'Grid size in pixels used to snap content (default 5)') + ]) + .paramGroup(pg('screenSettings', 'Screen Settings'), [ + pn('screenWidth', 'Screen Width', 'Screen width in pixels (default 1280)'), + pn('screenHeight', 'Screen Height', 'Screen width in pixels (default 720)'), + pb('scale', 'Scaling', 'Scale content to screen width (can lead to unexpected styling issues) (default false)'), + pt('imageUrl', 'Image URL', 'The URL of the image to display as background').c('url'), + pt('imageSrcSet', 'Image Source Set', 'The src-set attribute of background image element to take into account mulitple device resolutions. For example: "/static/floorplans/floor-0.jpg, /static/floorplans/floor-0@2x.jpg 2x"') + ]) + .paramGroup(pg('shadow', 'Canvas items shadow'), [ + pt('boxShadow', 'Box shadow', 'Shadow applied to box elements (box-shadow CSS syntax).').a(), + pt('textShadow', 'Text shadow', 'Shadow applied to text elements or font icons (text-shadow CSS syntax)').a(), + pt('filterShadow', 'Fitler Shadow', 'Shadow applied to raster or SVG image elements (filter: drop-shadow() CSS syntax)').a() + ]) +} diff --git a/bundles/org.openhab.ui/web/src/components/widgets/layout/index.js b/bundles/org.openhab.ui/web/src/components/widgets/layout/index.js index 2bb41c8df0..36579a55f9 100644 --- a/bundles/org.openhab.ui/web/src/components/widgets/layout/index.js +++ b/bundles/org.openhab.ui/web/src/components/widgets/layout/index.js @@ -6,3 +6,5 @@ export { default as OhGridCol } from './oh-grid-col.vue' export { default as OhGridCells } from './oh-grid-cells.vue' export { default as OhMasonry } from './oh-masonry.vue' export { default as OhGridLayout } from './oh-grid-layout.vue' +export { default as OhCanvasLayout } from './oh-canvas-layout.vue' +export { default as OhCanvasItem } from './oh-canvas-item.vue' diff --git a/bundles/org.openhab.ui/web/src/components/widgets/layout/oh-canvas-item.vue b/bundles/org.openhab.ui/web/src/components/widgets/layout/oh-canvas-item.vue new file mode 100644 index 0000000000..528773ab5f --- /dev/null +++ b/bundles/org.openhab.ui/web/src/components/widgets/layout/oh-canvas-item.vue @@ -0,0 +1,232 @@ + + + + + diff --git a/bundles/org.openhab.ui/web/src/components/widgets/layout/oh-canvas-layout.vue b/bundles/org.openhab.ui/web/src/components/widgets/layout/oh-canvas-layout.vue new file mode 100644 index 0000000000..e86c6aefd9 --- /dev/null +++ b/bundles/org.openhab.ui/web/src/components/widgets/layout/oh-canvas-layout.vue @@ -0,0 +1,260 @@ + + + + + diff --git a/bundles/org.openhab.ui/web/src/components/widgets/layout/oh-layout-page.vue b/bundles/org.openhab.ui/web/src/components/widgets/layout/oh-layout-page.vue index b6e8e52072..a7d13eb959 100644 --- a/bundles/org.openhab.ui/web/src/components/widgets/layout/oh-layout-page.vue +++ b/bundles/org.openhab.ui/web/src/components/widgets/layout/oh-layout-page.vue @@ -1,6 +1,6 @@