Skip to content

Commit

Permalink
fix: remove Buckets List page, add Chunks and Data tabs to Device
Browse files Browse the repository at this point in the history
  • Loading branch information
klausborges committed Dec 19, 2024
1 parent ab23173 commit 2d5c86a
Show file tree
Hide file tree
Showing 24 changed files with 2,093 additions and 443 deletions.
1,172 changes: 911 additions & 261 deletions package-lock.json

Large diffs are not rendered by default.

26 changes: 13 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"cors": "2.8.5",
"express": "4.21.1",
"luxon": "3.5.0",
"nanoid": "5.0.7",
"nanoid": "5.0.9",
"md5": "2.3.0",
"polished": "4.3.1",
"ora": "8.1.0",
Expand All @@ -39,7 +39,7 @@
"socket.io": "4.4.1",
"socket.io-client": "4.4.1",
"styled-components": "6.1.13",
"systeminformation": "5.23.5",
"systeminformation": "5.23.13",
"uuid": "10.0.0",
"zod": "3.23.8"
},
Expand All @@ -48,29 +48,29 @@
"@swc-node/register": "1.10.9",
"@tago-io/tcore-sdk": "0.7.2",
"@testing-library/dom": "10.4.0",
"@testing-library/jest-dom": "6.6.2",
"@testing-library/react": "16.0.1",
"@testing-library/jest-dom": "6.6.3",
"@testing-library/react": "16.1.0",
"@testing-library/user-event": "14.5.2",
"@types/async": "3.2.24",
"@types/axios": "0.14.0",
"@types/express": "5.0.0",
"@types/luxon": "3.4.2",
"@types/ms": "0.7.34",
"@types/node": "20.14.8",
"@types/node": "22.10.2",
"@types/semver": "7.5.8",
"@types/cors": "2.8.17",
"@types/uuid": "10.0.0",
"@types/md5": "2.3.5",
"@types/react": "18.3.12",
"@types/react-dom": "18.3.1",
"@vitejs/plugin-react-swc": "3.7.1",
"concurrently": "9.0.1",
"@types/react": "18.3.17",
"@types/react-dom": "18.3.5",
"@vitejs/plugin-react-swc": "3.7.2",
"concurrently": "9.1.0",
"esbuild": "0.24.0",
"jsdom": "25.0.1",
"ts-node": "10.9.2",
"typescript": "5.6.3",
"vitest": "2.1.3",
"vite": "5.4.10",
"vite-plugin-svgr": "4.2.0"
"typescript": "5.7.2",
"vitest": "2.1.8",
"vite": "6.0.3",
"vite-plugin-svgr": "4.3.0"
}
}
6 changes: 3 additions & 3 deletions packages/console/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
"cronstrue": "2.5.0",
"lodash.clonedeep": "4.5.0",
"mobx": "6.13.5",
"mobx-react": "9.1.1",
"mobx-react": "9.2.0",
"react-helmet-async": "2.0.5",
"react-markdown": "9.0.1",
"react-router": "6.27.0",
"react-router-dom": "6.27.0",
"react-router": "6.28.0",
"react-router-dom": "6.28.0",
"swr": "2.2.5"
},
"devDependencies": {
Expand Down
2 changes: 0 additions & 2 deletions packages/console/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import ActionList from "./Components/Action/List/ActionList.tsx";
import AnalysisEdit from "./Components/Analysis/Edit/AnalysisEdit.tsx";
import AnalysisList from "./Components/Analysis/List/AnalysisList.tsx";
import BucketEdit from "./Components/Bucket/Edit/BucketEdit.tsx";
import BucketList from "./Components/Bucket/List/BucketList.tsx";
import DeviceEdit from "./Components/Device/Edit/DeviceEdit.tsx";
import DeviceList from "./Components/Device/List/DeviceList.tsx";
import Home from "./Components/Home/Home.tsx";
Expand Down Expand Up @@ -171,7 +170,6 @@ function MainScreenWrapper() {
<Route path="/actions/:id" element={<ActionEdit />} />
<Route path="/analysis" element={<AnalysisList />} />
<Route path="/analysis/:id" element={<AnalysisEdit />} />
<Route path="/buckets" element={<BucketList />} />
<Route path="/buckets/:id" element={<BucketEdit />} />
<Route path="/devices" element={<DeviceList />} />
<Route path="/devices/:id" element={<DeviceEdit />} />
Expand Down
98 changes: 0 additions & 98 deletions packages/console/src/Components/Bucket/List/BucketList.tsx

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import styled from "styled-components";

export const Characters = styled.div`
color: rgba(0, 0, 0, 0.6);
display: inline-block;
text-align: right;
font-size: 0.73rem;
position: absolute;
right: 10px;
top: 50%;
transform: translate(0%, -50%);
z-index: 12;
`;
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import type { IDevice, IDeviceData } from "@tago-io/tcore-sdk/types";
import { useCallback, useState } from "react";
import editDeviceData from "../../../../Requests/editDeviceData.ts";
import { FormGroup, Input, Modal } from "../../../../index.ts";
import { EIcon } from "../../../Icon/Icon.types";
import * as Style from "./ModalEditGroup.style";

interface ModalEditGroupProps {
device: IDevice;
data: IDeviceData;
onClose: () => void;
}

export function ModalEditGroup(props: ModalEditGroupProps) {
const { data, device, onClose } = props;
const [value, setValue] = useState(() => String(data.group || ""));

const confirm = useCallback(async () => {
data.group = String(value);
await editDeviceData(device.id, data);
}, [value, device?.id, data]);

return (
<Modal
onClose={onClose}
onCancel={onClose}
onConfirm={confirm}
title="Edit group"
width="400px"
>
<FormGroup
addMarginBottom={false}
icon={EIcon.cube}
tooltip="Insert the group for this data item"
label="Group"
>
<div style={{ position: "relative" }}>
<Input
autoFocus
onChange={(e) => setValue(e.target.value.substring(0, 24))}
value={value}
placeholder="Enter the group for the data item"
spellCheck="false"
/>
<Style.Characters>{String(value).length} / 24</Style.Characters>
</div>
</FormGroup>
</Modal>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import type { IDevice, IDeviceData } from "@tago-io/tcore-sdk/types";
import { useCallback, useState } from "react";
import editDeviceData from "../../../../Requests/editDeviceData.ts";
import { Col, FormGroup, Input, Modal, Row } from "../../../../index.ts";
import { EIcon } from "../../../Icon/Icon.types";

interface ModalEditLocationProps {
device: IDevice;
data: IDeviceData;
onClose: () => void;
}

export function ModalEditLocation(props: ModalEditLocationProps) {
const { data, device, onClose } = props;

const [lat, setLat] = useState(() => data.location?.coordinates?.[1] || "");
const [lng, setLng] = useState(() => data.location?.coordinates?.[0] || "");

const confirm = useCallback(async () => {
data.location = {
type: "Point",
coordinates: [Number(lng), Number(lat)],
};
await editDeviceData(device.id, data);
}, [lat, lng, device?.id, data]);

return (
<Modal
onClose={onClose}
onCancel={onClose}
onConfirm={confirm}
title="Edit location"
width="550px"
isConfirmButtonDisabled={!lat || !lng}
>
<Row>
<Col size="6">
<FormGroup
addMarginBottom={false}
icon={EIcon.cube}
tooltip="Insert the latitude for this data item"
label="Latitude"
>
<Input
autoFocus
onChange={(e) => setLat(e.target.value)}
value={lat}
placeholder="Enter the latitude for the data item"
/>
</FormGroup>
</Col>

<Col size="6">
<FormGroup
addMarginBottom={false}
icon={EIcon.cube}
tooltip="Insert the longitude for this data item"
label="Longitude"
>
<Input
autoFocus
onChange={(e) => setLng(e.target.value)}
value={lng}
placeholder="Enter the longitude for the data item"
/>
</FormGroup>
</Col>
</Row>
</Modal>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import styled from "styled-components";
import FormControlStyles from "../../../Styles/FormControlStyles.ts";

export const TextArea = styled.textarea`
${FormControlStyles}
resize: none;
height: 300px;
font-family: Monospace;
`;
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import type { IDevice, IDeviceData } from "@tago-io/tcore-sdk/types";
import { useCallback, useState } from "react";
import editDeviceData from "../../../../Requests/editDeviceData.ts";
import { FormGroup, Modal } from "../../../../index.ts";
import { EIcon } from "../../../Icon/Icon.types";
import * as Style from "./ModalEditMetadata.style";

interface ModalEditMetadataProps {
device: IDevice;
data: IDeviceData;
onClose: () => void;
}

export function ModalEditMetadata(props: ModalEditMetadataProps) {
const { data, device, onClose } = props;
const [value, setValue] = useState(() =>
data.metadata ? JSON.stringify(data.metadata, null, 2) : "",
);

const confirm = useCallback(async () => {
data.metadata = JSON.parse(value);
await editDeviceData(device.id, data);
}, [value, device?.id, data]);

let validJSON = true;
try {
JSON.parse(value);
validJSON = true;
} catch (ex) {
validJSON = false;
}

return (
<Modal
onClose={onClose}
onCancel={onClose}
onConfirm={confirm}
title="Edit metadata"
width="550px"
isConfirmButtonDisabled={!validJSON}
>
<FormGroup
addMarginBottom={false}
icon={EIcon.cube}
tooltip="Insert the group for this data item"
label="Metadata"
>
<Style.TextArea
autoFocus
onChange={(e) => setValue(e.target.value)}
placeholder="Insert a valid JSON"
value={value}
/>
</FormGroup>
</Modal>
);
}
Loading

0 comments on commit 2d5c86a

Please sign in to comment.