-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19 from diyhue/restructure
Restructure
- Loading branch information
Showing
148 changed files
with
6,471 additions
and
6,017 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ on: | |
push: | ||
branches: | ||
- "main" | ||
- "restructure" | ||
|
||
jobs: | ||
build-project: | ||
|
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
import { useState, useEffect } from "react"; | ||
|
||
import axios from "axios"; | ||
import { FaBars } from "react-icons/fa"; | ||
import { motion } from "framer-motion"; | ||
import { toast } from "react-hot-toast"; | ||
import FlipSwitch from "../components/FlipSwitch/FlipSwitch"; | ||
|
||
|
||
import "./headerSection.scss"; | ||
import NotificationCenter from "../components/NotificationCenter/NotificationCenter"; | ||
|
||
const HeaderSection = ({ HOST_IP, showSidebar, setShowSidebar, API_KEY }) => { | ||
const [group0State, setGroup0State] = useState(false); | ||
|
||
const iconVariants = { | ||
opened: { | ||
rotate: 90, | ||
//scale: 2 | ||
}, | ||
closed: { | ||
rotate: 0, | ||
//scale: 1 | ||
}, | ||
}; | ||
|
||
useEffect(() => { | ||
const fetchGroups = () => { | ||
if (API_KEY !== undefined) { | ||
axios | ||
.get(`${HOST_IP}/api/${API_KEY}/groups/0`) | ||
.then((fetchedData) => { | ||
//console.log(fetchedData.data); | ||
setGroup0State(fetchedData.data["state"]["any_on"]); | ||
}) | ||
.catch((error) => { | ||
console.error(error); | ||
toast.error(`Error occurred: ${error.message}`); | ||
}); | ||
} | ||
}; | ||
|
||
fetchGroups(); | ||
const interval = setInterval(() => { | ||
fetchGroups(); | ||
}, 5000); // <<-- ⏱ 1000ms = 1s | ||
return () => clearInterval(interval); | ||
}, [HOST_IP, API_KEY]); | ||
|
||
const handleToggleChange = (state) => { | ||
const newState = { on: state }; | ||
//console.log("Apply state " + JSON.stringify(newState)); | ||
axios | ||
.put(`${HOST_IP}/api/${API_KEY}/groups/0/action`, newState) | ||
.then((response) => { | ||
// Only update the state if the request was successful | ||
setGroup0State(state); | ||
}) | ||
.catch((error) => { | ||
console.error("Error updating state: ", error); | ||
}); | ||
}; | ||
|
||
return ( | ||
<div className="topbarRight"> | ||
<motion.div | ||
className="hamburger" | ||
initial={false} | ||
variants={iconVariants} | ||
animate={showSidebar ? "opened" : "closed"} | ||
onClick={() => setShowSidebar(!showSidebar)} | ||
> | ||
<FaBars /> | ||
</motion.div> | ||
|
||
<NotificationCenter | ||
notifications={true} | ||
updating={true} | ||
HOST_IP={HOST_IP} | ||
API_KEY={API_KEY} | ||
/> | ||
|
||
<div className="onbtn"> | ||
<FlipSwitch | ||
value={group0State} | ||
onChange={(e) => handleToggleChange(e)} | ||
checked={group0State} | ||
label={`Turn all lights ${group0State ? "off" : "on"}`} | ||
/> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default HeaderSection; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { useState } from "react"; | ||
import { useMediaQuery } from "react-responsive"; | ||
|
||
import ContentSection from "./ContentSection"; | ||
import SidebarSection from "./SidebarSection"; | ||
import HeaderSection from "./HeaderSection"; | ||
|
||
import "./layout.scss"; | ||
import "./scrollbar.scss"; | ||
|
||
const Layout = ({ HOST_IP, API_KEY }) => { | ||
const isMobile = useMediaQuery({ query: `(max-width: 750px)` }); | ||
const [showSidebar, setShowSidebar] = useState(!isMobile); | ||
|
||
return ( | ||
<> | ||
<SidebarSection | ||
showSidebar={showSidebar} | ||
setShowSidebar={setShowSidebar} | ||
isMobile={isMobile} | ||
/> | ||
|
||
<div className="columnRight"> | ||
<HeaderSection | ||
HOST_IP={HOST_IP} | ||
API_KEY={API_KEY} | ||
showSidebar={showSidebar} | ||
setShowSidebar={setShowSidebar} | ||
/> | ||
<ContentSection | ||
HOST_IP={HOST_IP} | ||
API_KEY={API_KEY} | ||
/> | ||
</div> | ||
</> | ||
); | ||
}; | ||
|
||
export default Layout; |
Oops, something went wrong.