Make changes for video processing check
This commit is contained in:
parent
4e0729e91e
commit
de8fc6a4e2
@ -21,9 +21,6 @@ export default function (props: ReportCardProps) {
|
|||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
const toast = useToast();
|
const toast = useToast();
|
||||||
const targetMap: { [k: number]: string } = {};
|
const targetMap: { [k: number]: string } = {};
|
||||||
const [attachmentsReady, setAttachmentReady] = useState(
|
|
||||||
!props.attachments_loading,
|
|
||||||
);
|
|
||||||
const actionMap: { [k: number]: number } = {};
|
const actionMap: { [k: number]: number } = {};
|
||||||
|
|
||||||
for (let i = 0; i < props.target_ids.length; i++)
|
for (let i = 0; i < props.target_ids.length; i++)
|
||||||
@ -31,18 +28,6 @@ export default function (props: ReportCardProps) {
|
|||||||
value: props.target_usernames[i],
|
value: props.target_usernames[i],
|
||||||
});
|
});
|
||||||
|
|
||||||
async function recheckAttachment() {
|
|
||||||
const attachmentCheck = await fetch("/api/uploads/status", {
|
|
||||||
body: JSON.stringify(props.attachments),
|
|
||||||
headers: {
|
|
||||||
"content-type": "application/json",
|
|
||||||
},
|
|
||||||
method: "POST",
|
|
||||||
});
|
|
||||||
|
|
||||||
setAttachmentReady(attachmentCheck.ok);
|
|
||||||
}
|
|
||||||
|
|
||||||
async function submitActions() {
|
async function submitActions() {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
const submitReq = await fetch(`/api/reports/${props.id}/action`, {
|
const submitReq = await fetch(`/api/reports/${props.id}/action`, {
|
||||||
@ -82,14 +67,11 @@ export default function (props: ReportCardProps) {
|
|||||||
<Text fontSize="xs">ID(s): {props.target_ids.toString()}</Text>
|
<Text fontSize="xs">ID(s): {props.target_ids.toString()}</Text>
|
||||||
</CardHeader>
|
</CardHeader>
|
||||||
<CardBody>
|
<CardBody>
|
||||||
{attachmentsReady ? (
|
|
||||||
<div style={{ position: "relative" }}>
|
<div style={{ position: "relative" }}>
|
||||||
<video
|
<video autoPlay={true} controls={true} width="100%">
|
||||||
autoPlay={true}
|
<source src={`/api/uploads/${props.attachments[attachmentIdx]}`} />
|
||||||
controls={true}
|
<source src="/files/processing.webm" />
|
||||||
src={`/api/uploads/${props.attachments[attachmentIdx]}`}
|
</video>
|
||||||
width="100%"
|
|
||||||
/>
|
|
||||||
<HStack
|
<HStack
|
||||||
pos="absolute"
|
pos="absolute"
|
||||||
top="50%"
|
top="50%"
|
||||||
@ -144,21 +126,10 @@ export default function (props: ReportCardProps) {
|
|||||||
</Button>
|
</Button>
|
||||||
</HStack>
|
</HStack>
|
||||||
</div>
|
</div>
|
||||||
) : (
|
|
||||||
<Text>Attachments processing...</Text>
|
|
||||||
)}
|
|
||||||
<br />
|
<br />
|
||||||
<Text my="16px">{props.description}</Text>
|
<Text my="16px">{props.description}</Text>
|
||||||
</CardBody>
|
</CardBody>
|
||||||
<CardFooter>
|
<CardFooter>
|
||||||
{props.attachments_loading ? (
|
|
||||||
<Button
|
|
||||||
colorScheme="blue"
|
|
||||||
onClick={async () => await recheckAttachment()}
|
|
||||||
>
|
|
||||||
Reload Attachment
|
|
||||||
</Button>
|
|
||||||
) : (
|
|
||||||
<Stack direction="column">
|
<Stack direction="column">
|
||||||
{(function () {
|
{(function () {
|
||||||
const radioGroups = [];
|
const radioGroups = [];
|
||||||
@ -199,7 +170,6 @@ export default function (props: ReportCardProps) {
|
|||||||
</Button>
|
</Button>
|
||||||
</Box>
|
</Box>
|
||||||
</Stack>
|
</Stack>
|
||||||
)}
|
|
||||||
</CardFooter>
|
</CardFooter>
|
||||||
</Card>
|
</Card>
|
||||||
);
|
);
|
||||||
|
@ -189,15 +189,6 @@ export async function onRequestPost(context: RequestContext) {
|
|||||||
uploadUrls.push(urlResult.value);
|
uploadUrls.push(urlResult.value);
|
||||||
|
|
||||||
let url = new URL(urlResult.value).searchParams.get("name") as string;
|
let url = new URL(urlResult.value).searchParams.get("name") as string;
|
||||||
const extension = (url.split(".").at(-1) as string).toLowerCase();
|
|
||||||
|
|
||||||
if (["mkv", "wmv"].includes(extension)) {
|
|
||||||
url = url.replace(`.${extension}`, ".mp4");
|
|
||||||
|
|
||||||
await context.env.DATA.put(`videoprocessing_${url}`, "1", {
|
|
||||||
expirationTtl: 600,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
attachments.push(url);
|
attachments.push(url);
|
||||||
}
|
}
|
||||||
|
1
index.d.ts
vendored
1
index.d.ts
vendored
@ -63,7 +63,6 @@ declare global {
|
|||||||
|
|
||||||
interface ReportCardProps {
|
interface ReportCardProps {
|
||||||
attachments: string[];
|
attachments: string[];
|
||||||
attachments_loading?: boolean;
|
|
||||||
created_at: number;
|
created_at: number;
|
||||||
description?: string;
|
description?: string;
|
||||||
id: string;
|
id: string;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user