diff --git a/client/src/components/Canvas/CanvasComponents/AddWidgetMenu.jsx b/client/src/components/Canvas/CanvasComponents/AddWidgetMenu.jsx index 5ce0553..c2f4b5e 100644 --- a/client/src/components/Canvas/CanvasComponents/AddWidgetMenu.jsx +++ b/client/src/components/Canvas/CanvasComponents/AddWidgetMenu.jsx @@ -1,18 +1,8 @@ import { IoIosArrowBack } from "react-icons/io"; import { Menu, Portal } from "@chakra-ui/react"; -import { v4 as uuid } from 'uuid'; import AlertLevel from "./AlertLevelWidget"; -export default function AddWidgetMenu({onAddWidget, widgetArray, setWidgetArray}) { - function appendWidget(name) { - const newID = uuid(); // could be replaced with something else like guid - setWidgetArray([ // updating widget array containing info on the types of widgets - ...widgetArray, - {i: newID, widget: name} - ]); - onAddWidget(newID); // updating array containing info on layout of widgets - } - +export default function AddWidgetMenu({appendWidget}) { return ( @@ -23,10 +13,22 @@ export default function AddWidgetMenu({onAddWidget, widgetArray, setWidgetArray} appendWidget(AlertLevel)} + onClick={() => appendWidget(AlertLevel, 3, 6, 3, 6, 3, 6)} // width and height are passed through here for each widget > Alert Level + + CO2 + + + IVANS + + + Plume Heights + + + Alert Level Changes + diff --git a/client/src/components/Canvas/CanvasComponents/AlertLevelWidget.jsx b/client/src/components/Canvas/CanvasComponents/AlertLevelWidget.jsx index 9591b72..c28945c 100644 --- a/client/src/components/Canvas/CanvasComponents/AlertLevelWidget.jsx +++ b/client/src/components/Canvas/CanvasComponents/AlertLevelWidget.jsx @@ -1,27 +1,65 @@ import Widget from "./Widget"; -import { HStack, Box, Field, Input, Button } from "@chakra-ui/react"; +import { Stack, Box, Field, Input, Button, Text } from "@chakra-ui/react"; import { useForm } from "react-hook-form"; +import { useState } from "react"; export default function AlertLevel({id, isEditable, isDelete, DeleteWidget}) { const { register, handleSubmit } = useForm(); - const onSubmit = (data) => console.log(data); + const onSubmit = (data) => { + console.log(data); + setIsSubmit(true); + } + const [isSubmit, setIsSubmit] = useState(false); + // Prop Forwarding + const widgetProps = { id, isEditable, isDelete, DeleteWidget, isSubmit, setIsSubmit } return ( - - - - - Country Name - - - - + + {!isSubmit ? ( + + + + + Country Name + + + + Volcano Name + + + + + + + ):( + + + Alert Level Data Coming Soon. + + + )} ); } \ No newline at end of file diff --git a/client/src/components/Canvas/CanvasComponents/SettingsButton.jsx b/client/src/components/Canvas/CanvasComponents/SettingsButton.jsx index 31d7280..d51904b 100644 --- a/client/src/components/Canvas/CanvasComponents/SettingsButton.jsx +++ b/client/src/components/Canvas/CanvasComponents/SettingsButton.jsx @@ -2,7 +2,8 @@ import { IconButton, Menu, Portal } from "@chakra-ui/react"; import { FiSettings } from "react-icons/fi"; import AddWidgetMenu from "./AddWidgetMenu"; -export function SettingsButton({onAddWidget, onEditWidgets, onDeleteWidgets, widgetArray, setWidgetArray}) { +export function SettingsButton({ onEditWidgets, onDeleteWidgets, appendWidget}) { + const addWidgetMenuProps = { appendWidget } return ( @@ -13,7 +14,7 @@ export function SettingsButton({onAddWidget, onEditWidgets, onDeleteWidgets, wid - + Edit Widgets ); -} - - - - - +} \ No newline at end of file diff --git a/client/src/components/Canvas/CanvasComponents/Widget.jsx b/client/src/components/Canvas/CanvasComponents/Widget.jsx index b31f8e8..f9fc0d1 100644 --- a/client/src/components/Canvas/CanvasComponents/Widget.jsx +++ b/client/src/components/Canvas/CanvasComponents/Widget.jsx @@ -1,10 +1,13 @@ import { useSlotRecipe, chakra, Flex, CloseButton, Text, IconButton } from "@chakra-ui/react" -import { FaEllipsisH } from "react-icons/fa"; +import { GrUndo } from "react-icons/gr"; -export default function Widget({ id, title, isEditable, isDelete, DeleteWidget, children }) { +export default function Widget(props) { + // deconstructing props + const { id, title, isEditable, isDelete, DeleteWidget, isSubmit, setIsSubmit, children } = props; const recipe = useSlotRecipe({ key: "widget" }); const styles = recipe(); + return ( <> @@ -19,12 +22,14 @@ export default function Widget({ id, title, isEditable, isDelete, DeleteWidget, <> {title} - + {isSubmit ? ( + setIsSubmit(false)} size="xs" bg="base300" cursor="pointer"> + ):(null)} )} - + {children} diff --git a/client/src/components/Canvas/views/Home.jsx b/client/src/components/Canvas/views/Home.jsx index bc95eb8..6ef3ad9 100644 --- a/client/src/components/Canvas/views/Home.jsx +++ b/client/src/components/Canvas/views/Home.jsx @@ -9,23 +9,27 @@ import { RemoteSensing } from "./HomeTabs/RemoteSensing"; import { CancelButton } from "../CanvasComponents/CancelButton"; import { SaveButton } from "../CanvasComponents/SaveButton"; import DeleteAllButton from "../CanvasComponents/DeleteAllButton"; +import { v4 as uuid } from 'uuid'; + export default function Home({...props}) { // deconstructing props const { view, layout, setLayout, setOriginalLayout, onLayoutChange, onChangeView, onCancel, isDelete, setIsDelete, isEditable, setIsEditable, widgetArray, setWidgetArray } = props; - const onAddWidget = (ID) => { + const onAddWidget = (ID, w, h, minw, minh, maxw, maxh) => { setLayout(prev => [ ...prev, { i: ID, x: (prev.length * 3) % 12, y: Infinity, - w: 2, - h: 5, - minW: 2, - minH: 5, + w: w, + h: h, + minW: minw, + minH: minh, + maxW: maxw, + maxH: maxh, static: false, resizeHandles: ['se'] } @@ -33,6 +37,15 @@ export default function Home({...props}) { onEditWidgets(); }; + function appendWidget(name, w, h, minw, minh, maxw, maxh) { + const newID = uuid(); // could be replaced with something else like guid + setWidgetArray([ // updating widget array containing info on the types of widgets + ...widgetArray, + {i: newID, widget: name } + ]); + onAddWidget(newID, w, h, minw, minh, maxw, maxh); // updating array containing info on layout of widgets + } + const onEditWidgets = () => { console.log("widgets are now editable"); setOriginalLayout(layout); // Backup layout before editing @@ -87,7 +100,7 @@ export default function Home({...props}) { // Prop Forwarding const MyDashboardProps = { layout, onLayoutChange, isEditable, isDelete, DeleteWidget, widgetArray }; - const settingsButtonProps = { onAddWidget, onEditWidgets, onDeleteWidgets, setWidgetArray, widgetArray }; + const settingsButtonProps = { onEditWidgets, onDeleteWidgets, appendWidget }; return ( /* HEADER */ @@ -109,7 +122,7 @@ export default function Home({...props}) { top="0" zIndex="dropdown" // zIndex: 1100 bg="base200" - px={6} + px={5} pt={3} align="center" justify="space-between" diff --git a/client/src/components/Canvas/views/HomeTabs/MyDashboard.jsx b/client/src/components/Canvas/views/HomeTabs/MyDashboard.jsx index a982349..fcd364f 100644 --- a/client/src/components/Canvas/views/HomeTabs/MyDashboard.jsx +++ b/client/src/components/Canvas/views/HomeTabs/MyDashboard.jsx @@ -13,6 +13,7 @@ export default function MyDashboard({layout, onLayoutChange, isEditable, isDelet console.log("widgetArray: ", widgetArray); console.log("layout: ", layout); + if (widgetArray.length && layout.length) { const widgetMap = new Map(widgetArray.map(item => [item.i, item])); merged = layout.map(item => { @@ -29,17 +30,16 @@ export default function MyDashboard({layout, onLayoutChange, isEditable, isDelet useCSSTransforms={false} // remove the sliding animation of the widgets className="layout" layout={layout} - cols={12} // Total columns in grid - rowHeight={30} //Height of a single row in px + cols={16} // Total columns in grid + rowHeight={30} // Height of a single row in px isBounded={true} // Total width of the grid - margin={[10, 10]} // [horizontal, vertical] gap + margin={[15, 5]} // [horizontal, vertical] gap onLayoutChange={onLayoutChange} draggableHandle=".widget-handle" // Make only the header draggable onDragStart={handleDragStart} onDragStop={handleDragStop} position="relative" resizeHandle={} - isResizable={isEditable} > {merged.map((item) => { const Widget = item.widget; diff --git a/client/src/components/Dashboard.jsx b/client/src/components/Dashboard.jsx index 02a6a51..a9db845 100644 --- a/client/src/components/Dashboard.jsx +++ b/client/src/components/Dashboard.jsx @@ -1,7 +1,7 @@ import Header from './Header/Header.jsx'; import Sidebar from './Sidebar/Sidebar.jsx'; import Canvas from './Canvas/Canvas.jsx'; -import { Grid, GridItem, useRecipe } from '@chakra-ui/react'; +import { Grid, GridItem, useRecipe, Dialog } from '@chakra-ui/react'; import { useState } from 'react'; export default function Dashboard() { diff --git a/client/src/css/index.css b/client/src/css/index.css index 22e4f59..3725a93 100644 --- a/client/src/css/index.css +++ b/client/src/css/index.css @@ -1,4 +1,3 @@ :root { font-family: Georgia, 'Times New Roman', Times, serif; - color: #19332D; } \ No newline at end of file