Use material-design-icons instead of material-icons

This commit is contained in:
uwap 2017-11-06 05:50:15 +01:00
parent 465dfa5483
commit 2f342b72bc
16 changed files with 970 additions and 140 deletions

View file

@ -122,63 +122,63 @@ const config : Config = {
led_stahltrager: { led_stahltrager: {
name: "LED Stahlträger", name: "LED Stahlträger",
position: [380, 300], position: [380, 300],
icon: "wb_incandescent", icon: "white-balance-iridescent mdi-rotate-90",
iconColor: state => state.led_stahltraeger == "on" ? utils.rainbow : "#000000", iconColor: state => state.led_stahltraeger == "on" ? utils.rainbow : "#000000",
ui: [ ui: [
{ {
type: "toggle", type: "toggle",
text: "Stahlträger LED", text: "Stahlträger LED",
topic: "led_stahltraeger", topic: "led_stahltraeger",
icon: "power_settings_new" icon: "power"
}, },
] ]
}, },
snackbar: { snackbar: {
name: "Snackbar", name: "Snackbar",
position: [510, 500], position: [510, 500],
icon: "kitchen", icon: "fridge",
iconColor: state => state.snackbar == "on" ? "#E20074" : "#000000", iconColor: state => state.snackbar == "on" ? "#E20074" : "#000000",
ui: [ ui: [
{ {
type: "toggle", type: "toggle",
text: "Snackbar", text: "Snackbar",
topic: "snackbar", topic: "snackbar",
icon: "power_settings_new" icon: "power"
} }
] ]
}, },
twinkle: { twinkle: {
name: "Twinkle", name: "Twinkle",
position: [530, 560], position: [530, 560],
icon: "wb_incandescent", icon: "led-off mdi-flip-v",
iconColor: state => state.twinkle == "on" ? utils.rainbow : "#000000", iconColor: state => state.twinkle == "on" ? utils.rainbow : "#000000",
ui: [ ui: [
{ {
type: "toggle", type: "toggle",
text: "Twinkle", text: "Twinkle",
topic: "twinkle", topic: "twinkle",
icon: "power_settings_new" icon: "power"
} }
] ]
}, },
fan: { fan: {
name: "Ventilator", name: "Ventilator",
position: [520, 450], position: [520, 450],
icon: "toys", icon: "fan",
iconColor: state => state.fan == "on" ? "#00FF00" : "#000000", iconColor: state => state.fan == "on" ? "#00FF00" : "#000000",
ui: [ ui: [
{ {
type: "toggle", type: "toggle",
text: "Ventilator", text: "Ventilator",
topic: "fan", topic: "fan",
icon: "power_settings_new" icon: "power"
} }
] ]
}, },
cashdesk: { cashdesk: {
name: "Cashdesk", name: "Cashdesk",
position: [500, 470], position: [500, 470],
icon: "monetization_on", icon: "coin",
ui: [ ui: [
{ {
type: "link", type: "link",
@ -190,49 +190,49 @@ const config : Config = {
videogames: { videogames: {
name: "Videospiele", name: "Videospiele",
position: [100, 100], position: [100, 100],
icon: "videogame_asset", icon: "gamepad-variant",
iconColor: state => state.videogames == "on" ? "#00FF00" : "#000000", iconColor: state => state.videogames == "on" ? "#00FF00" : "#000000",
ui: [ ui: [
{ {
type: "toggle", type: "toggle",
text: "Videospiele", text: "Videospiele",
topic: "videogames", topic: "videogames",
icon: "power_settings_new" icon: "power"
} }
] ]
}, },
olymp_pc: { olymp_pc: {
name: "Rechner und Drucker", name: "Rechner und Drucker",
position: [297, 90], position: [297, 90],
icon: "desktop_windows", icon: "desktop-classic",
iconColor: state => state.olymp_pc == "on" ? "#00FF00" : "#000000", iconColor: state => state.olymp_pc == "on" ? "#00FF00" : "#000000",
ui: [ ui: [
{ {
type: "toggle", type: "toggle",
text: "Rechner und Drucker", text: "Rechner und Drucker",
topic: "olymp_pc", topic: "olymp_pc",
icon: "power_settings_new" icon: "power"
} }
] ]
}, },
flyfry: { flyfry: {
name: "Fliegenbratgerät", name: "Fliegenbratgerät",
position: [450, 590], position: [450, 590],
icon: "whatshot", icon: "fire",
iconColor: state => state.flyfry == "on" ? "#6666FF" : "#000000", iconColor: state => state.flyfry == "on" ? "#6666FF" : "#000000",
ui: [ ui: [
{ {
type: "toggle", type: "toggle",
text: "Fliegenbratgerät", text: "Fliegenbratgerät",
topic: "flyfry", topic: "flyfry",
icon: "power_settings_new" icon: "power"
} }
] ]
}, },
artnet: { artnet: {
name: "Artnet", name: "Artnet",
position: [535,480], position: [535,480],
icon: "wb_incandescent", icon: "spotlight",
iconColor: state => iconColor: state =>
({ ({
off: "#000000", off: "#000000",
@ -249,7 +249,7 @@ const config : Config = {
topic: "artnet", topic: "artnet",
on: "cycle", on: "cycle",
toggled: val => val != "off", toggled: val => val != "off",
icon: "power_settings_new" icon: "power"
}, },
{ {
type: "dropDown", type: "dropDown",
@ -263,7 +263,7 @@ const config : Config = {
cycle: "Farbwechsel" cycle: "Farbwechsel"
}, },
enableCondition: val => val != "off", enableCondition: val => val != "off",
icon: "color_lens" icon: "palette"
} }
] ]
}, },
@ -272,12 +272,12 @@ const config : Config = {
position: [350, 650], position: [350, 650],
iconColor: state => iconColor: state =>
state.onkyo_connection != "connected" ? "#888888" : (state.onkyo_power == "on" ? "#00FF00" : "#000000"), state.onkyo_connection != "connected" ? "#888888" : (state.onkyo_power == "on" ? "#00FF00" : "#000000"),
icon: "volume_up", icon: "volume-high",
ui: [ ui: [
{ {
type: "toggle", type: "toggle",
text: "Power", text: "Power",
icon: "power_settings_new", icon: "power",
topic: "onkyo_power", topic: "onkyo_power",
enableCondition: (a, b, state) => state.onkyo_connection == "connected" enableCondition: (a, b, state) => state.onkyo_connection == "connected"
}, },
@ -291,14 +291,14 @@ const config : Config = {
topic: "onkyo_volume", topic: "onkyo_volume",
min: 0, min: 0,
max: 50, max: 50,
icon: "volume_up", icon: "volume-high",
enableCondition: (a, b, state) => state.onkyo_connection == "connected" enableCondition: (a, b, state) => state.onkyo_connection == "connected"
}, },
{ {
type: "toggle", type: "toggle",
text: "Mute", text: "Mute",
topic: "onkyo_mute", topic: "onkyo_mute",
icon: "volume_off", icon: "volume-off",
enableCondition: (a, b, state) => state.onkyo_connection == "connected" enableCondition: (a, b, state) => state.onkyo_connection == "connected"
}, },
{ {
@ -315,7 +315,7 @@ const config : Config = {
chromecast: "Chromecast", chromecast: "Chromecast",
pult: "Pult" pult: "Pult"
}, },
icon: "settings_input_component", icon: "usb",
enableCondition: (a, b, state) => state.onkyo_connection == "connected" enableCondition: (a, b, state) => state.onkyo_connection == "connected"
}, },
{ {
@ -349,21 +349,21 @@ const config : Config = {
rundumleuchte: { rundumleuchte: {
name: "Rundumleuchte", name: "Rundumleuchte",
position: [310,275], position: [310,275],
icon: "wb_sunny", icon: "alarm-light",
iconColor: state => state.rundumleuchte == "on" ? "#CCCC00" : "#000000", iconColor: state => state.rundumleuchte == "on" ? "#CCCC00" : "#000000",
ui: [ ui: [
{ {
type: "toggle", type: "toggle",
text: "Rundumleuchte", text: "Rundumleuchte",
topic: "rundumleuchte", topic: "rundumleuchte",
icon: "power_settings_new" icon: "power"
} }
] ]
}, },
door: { door: {
name: "Tür", name: "Tür",
position: [455,350], position: [455,350],
icon: "swap_vert", icon: "swap-vertical",
iconColor: state => state.door_status == "on" ? "#00FF00" : "#FF0000", iconColor: state => state.door_status == "on" ? "#00FF00" : "#FF0000",
ui: [ ui: [
{ {
@ -376,14 +376,14 @@ const config : Config = {
infoscreen: { infoscreen: {
name: "Infoscreen", name: "Infoscreen",
position: [255, 495], position: [255, 495],
icon: "developer_board", icon: "developer-board",
iconColor: state => state.infoscreen == "on" ? "#4444FF" : "#000000", iconColor: state => state.infoscreen == "on" ? "#4444FF" : "#000000",
ui: [ ui: [
{ {
type: "toggle", type: "toggle",
text: "Infoscreen", text: "Infoscreen",
topic: "infoscreen", topic: "infoscreen",
icon: "power_settings_new" icon: "power"
}, },
{ {
type: "link", type: "link",
@ -395,18 +395,18 @@ const config : Config = {
}, },
layers: [ layers: [
{ {
image: "img/layers/rzl/rooms.svg", image: require("../img/layers/rzl/rooms.svg"),
baseLayer: true, baseLayer: true,
name: "RaumZeitLabor", name: "RaumZeitLabor",
defaultVisibility: "visible" defaultVisibility: "visible"
}, },
{ {
image: "img/layers/rzl/details.svg", image: require("../img/layers/rzl/details.svg"),
name: "Details", name: "Details",
defaultVisibility: "visible" defaultVisibility: "visible"
}, },
{ {
image: "img/layers/rzl/labels.svg", image: require("../img/layers/rzl/labels.svg"),
name: "Labels", name: "Labels",
defaultVisibility: "visible" defaultVisibility: "visible"
} }

25
css/styles.css Normal file
View file

@ -0,0 +1,25 @@
#content {
height: 100%;
height: 100vh;
}
.leaflet-container {
height: calc(100vh - 64px);
max-height: 100%;
}
body {
margin: 0;
}
#drawer_uiComponents {
margin: 10px;
}
body .leaflet-div-icon {
border: 0;
background: transparent;
}
.leaflet-marker-icon .mdi {
line-height: 1;
}
#drawer_uiComponents .mdi {
width: auto;
height: auto;
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

12
index.ejs Normal file
View file

@ -0,0 +1,12 @@
<!DOCTYPE html>
<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>
<div id="content">
</div>
</body>
</html>

View file

@ -1,70 +0,0 @@
<!DOCTYPE html>
<head>
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.2.0/dist/leaflet.css" integrity="sha512-M2wvCLH6DSRazYeZRIm1JnYyh22purTM+FDB5CsyxtQJYeKq83arPe5wgbNmcFXGqiSH2XR8dT/fJISVA1r/zQ==" crossorigin=""/>
<meta charset="utf-8" />
<title>Space Map</title>
<style>
#content {
height: 100%;
height: 100vh;
}
.leaflet-container {
height: calc(100vh - 64px);
max-height: 100%;
}
body {
margin: 0;
}
#drawer_uiComponents {
margin: 10px;
}
body .leaflet-div-icon {
border: 0;
background: transparent;
}
@font-face {
font-family: 'Material Icons';
font-style: normal;
font-weight: 400;
src: url(icons/MaterialIcons-Regular.eot); /* For IE6-8 */
src: local('Material Icons'),
local('MaterialIcons-Regular'),
url(icons/MaterialIcons-Regular.woff2) format('woff2'),
url(icons/MaterialIcons-Regular.woff) format('woff'),
url(icons/MaterialIcons-Regular.ttf) format('truetype');
}
.material-icons {
font-family: 'Material Icons';
font-weight: normal;
font-style: normal;
font-size: 32px; /* Preferred icon size */
display: inline-block;
line-height: 1;
text-transform: none;
letter-spacing: normal;
word-wrap: normal;
white-space: nowrap;
direction: ltr;
/* Support for all WebKit browsers. */
-webkit-font-smoothing: antialiased;
/* Support for Safari and Chrome. */
text-rendering: optimizeLegibility;
/* Support for Firefox. */
-moz-osx-font-smoothing: grayscale;
/* Support for IE. */
font-feature-settings: 'liga';
}
#drawer_uiComponents .material-icons {
font-size: 24px;
}
</style>
</head>
<body>
<div id="content">
</div>
<script src="dist/main.js"></script>
</body>

View file

@ -12,6 +12,7 @@
"leaflet": "^1.2.0", "leaflet": "^1.2.0",
"material-ui": "next", "material-ui": "next",
"material-ui-old": "npm:material-ui@latest", "material-ui-old": "npm:material-ui@latest",
"mdi": "^2.0.46",
"mqtt": "^2.11.0", "mqtt": "^2.11.0",
"ramda": "^0.24.1", "ramda": "^0.24.1",
"react": "^15.6.1", "react": "^15.6.1",
@ -25,9 +26,14 @@
"babel-core": "^6.25.0", "babel-core": "^6.25.0",
"babel-loader": "^7.1.1", "babel-loader": "^7.1.1",
"babel-preset-react": "^6.24.1", "babel-preset-react": "^6.24.1",
"css-loader": "^0.28.7",
"extract-text-webpack-plugin": "^3.0.2",
"file-loader": "^1.1.5",
"flow": "^0.2.3", "flow": "^0.2.3",
"flow-bin": "^0.50.0", "flow-bin": "^0.50.0",
"flow-typed": "^2.2.1", "flow-typed": "^2.2.1",
"html-webpack-plugin": "^2.30.1",
"style-loader": "^0.19.0",
"webpack": "^3.1.0", "webpack": "^3.1.0",
"webpack-shell-plugin": "^0.5.0" "webpack-shell-plugin": "^0.5.0"
}, },

View file

@ -56,7 +56,7 @@ export const isToggled = (state: State, props: ControlUI) => {
export const toggle = (state: State, props: ControlUI) => { export const toggle = (state: State, props: ControlUI) => {
return ( return (
<ListItem> <ListItem>
{props.icon && <ListItemIcon><Icon>{props.icon}</Icon></ListItemIcon>} {props.icon && <ListItemIcon><i className={`mdi mdi-${props.icon} mdi-24px`}></i></ListItemIcon>}
<ListItemText primary={props.text} /> <ListItemText primary={props.text} />
<ListItemSecondaryAction> <ListItemSecondaryAction>
<Switch label={props.text} <Switch label={props.text}
@ -83,7 +83,7 @@ export const dropDown = (state: State, props: ControlUI) => {
const id = `${props.topic}.${Object.keys(props.options).reduce((v,r) => v + "." + r)}`; const id = `${props.topic}.${Object.keys(props.options).reduce((v,r) => v + "." + r)}`;
return ( return (
<ListItem> <ListItem>
{props.icon && <ListItemIcon><Icon>{props.icon}</Icon></ListItemIcon>} {props.icon && <ListItemIcon><i className={`mdi mdi-${props.icon} mdi-24px`}></i></ListItemIcon>}
<FormControl> <FormControl>
<InputLabel htmlFor={id}>{props.text}</InputLabel> <InputLabel htmlFor={id}>{props.text}</InputLabel>
<Select value={state.values[props.topic].actual} <Select value={state.values[props.topic].actual}
@ -107,7 +107,7 @@ const onSliderChange = (state: State, props: ControlUI) =>
export const slider = (state: State, props: ControlUI) => ( export const slider = (state: State, props: ControlUI) => (
<ListItem> <ListItem>
{props.icon && <ListItemIcon><Icon>{props.icon}</Icon></ListItemIcon>} {props.icon && <ListItemIcon><i className={`mdi mdi-${props.icon} mdi-24px`}></i></ListItemIcon>}
<ListItemText primary={props.text} /> <ListItemText primary={props.text} />
<ListItemSecondaryAction> <ListItemSecondaryAction>
<MuiThemeProvider> <MuiThemeProvider>

View file

@ -3,7 +3,6 @@ import React from "react";
import AppBar from "material-ui/AppBar"; import AppBar from "material-ui/AppBar";
import Toolbar from 'material-ui/Toolbar'; import Toolbar from 'material-ui/Toolbar';
import { CircularProgress } from "material-ui/Progress"; import { CircularProgress } from "material-ui/Progress";
import Icon from 'material-ui/Icon';
import IconButton from "material-ui/IconButton"; import IconButton from "material-ui/IconButton";
import Menu, { MenuItem } from "material-ui/Menu"; import Menu, { MenuItem } from "material-ui/Menu";
import Typography from 'material-ui/Typography'; import Typography from 'material-ui/Typography';
@ -17,8 +16,8 @@ const TopBarLayerSelector = (props: Object) => (
const TopBarIndicatorMenu = (props: Object) => ( const TopBarIndicatorMenu = (props: Object) => (
<IconButton> <IconButton>
{props.mqtt.connected ? {props.mqtt.connected ?
(<Icon style={{fontSize: 48}}>map</Icon>) : (<i style={{fontSize: 48}} className="mdi mdi-map"></i>) :
(<Icon style={{fontSize: 48}}>phonelink_off</Icon>)} (<i style={{fontSize: 48}} className="mdi mdi-lan-disconnect"></i>)}
</IconButton> </IconButton>
); );

View file

@ -22,6 +22,9 @@ import IconButton from 'material-ui/IconButton';
import Icon from 'material-ui/Icon'; import Icon from 'material-ui/Icon';
import AppBar from 'material-ui/AppBar'; import AppBar from 'material-ui/AppBar';
import '../node_modules/mdi/css/materialdesignicons.min.css';
import '../css/styles.css';
injectTapEventPlugin(); injectTapEventPlugin();
document.title = `${Config.space.name} Map`; document.title = `${Config.space.name} Map`;
@ -64,7 +67,7 @@ class app extends React.Component<{state: State, classes: Object}> {
<AppBar position="static"> <AppBar position="static">
<Toolbar> <Toolbar>
<IconButton onClick={() => store.dispatch({type: Actions.CHANGE_UI})}> <IconButton onClick={() => store.dispatch({type: Actions.CHANGE_UI})}>
<Icon>keyboard_tab</Icon> <i className="mdi mdi-format-horizontal-align-right mdi-36px"></i>
</IconButton> </IconButton>
<Typography type="title"> <Typography type="title">
{state.uiOpened == null ? "" : Config.controls[state.uiOpened].name} {state.uiOpened == null ? "" : Config.controls[state.uiOpened].name}

View file

@ -22,17 +22,17 @@ const color = (iconColor, state: State) => {
); );
} }
const iconHtml = (el, state: State) => const iconHtml = (el, state: State) =>
"<i class=\"material-icons\" style=\"" "<i class=\"mdi mdi-" + el.icon + " mdi-36px\" style=\""
+ "color:" + color(el.iconColor, state) + ";\">" + "color:" + color(el.iconColor, state) + ";\">"
+ el.icon + "</i>" + "</i>"
const Markers = (props) => R.values(R.mapObjIndexed((el,key) => ( const Markers = (props) => R.values(R.mapObjIndexed((el,key) => (
<Marker position={c(el.position)} key={el.name} <Marker position={c(el.position)} key={el.name}
icon={Leaflet.divIcon( icon={Leaflet.divIcon(
{ {
html: iconHtml(el, props.state), html: iconHtml(el, props.state),
iconSize: Leaflet.point(32,32), iconSize: Leaflet.point(36,36),
iconAnchor: Leaflet.point(16,16) iconAnchor: Leaflet.point(18,18)
})} })}
onClick={(e) => store.dispatch({type: Actions.CHANGE_UI, payload: key, toggle: e.originalEvent.ctrlKey})}> onClick={(e) => store.dispatch({type: Actions.CHANGE_UI, payload: key, toggle: e.originalEvent.ctrlKey})}>
</Marker> </Marker>

View file

@ -30,6 +30,7 @@ export default function connectMqtt(url: string, store: Store<*,*>) {
store.dispatch({ type: null }); store.dispatch({ type: null });
}); });
client.on("reconnect", () => { client.on("reconnect", () => {
client.end();
store.dispatch({ type: null }); store.dispatch({ type: null });
}); });
} }

View file

@ -3,11 +3,18 @@
const path = require('path'); const path = require('path');
const webpack = require('webpack'); const webpack = require('webpack');
const WebpackShellPlugin = require('webpack-shell-plugin'); const WebpackShellPlugin = require('webpack-shell-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const ExtractTextPlugin = require("extract-text-webpack-plugin");
const preBuildScripts = process.env.NO_FLOW == undefined ? const preBuildScripts = process.env.NO_FLOW == undefined ?
process.env.FLOW_PATH != undefined ? [process.env.FLOW_PATH] : ['flow'] process.env.FLOW_PATH != undefined ? [process.env.FLOW_PATH] : ['flow']
: []; : [];
const extractTextCSSLoader = ExtractTextPlugin.extract({
fallback: "style-loader",
use: "css-loader"
});
module.exports = { module.exports = {
resolve: { resolve: {
extensions: ['.js', '.jsx'] extensions: ['.js', '.jsx']
@ -18,17 +25,22 @@ module.exports = {
output: { output: {
path: path.resolve(__dirname, 'dist'), path: path.resolve(__dirname, 'dist'),
filename: 'main.js', filename: 'main.js',
publicPath: 'dist/' publicPath: './'
}, },
module: { module: {
loaders: [ loaders: [
{ test: /\.(woff2?|eot|ttf|svg)$/, loader: "file-loader" }, { test: /\.(woff2?|eot|ttf|svg)$/, loader: "file-loader" },
{ test: /\.css$/, loader: "style-loader!css-loader" }, { test: /\.css$/, use: extractTextCSSLoader },
{ test: /\.js(x)?$/, exclude: /node_modules/, loader: "babel-loader" } { test: /\.js(x)?$/, exclude: /node_modules/, loader: "babel-loader" }
] ]
}, },
plugins: [ plugins: [
new WebpackShellPlugin({onBuildStart:preBuildScripts}) new WebpackShellPlugin({onBuildStart:preBuildScripts}),
new HtmlWebpackPlugin({
title: 'Space Map',
template: 'index.ejs'
}),
new ExtractTextPlugin("styles.css")
], ],
devtool: 'source-map' devtool: 'source-map'
}; };

892
yarn.lock

File diff suppressed because it is too large Load diff