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.
|
|
@ -1,6 +1,6 @@
|
||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
//src/app/dashboard/dashboard-view.tsx
|
// src/app/dashboard/dashboard-view.tsx
|
||||||
|
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import {
|
import {
|
||||||
|
|
@ -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,33 +179,53 @@ 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 (
|
|
||||||
<Stack direction="row" spacing={0.5}>
|
return (
|
||||||
<IconButton
|
<Stack direction="row" spacing={0.5} justifyContent="flex-end">
|
||||||
size="small"
|
{!isFolder && (
|
||||||
color="primary"
|
<>
|
||||||
onClick={() => router.push(`/update/${params.row.id}`)}
|
<Tooltip title="View in Tab">
|
||||||
title="Edit Details"
|
<IconButton size="small" color="info" onClick={() => handleViewInTab(params.row.id)}>
|
||||||
>
|
<OpenInNewIcon fontSize="small" />
|
||||||
<EditIcon fontSize="small" />
|
</IconButton>
|
||||||
</IconButton>
|
</Tooltip>
|
||||||
<IconButton
|
<Tooltip title="Download to Folder">
|
||||||
size="small"
|
<IconButton size="small" color="success" onClick={() => handleDownload(params.row.id)}>
|
||||||
color="error"
|
<DownloadIcon fontSize="small" />
|
||||||
onClick={() => handleDelete(params.row.id, params.row.name)}
|
</IconButton>
|
||||||
title="Delete"
|
</Tooltip>
|
||||||
>
|
</>
|
||||||
<DeleteIcon fontSize="small" />
|
)}
|
||||||
</IconButton>
|
|
||||||
</Stack>
|
{(isAdmin || isOwner) && (
|
||||||
);
|
<>
|
||||||
}
|
<Tooltip title="Edit Details">
|
||||||
return null;
|
<IconButton
|
||||||
|
size="small"
|
||||||
|
color="primary"
|
||||||
|
onClick={() => router.push(`/update/${params.row.id}`)}
|
||||||
|
>
|
||||||
|
<EditIcon fontSize="small" />
|
||||||
|
</IconButton>
|
||||||
|
</Tooltip>
|
||||||
|
<Tooltip title="Delete">
|
||||||
|
<IconButton
|
||||||
|
size="small"
|
||||||
|
color="error"
|
||||||
|
onClick={() => handleDelete(params.row.id, params.row.name)}
|
||||||
|
>
|
||||||
|
<DeleteIcon fontSize="small" />
|
||||||
|
</IconButton>
|
||||||
|
</Tooltip>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</Stack>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue