mirror of
https://github.com/v0l/route96.git
synced 2025-06-20 15:15:39 +00:00
Implement Admin Reporting UI with backend and frontend support (#21)
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
* Initial plan for issue * Implement Admin Reporting UI with backend and frontend Co-authored-by: v0l <1172179+v0l@users.noreply.github.com> * Implement reviewed flag for reports instead of deletion and revert upload.tsx changes Co-authored-by: v0l <1172179+v0l@users.noreply.github.com> * Remove legacy files migration logic from upload UI Co-authored-by: v0l <1172179+v0l@users.noreply.github.com> * Delete ui_src/package-lock.json * Delete ui_src/yarn.lock * Restore yarn.lock file to original state Co-authored-by: v0l <1172179+v0l@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: v0l <1172179+v0l@users.noreply.github.com> Co-authored-by: Kieran <kieran@harkin.me>
This commit is contained in:
@ -8,16 +8,13 @@ import usePublisher from "../hooks/publisher";
|
||||
import { Nip96, Nip96FileList } from "../upload/nip96";
|
||||
import { AdminSelf, Route96 } from "../upload/admin";
|
||||
import { FormatBytes } from "../const";
|
||||
import Report from "../report.json";
|
||||
|
||||
export default function Upload() {
|
||||
const [type, setType] = useState<"blossom" | "nip96">("blossom");
|
||||
const [noCompress, setNoCompress] = useState(false);
|
||||
const [showLegacy, setShowLegacy] = useState(false);
|
||||
const [toUpload, setToUpload] = useState<File>();
|
||||
const [self, setSelf] = useState<AdminSelf>();
|
||||
const [error, setError] = useState<string>();
|
||||
const [bulkPrgress, setBulkProgress] = useState<number>();
|
||||
const [results, setResults] = useState<Array<object>>([]);
|
||||
const [listedFiles, setListedFiles] = useState<Nip96FileList>();
|
||||
const [adminListedFiles, setAdminListedFiles] = useState<Nip96FileList>();
|
||||
@ -28,9 +25,6 @@ export default function Upload() {
|
||||
const login = useLogin();
|
||||
const pub = usePublisher();
|
||||
|
||||
const legacyFiles = Report as Record<string, Array<string>>;
|
||||
const myLegacyFiles = login ? (legacyFiles[login.pubkey] ?? []) : [];
|
||||
|
||||
const url =
|
||||
import.meta.env.VITE_API_URL || `${location.protocol}//${location.host}`;
|
||||
async function doUpload() {
|
||||
@ -116,20 +110,6 @@ export default function Upload() {
|
||||
}
|
||||
}
|
||||
|
||||
async function migrateLegacy() {
|
||||
if (!pub) return;
|
||||
const uploader = new Blossom(url, pub);
|
||||
let ctr = 0;
|
||||
for (const f of myLegacyFiles) {
|
||||
try {
|
||||
await uploader.mirror(`https://void.cat/d/${f}`);
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
setBulkProgress(ctr++ / myLegacyFiles.length);
|
||||
}
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
listUploads(listedPage);
|
||||
}, [listedPage]);
|
||||
@ -211,27 +191,6 @@ export default function Upload() {
|
||||
</div>
|
||||
)}
|
||||
|
||||
{login && myLegacyFiles.length > 0 && (
|
||||
<div className="flex flex-col gap-4 font-bold">
|
||||
You have {myLegacyFiles.length.toLocaleString()} files which can be
|
||||
migrated from void.cat
|
||||
<div className="flex gap-2">
|
||||
<Button onClick={() => migrateLegacy()}>Migrate Files</Button>
|
||||
<Button onClick={() => setShowLegacy((s) => !s)}>
|
||||
{!showLegacy ? "Show Files" : "Hide Files"}
|
||||
</Button>
|
||||
</div>
|
||||
{bulkPrgress !== undefined && <progress value={bulkPrgress} />}
|
||||
</div>
|
||||
)}
|
||||
{showLegacy && (
|
||||
<FileList
|
||||
files={myLegacyFiles.map((f) => ({
|
||||
id: f,
|
||||
url: `https://void.cat/d/${f}`,
|
||||
}))}
|
||||
/>
|
||||
)}
|
||||
{listedFiles && (
|
||||
<FileList
|
||||
files={listedFiles.files}
|
||||
|
Reference in New Issue
Block a user