mirror of
https://github.com/wavetermdev/backup.git
synced 2026-08-05 13:57:07 -07:00
feat: pass contents of directory to front end
This mainly focuses on passing directory info to the front end. It isn't a complete version of that, but it's enough to plan out some details of the styling
This commit is contained in:
@@ -53,6 +53,18 @@ function StreamingPreview({ fileInfo }: { fileInfo: FileInfo }) {
|
||||
return <CenteredDiv>Preview Not Supported</CenteredDiv>;
|
||||
}
|
||||
|
||||
function DirectoryPreview({ contentAtom }: { contentAtom: jotai.Atom<Promise<string>> }) {
|
||||
const contentText = jotai.useAtomValue(contentAtom);
|
||||
let content: FileInfo[] = JSON.parse(contentText);
|
||||
return (
|
||||
<div className="view-preview view-preview-directory">
|
||||
{content.map((finfo) => (
|
||||
<span>{finfo.path}</span>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function PreviewView({ blockId }: { blockId: string }) {
|
||||
const blockDataAtom: jotai.Atom<BlockData> = blockDataMap.get(blockId);
|
||||
const fileNameAtom = useBlockAtom(blockId, "preview:filename", () =>
|
||||
@@ -118,6 +130,9 @@ function PreviewView({ blockId }: { blockId: string }) {
|
||||
</div>
|
||||
);
|
||||
}
|
||||
if (mimeType === "directory") {
|
||||
return <DirectoryPreview contentAtom={fileContentAtom} />;
|
||||
}
|
||||
return (
|
||||
<div className="view-preview">
|
||||
<div>Preview ({mimeType})</div>
|
||||
|
||||
@@ -63,4 +63,8 @@
|
||||
object-fit: contain;
|
||||
}
|
||||
}
|
||||
&.view-preview-directory {
|
||||
flex-direction: column;
|
||||
align-items: start;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,6 +92,9 @@ function Widgets() {
|
||||
<div className="widget" onClick={() => clickPreview("build/appicon.png")}>
|
||||
<i className="fa fa-solid fa-files fa-fw" />
|
||||
</div>
|
||||
<div className="widget" onClick={() => clickPreview("~")}>
|
||||
<i className="fa fa-solid fa-files fa-fw" />
|
||||
</div>
|
||||
<div className="widget" onClick={() => clickPlot()}>
|
||||
<i className="fa fa-solid fa-chart-simple fa-fw" />
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user