added delete all widgets button
This commit is contained in:
@@ -0,0 +1,9 @@
|
|||||||
|
import { Button } from "@chakra-ui/react";
|
||||||
|
|
||||||
|
export default function DeleteAllButton ({onDeleteAll}) {
|
||||||
|
return (
|
||||||
|
<Button onClick={onDeleteAll} color="#FFFFFF" bg="#EF4444" _hover={{ bg: "bg.error", color: "#EF4444"}}>
|
||||||
|
Delete All
|
||||||
|
</Button>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
import { HStack, Flex, Tabs, Button, Box } from "@chakra-ui/react";
|
import { HStack, Flex, Tabs } from "@chakra-ui/react";
|
||||||
|
import { useState, useEffect } from "react";
|
||||||
import WidgetCanvas from "./DashboardCanvasNav/WidgetCanvas";
|
import WidgetCanvas from "./DashboardCanvasNav/WidgetCanvas";
|
||||||
import { SearchBar } from "../components/SearchBar";
|
import { SearchBar } from "../components/SearchBar";
|
||||||
import { SettingsButton } from "../components/SettingsButton";
|
import { SettingsButton } from "../components/SettingsButton";
|
||||||
@@ -6,9 +7,9 @@ import { DailyActivity } from "./DashboardCanvasNav/DailyActivity";
|
|||||||
import { Gas } from "./DashboardCanvasNav/Gas";
|
import { Gas } from "./DashboardCanvasNav/Gas";
|
||||||
import { Seismic } from "./DashboardCanvasNav/Seismic";
|
import { Seismic } from "./DashboardCanvasNav/Seismic";
|
||||||
import { RemoteSensing } from "./DashboardCanvasNav/RemoteSensing";
|
import { RemoteSensing } from "./DashboardCanvasNav/RemoteSensing";
|
||||||
import { useState, useEffect, useDebugValue } from "react";
|
|
||||||
import { CancelButton } from "../components/CancelButton";
|
import { CancelButton } from "../components/CancelButton";
|
||||||
import { SaveButton } from "../components/SaveButton";
|
import { SaveButton } from "../components/SaveButton";
|
||||||
|
import DeleteAllButton from "../components/DeleteAllButton";
|
||||||
|
|
||||||
export function DashboardCanvas({ view, setView, layout, setLayout, onLayoutChange }) {
|
export function DashboardCanvas({ view, setView, layout, setLayout, onLayoutChange }) {
|
||||||
const [isEditable, setIsEditable] = useState(false); // editable=true means static=false (vice versa)
|
const [isEditable, setIsEditable] = useState(false); // editable=true means static=false (vice versa)
|
||||||
@@ -79,6 +80,17 @@ export function DashboardCanvas({ view, setView, layout, setLayout, onLayoutChan
|
|||||||
setLayout(layout => layout.filter(w => w.i !== id));
|
setLayout(layout => layout.filter(w => w.i !== id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const DeleteAll = () => {
|
||||||
|
const confirm = window.confirm(
|
||||||
|
"Are you sure you want to delete all widgets?"
|
||||||
|
);
|
||||||
|
if (confirm) {
|
||||||
|
setLayout([]);
|
||||||
|
onSave();
|
||||||
|
}
|
||||||
|
else return;
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
/* HEADER */
|
/* HEADER */
|
||||||
<Tabs.Root
|
<Tabs.Root
|
||||||
@@ -129,10 +141,14 @@ export function DashboardCanvas({ view, setView, layout, setLayout, onLayoutChan
|
|||||||
</Tabs.List>
|
</Tabs.List>
|
||||||
|
|
||||||
<HStack >
|
<HStack >
|
||||||
{isEditable || isDelete ? (
|
{isEditable ? (
|
||||||
<>
|
<>
|
||||||
<SaveButton onSave={ onSave } />
|
<SaveButton onSave={ onSave } />
|
||||||
<CancelButton onCancel={ onCancel } />
|
<CancelButton onCancel={ onCancel } />
|
||||||
|
{isDelete ? (
|
||||||
|
<DeleteAllButton onDeleteAll={ DeleteAll } />
|
||||||
|
):(null)
|
||||||
|
}
|
||||||
</>
|
</>
|
||||||
):(
|
):(
|
||||||
<>
|
<>
|
||||||
|
|||||||
@@ -20,17 +20,6 @@ export default function Dashboard() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{/* <Global styles={css`
|
|
||||||
.leaflet-tile,
|
|
||||||
.leaflet-control-zoom-in,
|
|
||||||
.leaflet-control-zoom-out,
|
|
||||||
.leaflet-control-attribution {
|
|
||||||
filter: invert(100%) hue-rotate(180deg) brightness(95%) contrast(90%);
|
|
||||||
}
|
|
||||||
|
|
||||||
.leaflet-container {
|
|
||||||
background-color: #1e1e1e;
|
|
||||||
*/}
|
|
||||||
<Grid css={styles}
|
<Grid css={styles}
|
||||||
templateRows="1fr 11fr"
|
templateRows="1fr 11fr"
|
||||||
templateColumns="1fr 20fr"
|
templateColumns="1fr 20fr"
|
||||||
|
|||||||
Reference in New Issue
Block a user