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
Add mobile webapp and mobile pages, radial modal
Robin Dekkersa2e5f1e7b9fe
diff --git a/ui/app/mobile/.babelrc b/ui/app/mobile/.babelrcnew file mode 100644index 000000000..8aa924d7c--- /dev/null+++ b/ui/app/mobile/.babelrc@@ -0,0 +1,3 @@+{+ "presets": ["@babel/preset-env"]+}\ No newline at end of filediff --git a/ui/app/mobile/.gitignore b/ui/app/mobile/.gitignorenew file mode 100644index 000000000..632fd9253--- /dev/null+++ b/ui/app/mobile/.gitignore@@ -0,0 +1,11 @@+build/+node_modules/+test/integration/screenshots-current/+_site/+.DS_Store+src/**/*.d.ts+src/**/*.js+src/**/*.js.map+openremote/**/*.d.ts+openremote/**/*.js+openremote/**/*.js.map\ No newline at end of filediff --git a/ui/app/mobile/babel.config.js b/ui/app/mobile/babel.config.jsnew file mode 100644index 000000000..a12d41ed6--- /dev/null+++ b/ui/app/mobile/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/mobile/build.gradle b/ui/app/mobile/build.gradlenew file mode 100644index 000000000..010a45540--- /dev/null+++ b/ui/app/mobile/build.gradle@@ -0,0 +1,7 @@+buildDir = "dist"++task installDist(type: Copy) {+ dependsOn npmClean, npmBuild+ from project.buildDir+ into "${project(':deployment').buildDir}/manager/app/${projectDir.name}"+}\ No newline at end of filediff --git a/ui/app/mobile/images/Icon-128.png b/ui/app/mobile/images/Icon-128.pngnew file mode 100755index 000000000..ff533dc13Binary files /dev/null and b/ui/app/mobile/images/Icon-128.png differdiff --git a/ui/app/mobile/images/Icon-144.png b/ui/app/mobile/images/Icon-144.pngnew file mode 100755index 000000000..268fcb42fBinary files /dev/null and b/ui/app/mobile/images/Icon-144.png differdiff --git a/ui/app/mobile/images/Icon-196.png b/ui/app/mobile/images/Icon-196.pngnew file mode 100755index 000000000..97a0a93c0Binary files /dev/null and b/ui/app/mobile/images/Icon-196.png differdiff --git a/ui/app/mobile/images/Icon-256.png b/ui/app/mobile/images/Icon-256.pngnew file mode 100755index 000000000..869c157e2Binary files /dev/null and b/ui/app/mobile/images/Icon-256.png differdiff --git a/ui/app/mobile/images/Icon-48.png b/ui/app/mobile/images/Icon-48.pngnew file mode 100755index 000000000..f73176b9bBinary files /dev/null and b/ui/app/mobile/images/Icon-48.png differdiff --git a/ui/app/mobile/images/Icon-512.png b/ui/app/mobile/images/Icon-512.pngnew file mode 100755index 000000000..a64a845a6Binary files /dev/null and b/ui/app/mobile/images/Icon-512.png differdiff --git a/ui/app/mobile/images/Icon-72.png b/ui/app/mobile/images/Icon-72.pngnew file mode 100755index 000000000..f30af07e2Binary files /dev/null and b/ui/app/mobile/images/Icon-72.png differdiff --git a/ui/app/mobile/images/favicon.ico b/ui/app/mobile/images/favicon.iconew file mode 100644index 000000000..041659d88Binary files /dev/null and b/ui/app/mobile/images/favicon.ico differdiff --git a/ui/app/mobile/images/logo-mobile.png b/ui/app/mobile/images/logo-mobile.pngnew file mode 100644index 000000000..15ace0048Binary files /dev/null and b/ui/app/mobile/images/logo-mobile.png differdiff --git a/ui/app/mobile/images/logo.png b/ui/app/mobile/images/logo.pngnew file mode 100644index 000000000..2179b259dBinary files /dev/null and b/ui/app/mobile/images/logo.png differdiff --git a/ui/app/mobile/index.html b/ui/app/mobile/index.htmlnew file mode 100644index 000000000..acb59aaba--- /dev/null+++ b/ui/app/mobile/index.html@@ -0,0 +1,88 @@+<!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 Demo</title>+ <meta name="application-name" content="OpenRemote Demo">+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8">+ <meta name="apple-mobile-web-app-title" content="OpenRemote Demo">++ <meta name="msapplication-TileImage" content="images/Icon-144.png">+ <meta name="msapplication-TileColor" content="#ffffff">+ <meta name="msapplication-tap-highlight" content="no">++ <link rel="icon" href="images/favicon.ico">+ <meta name="theme-color" content="#ffffff">++ <!-- Add to homescreen for Chrome on Android. Fallback for manifest.json -->+ <meta name="mobile-web-app-capable" content="yes">++ <!-- Add to homescreen for Safari on iOS -->+ <meta name="apple-mobile-web-app-capable" content="yes">++ <!-- Homescreen icons -->+ <link rel="apple-touch-icon" href="images/Icon-48.png">+ <link rel="apple-touch-icon" sizes="72x72" href="images/Icon-72.png">+ <link rel="apple-touch-icon" sizes="144x144" href="images/Icon-144.png">+ <link rel="apple-touch-icon" sizes="192x192" href="images/Icon-196.png">++ <!-- Tile icon for Windows 8 (144x144 + tile color) -->+ <meta name="msapplication-TileImage" content="images/Icon-144.png">+ <meta name="msapplication-TileColor" content="#ffffff">+ <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/Icon-144.png" />++ <!--+ 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>+ html {+ height: 100%;+ }+ body {+ margin: 0;+ font-family: "Segoe UI", Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol";+ line-height: 1.5;+ height: 100%;+ -webkit-font-smoothing: antialiased;+ overflow: hidden;+ }+ </style>+++</head>+<body>+<!--+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/mobile/package.json b/ui/app/mobile/package.jsonnew file mode 100644index 000000000..02b75e741--- /dev/null+++ b/ui/app/mobile/package.json@@ -0,0 +1,46 @@+{+ "name": "mobile",+ "version": "1.0.0",+ "description": "Mobile App",+ "author": "OpenRemote",+ "license": "AGPL-3.0-or-later",+ "private": true,+ "scripts": {+ "clean": "npx shx rm -rf dist",+ "modelBuild": "node ../../model-build.js",+ "modelWatch": "node ../../model-watch.js",+ "build": "npx tsc -b && npx cross-env NODE_OPTIONS=--max_old_space_size=4096 webpack --mode production",+ "serve": "npx cross-env NODE_OPTIONS=--max_old_space_size=4096 webpack-dev-server --mode development",+ "watch": "npx tsc -b -w",+ "test": "echo \"Error: no test specified\" && exit 1"+ },+ "dependencies": {+ "@openremote/or-app": "^1.1.0"+ },+ "devDependencies": {+ "@babel/core": "^7.2.2",+ "@babel/plugin-syntax-dynamic-import": "^7.8.3",+ "@babel/plugin-syntax-object-rest-spread": "^7.8.3",+ "@babel/plugin-transform-regenerator": "^7.0.0",+ "@babel/plugin-transform-runtime": "^7.8.3",+ "@babel/preset-env": "^7.8.3",+ "@babel/runtime": "^7.8.3",+ "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.4.5",+ "url-loader": "^1.1.2",+ "webpack": "^4.41.2",+ "webpack-cli": "^3.3.9",+ "webpack-dev-server": "^3.9.0"+ }+}diff --git a/ui/app/mobile/src/index.ts b/ui/app/mobile/src/index.tsnew file mode 100644index 000000000..b11b01e20--- /dev/null+++ b/ui/app/mobile/src/index.ts@@ -0,0 +1,100 @@+// Declare require method which we'll use for importing webpack resources (using ES6 imports will confuse typescript parser)+declare function require(name: string): any;++import {combineReducers, configureStore} from "@reduxjs/toolkit";+import "@openremote/or-app";+import {+ OrApp,+ AppConfig,+ appReducer,+ getRealmQueryParameter,+ headerItemLogout,+ headerItemLogs,+ headerItemMap,+ headerItemAssets,+ headerItemRules,+ headerItemAccount,+ headerItemInsights} from "@openremote/or-app";++import manager, {Auth, DefaultColor2, DefaultColor3, DefaultHeaderHeight, ManagerConfig, Util, BasicLoginResult} from "@openremote/core";+import "@openremote/or-app/dist/pages/page-mobile-onboarding";+import {pageMobileOnboardingProvider, OnboardingConfig} from "@openremote/or-app/dist/pages/page-mobile-onboarding";+import "@openremote/or-app/dist/pages/page-mobile-splash";+import {pageMobileSplashProvider, SplashConfig} from "@openremote/or-app/dist/pages/page-mobile-splash";+import "@openremote/or-app/dist/pages/page-mobile-geofences";+import {pageMobileGeofencesProvider, GeofencesConfig} from "@openremote/or-app/dist/pages/page-mobile-geofences";++const onboardingConfig:OnboardingConfig = {+ pages: [+ {+ title: "Welcome",+ type: "default",+ description: "Welcome at the first page",+ image: require("../images/logo-mobile.png")+ },+ {+ title: "At the right time and place",+ type: "bottom-image",+ description: "Welcome at the second page",+ enableProviders: [+ {+ name:"geofence",+ action:"GEOFENCE_REFRESH"+ }+ ],+ image: require("../images/logo-mobile.png")+ },+ {+ title: "View your messages",+ type: "default",+ description: "Welcome at the third page",+ image: require("../images/logo-mobile.png")+ }+ ],+ redirect: MANAGER_URL+}++const splashConfig:SplashConfig = {+ redirect: "#!onboarding/",+ interval: 5000,+ logoMobile: require("../images/logo-mobile.png")+}++declare var MANAGER_URL: string;++const rootReducer = combineReducers({+ app: appReducer+});++type RootState = ReturnType<typeof rootReducer>;++export const store = configureStore({+ reducer: rootReducer+});++const orApp = new OrApp(store);+const managerConfig: ManagerConfig = {+ managerUrl: MANAGER_URL,+ auth: Auth.NONE,+ autoLogin: false,+ realm: getRealmQueryParameter(),+ consoleAutoEnable: true,+ loadTranslations: ["app", "or"]+};++const appConfig: AppConfig<RootState> = {+ pages: {+ default: pageMobileSplashProvider(store, splashConfig),+ geofences: pageMobileGeofencesProvider(store),+ onboarding: pageMobileOnboardingProvider(store, onboardingConfig)+ },+ default: {+ appTitle: "OpenRemote Demo",+ logo: require("../images/logo.png"),+ logoMobile: require("../images/logo-mobile.png")+ }+};+orApp.managerConfig = managerConfig;+orApp.appConfig = appConfig;++document.body.appendChild(orApp);diff --git a/ui/app/mobile/tsconfig.json b/ui/app/mobile/tsconfig.jsonnew file mode 100644index 000000000..7da0c6ae9--- /dev/null+++ b/ui/app/mobile/tsconfig.json@@ -0,0 +1,13 @@+{+ "extends": "../../tsconfig",+ "compilerOptions": {+ "tsBuildInfoFile": "./.tsbuildinfo",+ "strict": true+ },+ "include": [+ "./src"+ ],+ "references": [+ { "path": "../or-app" }+ ]+}diff --git a/ui/app/mobile/webpack.config.js b/ui/app/mobile/webpack.config.jsnew file mode 100644index 000000000..189be51b6--- /dev/null+++ b/ui/app/mobile/webpack.config.js@@ -0,0 +1,120 @@+var webpack = require("webpack");+var path = require("path");+var CopyWebpackPlugin = require("copy-webpack-plugin");+var HtmlWebpackPlugin = require("html-webpack-plugin");++var config = {+ entry: {+ 'bundle': './src/index.js'+ },+ output: {+ path: __dirname + "/dist",+ publicPath: "",+ filename: "[name].[hash].js"+ },+ module: {+ rules: [+ {+ test: /\.css$/,+ use: [+ { loader: "css-loader" }+ ]+ },+ {+ test: /\.(png|jpg|gif|svg|eot|ttf|woff|woff2)$/,+ loader: 'url-loader',+ options: {+ outputPath: "images/",+ limit: 10000,+ },+ }+ ]+ }+};++module.exports = (env, argv) => {++ const production = argv.mode === "production";+ const managerUrl = production ? undefined : "http://localhost:8080";+ const IS_DEV_SERVER = process.argv.find(arg => arg.includes('webpack-dev-server'));+ const OUTPUT_PATH = IS_DEV_SERVER ? 'src' : 'dist';++ // Only use babel for production otherwise source maps don't work+ if (production) {+ config.module.rules.push(+ {+ 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'+ }+ ]+ },+ );+ } else {+ config.module.rules.push(+ {+ test: /\.js$/,+ use: ["source-map-loader"],+ enforce: "pre",+ exclude: [+ /node_modules/+ ]+ },+ );+ }++ config.plugins = [+ // Conditional compilation variables+ new webpack.DefinePlugin({+ PRODUCTION: JSON.stringify(production),+ MANAGER_URL: JSON.stringify(managerUrl),+ "process.env": {+ BABEL_ENV: JSON.stringify(argv.mode)+ }+ }),+ 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: path.join(path.dirname(require.resolve("@openremote/or-app/package.json")), "locales"),+ // to: "locales"+ // },+ {+ from: "./images",+ to: "images"+ }+ // {+ // from: "./locales",+ // to: "locales"+ // }+ ])+ ];++ config.devtool = production ? false :"inline-source-map",+ config.devServer = {+ historyApiFallback: {+ index: "/" + __dirname.split(path.sep).slice(-1)[0] + "/",+ },+ port: 9000,+ publicPath: "/" + __dirname.split(path.sep).slice(-1)[0] + "/",+ contentBase: OUTPUT_PATH,+ disableHostCheck: true+ };+ config.watchOptions = {+ ignored: ['**/*.ts', 'node_modules']+ }++ return config;+};\ No newline at end of filediff --git a/ui/app/or-app/src/index.ts b/ui/app/or-app/src/index.tsindex 3784ce103..614aac478 100644--- a/ui/app/or-app/src/index.ts+++ b/ui/app/or-app/src/index.ts@@ -40,7 +40,7 @@ export interface DefaultAppConfig {logo: HTMLTemplateElement | string;logoMobile: HTMLTemplateElement | string;language?: string;- header: HeaderConfig;+ header?: HeaderConfig;styles?: TemplateResult;}@@ -188,7 +188,7 @@ export function headerItemAccount<S extends AppStateKeyed, A extends AnyAction>(};}-function getRealmQueryParameter(): string {+export function getRealmQueryParameter(): string {return Util.getQueryParameter(location.search, "realm");}@@ -237,14 +237,19 @@ export class OrApp<S extends AppStateKeyed> extends LitElement {color: ${unsafeCSS(DefaultColor3)};fill: ${unsafeCSS(DefaultColor3)};font-size: 14px;++ height: 100vh;+ display: flex;+ flex: 1;+ flex-direction: column;}.main-content {display: flex;- padding-top: ${unsafeCSS(DefaultHeaderHeight)};- height: 100vh;+ flex: 1;box-sizing: border-box;background-color: var(--or-app-color2);+ overflow: auto;}main > * {@@ -439,7 +444,9 @@ export class OrApp<S extends AppStateKeyed> extends LitElement {}return html`${unsafeHTML(this._config.styles ? this._config.styles.strings : ``)}- <or-header logo="${this._config.logo}" .logoMobile="${this._config.logoMobile}" .config="${this._config.header}"></or-header>+ ${this._config.header ? html`+ <or-header logo="${this._config.logo}" .logoMobile="${this._config.logoMobile}" .config="${this._config.header}"></or-header>+ ` : ``}<!-- Main content --><main role="main" class="main-content d-none"></main>diff --git a/ui/app/or-app/src/or-header.ts b/ui/app/or-app/src/or-header.tsindex 483a19525..9607eb057 100644--- a/ui/app/or-app/src/or-header.ts+++ b/ui/app/or-app/src/or-header.ts@@ -104,9 +104,6 @@ class OrHeader extends LitElement {#header {opacity: 1;- position: absolute;- top: 0;- left: 0;width: 100%;height: var(--internal-or-header-height);text-align: center;diff --git a/ui/app/or-app/src/pages/page-mobile-geofences.ts b/ui/app/or-app/src/pages/page-mobile-geofences.tsnew file mode 100644index 000000000..95ff59d04--- /dev/null+++ b/ui/app/or-app/src/pages/page-mobile-geofences.ts@@ -0,0 +1,295 @@+import {css, customElement, html, property} from "lit-element";+import {AppStateKeyed, Page} from "../index";+import {EnhancedStore} from "@reduxjs/toolkit";+import manager from "@openremote/core";+import { JsonRulesetDefinition } from "@openremote/model";+import { getGeoNotificationsFromRulesSet } from "@openremote/core/dist/util";+import { OrMap, OrMapMarkerClickedEvent, OrMapClickedEvent } from "@openremote/or-map";++export interface GeofencesConfig {+}++export function pageMobileGeofencesProvider<S extends AppStateKeyed>(store: EnhancedStore<S>, config?: GeofencesConfig) {+ return {+ routes: [+ "geofences"+ ],+ pageCreator: () => {+ const page = new PageMobileGeofences(store);+ if(config) page.config = config;+ return page;+ }+ };+}+const QUERY_VIEW = new URLSearchParams(window.location.search).get("view");+@customElement("page-mobile-geofences")+class PageMobileGeofences<S extends AppStateKeyed> extends Page<S> {+ @property({type: String})+ view = QUERY_VIEW ? QUERY_VIEW : "map";++ @property({type: Array})+ mapItems = [];++ @property({type: Array})+ listItems = [];++ @property({type: Object})+ activeItem;++ static get styles() {+ // language=CSS+ return css`+ :host {+ flex: 1;+ width: 100%;+ align-items: center;+ justify-content: center;+ flex-direction: column;+ }++ .header {+ position: fixed;+ z-index: 99999;+ width: auto;+ top: 0;+ right: 0;+ }++ .d-flex {+ display: flex;+ flex-direction: column;+ }++ .right {+ align-items: flex-end;+ }++ .flex {+ flex: 1;+ }++ .list-container {+ width: 100vw;+ height: 100vh;+ }++ .list-item {+ display: flex;+ flex-direction: row;+ text-decoration: none;+ padding: 10px;+ color: var(--or-app-color3);+ border-bottom: 1px solid var(--or-app-color3);;+ }++ .button {+ cursor: pointer;+ background-color: var(--or-app-color2);+ color: var(--or-app-color4);+ --or-icon-fill: var(--or-app-color3);+ width: 42px;+ height: 42px;+ align-items: center;+ justify-content: center;+ text-align: center;+ border-radius: 30px;+ margin: 10px;+ -webkit-box-shadow: 0 2px 4px rgba(0,0,0,0.16), 0 2px 4px rgba(0,0,0,0.19);+ -moz-box-shadow: 0 2px 4px rgba(0,0,0,0.16), 0 2px 4px rgba(0,0,0,0.19);+ box-shadow: 0 2px 4px rgba(0,0,0,0.16), 0 2px 4px rgba(0,0,0,0.19);+ }++ .marker-tooltip {+ position: absolute;+ bottom: 0;+ right: 0;+ margin: 15px;+ padding: 20px;+ background-color: var(--or-app-color2);+ color: var(--or-app-color3);+ text-decoration: none;+ max-width: 260px;++ -webkit-box-shadow: 0 2px 4px rgba(0,0,0,0.16), 0 2px 4px rgba(0,0,0,0.19);+ -moz-box-shadow: 0 2px 4px rgba(0,0,0,0.16), 0 2px 4px rgba(0,0,0,0.19);+ box-shadow: 0 2px 4px rgba(0,0,0,0.16), 0 2px 4px rgba(0,0,0,0.19);++ z-index: 99999;++ }++ or-map-marker[active] {+ --or-map-marker-width: 60px;+ --or-map-marker-height: 60px;+ }+ `;+ }++ constructor(store: EnhancedStore<S>) {+ super(store);+ this.getGeoNotifications();+ }++ public connectedCallback() {+ super.connectedCallback();+ this.addEventListener(OrMapMarkerClickedEvent.NAME, this.onMapMarkerClick);+ this.addEventListener(OrMapClickedEvent.NAME, this.onMapClick);+ }++ public disconnectedCallback() {+ super.disconnectedCallback();+ this.removeEventListener(OrMapMarkerClickedEvent.NAME, this.onMapMarkerClick);+ this.removeEventListener(OrMapClickedEvent.NAME, this.onMapClick);+ }++ protected onMapMarkerClick(evt: OrMapMarkerClickedEvent) {+ const marker:any = evt.detail.marker;+ this.activeItem = marker.marker;+ }++ protected onMapClick(e: OrMapClickedEvent) {+ this.activeItem = null;+ }++ public stateChanged(state: S) {+ }+++ @property()+ public config?: GeofencesConfig;++ protected render() {+ return html`+ ${this.view === 'map' ? html`+ <div class="header">+ <div class="d-flex right">+ <a class="d-flex button" @click="${() => history.back()}"><or-icon icon="close"></or-icon></a>+ <a class="d-flex button" @click="${() => this.view = "list"}"><or-icon icon="view-list"></or-icon></a>+ <a class="d-flex location-button button" @click="${this.getLocation}"><or-icon icon="crosshairs-gps"></or-icon></a>+ </div>+ </div>+ <or-map id="vector" class="or-map" type="VECTOR" style="height: 100%; width: 100%;">+ ${this.mapItems.map((marker: any) => {+ return html`+ <or-map-marker ?active="${JSON.stringify(this.activeItem) === JSON.stringify(marker) }" icon="information" .marker="${marker}" lat="${marker.predicate.lat}" lng="${marker.predicate.lng}"></or-map-marker>+ `})}+ </or-map>+ ${this.activeItem ? html`+ <a class="marker-tooltip" href="${this.createUrl(this.activeItem.notification.action)}">+ <div class="flex marker-tooltip-inner" >+ <div style="flex-direction:row;" class="d-flex list-item">+ <div class="flex">+ <h3>${this.activeItem.notification.title}</h3>+ <p>${this.activeItem.notification.body}</p>+ </div>+ <div style="align-items: center; justify-content: center; display: flex;">+ <or-icon style="margin-left: 20px;" icon="chevron-right"></or-icon>+ </div>+ </div>+ </div>+ </a>+ ` : ``}+ ` : ``}++ ${this.view === 'list' ? html`+ <div class="header">+ <div class="d-flex right">+ <a class="d-flex button" @click="${() => history.back()}"><or-icon icon="close"></or-icon></a>+ <a class="d-flex button" @click="${() => this.view = "map"}"><or-icon icon="map"></or-icon></a>+ </div>+ </div>+ <div class="d-flex flex list-container">+ ${this.listItems.map((item: any) => {+ return html`+ <a class="list-item" href="${this.createUrl(item.notification.action)}">+ <div class="flex">+ <h3>${item.notification.title}</h3>+ <p>${item.notification.body}</p>+ </div>+ <div style="align-items: center; justify-content: center; display: flex;">+ <or-icon style="margin-left: 20px;" icon="chevron-right"></or-icon>+ </div>+ </a>+ `})}+ </div>+ ` : ``}++ `;+ }+++ protected checkPeriode(datetime){+ const today = new Date().getTime();+ const startDate = new Date(datetime.start).getTime();+ const endDate = new Date(datetime.end).getTime();++ if((today - startDate) > 0 && (today - endDate) < 0) {+ return true;+ } else {+ return false;+ }+ }++ protected getGeoNotifications() {+ manager.rest.api.RulesResource.getTenantRulesets(manager.config.realm, {fullyPopulate: true}).then((response: any) => {+ const mapItemDefinition: JsonRulesetDefinition = {+ rules: []+ };++ const listItemtDefinition: JsonRulesetDefinition = {+ rules: []+ };+ if (response && response.data) {+ response.data.forEach((rulesSet) => {+ let parsedRules = JSON.parse(rulesSet.rules);+ // TODO enable this when custom validity en meta items are availible+ // const datetime = rulesSet.meta.validity;+ // if(this.checkPeriode(datetime) === false || rulesSet.enabled === false) {+ // return;+ // }+ // if(rulesSet.meta && rulesSet.meta.showOnMap) {+ // mapItemDefinition.rules.push(...parsedRules.rules);+ // }+ // if(rulesSet.meta && rulesSet.meta.showOnList) {+ // listItemtDefinition.rules.push(...parsedRules.rules);+ // }+ mapItemDefinition.rules.push(...parsedRules.rules);+ listItemtDefinition.rules.push(...parsedRules.rules);++ });+ }+ this.mapItems = getGeoNotificationsFromRulesSet(mapItemDefinition);+ this.listItems = getGeoNotificationsFromRulesSet(listItemtDefinition);+ }).catch((reason) => {+ console.log("Error:" + reason);+ const rulesetDefinition: JsonRulesetDefinition = {+ rules: []+ };+ this.mapItems = getGeoNotificationsFromRulesSet(rulesetDefinition);+ this.listItems = getGeoNotificationsFromRulesSet(rulesetDefinition);+ });+ }++ protected createUrl(action) {+ if(action){+ let url = action.url;++ if(action.openInBrowser) {+ url = url.replace("https", "webbrowser");+ }++ return url;+ }+ }++ protected getLocation() {+ const map = this.shadowRoot.querySelector('.or-map');+ const vectorMap = map as OrMap;++ manager.console.sendProviderMessage({provider: 'geofence', action: "GET_LOCATION"}, true).then(response => {+ if (response.data) {+ vectorMap.flyTo({lng: response.data.longitude, lat: response.data.latitude});+ }+ });+ }+}diff --git a/ui/app/or-app/src/pages/page-mobile-onboarding.ts b/ui/app/or-app/src/pages/page-mobile-onboarding.tsnew file mode 100644index 000000000..2d2fc0d1e--- /dev/null+++ b/ui/app/or-app/src/pages/page-mobile-onboarding.ts@@ -0,0 +1,152 @@+import {css, customElement, html, property} from "lit-element";+import {AppStateKeyed, Page} from "../index";+import {EnhancedStore} from "@reduxjs/toolkit";+import manager from "@openremote/core";++export interface ConsoleProvider {+ name: string;+ action: string;+}+export interface OnboardingPage {+ title: string;+ description?: string;+ enableProviders?: ConsoleProvider[];+ image?: HTMLTemplateElement | string;+ type: "default" | "bottom-image";+ next?: string;+}++export interface OnboardingConfig {+ pages: OnboardingPage[],+ redirect: string;+}++export function pageMobileOnboardingProvider<S extends AppStateKeyed>(store: EnhancedStore<S>, config?: OnboardingConfig) {+ return {+ routes: [+ "onboarding"+ ],+ pageCreator: () => {+ const page = new PageMobileOnboarding(store);+ if(config) page.config = config;+ return page;+ }+ };+}++@customElement("page-mobile-onboarding")+class PageMobileOnboarding<S extends AppStateKeyed> extends Page<S> {++ static get styles() {+ // language=CSS+ return css`+ :host {+ flex: 1;+ width: 100%;+ flex-direction: column;+ }++ .page-container {+ width: 100vw;+ height: 100vh;+ flex-direction: column;+ display: none;++ }++ .page-container.active {+ display: flex;+ }++ .page-content {+ flex: 1;+ display: flex;+ flex-direction: column;+ align-items: center;+ justify-content: center;+ }++ .next-button {+ cursor: pointer;+ margin: 0 20px 20px auto;+ width: 42px;+ height: 42px;+ border-radius: 50%;+ background-color: var(--or-app-color4);+ justify-content: center;+ align-items: center;+ display: flex;+ --or-icon-fill: var(--or-app-color2, #F9F9F9);+ }+ `;+ }++ constructor(store: EnhancedStore<S>) {+ super(store);++++ }++ public connectedCallback() {+ super.connectedCallback();+ if (localStorage.getItem("completedOnboarding") !== null) {+ window.location.href = this.config.redirect;+ }+ }++ public stateChanged(state: S) {+ }++ @property()+ public pageIndex: number = 0;++ @property()+ public config?: OnboardingConfig;++ protected render() {+ return html`+ ${this.config.pages.map((page, index) => {+ return html`+ <div class="page-container ${this.pageIndex === index ? "active" :""}">+ <div class="page-content">+ ${page.type === "default" ? html`+ <div><img src="${page.image}" /></div>+ <h1>${page.title}</h1>+ <p>${page.description}</p>+ ` : ``}++ ${page.type === "bottom-image" ? html`+ <h1>${page.title}</h1>+ <p>${page.description}</p>+ <div><img src="${page.image}" /></div>+ ` : ``}+ </div>++ <div class="next-button" @click="${() => this.nextPage(index)}">+ <or-icon icon="chevron-right"></or-icon>+ </div>+ </div>+ `+ })}+ `;+ }++ private async enableProviders() {+ if(this.config.pages[this.pageIndex-1].enableProviders) {+ this.config.pages[this.pageIndex-1].enableProviders.map(provider => {+ manager.console.sendProviderMessage({provider: provider.name, action: provider.action}, true)+ })+ }+ }++ private nextPage(index) {+ if(this.config.pages.length-1 === index) {+ window.location.href = this.config.redirect;+ window.localStorage.setItem("completedOnboarding", "1");+ } else {+ this.pageIndex = this.pageIndex+1+ }+ this.enableProviders();+ }+}diff --git a/ui/app/or-app/src/pages/page-mobile-splash.ts b/ui/app/or-app/src/pages/page-mobile-splash.tsnew file mode 100644index 000000000..0157c6085--- /dev/null+++ b/ui/app/or-app/src/pages/page-mobile-splash.ts@@ -0,0 +1,62 @@+import {css, customElement, html, property} from "lit-element";+import {AppStateKeyed, Page} from "../index";+import {EnhancedStore} from "@reduxjs/toolkit";++export interface SplashConfig {+ redirect: string;+ interval?: number;+ logoMobile?: HTMLTemplateElement | string;+}++export function pageMobileSplashProvider<S extends AppStateKeyed>(store: EnhancedStore<S>, config?: SplashConfig) {+ return {+ routes: [+ "splash"+ ],+ pageCreator: () => {+ const page = new PageMobileSplash(store);+ if(config) page.config = config;+ return page;+ }+ };+}++@customElement("page-mobile-splash")+class PageMobileSplash<S extends AppStateKeyed> extends Page<S> {++ static get styles() {+ // language=CSS+ return css`+ :host {+ flex: 1;+ width: 100%;+ align-items: center;+ justify-content: center;+ }+ `;+ }++ constructor(store: EnhancedStore<S>) {+ super(store);+ }+ public connectedCallback() {+ super.connectedCallback();+ setTimeout(() => {+ window.location.href = this.config.redirect;+ }, this.config.interval ? this.config.interval : 3000)+ }+++ public stateChanged(state: S) {+ }+++ @property()+ public config?: SplashConfig;++ protected render() {+ return html`+ <div><img id="logo-mobile" src="${this.config.logoMobile}" /></div>+ `;+ }+}diff --git a/ui/component/core/src/util.ts b/ui/component/core/src/util.tsindex bc01ec3f5..1af19c9f1 100644--- a/ui/component/core/src/util.ts+++ b/ui/component/core/src/util.ts@@ -75,7 +75,6 @@ export function getGeoNotificationsFromRulesSet(rulesetDefinition: JsonRulesetDeif (geoNotificationMap.size > 0) {rule.then.forEach((ruleAction) => addPushNotificationsFromRuleAction(ruleAction, geoNotificationMap));}-for (const geoNotificationsArr of geoNotificationMap.values()) {geoNotificationsArr.forEach((geoNotification) => {if (geoNotification.notification) {@@ -93,9 +92,25 @@ function addGeofencePredicatesFromRuleConditionCondition(ruleCondition: LogicGroif (!ruleCondition) {return;}-+ const items:any = [];+ if (ruleCondition.groups) {+ ruleCondition.groups.forEach((ruleGroup) => {+ if(ruleGroup.items){+ ruleGroup.items.forEach((ruleTrigger) => {+ items.push(ruleTrigger)+ });+ }+ });+ }+if (ruleCondition.items) {ruleCondition.items.forEach((ruleTrigger) => {+ items.push(ruleTrigger)+ });++ }+ if (items) {+ items.forEach((ruleTrigger:any) => {if (ruleTrigger.assets && ruleTrigger.assets.attributes) {const geoNotifications: GeoNotification[] = [];addGeoNotificationsFromAttributePredicateCondition(ruleTrigger.assets.attributes, geoNotifications);diff --git a/ui/component/or-rules/src/index.ts b/ui/component/or-rules/src/index.tsindex 276502b4a..9f1925987 100644--- a/ui/component/or-rules/src/index.ts+++ b/ui/component/or-rules/src/index.ts@@ -639,7 +639,6 @@ export class OrRules extends translate(i18next)(LitElement) {realm: realm,rules: undefined // View needs to populate this on load};- console.log(ruleset)this._activeRuleset = ruleset;}diff --git a/ui/component/or-rules/src/json-viewer/modals/or-rule-radial-modal.ts b/ui/component/or-rules/src/json-viewer/modals/or-rule-radial-modal.tsnew file mode 100644index 000000000..c0343bded--- /dev/null+++ b/ui/component/or-rules/src/json-viewer/modals/or-rule-radial-modal.ts@@ -0,0 +1,145 @@+import { customElement, html, LitElement, property} from "lit-element";+import {+ AssetDescriptor,+ AttributePredicate,+ AssetQuery,+ RadialGeofencePredicate+} from "@openremote/model";+import {+ getAssetTypeFromQuery,+} from "../../index";+import "@openremote/or-input";+import {InputType} from "@openremote/or-input";+import i18next from "i18next";+import {OrRulesJsonRuleChangedEvent} from "../or-rule-json-viewer";+import {translate} from "@openremote/or-translate";++import {DialogAction, OrMwcDialog, OrMwcDialogOpenedEvent} from "@openremote/or-mwc-components/dist/or-mwc-dialog";+import {OrMap, OrMapClickedEvent} from '@openremote/or-map';+import '@openremote/or-map/dist/markers/or-map-marker';++@customElement("or-rule-radial-modal")+export class OrRuleRadialModal extends translate(i18next)(LitElement) {++ @property({type: Object})+ public assetDescriptor?: AssetDescriptor;++ @property({type: Object})+ public attributePredicate?: AttributePredicate;+++ @property({type: Object})+ public query?: AssetQuery;++ constructor() {+ super();+ this.addEventListener(OrMwcDialogOpenedEvent.NAME, this.initRadialMap)+ }++ initRadialMap() {+ const modal = this.shadowRoot!.getElementById('radial-modal');+ if(!modal) return;++ const map = modal.shadowRoot!.querySelector('.or-map') as OrMap;+ if(map){+ map.addEventListener(OrMapClickedEvent.NAME, (evt: CustomEvent) => {+ const lngLat:any = evt.detail.lngLat;+ const latElement = (<HTMLInputElement>modal.shadowRoot!.querySelector('.location-lat'));+ const lngElement = (<HTMLInputElement>modal.shadowRoot!.querySelector('.location-lng'));+ latElement.value = lngLat.lat;+ lngElement.value = lngLat.lng;++ const event = new Event('change');+ latElement.dispatchEvent(event);+ lngElement.dispatchEvent(event);+ this.setValuePredicateProperty('lat', lngLat.lat);+ this.setValuePredicateProperty('lng', lngLat.lng);+ });+ }+ }++ protected getAttributeName(attributePredicate: AttributePredicate): string | undefined {+ return attributePredicate && attributePredicate.name ? attributePredicate.name.value : undefined;+ }++ protected setValuePredicateProperty(propertyName: string, value: any) {+ if(!this.attributePredicate) return;+ if(!this.attributePredicate.value) return;++ const valuePredicate = this.attributePredicate.value;++ (valuePredicate as any)[propertyName] = value;+ this.attributePredicate = {...this.attributePredicate};+ this.dispatchEvent(new OrRulesJsonRuleChangedEvent());+ this.requestUpdate();+ }++ renderDialogHTML(value:RadialGeofencePredicate) {+ const dialog: OrMwcDialog = this.shadowRoot!.getElementById("radial-modal") as OrMwcDialog;+ if (dialog) {+ dialog.dialogContent = html`+ <div style="display:grid">+ <or-map class="or-map" type="VECTOR" style="border: 1px solid #d5d5d5; height: 400px; min-width: 300px;">+ <or-map-marker active color="#FF0000" icon="information" lat="${value.lat}" lng="${value.lng}" radius="${value.radius}"></or-map-marker>+ </or-map>++ <div class="layout horizontal">+ <input hidden class="location-lng" required placeholder=" " type="text" .value="${value && value.lng ? value.lng : null}" />+ <input hidden class="location-lat" required placeholder=" " type="text" .value="${value && value.lat ? value.lat : null}" />+ </div>+++ <label>Straal (minimaal 100m)</label>+ <input @change="${(e:any) => this.setValuePredicateProperty("radius", parseInt(e.target.value))}" style="max-width: calc(50% - 30px);" required placeholder=" " min="50" type="number" .value="${value && value.radius ? value.radius : null}" />+ </div>`;+ }+ }++ protected render() {+ if(!this.attributePredicate) return html``;+ if(!this.query) return html``;++ const valuePredicate = this.attributePredicate.value;+ if (!this.assetDescriptor || !valuePredicate) {+ return html``;+ }++ const attributeName = this.getAttributeName(this.attributePredicate);+ const assetType = getAssetTypeFromQuery(this.query);+ // @ts-ignore+ const value:RadialGeofencePredicate = valuePredicate ? valuePredicate : undefined;++ const radiusPickerModalActions: DialogAction[] = [+ {+ actionName: "ok",+ default: true,+ content: html`<or-input class="button" .type="${InputType.BUTTON}" .label="${i18next.t("ok")}"></or-input>`,+ action: () => {+ }+ },+ {+ actionName: "cancel",+ content: html`<or-input class="button" .type="${InputType.BUTTON}" .label="${i18next.t("cancel")}"></or-input>`,+ action: () => {+ // Nothing to do here+ }+ },+ ];+++ const radialPickerModalOpen = () => {+ const dialog: OrMwcDialog = this.shadowRoot!.getElementById("radial-modal") as OrMwcDialog;+ if (dialog) {+ dialog.open();+ this.renderDialogHTML(value);+ }+ };++ this.renderDialogHTML(value);++ return html`+ <or-input .type="${InputType.BUTTON}" .label="${i18next.t("area")}" @click="${radialPickerModalOpen}"></or-input>+ <or-mwc-dialog id="radial-modal" dialogTitle="area" .dialogActions="${radiusPickerModalActions}"></or-mwc-dialog>+ `+ }+}\ No newline at end of filediff --git a/ui/component/or-rules/src/json-viewer/or-rule-asset-query.ts b/ui/component/or-rules/src/json-viewer/or-rule-asset-query.tsindex 286a92064..c17e9ec1f 100644--- a/ui/component/or-rules/src/json-viewer/or-rule-asset-query.ts+++ b/ui/component/or-rules/src/json-viewer/or-rule-asset-query.ts@@ -33,6 +33,7 @@ import {buttonStyle} from "../style";import {OrRulesJsonRuleChangedEvent} from "./or-rule-json-viewer";import {translate} from "@openremote/or-translate";import { OrAttributeInputChangedEvent } from "@openremote/or-attribute-input";+import "./modals/or-rule-radial-modal";// language=CSSconst style = css`@@ -211,7 +212,7 @@ export class OrRuleAssetQuery extends translate(i18next)(LitElement) {case "string-array":return html `<span>NOT IMPLEMENTED</span>`;case "radial":- return html `<span>NOT IMPLEMENTED</span>`;+ return html`<or-rule-radial-modal .query="${this.query}" .assetDescriptor="${assetDescriptor}" .attributePredicate="${attributePredicate}"></or-rule-radial-modal>`;case "rect":return html `<span>NOT IMPLEMENTED</span>`;case "object-value-key":