Skip to content
Merged
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
1 change: 1 addition & 0 deletions App/frontend-app/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
2 changes: 1 addition & 1 deletion App/frontend-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
"ts-node": "^10.9.2",
"tslib": "^2.6.2",
"typescript": "^5.8.2",
"vite": "^6.2.0"
"vite": "^6.2.6"
},
"volta": {
"node": "18.16.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ export function SidecarCopilot({
onSourceChange={handleSourceChange}
disabled={disableSources}
selectedDocuments={selectedDocuments}
isSticky={false}
/>

<CopilotProvider>
Expand Down
219 changes: 118 additions & 101 deletions App/frontend-app/src/components/uploadButton/uploadButton.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState, useCallback } from "react";
import React, { useState, useCallback, useEffect } from "react";
import { useDropzone } from "react-dropzone";
import {
Button,
Expand All @@ -24,9 +24,22 @@ import { getFileTypeIconProps } from "@fluentui/react-file-type-icons";
const UploadDocumentsDialog = () => {
const [isOpen, setIsOpen] = useState(false);
const [uploadingFiles, setUploadingFiles] = useState<
{ name: string; progress: number; status: string; errorMsg:string }[]
{ name: string; progress: number; status: string; errorMsg: string }[]
>([]);
const [isUploading, setIsUploading] = useState(false);
const [isUploadBtnVisible, setIsUploadBtnVisible] = useState<boolean>(false);


function toBoolean(value: unknown): boolean {
return String(value).toLowerCase() === "true";
}

useEffect(() => {
if (import.meta.env.VITE_ENABLE_UPLOAD_BUTTON != undefined){
const flag = import.meta.env.VITE_ENABLE_UPLOAD_BUTTON;
setIsUploadBtnVisible(toBoolean(flag))
}
}, [import.meta.env.VITE_ENABLE_UPLOAD_BUTTON])

// Handle file drop and simulate upload
const onDrop = useCallback(async (acceptedFiles: any[]) => {
Expand All @@ -35,7 +48,7 @@ const UploadDocumentsDialog = () => {
name: file.name,
progress: 0,
status: "uploading",
errorMsg : ""
errorMsg: ""
}));
setUploadingFiles((prev) => [...prev, ...newFiles]);

Expand All @@ -57,15 +70,15 @@ const UploadDocumentsDialog = () => {
: f
)
);
} catch (error:any) {
} catch (error: any) {
const errorMessage = error.message.replace(/^Error:\s*/, ""); // Remove "Error: " prefix
const parsedError = JSON.parse(errorMessage);

// Update file status to error
setUploadingFiles((prev) =>
prev.map((f, index) =>
index === prev.length - acceptedFiles.length + i
? { ...f, progress: 100, status: "error", errorMsg: parsedError.summary}
? { ...f, progress: 100, status: "error", errorMsg: parsedError.summary }
: f
)
);
Expand All @@ -80,63 +93,63 @@ const UploadDocumentsDialog = () => {
noKeyboard: true,
});

