Skip to content

Commit

Permalink
Merge pull request #23 from hendriksen-mark/main
Browse files Browse the repository at this point in the history
Add hue icons, fix warnings about id and key missing, add properties for username and password.
  • Loading branch information
hendriksen-mark authored Aug 2, 2024
2 parents 8d4c373 + 24c1e8a commit 158bd45
Show file tree
Hide file tree
Showing 14 changed files with 140 additions and 32 deletions.
1 change: 1 addition & 0 deletions src/Mainframe/HeaderSection.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ const HeaderSection = ({ HOST_IP, showSidebar, setShowSidebar, API_KEY }) => {

<div className="onbtn">
<FlipSwitch
id="onbtn"
value={group0State}
onChange={(e) => handleToggleChange(e)}
checked={group0State}
Expand Down
3 changes: 3 additions & 0 deletions src/Pages/Account.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ const Account = ({ HOST_IP, API_KEY }) => {
readOnly={true}
type="text"
value={email}
autoComplete="username"
/>
</div>
<div className="form-control">
Expand All @@ -112,6 +113,7 @@ const Account = ({ HOST_IP, API_KEY }) => {
placeholder="Enter Password"
value={pass}
onChange={(e) => handleChange(e)}
autoComplete="new-password"
/>
</div>
<small>
Expand All @@ -132,6 +134,7 @@ const Account = ({ HOST_IP, API_KEY }) => {
placeholder="Repeat Password"
value={pass1}
onChange={(e) => setPass1(e)}
autoComplete="new-password"
/>
</div>
{pass !== pass1 && (
Expand Down
1 change: 1 addition & 0 deletions src/Pages/Alarm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ const Alarm = ({ HOST_IP, API_KEY }) => {
<div className="headline">Motion notifications alarm</div>
<form className="add-form">
<FlipSwitch
id="alarm"
value={enable}
onChange={(e) => toggleEnable(e)}
checked={enable}
Expand Down
3 changes: 3 additions & 0 deletions src/Pages/Bridge.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ const Bridge = ({ HOST_IP, API_KEY }) => {
axios
.get(`${HOST_IP}/api/${API_KEY}/config`)
.then((result) => {
//console.log(result.data);
setBridgeName(result.data["name"]);
setSwversion(result.data["swversion"]);
setApiVersion(result.data["apiversion"]);
Expand Down Expand Up @@ -416,6 +417,7 @@ const Bridge = ({ HOST_IP, API_KEY }) => {
</div>
<div className="form-control">
<FlipSwitch
id="Remote API"
value={remoteApi}
onChange={(e) => setRemoteApi(e)}
checked={remoteApi}
Expand All @@ -425,6 +427,7 @@ const Bridge = ({ HOST_IP, API_KEY }) => {
</div>
<div className="form-control">
<FlipSwitch
id="Discovery"
value={discovery}
onChange={(e) => setDiscovery(e)}
checked={discovery}
Expand Down
1 change: 1 addition & 0 deletions src/Pages/Deconz.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ const Deconz = ({ HOST_IP, API_KEY }) => {
<div className="headline">Deconz Config</div>
<form className="add-form">
<FlipSwitch
id="Deconz"
value={enable}
onChange={(e) => toggleEnable(e)}
checked={enable}
Expand Down
1 change: 1 addition & 0 deletions src/Pages/HA.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ const HA = ({ HOST_IP, API_KEY }) => {
<div className="headline">Home Assistant config</div>
<form className="add-form">
<FlipSwitch
id="ha"
value={enable}
onChange={(e) => setEnable(e)}
checked={enable}
Expand Down
1 change: 1 addition & 0 deletions src/Pages/Mqtt.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ const Mqtt = ({ HOST_IP, API_KEY }) => {
<div className="headline">ZigBee2MQTT config</div>
<form className="add-form">
<FlipSwitch
id="mqtt"
value={enable}
onChange={(e) => setEnable(e)}
checked={enable}
Expand Down
10 changes: 10 additions & 0 deletions src/Pages/Settings.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ const Settings = ({ HOST_IP, API_KEY }) => {
<p>To add ports separate the ports with "," ex: 80,81,82</p>
<form className="add-form">
<FlipSwitch
id="ports"
value={enable}
onChange={(e) => toggleEnable(e)}
checked={enable}
Expand Down Expand Up @@ -218,6 +219,7 @@ const Settings = ({ HOST_IP, API_KEY }) => {
<p>Set which protocol to find.</p>
<form className="add-form">
<FlipSwitch
id="Yeelight"
value={yeelight}
onChange={(e) => setYeelight(e)}
checked={yeelight}
Expand All @@ -226,6 +228,7 @@ const Settings = ({ HOST_IP, API_KEY }) => {
/>

<FlipSwitch
id="Native_multi"
value={native_multi}
onChange={(e) => setNative_multi(e)}
checked={native_multi}
Expand All @@ -234,6 +237,7 @@ const Settings = ({ HOST_IP, API_KEY }) => {
/>

<FlipSwitch
id="Tasmota"
value={tasmota}
onChange={(e) => setTasmota(e)}
checked={tasmota}
Expand All @@ -242,6 +246,7 @@ const Settings = ({ HOST_IP, API_KEY }) => {
/>

<FlipSwitch
id="Wled"
value={wled}
onChange={(e) => setWled(e)}
checked={wled}
Expand All @@ -250,6 +255,7 @@ const Settings = ({ HOST_IP, API_KEY }) => {
/>

<FlipSwitch
id="Shelly"
value={shelly}
onChange={(e) => setShelly(e)}
checked={shelly}
Expand All @@ -258,6 +264,7 @@ const Settings = ({ HOST_IP, API_KEY }) => {
/>

<FlipSwitch
id="Esphome"
value={esphome}
onChange={(e) => setEsphome(e)}
checked={esphome}
Expand All @@ -266,6 +273,7 @@ const Settings = ({ HOST_IP, API_KEY }) => {
/>

<FlipSwitch
id="Hyperion"
value={hyperion}
onChange={(e) => setHyperion(e)}
checked={hyperion}
Expand All @@ -274,6 +282,7 @@ const Settings = ({ HOST_IP, API_KEY }) => {
/>

<FlipSwitch
id="Tpkasa"
value={tpkasa}
onChange={(e) => setTpkasa(e)}
checked={tpkasa}
Expand All @@ -282,6 +291,7 @@ const Settings = ({ HOST_IP, API_KEY }) => {
/>

<FlipSwitch
id="Elgato"
value={elgato}
onChange={(e) => setElgato(e)}
checked={elgato}
Expand Down
3 changes: 2 additions & 1 deletion src/components/FlipSwitch/FlipSwitch.jsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import "./flipswitch.scss";

const FlipSwitch = ({ value = '', onChange = undefined, checked = false, label = '', position = undefined }) => (
const FlipSwitch = ({ value = '', onChange = undefined, checked = false, label = '', position = undefined, id }) => (
<>
<div className="flipSwitch">
<p>{label}</p>
<label className={`flipSwitchLabel ${position}`}>
<input
id={id}
type="checkbox"
value={value}
onChange={(e) => onChange(e.target.checked)}
Expand Down
6 changes: 4 additions & 2 deletions src/components/GenericText/GenericText.jsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
import "./genericText.scss";

const GenericText = ({ label = '', value = '', placeholder = '', readOnly = false, type = 'text', onChange = undefined, pattern = '' }) => {
const GenericText = ({ label = '', value = '', placeholder = '', readOnly = false, type = 'text', onChange = undefined, pattern = '', autoComplete = 'off' }) => {
return (<>
<label>{label}</label>
<label htmlFor={label}>{label}</label>
<input
id={label}
readOnly={readOnly}
type={type}
pattern={pattern}
placeholder={placeholder}
value={value}
onChange={(e) => onChange && onChange(e.target.value)}
autoComplete={autoComplete}
/>
</>);
};
Expand Down
1 change: 1 addition & 0 deletions src/components/Group/GroupHeader.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ const GroupHeader = ({ HOST_IP, api_key, id, group, lights }) => {
</div>
<div className="flipSwitch">
<FlipSwitch
id={"group " + id}
value={group.state["any_on"]}
onChange={(e) => handleToggleChange(e)}
checked={group.state["any_on"]}
Expand Down
8 changes: 6 additions & 2 deletions src/components/GroupLight/GroupLight.jsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import axios from "axios";

import { FaLightbulb } from "react-icons/fa";
import { RiAlertLine } from "react-icons/ri";
import { AnimatePresence } from "framer-motion";

import { cieToRgb, colorTemperatureToRgb } from "../ColorFormatConverter/ColorFormatConverter";
import FlipSwitch from "../FlipSwitch/FlipSwitch";
import BrightnessSlider from "../BrightnessSlider/BrightnessSlider";
import { HueIcons } from "../../static/icons/hass-hue-icons";

const Light = ({ HOST_IP, api_key, id, light }) => {
const switchLight = (newState) => {
Expand Down Expand Up @@ -36,7 +36,10 @@ const Light = ({ HOST_IP, api_key, id, light }) => {
<div className="groupCard light">
<div className="row top">
<div className="gradient" style={getStyle()}>
<FaLightbulb />
<HueIcons
type={"light-" + light["config"]["archetype"]}
color="#eeeeee"
/>
</div>
<div className="text">
<p className="name">
Expand All @@ -45,6 +48,7 @@ const Light = ({ HOST_IP, api_key, id, light }) => {
</p>
</div>
<FlipSwitch
id={"light " + id}
value={light["state"]["on"]}
checked={light["state"]["on"]}
onChange={(e) => switchLight({ on: e })}
Expand Down
2 changes: 1 addition & 1 deletion src/components/User/User.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ const User = ({ HOST_IP, api_key, id, user, whitelist }) => {
{Object.entries(whitelist)
.filter((new_user) => new_user[1].name !== user["name"])
.map(([new_id, new_user]) => (
<div className="form-control">
<div key={new_id} className="form-control">
<GenericButton
value={new_user["name"]}
color="blue"
Expand Down
Loading

0 comments on commit 158bd45

Please sign in to comment.