still working on download, but I we will Refactor and add DAL

This commit is contained in:
stephen 2026-01-15 17:17:36 +11:00
parent 1abeab6e46
commit 2f712dba23
3 changed files with 2240 additions and 26 deletions

2180
docs/Ai-converstion.md Normal file

File diff suppressed because it is too large Load diff

BIN
docs/Ai-converstion.pdf Normal file

Binary file not shown.

View file

@ -12,7 +12,8 @@ import {
Typography, Typography,
Stack, Stack,
TextField, TextField,
InputAdornment InputAdornment,
Tooltip
} from "@mui/material"; } from "@mui/material";
import { import {
DataGrid, DataGrid,
@ -30,6 +31,8 @@ import DeleteIcon from "@mui/icons-material/Delete";
import EditIcon from "@mui/icons-material/Edit"; import EditIcon from "@mui/icons-material/Edit";
import SearchIcon from '@mui/icons-material/Search'; import SearchIcon from '@mui/icons-material/Search';
import CancelIcon from '@mui/icons-material/Cancel'; import CancelIcon from '@mui/icons-material/Cancel';
import DownloadIcon from '@mui/icons-material/Download';
import OpenInNewIcon from '@mui/icons-material/OpenInNew';
import { syncOneDrive } from "./sync-actions"; import { syncOneDrive } from "./sync-actions";
import { deleteFileAction } from "./actions"; import { deleteFileAction } from "./actions";
@ -125,6 +128,17 @@ export default function DashboardView({ initialFiles, user }: DashboardViewProps
} }
}; };
// --- NEW DOWNLOAD FUNCTIONS ---
const handleDownload = (id: string) => {
// Triggers local folder download via Content-Disposition: attachment
window.location.href = `/api/download?id=${id}&mode=attachment`;
};
const handleViewInTab = (id: string) => {
// Opens in a new tab via Content-Disposition: inline
window.open(`/api/download?id=${id}&mode=inline`, '_blank');
};
const columns: GridColDef[] = [ const columns: GridColDef[] = [
{ {
field: "name", field: "name",
@ -165,34 +179,54 @@ export default function DashboardView({ initialFiles, user }: DashboardViewProps
{ {
field: "actions", field: "actions",
headerName: "Actions", headerName: "Actions",
width: 120, width: 180, // Increased width to accommodate new buttons
align: 'right', align: 'right',
renderCell: (params) => { renderCell: (params) => {
const isOwner = params.row.ownerId === user?.id; const isOwner = params.row.ownerId === user?.id;
if (isAdmin || isOwner) { const isFolder = params.row.isFolder;
return ( return (
<Stack direction="row" spacing={0.5}> <Stack direction="row" spacing={0.5} justifyContent="flex-end">
{!isFolder && (
<>
<Tooltip title="View in Tab">
<IconButton size="small" color="info" onClick={() => handleViewInTab(params.row.id)}>
<OpenInNewIcon fontSize="small" />
</IconButton>
</Tooltip>
<Tooltip title="Download to Folder">
<IconButton size="small" color="success" onClick={() => handleDownload(params.row.id)}>
<DownloadIcon fontSize="small" />
</IconButton>
</Tooltip>
</>
)}
{(isAdmin || isOwner) && (
<>
<Tooltip title="Edit Details">
<IconButton <IconButton
size="small" size="small"
color="primary" color="primary"
onClick={() => router.push(`/update/${params.row.id}`)} onClick={() => router.push(`/update/${params.row.id}`)}
title="Edit Details"
> >
<EditIcon fontSize="small" /> <EditIcon fontSize="small" />
</IconButton> </IconButton>
</Tooltip>
<Tooltip title="Delete">
<IconButton <IconButton
size="small" size="small"
color="error" color="error"
onClick={() => handleDelete(params.row.id, params.row.name)} onClick={() => handleDelete(params.row.id, params.row.name)}
title="Delete"
> >
<DeleteIcon fontSize="small" /> <DeleteIcon fontSize="small" />
</IconButton> </IconButton>
</Tooltip>
</>
)}
</Stack> </Stack>
); );
} }
return null;
}
}, },
{ {
field: "metadata_search", field: "metadata_search",