Add ISO catalog

This commit is contained in:
2025-05-21 20:28:46 +02:00
parent 35e7f4b59c
commit 8c27010396
12 changed files with 308 additions and 19 deletions

View File

@ -0,0 +1,75 @@
import {
Avatar,
Button,
Dialog,
DialogActions,
DialogContent,
DialogTitle,
List,
ListItem,
ListItemAvatar,
ListItemButton,
ListItemText,
} from "@mui/material";
import React from "react";
import { ISOCatalogEntry, IsoFilesApi } from "../api/IsoFilesApi";
import { AsyncWidget } from "../widgets/AsyncWidget";
export function IsoCatalogDialog(p: {
open: boolean;
onClose: () => void;
}): React.ReactElement {
const [catalog, setCatalog] = React.useState<ISOCatalogEntry[] | undefined>();
const load = async () => {
setCatalog(await IsoFilesApi.Catalog());
};
return (
<Dialog open={p.open} onClose={p.onClose}>
<DialogTitle>Iso catalog</DialogTitle>
<DialogContent>
<AsyncWidget
loadKey={1}
load={load}
errMsg="Failed to load catalog"
build={() => <IsoCatalogDialogInner catalog={catalog!} />}
/>
</DialogContent>
<DialogActions>
<Button autoFocus onClick={p.onClose}>
Close
</Button>
</DialogActions>
</Dialog>
);
}
export function IsoCatalogDialogInner(p: {
catalog: ISOCatalogEntry[];
}): React.ReactElement {
return (
<List dense>
{p.catalog.map((entry) => (
<a
href={entry.url}
target="_blank"
rel="noopener"
style={{ color: "inherit", textDecoration: "none" }}
>
<ListItem key={entry.name}>
<ListItemButton>
<ListItemAvatar>
<img
src={IsoFilesApi.CatalogImageURL(entry)}
style={{ width: "2em" }}
/>
</ListItemAvatar>
<ListItemText primary={entry.name} />
</ListItemButton>
</ListItem>
</a>
))}
</List>
);
}