still working on download, but I we will Refactor and add DAL
This commit is contained in:
parent
1abeab6e46
commit
2f712dba23
3 changed files with 2240 additions and 26 deletions
2180
docs/Ai-converstion.md
Normal file
2180
docs/Ai-converstion.md
Normal file
File diff suppressed because it is too large
Load diff
BIN
docs/Ai-converstion.pdf
Normal file
BIN
docs/Ai-converstion.pdf
Normal file
Binary file not shown.
|
|
@ -12,7 +12,8 @@ import {
|
|||
Typography,
|
||||
Stack,
|
||||
TextField,
|
||||
InputAdornment
|
||||
InputAdornment,
|
||||
Tooltip
|
||||
} from "@mui/material";
|
||||
import {
|
||||
DataGrid,
|
||||
|
|
@ -30,6 +31,8 @@ import DeleteIcon from "@mui/icons-material/Delete";
|
|||
import EditIcon from "@mui/icons-material/Edit";
|
||||
import SearchIcon from '@mui/icons-material/Search';
|
||||
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 { 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[] = [
|
||||
{
|
||||
field: "name",
|
||||
|
|
@ -165,34 +179,54 @@ export default function DashboardView({ initialFiles, user }: DashboardViewProps
|
|||
{
|
||||
field: "actions",
|
||||
headerName: "Actions",
|
||||
width: 120,
|
||||
width: 180, // Increased width to accommodate new buttons
|
||||
align: 'right',
|
||||
renderCell: (params) => {
|
||||
const isOwner = params.row.ownerId === user?.id;
|
||||
if (isAdmin || isOwner) {
|
||||
const isFolder = params.row.isFolder;
|
||||
|
||||
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
|
||||
size="small"
|
||||
color="primary"
|
||||
onClick={() => router.push(`/update/${params.row.id}`)}
|
||||
title="Edit Details"
|
||||
>
|
||||
<EditIcon fontSize="small" />
|
||||
</IconButton>
|
||||
</Tooltip>
|
||||
<Tooltip title="Delete">
|
||||
<IconButton
|
||||
size="small"
|
||||
color="error"
|
||||
onClick={() => handleDelete(params.row.id, params.row.name)}
|
||||
title="Delete"
|
||||
>
|
||||
<DeleteIcon fontSize="small" />
|
||||
</IconButton>
|
||||
</Tooltip>
|
||||
</>
|
||||
)}
|
||||
</Stack>
|
||||
);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
},
|
||||
{
|
||||
field: "metadata_search",
|
||||
|
|
|
|||
Loading…
Reference in a new issue