Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restructure #20

Merged
merged 8 commits into from
Jul 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Mainframe/SidebarSection.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const SidebarSection = ({ showSidebar, setShowSidebar, isMobile }) => {
icon: Diybridge,
subItems: [
{ label: "Bridge", icon: Diybridge, link: "#bridge" },
{ label: "Linkbutton", icon: FaLink, link: "#linkbutton" },
{ label: "Link button", icon: FaLink, link: "#linkbutton" },
{ label: "App Users", icon: PiUserListFill, link: "#users" },
{ label: "Alarm", icon: FaExclamationTriangle, link: "#alarm" },
{ label: "Settings", icon: FaCog, link: "#settings" },
Expand Down
8 changes: 8 additions & 0 deletions src/Pages/Bridge.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ const Bridge = ({ HOST_IP, API_KEY }) => {
console.error(error);
toast.error(`Error occurred: ${error.message}`);
});
closeWizard()
};

const backupConfig = () => {
Expand All @@ -165,6 +166,7 @@ const Bridge = ({ HOST_IP, API_KEY }) => {
console.error(error);
toast.error(`Error occurred: ${error.message}`);
});
closeWizard()
};

const downloadConfig = () => {
Expand All @@ -178,6 +180,7 @@ const Bridge = ({ HOST_IP, API_KEY }) => {
console.error(error);
toast.error(`Error occurred: ${error.message}`);
});
closeWizard()
};

const Restart = () => {
Expand Down Expand Up @@ -270,6 +273,7 @@ const Bridge = ({ HOST_IP, API_KEY }) => {
console.error(error);
toast.error(`Error occurred: ${error.message}`);
});
closeWizard()
};

const restoreAlert = () => {
Expand Down Expand Up @@ -299,6 +303,7 @@ const Bridge = ({ HOST_IP, API_KEY }) => {
console.error(error);
toast.error(`Error occurred: ${error.message}`);
});
closeWizard()
};

const debugOptions = () => {
Expand Down Expand Up @@ -340,6 +345,7 @@ const Bridge = ({ HOST_IP, API_KEY }) => {
console.error(error);
toast.error(`Error occurred: ${error.message}`);
});
closeWizard()
};

const downloadLog = () => {
Expand All @@ -353,6 +359,8 @@ const Bridge = ({ HOST_IP, API_KEY }) => {
console.error(error);
toast.error(`Error occurred: ${error.message}`);
});

closeWizard()
};

let options = timezones.map(function (timezone) {
Expand Down
2 changes: 1 addition & 1 deletion src/Pages/Lights.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ export default function Lights({ HOST_IP, API_KEY }) {
closeWizard={closeWizard}
headline="Add Light"
>
<AddLight HOST_IP={HOST_IP} API_KEY={API_KEY}></AddLight>
<AddLight HOST_IP={HOST_IP} API_KEY={API_KEY} closeWizard={closeWizard}></AddLight>
</Wizard>
</div>
);
Expand Down
7 changes: 3 additions & 4 deletions src/components/AddLight/AddLight.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import GenericButton from "../GenericButton/GenericButton";
import GenericText from "../GenericText/GenericText";
import SelectMenu from "../SelectMenu/SelectMenu";

const AddLight = ({ HOST_IP, API_KEY }) => {
const AddLight = ({ HOST_IP, API_KEY, closeWizard }) => {
const [lightData, setLightData] = useState({
protocol: "auto",
});
Expand All @@ -19,8 +19,7 @@ const AddLight = ({ HOST_IP, API_KEY }) => {
});
};

const handleForm = (evt) => {
evt.preventDefault();
const handleForm = () => {
const { protocol: lightproto, ip: lightip, ...rest } = lightData;
const formattedData = {
protocol: lightproto,
Expand All @@ -36,7 +35,7 @@ const AddLight = ({ HOST_IP, API_KEY }) => {
console.error(error);
toast.error(`Error occurred: ${error.message}`);
});

closeWizard()
};

const protocols = [
Expand Down
26 changes: 22 additions & 4 deletions src/components/MenuItem/MenuItem.jsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,27 @@
import React, { useState } from "react";
import { useState } from "react";

import { motion } from "framer-motion";
import { FaAngleDown } from "react-icons/fa";

const MenuItem = ({ label, icon, onClick, isActive, children, link }) => {
const MenuItem = ({ label, icon, onClick, isActive, children, link, items, currentElement }) => {
const [isOpen, setIsOpen] = useState(false);

const submenuActive = () => {
if (label === "DiyHue" || label === "Addons") {
for (let x = 0; x < items.length; x++) {
if (items[x]["label"] === label) {
const subItems = items[x].subItems
for (let i = 0; i < subItems.length; i++) {
if (subItems[i].link === currentElement) {
setIsOpen(true);
}
}
}
}
}
}


const handleParentClick = (e) => {
if (children) {
e.stopPropagation();
Expand All @@ -26,14 +42,14 @@ const MenuItem = ({ label, icon, onClick, isActive, children, link }) => {
{icon}
<p>{label}</p>
<motion.div
animate={{ rotate: isOpen ? 180 : 0 }}
animate={{ rotate: (isOpen || submenuActive()) ? 180 : 0 }}
transition={{ duration: 0.3 }}
className="submenuIcon"
>
{children && <FaAngleDown />}
</motion.div>
</div>
<div className="submenu">{isOpen && children}</div>
<div className="submenu">{(isOpen || submenuActive()) && children}</div>
</li>
);

Expand Down Expand Up @@ -67,6 +83,8 @@ const SubMenu = ({ items, currentElement, itemClicked }) => (
onClick={() => itemClicked(item.link)}
isActive={currentElement === item.link}
link={item.link}
items={items}
currentElement={currentElement}
>
{item.subItems && (
<SubMenu
Expand Down
14 changes: 9 additions & 5 deletions src/components/NotificationCenter/NotificationCenter.jsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import { FaBell } from "react-icons/fa";
import { useState, useEffect } from "react";
import "./notificationCenter.scss";
import Wizard from "../Wizard/Wizard";
import GenericButton from "../GenericButton/GenericButton";

import axios from "axios";
import { toast } from "react-hot-toast";
import { Tooltip } from "@mui/material";
import axios from "axios";
import { FaBell } from "react-icons/fa";

import Wizard from "../Wizard/Wizard";
import GenericButton from "../GenericButton/GenericButton";

import "./notificationCenter.scss";


const NotificationCenter = ({HOST_IP, API_KEY, updating, notifications }) => {
Expand Down Expand Up @@ -65,6 +68,7 @@ const NotificationCenter = ({HOST_IP, API_KEY, updating, notifications }) => {
toast.error(`Error occurred: ${error.message}`);
});
}
closeWizard()
};

const getValueState = (state) => {
Expand Down
Loading