From e1c83422dc45424676157f518bb56975b1bbdf5b Mon Sep 17 00:00:00 2001 From: uwap Date: Tue, 7 Nov 2017 20:48:03 +0100 Subject: [PATCH 01/10] Fix type error in rzl config --- config/rzl.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/rzl.js b/config/rzl.js index 6342361..eb19a65 100644 --- a/config/rzl.js +++ b/config/rzl.js @@ -61,8 +61,8 @@ const config : Config = { onkyo_connection: { state: "/service/onkyo/connected", command: "", - defaultValue: 0, - values: { disconnected: 0, connecting: 1, connected: 2 }, + defaultValue: "0", + values: { disconnected: "0", connecting: "1", connected: "2" }, }, onkyo_power: { state: "/service/onkyo/status/system-power", From c1ed43ee6c2f1254d436e607b4bbb0478e2e5d1c Mon Sep 17 00:00:00 2001 From: uwap Date: Fri, 19 Jan 2018 16:20:10 +0100 Subject: [PATCH 02/10] Cleanup flow types and fix eslint errors --- src/components/ControlMap.js | 10 +-- src/components/UiItemList/UiItem.js | 67 +++++++++++----- src/components/UiItemList/index.js | 114 ++++------------------------ types/types.js | 74 ++++++++++++------ 4 files changed, 118 insertions(+), 147 deletions(-) diff --git a/src/components/ControlMap.js b/src/components/ControlMap.js index 81dafcd..7c08afe 100644 --- a/src/components/ControlMap.js +++ b/src/components/ControlMap.js @@ -7,7 +7,7 @@ import parseIconName, { controlGetIcon } from "utils/parseIconName"; export type Point = [number, number]; -const convertPoint = ([y,x]: Point): Point => [-x, y]; +const convertPoint = ([y, x]: Point): Point => [-x, y]; export type ControlMapProps = { width: number, @@ -58,12 +58,10 @@ export default class ControlMap extends React.Component { } iconColor(control: Control): string { + const ints = _.mapValues(this.props.state, (x) => x.internal || x.actual); + const acts = _.mapValues(this.props.state, (x) => x.actual); if (control.iconColor != null) { - return control.iconColor( - _.mapValues(this.props.state, (x) => x.internal || x.actual), - _.mapValues(this.props.state, (x) => x.actual), - this.props.state - ); + return control.iconColor(ints, acts, this.props.state); } return "#000"; } diff --git a/src/components/UiItemList/UiItem.js b/src/components/UiItemList/UiItem.js index 8cb7d01..983495d 100644 --- a/src/components/UiItemList/UiItem.js +++ b/src/components/UiItemList/UiItem.js @@ -21,7 +21,7 @@ type UiItemProps = { onChangeState: (topic: string, nextState: any) => void }; -export default class UiItem extends React.Component> { +export default class UiItem extends React.Component> { constructor(props: UiItemProps) { super(props); } @@ -30,48 +30,79 @@ export default class UiItem extends React.Component> { } + render() { + return null; + } + + /* + * TODO: The type system can't really check if the enableCondition is of + * any function type or if it is a TopicDependentOption or a + * StateDependentOption. This should be fixed. + */ + isEnabled() { + if (Object.keys(this.props.item).includes("enableCondition") && + typeof this.props.item.enableCondition == "function") { + const enableCondition = this.props.item.enableCondition; + const state = this.props.state; + const internals = _.mapValues(state, (x) => x.internal); + const actuals = _.mapValues(state, (x) => x.actual); + return enableCondition(internals, actuals, state); + } else { + return true; + } + } +} + +export class UiControl extends UiItem { + constructor(props: UiItemProps) { + super(props); + } + changeState(next: any) { if (this.props.item.topic == null) { throw new Error( - `Undefined topic in ${this.props.item.type} "${this.props.item.text}"` + `Missing topic in ${this.props.item.type} "${this.props.item.text}"` ); } this.props.onChangeState(this.props.item.topic, next); } getValue() { - const topic: string = this.props.item.topic || ""; + const control = this.props.item; + const topic: string = control.topic || ""; const value = this.props.state[topic]; if (value == null) { - const control = this.props.item; + if (topic === "") { + throw new Error( + `Missing topic in ${control.type} "${control.text}"` + ); + } throw new Error( - `Unknown topic "${control.topic}" in ${control.type} "${control.text}"` + `Unknown topic "${topic}" in ${control.type} "${control.text}"` ); } return value; } isEnabled() { - const enableCondition = this.props.item.enableCondition; - if (enableCondition == null) { - return true; - } else { + if (Object.keys(this.props.item).includes("enableCondition") && + typeof this.props.item.enableCondition == "function") { + const enableCondition = this.props.item.enableCondition; const value = this.getValue(); return enableCondition( value.internal || value.actual, value.actual, this.props.state); + } else { + return true; } } - - render() { - return null; - } } -export class Toggle extends UiItem { +export class Toggle extends UiControl { isToggled = () => { const value = this.getValue(); const control = this.props.item; - const isChecked = control.toggled || ((i) => i === (control.on || "on")); + const isChecked = control.toggled || + ((i, _a, _s) => i === (control.on || "on")); const checked = isChecked( value.internal || value.actual, value.actual, this.props.state); return checked; @@ -99,7 +130,7 @@ export class Toggle extends UiItem { } } -export class DropDown extends UiItem { +export class DropDown extends UiControl { runPrimaryAction = (next?: any) => { if (this.isEnabled()) { const control = this.props.item; @@ -117,7 +148,7 @@ export class DropDown extends UiItem { render() { const control = this.props.item; const value = this.getValue(); - const id = `${control.topic}-${control.name}`; + const id = `${control.topic}-${control.text}`; const options = control.options; if (options == null) { throw new Error( @@ -173,7 +204,7 @@ export class Section extends UiItem { } } -export class Text extends UiItem { +export class Text extends UiControl { render() { return [ , diff --git a/src/components/UiItemList/index.js b/src/components/UiItemList/index.js index d6e3d8f..f089113 100644 --- a/src/components/UiItemList/index.js +++ b/src/components/UiItemList/index.js @@ -5,16 +5,9 @@ import { ListItem, ListItemIcon, ListItemSecondaryAction, - ListItemText, - ListSubheader + ListItemText } from "material-ui/List"; -import Switch from "material-ui/Switch"; import { renderIcon } from "utils/parseIconName"; -import Input, { InputLabel } from "material-ui/Input"; -import { FormControl } from "material-ui/Form"; -import Select from "material-ui/Select"; -import { MenuItem } from "material-ui/Menu"; -import Button from "material-ui/Button"; // TODO: Use something else import Slider from "material-ui-old/Slider"; @@ -57,31 +50,31 @@ export default class UiItemList extends React.Component { switch (control.type) { case "toggle": { return ; + state={this.props.state} + onChangeState={this.props.onChangeState} />; } case "dropDown": { return ; + state={this.props.state} + onChangeState={this.props.onChangeState} />; } case "section": { return
; + state={this.props.state} + onChangeState={this.props.onChangeState} />; } case "link": { return ; + state={this.props.state} + onChangeState={this.props.onChangeState} />; } case "slider": { return this.renderSlider(control); } case "text": { return ; + state={this.props.state} + onChangeState={this.props.onChangeState} />; } default: { throw new Error( @@ -91,18 +84,7 @@ export default class UiItemList extends React.Component { } } - isEnabled(control: ControlUI) { - const enableCondition = control.enableCondition; - if (enableCondition == null) { - return true; - } else { - const value = this.getValue(control); - return enableCondition( - value.internal || value.actual, value.actual, this.props.state); - } - } - - getValue(control: ControlUI) { + getValue(control: UIControl) { const value = this.props.state[control.topic]; if (value == null) { throw new Error( @@ -112,77 +94,7 @@ export default class UiItemList extends React.Component { return value; } - toggleSwitch(control: ControlUI, newState: boolean) { - this.props.onChangeState(control.topic, - newState ? (control.on || "on") : (control.off || "off")); - } - - renderToggle(control: ControlUI) { - const value = this.getValue(control); - const isToggled = control.toggled || ((i) => i === (control.on || "on")); - const checked = isToggled( - value.internal || value.actual, value.actual, this.props.state); - return [ - , - - this.toggleSwitch(control, state)} - disabled={!this.isEnabled(control)} /> - - ]; - } - - changeDropDown(control: ControlUI, newState: string) { - this.props.onChangeState(control.topic, newState); - } - - renderDropDown(control: ControlUI) { - const value = this.getValue(control); - const id = `${control.topic}-${control.name}`; - const options = control.options; - if (options == null) { - throw new Error( - `Parameter "options" missing for ${control.type} "${control.text}"` - ); - } - return ( - - {control.text} - } - > - {_.map(options, (v, k) => {v})} - - - ); - } - - renderSection(control: ControlUI) { - return ( - {control.text} - ); - } - - renderLink(control: ControlUI) { - if (control.link == null) { - throw new Error( - `Parameter "link" missing for ${control.type} "${control.text}"` - ); - } - return ( - - ); - } - - renderSlider(control: ControlUI) { + renderSlider(control: UISlider) { const value = this.getValue(control); return [ , diff --git a/types/types.js b/types/types.js index caf4ea3..d9b7785 100644 --- a/types/types.js +++ b/types/types.js @@ -13,46 +13,76 @@ declare type Topic = { }; declare type Topics = Map; -declare type UIBase = { - text: string, - topic?: string, - icon?: string, - enableCondition?: (internal: string, actual: any, state: State) => boolean -} +declare type TopicDependentOption = ( + internal: string, actual: any, state: State + ) => T; +declare type StateDependentOption = ( + internals: Map, actuals: Map, state: State + ) => T; -declare type UIToggle = { +interface UIControl { + +type: string, + +text: string, + +topic: string +}; + +interface Enableable { + enableCondition?: TopicDependentOption +}; + +declare type UIToggle = $ReadOnly<{| type: "toggle", + text: string, + topic: string, + icon?: string, + enableCondition?: TopicDependentOption, on?: string, off?: string, - toggled?: (internal: string, actual: any, state: State) => boolean, -} & UIBase; + toggled?: TopicDependentOption +|}>; -declare type UIDropDown = { +declare type UIDropDown = $ReadOnly<{| type: "dropDown", + text: string, + topic: string, + icon?: string, + enableCondition?: TopicDependentOption, options: Map, renderValue?: (value: string) => string -} & UIBase; +|}>; -declare type UISlider = { +declare type UISlider = $ReadOnly<{| type: "slider", + text: string, + topic: string, + icon?: string, + enableCondition?: TopicDependentOption, min?: number, max?: number, step?: number -} & UIBase; +|}>; -declare type UISection = { +declare type UISection = $ReadOnly<{| type: "section", text: string -}; +|}>; -declare type UILink = { +declare type UILink = $ReadOnly<{| type: "link", - link: string -} & UIBase; + text: string, + link: string, + enableCondition?: StateDependentOption, + + // TODO: check if both the following options are implemented + icon?: string +|}>; -declare type UIText = { - type: "text" -} & UIBase; +declare type UIText = $ReadOnly<{| + type: "text", + text: string, + topic: string, + icon?: string +|}>; declare type ControlUI = UIToggle @@ -64,7 +94,7 @@ declare type ControlUI = declare type Control = { name: string, - position: Array, + position: [number, number], icon: string | ( internals: Map, actuals: Map, From cfe8897f2a34fc079cec3794bacbb0aea3ad6943 Mon Sep 17 00:00:00 2001 From: uwap Date: Fri, 19 Jan 2018 16:53:16 +0100 Subject: [PATCH 03/10] Fix all type errors --- src/components/ControlMap.js | 11 +++++++++-- src/components/SideBar.js | 5 +++-- webpack.common.js | 2 +- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/components/ControlMap.js b/src/components/ControlMap.js index 7c08afe..5d4b1a1 100644 --- a/src/components/ControlMap.js +++ b/src/components/ControlMap.js @@ -92,9 +92,16 @@ export default class ControlMap extends React.Component { + checked={layer.defaultVisibility === "visible"} + removeLayer={(_layer) => {}} + removeLayerControl={(_layer) => {}} + addOverlay={(_layer, _name, _checked) => {}} + addBaseLayer={(_layer, _name, _checked) => {}}> ); diff --git a/src/components/SideBar.js b/src/components/SideBar.js index 1aadfa6..164f8fc 100644 --- a/src/components/SideBar.js +++ b/src/components/SideBar.js @@ -1,5 +1,5 @@ // @flow -import React from "react"; +import * as React from "react"; import withStyles from "material-ui/styles/withStyles"; import Drawer from "material-ui/Drawer"; @@ -14,7 +14,8 @@ export type SideBarProps = { control: ?Control, open: boolean, onCloseRequest: () => void, - icon?: ?string + icon?: ?string, + children?: React.Node }; export type SideBarState = { diff --git a/webpack.common.js b/webpack.common.js index 31d08f1..d5457c6 100644 --- a/webpack.common.js +++ b/webpack.common.js @@ -25,7 +25,7 @@ module.exports = { }, plugins: [ new CleanWebpackPlugin(["dist"]), - // new WebpackShellPlugin({onBuildStart:preBuildScripts}), + new WebpackShellPlugin({onBuildStart:preBuildScripts}), new HtmlWebpackPlugin({ title: 'Space Map', template: 'index.ejs' From 4b8b18515e175a10d07fa72d525b72622dcd656b Mon Sep 17 00:00:00 2001 From: uwap Date: Fri, 19 Jan 2018 16:58:02 +0100 Subject: [PATCH 04/10] fix flowconfig --- .flowconfig | 3 --- 1 file changed, 3 deletions(-) diff --git a/.flowconfig b/.flowconfig index 83cd117..de8b8f6 100644 --- a/.flowconfig +++ b/.flowconfig @@ -11,6 +11,3 @@ esproposal.export_star_as=enable unsafe.enable_getters_and_setters=true module.system.node.resolve_dirname=node_modules module.system.node.resolve_dirname=src - -[lints] -all=warn From 41cf23041df7b30e996919d4c9dfc1cd9a8b9a43 Mon Sep 17 00:00:00 2001 From: uwap Date: Fri, 19 Jan 2018 17:07:31 +0100 Subject: [PATCH 05/10] Upgrade all dependencies --- package.json | 10 ++-- yarn.lock | 158 +++++++++++++++++++++++++++------------------------ 2 files changed, 89 insertions(+), 79 deletions(-) diff --git a/package.json b/package.json index 24c4b49..bcf96bb 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ }, "dependencies": { "babel-preset-env": "^1.6.0", - "leaflet": "^1.2.0", + "leaflet": "^1.3.1", "lodash": "^4.17.4", "material-ui": "npm:material-ui@next", "material-ui-old": "npm:material-ui@latest", @@ -21,7 +21,7 @@ "mqtt": "^2.14.0", "react": "^16.0.0", "react-dom": "^16.0.0", - "react-leaflet": "^1.5.0", + "react-leaflet": "^1.8.0", "react-tap-event-plugin": "^3.0.0", "redux": "^3.7.2" }, @@ -33,20 +33,20 @@ "babel-plugin-transform-class-properties": "^6.24.1", "babel-preset-react": "^6.24.1", "clean-webpack-plugin": "^0.1.17", - "css-loader": "^0.28.7", + "css-loader": "^0.28.9", "eslint": "^4.10.0", "eslint-plugin-flowtype": "^2.39.1", "eslint-plugin-react": "^7.4.0", "extract-text-webpack-plugin": "^3.0.2", "file-loader": "^1.1.5", "flow": "^0.2.3", - "flow-bin": "^0.50.0", + "flow-bin": "^0.63.1", "flow-typed": "^2.2.1", "html-webpack-plugin": "^2.30.1", "husky": "^0.14.3", "style-loader": "^0.19.0", "webpack": "^3.1.0", - "webpack-dev-server": "^2.9.4", + "webpack-dev-server": "^2.11.0", "webpack-merge": "^4.1.1", "webpack-shell-plugin": "^0.5.0" }, diff --git a/yarn.lock b/yarn.lock index 6708b53..a7558e7 100644 --- a/yarn.lock +++ b/yarn.lock @@ -54,6 +54,20 @@ lodash "^4.2.0" to-fast-properties "^2.0.0" +"@types/jss@^9.3.0": + version "9.3.0" + resolved "https://registry.yarnpkg.com/@types/jss/-/jss-9.3.0.tgz#0f8484fd03ded206917be27b58217f274a0ad59f" + +"@types/react-transition-group@^2.0.6": + version "2.0.6" + resolved "https://registry.yarnpkg.com/@types/react-transition-group/-/react-transition-group-2.0.6.tgz#8903fa2cf540ba454461590bff811a787889617c" + dependencies: + "@types/react" "*" + +"@types/react@*": + version "16.0.34" + resolved "https://registry.yarnpkg.com/@types/react/-/react-16.0.34.tgz#7a8f795afd8a404a9c4af9539b24c75d3996914e" + abbrev@1: version "1.1.1" resolved "https://registry.yarnpkg.com/abbrev/-/abbrev-1.1.1.tgz#f8f2c887ad10bf67f634f005b6987fed3179aac8" @@ -1131,10 +1145,10 @@ browserslist@^1.3.6, browserslist@^1.5.2, browserslist@^1.7.6: electron-to-chromium "^1.2.7" browserslist@^2.1.2: - version "2.11.1" - resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-2.11.1.tgz#02fda29d9a2164b879100126e7b0d0b57e43a7bb" + version "2.11.3" + resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-2.11.3.tgz#fe36167aed1bbcde4827ebfe71347a2cc70b99b2" dependencies: - caniuse-lite "^1.0.30000789" + caniuse-lite "^1.0.30000792" electron-to-chromium "^1.3.30" buffer-indexof@^1.0.0: @@ -1240,12 +1254,12 @@ caniuse-api@^1.5.2: lodash.uniq "^4.5.0" caniuse-db@^1.0.30000529, caniuse-db@^1.0.30000634, caniuse-db@^1.0.30000639: - version "1.0.30000791" - resolved "https://registry.yarnpkg.com/caniuse-db/-/caniuse-db-1.0.30000791.tgz#06787f56caef4300a17e35d137447123bdf536f9" + version "1.0.30000793" + resolved "https://registry.yarnpkg.com/caniuse-db/-/caniuse-db-1.0.30000793.tgz#3c00c66e423a7a1907c7dd96769a78b2afa8a72e" -caniuse-lite@^1.0.30000789: - version "1.0.30000791" - resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30000791.tgz#8e35745efd483a3e23bb7d350990326d2319fc16" +caniuse-lite@^1.0.30000792: + version "1.0.30000792" + resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30000792.tgz#d0cea981f8118f3961471afbb43c9a1e5bbf0332" caseless@~0.12.0: version "0.12.0" @@ -1653,9 +1667,9 @@ css-in-js-utils@^2.0.0: dependencies: hyphenate-style-name "^1.0.2" -css-loader@^0.28.7: - version "0.28.8" - resolved "https://registry.yarnpkg.com/css-loader/-/css-loader-0.28.8.tgz#ff36381464dea18fe60f2601a060ba6445886bd5" +css-loader@^0.28.9: + version "0.28.9" + resolved "https://registry.yarnpkg.com/css-loader/-/css-loader-0.28.9.tgz#68064b85f4e271d7ce4c48a58300928e535d1c95" dependencies: babel-code-frame "^6.26.0" css-selector-tokenizer "^0.7.0" @@ -1665,7 +1679,7 @@ css-loader@^0.28.7: lodash.camelcase "^4.3.0" object-assign "^4.1.1" postcss "^5.0.6" - postcss-modules-extract-imports "^1.1.0" + postcss-modules-extract-imports "^1.2.0" postcss-modules-local-by-default "^1.2.0" postcss-modules-scope "^1.1.0" postcss-modules-values "^1.3.0" @@ -2004,15 +2018,9 @@ ee-first@1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/ee-first/-/ee-first-1.1.1.tgz#590c61156b0ae2f4f0255732a158b266bc56b21d" -electron-releases@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/electron-releases/-/electron-releases-2.1.0.tgz#c5614bf811f176ce3c836e368a0625782341fd4e" - electron-to-chromium@^1.2.7, electron-to-chromium@^1.3.30: - version "1.3.30" - resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.30.tgz#9666f532a64586651fc56a72513692e820d06a80" - dependencies: - electron-releases "^2.1.0" + version "1.3.31" + resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.31.tgz#00d832cba9fe2358652b0c48a8816c8e3a037e9f" elliptic@^6.0.0: version "6.4.0" @@ -2090,13 +2098,13 @@ es-to-primitive@^1.1.1: is-symbol "^1.0.1" es5-ext@^0.10.14, es5-ext@^0.10.35, es5-ext@^0.10.9, es5-ext@~0.10.14: - version "0.10.37" - resolved "https://registry.yarnpkg.com/es5-ext/-/es5-ext-0.10.37.tgz#0ee741d148b80069ba27d020393756af257defc3" + version "0.10.38" + resolved "https://registry.yarnpkg.com/es5-ext/-/es5-ext-0.10.38.tgz#fa7d40d65bbc9bb8a67e1d3f9cc656a00530eed3" dependencies: - es6-iterator "~2.0.1" + es6-iterator "~2.0.3" es6-symbol "~3.1.1" -es6-iterator@^2.0.1, es6-iterator@~2.0.1: +es6-iterator@^2.0.1, es6-iterator@~2.0.1, es6-iterator@~2.0.3: version "2.0.3" resolved "https://registry.yarnpkg.com/es6-iterator/-/es6-iterator-2.0.3.tgz#a7de889141a05a94b0854403b2d0a0fbfa98f3b7" dependencies: @@ -2555,9 +2563,9 @@ flatten@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/flatten/-/flatten-1.0.2.tgz#dae46a9d78fbe25292258cc1e780a41d95c03782" -flow-bin@^0.50.0: - version "0.50.0" - resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.50.0.tgz#d4cdb2430dee1a3599f0eb6fe551146e3027256a" +flow-bin@^0.63.1: + version "0.63.1" + resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.63.1.tgz#ab00067c197169a5fb5b4996c8f6927b06694828" flow-typed@^2.2.1: version "2.2.3" @@ -3561,8 +3569,8 @@ isurl@^1.0.0-alpha5: is-object "^1.0.1" js-base64@^2.1.9: - version "2.4.0" - resolved "https://registry.yarnpkg.com/js-base64/-/js-base64-2.4.0.tgz#9e566fee624751a1d720c966cd6226d29d4025aa" + version "2.4.1" + resolved "https://registry.yarnpkg.com/js-base64/-/js-base64-2.4.1.tgz#e02813181cd53002888e918935467acb2910e596" js-tokens@^3.0.0, js-tokens@^3.0.2: version "3.0.2" @@ -3657,15 +3665,15 @@ jss-compose@^5.0.0: dependencies: warning "^3.0.0" -jss-default-unit@^8.0.0, jss-default-unit@^8.0.2: +jss-default-unit@^8.0.2: version "8.0.2" resolved "https://registry.yarnpkg.com/jss-default-unit/-/jss-default-unit-8.0.2.tgz#cc1e889bae4c0b9419327b314ab1c8e2826890e6" -jss-expand@^5.0.0: +jss-expand@^5.1.0: version "5.1.0" resolved "https://registry.yarnpkg.com/jss-expand/-/jss-expand-5.1.0.tgz#b1ad74ec18631f34f65a2124fcfceb6400610e3d" -jss-extend@^6.0.1: +jss-extend@^6.1.0: version "6.1.0" resolved "https://registry.yarnpkg.com/jss-extend/-/jss-extend-6.1.0.tgz#85f3d39944018e8f44b322c14fa316068aa7bb0b" dependencies: @@ -3682,27 +3690,27 @@ jss-nested@^6.0.1: warning "^3.0.0" jss-preset-default@^4.0.1: - version "4.0.1" - resolved "https://registry.yarnpkg.com/jss-preset-default/-/jss-preset-default-4.0.1.tgz#822cecb87c27ff91633774422f4c221d61486b65" + version "4.1.0" + resolved "https://registry.yarnpkg.com/jss-preset-default/-/jss-preset-default-4.1.0.tgz#8a07d8de92cb0c55b70dc1919b802aed9cc4ebe9" dependencies: jss-camel-case "^6.0.0" jss-compose "^5.0.0" - jss-default-unit "^8.0.0" - jss-expand "^5.0.0" - jss-extend "^6.0.1" + jss-default-unit "^8.0.2" + jss-expand "^5.1.0" + jss-extend "^6.1.0" jss-global "^3.0.0" jss-nested "^6.0.1" jss-props-sort "^6.0.0" - jss-template "^1.0.0" + jss-template "^1.0.1" jss-vendor-prefixer "^7.0.0" jss-props-sort@^6.0.0: version "6.0.0" resolved "https://registry.yarnpkg.com/jss-props-sort/-/jss-props-sort-6.0.0.tgz#9105101a3b5071fab61e2d85ea74cc22e9b16323" -jss-template@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/jss-template/-/jss-template-1.0.0.tgz#4b874608706ddceecacdb5567e254aecb6ea69b3" +jss-template@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/jss-template/-/jss-template-1.0.1.tgz#09aed9d86cc547b07f53ef355d7e1777f7da430a" dependencies: warning "^3.0.0" @@ -3770,9 +3778,9 @@ lcid@^1.0.0: dependencies: invert-kv "^1.0.0" -leaflet@^1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/leaflet/-/leaflet-1.2.0.tgz#fd5d93d9cb00091f5f8a69206d0d6744c1c82697" +leaflet@^1.3.1: + version "1.3.1" + resolved "https://registry.yarnpkg.com/leaflet/-/leaflet-1.3.1.tgz#86f336d2fb0e2d0ff446677049a5dc34cf0ea60e" leven@^1.0.0: version "1.0.2" @@ -3931,7 +3939,7 @@ map-visit@^1.0.0: buffers "~0.1.1" readable-stream "~1.0.0" -"material-ui-old@npm:material-ui@latest": +"material-ui-old@npm:material-ui@latest", "material-ui@npm:material-ui@latest": version "0.20.0" resolved "https://registry.yarnpkg.com/material-ui/-/material-ui-0.20.0.tgz#85411bb59c916c9c7703f29dcffc44e3a67d5111" dependencies: @@ -3948,9 +3956,11 @@ map-visit@^1.0.0: warning "^3.0.0" "material-ui@npm:material-ui@next": - version "1.0.0-beta.27" - resolved "https://registry.yarnpkg.com/material-ui/-/material-ui-1.0.0-beta.27.tgz#f3073b7acffebd1fc6d0339a3260d4555445daf7" + version "1.0.0-beta.29" + resolved "https://registry.yarnpkg.com/material-ui/-/material-ui-1.0.0-beta.29.tgz#21ddf110d7aae4a6582584fc10ce948f144b1f2b" dependencies: + "@types/jss" "^9.3.0" + "@types/react-transition-group" "^2.0.6" babel-runtime "^6.26.0" brcast "^3.0.1" classnames "^2.2.5" @@ -4190,8 +4200,8 @@ multicast-dns-service-types@^1.1.0: resolved "https://registry.yarnpkg.com/multicast-dns-service-types/-/multicast-dns-service-types-1.1.0.tgz#899f11d9686e5e05cb91b35d5f0e63b773cfc901" multicast-dns@^6.0.1: - version "6.2.1" - resolved "https://registry.yarnpkg.com/multicast-dns/-/multicast-dns-6.2.1.tgz#c5035defa9219d30640558a49298067352098060" + version "6.2.2" + resolved "https://registry.yarnpkg.com/multicast-dns/-/multicast-dns-6.2.2.tgz#300b6133361f8aaaf2b8d1248e85c363fe5b95a0" dependencies: dns-packet "^1.0.1" thunky "^0.1.0" @@ -4437,8 +4447,8 @@ onetime@^2.0.0: mimic-fn "^1.0.0" opn@^5.1.0: - version "5.1.0" - resolved "https://registry.yarnpkg.com/opn/-/opn-5.1.0.tgz#72ce2306a17dbea58ff1041853352b4a8fc77519" + version "5.2.0" + resolved "https://registry.yarnpkg.com/opn/-/opn-5.2.0.tgz#71fdf934d6827d676cecbea1531f95d354641225" dependencies: is-wsl "^1.1.0" @@ -4819,9 +4829,9 @@ postcss-minify-selectors@^2.0.4: postcss "^5.0.14" postcss-selector-parser "^2.0.0" -postcss-modules-extract-imports@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/postcss-modules-extract-imports/-/postcss-modules-extract-imports-1.1.0.tgz#b614c9720be6816eaee35fb3a5faa1dba6a05ddb" +postcss-modules-extract-imports@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/postcss-modules-extract-imports/-/postcss-modules-extract-imports-1.2.0.tgz#66140ecece38ef06bf0d3e355d69bf59d141ea85" dependencies: postcss "^6.0.1" @@ -5038,8 +5048,8 @@ pump@^2.0.0: once "^1.3.1" pumpify@^1.3.5: - version "1.3.6" - resolved "https://registry.yarnpkg.com/pumpify/-/pumpify-1.3.6.tgz#00d40e5ded0a3bf1e0788b1c0cf426a42882ab64" + version "1.4.0" + resolved "https://registry.yarnpkg.com/pumpify/-/pumpify-1.4.0.tgz#80b7c5df7e24153d03f0e7ac8a05a5d068bd07fb" dependencies: duplexify "^3.5.3" inherits "^2.0.3" @@ -5128,8 +5138,8 @@ raw-body@2.3.2: unpipe "1.0.0" rc@^1.1.7: - version "1.2.3" - resolved "https://registry.yarnpkg.com/rc/-/rc-1.2.3.tgz#51575a900f8dd68381c710b4712c2154c3e2035b" + version "1.2.4" + resolved "https://registry.yarnpkg.com/rc/-/rc-1.2.4.tgz#a0f606caae2a3b862bbd0ef85482c0125b315fa3" dependencies: deep-extend "~0.4.0" ini "~1.3.0" @@ -5164,9 +5174,9 @@ react-jss@^8.1.0: prop-types "^15.6.0" theming "^1.3.0" -react-leaflet@^1.5.0: - version "1.7.8" - resolved "https://registry.yarnpkg.com/react-leaflet/-/react-leaflet-1.7.8.tgz#5b58be948a7e2efe5c302a65746c9e8b25477c59" +react-leaflet@^1.8.0: + version "1.8.0" + resolved "https://registry.yarnpkg.com/react-leaflet/-/react-leaflet-1.8.0.tgz#e33ba704910e2ad86dd29b5a4a52acb7030fe2c4" dependencies: lodash "^4.0.0" lodash-es "^4.0.0" @@ -5262,7 +5272,7 @@ readable-stream@1.0, readable-stream@~1.0.0, readable-stream@~1.0.31: isarray "0.0.1" string_decoder "~0.10.x" -"readable-stream@> 1.0.0 < 3.0.0", readable-stream@^2.0.0, readable-stream@^2.0.1, readable-stream@^2.0.2, readable-stream@^2.0.5, readable-stream@^2.0.6, readable-stream@^2.1.4, readable-stream@^2.1.5, readable-stream@^2.2.2, readable-stream@^2.2.6, readable-stream@^2.2.9, readable-stream@^2.3.3: +"readable-stream@> 1.0.0 < 3.0.0", readable-stream@^2.0.0, readable-stream@^2.0.1, readable-stream@^2.0.2, readable-stream@^2.0.5, readable-stream@^2.0.6, readable-stream@^2.1.4, readable-stream@^2.1.5, readable-stream@^2.2.2, readable-stream@^2.2.9, readable-stream@^2.3.3: version "2.3.3" resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.3.3.tgz#368f2512d79f9d46fdfc71349ae7878bbc1eb95c" dependencies: @@ -5580,8 +5590,8 @@ selfsigned@^1.9.1: node-forge "0.6.33" "semver@2 || 3 || 4 || 5", semver@^5.1.0, semver@^5.3.0: - version "5.4.1" - resolved "https://registry.yarnpkg.com/semver/-/semver-5.4.1.tgz#e059c09d8571f0540823733433505d3a2f00b18e" + version "5.5.0" + resolved "https://registry.yarnpkg.com/semver/-/semver-5.5.0.tgz#dc4bbc7a6ca9d916dee5d43516f0092b58f7b8ab" send@0.16.1: version "0.16.1" @@ -5892,12 +5902,12 @@ stream-browserify@^2.0.1: readable-stream "^2.0.2" stream-http@^2.7.2: - version "2.7.2" - resolved "https://registry.yarnpkg.com/stream-http/-/stream-http-2.7.2.tgz#40a050ec8dc3b53b33d9909415c02c0bf1abfbad" + version "2.8.0" + resolved "https://registry.yarnpkg.com/stream-http/-/stream-http-2.8.0.tgz#fd86546dac9b1c91aff8fc5d287b98fafb41bc10" dependencies: builtin-status-codes "^3.0.0" inherits "^2.0.1" - readable-stream "^2.2.6" + readable-stream "^2.3.3" to-arraybuffer "^1.0.0" xtend "^4.0.0" @@ -6212,8 +6222,8 @@ ua-parser-js@^0.7.9: resolved "https://registry.yarnpkg.com/ua-parser-js/-/ua-parser-js-0.7.17.tgz#e9ec5f9498b9ec910e7ae3ac626a805c4d09ecac" uglify-js@3.3.x: - version "3.3.6" - resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.3.6.tgz#3ca624e713f1981df455d72a02ab6ffe632b5d2d" + version "3.3.7" + resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.3.7.tgz#28463e7c7451f89061d2b235e30925bf5625e14d" dependencies: commander "~2.13.0" source-map "~0.6.1" @@ -6381,8 +6391,8 @@ utils-merge@1.0.1: resolved "https://registry.yarnpkg.com/utils-merge/-/utils-merge-1.0.1.tgz#9f95710f50a267947b2ccc124741c1028427e713" uuid@^3.0.0, uuid@^3.0.1, uuid@^3.1.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.1.0.tgz#3dd3d3e790abc24d7b0d3a034ffababe28ebbc04" + version "3.2.1" + resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.2.1.tgz#12c528bb9d58d0b9265d9a2f6f0fe8be17ff1f14" v8flags@^2.1.1: version "2.1.1" @@ -6449,9 +6459,9 @@ webpack-dev-middleware@1.12.2: range-parser "^1.0.3" time-stamp "^2.0.0" -webpack-dev-server@^2.9.4: - version "2.10.1" - resolved "https://registry.yarnpkg.com/webpack-dev-server/-/webpack-dev-server-2.10.1.tgz#a9768375346e62155860fe3cef3d4d641b24273e" +webpack-dev-server@^2.11.0: + version "2.11.0" + resolved "https://registry.yarnpkg.com/webpack-dev-server/-/webpack-dev-server-2.11.0.tgz#e9d4830ab7eb16c6f92ed68b92f6089027960e1b" dependencies: ansi-html "0.0.7" array-includes "^3.0.3" From a5668b1f9501e8aca3b93acfdc11e05ba65c4124 Mon Sep 17 00:00:00 2001 From: uwap Date: Fri, 19 Jan 2018 17:26:07 +0100 Subject: [PATCH 06/10] Change travis build --- .flowconfig | 1 - .travis.yml | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.flowconfig b/.flowconfig index de8b8f6..267709e 100644 --- a/.flowconfig +++ b/.flowconfig @@ -8,6 +8,5 @@ types/types.js [options] esproposal.export_star_as=enable -unsafe.enable_getters_and_setters=true module.system.node.resolve_dirname=node_modules module.system.node.resolve_dirname=src diff --git a/.travis.yml b/.travis.yml index 23cd14c..3687c35 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,8 @@ language: node_js node_js: - - 7 + - 6 - 8 + - 9 script: - yarn travis cache: From 9e7b6558210dd5b48c226a04257636893deb3a56 Mon Sep 17 00:00:00 2001 From: uwap Date: Fri, 19 Jan 2018 21:00:30 +0100 Subject: [PATCH 07/10] RZL: Add Partkeepr Link --- config/rzl.js | 12 ++++++++++++ yarn.lock | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/config/rzl.js b/config/rzl.js index a8a38c0..2cc28ba 100644 --- a/config/rzl.js +++ b/config/rzl.js @@ -393,6 +393,18 @@ const config : Config = { text: "Open Infoscreen" } ] + }, + partkeepr: { + name: "Partkeepr", + position: [48, 450], + icon: "chip", + ui: [ + { + type: "link", + link: "http://partkeepr.rzl/", + text: "Open Partkeepr" + } + ] } }, layers: [ diff --git a/yarn.lock b/yarn.lock index a7558e7..3d77a50 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3939,7 +3939,7 @@ map-visit@^1.0.0: buffers "~0.1.1" readable-stream "~1.0.0" -"material-ui-old@npm:material-ui@latest", "material-ui@npm:material-ui@latest": +"material-ui-old@npm:material-ui@latest": version "0.20.0" resolved "https://registry.yarnpkg.com/material-ui/-/material-ui-0.20.0.tgz#85411bb59c916c9c7703f29dcffc44e3a67d5111" dependencies: From 196aa448953b5b8bbb20534c3ce36c4552980401 Mon Sep 17 00:00:00 2001 From: uwap Date: Fri, 19 Jan 2018 21:21:04 +0100 Subject: [PATCH 08/10] RZL: Change Infoscreen Icon --- config/rzl.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/rzl.js b/config/rzl.js index 2cc28ba..1c85141 100644 --- a/config/rzl.js +++ b/config/rzl.js @@ -378,7 +378,7 @@ const config : Config = { infoscreen: { name: "Infoscreen", position: [255, 495], - icon: "developer-board", + icon: "television-guide", iconColor: ({infoscreen}) => infoscreen == "on" ? "#4444FF" : "#000000", ui: [ { From 8d2d39cb0e10e7809ffbda327ed13602f411824c Mon Sep 17 00:00:00 2001 From: uwap Date: Fri, 19 Jan 2018 21:52:53 +0100 Subject: [PATCH 09/10] Fix most eslint warnings --- .eslintrc.js | 2 +- src/components/App.js | 4 ++-- src/components/UiItemList/UiItem.js | 7 ++++--- src/components/UiItemList/index.js | 2 +- src/utils/parseIconName.js | 11 ++++++----- types/types.js | 2 ++ 6 files changed, 16 insertions(+), 12 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 522ce82..e03c58d 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -137,6 +137,6 @@ module.exports = { // flow "flowtype/no-dupe-keys": "error", "flowtype/no-weak-types": "warn", - "flowtype/require-variable-type": "warn" + "flowtype/require-variable-type": "off" // wait for https://github.com/gajus/eslint-plugin-flowtype/issues/198 to be resolved } }; diff --git a/src/components/App.js b/src/components/App.js index 671fb62..45508f5 100644 --- a/src/components/App.js +++ b/src/components/App.js @@ -25,7 +25,7 @@ export type AppState = { selectedControl: ?Control, drawerOpened: boolean, mqttState: State, - mqttSend: (topic: string, value: any) => void, + mqttSend: (topic: string, value: Actual) => void, mqttConnected: boolean, }; @@ -91,7 +91,7 @@ class App extends React.Component { this.setState({drawerOpened: false}); } - changeState(topic: string, value: any) { + changeState(topic: string, value: Actual) { const rawTopic = this.props.config.topics[topic].command; if (rawTopic == null) { return; diff --git a/src/components/UiItemList/UiItem.js b/src/components/UiItemList/UiItem.js index 983495d..182017c 100644 --- a/src/components/UiItemList/UiItem.js +++ b/src/components/UiItemList/UiItem.js @@ -18,9 +18,10 @@ import keyOf from "utils/keyOf"; type UiItemProps = { item: I, state: State, - onChangeState: (topic: string, nextState: any) => void + onChangeState: (topic: string, nextState: Actual) => void }; +// eslint-disable-next-line flowtype/no-weak-types export default class UiItem extends React.Component> { constructor(props: UiItemProps) { super(props); @@ -58,7 +59,7 @@ export class UiControl extends UiItem { super(props); } - changeState(next: any) { + changeState(next: Actual) { if (this.props.item.topic == null) { throw new Error( `Missing topic in ${this.props.item.type} "${this.props.item.text}"` @@ -131,7 +132,7 @@ export class Toggle extends UiControl { } export class DropDown extends UiControl { - runPrimaryAction = (next?: any) => { + runPrimaryAction = (next?: Actual) => { if (this.isEnabled()) { const control = this.props.item; const keys = _.keys(control.options); diff --git a/src/components/UiItemList/index.js b/src/components/UiItemList/index.js index f089113..d393ba3 100644 --- a/src/components/UiItemList/index.js +++ b/src/components/UiItemList/index.js @@ -18,7 +18,7 @@ import { Toggle, DropDown, Link, Section, Text } from "./UiItem"; export type UiItemListProps = { controls: Array, state: State, - onChangeState: (topic: string, nextState: any) => void + onChangeState: (topic: string, nextState: Actual) => void }; export default class UiItemList extends React.Component { diff --git a/src/utils/parseIconName.js b/src/utils/parseIconName.js index 98e82ac..5b3e249 100644 --- a/src/utils/parseIconName.js +++ b/src/utils/parseIconName.js @@ -1,23 +1,24 @@ // @flow -import React from "react"; +import * as React from "react"; import _ from "lodash"; +import { getInternals, getActuals } from "utils/state"; export default function parseIconName(name: string): string { return `mdi ${name.split(" ").map((icon) => "mdi-".concat(icon)).join(" ")}`; } -export const renderIcon = (name: string, extraClass?: string) => { +export const renderIcon = (name: string, extraClass?: string): React.Node => { return ; }; export const controlGetIcon = (control: Control, state: State): string => { - const internals = _.mapValues(state, (x) => x.internal || x.actual); - const actuals = _.mapValues(state, (x) => x.actual); + const internals: Map = getInternals(state); + const actuals: Map = getActuals(state); return typeof control.icon !== "function" ? control.icon : control.icon(internals, actuals, state); }; export const renderControlIcon = (control: Control, - state: State, extraClass?: string) => { + state: State, extraClass?: string): React.Node => { return renderIcon(controlGetIcon(control, state), extraClass); }; diff --git a/types/types.js b/types/types.js index d9b7785..8dba59b 100644 --- a/types/types.js +++ b/types/types.js @@ -123,6 +123,8 @@ declare type Space = { mqtt: string }; +declare type Internal = string; +declare type Actual = any; declare type StateValue = { internal: string, actual: any From 3ed861369efac5627be6f02b552a40ebfa1e8972 Mon Sep 17 00:00:00 2001 From: uwap Date: Fri, 19 Jan 2018 21:57:20 +0100 Subject: [PATCH 10/10] Fix build --- src/components/UiItemList/UiItem.js | 5 +++-- src/utils/state.js | 8 ++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 src/utils/state.js diff --git a/src/components/UiItemList/UiItem.js b/src/components/UiItemList/UiItem.js index 182017c..054308f 100644 --- a/src/components/UiItemList/UiItem.js +++ b/src/components/UiItemList/UiItem.js @@ -14,6 +14,7 @@ import { MenuItem } from "material-ui/Menu"; import Button from "material-ui/Button"; import keyOf from "utils/keyOf"; +import { getInternals, getActuals } from "utils/state"; type UiItemProps = { item: I, @@ -45,8 +46,8 @@ export default class UiItem extends React.Component> { typeof this.props.item.enableCondition == "function") { const enableCondition = this.props.item.enableCondition; const state = this.props.state; - const internals = _.mapValues(state, (x) => x.internal); - const actuals = _.mapValues(state, (x) => x.actual); + const internals = getInternals(state); + const actuals = getActuals(state); return enableCondition(internals, actuals, state); } else { return true; diff --git a/src/utils/state.js b/src/utils/state.js new file mode 100644 index 0000000..94fcd48 --- /dev/null +++ b/src/utils/state.js @@ -0,0 +1,8 @@ +// @flow +import _ from "lodash"; + +export const getInternals = (state: State): Map => + _.mapValues(state, (x) => x.internal || x.actual); + +export const getActuals = (state: State): Map => + _.mapValues(state, (x) => x.actual);