Skip to content

Commit

Permalink
completed file management system dashboard and all functions
Browse files Browse the repository at this point in the history
  • Loading branch information
RamanSharma100 committed May 29, 2021
1 parent 3fa6eea commit fc977a0
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 24 deletions.
113 changes: 89 additions & 24 deletions src/components/Dashboard/FileComponent/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import FileViewer from "react-file-viewer";
import "./FileComponent.css";
import Header from "./Header";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { faDownload } from "@fortawesome/free-solid-svg-icons";
import { faDownload, faEye } from "@fortawesome/free-solid-svg-icons";

const FileComponent = () => {
const { fileId } = useParams();
Expand Down Expand Up @@ -244,29 +244,94 @@ const FileComponent = () => {
</div>
</div>
<Col md={12} style={{ height: "83%" }}>
<FileViewer
fileType={
currentFile.data.name.split(".")[
currentFile.data.name.split(".").length - 1
]
}
filePath={currentFile.data.url}
errorComponent={
<>
<h1>This file is not viewable</h1>
<a
className="btn btn-primary"
target="_blank"
href={currentFile.data.url}
download
>
<FontAwesomeIcon icon={faDownload} />
&nbsp; Download
</a>
</>
}
style={{ height: "100%", width: "100%" }}
/>
{currentFile.data.name
.split(".")
[currentFile.data.name.split(".").length - 1].includes(
"pdf"
) ? (
<a
className="btn btn-primary mx-auto mt-5"
target="_blank"
href={currentFile.data.url}
>
<FontAwesomeIcon icon={faEye} />
&nbsp; View{" "}
{
currentFile.data.name.split(".")[
currentFile.data.name.split(".").length - 1
]
}{" "}
file
</a>
) : currentFile.data.name
.split(".")
[currentFile.data.name.split(".").length - 1].includes(
"csv"
) ||
currentFile.data.name
.split(".")
[currentFile.data.name.split(".").length - 1].includes(
"xslx"
) ||
currentFile.data.name
.split(".")
[currentFile.data.name.split(".").length - 1].includes(
"docx"
) ||
currentFile.data.name
.split(".")
[currentFile.data.name.split(".").length - 1].includes(
"mp4"
) ||
currentFile.data.name
.split(".")
[currentFile.data.name.split(".").length - 1].includes(
"webm"
) ||
currentFile.data.name
.split(".")
[currentFile.data.name.split(".").length - 1].includes(
"mp3"
) ? (
<FileViewer
fileType={
currentFile.data.name.split(".")[
currentFile.data.name.split(".").length - 1
]
}
filePath={currentFile.data.url}
errorComponent={
<>
<h1>This file is not viewable</h1>
<a
className="btn btn-primary"
target="_blank"
href={currentFile.data.url}
download
>
<FontAwesomeIcon icon={faDownload} />
&nbsp; Download
</a>
</>
}
style={{ height: "100%", width: "100%" }}
/>
) : (
<a
className="btn btn-primary mx-auto mt-5"
target="_blank"
href={currentFile.data.url}
>
<FontAwesomeIcon icon={faEye} />
&nbsp; View{" "}
{
currentFile.data.name.split(".")[
currentFile.data.name.split(".").length - 1
]
}{" "}
file
</a>
)}
</Col>
</Col>
</Row>
Expand Down
1 change: 1 addition & 0 deletions src/components/UploadFile/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ const UploadFile = ({ currentFolder }) => {
"mp3",
"mp4",
"webm",
"pdf",
];

if (allowedExtensions.indexOf(fileExtension) === -1) {
Expand Down

0 comments on commit fc977a0

Please sign in to comment.