Fix many eslint warnings
This commit is contained in:
parent
f7972afcd4
commit
b1bf5efd11
7 changed files with 46 additions and 39 deletions
|
|
@ -2,7 +2,7 @@
|
||||||
import type { Config } from "config/flowtypes";
|
import type { Config } from "config/flowtypes";
|
||||||
import * as types from "config/types";
|
import * as types from "config/types";
|
||||||
import { hex, rgb, rgba, rainbow } from "config/colors";
|
import { hex, rgb, rgba, rainbow } from "config/colors";
|
||||||
import { mdi, raw_mdi, mdi_battery } from "config/icon";
|
import { mdi, rawMdi, mdiBattery } from "config/icon";
|
||||||
import { esper_topics, esper_statistics, floalt, tradfri_remote } from "./utils";
|
import { esper_topics, esper_statistics, floalt, tradfri_remote } from "./utils";
|
||||||
|
|
||||||
const config : Config = {
|
const config : Config = {
|
||||||
|
|
@ -401,7 +401,7 @@ const config : Config = {
|
||||||
name: "Twinkle",
|
name: "Twinkle",
|
||||||
position: [530, 560],
|
position: [530, 560],
|
||||||
icon: ({twinkle}) =>
|
icon: ({twinkle}) =>
|
||||||
twinkle == "on" ? raw_mdi("led-on flip-v") : raw_mdi("led-off flip-v"),
|
twinkle == "on" ? rawMdi("led-on flip-v") : rawMdi("led-off flip-v"),
|
||||||
iconColor: ({twinkle}) => twinkle == "on" ? rainbow : hex("#000000"),
|
iconColor: ({twinkle}) => twinkle == "on" ? rainbow : hex("#000000"),
|
||||||
ui: [
|
ui: [
|
||||||
{
|
{
|
||||||
|
|
@ -434,7 +434,8 @@ const config : Config = {
|
||||||
{
|
{
|
||||||
type: "link",
|
type: "link",
|
||||||
link: "http://cashdesk.rzl:8081/",
|
link: "http://cashdesk.rzl:8081/",
|
||||||
text: "Open Cashdesk"
|
text: "Open Cashdesk",
|
||||||
|
icon: mdi("open-in-new")
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
@ -481,7 +482,8 @@ const config : Config = {
|
||||||
{
|
{
|
||||||
type: "link",
|
type: "link",
|
||||||
link: "http://annette.rzl/",
|
link: "http://annette.rzl/",
|
||||||
text: "Open Annette"
|
text: "Open Annette",
|
||||||
|
icon: mdi("open-in-new")
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
@ -599,7 +601,8 @@ const config : Config = {
|
||||||
{
|
{
|
||||||
type: "link",
|
type: "link",
|
||||||
link: "http://mpd.rzl/mpd/player/index.php",
|
link: "http://mpd.rzl/mpd/player/index.php",
|
||||||
text: "Open MPD Interface"
|
text: "Open MPD Interface",
|
||||||
|
icon: mdi("open-in-new")
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
@ -661,7 +664,8 @@ const config : Config = {
|
||||||
{
|
{
|
||||||
type: "link",
|
type: "link",
|
||||||
link: "http://s.rzl.so",
|
link: "http://s.rzl.so",
|
||||||
text: "Open Status Page"
|
text: "Open Status Page",
|
||||||
|
icon: mdi("open-in-new")
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: "text",
|
type: "text",
|
||||||
|
|
@ -693,7 +697,8 @@ const config : Config = {
|
||||||
{
|
{
|
||||||
type: "link",
|
type: "link",
|
||||||
link: "http://cashdesk.rzl:3030/rzl",
|
link: "http://cashdesk.rzl:3030/rzl",
|
||||||
text: "Open Infoscreen"
|
text: "Open Infoscreen",
|
||||||
|
icon: mdi("open-in-new")
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
@ -713,7 +718,8 @@ const config : Config = {
|
||||||
{
|
{
|
||||||
type: "link",
|
type: "link",
|
||||||
link: "http://ultimaker.rzl/",
|
link: "http://ultimaker.rzl/",
|
||||||
text: "Open Webinterface"
|
text: "Open Webinterface",
|
||||||
|
icon: mdi("open-in-new")
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: "section",
|
type: "section",
|
||||||
|
|
@ -737,7 +743,8 @@ const config : Config = {
|
||||||
{
|
{
|
||||||
type: "link",
|
type: "link",
|
||||||
link: "http://partkeepr.rzl/",
|
link: "http://partkeepr.rzl/",
|
||||||
text: "Open Partkeepr"
|
text: "Open Partkeepr",
|
||||||
|
icon: mdi("open-in-new")
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
@ -934,7 +941,7 @@ const config : Config = {
|
||||||
ui: [
|
ui: [
|
||||||
{
|
{
|
||||||
type: "progress",
|
type: "progress",
|
||||||
icon: mdi_battery(tradfri_remote.level("65536")),
|
icon: mdiBattery(tradfri_remote.level("65536")),
|
||||||
min: 0,
|
min: 0,
|
||||||
max: 100,
|
max: 100,
|
||||||
text: "Licht Tisch 1",
|
text: "Licht Tisch 1",
|
||||||
|
|
@ -942,7 +949,7 @@ const config : Config = {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: "progress",
|
type: "progress",
|
||||||
icon: mdi_battery(tradfri_remote.level("65547")),
|
icon: mdiBattery(tradfri_remote.level("65547")),
|
||||||
min: 0,
|
min: 0,
|
||||||
max: 100,
|
max: 100,
|
||||||
text: "Licht Tisch 2",
|
text: "Licht Tisch 2",
|
||||||
|
|
@ -950,7 +957,7 @@ const config : Config = {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: "progress",
|
type: "progress",
|
||||||
icon: mdi_battery(tradfri_remote.level("65542")),
|
icon: mdiBattery(tradfri_remote.level("65542")),
|
||||||
min: 0,
|
min: 0,
|
||||||
max: 100,
|
max: 100,
|
||||||
text: "Licht Theke 1",
|
text: "Licht Theke 1",
|
||||||
|
|
@ -958,7 +965,7 @@ const config : Config = {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: "progress",
|
type: "progress",
|
||||||
icon: mdi_battery(tradfri_remote.level("65546")),
|
icon: mdiBattery(tradfri_remote.level("65546")),
|
||||||
min: 0,
|
min: 0,
|
||||||
max: 100,
|
max: 100,
|
||||||
text: "Licht Theke 2",
|
text: "Licht Theke 2",
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,7 @@ class App extends React.PureComponent<AppProps & Classes, AppState> {
|
||||||
Object.assign({}, ...this.props.config.topics) : this.props.config.topics;
|
Object.assign({}, ...this.props.config.topics) : this.props.config.topics;
|
||||||
}
|
}
|
||||||
|
|
||||||
static styles(_theme: Object) {
|
static styles() {
|
||||||
return {
|
return {
|
||||||
drawerPaper: {
|
drawerPaper: {
|
||||||
width: 320
|
width: 320
|
||||||
|
|
@ -83,10 +83,9 @@ class App extends React.PureComponent<AppProps & Classes, AppState> {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (let i in topics) {
|
for (let i in topics) {
|
||||||
// TODO: Remove FlowFixMe
|
|
||||||
const topic = topics[i];
|
const topic = topics[i];
|
||||||
// $FlowFixMe
|
const stateTopic = this.topics[topic].state;
|
||||||
const parseValue = this.topics[topic].state.type;
|
const parseValue = stateTopic ? stateTopic.type : null;
|
||||||
const val = parseValue == null ? message.toString() : parseValue(message);
|
const val = parseValue == null ? message.toString() : parseValue(message);
|
||||||
this.setState({mqttState: Object.assign({}, merge(this.state.mqttState,
|
this.setState({mqttState: Object.assign({}, merge(this.state.mqttState,
|
||||||
{ [topic]: val}))});
|
{ [topic]: val}))});
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ class SideBar extends React.PureComponent<Props, SideBarState> {
|
||||||
super(props);
|
super(props);
|
||||||
}
|
}
|
||||||
|
|
||||||
static styles(_theme: Object): Object {
|
static styles(): Object {
|
||||||
return {
|
return {
|
||||||
drawerPaper: {
|
drawerPaper: {
|
||||||
width: 340
|
width: 340
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ import React from "react";
|
||||||
import keys from "lodash/keys";
|
import keys from "lodash/keys";
|
||||||
import map from "lodash/map";
|
import map from "lodash/map";
|
||||||
import debounce from "lodash/debounce";
|
import debounce from "lodash/debounce";
|
||||||
|
import { renderIcon } from "config/icon";
|
||||||
import ListItemSecondaryAction from "@material-ui/core/ListItemSecondaryAction";
|
import ListItemSecondaryAction from "@material-ui/core/ListItemSecondaryAction";
|
||||||
import ListItemText from "@material-ui/core/ListItemText";
|
import ListItemText from "@material-ui/core/ListItemText";
|
||||||
import ListSubheader from "@material-ui/core/ListSubheader";
|
import ListSubheader from "@material-ui/core/ListSubheader";
|
||||||
|
|
@ -216,6 +217,8 @@ export class Link extends UiItem<UILink> {
|
||||||
color="primary"
|
color="primary"
|
||||||
disabled={!this.isEnabled()}
|
disabled={!this.isEnabled()}
|
||||||
>
|
>
|
||||||
|
{this.props.item.icon == null ? ""
|
||||||
|
: renderIcon(this.props.item.icon(this.props.state), "mdi-24px")}
|
||||||
{this.props.item.text}
|
{this.props.item.text}
|
||||||
</Button>
|
</Button>
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ export default class UiItemList extends React.PureComponent<UiItemListProps> {
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<ListItem key={key}>
|
<ListItem key={key}>
|
||||||
{control.icon == null ||
|
{control.icon == null || control.type === "link" ||
|
||||||
<ListItemIcon>
|
<ListItemIcon>
|
||||||
{renderIcon(control.icon(this.props.state), "mdi-24px")}
|
{renderIcon(control.icon(this.props.state), "mdi-24px")}
|
||||||
</ListItemIcon>}
|
</ListItemIcon>}
|
||||||
|
|
|
||||||
|
|
@ -68,8 +68,6 @@ export type UILink = $ReadOnly<{|
|
||||||
text: string,
|
text: string,
|
||||||
link: string,
|
link: string,
|
||||||
enableCondition?: (s: State) => boolean,
|
enableCondition?: (s: State) => boolean,
|
||||||
|
|
||||||
// TODO: check if both the following options are implemented
|
|
||||||
icon?: Icon
|
icon?: Icon
|
||||||
|}>;
|
|}>;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,37 +5,37 @@ export opaque type RawIcon: string = string;
|
||||||
|
|
||||||
export type Icon = (State) => RawIcon;
|
export type Icon = (State) => RawIcon;
|
||||||
|
|
||||||
export const raw_mdi = (name: string): RawIcon => {
|
export const rawMdi = (name: string): RawIcon => {
|
||||||
return `mdi ${name.split(" ").map((icon) => "mdi-".concat(icon)).join(" ")}`;
|
return `mdi ${name.split(" ").map((icon) => "mdi-".concat(icon)).join(" ")}`;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const mdi = (icon: string) => () => raw_mdi(icon);
|
export const mdi = (icon: string) => () => rawMdi(icon);
|
||||||
|
|
||||||
export const mdi_battery = (topic: string) => (state: State) => {
|
export const mdiBattery = (topic: string) => (state: State) => {
|
||||||
const rawval = state[topic];
|
const rawval = state[topic];
|
||||||
const val = parseInt(rawval);
|
const val = parseInt(rawval, 10);
|
||||||
if (isNaN(val)) {
|
if (isNaN(val)) {
|
||||||
return raw_mdi("battery-unknown");
|
return rawMdi("battery-unknown");
|
||||||
} else if (val > 95) {
|
} else if (val > 95) {
|
||||||
return raw_mdi("battery");
|
return rawMdi("battery");
|
||||||
} else if (val > 85) {
|
} else if (val > 85) {
|
||||||
return raw_mdi("battery-90");
|
return rawMdi("battery-90");
|
||||||
} else if (val > 75) {
|
} else if (val > 75) {
|
||||||
return raw_mdi("battery-80");
|
return rawMdi("battery-80");
|
||||||
} else if (val > 65) {
|
} else if (val > 65) {
|
||||||
return raw_mdi("battery-70");
|
return rawMdi("battery-70");
|
||||||
} else if (val > 55) {
|
} else if (val > 55) {
|
||||||
return raw_mdi("battery-60");
|
return rawMdi("battery-60");
|
||||||
} else if (val > 45) {
|
} else if (val > 45) {
|
||||||
return raw_mdi("battery-50");
|
return rawMdi("battery-50");
|
||||||
} else if (val > 35) {
|
} else if (val > 35) {
|
||||||
return raw_mdi("battery-40");
|
return rawMdi("battery-40");
|
||||||
} else if (val > 25) {
|
} else if (val > 25) {
|
||||||
return raw_mdi("battery-30");
|
return rawMdi("battery-30");
|
||||||
} else if (val > 15) {
|
} else if (val > 15) {
|
||||||
return raw_mdi("battery-20");
|
return rawMdi("battery-20");
|
||||||
} else {
|
} else {
|
||||||
return raw_mdi("battery-10");
|
return rawMdi("battery-10");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue