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

Scroll UI #62

Closed
wants to merge 10 commits into from
Closed
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
45 changes: 45 additions & 0 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import "@mantine/core/styles.css";
import { MantineProvider } from "@mantine/core";
import { theme } from "@/theme";
import { data } from "@/data/sampledata";
import { useState } from "react";
import Navbar from "@/components/Navbar";
import SearchBar from "@/components/SearchBar";
import "@/css/App.css";
import DataTable from "@/components/DataTable";
import PreviewCard from "@/components/PreviewCard";

export default function App() {
const [filteredData, setFilteredData] = useState<MCAPFileInformation[]>(data);

return (
<MantineProvider theme={theme}>
<div className="app-container">
<header className="navbar">
<Navbar />
</header>

<div className="main-content static">
<div className="results-container">

<div className="table-contain-result scrollable-container">
<div className="scrollable">
<DataTable data={filteredData} />

Check failure on line 27 in src/App.tsx

View workflow job for this annotation

GitHub Actions / build

Type '{ data: MCAPFileInformation[]; }' is missing the following properties from type 'DataTableProps': setSelectedRow, setSelectedData
</div>
</div>

<div className="search-container scrollable">
<SearchBar setFilteredData={setFilteredData}/>

Check failure on line 32 in src/App.tsx

View workflow job for this annotation

GitHub Actions / build

Type '{ setFilteredData: Dispatch<SetStateAction<MCAPFileInformation[]>>; }' is not assignable to type 'IntrinsicAttributes & SearchBarWithFilterProps'.
</div>

</div>
<div className="preview-contain-result">
<PreviewCard />

Check failure on line 37 in src/App.tsx

View workflow job for this annotation

GitHub Actions / build

Property 'selectedData' is missing in type '{}' but required in type 'PreviewCardProps'.
</div>
</div>
</div>

{/* <PreviewCard /> */}
</MantineProvider>
);
}
6 changes: 5 additions & 1 deletion src/components/DataTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,11 @@ export default function DataTable({
))
);
return (
<Table.ScrollContainer h="100%" minWidth={800} style={{ overflowY: 'auto' }}>
<Table.ScrollContainer
h="100%"
minWidth={800}
style={{ overflowY: "auto" }}
>
<Table
stickyHeader
highlightOnHover={data && data.length > 0}
Expand Down
47 changes: 37 additions & 10 deletions src/components/FileUpload.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useState } from 'react';
import { Modal, Button, Notification, FileInput } from '@mantine/core';
import '@/css/FileUpload.css';
import React, { useState } from "react";
import { Modal, Button, Notification, FileInput } from "@mantine/core";
import "@/css/FileUpload.css";

interface FileUploadProps {
uploadUrl: string;
Expand All @@ -22,6 +22,24 @@ const FileUpload: React.FC<FileUploadProps> = ({ uploadUrl }) => {
setError(null);
setSuccess(null)
if (selectedFiles.length > 0) {
const formData = new FormData();
selectedFiles.forEach((file) => {
formData.append("files", file);
});

try {
const response = await fetch(uploadUrl, {
method: "POST",
body: formData,
});

if (!response.ok) {
setError("Upload failed. Network response was not ok.");
return;
}

const data = await response.json();
console.log("Upload successful:", data);
try {
const formData = new FormData();
selectedFiles.forEach(file => {
Expand Down Expand Up @@ -54,11 +72,12 @@ const FileUpload: React.FC<FileUploadProps> = ({ uploadUrl }) => {

setSelectedFiles([]);
} catch (error) {
console.error('Upload failed:', error);
setError('An error occurred while uploading. Please try again.');
console.error("Upload failed:", error);
setError("An error occurred while uploading. Please try again.");
}
} else {
setError('Please select files to upload.');
} catch (error) {
setError("Please select files to upload.");
}
}
};

Expand All @@ -82,7 +101,7 @@ const FileUpload: React.FC<FileUploadProps> = ({ uploadUrl }) => {
onClose={handleClose}
title="Select files to upload"
centered
style={{ textAlign: "center" }}
style={{ textAlign: "center" }}
>
<div className="files">
<FileInput
Expand All @@ -91,7 +110,7 @@ const FileUpload: React.FC<FileUploadProps> = ({ uploadUrl }) => {
onChange={handleFileChange}
placeholder="Select files to upload"
label="Choose files"
style={{ display: 'block', margin: '0 auto' }}
style={{ display: "block", margin: "0 auto" }}
/>
{selectedFiles.length > 0 && (
<div>
Expand All @@ -105,14 +124,22 @@ const FileUpload: React.FC<FileUploadProps> = ({ uploadUrl }) => {
)}
</div>

<Button onClick={handleUpload} style={{ marginTop: 10 }}>
Upload
</Button>

<Button onClick={handleUpload} style={{ marginTop: 10 }}>Upload</Button>
{success && (
<Notification color="green" onClose={() => setSuccess(null)} style={{ marginTop: 10 }}>
{success}
</Notification>
)}
{error && (
<Notification color="red" onClose={() => setError(null)} style={{ marginTop: 10 }}>
<Notification
color="red"
onClose={() => setError(null)}
style={{ marginTop: 10 }}
>
{error}
</Notification>
)}
Expand Down
3 changes: 2 additions & 1 deletion src/components/Navbar.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import "@mantine/core/styles.css";
import "@/css/Navbar.css";
import { NavLink } from "react-router-dom";
import FileUpload from "@/components/FileUpload"
import FileUpload from "@/components/FileUpload";

const mainLinksData = [
{ name: "Files", url: "/" },
Expand All @@ -27,6 +27,7 @@ export default function Navbar() {
/>
{links}

{/* Once POST API is out -- Currently WIP */}
<FileUpload uploadUrl={`${import.meta.env.VITE_API_URL}/api/v2/mcaps/bulk_upload`}/>

{/* Optionally render active link or other content here */}
Expand Down
57 changes: 57 additions & 0 deletions src/components/PreviewCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,63 @@
<SchemaTable></SchemaTable>
</Grid.Col>
<Grid.Col span={3} style={{ position: "relative", padding: "10px" }}>
<div style={{ display: "flex", alignItems: "center" }}>
<Text size="md" fw={700}>
run 2024-18-10.mcap
</Text>
</div>
<div style={{ display: "flex", alignItems: "center" }}>
<Text size="xs" fw={700}>
Date:{" "}
</Text>
<span style={{ marginLeft: "5px" }} /> {/* Spacer */}
<Text size="xs" fw={400}>
Fri, Oct 18, 2024
</Text>
</div>
<div style={{ display: "flex", alignItems: "center" }}>
<Text size="xs" fw={700}>
Time:{" "}
</Text>
<span style={{ marginLeft: "5px" }} /> {/* Spacer */}
<Text size="xs" fw={400}>
12:24:02 PM
</Text>
</div>
<div style={{ display: "flex", alignItems: "center" }}>
<Text size="xs" fw={700}>
Location:{" "}
</Text>
<span style={{ marginLeft: "5px" }} /> {/* Spacer */}
<Text size="xs" fw={400}>
MRDC
</Text>
</div>
<div style={{ display: "flex", alignItems: "center" }}>
<Text size="xs" fw={700}>
Sensors:{" "}
</Text>
<span style={{ marginLeft: "5px" }} /> {/* Spacer */}
<Text size="xs" fw={400}>
aero_sensor_1
</Text>
</div>
<div
style={{
display: "flex",
alignItems: "center",
position: "absolute",
bottom: 0,
left: 0,
padding: 20,
gap: "10px",
}}
>
<div className="previewFileButtons">
<DownloadButton buttonText="MAT" />

Check failure on line 127 in src/components/PreviewCard.tsx

View workflow job for this annotation

GitHub Actions / build

Type '{ buttonText: string; }' is missing the following properties from type 'DownloadButtonProps': fileName, signedUrl
<DownloadButton buttonText="MCAP" />

Check failure on line 128 in src/components/PreviewCard.tsx

View workflow job for this annotation

GitHub Actions / build

Type '{ buttonText: string; }' is missing the following properties from type 'DownloadButtonProps': fileName, signedUrl
</div>
</div>
{selectedData ? (
<>
<PreviewDataDiv name={getFileNameWithoutExtension(selectedData.mcap_files[0].file_name)} val={""} />
Expand Down
33 changes: 33 additions & 0 deletions src/css/Root.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.app-container {
height: 100vh;
width: 100%;
display: flex;
flex-direction: column;
}
Expand All @@ -12,6 +13,8 @@
}

.main-content {
height: 100vh;
width: 100%;
display: flex;
flex: 1;
overflow: hidden;
Expand All @@ -25,16 +28,46 @@
flex: 1;
overflow: hidden;
flex-direction: row;
height: 70%;
flex-shrink: 0;
}

.table-contain-result {
flex-grow: 1;
overflow-y: auto;
padding-bottom: 10px;
width: 80%;
min-width: 80%;
overflow: hidden;
word-wrap: break-word;
word-break: break-word;
}

.footer {
text-align: center;
background: #9b8b5de5;
color: white;
}

.static {
position: fixed;
}

.scrollable {
overflow-y: auto;
flex-shrink: 0;
}

.scrollable-container {
overflow-y: auto;
}

.preview-contain-result {
z-index: 1000;
}

.search-container {
width: auto;
display: flex;
justify-content: center;
}
Loading