return (
<Dialog open={isOpen} onOpenChange={(event, data) => setIsOpen(data.open)}>
<DialogTrigger>
<Button icon={<ArrowUpload24Regular />} onClick={() => setIsOpen(true)}>
Upload documents
</Button>
</DialogTrigger>

<DialogSurface>
<DialogBody>
<DialogTitle>
Upload Documents
<Button
icon={<DismissRegular />}
appearance="subtle"
onClick={() => setIsOpen(false)}
style={{ position: "absolute", right: 20, top: 20 }}
/>
</DialogTitle>

<DialogContent>
{isUploading ? (
<div style={{ textAlign: "center", padding: "40px 0" }}>
<Icon
{...getFileTypeIconProps({ extension: "pdf", size: 32, imageFileType: "svg" })}
/>
<p style={{ fontSize: "1.25rem" }}>Uploading documents...</p>
</div>
) : (
<div
{...getRootProps()}
style={{
border: "2px dashed #ccc",
borderRadius: "4px",
padding: "20px",
textAlign: "center",
marginBottom: "20px",
}}
>
<input {...getInputProps()} />
<CloudArrowUp24Regular
return (<>
{isUploadBtnVisible == true ?
<Dialog open={isOpen} onOpenChange={(event, data) => setIsOpen(data.open)}>
<DialogTrigger>
<Button icon={<ArrowUpload24Regular />} onClick={() => setIsOpen(true)}>
Upload documents
</Button>
</DialogTrigger>
<DialogSurface>
<DialogBody>
<DialogTitle>
Upload Documents
<Button
icon={<DismissRegular />}
appearance="subtle"
onClick={() => setIsOpen(false)}
style={{ position: "absolute", right: 20, top: 20 }}
/>
</DialogTitle>

<DialogContent>
{isUploading ? (
<div style={{ textAlign: "center", padding: "40px 0" }}>
<Icon
{...getFileTypeIconProps({ extension: "pdf", size: 32, imageFileType: "svg" })}
/>
<p style={{ fontSize: "1.25rem" }}>Uploading documents...</p>
</div>
) : (
<div
{...getRootProps()}
style={{
fontSize: "48px",
color: "#551A8B",
marginBottom: "10px",
border: "2px dashed #ccc",
borderRadius: "4px",
padding: "20px",
textAlign: "center",
marginBottom: "20px",
}}
/>
<p>Drag and drop files</p>
<p>or</p>
<Button appearance="secondary" onClick={open}>
Browse files
</Button>
</div>
)}
>
<input {...getInputProps()} />
<CloudArrowUp24Regular
style={{
fontSize: "48px",
color: "#551A8B",
marginBottom: "10px",
}}
/>
<p>Drag and drop files</p>
<p>or</p>
<Button appearance="secondary" onClick={open}>
Browse files
</Button>
</div>
)}

{/* Upload link section */}
{/* <div style={{ marginTop: "20px" }}>
{/* Upload link section */}
{/* <div style={{ marginTop: "20px" }}>
<h3>Upload link</h3>
<div style={{ display: "flex", alignItems: "center" }}>
<input
Expand All @@ -160,54 +173,58 @@ const UploadDocumentsDialog = () => {
</div>
</div> */}

{/* File progress display */}
{uploadingFiles.map((file, index) => (
<div
key={index}
style={{
marginTop: "20px",
border: "1px solid #ccc",
borderRadius: "4px",
padding: "10px",
}}
>
{/* File progress display */}
{uploadingFiles.map((file, index) => (
<div
key={index}
style={{
display: "flex",
alignItems: "center",
justifyContent: "space-between",
marginTop: "20px",
border: "1px solid #ccc",
borderRadius: "4px",
padding: "10px",
}}
>
<div style={{ display: "flex", alignItems: "center" }}>
<Icon {...getFileTypeIconProps({ extension: "pdf", size: 32, imageFileType: "svg" })}/>
<span>{file.name}</span>
<div
style={{
display: "flex",
alignItems: "center",
justifyContent: "space-between",
}}
>
<div style={{ display: "flex", alignItems: "center" }}>
<Icon {...getFileTypeIconProps({ extension: "pdf", size: 32, imageFileType: "svg" })} />
<span>{file.name}</span>
</div>
{file.status === "success" && (
<CheckmarkCircle24Regular style={{ color: "green" }} />
)}
{file.status === "error" && (
<DismissCircle24Regular style={{ color: "red" }} />
)}
</div>
{file.status === "success" && (
<CheckmarkCircle24Regular style={{ color: "green" }} />
)}
{file.status === "error" && (
<DismissCircle24Regular style={{ color: "red" }} />
)}
<ProgressBar value={file.progress} />
<span
style={{
color: file.status === "error" ? "red" : "inherit", // Apply red color only for error messages
}}>
{file.status === "uploading"
? "Uploading..."
: file.status === "success"
? "Upload complete"
: file.errorMsg}
</span>
<span>{ }</span>
</div>
<ProgressBar value={file.progress} />
<span
style={{
color: file.status === "error" ? "red" : "inherit", // Apply red color only for error messages
}}>
{file.status === "uploading"
? "Uploading..."
: file.status === "success"
? "Upload complete"
: file.errorMsg}
</span>
<span>{}</span>
</div>
))}
</DialogContent>
</DialogBody>
</DialogSurface>
</Dialog>
);
))}
</DialogContent>
</DialogBody>
</DialogSurface>
</Dialog> : <></>
}
</>
)


};

export default UploadDocumentsDialog;
2 changes: 1 addition & 1 deletion App/frontend-app/src/types/searchRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ export interface SearchRequest {
searchFacets: SearchFacet[];
currentPage: number;
incomingFilter: string;
filters?: string[];
filters?: { [key: string]: string };
parameters: {
scoringProfile: string;
inOrderBy: string[];
Expand Down
1 change: 1 addition & 0 deletions App/frontend-app/src/vite-env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

interface ImportMetaEnv {
VITE_API_ENDPOINT: string
VITE_ENABLE_UPLOAD_BUTTON : string
// Add other environment variables here
}

Expand Down
Loading