Compare commits
85 commits
greenkeepe
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| b1c59d866a | |||
| 3528e8179d | |||
| a67aaade0a | |||
|
|
bb8f5be644 | ||
| dd198d8aaa | |||
| 60178de93b | |||
| e89fd10c23 | |||
| 6f3fb4dc0a | |||
|
|
8e002e3b1a | ||
|
|
58c9ae1125 | ||
|
|
c2ed2fd37a | ||
|
|
eb7d1f7c5d | ||
|
|
b6c7ba89cb | ||
|
|
14d72d626c | ||
|
|
d73ee95178 | ||
|
|
fa8d403076 | ||
|
|
38de936bdd | ||
|
|
060dfa61d8 | ||
|
|
ca2bef4248 | ||
|
|
f2f5e3441b | ||
|
|
eab431f13b | ||
|
|
53911db686 | ||
|
|
51d410fbd3 | ||
|
|
4d39149e77 | ||
|
|
5b62bc9325 | ||
|
|
9e8765711a | ||
|
|
cbc3084eff | ||
|
|
9b0c554e54 | ||
|
|
4806973c0a | ||
|
|
167d58d670 | ||
|
|
b4b85fdb17 | ||
|
|
8c91dee9b8 | ||
|
|
db62d59f67 | ||
|
|
3208de65d4 | ||
|
|
bb334ca7bc | ||
|
|
fa07cdc784 | ||
|
|
9d44540ebc | ||
|
|
e6b26dbac1 | ||
|
|
27a9544092 | ||
|
|
6b78cc0a2f | ||
|
|
6e63404724 | ||
|
|
6028302a64 | ||
|
|
a6aef2ee9a | ||
|
|
01ed36e5be | ||
|
|
a25d7cc01d | ||
|
|
57655b0f66 | ||
|
|
b7b0bd7cac | ||
|
|
6c80eb2bd4 | ||
|
|
9a070dcc2b | ||
|
|
424aef1991 | ||
|
|
e3eb924f1f | ||
|
|
9e388f4ae9 | ||
|
|
dc2728b59a | ||
|
|
94aafdfbdd | ||
|
|
ee4800d087 | ||
|
|
b898455f56 | ||
|
|
4e316f9e47 | ||
|
|
fdb49f79a5 | ||
|
|
39c364c742 | ||
|
|
c298a58a47 | ||
| 0a0639e994 | |||
| d9096b13e4 | |||
| a44eea520a | |||
| 0f08e9f1ee | |||
| ccd9bcd3b5 | |||
|
|
550e0c7479 | ||
|
|
3fd432b2d2 | ||
|
|
263507871b | ||
|
|
65452ac0cb | ||
|
|
d50ea6fd49 | ||
|
|
53d547bc65 | ||
| 2997ff8862 | |||
| e43842fbed | |||
| 1c1de6356c | |||
| 9a5557db03 | |||
| 8376f404e4 | |||
| 856aab41ad | |||
| 43a33c3ab3 | |||
|
|
5bae8025bd | ||
|
|
d338093eee | ||
| 8917402888 | |||
| af89238999 | |||
|
|
42e7697bf8 | ||
|
|
66ff91da2d | ||
| d39e547623 |
37 changed files with 6322 additions and 6049 deletions
5
.babelrc
5
.babelrc
|
|
@ -1,7 +1,10 @@
|
|||
{
|
||||
"presets": [
|
||||
["@babel/preset-env", {
|
||||
modules: false
|
||||
modules: false,
|
||||
corejs: "3.6",
|
||||
useBuiltIns: "entry",
|
||||
targets: "last 3 years"
|
||||
}],
|
||||
"@babel/preset-react",
|
||||
"@babel/preset-flow"
|
||||
|
|
|
|||
|
|
@ -7,7 +7,8 @@ module.exports = {
|
|||
"extends": [
|
||||
"eslint:recommended",
|
||||
"plugin:flowtype/recommended",
|
||||
"plugin:react/recommended"
|
||||
"plugin:react/recommended",
|
||||
"plugin:react-hooks/recommended"
|
||||
],
|
||||
"parserOptions": {
|
||||
"ecmaFeatures": {
|
||||
|
|
|
|||
|
|
@ -10,9 +10,8 @@ types/types.js
|
|||
types/mqtt.js
|
||||
|
||||
[options]
|
||||
esproposal.export_star_as=enable
|
||||
module.system.node.resolve_dirname=node_modules
|
||||
module.system.node.resolve_dirname=./src
|
||||
module.system.node.resolve_dirname=src
|
||||
|
||||
[lints]
|
||||
all=warn
|
||||
|
|
|
|||
|
|
@ -4,10 +4,6 @@ node_js:
|
|||
script:
|
||||
- yarn travis
|
||||
|
||||
before_install: yarn global add greenkeeper-lockfile@1
|
||||
before_script: greenkeeper-lockfile-update
|
||||
after_script: greenkeeper-lockfile-upload
|
||||
|
||||
after_success:
|
||||
- ./travis-upload-artifacts.sh
|
||||
|
||||
|
|
|
|||
32
README.md
32
README.md
|
|
@ -1,7 +1,6 @@
|
|||
# MQTT Control Map
|
||||
|
||||
[](https://travis-ci.org/uwap/mqtt-control-map)
|
||||
[](https://greenkeeper.io/)
|
||||
|
||||
## Development / Configuration
|
||||
|
||||
|
|
@ -12,33 +11,6 @@ your the mqtt control map for the given CONFIG everytime something changes.
|
|||
for the given config.
|
||||
4. run `yarn build CONFIG` to generate all files for production use.
|
||||
|
||||
## Config
|
||||
## Documentation
|
||||
|
||||
See `config/`.
|
||||
|
||||
The Config format consists out of two sections. Topics and Controls.
|
||||
|
||||
### Topics
|
||||
|
||||
The topics section defines the mqtt interfaces.
|
||||
|
||||
### Controls
|
||||
|
||||
The Controls define the UI Controls.
|
||||
|
||||
| Name | Type | Optional? | Default | Description |
|
||||
|-----------------|-------------------|------------|-----------------|-------------|
|
||||
| type | "toggle" \| "dropDown" \| "slider" | No | | The type of the UI element. |
|
||||
| text | string | No | | The text displayed right next to the UI element. |
|
||||
| topic | string | No | | The topic the UI element is supposed to change and/or receive its status from. |
|
||||
| enableCondition | (key: string, value: *) => boolean | Yes | () => true | This option allows you to enable or disable UI elements, depending on the current state. The first parameter is the internal representation of the value. For example "off". The second parameter is the actual value that was received via MQTT. Return true to enable the element and false to disable it. |
|
||||
| **Toggle Options** |
|
||||
| on | string | Yes | "on" | If the state is equal to the value of this option the toggle will be toggled on (if the toggled function is not overriden). This is also the value that will be sent when the button is toggled on. |
|
||||
| off | string | Yes | "off" | If the state is equal to the value of this option the toggle will be toggled off (if the toggled function is not overriden). This is also the value that will be sent when the button is toggled off. |
|
||||
| toggled | (key: string, value: *) => boolean | Yes | Use the on and off options | This is the function that decides whether the button should be in a toggled state or not. The parameters are equivalent to those of `enableCondition`. Return true to set the button to a toggled state. Return false to set it to the untoggled state. |
|
||||
| **DropDown Options** |
|
||||
| options | Map<string,string>| Yes | {} | This is an attribute set that will map all values defined in the topics section to a description text. For example `{ on: "Lights On", off: "Lights Off" }` will give the drop down element two options, one that is named `Lights On` and one that is named `Lights Off`. |
|
||||
| **Slider Options** |
|
||||
| min | number | Yes | 0 | The minimum value of that slider. |
|
||||
| max | number | Yes | 1 | The maximum value of that slider. |
|
||||
| step | number | Yes | 1 | The smallest step of the slider. |
|
||||
The documentation can be found in our [mqtt-control-map wiki](https://github.com/uwap/mqtt-control-map/wiki).
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
// @flow
|
||||
import type { Config } from "config/flowtypes";
|
||||
import { hex } from "config/colors";
|
||||
import * as types from "config/types";
|
||||
import { mdi } from "config/icon";
|
||||
import * as icons from "@mdi/js";
|
||||
import { svg } from "config/icon";
|
||||
|
||||
const config: Config = {
|
||||
space: {
|
||||
|
|
@ -32,20 +32,19 @@ const config: Config = {
|
|||
hauptraumTableLight: {
|
||||
name: "Hauptraum Tisch",
|
||||
position: [450, 450],
|
||||
icon: mdi("white-balance-iridescent"),
|
||||
iconColor: () => hex("#000000"),
|
||||
icon: svg(icons.mdiWhiteBalanceIridescent),
|
||||
ui: [
|
||||
{
|
||||
type: "toggle",
|
||||
text: "Licht",
|
||||
topic: "hauptraumTableLight",
|
||||
icon: mdi("power")
|
||||
icon: svg(icons.mdiPower)
|
||||
},
|
||||
{
|
||||
type: "toggle",
|
||||
text: "Licht",
|
||||
topic: "hauptraumTableLightOnHack",
|
||||
icon: mdi("power")
|
||||
icon: svg(icons.mdiPower)
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,8 +2,9 @@
|
|||
import type { Config } from "config/flowtypes";
|
||||
import * as types from "config/types";
|
||||
import { hex, rainbow } from "config/colors";
|
||||
import { mdi, rawMdi } from "config/icon";
|
||||
import { svg, withState } from "config/icon";
|
||||
import { esper, tasmota } from "./utils";
|
||||
import * as icons from "@mdi/js";
|
||||
|
||||
import * as onkyo from "./onkyo";
|
||||
import * as olymp from "./olymp";
|
||||
|
|
@ -225,6 +226,35 @@ const config: Config = {
|
|||
type: types.option({ on: "ON", off: "OFF" })
|
||||
},
|
||||
defaultValue: "off"
|
||||
},
|
||||
whirlpoolTemperatureSetpoint: {
|
||||
state: {
|
||||
name: "/service/whirlpool/state",
|
||||
type: types.json("temperatureSetpointC")
|
||||
},
|
||||
command: {
|
||||
name: "/service/whirlpool/set/temperature",
|
||||
type: types.string
|
||||
},
|
||||
defaultValue: "0"
|
||||
},
|
||||
whirlpoolBubbles: {
|
||||
state: {
|
||||
name: "/service/whirlpool/state",
|
||||
type: types.json("bubbles")
|
||||
},
|
||||
command: {
|
||||
name: "/service/whirlpool/set/bubbles",
|
||||
type: types.string
|
||||
},
|
||||
defaultValue: "0"
|
||||
},
|
||||
whirlpoolTemperature: {
|
||||
state: {
|
||||
name: "/service/whirlpool/state",
|
||||
type: types.json("waterTemperatureC")
|
||||
},
|
||||
defaultValue: "0"
|
||||
}
|
||||
},
|
||||
//Tasmota-Dosen
|
||||
|
|
@ -246,29 +276,28 @@ const config: Config = {
|
|||
ledStahltrager: {
|
||||
name: "LED Stahlträger",
|
||||
position: [340, 590],
|
||||
icon: mdi("white-balance-iridescent"),
|
||||
iconColor: ({ledStahltraeger}) =>
|
||||
(ledStahltraeger === "on" ? rainbow : hex("#000000")),
|
||||
icon: svg(icons.mdiWhiteBalanceIridescent).color(({ledStahltraeger}) =>
|
||||
(ledStahltraeger === "on" ? rainbow : hex("#000000"))),
|
||||
ui: [
|
||||
{
|
||||
type: "toggle",
|
||||
text: "Stahlträger LED",
|
||||
topic: "ledStahltraeger",
|
||||
icon: mdi("power")
|
||||
icon: svg(icons.mdiPower)
|
||||
}
|
||||
]
|
||||
},
|
||||
snackbar: {
|
||||
name: "Snackbar",
|
||||
position: [510, 500],
|
||||
icon: mdi("fridge"),
|
||||
iconColor: tasmota.iconColor("snackbar", hex("#E20074")),
|
||||
icon: svg(icons.mdiFridge).color(
|
||||
tasmota.iconColor("snackbar", hex("#E20074"))),
|
||||
ui: [
|
||||
{
|
||||
type: "toggle",
|
||||
text: "Snackbar",
|
||||
topic: "snackbar",
|
||||
icon: mdi("power")
|
||||
icon: svg(icons.mdiPower)
|
||||
},
|
||||
{
|
||||
type: "section",
|
||||
|
|
@ -278,7 +307,7 @@ const config: Config = {
|
|||
type: "text",
|
||||
text: "LED-Streifen",
|
||||
topic: "snackbarLedOnline",
|
||||
icon: mdi("white-balance-iridescent")
|
||||
icon: svg(icons.mdiWhiteBalanceIridescent)
|
||||
},
|
||||
{
|
||||
type: "dropDown",
|
||||
|
|
@ -297,7 +326,7 @@ const config: Config = {
|
|||
"11": "Rainbow Pattern",
|
||||
"12": "Fire Pattern"
|
||||
},
|
||||
icon: mdi("settings"),
|
||||
icon: svg(icons.mdiCog),
|
||||
enableCondition: ({ snackbarLedOnline }) => snackbarLedOnline === "on"
|
||||
},
|
||||
{
|
||||
|
|
@ -306,7 +335,7 @@ const config: Config = {
|
|||
topic: "snackbarDimmmer",
|
||||
min: 0,
|
||||
max: 100,
|
||||
icon: mdi("brightness-7"),
|
||||
icon: svg(icons.mdiBrightness7),
|
||||
enableCondition: ({ snackbarLedOnline }) => snackbarLedOnline === "on"
|
||||
},
|
||||
{
|
||||
|
|
@ -315,7 +344,7 @@ const config: Config = {
|
|||
topic: "snackbarSpeed",
|
||||
min: 0,
|
||||
max: 20,
|
||||
icon: mdi("speedometer"),
|
||||
icon: svg(icons.mdiSpeedometer),
|
||||
enableCondition: ({ snackbarLedOnline }) => snackbarLedOnline === "on"
|
||||
}
|
||||
]
|
||||
|
|
@ -323,155 +352,151 @@ const config: Config = {
|
|||
twinkle: {
|
||||
name: "Twinkle",
|
||||
position: [530, 560],
|
||||
icon: ({twinkle}) =>
|
||||
(twinkle === "on" ? rawMdi("led-on flip-v") : rawMdi("led-off flip-v")),
|
||||
iconColor: ({twinkle}) => (twinkle === "on" ? rainbow : hex("#000000")),
|
||||
icon: withState(({twinkle}) =>
|
||||
(twinkle === "on" ? svg(icons.mdiLedOn).flipV().color(rainbow)
|
||||
: svg(icons.mdiLedOff).flipV())
|
||||
),
|
||||
ui: [
|
||||
{
|
||||
type: "toggle",
|
||||
text: "Twinkle",
|
||||
topic: "twinkle",
|
||||
icon: mdi("power")
|
||||
icon: svg(icons.mdiPower)
|
||||
}
|
||||
]
|
||||
},
|
||||
fan: {
|
||||
name: "Ventilator",
|
||||
position: [530, 440],
|
||||
icon: mdi("fan"),
|
||||
iconColor: ({fan}) => (fan === "on" ? hex("#00FF00") : hex("#000000")),
|
||||
icon: svg(icons.mdiFan).color(({fan}) =>
|
||||
(fan === "on" ? hex("#00FF00") : hex("#000000"))),
|
||||
ui: [
|
||||
{
|
||||
type: "toggle",
|
||||
text: "Ventilator",
|
||||
topic: "fan",
|
||||
icon: mdi("power")
|
||||
icon: svg(icons.mdiPower)
|
||||
}
|
||||
]
|
||||
},
|
||||
cashdesk: {
|
||||
name: "Cashdesk",
|
||||
position: [510, 467],
|
||||
icon: mdi("coin"),
|
||||
icon: svg(icons.mdiCurrencyUsdCircle),
|
||||
ui: [
|
||||
{
|
||||
type: "link",
|
||||
link: "http://cashdesk.rzl:8000/",
|
||||
text: "Open Cashdesk",
|
||||
icon: mdi("open-in-new")
|
||||
icon: svg(icons.mdiOpenInNew)
|
||||
}
|
||||
]
|
||||
},
|
||||
flyfry: {
|
||||
name: "Fliegenbratgerät",
|
||||
position: [450, 570],
|
||||
icon: mdi("fire"),
|
||||
iconColor: ({flyfry}) =>
|
||||
(flyfry === "on" ? hex("#6666FF") : hex("#000000")),
|
||||
icon: svg(icons.mdiFire).color(({flyfry}) =>
|
||||
(flyfry === "on" ? hex("#6666FF") : hex("#000000"))),
|
||||
ui: esper.statistics("flyfry", [
|
||||
{
|
||||
type: "toggle",
|
||||
text: "Fliegenbratgerät",
|
||||
topic: "flyfry",
|
||||
icon: mdi("power")
|
||||
icon: svg(icons.mdiPower)
|
||||
}
|
||||
])
|
||||
},
|
||||
projector: {
|
||||
name: "Beamer",
|
||||
position: [380, 590],
|
||||
icon: mdi("projector flip-v"),
|
||||
iconColor: ({projector}) =>
|
||||
icon: svg(icons.mdiProjector).flipV().color(({projector}) =>
|
||||
({
|
||||
transientOn: hex("#b3b300"),
|
||||
transientOff: hex("#b3b300"),
|
||||
on: hex("#00ff00"),
|
||||
off: hex("#000000"),
|
||||
unknown: hex("#888888")
|
||||
})[projector],
|
||||
})[projector]),
|
||||
ui: [
|
||||
{
|
||||
type: "toggle",
|
||||
text: "Beamer",
|
||||
topic: "projector",
|
||||
toggled: (val) => val === "transientOn" || val === "on",
|
||||
icon: mdi("power")
|
||||
icon: svg(icons.mdiPower)
|
||||
}
|
||||
]
|
||||
},
|
||||
loetarbeitsplatz4: {
|
||||
name: "Lötarbeitsplatz",
|
||||
position: [205, 455],
|
||||
icon: mdi("eyedropper-variant"),
|
||||
iconColor: ({loetarbeitsplatz4}) =>
|
||||
(loetarbeitsplatz4 === "on" ? hex("#FF0000") : hex("#000000")),
|
||||
icon: svg(icons.mdiEyedropperVariant).color(({loetarbeitsplatz4}) =>
|
||||
(loetarbeitsplatz4 === "on" ? hex("#FF0000") : hex("#000000"))),
|
||||
ui: [
|
||||
{
|
||||
type: "text",
|
||||
text: "Status",
|
||||
topic: "loetarbeitsplatz4",
|
||||
icon: mdi("eyedropper-variant")
|
||||
icon: svg(icons.mdiEyedropperVariant)
|
||||
}
|
||||
]
|
||||
},
|
||||
loetarbeitsplatz5: {
|
||||
name: "Lötarbeitsplatz",
|
||||
position: [205, 405],
|
||||
icon: mdi("eyedropper-variant"),
|
||||
iconColor: ({loetarbeitsplatz5}) =>
|
||||
(loetarbeitsplatz5 === "on" ? hex("#FF0000") : hex("#000000")),
|
||||
icon: svg(icons.mdiEyedropperVariant).color(({loetarbeitsplatz4}) =>
|
||||
(loetarbeitsplatz4 === "on" ? hex("#FF0000") : hex("#000000"))),
|
||||
ui: [
|
||||
{
|
||||
type: "text",
|
||||
text: "Status",
|
||||
topic: "loetarbeitsplatz5",
|
||||
icon: mdi("eyedropper-variant")
|
||||
icon: svg(icons.mdiEyedropperVariant)
|
||||
}
|
||||
]
|
||||
},
|
||||
door: {
|
||||
name: "Tür",
|
||||
position: [455, 350],
|
||||
icon: mdi("swap-vertical"),
|
||||
iconColor: ({doorStatus}) =>
|
||||
(doorStatus === "on" ? hex("#00FF00") : hex("#FF0000")),
|
||||
icon: svg(icons.mdiSwapVertical).color(({doorStatus}) =>
|
||||
(doorStatus === "on" ? hex("#00FF00") : hex("#FF0000"))),
|
||||
ui: [
|
||||
{
|
||||
type: "link",
|
||||
link: "http://s.rzl.so",
|
||||
text: "Open Status Page",
|
||||
icon: mdi("open-in-new")
|
||||
icon: svg(icons.mdiOpenInNew)
|
||||
},
|
||||
{
|
||||
type: "link",
|
||||
// eslint-disable-next-line max-len
|
||||
link: "http://kunterbunt.vm.rzl/dashboard/db/allgemeines-copy-ranlvor?orgId=1",
|
||||
text: "RZL-Dashboard",
|
||||
icon: mdi("open-in-new")
|
||||
icon: svg(icons.mdiOpenInNew)
|
||||
},
|
||||
{
|
||||
type: "text",
|
||||
text: "Anwesend",
|
||||
topic: "presenceStatus",
|
||||
icon: mdi("account")
|
||||
icon: svg(icons.mdiAccount)
|
||||
},
|
||||
{
|
||||
type: "text",
|
||||
text: "Devices",
|
||||
topic: "devicesStatus",
|
||||
icon: mdi("wifi")
|
||||
icon: svg(icons.mdiWifi)
|
||||
},
|
||||
{
|
||||
type: "toggle",
|
||||
text: "Deko",
|
||||
topic: "deko",
|
||||
icon: mdi("invert-colors")
|
||||
icon: svg(icons.mdiInvertColors)
|
||||
},
|
||||
{
|
||||
type: "text",
|
||||
text: "Power Hauptraum",
|
||||
topic: "powerConsumption",
|
||||
icon: mdi("speedometer")
|
||||
icon: svg(icons.mdiSpeedometer)
|
||||
}
|
||||
|
||||
]
|
||||
|
|
@ -479,56 +504,56 @@ const config: Config = {
|
|||
infoscreen: {
|
||||
name: "Infoscreen",
|
||||
position: [255, 495],
|
||||
icon: mdi("television-guide flip-v"),
|
||||
iconColor: tasmota.iconColor("infoscreen", hex("#4444FF")),
|
||||
icon: svg(icons.mdiTelevisionGuide).flipV().color(
|
||||
tasmota.iconColor("infoscreen", hex("#4444FF"))
|
||||
),
|
||||
ui: [
|
||||
{
|
||||
type: "toggle",
|
||||
text: "Infoscreen",
|
||||
topic: "infoscreen",
|
||||
icon: mdi("power")
|
||||
icon: svg(icons.mdiPower)
|
||||
},
|
||||
{
|
||||
type: "link",
|
||||
link: "http://cashdesk.rzl:3030/rzl",
|
||||
text: "Open Infoscreen",
|
||||
icon: mdi("open-in-new")
|
||||
icon: svg(icons.mdiOpenInNew)
|
||||
}
|
||||
]
|
||||
},
|
||||
pilze: {
|
||||
name: "Pilze",
|
||||
position: [48, 499],
|
||||
icon: ({pilze}) =>
|
||||
(pilze === "on" ? rawMdi("led-on") : rawMdi("led-off")),
|
||||
iconColor: tasmota.iconColor("pilze", rainbow),
|
||||
icon: withState(({pilze}) =>
|
||||
(pilze === "on" ? svg(icons.mdiLedOn) : svg(icons.mdiLedOff))).color(
|
||||
tasmota.iconColor("pilze", rainbow)),
|
||||
ui: [
|
||||
{
|
||||
type: "toggle",
|
||||
text: "Pilze",
|
||||
topic: "pilze",
|
||||
icon: mdi("power")
|
||||
icon: svg(icons.mdiPower)
|
||||
}
|
||||
]
|
||||
},
|
||||
printer3D: {
|
||||
name: "Ultimaker 3",
|
||||
position: [754, 560],
|
||||
icon: mdi("printer-3d"),
|
||||
iconColor: ({printer3DStatus}) =>
|
||||
icon: svg(icons.mdiPrinter3d).color(({printer3DStatus}) =>
|
||||
({
|
||||
awaitingInteraction: hex("#b3b300"),
|
||||
printing: hex("#00ff00"),
|
||||
idle: hex("#000000"),
|
||||
unavailable: hex("#888888"),
|
||||
error: hex("#ff0000")
|
||||
})[printer3DStatus],
|
||||
})[printer3DStatus]),
|
||||
ui: [
|
||||
{
|
||||
type: "link",
|
||||
link: "http://ultimaker.rzl/",
|
||||
text: "Open Webinterface",
|
||||
icon: mdi("open-in-new")
|
||||
icon: svg(icons.mdiOpenInNew)
|
||||
},
|
||||
{
|
||||
type: "section",
|
||||
|
|
@ -536,7 +561,7 @@ const config: Config = {
|
|||
},
|
||||
{
|
||||
type: "progress",
|
||||
icon: mdi("rotate-right"),
|
||||
icon: svg(icons.mdiRotateRight),
|
||||
min: 0,
|
||||
max: 1,
|
||||
text: "Printing Progress",
|
||||
|
|
@ -545,7 +570,7 @@ const config: Config = {
|
|||
{
|
||||
type: "text",
|
||||
text: "Time Left",
|
||||
icon: mdi("clock"),
|
||||
icon: svg(icons.mdiClock),
|
||||
topic: "printer3Dremaining"
|
||||
}
|
||||
]
|
||||
|
|
@ -553,51 +578,87 @@ const config: Config = {
|
|||
partkeepr: {
|
||||
name: "Partkeepr",
|
||||
position: [48, 450],
|
||||
icon: mdi("chip"),
|
||||
icon: svg(icons.mdiChip),
|
||||
ui: [
|
||||
{
|
||||
type: "link",
|
||||
link: "http://partkeepr.rzl/",
|
||||
text: "Open Partkeepr",
|
||||
icon: mdi("open-in-new")
|
||||
icon: svg(icons.mdiOpenInNew)
|
||||
}
|
||||
]
|
||||
},
|
||||
printerAnnette: {
|
||||
name: "Drucker",
|
||||
position: [800, 350],
|
||||
icon: mdi("printer"),
|
||||
iconColor: tasmota.iconColor("printerAnnette"),
|
||||
icon: svg(icons.mdiPrinter).color(tasmota.iconColor("printerAnnette")),
|
||||
ui: [
|
||||
{
|
||||
type: "toggle",
|
||||
text: "Drucker",
|
||||
topic: "printerAnnette",
|
||||
icon: mdi("power")
|
||||
icon: svg(icons.mdiPower)
|
||||
},
|
||||
{
|
||||
type: "link",
|
||||
link: "http://annette.rzl/",
|
||||
text: "Open Annette",
|
||||
icon: mdi("open-in-new")
|
||||
icon: svg(icons.mdiOpenInNew)
|
||||
}
|
||||
]
|
||||
},
|
||||
nebenraumPowerStatus: {
|
||||
name: "Strom Fablab",
|
||||
position: [613, 537],
|
||||
icon: ({nebenraumPowerStatus}) =>
|
||||
(nebenraumPowerStatus === "on" ? rawMdi("flash") : rawMdi("flash-off")),
|
||||
iconColor: ({nebenraumPowerStatus}) =>
|
||||
(nebenraumPowerStatus === "on" ? hex("#00ff00") : hex("#000000")),
|
||||
icon: withState(({nebenraumPowerStatus}) =>
|
||||
(nebenraumPowerStatus === "on" ?
|
||||
svg(icons.mdiFlash).color(hex("#00FF00")) : svg(icons.mdiFlashOff))),
|
||||
ui: [
|
||||
{
|
||||
type: "text",
|
||||
icon: mdi("power"),
|
||||
icon: svg(icons.mdiPower),
|
||||
text: "Strom Fablab",
|
||||
topic: "nebenraumPowerStatus"
|
||||
}
|
||||
]
|
||||
},
|
||||
whirlpool: {
|
||||
name: "Vorstandswhirlpool",
|
||||
position: [1413, 500],
|
||||
icon: svg(icons.mdiPool).color(
|
||||
({whirlpoolBubbles}) =>
|
||||
(parseInt(whirlpoolBubbles, 10) > 0 ? hex("#00ff00")
|
||||
: hex("#000000"))),
|
||||
ui: [
|
||||
{
|
||||
type: "text",
|
||||
icon: svg(icons.mdiOilTemperature),
|
||||
text: "Temperatur",
|
||||
topic: "whirlpoolTemperature"
|
||||
},
|
||||
{
|
||||
type: "text",
|
||||
icon: svg(icons.mdiOilTemperature),
|
||||
text: "Temperatur Sollwert",
|
||||
topic: "whirlpoolTemperatureSetpoint"
|
||||
},
|
||||
{
|
||||
type: "slider",
|
||||
min: 4,
|
||||
max: 100,
|
||||
text: "Temperatur Sollwert",
|
||||
icon: svg(icons.mdiOilTemperature),
|
||||
topic: "whirlpoolTemperatureSetpoint"
|
||||
},
|
||||
{
|
||||
type: "slider",
|
||||
min: 0,
|
||||
max: 9,
|
||||
text: "Bubbles",
|
||||
icon: svg(icons.mdiChartBubble),
|
||||
topic: "whirlpoolBubbles"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
layers: [
|
||||
|
|
|
|||
|
|
@ -1,9 +1,10 @@
|
|||
// @flow
|
||||
import type { Topics, Controls } from "config/flowtypes";
|
||||
import { mdi, mdiBattery } from "config/icon";
|
||||
import { svg, mdiBattery } from "config/icon";
|
||||
import { hex } from "config/colors";
|
||||
import * as types from "config/types";
|
||||
import { floalt, tradfri, tasmota } from "./utils";
|
||||
import * as icons from "@mdi/js";
|
||||
|
||||
export const topics: Topics = {
|
||||
//Kuechen-Floalts
|
||||
|
|
@ -65,7 +66,7 @@ export const controls: Controls = {
|
|||
kitchenLight: {
|
||||
name: "Deckenlicht Küche",
|
||||
position: [325, 407],
|
||||
icon: mdi("ceiling-light"),
|
||||
icon: svg(icons.mdiCeilingLight),
|
||||
ui: [
|
||||
{
|
||||
type: "toggle",
|
||||
|
|
@ -74,14 +75,14 @@ export const controls: Controls = {
|
|||
toggled: (n) => parseInt(n, 10) > 0,
|
||||
topic: "kitchenLightBrightness",
|
||||
text: "Ein/Ausschalten",
|
||||
icon: mdi("power")
|
||||
icon: svg(icons.mdiPower)
|
||||
},
|
||||
{
|
||||
type: "slider",
|
||||
min: 0,
|
||||
max: 100,
|
||||
text: "Helligkeit",
|
||||
icon: mdi("brightness-7"),
|
||||
icon: svg(icons.mdiBrightness7),
|
||||
topic: "kitchenLightBrightness"
|
||||
},
|
||||
{
|
||||
|
|
@ -89,7 +90,7 @@ export const controls: Controls = {
|
|||
min: 0,
|
||||
max: 100,
|
||||
text: "Farbtemperatur",
|
||||
icon: mdi("weather-sunset-down"),
|
||||
icon: svg(icons.mdiWeatherSunsetDown),
|
||||
topic: "kitchenLightColor"
|
||||
},
|
||||
{
|
||||
|
|
@ -101,7 +102,7 @@ export const controls: Controls = {
|
|||
min: 0,
|
||||
max: 100,
|
||||
text: "Helligkeit",
|
||||
icon: mdi("brightness-7"),
|
||||
icon: svg(icons.mdiBrightness7),
|
||||
topic: floalt.brightness("65537")
|
||||
},
|
||||
{
|
||||
|
|
@ -109,7 +110,7 @@ export const controls: Controls = {
|
|||
min: 0,
|
||||
max: 100,
|
||||
text: "Farbtemperatur",
|
||||
icon: mdi("weather-sunset-down"),
|
||||
icon: svg(icons.mdiWeatherSunsetDown),
|
||||
topic: floalt.color("65537")
|
||||
},
|
||||
{
|
||||
|
|
@ -121,7 +122,7 @@ export const controls: Controls = {
|
|||
min: 0,
|
||||
max: 100,
|
||||
text: "Helligkeit",
|
||||
icon: mdi("brightness-7"),
|
||||
icon: svg(icons.mdiBrightness7),
|
||||
topic: floalt.brightness("65538")
|
||||
},
|
||||
{
|
||||
|
|
@ -129,7 +130,7 @@ export const controls: Controls = {
|
|||
min: 0,
|
||||
max: 100,
|
||||
text: "Farbtemperatur",
|
||||
icon: mdi("weather-sunset-down"),
|
||||
icon: svg(icons.mdiWeatherSunsetDown),
|
||||
topic: floalt.color("65538")
|
||||
},
|
||||
{
|
||||
|
|
@ -141,7 +142,7 @@ export const controls: Controls = {
|
|||
min: 0,
|
||||
max: 100,
|
||||
text: "Helligkeit",
|
||||
icon: mdi("brightness-7"),
|
||||
icon: svg(icons.mdiBrightness7),
|
||||
topic: floalt.brightness("65539")
|
||||
},
|
||||
{
|
||||
|
|
@ -149,7 +150,7 @@ export const controls: Controls = {
|
|||
min: 0,
|
||||
max: 100,
|
||||
text: "Farbtemperatur",
|
||||
icon: mdi("weather-sunset-down"),
|
||||
icon: svg(icons.mdiWeatherSunsetDown),
|
||||
topic: floalt.color("65539")
|
||||
},
|
||||
{
|
||||
|
|
@ -161,7 +162,7 @@ export const controls: Controls = {
|
|||
min: 0,
|
||||
max: 100,
|
||||
text: "Helligkeit",
|
||||
icon: mdi("brightness-7"),
|
||||
icon: svg(icons.mdiBrightness7),
|
||||
topic: floalt.brightness("65540")
|
||||
},
|
||||
{
|
||||
|
|
@ -169,7 +170,7 @@ export const controls: Controls = {
|
|||
min: 0,
|
||||
max: 100,
|
||||
text: "Farbtemperatur",
|
||||
icon: mdi("weather-sunset-down"),
|
||||
icon: svg(icons.mdiWeatherSunsetDown),
|
||||
topic: floalt.color("65540")
|
||||
}
|
||||
]
|
||||
|
|
@ -177,7 +178,7 @@ export const controls: Controls = {
|
|||
kitchenSinkLight: {
|
||||
name: "Licht Spüle",
|
||||
position: [300, 345],
|
||||
icon: mdi("wall-sconce-flat"),
|
||||
icon: svg(icons.mdiWallSconceFlat),
|
||||
ui: [
|
||||
{
|
||||
type: "toggle",
|
||||
|
|
@ -186,14 +187,14 @@ export const controls: Controls = {
|
|||
toggled: (n) => parseInt(n, 10) > 0,
|
||||
topic: "kitchenSinkLightBrightness",
|
||||
text: "Ein/Ausschalten",
|
||||
icon: mdi("power")
|
||||
icon: svg(icons.mdiPower)
|
||||
},
|
||||
{
|
||||
type: "slider",
|
||||
min: 0,
|
||||
max: 100,
|
||||
text: "Helligkeit",
|
||||
icon: mdi("brightness-7"),
|
||||
icon: svg(icons.mdiBrightness7),
|
||||
topic: "kitchenSinkLightBrightness"
|
||||
}
|
||||
]
|
||||
|
|
@ -201,7 +202,7 @@ export const controls: Controls = {
|
|||
kitchenCounterLight: {
|
||||
name: "Deckenlicht Theke",
|
||||
position: [400, 440],
|
||||
icon: mdi("ceiling-light"),
|
||||
icon: svg(icons.mdiCeilingLight),
|
||||
ui: [
|
||||
{
|
||||
type: "section",
|
||||
|
|
@ -212,7 +213,7 @@ export const controls: Controls = {
|
|||
min: 0,
|
||||
max: 100,
|
||||
text: "Helligkeit",
|
||||
icon: mdi("brightness-7"),
|
||||
icon: svg(icons.mdiBrightness7),
|
||||
topic: floalt.brightness("65544")
|
||||
},
|
||||
{
|
||||
|
|
@ -220,7 +221,7 @@ export const controls: Controls = {
|
|||
min: 0,
|
||||
max: 100,
|
||||
text: "Farbtemperatur",
|
||||
icon: mdi("weather-sunset-down"),
|
||||
icon: svg(icons.mdiWeatherSunsetDown),
|
||||
topic: floalt.color("65544")
|
||||
},
|
||||
{
|
||||
|
|
@ -232,7 +233,7 @@ export const controls: Controls = {
|
|||
min: 0,
|
||||
max: 100,
|
||||
text: "Helligkeit",
|
||||
icon: mdi("brightness-7"),
|
||||
icon: svg(icons.mdiBrightness7),
|
||||
topic: floalt.brightness("65543")
|
||||
},
|
||||
{
|
||||
|
|
@ -240,7 +241,7 @@ export const controls: Controls = {
|
|||
min: 0,
|
||||
max: 100,
|
||||
text: "Farbtemperatur",
|
||||
icon: mdi("weather-sunset-down"),
|
||||
icon: svg(icons.mdiWeatherSunsetDown),
|
||||
topic: floalt.color("65543")
|
||||
}
|
||||
]
|
||||
|
|
@ -248,21 +249,21 @@ export const controls: Controls = {
|
|||
lichtDunstabzug: {
|
||||
name: "Licht Dunstabzugshaube",
|
||||
position: [252, 405],
|
||||
icon: mdi("ceiling-light"),
|
||||
icon: svg(icons.mdiCeilingLight),
|
||||
iconColor: tasmota.iconColor("lichtDunstabzug"),
|
||||
ui: [
|
||||
{
|
||||
type: "toggle",
|
||||
text: "Licht Dunstabzugshaube",
|
||||
topic: "lichtDunstabzug",
|
||||
icon: mdi("power")
|
||||
icon: svg(icons.mdiPower)
|
||||
}
|
||||
]
|
||||
},
|
||||
remotes: {
|
||||
name: "Fernbedinungen",
|
||||
position: [400, 344],
|
||||
icon: mdi("light-switch"),
|
||||
icon: svg(icons.mdiLightSwitch),
|
||||
iconColor: (state) => //if any remote is low make icon red
|
||||
(["65536", "65542", "65546", "65547"]
|
||||
.some((x) => state[tradfri.remote.low(x)] === "true")
|
||||
|
|
|
|||
|
|
@ -1,11 +1,14 @@
|
|||
// @flow
|
||||
import type { Topics, Controls } from "config/flowtypes";
|
||||
import { mdi } from "config/icon";
|
||||
import { svg } from "config/icon";
|
||||
import { hex, rainbow } from "config/colors";
|
||||
import * as types from "config/types";
|
||||
import { tasmota, esper } from "./utils";
|
||||
import * as icons from "@mdi/js";
|
||||
|
||||
export const topics: Topics = {
|
||||
...tasmota.topics("8", "ledOlymp"),
|
||||
...esper.topics("afba45", "alarm"),
|
||||
videogames: {
|
||||
state: {
|
||||
name: "/service/openhab/out/pca301_videogames/state",
|
||||
|
|
@ -38,75 +41,70 @@ export const topics: Topics = {
|
|||
type: types.option({ on: "ON", off: "OFF" })
|
||||
},
|
||||
defaultValue: "off"
|
||||
},
|
||||
...tasmota.topics("8", "ledOlymp"),
|
||||
...esper.topics("afba45", "alarm")
|
||||
}
|
||||
};
|
||||
|
||||
export const controls: Controls = {
|
||||
ledOlymp: {
|
||||
name: "LED Olymp",
|
||||
position: [196, 154],
|
||||
icon: mdi("white-balance-iridescent rotate-45"),
|
||||
iconColor: tasmota.iconColor("ledOlymp", rainbow),
|
||||
icon: svg(icons.mdiWhiteBalanceIridescent).rotate(45).color(
|
||||
tasmota.iconColor("ledOlymp", rainbow)),
|
||||
ui: [
|
||||
{
|
||||
type: "toggle",
|
||||
text: "LED Olymp",
|
||||
topic: "ledOlymp",
|
||||
icon: mdi("power")
|
||||
icon: svg(icons.mdiPower)
|
||||
}
|
||||
]
|
||||
},
|
||||
videogames: {
|
||||
name: "Videospiele",
|
||||
position: [100, 100],
|
||||
icon: mdi("gamepad-variant"),
|
||||
iconColor: ({videogames}) =>
|
||||
(videogames === "on" ? hex("#00FF00") : hex("#000000")),
|
||||
icon: svg(icons.mdiGamepadVariant).color(({videogames}) =>
|
||||
(videogames === "on" ? hex("#00FF00") : hex("#000000"))),
|
||||
ui: [
|
||||
{
|
||||
type: "toggle",
|
||||
text: "Videospiele",
|
||||
topic: "videogames",
|
||||
icon: mdi("power")
|
||||
icon: svg(icons.mdiPower)
|
||||
}
|
||||
]
|
||||
},
|
||||
olympPC: {
|
||||
name: "Rechner",
|
||||
position: [297, 90],
|
||||
icon: mdi("desktop-classic"),
|
||||
iconColor: ({olympPC}) =>
|
||||
(olympPC === "on" ? hex("#00FF00") : hex("#000000")),
|
||||
icon: svg(icons.mdiDesktopClassic).color(({olympPC}) =>
|
||||
(olympPC === "on" ? hex("#00FF00") : hex("#000000"))),
|
||||
ui: [
|
||||
{
|
||||
type: "toggle",
|
||||
text: "Rechner",
|
||||
topic: "olympPC",
|
||||
icon: mdi("power")
|
||||
icon: svg(icons.mdiPower)
|
||||
}
|
||||
]
|
||||
},
|
||||
rundumleuchte: {
|
||||
name: "Rundumleuchte",
|
||||
position: [310, 275],
|
||||
icon: mdi("alarm-light"),
|
||||
iconColor: ({rundumleuchte}) =>
|
||||
(rundumleuchte === "on" ? hex("#F0DF10") : hex("#000000")),
|
||||
icon: svg(icons.mdiAlarmLight).color(({rundumleuchte}) =>
|
||||
(rundumleuchte === "on" ? hex("#F0DF10") : hex("#000000"))),
|
||||
ui: [
|
||||
{
|
||||
type: "toggle",
|
||||
text: "Rundumleuchte",
|
||||
topic: "rundumleuchte",
|
||||
icon: mdi("power")
|
||||
icon: svg(icons.mdiPower)
|
||||
}
|
||||
]
|
||||
},
|
||||
alarm: {
|
||||
name: "Alarm",
|
||||
position: [340, 250],
|
||||
icon: mdi("alarm-bell"),
|
||||
icon: svg(icons.mdiAlarmBell),
|
||||
iconColor: () => hex("#000000"),
|
||||
ui: esper.statistics("alarm")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
// @flow
|
||||
import type { Topics, Controls } from "config/flowtypes";
|
||||
import { mdi } from "config/icon";
|
||||
import { svg } from "config/icon";
|
||||
import { hex } from "config/colors";
|
||||
import * as types from "config/types";
|
||||
import * as icons from "@mdi/js";
|
||||
|
||||
export const topics: Topics = {
|
||||
onkyoConnection: {
|
||||
|
|
@ -132,12 +133,12 @@ export const controls: Controls = {
|
|||
iconColor: ({onkyoConnection, onkyoPower}) =>
|
||||
(onkyoConnection !== "connected" ? hex("#888888") :
|
||||
(onkyoPower === "on" ? hex("#00FF00") : hex("#000000"))),
|
||||
icon: mdi("audio-video"),
|
||||
icon: svg(icons.mdiAudioVideo),
|
||||
ui: [
|
||||
{
|
||||
type: "toggle",
|
||||
text: "Power",
|
||||
icon: mdi("power"),
|
||||
icon: svg(icons.mdiPower),
|
||||
topic: "onkyoPower",
|
||||
enableCondition: (state) => state.onkyoConnection === "connected"
|
||||
},
|
||||
|
|
@ -151,14 +152,14 @@ export const controls: Controls = {
|
|||
topic: "onkyoVolume",
|
||||
min: 0,
|
||||
max: 50,
|
||||
icon: mdi("volume-high"),
|
||||
icon: svg(icons.mdiVolumeHigh),
|
||||
enableCondition: (state) => state.onkyoConnection === "connected"
|
||||
},
|
||||
{
|
||||
type: "toggle",
|
||||
text: "Mute",
|
||||
topic: "onkyoMute",
|
||||
icon: mdi("volume-off"),
|
||||
icon: svg(icons.mdiVolumeOff),
|
||||
enableCondition: (state) => state.onkyoConnection === "connected"
|
||||
},
|
||||
{
|
||||
|
|
@ -176,7 +177,7 @@ export const controls: Controls = {
|
|||
pult: "Pult",
|
||||
front: "Front HDMI"
|
||||
},
|
||||
icon: mdi("usb"),
|
||||
icon: svg(icons.mdiUsb),
|
||||
enableCondition: (state) => state.onkyoConnection === "connected"
|
||||
},
|
||||
{
|
||||
|
|
@ -200,7 +201,7 @@ export const controls: Controls = {
|
|||
somafmChrismasLounge: "Christmas Lounge (SomaFM)",
|
||||
unknown: "Unknown"
|
||||
},
|
||||
icon: mdi("radio"),
|
||||
icon: svg(icons.mdiRadio),
|
||||
enableCondition: (state) => state.onkyoConnection === "connected"
|
||||
&& state.onkyoInputs === "netzwerk"
|
||||
},
|
||||
|
|
@ -212,7 +213,7 @@ export const controls: Controls = {
|
|||
type: "link",
|
||||
link: "http://mpd.rzl/mpd/player/index.php",
|
||||
text: "Open MPD Interface",
|
||||
icon: mdi("open-in-new")
|
||||
icon: svg(icons.mdiOpenInNew)
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,12 @@
|
|||
// @flow
|
||||
import type { ControlUI } from "config/flowtypes";
|
||||
import { mdi } from "config/icon";
|
||||
import { hex } from "config/colors";
|
||||
import type { ControlUI, Topics } from "config/flowtypes";
|
||||
import { svg } from "config/icon";
|
||||
import { hex, type Color } from "config/colors";
|
||||
import * as types from "config/types";
|
||||
import * as icons from "@mdi/js";
|
||||
|
||||
export const tasmota = {
|
||||
topics: (id: string, name: string) => ({
|
||||
topics: (id: string, name: string): Topics => ({
|
||||
[name]: {
|
||||
state: {
|
||||
name: `stat/sonoff${id}/POWER`,
|
||||
|
|
@ -26,20 +27,20 @@ export const tasmota = {
|
|||
defaultValue: "off"
|
||||
}
|
||||
}),
|
||||
iconColor: (name: string, onColor: Color = hex("#00FF00")) =>
|
||||
(state: State) => {
|
||||
iconColor: (name: string, onCol: Color = hex("#00FF00")): (State => Color) =>
|
||||
(state: State): Color => {
|
||||
if (state[`${name}_online`] === "off") {
|
||||
return hex("#888888");
|
||||
} else if (state[name] === "on") {
|
||||
return onColor;
|
||||
return onCol;
|
||||
}
|
||||
return hex("#000000");
|
||||
}
|
||||
};
|
||||
export const floalt = {
|
||||
color: (lightId: string) => `floalt_${lightId}_color`,
|
||||
brightness: (lightId: string) => `floalt_${lightId}_brightness`,
|
||||
topics: (lightId: string) => ({
|
||||
color: (lightId: string): string => `floalt_${lightId}_color`,
|
||||
brightness: (lightId: string): string => `floalt_${lightId}_brightness`,
|
||||
topics: (lightId: string): Topics => ({
|
||||
[`floalt_${lightId}_color`]: {
|
||||
state: {
|
||||
name: `/service/openhab/out/tradfri_0220_gwb8d7af2b448f_${lightId}` +
|
||||
|
|
@ -70,9 +71,9 @@ export const floalt = {
|
|||
};
|
||||
|
||||
const tradfriRemote = {
|
||||
level: (remoteId: string) => `tradfri_remote_${remoteId}_level`,
|
||||
low: (remoteId: string) => `tradfri_remote_${remoteId}_low`,
|
||||
topics: (remoteId: string) => ({
|
||||
level: (remoteId: string): string => `tradfri_remote_${remoteId}_level`,
|
||||
low: (remoteId: string): string => `tradfri_remote_${remoteId}_low`,
|
||||
topics: (remoteId: string): Topics => ({
|
||||
[`tradfri_remote_${remoteId}_level`]: {
|
||||
state: {
|
||||
name: `/service/openhab/out/tradfri_0830_gwb8d7af2b448f_${remoteId}` +
|
||||
|
|
@ -106,36 +107,36 @@ const esperStatistics = (name: string,
|
|||
{
|
||||
type: "text",
|
||||
text: "Device Variant",
|
||||
icon: mdi("chart-donut"),
|
||||
icon: svg(icons.mdiChartDonut),
|
||||
topic: `esper_${name}_device`
|
||||
},
|
||||
{
|
||||
type: "text",
|
||||
text: "Version",
|
||||
icon: mdi("source-branch"),
|
||||
icon: svg(icons.mdiSourceBranch),
|
||||
topic: `esper_${name}_version`
|
||||
},
|
||||
{
|
||||
type: "text",
|
||||
text: "IP",
|
||||
icon: mdi("access-point-network"),
|
||||
icon: svg(icons.mdiAccessPointNetwork),
|
||||
topic: `esper_${name}_ip`
|
||||
},
|
||||
{
|
||||
type: "text",
|
||||
text: "RSSI",
|
||||
icon: mdi("wifi"),
|
||||
icon: svg(icons.mdiWifi),
|
||||
topic: `esper_${name}_rssi`
|
||||
},
|
||||
{
|
||||
type: "text",
|
||||
text: "Running since…",
|
||||
icon: mdi("av-timer"),
|
||||
icon: svg(icons.mdiAvTimer),
|
||||
topic: `esper_${name}_uptime`
|
||||
}
|
||||
])
|
||||
);
|
||||
const esperTopics = (chipId: string, name: string) => ({
|
||||
const esperTopics = (chipId: string, name: string): Topics => ({
|
||||
[`esper_${name}_version`]: {
|
||||
state: {
|
||||
name: `/service/esper/${chipId}/info`,
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -2,7 +2,6 @@
|
|||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.2.0/dist/leaflet.css" integrity="sha512-M2wvCLH6DSRazYeZRIm1JnYyh22purTM+FDB5CsyxtQJYeKq83arPe5wgbNmcFXGqiSH2XR8dT/fJISVA1r/zQ==" crossorigin=""/>
|
||||
<title><%= htmlWebpackPlugin.options.title %></title>
|
||||
</head>
|
||||
<body>
|
||||
|
|
|
|||
63
package.json
63
package.json
|
|
@ -1,10 +1,10 @@
|
|||
{
|
||||
"name": "mqtt-control-map",
|
||||
"version": "1.0.0",
|
||||
"author": "uwap <me+mqttmap.package.json@uwap.name>",
|
||||
"description": "control devices via mqtt on a beautiful map of your space",
|
||||
"author": "uwap <me@uwap.name>",
|
||||
"description": "Control Devices via mqtt, visualized on a Map",
|
||||
"scripts": {
|
||||
"build": "webpack --bail --config webpack.config.js -p --env",
|
||||
"build": "webpack --bail --config webpack.config.js --mode production --env",
|
||||
"dev": "webpack --bail --config webpack.config.js --mode development --env",
|
||||
"watch": "webpack-dev-server --open --config webpack.config.js --mode development --env",
|
||||
"travis": "./travis.sh",
|
||||
|
|
@ -12,45 +12,52 @@
|
|||
"precommit": "yarn lint"
|
||||
},
|
||||
"dependencies": {
|
||||
"@material-ui/core": "^3.0.1",
|
||||
"@material-ui/lab": "^3.0.0-alpha.16",
|
||||
"@mdi/font": "^5.3.45",
|
||||
"@emotion/react": "^11.10.5",
|
||||
"@emotion/styled": "^11.10.5",
|
||||
"@fontsource/roboto": "^4.5.8",
|
||||
"@mdi/react": "^1.4.0",
|
||||
"@mui/material": "^5.10.15",
|
||||
"@mui/styles": "^5.10.15",
|
||||
"leaflet": "^1.5.1",
|
||||
"lodash-es": "^4.17.15",
|
||||
"mqtt": "^3.0.0",
|
||||
"react": "^16.8.6",
|
||||
"react-dom": "^16.8.6",
|
||||
"react-leaflet": "^2.4.0",
|
||||
"redux": "^4.0.4"
|
||||
"mqtt": "^4.2.1",
|
||||
"react": "^18.2.0",
|
||||
"react-dom": "^18.2.0",
|
||||
"react-leaflet": "^4.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/cli": "^7.5.5",
|
||||
"@babel/core": "^7.5.5",
|
||||
"@babel/plugin-proposal-class-properties": "^7.5.5",
|
||||
"@babel/plugin-proposal-object-rest-spread": "^7.5.5",
|
||||
"@babel/polyfill": "^7.4.4",
|
||||
"@babel/preset-env": "^7.5.5",
|
||||
"@babel/preset-flow": "^7.0.0-rc.1",
|
||||
"@babel/preset-react": "^7.0.0-rc.1",
|
||||
"@mdi/js": "^7.0.96",
|
||||
"babel-eslint": "^10.0.2",
|
||||
"babel-loader": "^8.0.6",
|
||||
"clean-webpack-plugin": "^2.0.0",
|
||||
"css-loader": "^3.0.0",
|
||||
"eslint": "^6.1.0",
|
||||
"eslint-plugin-flowtype": "^4.0.0",
|
||||
"babel-loader": "^9.1.0",
|
||||
"buffer": "^6.0.3",
|
||||
"clean-webpack-plugin": "^4.0.0",
|
||||
"core-js": "^3.6.0",
|
||||
"css-loader": "^6.7.2",
|
||||
"eslint": "^8.28.0",
|
||||
"eslint-plugin-flowtype": "^8.0.3",
|
||||
"eslint-plugin-fp": "^2.3.0",
|
||||
"eslint-plugin-react": "^7.14.3",
|
||||
"file-loader": "^5.0.0",
|
||||
"eslint-plugin-react-hooks": "^4.1.2",
|
||||
"file-loader": "^6.1.0",
|
||||
"flow": "^0.2.3",
|
||||
"flow-bin": "^0.82.0",
|
||||
"flow-typed": "^2.3.0",
|
||||
"html-webpack-plugin": "^3.1.0",
|
||||
"husky": "^3.0.0",
|
||||
"style-loader": "^0.23.0",
|
||||
"webpack": "^4.39.1",
|
||||
"webpack-cli": "^3.3.6",
|
||||
"webpack-dev-server": "^3.7.2",
|
||||
"webpack-shell-plugin": "^0.5.0"
|
||||
"flow-bin": "^0.193.0",
|
||||
"flow-typed": "^3.2.1",
|
||||
"html-webpack-plugin": "^5.5.0",
|
||||
"husky": "^8.0.2",
|
||||
"lodash-es": "^4.17.15",
|
||||
"process": "^0.11.10",
|
||||
"style-loader": "^3.3.1",
|
||||
"url": "^0.11.0",
|
||||
"webpack": "^5.75.0",
|
||||
"webpack-cli": "^5.0.0",
|
||||
"webpack-dev-server": "^4.11.1",
|
||||
"webpack-shell-plugin-next": "^2.3.1"
|
||||
},
|
||||
"license": "MIT"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,13 +9,10 @@ import throttle from "lodash/throttle";
|
|||
|
||||
import type { Config, Control, Topics } from "config/flowtypes";
|
||||
|
||||
import MuiThemeProvider from "@material-ui/core/styles/MuiThemeProvider";
|
||||
import createMuiTheme from "@material-ui/core/styles/createMuiTheme";
|
||||
import withStyles from "@material-ui/core/styles/withStyles";
|
||||
import * as Colors from "@material-ui/core/colors";
|
||||
import Snackbar from "@material-ui/core/Snackbar";
|
||||
import IconButton from "@material-ui/core/IconButton";
|
||||
import Typography from "@material-ui/core/Typography";
|
||||
import { withStyles } from "@mui/styles";
|
||||
import Snackbar from "@mui/material/Snackbar";
|
||||
import IconButton from "@mui/material/IconButton";
|
||||
import Typography from "@mui/material/Typography";
|
||||
|
||||
import SideBar from "components/SideBar";
|
||||
import ControlMap from "components/ControlMap";
|
||||
|
|
@ -39,6 +36,14 @@ export type AppState = {
|
|||
error: ?string
|
||||
};
|
||||
|
||||
/*
|
||||
*const App = (props: AppProps) => {
|
||||
* const topics = Array.isArray(props.config.topics) ?
|
||||
* Object.assign({}, ...props.config.topics) : props.config.topics;
|
||||
* const [mqttConnected, setMqttConnected] = useState(false);
|
||||
*};
|
||||
*/
|
||||
|
||||
class App extends React.PureComponent<AppProps & Classes, AppState> {
|
||||
controlMap: React.Node
|
||||
|
||||
|
|
@ -55,7 +60,8 @@ class App extends React.PureComponent<AppProps & Classes, AppState> {
|
|||
onDisconnect: () => this.setState({ mqttConnected: false }),
|
||||
subscribe: map(
|
||||
filter(keys(this.topics), (x) => this.topics[x].state != null),
|
||||
(x) => this.topics[x].state.name)
|
||||
(x) => (this.topics[x].state != null ? this.topics[x].state.name : "")
|
||||
)
|
||||
}),
|
||||
mqttConnected: false,
|
||||
search: "",
|
||||
|
|
@ -94,14 +100,6 @@ class App extends React.PureComponent<AppProps & Classes, AppState> {
|
|||
};
|
||||
}
|
||||
|
||||
static theme(config: Config) {
|
||||
return createMuiTheme({
|
||||
palette: {
|
||||
primary: Colors[config.space.color]
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
receiveMessage(rawTopic: string, message: Buffer) {
|
||||
try {
|
||||
const topics = filter(
|
||||
|
|
@ -115,8 +113,8 @@ class App extends React.PureComponent<AppProps & Classes, AppState> {
|
|||
for (let i in topics) {
|
||||
const topic = topics[i];
|
||||
const stateTopic = this.topics[topic].state;
|
||||
const parseVal = stateTopic ? stateTopic.type : null;
|
||||
const val = parseVal == null ? message.toString() : parseVal(message);
|
||||
const typeConversion = stateTopic?.type?.from ?? stateTopic?.type;
|
||||
const val = (typeConversion ?? ((x: Buffer) => x.toString()))(message);
|
||||
this.setMqttStateDebounced(
|
||||
{mqttState: Object.assign({},
|
||||
merge(this.state.mqttState, { [topic]: val}))});
|
||||
|
|
@ -136,16 +134,16 @@ class App extends React.PureComponent<AppProps & Classes, AppState> {
|
|||
this.setState({drawerOpened: false});
|
||||
}
|
||||
|
||||
changeState = (topic: string, value: string) => {
|
||||
changeState = (topic: string, val: string) => {
|
||||
try {
|
||||
if (this.topics[topic].command == null) {
|
||||
const commandTopic = this.topics[topic].command;
|
||||
if (commandTopic == null) {
|
||||
return;
|
||||
}
|
||||
const rawTopic = this.topics[topic].command.name;
|
||||
const transformValue = this.topics[topic].command.type;
|
||||
const val =
|
||||
transformValue == null ? value : transformValue(Buffer.from(value));
|
||||
this.state.mqttSend(rawTopic, Buffer.from(val));
|
||||
const rawTopic = commandTopic.name;
|
||||
const typeConversion = commandTopic?.type?.to ?? commandTopic.type;
|
||||
const value = (typeConversion ?? Buffer.from)(val);
|
||||
this.state.mqttSend(rawTopic, value);
|
||||
} catch (err) {
|
||||
this.setState({ error: err.toString() });
|
||||
}
|
||||
|
|
@ -170,7 +168,7 @@ class App extends React.PureComponent<AppProps & Classes, AppState> {
|
|||
control={this.state.selectedControl}
|
||||
onCloseRequest={this.closeDrawer}
|
||||
icon={this.state.selectedControl == null ? null :
|
||||
this.state.selectedControl.icon(this.state.mqttState)}
|
||||
this.state.selectedControl.icon.render(this.state.mqttState)}
|
||||
>
|
||||
{this.state.selectedControl == null
|
||||
|| <UiItemList controls={this.state.selectedControl.ui} />}
|
||||
|
|
@ -204,11 +202,6 @@ class App extends React.PureComponent<AppProps & Classes, AppState> {
|
|||
}
|
||||
}
|
||||
|
||||
export default (props: AppProps) => {
|
||||
const StyledApp = withStyles(App.styles)(App);
|
||||
return (
|
||||
<MuiThemeProvider theme={App.theme(props.config)}>
|
||||
<StyledApp {...props} />
|
||||
</MuiThemeProvider>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
export default withStyles(App.styles)(App);
|
||||
|
|
|
|||
|
|
@ -1,12 +1,15 @@
|
|||
// @flow
|
||||
import React from "react";
|
||||
import { Map, ImageOverlay, Marker, LayersControl } from "react-leaflet";
|
||||
import { MapContainer, ImageOverlay, Marker, LayersControl } from "react-leaflet";
|
||||
import { CRS, point, divIcon } from "leaflet";
|
||||
import map from "lodash/map";
|
||||
import filter from "lodash/filter";
|
||||
import reduce from "lodash/reduce";
|
||||
import MqttContext from "mqtt/context";
|
||||
import type { Controls, Control, UIControl, ControlUI } from "config/flowtypes";
|
||||
import type {
|
||||
Controls, Control, UIControl, ControlUI, Layer
|
||||
} from "config/flowtypes";
|
||||
import { renderToString } from "react-dom/server";
|
||||
|
||||
export type Point = [number, number];
|
||||
|
||||
|
|
@ -28,21 +31,11 @@ const center = (props: ControlMapProps): Point =>
|
|||
props.height / 2
|
||||
]);
|
||||
|
||||
const iconColor = (control: Control, state: State): string => {
|
||||
if (control.iconColor != null) {
|
||||
return control.iconColor(state);
|
||||
}
|
||||
return "#000";
|
||||
};
|
||||
|
||||
const createLeafletIcon = (control: Control, state: State) => {
|
||||
const icon = control.icon(state);
|
||||
const iconClass = `${icon} mdi-36px`;
|
||||
return divIcon({
|
||||
iconSize: point(36, 36),
|
||||
iconAnchor: point(18, 18),
|
||||
html: `<i class="${iconClass}"
|
||||
style="line-height: 1; color: ${iconColor(control, state)}"></i>`
|
||||
html: renderToString(control.icon.render(state))
|
||||
});
|
||||
};
|
||||
|
||||
|
|
@ -52,7 +45,9 @@ const renderMarker = (props: ControlMapProps) =>
|
|||
{({ state }) => (
|
||||
<Marker position={convertPoint(control.position)}
|
||||
icon={createLeafletIcon(control, state)}
|
||||
onClick={() => props.onChangeControl(control)}
|
||||
eventHandlers={{
|
||||
click: () => props.onChangeControl(control)
|
||||
}}
|
||||
>
|
||||
</Marker>
|
||||
)}
|
||||
|
|
@ -125,13 +120,13 @@ const renderLayers = (props: ControlMapProps) => (
|
|||
);
|
||||
|
||||
const ControlMap = (props: ControlMapProps) => (
|
||||
<Map center={center(props)}
|
||||
<MapContainer center={center(props)}
|
||||
zoom={props.zoom}
|
||||
crs={CRS.Simple}
|
||||
leaflet={{}}>
|
||||
{renderMarkers(props)}
|
||||
{renderLayers(props)}
|
||||
</Map>
|
||||
</MapContainer>
|
||||
);
|
||||
|
||||
export default ControlMap;
|
||||
|
|
|
|||
|
|
@ -1,45 +1,55 @@
|
|||
// @flow
|
||||
import * as React from "react";
|
||||
|
||||
import withStyles from "@material-ui/core/styles/withStyles";
|
||||
import Drawer from "@material-ui/core/Drawer";
|
||||
import Typography from "@material-ui/core/Typography";
|
||||
import IconButton from "@material-ui/core/IconButton";
|
||||
import AppBar from "@material-ui/core/AppBar";
|
||||
import Toolbar from "@material-ui/core/Toolbar";
|
||||
import List from "@material-ui/core/List";
|
||||
import { renderRawIcon } from "config/icon";
|
||||
import { makeStyles } from "@mui/styles";
|
||||
import Drawer from "@mui/material/Drawer";
|
||||
import Typography from "@mui/material/Typography";
|
||||
import IconButton from "@mui/material/IconButton";
|
||||
import AppBar from "@mui/material/AppBar";
|
||||
import Toolbar from "@mui/material/Toolbar";
|
||||
import List from "@mui/material/List";
|
||||
import ReactIcon from "@mdi/react";
|
||||
import { mdiClose } from "@mdi/js";
|
||||
|
||||
import type { RawIcon } from "config/icon";
|
||||
import type { Control } from "config/flowtypes";
|
||||
|
||||
export type SideBarProps = {
|
||||
control: ?Control,
|
||||
open: boolean,
|
||||
onCloseRequest: () => void,
|
||||
icon?: ?RawIcon,
|
||||
icon?: ?React.Node,
|
||||
children?: React.Node
|
||||
};
|
||||
|
||||
type Props = SideBarProps & Classes;
|
||||
const useStyles = makeStyles((theme) => ({
|
||||
drawerPaper: {
|
||||
width: 340
|
||||
},
|
||||
title: {
|
||||
flex: 1,
|
||||
marginLeft: theme.spacing(1)
|
||||
}
|
||||
}));
|
||||
|
||||
const SideBar = (props: Props) => (
|
||||
const SideBar = (props: SideBarProps) => {
|
||||
const classes = useStyles();
|
||||
return (
|
||||
<Drawer open={props.open}
|
||||
anchor="right"
|
||||
onClose={props.onCloseRequest}
|
||||
classes={{paper: props.classes.drawerPaper}}
|
||||
classes={{paper: classes.drawerPaper}}
|
||||
variant="persistent"
|
||||
>
|
||||
<AppBar position="static">
|
||||
<Toolbar>
|
||||
<span>
|
||||
{props.icon == null || renderRawIcon(props.icon, "mdi-36px")}
|
||||
{props.icon == null || props.icon}
|
||||
</span>
|
||||
<Typography variant="title" className={props.classes.title}>
|
||||
<Typography variant="subtitle1" className={classes.title}>
|
||||
{props.control == null ? "" : props.control.name}
|
||||
</Typography>
|
||||
<IconButton onClick={props.onCloseRequest}>
|
||||
<i className="mdi mdi-close"></i>
|
||||
<ReactIcon path={mdiClose} size={1.5} />
|
||||
</IconButton>
|
||||
</Toolbar>
|
||||
</AppBar>
|
||||
|
|
@ -47,16 +57,7 @@ const SideBar = (props: Props) => (
|
|||
<React.Fragment>{props.children}</React.Fragment>
|
||||
</List>
|
||||
</Drawer>
|
||||
);
|
||||
);
|
||||
};
|
||||
|
||||
const styles = (theme) => ({
|
||||
drawerPaper: {
|
||||
width: 340
|
||||
},
|
||||
title: {
|
||||
flex: 1,
|
||||
marginLeft: theme.spacing.unit
|
||||
}
|
||||
});
|
||||
|
||||
export default withStyles(styles)(SideBar);
|
||||
export default SideBar;
|
||||
|
|
|
|||
|
|
@ -1,14 +1,16 @@
|
|||
// @flow
|
||||
import React from "react";
|
||||
|
||||
import AppBar from "@material-ui/core/AppBar";
|
||||
import Toolbar from "@material-ui/core/Toolbar";
|
||||
import CircularProgress from "@material-ui/core/CircularProgress";
|
||||
import InputBase from "@material-ui/core/InputBase";
|
||||
import { fade } from "@material-ui/core/styles/colorManipulator";
|
||||
import { withStyles } from "@material-ui/core/styles";
|
||||
import Tooltip from "@material-ui/core/Tooltip";
|
||||
import IconButton from "@material-ui/core/IconButton";
|
||||
import AppBar from "@mui/material/AppBar";
|
||||
import Toolbar from "@mui/material/Toolbar";
|
||||
import CircularProgress from "@mui/material/CircularProgress";
|
||||
import InputBase from "@mui/material/InputBase";
|
||||
import { styled } from "@mui/styles";
|
||||
import { alpha } from "@mui/material/styles";
|
||||
import Tooltip from "@mui/material/Tooltip";
|
||||
import IconButton from "@mui/material/IconButton";
|
||||
import ReactIcon from "@mdi/react";
|
||||
import { mdiMap, mdiGithub, mdiMagnify } from "@mdi/js";
|
||||
|
||||
export type TopBarProps = {
|
||||
connected: boolean,
|
||||
|
|
@ -21,89 +23,74 @@ export type SearchBarProps = {
|
|||
|
||||
const renderConnectionIndicator = (connected: boolean) => {
|
||||
if (connected) {
|
||||
return (<i style={{fontSize: 32}} className="mdi mdi-map"></i>);
|
||||
return (<ReactIcon path={mdiMap} size={2} />);
|
||||
}
|
||||
return (
|
||||
<CircularProgress size={32} style={{color: "rgba(0, 0, 0, 0.54)"}} />
|
||||
);
|
||||
};
|
||||
|
||||
const searchStyles = (theme) => ({
|
||||
search: {
|
||||
position: "relative",
|
||||
const Search = styled('div')(({ theme }) => ({
|
||||
position: 'relative',
|
||||
borderRadius: theme.shape.borderRadius,
|
||||
backgroundColor: fade(theme.palette.common.white, 0.15),
|
||||
"&:hover": {
|
||||
backgroundColor: fade(theme.palette.common.white, 0.25)
|
||||
backgroundColor: alpha(theme.palette.common.white, 0.15),
|
||||
'&:hover': {
|
||||
backgroundColor: alpha(theme.palette.common.white, 0.25),
|
||||
},
|
||||
marginRight: theme.spacing.unit * 2,
|
||||
marginRight: theme.spacing(2),
|
||||
marginLeft: 0,
|
||||
width: "100%",
|
||||
[theme.breakpoints.up("sm")]: {
|
||||
marginLeft: theme.spacing.unit * 3,
|
||||
width: "auto"
|
||||
}
|
||||
width: '100%',
|
||||
[theme.breakpoints.up('sm')]: {
|
||||
marginLeft: theme.spacing(3),
|
||||
width: 'auto',
|
||||
},
|
||||
searchIcon: {
|
||||
width: theme.spacing.unit * 6,
|
||||
height: "100%",
|
||||
position: "absolute",
|
||||
pointerEvents: "none",
|
||||
display: "flex",
|
||||
alignItems: "center",
|
||||
justifyContent: "center",
|
||||
fontSize: "24px"
|
||||
},
|
||||
inputRoot: {
|
||||
color: "inherit",
|
||||
width: "100%"
|
||||
},
|
||||
inputInput: {
|
||||
paddingTop: theme.spacing.unit,
|
||||
paddingRight: theme.spacing.unit,
|
||||
paddingBottom: theme.spacing.unit,
|
||||
paddingLeft: theme.spacing.unit * 6,
|
||||
transition: theme.transitions.create("width"),
|
||||
width: "100%",
|
||||
[theme.breakpoints.up("md")]: {
|
||||
width: 200
|
||||
}
|
||||
}
|
||||
});
|
||||
}));
|
||||
|
||||
const RawSearch = (props: SearchBarProps & Classes) => (
|
||||
<div className={props.classes.search}>
|
||||
<i className={`mdi mdi-magnify ${props.classes.searchIcon}`}></i>
|
||||
<InputBase placeholder="Search…" type="search"
|
||||
onChange={(e) => props.onSearch(e.target.value)}
|
||||
classes={{
|
||||
root: props.classes.inputRoot,
|
||||
input: props.classes.inputInput
|
||||
}} />
|
||||
</div>
|
||||
);
|
||||
const SearchIconWrapper = styled('div')(({ theme }) => ({
|
||||
padding: theme.spacing(0, 2),
|
||||
height: '100%',
|
||||
position: 'absolute',
|
||||
pointerEvents: 'none',
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
}));
|
||||
|
||||
const Search = withStyles(searchStyles)(RawSearch);
|
||||
const StyledInputBase = styled(InputBase)(({ theme }) => ({
|
||||
color: 'inherit',
|
||||
'& .MuiInputBase-input': {
|
||||
padding: theme.spacing(1, 1, 1, 0),
|
||||
// vertical padding + font size from searchIcon
|
||||
paddingLeft: `calc(1em + ${theme.spacing(4)})`,
|
||||
transition: theme.transitions.create('width'),
|
||||
width: '100%',
|
||||
[theme.breakpoints.up('md')]: {
|
||||
width: '20ch',
|
||||
},
|
||||
},
|
||||
}));
|
||||
|
||||
const openOnGithub = () => window.open(
|
||||
"https://github.com/uwap/mqtt-control-map", "_blank");
|
||||
|
||||
const sendFeedback = () => window.open("mailto:mail+feedback@uwap.name");
|
||||
|
||||
const TopBar = (props: TopBarProps) => (
|
||||
<AppBar position="static">
|
||||
<AppBar position="static" color="primary">
|
||||
<Toolbar>
|
||||
{renderConnectionIndicator(props.connected)}
|
||||
<Search onSearch={props.onSearch} />
|
||||
<Search>
|
||||
<SearchIconWrapper>
|
||||
<ReactIcon path={mdiMagnify} size={1} />
|
||||
</SearchIconWrapper>
|
||||
<StyledInputBase
|
||||
placeholder="Search…"
|
||||
inputProps={{ 'aria-label': 'search' }}
|
||||
onChange={(e) => props.onSearch(e.target.value)}
|
||||
/>
|
||||
</Search>
|
||||
<span style={{flex: 1}}></span>
|
||||
<Tooltip title="Github">
|
||||
<IconButton onClick={openOnGithub} style={{ fontSize: "28px" }}>
|
||||
<i className="mdi mdi-github-circle"></i>
|
||||
</IconButton>
|
||||
</Tooltip>
|
||||
<Tooltip title="Send me feedback">
|
||||
<IconButton onClick={sendFeedback} style={{ fontSize: "28px" }}>
|
||||
<i className="mdi mdi-email-plus"></i>
|
||||
<Tooltip title="View on Github">
|
||||
<IconButton onClick={openOnGithub}>
|
||||
<ReactIcon path={mdiGithub} size={1.5} />
|
||||
</IconButton>
|
||||
</Tooltip>
|
||||
</Toolbar>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
// @flow
|
||||
import * as React from "react";
|
||||
import ListItem from "@material-ui/core/ListItem";
|
||||
import ListItem from "@mui/material/ListItem";
|
||||
|
||||
import type { ControlUI } from "config/flowtypes";
|
||||
|
||||
|
|
|
|||
|
|
@ -6,11 +6,11 @@ import { isDisabled, getValue } from "./utils";
|
|||
|
||||
import type { UIDropDown } from "config/flowtypes";
|
||||
|
||||
import Select from "@material-ui/core/Select";
|
||||
import FormControl from "@material-ui/core/FormControl";
|
||||
import InputLabel from "@material-ui/core/InputLabel";
|
||||
import MenuItem from "@material-ui/core/MenuItem";
|
||||
import Input from "@material-ui/core/Input";
|
||||
import Select from "@mui/material/Select";
|
||||
import FormControl from "@mui/material/FormControl";
|
||||
import InputLabel from "@mui/material/InputLabel";
|
||||
import MenuItem from "@mui/material/MenuItem";
|
||||
import Input from "@mui/material/Input";
|
||||
|
||||
const componentId = (item: UIDropDown) => `dropdown-${item.topic}`;
|
||||
|
||||
|
|
|
|||
|
|
@ -2,11 +2,10 @@
|
|||
import React from "react";
|
||||
import createComponent from "./base";
|
||||
import { isEnabled, isDisabled } from "./utils";
|
||||
import { renderRawIcon } from "config/icon";
|
||||
|
||||
import type { UILink } from "config/flowtypes";
|
||||
|
||||
import Button from "@material-ui/core/Button";
|
||||
import Button from "@mui/material/Button";
|
||||
|
||||
const followLink = (item, state) => () => {
|
||||
if (isEnabled(item, state)) {
|
||||
|
|
@ -19,7 +18,7 @@ const Icon = ({item, state}) => {
|
|||
if (item.icon == null) {
|
||||
return false;
|
||||
}
|
||||
return renderRawIcon(item.icon(state), "mdi-24px");
|
||||
return item.icon.render(state);
|
||||
};
|
||||
|
||||
const BaseComponent = (_h, item: UILink, state, _changeState) => (
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import { getValue } from "./utils";
|
|||
|
||||
import type { UIProgress } from "config/flowtypes";
|
||||
|
||||
import LinearProgress from "@material-ui/core/LinearProgress";
|
||||
import LinearProgress from "@mui/material/LinearProgress";
|
||||
|
||||
const progressVal = (item, state) => {
|
||||
const min = item.min || 0;
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import createComponent from "./base";
|
|||
|
||||
import type { UISection } from "config/flowtypes";
|
||||
|
||||
import ListSubheader from "@material-ui/core/ListSubheader";
|
||||
import ListSubheader from "@mui/material/ListSubheader";
|
||||
|
||||
const BaseComponent = (_b, item: UISection, _state, _changeState) => (
|
||||
<ListSubheader>{item.text}</ListSubheader>
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import { isDisabled, getValue } from "./utils";
|
|||
|
||||
import type { UISlider } from "config/flowtypes";
|
||||
|
||||
import SliderComponent from "@material-ui/lab/Slider";
|
||||
import SliderComponent from "@mui/material/Slider";
|
||||
|
||||
const changeSliderValue = (item: UISlider, changeState) => (_e, v) =>
|
||||
changeState(item, v.toString());
|
||||
|
|
@ -16,10 +16,12 @@ const BaseComponent = ({Icon, Label}, item, state, changeState) => (
|
|||
<Label />
|
||||
<SliderComponent
|
||||
value={parseFloat(getValue(item, state))}
|
||||
min={item.min || 0} max={item.max || 100}
|
||||
step={item.step || 1}
|
||||
min={item.min ?? 0} max={item.max ?? 100}
|
||||
step={item.step}
|
||||
marks={item.marks ?? false}
|
||||
onChange={changeSliderValue(item, changeState)}
|
||||
disabled={isDisabled(item, state)}
|
||||
valueLabelDisplay="auto"
|
||||
style={{marginLeft: 40}} />
|
||||
</React.Fragment>
|
||||
);
|
||||
|
|
@ -36,5 +38,3 @@ export default createComponent({
|
|||
},
|
||||
baseComponent: BaseComponent
|
||||
});
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import { getValue } from "./utils";
|
|||
|
||||
import type { UIText } from "config/flowtypes";
|
||||
|
||||
import ListItemText from "@material-ui/core/ListItemText";
|
||||
import ListItemText from "@mui/material/ListItemText";
|
||||
|
||||
const BaseComponent = ({Icon}, item: UIText, state, _changeState) => (
|
||||
<React.Fragment>
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import { isDisabled, isEnabled, getValue } from "./utils";
|
|||
|
||||
import type { UIToggle } from "config/flowtypes";
|
||||
|
||||
import Switch from "@material-ui/core/Switch";
|
||||
import Switch from "@mui/material/Switch";
|
||||
|
||||
const isToggled = (item: UIToggle, state: State) => {
|
||||
const isChecked = item.toggled ||
|
||||
|
|
|
|||
|
|
@ -2,18 +2,17 @@
|
|||
import * as React from "react";
|
||||
import MqttContext from "mqtt/context";
|
||||
|
||||
import ListItemSecondaryAction from "@material-ui/core/ListItemSecondaryAction";
|
||||
import ListItemText from "@material-ui/core/ListItemText";
|
||||
import ListItemIcon from "@material-ui/core/ListItemIcon";
|
||||
import ListItemSecondaryAction from "@mui/material/ListItemSecondaryAction";
|
||||
import ListItemText from "@mui/material/ListItemText";
|
||||
import ListItemIcon from "@mui/material/ListItemIcon";
|
||||
|
||||
import throttle from "lodash/throttle";
|
||||
import { renderRawIcon } from "config/icon";
|
||||
import type { Icon } from "config/icon";
|
||||
|
||||
export type Helpers = {
|
||||
Icon: (props: Object) => React.Node,
|
||||
Label: (props: Object) => React.Node,
|
||||
Action: (props: Object) => React.Node
|
||||
Icon: (props: { item: { +icon?: Icon }, state: State }) => React.Node,
|
||||
Label: (props: {}) => React.Node,
|
||||
Action: (props: {}) => React.Node
|
||||
};
|
||||
|
||||
export type BaseComponent<T> = (
|
||||
|
|
@ -41,15 +40,15 @@ type SuperT = $ReadOnly<{ text: string }>;
|
|||
|
||||
const IconHelper = ({item, state}: { item: { +icon?: Icon }, state: State }) =>
|
||||
( <ListItemIcon>
|
||||
{item.icon == null || renderRawIcon(item.icon(state), "mdi-24px")}
|
||||
{item.icon == null || item.icon.size(1).render(state)}
|
||||
</ListItemIcon>
|
||||
);
|
||||
|
||||
const createHelpers = <T: SuperT> (item: T) =>
|
||||
({
|
||||
Icon: IconHelper,
|
||||
Label: (props) => (
|
||||
<ListItemText primary={item.text} {...props} />
|
||||
Label: () => (
|
||||
<ListItemText primary={item.text} />
|
||||
),
|
||||
Action: (props) => (
|
||||
<ListItemSecondaryAction {...props} />
|
||||
|
|
|
|||
|
|
@ -6,10 +6,11 @@ import Link from "./Link";
|
|||
import Slider from "./Slider";
|
||||
import Text from "./Text";
|
||||
import Progress from "./Progress";
|
||||
import * as React from "react";
|
||||
|
||||
import type { ControlUI } from "config/flowtypes";
|
||||
|
||||
const Control = ({item}: {item: ControlUI}) => {
|
||||
const Control = ({item}: {item: ControlUI}): React.Node => {
|
||||
switch (item.type) {
|
||||
case "toggle": {
|
||||
return Toggle.component(item);
|
||||
|
|
|
|||
|
|
@ -1,17 +1,22 @@
|
|||
// @flow
|
||||
import type { Color } from "config/colors";
|
||||
import type { Icon } from "config/icon";
|
||||
|
||||
export type TopicType = (msg: Buffer) => string;
|
||||
export type TopicType = {
|
||||
from: (msg: Buffer) => string,
|
||||
to: (newstate: string) => Buffer
|
||||
};
|
||||
|
||||
export type StateCommand = {
|
||||
export type StateTopicType = TopicType | ((msg: Buffer) => string);
|
||||
export type CommandTopicType = TopicType | ((newstate: string) => Buffer);
|
||||
|
||||
export type StateCommand<T> = {
|
||||
name: string,
|
||||
type: TopicType
|
||||
type: T
|
||||
}
|
||||
|
||||
export type Topic = {
|
||||
state?: StateCommand,
|
||||
command?: StateCommand,
|
||||
state?: StateCommand<StateTopicType>,
|
||||
command?: StateCommand<CommandTopicType>,
|
||||
defaultValue: string
|
||||
};
|
||||
export type Topics = Map<string, Topic>;
|
||||
|
|
@ -53,9 +58,10 @@ export type UISlider = $ReadOnly<{|
|
|||
topic: string,
|
||||
icon?: Icon,
|
||||
enableCondition?: (s: State) => boolean,
|
||||
marks?: boolean | Array<{ value: number, label: string}>,
|
||||
min?: number,
|
||||
max?: number,
|
||||
step?: number
|
||||
step?: ?number
|
||||
|}>;
|
||||
|
||||
export type UISection = $ReadOnly<{|
|
||||
|
|
@ -100,7 +106,6 @@ export type Control = {
|
|||
name: string,
|
||||
position: [number, number],
|
||||
icon: Icon,
|
||||
iconColor?: (state: State) => Color,
|
||||
ui: Array<ControlUI>
|
||||
};
|
||||
export type Controls = Map<string, Control>;
|
||||
|
|
@ -116,6 +121,17 @@ export type Space = {
|
|||
mqtt: string
|
||||
};
|
||||
|
||||
export type Layer = {
|
||||
image: string,
|
||||
name: string,
|
||||
baseLayer?: boolean,
|
||||
defaultVisibility: "visible" | "hidden",
|
||||
opacity?: number,
|
||||
bounds: {
|
||||
topLeft: Point,
|
||||
bottomRight: Point
|
||||
}
|
||||
};
|
||||
export type Config = {
|
||||
space: Space,
|
||||
topics: Topics | Array<Topics>,
|
||||
|
|
|
|||
|
|
@ -1,55 +1,88 @@
|
|||
// @flow
|
||||
import * as React from "react";
|
||||
import ReactContext from "mqtt/context";
|
||||
import React from "react";
|
||||
import ReactIcon from "@mdi/react";
|
||||
import { type Color } from "./colors";
|
||||
import * as mdiIcons from "@mdi/js";
|
||||
|
||||
export opaque type RawIcon: string = string;
|
||||
|
||||
export type Icon = (State) => RawIcon;
|
||||
|
||||
export const rawMdi = (name: string): RawIcon => {
|
||||
return `mdi ${name.split(" ").map((icon) => "mdi-".concat(icon)).join(" ")}`;
|
||||
type IconPropHelper = {
|
||||
size?: number,
|
||||
rotate?: number,
|
||||
horizontal?: boolean,
|
||||
vertical?: boolean,
|
||||
color?: Color
|
||||
};
|
||||
|
||||
export const mdi = (icon: string) => () => rawMdi(icon);
|
||||
export type Icon = {
|
||||
render: (s: State) => React.Node,
|
||||
size: (n: number) => Icon,
|
||||
rotate: (n: number) => Icon,
|
||||
flip: () => Icon,
|
||||
flipV: () => Icon,
|
||||
color: (c: Color | (State) => Color) => Icon,
|
||||
applyProps: (props: IconPropHelper) => Icon
|
||||
};
|
||||
|
||||
export const mdiBattery = (topic: string) => (state: State) => {
|
||||
const iconChainUtils = <T> (cb: (x: T, p?: IconPropHelper) => Icon,
|
||||
p1: T, p?: IconPropHelper) => ({
|
||||
size: (n: number) => cb(p1, {...p, size: n}),
|
||||
rotate: (n: number) => cb(p1, {...p, rotate: n}),
|
||||
flip: () => cb(p1, {...p, horizontal: !p?.horizontal ?? true}),
|
||||
flipV: () => cb(p1, {...p, vertical: !p?.vertical ?? true}),
|
||||
color: (c: Color | (State) => Color) => cb(p1, {...p, color: c}),
|
||||
applyProps: (props: IconPropHelper) => cb(p1, {...p, ...props})
|
||||
}
|
||||
);
|
||||
|
||||
export const svg = (data: string, props?: IconPropHelper): Icon => {
|
||||
const propColor = ((c: ?Color | (State) => Color) => (state: State) => {
|
||||
if (typeof c === "function") {
|
||||
return c(state);
|
||||
}
|
||||
return c;
|
||||
})(props?.color);
|
||||
return {
|
||||
render: (state) => (
|
||||
<ReactIcon path={data} size={props?.size ?? 1.5}
|
||||
rotate={props?.rotate ?? 0}
|
||||
horizontal={props?.horizontal ?? false}
|
||||
vertical={props?.vertical ?? false}
|
||||
color={propColor(state)}
|
||||
/>
|
||||
),
|
||||
...iconChainUtils(svg, data, props)
|
||||
};
|
||||
};
|
||||
|
||||
export const withState = (f: (s: State) => Icon,
|
||||
props?: IconPropHelper): Icon => ({
|
||||
render: (state) => f(state).applyProps(props).render(state),
|
||||
...iconChainUtils(withState, f, props)
|
||||
}
|
||||
);
|
||||
|
||||
export const mdiBattery = (topic: string): Icon => withState((state) => {
|
||||
const rawval = state[topic];
|
||||
const val = parseInt(rawval, 10);
|
||||
if (isNaN(val)) {
|
||||
return rawMdi("battery-unknown");
|
||||
return svg(mdiIcons.mdiBatteryUnknown);
|
||||
} else if (val > 95) {
|
||||
return rawMdi("battery");
|
||||
return svg(mdiIcons.mdiBattery);
|
||||
} else if (val > 85) {
|
||||
return rawMdi("battery-90");
|
||||
return svg(mdiIcons.mdiBattery90);
|
||||
} else if (val > 75) {
|
||||
return rawMdi("battery-80");
|
||||
return svg(mdiIcons.mdiBattery80);
|
||||
} else if (val > 65) {
|
||||
return rawMdi("battery-70");
|
||||
return svg(mdiIcons.mdiBattery70);
|
||||
} else if (val > 55) {
|
||||
return rawMdi("battery-60");
|
||||
return svg(mdiIcons.mdiBattery60);
|
||||
} else if (val > 45) {
|
||||
return rawMdi("battery-50");
|
||||
return svg(mdiIcons.mdiBattery50);
|
||||
} else if (val > 35) {
|
||||
return rawMdi("battery-40");
|
||||
return svg(mdiIcons.mdiBattery40);
|
||||
} else if (val > 25) {
|
||||
return rawMdi("battery-30");
|
||||
return svg(mdiIcons.mdiBattery30);
|
||||
} else if (val > 15) {
|
||||
return rawMdi("battery-20");
|
||||
} else {
|
||||
return rawMdi("battery-10");
|
||||
return svg(mdiIcons.mdiBattery20);
|
||||
}
|
||||
};
|
||||
|
||||
export const renderRawIcon =
|
||||
(icon: RawIcon, extraClass?: string): React.Node => {
|
||||
return <i className={`${extraClass || ""} ${icon}`}></i>;
|
||||
};
|
||||
|
||||
export const renderIcon =
|
||||
(icon: Icon, extraClass?: string): React.Node => {
|
||||
return (
|
||||
<ReactContext.Consumer>
|
||||
{({state}) => renderRawIcon(icon(state), extraClass)}
|
||||
</ReactContext.Consumer>
|
||||
);
|
||||
};
|
||||
return svg(mdiIcons.mdiBattery10);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,13 +1,22 @@
|
|||
// @flow
|
||||
import type { TopicType } from "config/flowtypes";
|
||||
import at from "lodash/at";
|
||||
import set from "lodash/set";
|
||||
|
||||
export const string: TopicType = (msg: Buffer) => msg.toString();
|
||||
export const string: TopicType = {
|
||||
from: (msg: Buffer) => msg.toString(),
|
||||
to: (msg: string) => Buffer.from(msg)
|
||||
};
|
||||
|
||||
export const json = (path: string, innerType?: TopicType): TopicType => {
|
||||
const parseAgain = innerType == null ? (x) => x.toString() : innerType;
|
||||
return (msg) => parseAgain(Buffer.from(
|
||||
at(JSON.parse(msg.toString()), path)[0].toString()));
|
||||
const parseAgain = innerType?.from ?? ((x) => x.toString());
|
||||
const parseFirst = innerType?.to ?? ((x) => Buffer.from(x));
|
||||
return {
|
||||
from: (msg) => parseAgain(Buffer.from(
|
||||
at(JSON.parse(msg.toString()), path)[0].toString())),
|
||||
to: (msg) => Buffer.from(
|
||||
JSON.stringify(set({}, path, parseFirst(msg).toString())))
|
||||
};
|
||||
};
|
||||
|
||||
export type TypeOptionParam = { otherwise?: string, [string]: string };
|
||||
|
|
@ -16,13 +25,17 @@ export const option = (values: TypeOptionParam): TopicType => {
|
|||
if (values.otherwise != null) {
|
||||
return values.otherwise;
|
||||
} else {
|
||||
throw new Error(
|
||||
`Value ${x.toString()} cannot by mapped by the option parameters given`
|
||||
);
|
||||
return x;
|
||||
}
|
||||
};
|
||||
const mapVal = (x) => (values[x] != null ? values[x] : defaultValue(x));
|
||||
return (x) => mapVal(x.toString());
|
||||
return {
|
||||
from: (x) => mapVal(x.toString()),
|
||||
to: (x) => Buffer.from(mapVal(x))
|
||||
};
|
||||
};
|
||||
|
||||
export const jsonArray = (msg: Buffer) => JSON.parse(msg.toString()).join(", ");
|
||||
export const jsonArray = {
|
||||
from: (msg: Buffer) => JSON.parse(msg.toString()).join(", "),
|
||||
to: (msg: string) => Buffer.from(`[${msg}]`)
|
||||
};
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ export default function connectMqtt(
|
|||
}
|
||||
});
|
||||
return (topic: string, message: Buffer) => {
|
||||
client.publish(topic, message, null, (error) => {
|
||||
client.publish(topic, message, {}, (error) => {
|
||||
if (error == null && settings.onMessageSent != null) {
|
||||
settings.onMessageSent(topic, message);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,20 @@
|
|||
// @flow
|
||||
import "core-js/stable";
|
||||
import "regenerator-runtime/runtime";
|
||||
import "../node_modules/leaflet/dist/leaflet.css";
|
||||
import '@fontsource/roboto/300.css';
|
||||
import '@fontsource/roboto/400.css';
|
||||
import '@fontsource/roboto/500.css';
|
||||
import '@fontsource/roboto/700.css';
|
||||
|
||||
import React from "react";
|
||||
import ReactDOM from "react-dom";
|
||||
|
||||
import App from "components/App";
|
||||
import { createTheme } from "@mui/material/styles";
|
||||
import { ThemeProvider } from "@mui/styles";
|
||||
import * as Colors from "@mui/material/colors";
|
||||
|
||||
import "../node_modules/@mdi/font/css/materialdesignicons.min.css";
|
||||
import "../css/styles.css";
|
||||
|
||||
import type { Config } from "config/flowtypes";
|
||||
|
|
@ -13,6 +23,21 @@ const config: Config = window.config;
|
|||
|
||||
document.title = `${config.space.name} Map`;
|
||||
|
||||
const theme = createTheme({
|
||||
palette: {
|
||||
primary: {
|
||||
main: Colors[config.space.color][500]
|
||||
},
|
||||
secondary: {
|
||||
main: Colors.orange[500]
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// $FlowFixMe
|
||||
const contentElement: Element = document.getElementById("content");
|
||||
ReactDOM.render(<App config={config} />, contentElement);
|
||||
ReactDOM.render((
|
||||
<ThemeProvider theme={theme}>
|
||||
<App config={config} />
|
||||
</ThemeProvider>
|
||||
), contentElement);
|
||||
|
|
|
|||
|
|
@ -3,10 +3,10 @@ import React from "react";
|
|||
|
||||
export type MqttContextValue = {
|
||||
state: State,
|
||||
changeState: (topic: string, value: string) => void
|
||||
changeState: (topic: string, value: string) => State
|
||||
};
|
||||
|
||||
export default React.createContext({
|
||||
state: {},
|
||||
changeState: (_topic, _val) => {}
|
||||
changeState: (_topic, _val) => ({})
|
||||
});
|
||||
|
|
|
|||
|
|
@ -10,15 +10,3 @@ declare type Classes = {
|
|||
declare type State = Map<string,string>;
|
||||
|
||||
declare type Point = [number, number];
|
||||
|
||||
declare type Layer = {
|
||||
image: string,
|
||||
name: string,
|
||||
baseLayer?: boolean,
|
||||
defaultVisibility: "visible" | "hidden",
|
||||
opacity?: number,
|
||||
bounds: {
|
||||
topLeft: Point,
|
||||
bottomRight: Point
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,30 +1,32 @@
|
|||
const path = require('path');
|
||||
const webpack = require('webpack');
|
||||
const WebpackShellPlugin = require('webpack-shell-plugin');
|
||||
const WebpackShellPlugin = require('webpack-shell-plugin-next');
|
||||
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
||||
const CleanWebpackPlugin = require('clean-webpack-plugin');
|
||||
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
|
||||
const preBuildScripts = process.env.NO_FLOW == undefined ?
|
||||
process.env.FLOW_PATH != undefined ? [process.env.FLOW_PATH] : ['flow']
|
||||
: [];
|
||||
|
||||
const configPath = env => {
|
||||
if (env === true) {
|
||||
const filtered = Object.keys(env).filter((e) => !e.startsWith("WEBPACK"));
|
||||
if (filtered.length < 1) {
|
||||
throw "No config file was provided.";
|
||||
}
|
||||
return path.resolve(__dirname, `config/${env}`);
|
||||
return path.resolve(__dirname, `config/${filtered[0]}`);
|
||||
};
|
||||
|
||||
module.exports = env => ({
|
||||
entry: {
|
||||
main: ["@babel/polyfill", configPath(env),
|
||||
main: [configPath(env),
|
||||
path.resolve(__dirname, 'src/index.jsx')]
|
||||
},
|
||||
resolve: {
|
||||
modules: [path.resolve(__dirname, "src"), "node_modules"],
|
||||
extensions: ['.js', '.jsx'],
|
||||
alias: {
|
||||
'lodash': 'lodash-es'
|
||||
}
|
||||
'lodash': 'lodash-es',
|
||||
"leaflet": "leaflet/dist/leaflet-src.esm.js"
|
||||
},
|
||||
},
|
||||
output: {
|
||||
path: path.resolve(__dirname, 'dist'),
|
||||
|
|
@ -34,16 +36,26 @@ module.exports = env => ({
|
|||
rules: [
|
||||
// TODO: CSS follow imports and minify + sourcemap on production
|
||||
{ test: /\.css$/, use: [ 'style-loader', 'css-loader' ] },
|
||||
{ test: /\.(woff2?|eot|ttf|svg)$/, loader: "file-loader" },
|
||||
{ test: /\.js(x)?$/, loader: "babel-loader?cacheDirectory=true" }
|
||||
{ test: /\.(woff2?|eot|ttf|svg|png)$/, use: [ { loader: "file-loader", options: { esModule: false } } ] },
|
||||
{ test: /\.js(x)?$/, use: ["babel-loader?cacheDirectory=true"] }
|
||||
]
|
||||
},
|
||||
plugins: [
|
||||
new CleanWebpackPlugin(),
|
||||
new WebpackShellPlugin({onBuildStart:preBuildScripts}),
|
||||
new WebpackShellPlugin({
|
||||
onBuildStart: {
|
||||
scripts: preBuildScripts,
|
||||
blocking: true,
|
||||
parallel: false
|
||||
}
|
||||
}),
|
||||
new HtmlWebpackPlugin({
|
||||
title: 'Space Map',
|
||||
template: 'index.ejs'
|
||||
}),
|
||||
new webpack.ProvidePlugin({
|
||||
Buffer: ['buffer', 'Buffer'],
|
||||
process: 'process/browser',
|
||||
}),
|
||||
]
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue