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
Initial commit of or-thermostat component and demo (copied from or-header)
Rich Turnercd00762e2d4e
diff --git a/ui/component/or-thermostat/.npmignore b/ui/component/or-thermostat/.npmignorenew file mode 100644index 000000000..ca658009d--- /dev/null+++ b/ui/component/or-thermostat/.npmignore@@ -0,0 +1,3 @@+build/+build.gradle+test/\ No newline at end of filediff --git a/ui/component/or-thermostat/README.md b/ui/component/or-thermostat/README.mdnew file mode 100644index 000000000..6bf87e6a9--- /dev/null+++ b/ui/component/or-thermostat/README.md@@ -0,0 +1,21 @@+# \<or-header\>++Displays header with menu based on slots.++## Install the Polymer-CLI++First, make sure you have the [Polymer CLI](https://www.npmjs.com/package/polymer-cli) and npm (packaged with [Node.js](https://nodejs.org)) installed. Run `npm install` to install your element's dependencies, then run `polymer serve` to serve your element locally.++## Viewing Your Element++```+$ polymer serve+```++## Running Tests++```+$ polymer test+```++Your application is already set up to be tested via [web-component-tester](https://github.com/Polymer/web-component-tester). Run `polymer test` to run your application's test suite locally.diff --git a/ui/component/or-thermostat/build.gradle b/ui/component/or-thermostat/build.gradlenew file mode 100644index 000000000..489605e7b--- /dev/null+++ b/ui/component/or-thermostat/build.gradle@@ -0,0 +1,9 @@+task clean() {+ doLast {+ delete "dist"+ }+}++task build() {+ dependsOn rootProject.tasks.getByName("yarnInstall"), npmBuild+}diff --git a/ui/component/or-thermostat/package.json b/ui/component/or-thermostat/package.jsonnew file mode 100644index 000000000..56f9e2b03--- /dev/null+++ b/ui/component/or-thermostat/package.json@@ -0,0 +1,24 @@+{+ "name": "@openremote/or-thermostat",+ "version": "1.0.0",+ "description": "A thermostat component for viewing current temperature and setting target temperature",+ "main": "dist/index.js",+ "types": "src/index.ts",+ "scripts": {+ "build": "npx tsc",+ "test": "echo \"No tests\" && exit 0"+ },+ "author": "OpenRemote",+ "license": "AGPL-3.0-or-later",+ "dependencies": {+ "lit-element": "^2.0.1"+ },+ "devDependencies": {+ "@webcomponents/webcomponentsjs": "^2.0.0",+ "css-loader": "^2.0.0",+ "style-loader": "^0.23.1",+ "tslint": "^5.11.0",+ "typescript": "^3.2.2",+ "wct-browser-legacy": "^1.0.0"+ }+}diff --git a/ui/component/or-thermostat/src/index.ts b/ui/component/or-thermostat/src/index.tsnew file mode 100644index 000000000..90e43d363--- /dev/null+++ b/ui/component/or-thermostat/src/index.ts@@ -0,0 +1,157 @@+import {OrHeaderStyle} from "@openremote/or-header/src/or-header-style";+import {css, html, LitElement, property, customElement} from "lit-element";++const menuIcon = html`<svg height="24" viewBox="0 0 24 24" width="24"><path d="M3 18h18v-2H3v2zm0-5h18v-2H3v2zm0-7v2h18V6H3z"></path></svg>`;++const menu = html`<svg version="1.1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" xmlns:xlink="http://www.w3.org/1999/xlink" enable-background="new 0 0 24 24">+ <g>+ <path d="M24,3c0-0.6-0.4-1-1-1H1C0.4,2,0,2.4,0,3v2c0,0.6,0.4,1,1,1h22c0.6,0,1-0.4,1-1V3z"/>+ <path d="M24,11c0-0.6-0.4-1-1-1H1c-0.6,0-1,0.4-1,1v2c0,0.6,0.4,1,1,1h22c0.6,0,1-0.4,1-1V11z"/>+ <path d="M24,19c0-0.6-0.4-1-1-1H1c-0.6,0-1,0.4-1,1v2c0,0.6,0.4,1,1,1h22c0.6,0,1-0.4,1-1V19z"/>+ </g>+</svg>+`;++const close = html`<svg version="1.1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 21.9 21.9" xmlns:xlink="http://www.w3.org/1999/xlink" enable-background="new 0 0 21.9 21.9">+ <path d="M14.1,11.3c-0.2-0.2-0.2-0.5,0-0.7l7.5-7.5c0.2-0.2,0.3-0.5,0.3-0.7s-0.1-0.5-0.3-0.7l-1.4-1.4C20,0.1,19.7,0,19.5,0 c-0.3,0-0.5,0.1-0.7,0.3l-7.5,7.5c-0.2,0.2-0.5,0.2-0.7,0L3.1,0.3C2.9,0.1,2.6,0,2.4,0S1.9,0.1,1.7,0.3L0.3,1.7C0.1,1.9,0,2.2,0,2.4 s0.1,0.5,0.3,0.7l7.5,7.5c0.2,0.2,0.2,0.5,0,0.7l-7.5,7.5C0.1,19,0,19.3,0,19.5s0.1,0.5,0.3,0.7l1.4,1.4c0.2,0.2,0.5,0.3,0.7,0.3 s0.5-0.1,0.7-0.3l7.5-7.5c0.2-0.2,0.5-0.2,0.7,0l7.5,7.5c0.2,0.2,0.5,0.3,0.7,0.3s0.5-0.1,0.7-0.3l1.4-1.4c0.2-0.2,0.3-0.5,0.3-0.7 s-0.1-0.5-0.3-0.7L14.1,11.3z"/>+</svg>`;++@customElement("or-header")+class OrHeader extends LitElement {++ @property({type: Boolean})+ private _drawerOpened = false;++ @property({type: String})+ private logo = "";++ static styles = css`+ #app-header {+ position: absolute;+ top: 0;+ left: 0;+ width: 100%;+ height: 60px;+ text-align: center;+ background-color: var(--app-header-background-color);+ color: var(--app-header-text-color);+ z-index: 9999999;+ box-shadow: 0px 0px 5px 0px rgba(0,0,0,0.57);+ }++ .toolbar-top {+ display: flex;+ background-color: var(--app-header-background-color);+ padding: 0;+ }++ #logo {+ height: 60px;+ display: block;+ }++ slot[name="desktop-right"] {+ display: none;+ }++ slot[name="desktop-right"]{+ margin-left: auto;+ margin-right: 20px;+ }++ app-drawer {+ z-index: 999999;+ position: absolute;+ top: 60px;+ width: 100%;+ height: calc(100% - 60px);+ transition: all 300ms ease-in;+ transition-property: -webkit-transform;+ transition-property: transform;+ -webkit-transform: translate3d(0, -100%, 0);+ transform: translate3d(0, -100%, 0);+ }++ app-drawer[opened] {+ -webkit-transform: translate3d(0, 0, 0);+ transform: translate3d(0, 0, 0);+ }++ .menu-btn {+ background: none;+ border: none;+ fill: var(--app-header-text-color);+ cursor: pointer;+ height: 40px;+ width: 40px;+ margin: 10px 0 10px auto;+ }++ .menu-btn svg {+ width: 24px;+ height: 24px;+ }+ .menu-btn svg,+ .menu-btn svg path {+ fill: #FFF;+ }++ .drawer-list {+ box-sizing: border-box;+ width: 100%;+ height: 100%;+ padding: 24px;+ background: var(--app-drawer-background-color);+ position: relative;+ }++ /* Wide layout: when the viewport width is bigger than 460px, layout+ changes to a wide layout. */+ @media (min-width: 460px) {+ .menu-btn {+ display: none;+ }+ slot[name="desktop-left"],+ slot[name="desktop-right"] {+ display: block;+ }+ }+ `;++ protected render() {+ return html`+ <!-- Header -->+ <div id="app-header">+ <div class="toolbar-top">+ <div><img id="logo" src="${this.logo}" /></div>+ <!-- This gets hidden on a small screen-->++ <nav class="toolbar-list">+ <slot name="desktop-left"></slot>+ </nav>++ <slot name="desktop-right"></slot>++ <button class="menu-btn" title="Menu" @click="${this._menuButtonClicked}">${this._drawerOpened ? close : menu}</button>+ </div>+ </div>++ <app-drawer ?opened="${this._drawerOpened}" @click="${this._close}">+ <nav class="drawer-list">+ <slot name="mobile-top"></slot>++ <slot name="mobile-bottom"></slot>+ </nav>+ </app-drawer>++ `;+ }++ private _close() {+ this._drawerOpened = false;+ }++ private _menuButtonClicked() {+ this._drawerOpened = !this._drawerOpened;+ }+}diff --git a/ui/component/or-thermostat/tsconfig.json b/ui/component/or-thermostat/tsconfig.jsonnew file mode 100644index 000000000..aa12a532d--- /dev/null+++ b/ui/component/or-thermostat/tsconfig.json@@ -0,0 +1,14 @@+{+ "extends": "../../tsconfig",+ "compilerOptions": {+ "outDir": "./dist/",+ "rootDir": "src"+ },+ "include": [+ "./src"+ ],+ "references": [+ { "path": "../core" },+ { "path": "../rest" }+ ]+}\ No newline at end of filediff --git a/ui/demo/demo-or-thermostat/.gitignore b/ui/demo/demo-or-thermostat/.gitignorenew file mode 100644index 000000000..9fde23e0a--- /dev/null+++ b/ui/demo/demo-or-thermostat/.gitignore@@ -0,0 +1,3 @@+src/**/*.d.ts+src/**/*.js.map+src/**/*.js\ No newline at end of filediff --git a/ui/demo/demo-or-thermostat/babel.config.js b/ui/demo/demo-or-thermostat/babel.config.jsnew file mode 100644index 000000000..a12d41ed6--- /dev/null+++ b/ui/demo/demo-or-thermostat/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/demo/demo-or-thermostat/build.gradle b/ui/demo/demo-or-thermostat/build.gradlenew file mode 100644index 000000000..694777f3a--- /dev/null+++ b/ui/demo/demo-or-thermostat/build.gradle@@ -0,0 +1,9 @@+buildDir = "dist"++task build {+ dependsOn rootProject.tasks.getByName("yarnInstall"), npmBuild+}++task clean() {+ dependsOn npmClean+}\ No newline at end of filediff --git a/ui/demo/demo-or-thermostat/index.html b/ui/demo/demo-or-thermostat/index.htmlnew file mode 100644index 000000000..d1afaa7b9--- /dev/null+++ b/ui/demo/demo-or-thermostat/index.html@@ -0,0 +1,59 @@+<!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>Demo</title>++ <!--+ 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 -->++ <custom-style>+ <style is="custom-style" include="demo-pages-shared-styles">+ </style>+ </custom-style>+</head>+<body>+<div class="vertical-section-container centered">+ <h3>Demo</h3>+ <demo-snippet>+ <template>+ <or-map type="RASTER" style="height: 500px; width: 100%;">+ <or-map-marker lat="51.4403423" lng="5.4679712" click-action="showCard" class="marker"></or-map-marker>+ </or-map>+ <or-map style="height: 500px; width: 100%;">+ <or-map-marker lat="51.4403423" lng="5.4679712" click-action="showCard" class="marker"></or-map-marker>+ </or-map>+ </template>+ </demo-snippet>+</div>++<!--+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/demo/demo-or-thermostat/package.json b/ui/demo/demo-or-thermostat/package.jsonnew file mode 100644index 000000000..b0acd4e1e--- /dev/null+++ b/ui/demo/demo-or-thermostat/package.json@@ -0,0 +1,44 @@+{+ "name": "@openremote/demo-or-thermostat",+ "version": "1.0.0",+ "description": "Component Demo",+ "scripts": {+ "clean": "npx shx rm -rf dist",+ "build": "npx tsc -b && npx cross-env NODE_ENV=production webpack",+ "serve": "npx webpack-dev-server",+ "test": "echo \"Error: no test specified\" && exit 1"+ },+ "author": "OpenRemote",+ "license": "AGPL-3.0-or-later",+ "dependencies": {+ "@openremote/or-map": "^1.0.0-alpha",+ "source-map-loader": "^0.2.4"+ },+ "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",+ "html-webpack-plugin": "^3.2.0",+ "source-map-loader": "^0.2.4",+ "style-loader": "^0.23.1",+ "css-loader": "^2.0.0",+ "fast-async": "^6.3.8",+ "file-loader": "^2.0.0",+ "raw-loader": "^0.5.1",+ "cross-env": "^5.2.0",+ "shx": "^0.3.2",+ "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",+ "@polymer/iron-demo-helpers": "^3.0.0-pre.19"+ }+}diff --git a/ui/demo/demo-or-thermostat/src/index.ts b/ui/demo/demo-or-thermostat/src/index.tsnew file mode 100644index 000000000..4262a2296--- /dev/null+++ b/ui/demo/demo-or-thermostat/src/index.ts@@ -0,0 +1,13 @@+import '@polymer/iron-demo-helpers/demo-pages-shared-styles';+import '@polymer/iron-demo-helpers/demo-snippet';+import "@openremote/or-map";+import "@openremote/or-map/dist/markers/or-map-marker";+import openremote, {Auth} from "@openremote/core";++openremote.init({+ auth: Auth.KEYCLOAK,+ autoLogin: true,+ keycloakUrl: "http://localhost:8080/auth",+ managerUrl: "http://localhost:8080",+ realm: "tenantA"+});diff --git a/ui/demo/demo-or-thermostat/tsconfig.json b/ui/demo/demo-or-thermostat/tsconfig.jsonnew file mode 100644index 000000000..dfd8967a0--- /dev/null+++ b/ui/demo/demo-or-thermostat/tsconfig.json@@ -0,0 +1,10 @@+{+ "extends": "../../tsconfig",+ "include": [+ "./src"+ ],+ "references": [+ { "path": "../../component/core" },+ { "path": "../../component/rest" }+ ]+}\ No newline at end of filediff --git a/ui/demo/demo-or-thermostat/webpack.config.js b/ui/demo/demo-or-thermostat/webpack.config.jsnew file mode 100644index 000000000..b577a324a--- /dev/null+++ b/ui/demo/demo-or-thermostat/webpack.config.js@@ -0,0 +1,72 @@+var HtmlWebpackPlugin = require("html-webpack-plugin");+var path = require("path");+var CopyWebpackPlugin = require("copy-webpack-plugin");++module.exports = {+ mode: 'development',+ entry: {+ 'bundle': './src/index.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: [+ new HtmlWebpackPlugin({+ chunksSortMode: 'none',+ inject: false,+ template: 'index.html'+ }),+ new CopyWebpackPlugin([+ {+ from: path.dirname(require.resolve("@webcomponents/webcomponentsjs")),+ to: "modules/@webcomponents/webcomponentsjs",+ ignore: "!*.js"+ }+ ])+ ],+ 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-html|lit-element|@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+ }+ }+ ]+ }+};\ No newline at end of file