100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps
Java asset-managementbuildingdashboarddataplatformdevice-managementedge-computingenergyenergy-managementenergy-monitorfleet-managementfleet-telematicsiotiot-applicationiot-platformmodbusmqttmqtt-brokerota-updaterules-enginesmartcity
build config updates and commit of smart building WIP
Rich Turner2813622b67e4
diff --git a/ui/app/smart-building/.gitignore b/ui/app/smart-building/.gitignorenew file mode 100644index 000000000..6ebead74e--- /dev/null+++ b/ui/app/smart-building/.gitignore@@ -0,0 +1,4 @@+node_modules+src/**/*.d.ts+src/**/*.js+src/**/*.js.mapdiff --git a/ui/app/smart-building/@types/@polymer/app-localize-behavior/app-localize-behavior.js.d.ts b/ui/app/smart-building/@types/@polymer/app-localize-behavior/app-localize-behavior.js.d.tsnew file mode 100644index 000000000..543488bca--- /dev/null+++ b/ui/app/smart-building/@types/@polymer/app-localize-behavior/app-localize-behavior.js.d.ts@@ -0,0 +1,52 @@+declare module "@polymer/app-localize-behavior/app-localize-behavior.js" {+ class AppLocalizeBehavior {++ /**+ * The language used for translation.+ */+ language: string | null | undefined;++ /**+ * The dictionary of localized messages, for each of the languages that+ * are going to be used. See http://formatjs.io/guides/message-syntax/ for+ * more information on the message syntax.+ *+ * For example, a valid dictionary would be:+ * this.resources = {+ * 'en': { 'greeting': 'Hello!' }, 'fr' : { 'greeting': 'Bonjour!' }+ * }+ */+ resources: object | null | undefined;++ /**+ * Optional dictionary of user defined formats, as explained here:+ * http://formatjs.io/guides/message-syntax/#custom-formats+ *+ * For example, a valid dictionary of formats would be:+ * this.formats = {+ * number: { USD: { style: 'currency', currency: 'USD' } }+ * }+ */+ formats: object | null | undefined;++ /**+ * If true, will use the provided key when+ * the translation does not exist for that key.+ */+ useKeyIfMissing: boolean | null | undefined;++ /**+ * Translates a string to the current `language`. Any parameters to the+ * string should be passed in order, as follows:+ * `localize(stringKey, param1Name, param1Value, param2Name, param2Value)`+ */+ readonly localize: Function | null | undefined;++ /**+ * If true, will bubble up the event to the parents+ */+ bubbleEvent: boolean | null | undefined;++ loadResources(path: any, language: any, merge: any): any;+ }+}diff --git a/ui/app/smart-building/babel.config.js b/ui/app/smart-building/babel.config.jsnew file mode 100644index 000000000..a12d41ed6--- /dev/null+++ b/ui/app/smart-building/babel.config.js@@ -0,0 +1,38 @@+module.exports = api => {++ api.cache(false);+ return {+ presets: [+ [+ "@babel/preset-env",+ {+ modules: false,+ exclude: ['transform-async-to-generator'],+ targets: [+ "last 2 versions",+ "IE 11"+ ]+ }+ ]+ ],+ plugins: [+ [+ "@babel/transform-runtime",+ {+ "corejs": false,+ "helpers": true,+ "regenerator": true,+ "useESModules": false+ }+ ],+ "@babel/syntax-dynamic-import",+ "@babel/syntax-object-rest-spread",+ [+ 'module:fast-async',+ {+ spec: true+ }+ ]+ ]+ };+};diff --git a/ui/app/smart-building/build.gradle b/ui/app/smart-building/build.gradlenew file mode 100644index 000000000..a8267a52d--- /dev/null+++ b/ui/app/smart-building/build.gradle@@ -0,0 +1,17 @@+//task build {+// dependsOn npmBuild+//}+//+//task installDist(type: Copy) {+// dependsOn build+// from(buildDir) {+// exclude "gwt", "build.gradle", "package.json", "yarn.lock", ".bowerrc"+// }+// into "${resolveProject(':deployment').projectDir}/manager/app/${projectDir.name}"+//}+//+//task clean() {+// doLast {+// delete "${resolveProject(':deployment').projectDir}/manager/app/${projectDir.name}"+// }+//}diff --git a/ui/app/smart-building/images/co2.png b/ui/app/smart-building/images/co2.pngnew file mode 100644index 000000000..20f89dd60Binary files /dev/null and b/ui/app/smart-building/images/co2.png differdiff --git a/ui/app/smart-building/images/eye.png b/ui/app/smart-building/images/eye.pngnew file mode 100644index 000000000..228c524f4Binary files /dev/null and b/ui/app/smart-building/images/eye.png differdiff --git a/ui/app/smart-building/images/eye_large.png b/ui/app/smart-building/images/eye_large.pngnew file mode 100644index 000000000..9269aacd6Binary files /dev/null and b/ui/app/smart-building/images/eye_large.png differdiff --git a/ui/app/smart-building/images/eye_large_active.png b/ui/app/smart-building/images/eye_large_active.pngnew file mode 100644index 000000000..e7596d0d5Binary files /dev/null and b/ui/app/smart-building/images/eye_large_active.png differdiff --git a/ui/app/smart-building/images/home_large_energy.png b/ui/app/smart-building/images/home_large_energy.pngnew file mode 100644index 000000000..1d522e134Binary files /dev/null and b/ui/app/smart-building/images/home_large_energy.png differdiff --git a/ui/app/smart-building/images/home_on.png b/ui/app/smart-building/images/home_on.pngnew file mode 100644index 000000000..955131fcdBinary files /dev/null and b/ui/app/smart-building/images/home_on.png differdiff --git a/ui/app/smart-building/images/humidity.png b/ui/app/smart-building/images/humidity.pngnew file mode 100644index 000000000..f0304e259Binary files /dev/null and b/ui/app/smart-building/images/humidity.png differdiff --git a/ui/app/smart-building/images/star.png b/ui/app/smart-building/images/star.pngnew file mode 100644index 000000000..374592cd5Binary files /dev/null and b/ui/app/smart-building/images/star.png differdiff --git a/ui/app/smart-building/images/temperature.png b/ui/app/smart-building/images/temperature.pngnew file mode 100644index 000000000..7abb2b09aBinary files /dev/null and b/ui/app/smart-building/images/temperature.png differdiff --git a/ui/app/smart-building/images/ventilation.png b/ui/app/smart-building/images/ventilation.pngnew file mode 100644index 000000000..68f4b4539Binary files /dev/null and b/ui/app/smart-building/images/ventilation.png differdiff --git a/ui/app/smart-building/index.html b/ui/app/smart-building/index.htmlnew file mode 100644index 000000000..d1e329731--- /dev/null+++ b/ui/app/smart-building/index.html@@ -0,0 +1,97 @@+<!doctype html>+<html lang="en">+<head>+ <meta charset="utf-8">+ <meta name="viewport" content="width=device-width, minimum-scale=1, initial-scale=1, user-scalable=yes">++ <title>OpenRemote Smart Building Demo</title>++ <link rel="icon" href="images/favicon.ico">++ <!-- See https://goo.gl/OOhYW5 -->+ <!--<link rel="manifest" href="manifest.json">-->++ <!-- See https://goo.gl/qRE0vM -->+ <meta name="theme-color" content="#3f51b5">++ <!-- Add to homescreen for Chrome on Android. Fallback for manifest.json -->+ <meta name="mobile-web-app-capable" content="yes">+ <meta name="application-name" content="Smart Building Demo">++ <!-- Add to homescreen for Safari on iOS -->+ <meta name="apple-mobile-web-app-capable" content="yes">+ <meta name="apple-mobile-web-app-status-bar-style" content="default">+ <meta name="apple-mobile-web-app-title" content="Smart Building Demo">++ <!-- Homescreen icons -->+ <link rel="apple-touch-icon" href="images/manifest/icon-48x48.png">+ <link rel="apple-touch-icon" sizes="72x72" href="images/manifest/icon-72x72.png">+ <link rel="apple-touch-icon" sizes="96x96" href="images/manifest/icon-96x96.png">+ <link rel="apple-touch-icon" sizes="144x144" href="images/manifest/icon-144x144.png">+ <link rel="apple-touch-icon" sizes="192x192" href="images/manifest/icon-192x192.png">++ <!-- Tile icon for Windows 8 (144x144 + tile color) -->+ <meta name="msapplication-TileImage" content="images/manifest/icon-144x144.png">+ <meta name="msapplication-TileColor" content="#3f51b5">+ <meta name="msapplication-tap-highlight" content="no">++ <!-- Default twitter cards -->+ <meta name="twitter:card" content="summary">+ <meta name="twitter:site" content="@username">+ <meta property="og:type" content="website">+ <meta property="og:site_name" content="my-app">+ <meta property="og:image" content="images/manifest/icon-144x144.png" />++ <!-- Performance tip: hint to the browser to start the handshake for the fonts site -->+ <link rel="preconnect" href="https://fonts.gstatic.com/" crossorigin>+ <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">+ <!--+ Feature detect Custom Elements support. If the browser DOES support Custom+ Elements then we need to load the custom-elements-es5-adapter because+ our project code has been transpiled from ES2015 to ES5 and native Custom+ Elements expect elements will be registered as classes.+ -->+ <script>if (!window.customElements) { document.write('<!--'); }</script>+ <script src="./modules/@webcomponents/webcomponentsjs/custom-elements-es5-adapter.js"></script>+ <!--! DO NOT REMOVE THIS COMMENT, WE NEED ITS CLOSING MARKER -->++ <style type="text/css">+ html, body {+ margin: 0;+ min-height: 100vh;+ overflow: hidden;+ }++ body {+ background: var(--theme-mediumgrey);+ font-family: 'Open Sans', 'Roboto', Helvetica, Arial, Lucida, sans-serif;+ }+ </style>+</head>+<body>+<smart-building-app>+ <!-- You can override the logo+ <img slot="logo" height="20" src="mylogo.png"/>+ -->+</smart-building-app>++<!--+Use the webcomponents-loader script which will feature detect which Web+Components features are missing and lazy load the appropriate polyfills.+When we hear the 'WebComponentsReady' event from the polyfill bundle we can+insert our 'bundle.js'.+-->+<script>+ (function () {+ document.addEventListener('WebComponentsReady', function componentsReady() {+ document.removeEventListener('WebComponentsReady', componentsReady, false);+ var script = document.createElement('script');+ script.src = '<%= htmlWebpackPlugin.files.js[0] %>';+ var refScript = document.getElementsByTagName('script')[0];+ refScript.parentNode.insertBefore(script, refScript);+ }, false);+ })();+</script>+<script src="modules/@webcomponents/webcomponentsjs/webcomponents-loader.js"></script>+</body>+</html>diff --git a/ui/app/smart-building/locales/nl.json b/ui/app/smart-building/locales/nl.jsonnew file mode 100644index 000000000..e61ce142d--- /dev/null+++ b/ui/app/smart-building/locales/nl.json@@ -0,0 +1,43 @@+{+ "weeklySchedule": "Weekschema",+ "Energy": "Start",+ "Security": "Veilig",+ "Climate": "Klimaat",+ "receivedMessages": "Ontvangen berichten",+ "sendMessage": "Melding maken",+ "All Smart": "Alles Slim",+ "At Home": "Thuis",+ "Away": "Weg",+ "Evening": "Avond",+ "Night": "Nacht",+ "Switch A": "Afwas",+ "Switch B": "Was",+ "Switch C": "Droger",+ "Now on": "Nu aan",+ "On at": "Aan om",+ "Ready at": "Klaar om",+ "tomorrow": "morgen",+ "Mode": "Mode",+ "Begin/end of cycle": "Begin/end of cycle",+ "Green": "Groen",+ "Usage today": "Huidig verbruik",+ "Zone & Battery": "Zon & Batterij",+ "Grid": "Netwerk",+ "Alarm": "Alarm",+ "Presence detected": "Activiteit",+ "No presence": "Geen Activiteit",+ "Kitchen": "Keuken",+ "Living Room": "Woonkamer",+ "Hallway": "Gang",+ "Bedroom": "Slaapkamer",+ "Bedroom 2": "Slaapkamer 2",+ "Bathroom": "Badkamer",+ "Ventilation": "Ventilatie",+ "Ventilation Mode": "Ventilation Mode",+ "Auto": "Auto",+ "Low": "Laag",+ "Medium": "Medium",+ "High": "Hoog",+ "Vacation": "Vakantie",+ "On vacation until": "Op vakantie tot"+}diff --git a/ui/app/smart-building/package.json b/ui/app/smart-building/package.jsonnew file mode 100644index 000000000..606b7e4eb--- /dev/null+++ b/ui/app/smart-building/package.json@@ -0,0 +1,65 @@+{+ "description": "Smart Building Demo",+ "homepage": "http://openremote.io/",+ "name": "smart-building",+ "version": "3.0.0",+ "author": "OpenRemote Inc. <[email protected]>",+ "license": "AGPL-3.0-or-later",+ "scripts": {+ "clean": "npx shx rm -rf dist",+ "build": "node ../../model-build.js && npx tsc -b && npx cross-env NODE_ENV=production webpack",+ "serve": "node ../../model-build.js && npx tsc -b && npx webpack-dev-server",+ "watch": "node ../../model-build.js && npx tsc -b -w",+ "test": "echo \"Error: no test specified\" && exit 1"+ },+ "dependencies": {+ "@fortawesome/fontawesome-svg-core": "^1.2.12",+ "@fortawesome/free-regular-svg-icons": "^5.6.3",+ "@fortawesome/free-solid-svg-icons": "^5.6.3",+ "@openremote/core": "^1.0.0",+ "@openremote/or-header": "^1.0.0",+ "@openremote/or-bottom-navigation": "^1.0.0",+ "@polymer/app-layout": "^3.0.0",+ "@polymer/iron-demo-helpers": "^3.0.0-pre.19",+ "@polymer/polymer": "^3.0.0",+ "@webcomponents/html-imports": "^1.2.0",+ "@webcomponents/webcomponentsjs": "^2.0.0",+ "bootstrap": "4.1.3",+ "i18next": "^15.0.9",+ "i18next-xhr-backend": "^2.0.1",+ "lit-element": "^2.0.1",+ "mapbox-gl": "^0.50.0",+ "moment": "^2.22.2",+ "moment-es6": "^1.0.0",+ "pwa-helpers": "^0.9.0",+ "redux": "^4.0.0",+ "redux-thunk": "^2.3.0",+ "reselect": "^3.0.1"+ },+ "devDependencies": {+ "@babel/core": "^7.2.2",+ "@babel/plugin-syntax-dynamic-import": "^7.2.0",+ "@babel/plugin-syntax-object-rest-spread": "^7.2.0",+ "@babel/plugin-transform-regenerator": "^7.0.0",+ "@babel/plugin-transform-runtime": "^7.2.0",+ "@babel/preset-env": "^7.2.0",+ "@babel/runtime": "^7.2.0",+ "babel-loader": "^8.0.4",+ "copy-webpack-plugin": "^4.6.0",+ "cross-env": "^5.2.0",+ "css-loader": "^2.0.0",+ "fast-async": "^6.3.8",+ "file-loader": "^2.0.0",+ "html-webpack-plugin": "^3.2.0",+ "raw-loader": "^0.5.1",+ "shx": "^0.3.2",+ "source-map-loader": "^0.2.4",+ "style-loader": "^0.23.1",+ "tslint": "^5.11.0",+ "typescript": "^3.2.2",+ "url-loader": "^1.1.2",+ "webpack": "^4.24.0",+ "webpack-cli": "^3.1.2",+ "webpack-dev-server": "^3.1.10"+ }+}diff --git a/ui/app/smart-building/src/actions/app.ts b/ui/app/smart-building/src/actions/app.tsnew file mode 100644index 000000000..7d4e6258d--- /dev/null+++ b/ui/app/smart-building/src/actions/app.ts@@ -0,0 +1,75 @@+import { Action, ActionCreator } from "redux";+import { ThunkAction } from "redux-thunk";+import { RootState } from "../store";+export const UPDATE_PAGE = "UPDATE_PAGE";+export const UPDATE_OFFLINE = "UPDATE_OFFLINE";+export const UPDATE_DRAWER_STATE = "UPDATE_DRAWER_STATE";+export const OPEN_SNACKBAR = "OPEN_SNACKBAR";+export const CLOSE_SNACKBAR = "CLOSE_SNACKBAR";++export interface AppActionUpdatePage extends Action<"UPDATE_PAGE"> {page: string};+export interface AppActionUpdateOffline extends Action<"UPDATE_OFFLINE"> {offline: boolean};+export interface AppActionUpdateDrawerState extends Action<"UPDATE_DRAWER_STATE"> {opened: boolean};+export interface AppActionOpenSnackbar extends Action<"OPEN_SNACKBAR"> {};+export interface AppActionCloseSnackbar extends Action<"CLOSE_SNACKBAR"> {};+export type AppAction = AppActionUpdatePage | AppActionUpdateOffline | AppActionUpdateDrawerState | AppActionOpenSnackbar | AppActionCloseSnackbar;++type ThunkResult = ThunkAction<void, RootState, undefined, AppAction>;++export const navigate: ActionCreator<ThunkResult> = (path: string) => (dispatch) => {+ // Extract the page name from path.+ const page = path === "/" ? "view1" : path.slice(1);++ // Any other info you might want to extract from the path (like page type),+ // you can do here+ dispatch(loadPage(page));++ // Close the drawer - in case the *path* change came from a link in the drawer.+ dispatch(updateDrawerState(false));+};++const loadPage: ActionCreator<ThunkResult> = (page: string) => (dispatch) => {+ switch(page) {+ default:+ page = "scenes";+ import("../components/page-scenes");+ }++ dispatch(updatePage(page));+};++const updatePage: ActionCreator<AppActionUpdatePage> = (page: string) => {+ return {+ type: UPDATE_PAGE,+ page+ };+};++let snackbarTimer: number;++export const showSnackbar: ActionCreator<ThunkResult> = () => (dispatch) => {+ dispatch({+ type: OPEN_SNACKBAR+ });+ window.clearTimeout(snackbarTimer);+ snackbarTimer = window.setTimeout(() =>+ dispatch({ type: CLOSE_SNACKBAR }), 3000);+};++export const updateOffline: ActionCreator<ThunkResult> = (offline: boolean) => (dispatch, getState) => {+ // Show the snackbar only if offline status changes.+ if (offline !== getState().app!.offline) {+ dispatch(showSnackbar());+ }+ dispatch({+ type: UPDATE_OFFLINE,+ offline+ });+};++export const updateDrawerState: ActionCreator<AppActionUpdateDrawerState> = (opened: boolean) => {+ return {+ type: UPDATE_DRAWER_STATE,+ opened+ };+};diff --git a/ui/app/smart-building/src/components/page-element.ts b/ui/app/smart-building/src/components/page-element.tsnew file mode 100644index 000000000..0c7c028fb--- /dev/null+++ b/ui/app/smart-building/src/components/page-element.ts@@ -0,0 +1,11 @@+import {LitElement, property} from "lit-element";++export abstract class PageElement extends LitElement {+ @property({type: Boolean})+ active = false;++ // Only render this page if it's actually visible.+ protected shouldUpdate() {+ return this.active;+ }+}diff --git a/ui/app/smart-building/src/components/page-scenes.ts b/ui/app/smart-building/src/components/page-scenes.tsnew file mode 100644index 000000000..cbffa0cc7--- /dev/null+++ b/ui/app/smart-building/src/components/page-scenes.ts@@ -0,0 +1,12 @@+import {css, html, LitElement, property, PropertyValues} from "lit-element";+import {connect} from "pwa-helpers/connect-mixin";+import {store} from "../store";+import {PageElement} from "./page-element";+import { localize } from "../localize-mixin";+import { i18next } from "../i18next";++class PageScenes extends connect(store)(localize(i18next)(PageElement)) {++}++window.customElements.define("page-scenes", PageScenes);diff --git a/ui/app/smart-building/src/components/smart-building-app.ts b/ui/app/smart-building/src/components/smart-building-app.tsnew file mode 100644index 000000000..c383b8158--- /dev/null+++ b/ui/app/smart-building/src/components/smart-building-app.ts@@ -0,0 +1,270 @@+import {css, html, LitElement, property, PropertyValues} from "lit-element";+import {connect} from "pwa-helpers/connect-mixin";+import {setPassiveTouchGestures} from "@polymer/polymer/lib/utils/settings";+import {installMediaQueryWatcher} from "pwa-helpers/media-query";+import {installRouter} from "pwa-helpers/router";+import {updateMetadata} from "pwa-helpers/metadata";+import {icon} from "@fortawesome/fontawesome-svg-core";+import {faMap, faSignOutAlt, faTable} from "@fortawesome/free-solid-svg-icons";+import "@openremote/or-header";+import "@openremote/or-bottom-navigation";++import {OrHeaderStyle} from "@openremote/or-header/dist/or-header-style";+import { localize } from "../localize-mixin";+import { i18next } from "../i18next";++// This element is connected to the Redux store.+import {store} from "../store";++// These are the actions needed by this element.+import {navigate, updateDrawerState, updateOffline} from "../actions/app";+++// Declare MANAGER_URL+declare var MANAGER_URL: string;++class SmartBuildingApp extends connect(store)(localize(i18next)(LitElement)) {++ @property({type: String})+ appTitle = '';++ @property({type: String})+ _page = "scenes";++ constructor() {+ super();+ // To force all event listeners for gestures to be passive.+ // See https://www.polymer-project.org/3.0/docs/devguide/settings#setting-passive-touch-gestures+ setPassiveTouchGestures(true);+ }++ protected invalidate() {+ this.requestUpdate();+ }++ protected render() {+ return html`+ <or-header>+ <div slot="desktop-left">+ <a ?selected="${this._page === 'scenes'}" href="#scenes">${i18next.t('scenes')}</a>+ <a ?selected="${this._page === 'messages'}" href="#scenes">${i18next.t('receivedMessages')}</a>+ <a ?selected="${this._page === 'contact'}" href="#scenes">${i18next.t('sendMessage')}</a>+ <a ?selected="${this._page === 'languages'}" href="#scenes">${i18next.t('selectLanguage')}</a>+ </div>+ <div slot="desktop-right">+ <a @click="${this.logout}">${icon(faSignOutAlt).node.item(0)} ${i18next.t('logOut')}</a>+ </div>+ <div slot="mobile-top">+ <a ?selected="${this._page === 'scenes'}" href="#scenes">${i18next.t('scenes')}</a>+ <a ?selected="${this._page === 'messages'}" href="#scenes">${i18next.t('receivedMessages')}</a>+ <a ?selected="${this._page === 'contact'}" href="#scenes">${i18next.t('sendMessage')}</a>+ <a ?selected="${this._page === 'languages'}" href="#scenes">${i18next.t('selectLanguage')}</a>+ <a @click="${this.logout}">${icon(faSignOutAlt).node.item(0)} ${i18next.t('logOut')}</a>+ </div>+ </or-header>++ <!-- Main content -->+ <main role="main" class="main-content">+ <page-scenes class="page" ?active="${this._page === "scenes"}"></page-scenes>+ <page-messages class="page" ?active="${this._page === "messages"}"></page-messages>+ <page-contact class="page" ?active="${this._page === "contact"}"></page-contact>+ <page-languages class="page" ?active="${this._page === "languages"}"></page-languages>+ </main>++ <or-bottom-navigation>+ <or-navigation-item icon="tv" text="TV"></or-navigation-item>+ <span class="mdc-bottom-navigation__list-item">+ <span class="material-icons mdc-bottom-navigation__list-item__icon">tv</span>+ <span class="mdc-bottom-navigation__list-item__text">TV</span>+ </span>+ <span class="mdc-bottom-navigation__list-item">+ <span class="material-icons mdc-bottom-navigation__list-item__icon">music_note</span>+ <span class="mdc-bottom-navigation__list-item__text">Music</span>+ </span>+ <span class="mdc-bottom-navigation__list-item">+ <span class="material-icons mdc-bottom-navigation__list-item__icon">book</span>+ <span class="mdc-bottom-navigation__list-item__text">Books</span>+ </span>+ <span class="mdc-bottom-navigation__list-item">+ <span class="material-icons mdc-bottom-navigation__list-item__icon">+ <svg style="width:24px;height:24px" viewBox="0 0 24 24">+ <path fill="#000000" d="M20,11H4V8H20M20,15H13V13H20M20,19H13V17H20M11,19H4V13H11M20.33,4.67L18.67,3L17,4.67L15.33,3L13.67,4.67L12,3L10.33,4.67L8.67,3L7,4.67L5.33,3L3.67,4.67L2,3V19A2,2 0 0,0 4,21H20A2,2 0 0,0 22,19V3L20.33,4.67Z" />+ </svg>+ </span>+ <span class="mdc-bottom-navigation__list-item__text">Newstand</span>+ </span>+ </or-bottom-navigation>+ `;+ }++ protected firstUpdated() {+ installRouter((location) => store.dispatch(navigate(decodeURIComponent(location.pathname))));+ installMediaQueryWatcher(`(min-width: 460px)`,+ () => store.dispatch(updateDrawerState(false)));+ }++ protected updated(changedProps: PropertyValues) {+ if (changedProps.has("_page")) {+ const pageTitle = this.appTitle + " - " + this._page;+ updateMetadata({+ title: pageTitle,+ description: pageTitle+ // This object also takes an image property, that points to an img src.+ });+ }+ }++ protected logout() {++ }++ static styles = css`+ :host {+ --app-header-background-color: #bcbcbc;+ }+ `;+ //static styles = OrHeaderStyle;+ // static styles = css`+ // :host {+ // display: block;+ //+ // --app-drawer-width: 256px;+ //+ // --app-primary-color: #E91E63;+ // --app-secondary-color: #293237;+ // --app-dark-text-color: var(--app-secondary-color);+ // --app-light-text-color: white;+ // --app-section-even-color: #f7f7f7;+ // --app-section-odd-color: white;+ //+ // --app-header-background-color: white;+ // --app-header-text-color: var(--app-dark-text-color);+ // --app-header-selected-color: var(--app-primary-color);+ //+ // --app-drawer-background-color: var(--app-secondary-color);+ // --app-drawer-text-color: var(--app-light-text-color);+ // --app-drawer-selected-color: #78909C;+ // }+ //+ // app-header {+ // position: fixed;+ // top: 0;+ // left: 0;+ // width: 100%;+ // text-align: center;+ // background-color: var(--app-header-background-color);+ // color: var(--app-header-text-color);+ // border-bottom: 1px solid #eee;+ // }+ //+ // .toolbar-top {+ // background-color: var(--app-header-background-color);+ // }+ //+ // [main-title] {+ // font-family: "Pacifico";+ // text-transform: lowercase;+ // font-size: 30px;+ // /* In the narrow layout, the toolbar is offset by the width of the+ // drawer button, and the text looks not centered. Add a padding to+ // match that button */+ // padding-right: 44px;+ // }+ //+ // .toolbar-list {+ // display: none;+ // }+ //+ // .toolbar-list > a {+ // display: inline-block;+ // color: var(--app-header-text-color);+ // text-decoration: none;+ // line-height: 30px;+ // padding: 4px 24px;+ // }+ //+ // .toolbar-list > a[selected] {+ // color: var(--app-header-selected-color);+ // border-bottom: 4px solid var(--app-header-selected-color);+ // }+ //+ // .menu-btn {+ // background: none;+ // border: none;+ // fill: var(--app-header-text-color);+ // cursor: pointer;+ // height: 44px;+ // width: 44px;+ // }+ //+ // .drawer-list {+ // box-sizing: border-box;+ // width: 100%;+ // height: 100%;+ // padding: 24px;+ // background: var(--app-drawer-background-color);+ // position: relative;+ // }+ //+ // .drawer-list > a {+ // display: block;+ // text-decoration: none;+ // color: var(--app-drawer-text-color);+ // line-height: 40px;+ // padding: 0 24px;+ // }+ //+ // .drawer-list > a[selected] {+ // color: var(--app-drawer-selected-color);+ // }+ //+ // /* Workaround for IE11 displaying <main> as inline */+ // main {+ // display: block;+ // }+ //+ // .main-content {+ // padding-top: 64px;+ // min-height: 100vh;+ // }+ //+ // .page {+ // display: none;+ // }+ //+ // .page[active] {+ // display: block;+ // }+ //+ // footer {+ // padding: 24px;+ // background: var(--app-drawer-background-color);+ // color: var(--app-drawer-text-color);+ // text-align: center;+ // }+ //+ // /* Wide layout: when the viewport width is bigger than 460px, layout+ // changes to a wide layout */+ // @media (min-width: 460px) {+ // .toolbar-list {+ // display: block;+ // }+ //+ // .menu-btn {+ // display: none;+ // }+ //+ // .main-content {+ // padding-top: 107px;+ // }+ //+ // /* The drawer button isn't shown in the wide layout, so we don't+ // need to offset the title */+ // [main-title] {+ // padding-right: 0px;+ // }+ // }+ // `;+}++window.customElements.define("smart-building-app", SmartBuildingApp);diff --git a/ui/app/smart-building/src/reducers/app.ts b/ui/app/smart-building/src/reducers/app.tsnew file mode 100644index 000000000..5fad50f4d--- /dev/null+++ b/ui/app/smart-building/src/reducers/app.ts@@ -0,0 +1,57 @@+import { Reducer } from "redux";+import {+ UPDATE_PAGE,+ UPDATE_OFFLINE,+ OPEN_SNACKBAR,+ CLOSE_SNACKBAR,+ UPDATE_DRAWER_STATE+} from "../actions/app";+import { RootAction } from "../store";++export interface AppState {+ page: string;+ offline: boolean;+ drawerOpened: boolean;+ snackbarOpened: boolean;+}++const INITIAL_STATE: AppState = {+ page: "",+ offline: false,+ drawerOpened: false,+ snackbarOpened: false,+};++const app: Reducer<AppState, RootAction> = (state = INITIAL_STATE, action) => {+ switch (action.type) {+ case UPDATE_PAGE:+ return {+ ...state,+ page: action.page+ };+ case UPDATE_OFFLINE:+ return {+ ...state,+ offline: action.offline+ };+ case UPDATE_DRAWER_STATE:+ return {+ ...state,+ drawerOpened: action.opened+ };+ case OPEN_SNACKBAR:+ return {+ ...state,+ snackbarOpened: true+ };+ case CLOSE_SNACKBAR:+ return {+ ...state,+ snackbarOpened: false+ };+ default:+ return state;+ }+};++export default app;diff --git a/ui/app/smart-building/src/store.ts b/ui/app/smart-building/src/store.tsnew file mode 100644index 000000000..a4cb0f6c2--- /dev/null+++ b/ui/app/smart-building/src/store.ts@@ -0,0 +1,52 @@+declare global {+ interface Window {+ process?: Object;+ __REDUX_DEVTOOLS_EXTENSION_COMPOSE__?: typeof compose;+ }+}++import {+ createStore,+ compose,+ applyMiddleware,+ combineReducers,+ Reducer,+ StoreEnhancer+} from "redux";++import thunk, { ThunkMiddleware } from "redux-thunk";+import { lazyReducerEnhancer } from "pwa-helpers/lazy-reducer-enhancer.js";++import app, { AppState } from "./reducers/app";+import { AppAction } from "./actions/app";++// Overall state extends static states and partials lazy states.+export interface RootState {+ app?: AppState;+}++export type RootAction = AppAction;++// Sets up a Chrome extension for time travel debugging.+// See https://github.com/zalmoxisus/redux-devtools-extension for more information.+const devCompose: <Ext0, Ext1, StateExt0, StateExt1>(+ f1: StoreEnhancer<Ext0, StateExt0>, f2: StoreEnhancer<Ext1, StateExt1>+) => StoreEnhancer<Ext0 & Ext1, StateExt0 & StateExt1> =+ window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;++// Initializes the Redux store with a lazyReducerEnhancer (so that you can+// lazily add reducers after the store has been created) and redux-thunk (so+// that you can dispatch async actions). See the "Redux and state management"+// section of the wiki for more details:+// https://github.com/Polymer/pwa-starter-kit/wiki/4.-Redux-and-state-management+export const store = createStore(+ state => state as Reducer<RootState, RootAction>,+ devCompose(+ lazyReducerEnhancer(combineReducers),+ applyMiddleware(thunk as ThunkMiddleware<RootState, RootAction>))+);++// Initially loaded reducers.+store.addReducers({+ app+});diff --git a/ui/app/smart-building/tsconfig.json b/ui/app/smart-building/tsconfig.jsonnew file mode 100644index 000000000..283d08f57--- /dev/null+++ b/ui/app/smart-building/tsconfig.json@@ -0,0 +1,16 @@+{+ "extends": "../../tsconfig",+ "compilerOptions": {+ "strict": false+ },+ "include": [+ "./src",+ "./@types"+ ],+ "references": [+ { "path": "../../component/core" },+ { "path": "../../component/or-bottom-navigation" },+ { "path": "../../component/rest" },+ { "path": "../../component/or-header" }+ ]+}diff --git a/ui/app/smart-building/webpack.config.js b/ui/app/smart-building/webpack.config.jsnew file mode 100644index 000000000..c451d2279--- /dev/null+++ b/ui/app/smart-building/webpack.config.js@@ -0,0 +1,91 @@+var production = process.env.NODE_ENV === "production";+var webpack = require("webpack");+var path = require("path");+var managerUrl = production ? undefined : "http://localhost:8080";+var CopyWebpackPlugin = require("copy-webpack-plugin");+var HtmlWebpackPlugin = require("html-webpack-plugin");++module.exports = {+ mode: 'development',+ entry: {+ 'bundle': './src/components/smart-building-app.js'+ },+ output: {+ path: __dirname + "/dist",+ filename: "[name].[hash].js",+ publicPath: ""+ },+ devtool: 'inline-source-map',+ devServer: {+ port: 9000,+ contentBase: './dist',+ publicPath: "/" + __dirname.split(path.sep).slice(-1)[0] + "/"+ },+ plugins: [+ // Conditional compilation variables+ new webpack.DefinePlugin({+ PRODUCTION: JSON.stringify(production),+ MANAGER_URL: JSON.stringify(managerUrl),+ "process.env": {+ BABEL_ENV: JSON.stringify(process.env.NODE_ENV)+ }+ }),+ new HtmlWebpackPlugin({+ chunksSortMode: 'none',+ inject: false,+ template: 'index.html'+ }),+ new CopyWebpackPlugin([+ {+ from: path.dirname(require.resolve("@webcomponents/webcomponentsjs")),+ to: "modules/@webcomponents/webcomponentsjs",+ ignore: "!*.js"+ },+ {+ from: "./images",+ to: "images"+ },+ {+ from: "./locales",+ to: "locales"+ }+ ])+ ],+ module: {+ rules: [+ {+ test: /\.js$/,+ use: ["source-map-loader"],+ enforce: "pre",+ exclude: [+ /node_modules/+ ]+ },+ {+ test: /\.js$/,+ include: function(modulePath) {+ return /(@webcomponents[\/|\\]shadycss|lit-css|styled-lit-element|lit-element|lit-html|@polymer|@lit|pwa-helpers)/.test(modulePath) || !/node_modules/.test(modulePath);+ },+ use: [+ {+ loader: 'babel-loader'+ }+ ]+ },+ {+ test: /\.css$/,+ use: [+ { loader: "css-loader" }+ ]+ },+ {+ test: /\.(png|jpg|gif|svg|eot|ttf|woff|woff2)$/,+ loader: 'url-loader',+ options: {+ outputPath: "images/",+ limit: 10000,+ },+ }+ ]+ }+};diff --git a/ui/component/model/build.gradle b/ui/component/model/build.gradleindex ca4dcc8f1..d1a9a4387 100644--- a/ui/component/model/build.gradle+++ b/ui/component/model/build.gradle@@ -65,7 +65,7 @@ clean {}}-build.dependsOn generateTypeScript+build.dependsOn generateTypeScript, npmBuildtask installDist() {dependsOn builddiff --git a/ui/component/model/package.json b/ui/component/model/package.jsonindex 12423c0eb..5275adbc4 100644--- a/ui/component/model/package.json+++ b/ui/component/model/package.json@@ -5,7 +5,7 @@"description": "OpenRemote 3.x Model Types","types": "src/index.ts","scripts": {- "build": "exit 0",+ "build": "npx tsc -b","test": "echo \"No tests\" && exit 0"},"author": "OpenRemote",diff --git a/ui/component/or-rules-editor/build.gradle b/ui/component/or-rules-editor/build.gradleindex fd1724054..d0ab403f0 100644--- a/ui/component/or-rules-editor/build.gradle+++ b/ui/component/or-rules-editor/build.gradle@@ -6,7 +6,7 @@ task clean() {}}-npmBuild.dependsOn resolveTask(":ui:component:or-select:build"), resolveTask(":ui:component:or-input:build")+npmBuild.dependsOn resolveTask(":ui:component:or-translate:build"), resolveTask(":ui:component:or-select:build"), resolveTask(":ui:component:or-input:build")task build() {dependsOn npmBuild