diff --git a/bundles/org.openhab.ui.basic/gulpfile.js b/bundles/org.openhab.ui.basic/gulpfile.js index 19909d3833..e05cb18302 100644 --- a/bundles/org.openhab.ui.basic/gulpfile.js +++ b/bundles/org.openhab.ui.basic/gulpfile.js @@ -17,7 +17,9 @@ var paths = { FontLibs: [ './node_modules/material-design-icons/iconfont/MaterialIcons-Regular.woff*', - './node_modules/material-design-icons/iconfont/MaterialIcons-Regular.ttf' + './node_modules/material-design-icons/iconfont/MaterialIcons-Regular.ttf', + './node_modules/framework7-icons/fonts/Framework7Icons-Regular.woff*', + './node_modules/framework7-icons/fonts/Framework7Icons-Regular.ttf' ] }; diff --git a/bundles/org.openhab.ui.basic/package-lock.json b/bundles/org.openhab.ui.basic/package-lock.json index 1427da5adb..df8b0e878e 100644 --- a/bundles/org.openhab.ui.basic/package-lock.json +++ b/bundles/org.openhab.ui.basic/package-lock.json @@ -8,6 +8,7 @@ "name": "org.openhab.ui.basic", "version": "4.0.0", "dependencies": { + "framework7-icons": "^5.0.5", "gulp": "^4.0.2", "gulp-eslint": "^6.0.0", "gulp-sass": "^5.0.0", @@ -2143,6 +2144,14 @@ "node": ">=0.10.0" } }, + "node_modules/framework7-icons": { + "version": "5.0.5", + "resolved": "https://registry.npmjs.org/framework7-icons/-/framework7-icons-5.0.5.tgz", + "integrity": "sha512-bvHMLyujV9TFuudehd3ORZ/EvNp19Ir3ckVzYAOf3MkLymHba/9oHLsgopCh0x5UsrYZUpkrE+fd7ggj5y4wRw==", + "engines": { + "node": ">= 0.10.0" + } + }, "node_modules/fs-minipass": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/fs-minipass/-/fs-minipass-2.1.0.tgz", @@ -8314,6 +8323,11 @@ "map-cache": "^0.2.2" } }, + "framework7-icons": { + "version": "5.0.5", + "resolved": "https://registry.npmjs.org/framework7-icons/-/framework7-icons-5.0.5.tgz", + "integrity": "sha512-bvHMLyujV9TFuudehd3ORZ/EvNp19Ir3ckVzYAOf3MkLymHba/9oHLsgopCh0x5UsrYZUpkrE+fd7ggj5y4wRw==" + }, "fs-minipass": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/fs-minipass/-/fs-minipass-2.1.0.tgz", diff --git a/bundles/org.openhab.ui.basic/package.json b/bundles/org.openhab.ui.basic/package.json index 1014b4e55b..2778423b17 100644 --- a/bundles/org.openhab.ui.basic/package.json +++ b/bundles/org.openhab.ui.basic/package.json @@ -11,6 +11,7 @@ "gulp-sass": "^5.0.0", "gulp-uglify": "^3.0.2", "material-design-icons": "^3.0.1", + "framework7-icons": "^5.0.5", "node-sass": "^8.0.0" } } diff --git a/bundles/org.openhab.ui.basic/pom.xml b/bundles/org.openhab.ui.basic/pom.xml index e8db58a628..1a96221879 100644 --- a/bundles/org.openhab.ui.basic/pom.xml +++ b/bundles/org.openhab.ui.basic/pom.xml @@ -32,14 +32,13 @@ com.github.eirslett frontend-maven-plugin - 1.9.0 + 1.13.4 - v16.14.2 - 8.6.0 + v18.17.0 + 9.8.1 ${project.basedir}/npm_cache - ${project.basedir}/npm_tmp diff --git a/bundles/org.openhab.ui.basic/src/main/java/org/openhab/ui/basic/internal/WebAppConfig.java b/bundles/org.openhab.ui.basic/src/main/java/org/openhab/ui/basic/internal/WebAppConfig.java index 44d27b905c..8edc6fa05b 100644 --- a/bundles/org.openhab.ui.basic/src/main/java/org/openhab/ui/basic/internal/WebAppConfig.java +++ b/bundles/org.openhab.ui.basic/src/main/java/org/openhab/ui/basic/internal/WebAppConfig.java @@ -40,8 +40,14 @@ public class WebAppConfig { private static final String DEFAULT_INLINE_SVG = "false"; private static final String DEFAULT_WEB_AUDIO = "false"; + private static final String DEFAULT_CONFIG_NB_COLUMNS = "3-2"; + private static final int DEFAULT_NB_COLUMNS_DESKTOP = 3; + private static final int DEFAULT_NB_COLUMNS_TABLET = 2; + private String defaultSitemap = DEFAULT_SITEMAP; private String theme = DEFAULT_THEME; + private int nbColsDesktop = DEFAULT_NB_COLUMNS_DESKTOP; + private int nbColsTablet = DEFAULT_NB_COLUMNS_TABLET; private boolean iconify = Boolean.parseBoolean(DEFAULT_ICONIFY); private boolean inlineSvg = Boolean.parseBoolean(DEFAULT_INLINE_SVG); private boolean webAudio = Boolean.parseBoolean(DEFAULT_WEB_AUDIO); @@ -53,6 +59,7 @@ public class WebAppConfig { private static final String CONFIG_ENABLE_ICONS = "enableIcons"; private static final String CONFIG_CONDENSED_LAYOUT = "condensedLayout"; + private static final String CONFIG_NB_COLUMNS = "nbColumns"; private static final String CONFIG_CAPITALIZE = "capitalizeValues"; static { @@ -81,6 +88,9 @@ private void applyCssClasses(Map configProps) { cssClassList.add(entry.getValue()); } } + if (nbColsDesktop == 3) { + cssClassList.add("ui-large-window"); + } } public void applyConfig(Map configProps) { @@ -90,6 +100,22 @@ public void applyConfig(Map configProps) { if ("default".equals(theme)) { theme = DEFAULT_THEME; } + String nbColumns = (String) configProps.getOrDefault(CONFIG_NB_COLUMNS, DEFAULT_CONFIG_NB_COLUMNS); + if (nbColumns.length() == 3) { + try { + nbColsDesktop = Integer.parseInt(nbColumns.substring(0, 1)); + } catch (NumberFormatException e) { + nbColsDesktop = DEFAULT_NB_COLUMNS_DESKTOP; + } + try { + nbColsTablet = Integer.parseInt(nbColumns.substring(2, 3)); + } catch (NumberFormatException e) { + nbColsTablet = DEFAULT_NB_COLUMNS_TABLET; + } + } else { + nbColsDesktop = DEFAULT_NB_COLUMNS_DESKTOP; + nbColsTablet = DEFAULT_NB_COLUMNS_TABLET; + } iconify = "true".equalsIgnoreCase((String) configProps.getOrDefault("enableIconify", DEFAULT_ICONIFY)); inlineSvg = "true".equalsIgnoreCase((String) configProps.getOrDefault("inlineSvg", DEFAULT_INLINE_SVG)); webAudio = "true".equalsIgnoreCase((String) configProps.getOrDefault("webAudio", DEFAULT_WEB_AUDIO)); @@ -113,6 +139,14 @@ public String getCssClassList() { return result; } + public int getNbColsDesktop() { + return nbColsDesktop; + } + + public int getNbColsTablet() { + return nbColsTablet; + } + public boolean isIconifyEnabled() { return iconify; } diff --git a/bundles/org.openhab.ui.basic/src/main/java/org/openhab/ui/basic/internal/render/AbstractWidgetRenderer.java b/bundles/org.openhab.ui.basic/src/main/java/org/openhab/ui/basic/internal/render/AbstractWidgetRenderer.java index 4baaefbf58..a00b63055d 100644 --- a/bundles/org.openhab.ui.basic/src/main/java/org/openhab/ui/basic/internal/render/AbstractWidgetRenderer.java +++ b/bundles/org.openhab.ui.basic/src/main/java/org/openhab/ui/basic/internal/render/AbstractWidgetRenderer.java @@ -61,6 +61,7 @@ public abstract class AbstractWidgetRenderer implements WidgetRenderer { private static final String ICON_SOURCE_IF = "if"; private static final String ICON_SOURCE_ICONIFY = "iconify"; private static final String ICON_SOURCE_MATERIAL = "material"; + private static final String ICON_SOURCE_FRAMEWORK7 = "f7"; private static final String ICON_SET_OH_CLASSIC = "classic"; private static final String DEFAULT_ICON_SOURCE = ICON_SOURCE_OH; private static final String DEFAULT_ICON_SET = ICON_SET_OH_CLASSIC; @@ -124,6 +125,8 @@ protected String preprocessSnippet(String originalSnippet, Widget w) { protected String preprocessSnippet(String originalSnippet, Widget w, boolean ignoreStateForIcon) { String snippet = preprocessIcon(originalSnippet, w, ignoreStateForIcon); + snippet = snippet.replace("%cells%", String.valueOf(12 / config.getNbColsDesktop())); + snippet = snippet.replace("%cells_tablet%", String.valueOf(8 / config.getNbColsTablet())); snippet = snippet.replace("%widget_id%", itemUIRegistry.getWidgetId(w)); snippet = snippet.replace("%item%", w.getItem() != null ? w.getItem() : ""); // Optimization: avoid calling 3 times itemUIRegistry.getLabel(w) @@ -174,6 +177,9 @@ private String preprocessIcon(String originalSnippet, Widget w, boolean ignoreSt case ICON_SOURCE_MATERIAL: iconSnippet = getSnippet("icon_material"); break; + case ICON_SOURCE_FRAMEWORK7: + iconSnippet = getSnippet("icon_framework7"); + break; default: break; } diff --git a/bundles/org.openhab.ui.basic/src/main/resources/OH-INF/config/config.xml b/bundles/org.openhab.ui.basic/src/main/resources/OH-INF/config/config.xml index f045147678..c4e8f01391 100644 --- a/bundles/org.openhab.ui.basic/src/main/resources/OH-INF/config/config.xml +++ b/bundles/org.openhab.ui.basic/src/main/resources/OH-INF/config/config.xml @@ -59,6 +59,19 @@ false + + + The number of columns to consider to fill the grid in large screen width (desktop) and medium screen + width (tablet). + + + + + + + + 3-2 + Displays all widget states in uppercase. diff --git a/bundles/org.openhab.ui.basic/src/main/resources/OH-INF/i18n/basic.properties b/bundles/org.openhab.ui.basic/src/main/resources/OH-INF/i18n/basic.properties index 9973707d63..1e8422ee25 100644 --- a/bundles/org.openhab.ui.basic/src/main/resources/OH-INF/i18n/basic.properties +++ b/bundles/org.openhab.ui.basic/src/main/resources/OH-INF/i18n/basic.properties @@ -20,6 +20,13 @@ ui.config.basic.inlineSvg.label = Inline SVG ui.config.basic.inlineSvg.description = If enabled, any SVG icon provided by the openHAB icon server will automatically be converted to an inline SVG in the WEB page, allowing control of its color with the sitemap widget property "iconcolor" in the case where the SVG icon sets "currentColor" as the fill color. Note that this will work with custom SVG icons but not with all the packaged icons from the classic iconset since they are defined with a hard-coded color palette. This feature is disabled by default. ui.config.basic.inlineSvg.option.true = Enable ui.config.basic.inlineSvg.option.false = Disable +ui.config.basic.nbColumns.label = Number Columns +ui.config.basic.nbColumns.description = The number of columns to consider to fill the grid in large screen width (desktop) and medium screen width (tablet). +ui.config.basic.nbColumns.option.1-1 = 1 column on desktop and tablet +ui.config.basic.nbColumns.option.2-1 = 2 columns on desktop but only 1 on tablet +ui.config.basic.nbColumns.option.2-2 = 2 columns on desktop and tablet +ui.config.basic.nbColumns.option.3-1 = 3 columns on desktop but only 1 on tablet +ui.config.basic.nbColumns.option.3-2 = 3 columns on desktop but only 2 on tablet ui.config.basic.theme.label = Theme ui.config.basic.theme.description = Defines the UI theme. ui.config.basic.theme.option.bright = Bright diff --git a/bundles/org.openhab.ui.basic/src/main/resources/snippets/buttons.html b/bundles/org.openhab.ui.basic/src/main/resources/snippets/buttons.html index c3d563f151..8ad90b5fd9 100644 --- a/bundles/org.openhab.ui.basic/src/main/resources/snippets/buttons.html +++ b/bundles/org.openhab.ui.basic/src/main/resources/snippets/buttons.html @@ -1,4 +1,4 @@ -
+
%icon_snippet% diff --git a/bundles/org.openhab.ui.basic/src/main/resources/snippets/colorpicker.html b/bundles/org.openhab.ui.basic/src/main/resources/snippets/colorpicker.html index 6e53aece7e..d0af3637ff 100644 --- a/bundles/org.openhab.ui.basic/src/main/resources/snippets/colorpicker.html +++ b/bundles/org.openhab.ui.basic/src/main/resources/snippets/colorpicker.html @@ -1,4 +1,4 @@ -
+
%icon_snippet% diff --git a/bundles/org.openhab.ui.basic/src/main/resources/snippets/group.html b/bundles/org.openhab.ui.basic/src/main/resources/snippets/group.html index 75485cd201..64c190c1dd 100644 --- a/bundles/org.openhab.ui.basic/src/main/resources/snippets/group.html +++ b/bundles/org.openhab.ui.basic/src/main/resources/snippets/group.html @@ -1,4 +1,4 @@ -