updating names cont.
This commit is contained in:
@@ -1,11 +1,10 @@
|
|||||||
import { Box } from "@chakra-ui/react";
|
import GlobalMap from "./views/GlobalMap";
|
||||||
import GlobalMapCanvas from "./views/GlobalMap";
|
import RegionalMap from "./views/RegionalMap";
|
||||||
import RegionalMapCanvas from "./views/RegionalMap";
|
import Volcano from "./views/Volcano";
|
||||||
import VolcanoCanvas from "./views/Volcano";
|
import Admin from "./views/Admin";
|
||||||
import AdminCanvas from "./views/Admin";
|
import Account from "./views/Account"
|
||||||
import AccountCanvas from "./views/Account"
|
import Settings from "./views/Settings"
|
||||||
import SettingsCanvas from "./views/Settings"
|
import Home from "./views/Home";
|
||||||
import { HomeCanvas } from "./views/Home";
|
|
||||||
import { DASHBOARD_VIEWS } from "@/constants/viewKeys";
|
import { DASHBOARD_VIEWS } from "@/constants/viewKeys";
|
||||||
|
|
||||||
export default function Canvas({...props}) {
|
export default function Canvas({...props}) {
|
||||||
@@ -14,14 +13,14 @@ export default function Canvas({...props}) {
|
|||||||
<>
|
<>
|
||||||
{/* Check if view is a tab inside the Canvas Header */}
|
{/* Check if view is a tab inside the Canvas Header */}
|
||||||
{ DASHBOARD_VIEWS.includes(view) && (
|
{ DASHBOARD_VIEWS.includes(view) && (
|
||||||
<HomeCanvas width="100%" height="100%" {...props}/>
|
<Home width="100%" height="100%" {...props}/>
|
||||||
)}
|
)}
|
||||||
{view === "global" && <GlobalMapCanvas />}
|
{view === "global" && <GlobalMap />}
|
||||||
{view === "regional" && <RegionalMapCanvas />}
|
{view === "regional" && <RegionalMap />}
|
||||||
{view === "volcano" && <VolcanoCanvas />}
|
{view === "volcano" && <Volcano />}
|
||||||
{view === "admin" && <AdminCanvas />}
|
{view === "admin" && <Admin />}
|
||||||
{view === "account" && <AccountCanvas />}
|
{view === "account" && <Account />}
|
||||||
{view === "settings" && <SettingsCanvas />}
|
{view === "settings" && <Settings />}
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
import { Box, Flex, Field, Input, Stack, Heading, Button } from "@chakra-ui/react"
|
import { Box, Flex, Field, Input, Stack, Heading, Button } from "@chakra-ui/react"
|
||||||
import { useForm } from 'react-hook-form';
|
import { useForm } from 'react-hook-form';
|
||||||
|
|
||||||
export default function AccountCanvas() {
|
export default function Account() {
|
||||||
const {
|
const {
|
||||||
register,
|
register,
|
||||||
handleSubmit,
|
handleSubmit,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { Box, Text } from '@chakra-ui/react';
|
import { Box, Text } from '@chakra-ui/react';
|
||||||
|
|
||||||
export default function AdminCanvas() {
|
export default function Admin() {
|
||||||
return (
|
return (
|
||||||
<Box p={8} mt={4} ml="auto" mr="auto" width="600px">
|
<Box p={8} mt={4} ml="auto" mr="auto" width="600px">
|
||||||
<Box
|
<Box
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import { MapContainer, TileLayer, Marker, Popup } from "react-leaflet";
|
import { MapContainer, TileLayer, Marker, Popup } from "react-leaflet";
|
||||||
|
|
||||||
export default function GlobalMapCanvas() {
|
export default function GlobalMap() {
|
||||||
const position = [45.61142478054226, -122.49630033167544]; // [latitude, longitude]
|
const position = [45.61142478054226, -122.49630033167544]; // [latitude, longitude]
|
||||||
return (
|
return (
|
||||||
<MapContainer center={position} zoom={3} style={{ height: "100%", width: "100%" }}>
|
<MapContainer center={position} zoom={3} style={{ height: "100%", width: "100%" }}>
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import { HStack, Flex, Tabs } from "@chakra-ui/react";
|
import { HStack, Flex, Tabs } from "@chakra-ui/react";
|
||||||
import { useState } from "react";
|
import MyDashboard from "./HomeTabs/MyDashboard";
|
||||||
import WidgetCanvas from "./HomeTabs/MyDashboard";
|
|
||||||
import { SearchBar } from "../CanvasComponents/SearchBar";
|
import { SearchBar } from "../CanvasComponents/SearchBar";
|
||||||
import { SettingsButton } from "../CanvasComponents/SettingsButton";
|
import { SettingsButton } from "../CanvasComponents/SettingsButton";
|
||||||
import { DailyActivity } from "./HomeTabs/DailyActivity";
|
import { DailyActivity } from "./HomeTabs/DailyActivity";
|
||||||
@@ -11,7 +10,7 @@ import { CancelButton } from "../CanvasComponents/CancelButton";
|
|||||||
import { SaveButton } from "../CanvasComponents/SaveButton";
|
import { SaveButton } from "../CanvasComponents/SaveButton";
|
||||||
import DeleteAllButton from "../CanvasComponents/DeleteAllButton";
|
import DeleteAllButton from "../CanvasComponents/DeleteAllButton";
|
||||||
|
|
||||||
export function HomeCanvas({...props}) {
|
export default function Home({...props}) {
|
||||||
// deconstructing props
|
// deconstructing props
|
||||||
const { width, height, view, layout, setLayout, setOriginalLayout, onLayoutChange, onChangeView, onCancel,
|
const { width, height, view, layout, setLayout, setOriginalLayout, onLayoutChange, onChangeView, onCancel,
|
||||||
isDelete, setIsDelete, isEditable, setIsEditable, widgetArray, setWidgetArray } = props;
|
isDelete, setIsDelete, isEditable, setIsEditable, widgetArray, setWidgetArray } = props;
|
||||||
@@ -84,7 +83,7 @@ export function HomeCanvas({...props}) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Prop Forwarding
|
// Prop Forwarding
|
||||||
const widgetCanvasProps = { layout, onLayoutChange, isEditable, isDelete, DeleteWidget, widgetArray };
|
const MyDashboardProps = { layout, onLayoutChange, isEditable, isDelete, DeleteWidget, widgetArray };
|
||||||
const settingsButtonProps = { onAddWidget, onEditWidgets, onDeleteWidgets, setWidgetArray, widgetArray };
|
const settingsButtonProps = { onAddWidget, onEditWidgets, onDeleteWidgets, setWidgetArray, widgetArray };
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -113,7 +112,7 @@ export function HomeCanvas({...props}) {
|
|||||||
justify="space-between"
|
justify="space-between"
|
||||||
>
|
>
|
||||||
<Tabs.List>
|
<Tabs.List>
|
||||||
<Tabs.Trigger value="widget" fontSize="lg">
|
<Tabs.Trigger value="mydashboard" fontSize="lg">
|
||||||
My Dashboard
|
My Dashboard
|
||||||
</Tabs.Trigger>
|
</Tabs.Trigger>
|
||||||
<Tabs.Trigger value="gas" fontSize="lg">
|
<Tabs.Trigger value="gas" fontSize="lg">
|
||||||
@@ -150,8 +149,8 @@ export function HomeCanvas({...props}) {
|
|||||||
</Flex>
|
</Flex>
|
||||||
|
|
||||||
{/* CANVAS */}
|
{/* CANVAS */}
|
||||||
<Tabs.Content value="widget">
|
<Tabs.Content value="mydashboard">
|
||||||
<WidgetCanvas {...widgetCanvasProps}/>
|
<MyDashboard {...MyDashboardProps}/>
|
||||||
</Tabs.Content>
|
</Tabs.Content>
|
||||||
<Tabs.Content value="gas">
|
<Tabs.Content value="gas">
|
||||||
<Gas />
|
<Gas />
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import GridLayout, { WidthProvider } from 'react-grid-layout';
|
import GridLayout, { WidthProvider } from 'react-grid-layout';
|
||||||
import { useSlotRecipe, chakra, Flex } from '@chakra-ui/react';
|
import { useSlotRecipe, chakra, Flex } from '@chakra-ui/react';
|
||||||
|
|
||||||
export default function WidgetCanvas({layout, onLayoutChange, isEditable, isDelete, DeleteWidget, widgetArray}) {
|
export default function MyDashboard({layout, onLayoutChange, isEditable, isDelete, DeleteWidget, widgetArray}) {
|
||||||
console.log("rendering MyDashboard");
|
console.log("rendering MyDashboard");
|
||||||
const recipe = useSlotRecipe({ key: "widget" });
|
const recipe = useSlotRecipe({ key: "widget" });
|
||||||
const styles = recipe(); // using root recipe for widget below
|
const styles = recipe(); // using root recipe for widget below
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import { MapContainer, TileLayer, Marker, Popup } from "react-leaflet";
|
import { MapContainer, TileLayer, Marker, Popup } from "react-leaflet";
|
||||||
|
|
||||||
export default function GlobalMapCanvas() {
|
export default function RegionalMap() {
|
||||||
const position = [45.61142478054226, -122.49630033167544]; // [latitude, longitude]
|
const position = [45.61142478054226, -122.49630033167544]; // [latitude, longitude]
|
||||||
return (
|
return (
|
||||||
<MapContainer center={position} zoom={13} style={{ height: "100%", width: "100%" }}>
|
<MapContainer center={position} zoom={13} style={{ height: "100%", width: "100%" }}>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { Box, Text } from '@chakra-ui/react';
|
import { Box, Text } from '@chakra-ui/react';
|
||||||
|
|
||||||
export default function SettingsCanvas() {
|
export default function Settings() {
|
||||||
return (
|
return (
|
||||||
<Box p={8} mt={4} ml="auto" mr="auto" width="600px">
|
<Box p={8} mt={4} ml="auto" mr="auto" width="600px">
|
||||||
<Box
|
<Box
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { Box, Text } from '@chakra-ui/react';
|
import { Box, Text } from '@chakra-ui/react';
|
||||||
|
|
||||||
export default function VolcanoCanvas() {
|
export default function Volcano() {
|
||||||
return (
|
return (
|
||||||
<Box p={8} mt={4} ml="auto" mr="auto" width="600px">
|
<Box p={8} mt={4} ml="auto" mr="auto" width="600px">
|
||||||
<Box
|
<Box
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ export default function Dashboard() {
|
|||||||
const [isEditable, setIsEditable] = useState(false); // editable=true means static=false (vice versa)
|
const [isEditable, setIsEditable] = useState(false); // editable=true means static=false (vice versa)
|
||||||
const [isDelete, setIsDelete] = useState(false);
|
const [isDelete, setIsDelete] = useState(false);
|
||||||
const [originalLayout, setOriginalLayout] = useState([]);
|
const [originalLayout, setOriginalLayout] = useState([]);
|
||||||
const [view, setView] = useState("widget");
|
const [view, setView] = useState("mydashboard");
|
||||||
const [layout, setLayout] = useState([]);
|
const [layout, setLayout] = useState([]);
|
||||||
const [widgetArray, setWidgetArray] = useState([]);
|
const [widgetArray, setWidgetArray] = useState([]);
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ export default function Sidebar({ view, onChangeView, darkMode, setDarkMode }) {
|
|||||||
|
|
||||||
// this list of btns will come from the db (not every usr will have access to admin)
|
// this list of btns will come from the db (not every usr will have access to admin)
|
||||||
const buttons = [
|
const buttons = [
|
||||||
{icon: FaHome, name: "Home", view: "widget"},
|
{icon: FaHome, name: "Home", view: "mydashboard"},
|
||||||
{icon: FaGlobeAmericas, name: "Global Map", view: "global"},
|
{icon: FaGlobeAmericas, name: "Global Map", view: "global"},
|
||||||
{icon: FaMapMarkerAlt, name: "Regional Map", view: "regional"},
|
{icon: FaMapMarkerAlt, name: "Regional Map", view: "regional"},
|
||||||
{icon: FaVolcano, name: "Volcano", view: "volcano"},
|
{icon: FaVolcano, name: "Volcano", view: "volcano"},
|
||||||
@@ -35,7 +35,7 @@ export default function Sidebar({ view, onChangeView, darkMode, setDarkMode }) {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
console.log("Current view = ", view);
|
console.log("Current view = ", view);
|
||||||
const newIndex = buttons.findIndex((btn) => {
|
const newIndex = buttons.findIndex((btn) => {
|
||||||
if (btn.view === "widget") {
|
if (btn.view === "mydashboard") {
|
||||||
return DASHBOARD_VIEWS.includes(view);
|
return DASHBOARD_VIEWS.includes(view);
|
||||||
}
|
}
|
||||||
return btn.view === view;
|
return btn.view === view;
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
// Main views called from Sidebar
|
// Main views called from Sidebar
|
||||||
export const DASHBOARD_VIEWS = ["widget", "gas", "seismic", "remote", "daily"]
|
export const DASHBOARD_VIEWS = ["mydashboard", "gas", "seismic", "remote", "daily"]
|
||||||
|
|
||||||
// Sub views called from inside DashboardCanvas
|
// Sub views called from inside Home.jsx
|
||||||
export const VIEW_LABELS = {
|
export const VIEW_LABELS = {
|
||||||
widget: "My Dashboard",
|
mydashboard: "My Dashboard",
|
||||||
gas: "Gas",
|
gas: "Gas",
|
||||||
seismic: "Seismic",
|
seismic: "Seismic",
|
||||||
remote: "Remote Sensing",
|
remote: "Remote Sensing",
|
||||||
|
|||||||
Reference in New Issue
Block a user