-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loading status checks…
Merge pull request #295 from opeolluwa/master
new patch
Showing
62 changed files
with
1,737 additions
and
812 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,4 +33,6 @@ core/views | |
mobile/node_modules | ||
|
||
core/test.db | ||
core/src/scripts | ||
core/src/scripts | ||
|
||
public/test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,13 @@ | ||
install-toolchain: | ||
|
||
|
||
install: | ||
|
||
|
||
|
||
run: | ||
|
||
|
||
build: | ||
npm install -g yarn | ||
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh | ||
#install the system depencies | ||
install-deps: | ||
yarn install | ||
cd core && cargo build | ||
# run the dev server | ||
dev: | ||
yarn tauri dev | ||
# build the binary for the current OS | ||
build: | ||
yarn tauri build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,17 @@ | ||
/** @type {import('next').NextConfig} */ | ||
|
||
const nextConfig = { | ||
reactStrictMode: true, | ||
// Note: This feature is required to use NextJS Image in SSG mode. | ||
// See https://nextjs.org/docs/messages/export-image-api for different workarounds. | ||
images: { | ||
unoptimized: true, | ||
}, | ||
} | ||
reactStrictMode: true, | ||
// Note: This feature is required to use NextJS Image in SSG mode. | ||
// See https://nextjs.org/docs/messages/export-image-api for different workarounds. | ||
images: { | ||
unoptimized: true, | ||
}, | ||
|
||
module.exports = nextConfig | ||
// webpack: (config) => { | ||
// config.resolve.alias.canvas = false; | ||
// return config; | ||
// }, | ||
}; | ||
|
||
module.exports = nextConfig; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<head> | ||
<link href="https://vjs.zencdn.net/8.10.0/video-js.css" rel="stylesheet" /> | ||
|
||
<!-- If you'd like to support IE8 (for Video.js versions prior to v7) --> | ||
<!-- <script src="https://vjs.zencdn.net/ie8/1.1.2/videojs-ie8.min.js"></script> --> | ||
</head> | ||
|
||
<body> | ||
<video id="my-video" class="video-js" controls preload="auto" width="640" height="264" poster="MY_VIDEO_POSTER.jpg" | ||
data-setup="{}"> | ||
<source src="MY_VIDEO.mp4" type="video/mp4" /> | ||
<source src="MY_VIDEO.webm" type="video/webm" /> | ||
<p class="vjs-no-js"> | ||
To view this video please enable JavaScript, and consider upgrading to a | ||
web browser that | ||
<a href="https://videojs.com/html5-video-support/" target="_blank">supports HTML5 video</a> | ||
</p> | ||
</video> | ||
|
||
<script src="https://vjs.zencdn.net/8.10.0/video.min.js"></script> | ||
</body> |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
declare module "react-file-viewer"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!bin/bash | ||
|
||
|
||
cp -r renderer ./out/media_renderer |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
function Loader() { | ||
return ( | ||
<> | ||
<span className="loader block my-10"></span> | ||
<style jsx>{` | ||
.loader, | ||
.loader:before { | ||
display: inline-block; | ||
border: 20px double transparent; | ||
border-top-color: #7EA8F9; | ||
border-radius: 50%; | ||
box-sizing: border-box; | ||
} | ||
.loader { | ||
padding: 8px; | ||
animation: wifiLoading 1s ease-in infinite; | ||
} | ||
.loader:before { | ||
content: ""; | ||
width: 0; | ||
height: 0; | ||
} | ||
@keyframes wifiLoading { | ||
0% { | ||
border-style: none; | ||
} | ||
100% { | ||
border-style: double; | ||
} | ||
} | ||
`}</style> | ||
</> | ||
); | ||
} | ||
|
||
export default Loader; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// provide file and folder icon | ||
import { StaticImageData } from "next/image"; | ||
import { getFileIcon } from "./media-icon-maker"; | ||
import folderIcon from "@/assets/common/folder-icon.png"; | ||
import Image from "next/image"; | ||
|
||
export interface ThumbnailIconInterface { | ||
isFolder: boolean; | ||
fileFormat: string; | ||
} | ||
|
||
export default function ThumbnailIcon({ | ||
isFolder, | ||
fileFormat, | ||
}: ThumbnailIconInterface) { | ||
let thumbnail: StaticImageData; | ||
if (isFolder) { | ||
thumbnail = folderIcon; | ||
} else { | ||
thumbnail = getFileIcon(fileFormat).icon; | ||
} | ||
|
||
return ( | ||
<Image | ||
src={thumbnail} | ||
height={144} | ||
width={144} | ||
alt="file card icon" | ||
className="w-[32px] mr-4" | ||
/> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,324 +1,79 @@ | ||
import { FileTransferStatus } from "@/store/context"; | ||
import { computeFileSize, isClient } from "@/utils"; | ||
import imageIcon from "@/assets/common/image.png"; | ||
import audioIcon from "@/assets/common/audio.png"; | ||
import presentationIcon from "@/assets/common/presentation.png"; | ||
import pdfIcon from "@/assets/common/pdf.png"; | ||
import videoIcon from "@/assets/common/video.png"; | ||
import csvIcon from "@/assets/common/csv.png"; | ||
import defaultIcon from "@/assets/common/default.png"; | ||
import archiveIcon from "@/assets/common/archived.png"; | ||
import documentIcon from "@/assets/common/document.png"; | ||
import textIcon from "@/assets/common/text.png"; | ||
import svgIcon from "@/assets/common/svg.png"; | ||
import Image, { StaticImageData } from "next/image"; | ||
import folderIcon from "@/assets/common/folder-icon.png"; | ||
import { File } from "../../../core/bindings/File"; | ||
|
||
// to interface with audio files coming from the application core | ||
// the type extends the AppData type | ||
export interface FileInterface extends File { | ||
} | ||
|
||
// the required data to render the file card component | ||
export interface FileCardInterface extends FileInterface { | ||
action?: () => void; // the action to perform when the file is clicked, for example it can be used to play an audio file | ||
} | ||
|
||
// the required data to render the file card component | ||
// the data will be passed dynamically | ||
"use client"; | ||
|
||
type TFileType = { | ||
fileType: string; | ||
fileName: string; | ||
fileSize: number; | ||
status: FileTransferStatus; | ||
// status: 'error' | 'done' | 'pending' | 'completed' | 'downloading' | 'paused'; | ||
}; | ||
export interface FileTransferInterface { | ||
fileType: string; | ||
fileName: string; | ||
fileSize: number; | ||
status: FileTransferStatus; | ||
} | ||
import { computeFileSize } from "@/utils"; | ||
import { useRouter } from "next/router"; | ||
import { useState } from "react"; | ||
import { File } from "../../../core/bindings/File"; | ||
import PreviewMedia from "./preview-media"; | ||
import { getFileIcon } from "./media-icon-maker"; | ||
import ThumbnailIcon from "./icon-renderer"; | ||
import { Modal } from "antd"; | ||
|
||
interface Props extends FileCardInterface { | ||
} | ||
export default function FileCard({ | ||
fileName, | ||
fileFormat, | ||
filePath, | ||
fileSize, | ||
isFolder, | ||
isHidden, | ||
}: File) { | ||
const [openModal, setOpenModal] = useState(false); | ||
const fileMeta = getFileIcon(fileFormat); | ||
const router = useRouter(); | ||
|
||
export default function FileCard( | ||
{ fileName, fileFormat, filePath, fileSize, action, isFolder, isHidden }: Props, | ||
) { | ||
let thumbnail: StaticImageData ; | ||
// if it is a folder open in folder renderer | ||
// otherwise open in file renderer | ||
let path:string; | ||
if (isFolder) { | ||
thumbnail = folderIcon; | ||
path = `/render?filePath=${filePath}&fileType=${fileFormat}&isFolder=${isFolder}`; | ||
} else { | ||
thumbnail = getFileIcon(fileFormat); | ||
path = `/render?filePath=${filePath}&fileType=${fileFormat}&isFolder=${isFolder}`; | ||
} | ||
|
||
return ( | ||
<div | ||
onClick={action} | ||
className="flex w-full hover:shadow hover:rounded-lg rouned bg-[#f9fbfe] flex-wrap items-center gap-2 cursor-pointer px-4 py-2 last:mb-10 " | ||
> | ||
<div> | ||
{ | ||
<Image | ||
src={thumbnail} // Route of the image file | ||
height={144} // Desired size with correct aspect ratio | ||
width={144} // Desired size with correct aspect ratio | ||
alt="file card icon" | ||
className="w-[32px] mr-4" // automatic height calculation | ||
/> | ||
} | ||
</div> | ||
<div className="flex flex-col justify-between mt-3"> | ||
<h6 className=" dark:text-gray-500 small overflow-clip w-[240px] lg:w-[400px] truncate"> | ||
{fileName} | ||
</h6> | ||
|
||
<div | ||
className="flex gap-3 mt[1.5px] text-gray-600 text-xs height={30} // Desired size with correct aspect ratio | ||
<> | ||
<Modal | ||
title={"Preview Media"} | ||
open={openModal} | ||
onOk={() => setOpenModal(false)} | ||
onCancel={() => setOpenModal(false)} | ||
centered | ||
okButtonProps={{ hidden: true }} | ||
cancelButtonProps={{ hidden: true }} | ||
width={600} | ||
> | ||
<> | ||
<div className="h-[600px] "> | ||
<PreviewMedia fileType={fileFormat} filePath={filePath}/> | ||
</div> | ||
</> | ||
</Modal> | ||
<div | ||
onClick={() => { | ||
isFolder ? router.push(path) : setOpenModal(true); | ||
}} | ||
className="flex w-full hover:shadow hover:rounded-lg rouned bg-[#f9fbfe] flex-wrap items-center gap-2 cursor-pointer px-4 py-2 last:mb-10 " | ||
> | ||
<ThumbnailIcon isFolder={isFolder} fileFormat={fileFormat} /> | ||
<div className="flex flex-col justify-between mt-3"> | ||
<h6 className=" dark:text-gray-500 small overflow-clip w-[240px] lg:w-[400px] truncate select-none"> | ||
{fileName} | ||
</h6> | ||
|
||
<div | ||
className="flex gap-3 mt[1.5px] text-gray-600 text-xs height={30} // Desired size with correct aspect ratio | ||
width={30} " | ||
> | ||
<span>{computeFileSize(fileSize as unknown as number)}</span>{" "} | ||
<span>{/**file duration goes here */}</span> | ||
> | ||
<span className="select-none"> | ||
{computeFileSize(fileSize as unknown as number)} | ||
</span> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</> | ||
); | ||
} | ||
|
||
export function getFileIcon(fileExtension: string) { | ||
const imageExtensions = [ | ||
"jpg", | ||
"jpeg", | ||
"png", | ||
"gif", | ||
"bmp", | ||
"tiff", | ||
"raw", | ||
"svg", | ||
"ai", | ||
"eps", | ||
"psd", | ||
"xcf", | ||
"ico", | ||
"webp", | ||
"jxr", | ||
"hdr", | ||
"tif", | ||
"exif", | ||
"pgm", | ||
"ppm", | ||
"pbm", | ||
"pnm", | ||
"heic", | ||
"heif", | ||
"dng", | ||
"cr2", | ||
"nef", | ||
"arw", | ||
"orf", | ||
"rw2", | ||
"sr2", | ||
"raf", | ||
"mrw", | ||
"pef", | ||
"x3f", | ||
"3fr", | ||
"kdc", | ||
"srw", | ||
"nrw", | ||
"rwz", | ||
"rwl", | ||
"iiq", | ||
"rw1", | ||
"r3d", | ||
"fff", | ||
"yuv", | ||
"cin", | ||
"dpx", | ||
"jp2", | ||
"j2k", | ||
"jpf", | ||
"jpx", | ||
"jpm", | ||
"mj2", | ||
"wdp", | ||
"hdp", | ||
"dds", | ||
"pvr", | ||
"tga", | ||
"cur", | ||
"icl", | ||
"thm", | ||
"sai", | ||
"ora", | ||
"pdn", | ||
"kra", | ||
"cpt", | ||
"pdd", | ||
"mng", | ||
"apng", | ||
"svgz", | ||
"emf", | ||
"wmf", | ||
]; | ||
const documentExtensions = [ | ||
"doc", | ||
"docx", | ||
"rtf", | ||
"odt", | ||
"ods", | ||
"odp", | ||
"odg", | ||
"odp", | ||
"fodp", | ||
"otp", | ||
"doc", | ||
"dot", | ||
"docx", | ||
"docm", | ||
"dotx", | ||
"dotm", | ||
"docb", | ||
"odt", | ||
"fodt", | ||
]; | ||
const svgExtensions = ["svg"]; | ||
const textExtensions = ["txt"]; | ||
const audioExtensions = [ | ||
"3gp", | ||
"aa", | ||
"aac", | ||
"aax", | ||
"act", | ||
"aiff", | ||
"alac", | ||
"amr", | ||
"ape", | ||
"au", | ||
"awb", | ||
"dss", | ||
"dvf", | ||
"flac", | ||
"gsm", | ||
"iklax", | ||
"ivs", | ||
"m4a", | ||
"m4b", | ||
"m4p", | ||
"mmf", | ||
"movpkg", | ||
"mp3", | ||
"mpc", | ||
"msv", | ||
"nmf", | ||
"ogg", | ||
"oga", | ||
"mogg", | ||
"opus", | ||
"ra", | ||
"rm", | ||
"raw", | ||
"rf64", | ||
"sln", | ||
"tta", | ||
"voc", | ||
"vox", | ||
"wav", | ||
"wma", | ||
"wv", | ||
"webm", | ||
"8svx", | ||
"cda", | ||
]; | ||
const pdfExtensions = ["pdf"]; | ||
const csvExtensions = ["csv"]; | ||
const presentationExtensions = [ | ||
"ppt", | ||
"pot", | ||
"pps", | ||
"pptx", | ||
"pptm", | ||
"potx", | ||
"potm", | ||
"ppam", | ||
"ppsx", | ||
"ppsm", | ||
"sldx", | ||
"sldm", | ||
"thmx", | ||
]; | ||
const videoExtensions = [ | ||
"mp4", | ||
"mkv", | ||
"webm", | ||
"flv", | ||
"vob", | ||
"ogv", | ||
"ogg", | ||
"drc", | ||
"gif", | ||
"gifv", | ||
"mng", | ||
"avi", | ||
"MTS", | ||
"MT2S", | ||
"TS", | ||
"mov", | ||
"qt", | ||
"wmv", | ||
"yuv", | ||
"rm", | ||
"rmvb", | ||
"viv", | ||
"asf", | ||
"amv", | ||
"m4p", | ||
"m4v", | ||
"mpg", | ||
"mp2", | ||
"mpeg", | ||
"mpe", | ||
"mpv", | ||
"m2v", | ||
"svi", | ||
"3gp", | ||
"3g2", | ||
"mxf", | ||
"roq", | ||
"nsv", | ||
"f4v", | ||
"f4p", | ||
"f4a", | ||
"f4b", | ||
]; | ||
const archiveExtensions = ["zip", "rar", "tar", "gz"]; | ||
const extension = fileExtension.toLocaleLowerCase().trim(); | ||
|
||
if (imageExtensions.includes(extension)) { | ||
return imageIcon; | ||
} else if (audioExtensions.includes(extension)) { | ||
return audioIcon; | ||
} else if (pdfExtensions.includes(extension)) { | ||
return pdfIcon; | ||
} else if (csvExtensions.includes(extension)) { | ||
return csvIcon; | ||
} else if ( | ||
presentationExtensions.includes(extension) | ||
) { | ||
return presentationIcon; | ||
} else if (videoExtensions.includes(extension)) { | ||
return videoIcon; | ||
} else if (archiveExtensions.includes(extension)) { | ||
return archiveIcon; | ||
} else if (documentExtensions.includes(extension)) { | ||
return documentIcon; | ||
} else if (textExtensions.includes(extension)) { | ||
return textIcon; | ||
} else if (svgExtensions.includes(extension)) { | ||
return svgIcon; | ||
} else { | ||
return defaultIcon; | ||
} | ||
} | ||
|
||
export interface FileInterface extends File {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,247 @@ | ||
// render the folder icon | ||
import { FileType } from "./preview-media"; | ||
import archiveIcon from "@/assets/common/archived.png"; | ||
import audioIcon from "@/assets/common/audio.png"; | ||
import csvIcon from "@/assets/common/csv.png"; | ||
import defaultIcon from "@/assets/common/default.png"; | ||
import documentIcon from "@/assets/common/document.png"; | ||
import imageIcon from "@/assets/common/image.png"; | ||
import pdfIcon from "@/assets/common/pdf.png"; | ||
import presentationIcon from "@/assets/common/presentation.png"; | ||
import svgIcon from "@/assets/common/svg.png"; | ||
import textIcon from "@/assets/common/text.png"; | ||
import videoIcon from "@/assets/common/video.png"; | ||
|
||
export function getFileIcon(fileExtension: string) { | ||
const imageExtensions = [ | ||
"jpg", | ||
"jpeg", | ||
"png", | ||
"gif", | ||
"bmp", | ||
"tiff", | ||
"raw", | ||
"svg", | ||
"ai", | ||
"eps", | ||
"psd", | ||
"xcf", | ||
"ico", | ||
"webp", | ||
"jxr", | ||
"hdr", | ||
"tif", | ||
"exif", | ||
"pgm", | ||
"ppm", | ||
"pbm", | ||
"pnm", | ||
"heic", | ||
"heif", | ||
"dng", | ||
"cr2", | ||
"nef", | ||
"arw", | ||
"orf", | ||
"rw2", | ||
"sr2", | ||
"raf", | ||
"mrw", | ||
"pef", | ||
"x3f", | ||
"3fr", | ||
"kdc", | ||
"srw", | ||
"nrw", | ||
"rwz", | ||
"rwl", | ||
"iiq", | ||
"rw1", | ||
"r3d", | ||
"fff", | ||
"yuv", | ||
"cin", | ||
"dpx", | ||
"jp2", | ||
"j2k", | ||
"jpf", | ||
"jpx", | ||
"jpm", | ||
"mj2", | ||
"wdp", | ||
"hdp", | ||
"dds", | ||
"pvr", | ||
"tga", | ||
"cur", | ||
"icl", | ||
"thm", | ||
"sai", | ||
"ora", | ||
"pdn", | ||
"kra", | ||
"cpt", | ||
"pdd", | ||
"mng", | ||
"apng", | ||
"svgz", | ||
"emf", | ||
"wmf", | ||
]; | ||
const documentExtensions = [ | ||
"doc", | ||
"docx", | ||
"rtf", | ||
"odt", | ||
"ods", | ||
"odp", | ||
"odg", | ||
"odp", | ||
"fodp", | ||
"otp", | ||
"doc", | ||
"dot", | ||
"docx", | ||
"docm", | ||
"dotx", | ||
"dotm", | ||
"docb", | ||
"odt", | ||
"fodt", | ||
]; | ||
const svgExtensions = ["svg"]; | ||
const textExtensions = ["txt"]; | ||
const audioExtensions = [ | ||
"3gp", | ||
"aa", | ||
"aac", | ||
"aax", | ||
"act", | ||
"aiff", | ||
"alac", | ||
"amr", | ||
"ape", | ||
"au", | ||
"awb", | ||
"dss", | ||
"dvf", | ||
"flac", | ||
"gsm", | ||
"iklax", | ||
"ivs", | ||
"m4a", | ||
"m4b", | ||
"m4p", | ||
"mmf", | ||
"movpkg", | ||
"mp3", | ||
"mpc", | ||
"msv", | ||
"nmf", | ||
"ogg", | ||
"oga", | ||
"mogg", | ||
"opus", | ||
"ra", | ||
"rm", | ||
"raw", | ||
"rf64", | ||
"sln", | ||
"tta", | ||
"voc", | ||
"vox", | ||
"wav", | ||
"wma", | ||
"wv", | ||
"webm", | ||
"8svx", | ||
"cda", | ||
]; | ||
const pdfExtensions = ["pdf"]; | ||
const csvExtensions = ["csv"]; | ||
const presentationExtensions = [ | ||
"ppt", | ||
"pot", | ||
"pps", | ||
"pptx", | ||
"pptm", | ||
"potx", | ||
"potm", | ||
"ppam", | ||
"ppsx", | ||
"ppsm", | ||
"sldx", | ||
"sldm", | ||
"thmx", | ||
]; | ||
const videoExtensions = [ | ||
"mp4", | ||
"mkv", | ||
"webm", | ||
"flv", | ||
"vob", | ||
"ogv", | ||
"ogg", | ||
"drc", | ||
"gif", | ||
"gifv", | ||
"mng", | ||
"avi", | ||
"MTS", | ||
"MT2S", | ||
"TS", | ||
"mov", | ||
"qt", | ||
"wmv", | ||
"yuv", | ||
"rm", | ||
"rmvb", | ||
"viv", | ||
"asf", | ||
"amv", | ||
"m4p", | ||
"m4v", | ||
"mpg", | ||
"mp2", | ||
"mpeg", | ||
"mpe", | ||
"mpv", | ||
"m2v", | ||
"svi", | ||
"3gp", | ||
"3g2", | ||
"mxf", | ||
"roq", | ||
"nsv", | ||
"f4v", | ||
"f4p", | ||
"f4a", | ||
"f4b", | ||
]; | ||
const archiveExtensions = ["zip", "rar", "tar", "gz"]; | ||
const extension = fileExtension.toLocaleLowerCase().trim(); | ||
|
||
if (imageExtensions.includes(extension)) { | ||
return { type: FileType.Image, icon: imageIcon }; | ||
} else if (audioExtensions.includes(extension)) { | ||
return { type: FileType.Audio, icon: audioIcon }; | ||
} else if (pdfExtensions.includes(extension)) { | ||
return { type: FileType.PDF, icon: pdfIcon }; | ||
} else if (csvExtensions.includes(extension)) { | ||
return { type: FileType.CSV, icon: csvIcon }; | ||
} else if (presentationExtensions.includes(extension)) { | ||
return { type: FileType.Presentation, icon: presentationIcon }; | ||
} else if (videoExtensions.includes(extension)) { | ||
return { type: FileType.Video, icon: videoIcon }; | ||
} else if (archiveExtensions.includes(extension)) { | ||
return { type: FileType.Archive, icon: archiveIcon }; | ||
} else if (documentExtensions.includes(extension)) { | ||
return { type: FileType.Document, icon: documentIcon }; | ||
} else if (textExtensions.includes(extension)) { | ||
return { type: FileType.Text, icon: textIcon }; | ||
} else if (svgExtensions.includes(extension)) { | ||
return { type: FileType.SVG, icon: svgIcon }; | ||
} else { | ||
return { type: FileType.Default, icon: defaultIcon }; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
"use client"; | ||
|
||
import { SystemInformationContext } from "@/store/sys-info"; | ||
import { useContext } from "react"; | ||
/// give preview for differet file type | ||
import FileViewer from "react-file-viewer"; | ||
|
||
const isClient = typeof window !== "undefined"; | ||
|
||
export enum FileType { | ||
Image = "image", | ||
Audio = "audio", | ||
PDF = "pdf", | ||
CSV = "csv", | ||
Presentation = "presentation", | ||
Video = "video", | ||
Archive = "archive", | ||
Document = "document", | ||
Text = "text", | ||
SVG = "svg", | ||
Default = "default", | ||
} | ||
|
||
interface Props { | ||
fileType: string; | ||
filePath: string; | ||
} | ||
|
||
export default function PreviewMedia({ fileType, filePath }: Props) { | ||
const { serverBaseUrl } = useContext(SystemInformationContext); | ||
|
||
const fileUrl = isClient | ||
? `${serverBaseUrl}/api/file?file_path=${filePath}` | ||
: ""; | ||
|
||
return ( | ||
<div className="w-full h-full"> | ||
<FileViewer fileType={fileType} filePath={fileUrl} /> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
|
||
// to interface with audio files coming from the application core | ||
|
||
import { FileTransferStatus } from "@/store/context"; | ||
|
||
// the type extends the AppData type | ||
export interface FileInterface extends File {} | ||
|
||
// the required data to render the file card component | ||
export interface FileCardInterface extends FileInterface { | ||
action?: () => void; // the action to perform when the file is clicked, for example it can be used to play an audio file | ||
} | ||
|
||
// the required data to render the file card component | ||
// the data will be passed dynamically | ||
|
||
export type TFileType = { | ||
fileType: string; | ||
fileName: string; | ||
fileSize: number; | ||
status: FileTransferStatus; | ||
}; | ||
|
||
|
||
export interface FileTransferInterface { | ||
fileType: string; | ||
fileName: string; | ||
fileSize: number; | ||
status: FileTransferStatus; | ||
} | ||
|
||
export interface Props extends FileCardInterface {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
"use client"; | ||
|
||
import { useRouter } from "next/router"; | ||
import { useEffect, useState } from "react"; | ||
import { useSearchParams } from "next/navigation"; | ||
import FileCard from "@/components/thumbnail"; | ||
import { AppData } from "@/types"; | ||
import { invoke } from "@tauri-apps/api"; | ||
import LoaderCircle from "@/components/loaders/LoaderCircle"; | ||
import QuickAccessLayout from "@/components/layout/PageLayout"; | ||
import {File} from "../../core/bindings/File" | ||
|
||
|
||
export default function PreviewMediaPage() { | ||
const [data, setData] = useState(null); | ||
const [isLoading, setLoading] = useState(false); | ||
|
||
const router = useRouter(); | ||
const searchParams = useSearchParams(); | ||
const filePath = searchParams.get("filePath"); | ||
const isFolder = searchParams.get("isFolder"); | ||
const fileType = searchParams.get("fileType"); | ||
|
||
|
||
|
||
const openInWebView = (filePath: string|null) => { | ||
console.log({ filePath }); | ||
}; | ||
|
||
useEffect(() => { | ||
if (isFolder) { | ||
setLoading(true); | ||
invoke("read_dir", { path: filePath?.trim() }).then((res) => { | ||
setData(res as any); | ||
setLoading(false); | ||
}); | ||
} else { | ||
setLoading(false); | ||
setData(null); | ||
} | ||
}, [filePath, isFolder]); | ||
|
||
// typecast the response into AppData type | ||
const fetchedFiles = data as unknown as AppData<Array<File>>; | ||
|
||
// if it is a folder, get the files nd list them | ||
// get the data from the application core | ||
if (isLoading) { | ||
return ( | ||
<> | ||
<LoaderCircle /> | ||
<h2 className="font-xl font-bold mt-8">Loading...</h2> | ||
<p className="leading-5 text-gray-400"> | ||
Please wait while we load your documents. This might take a while. | ||
</p> | ||
</> | ||
); | ||
} | ||
|
||
// render them | ||
if (data) { | ||
return ( | ||
<QuickAccessLayout | ||
pageTitle={"Document"} | ||
includeSearchBar={true} | ||
searchBarText="search document" | ||
> | ||
<div> | ||
<div className="flex flex-wrap flex-grow gap-4 justify-start mt-12"> | ||
{fetchedFiles?.data.map((file, index) => ( | ||
<FileCard | ||
key={index} | ||
fileName={file.fileName} | ||
fileSize={file.fileSize} | ||
fileFormat={file.fileFormat} | ||
filePath={file.filePath} | ||
isHidden={file.isHidden} | ||
isFolder={file.isFolder} | ||
/> | ||
))} | ||
</div> | ||
</div> | ||
</QuickAccessLayout> | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { invoke } from "@tauri-apps/api/tauri"; | ||
import { ReactNode, createContext, useEffect, useState } from "react"; | ||
import { CommandData } from "../../core/bindings/CommandData"; | ||
|
||
type WifiStatusInterface = CommandData<boolean>; | ||
|
||
export const WifiStatusContext = createContext({} as WifiStatusInterface); | ||
|
||
export default function WifiStatus({ children }: { children: ReactNode }) { | ||
const [isConnectedToWifi, setConnectedToWifi] = useState(null); | ||
|
||
useEffect(() => { | ||
invoke("is_connected_to_wifi").then((res) => { | ||
setConnectedToWifi(res as any); | ||
}); | ||
}, []); | ||
|
||
// typecast the wifi response too | ||
const wifiStatus = isConnectedToWifi as unknown as CommandData<boolean>; | ||
|
||
return ( | ||
<WifiStatusContext.Provider | ||
value={{ | ||
data: wifiStatus?.data, | ||
message: wifiStatus?.message, | ||
status: wifiStatus?.status, | ||
}} | ||
> | ||
{children} | ||
</WifiStatusContext.Provider> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
declare module 'viewerjs' |