mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-16 14:52:31 +00:00
video mocap layout + additions
This commit is contained in:
1 parent
ba4eaa5d91
commit
3b503a9c8a
4 files changed
+226
-186
No files matched your search
@@ -9,8 +9,9 @@ import { faTrash } from "@fortawesome/free-solid-svg-icons";
|
||||
|
||||
interface TabConfig {
|
||||
label: string;
|
||||
searcherKey: string;
|
||||
searcherKey?: string;
|
||||
weightTypeFilter?: string;
|
||||
mediaTypeFilter?: string; // NOT DONE
|
||||
}
|
||||
interface SelectSearcherProps {
|
||||
label?: string;
|
||||
@@ -35,14 +36,14 @@ const SelectSearcher = memo(({ label, tabs }: SelectSearcherProps) => {
|
||||
|
||||
const searchTabs = tabs.map(tab => ({
|
||||
label: tab.label,
|
||||
content: (
|
||||
content: tab.searcherKey ? (
|
||||
<Searcher
|
||||
type="modal"
|
||||
onResultSelect={closeModal}
|
||||
searcherKey={tab.searcherKey}
|
||||
weightType={tab.weightTypeFilter}
|
||||
/>
|
||||
),
|
||||
) : null,
|
||||
padding: true,
|
||||
}));
|
||||
|
||||
|
||||
@@ -2,90 +2,122 @@ import React, { useState } from "react";
|
||||
|
||||
import { useLocalize } from "hooks";
|
||||
import { SessionSubscriptionsWrapper } from "@storyteller/components/src/session/SessionSubscriptionsWrapper";
|
||||
import { FrontendInferenceJobType, InferenceJob } from "@storyteller/components/src/jobs/InferenceJob";
|
||||
import {
|
||||
FrontendInferenceJobType,
|
||||
InferenceJob,
|
||||
} from "@storyteller/components/src/jobs/InferenceJob";
|
||||
|
||||
import { PageVideoProvision } from "./components/pageVideoProvision";
|
||||
// import { PageVideoProvision } from "./components/pageVideoProvision";
|
||||
import { PageInferenceStatuses } from "./components/pageInferenceStatuses";
|
||||
import { BasicVideo } from "components/common";
|
||||
import { BasicVideo, Container, Panel } from "components/common";
|
||||
import PageHeader from "components/layout/PageHeader";
|
||||
import Tabs from "components/common/Tabs";
|
||||
import { Redirect, useLocation } from "react-router-dom";
|
||||
import TabContentUpload from "./components/tabContentUpload";
|
||||
import TabContentLibrary from "./components/tabContentLibrary";
|
||||
|
||||
export default function VideoMotionCapture(props: {
|
||||
sessionSubscriptionsWrapper: SessionSubscriptionsWrapper,
|
||||
sessionSubscriptionsWrapper: SessionSubscriptionsWrapper;
|
||||
enqueueInferenceJob: (
|
||||
jobToken: string,
|
||||
frontendInferenceJobType: FrontendInferenceJobType
|
||||
) => void,
|
||||
inferenceJobs: Array<InferenceJob>,
|
||||
inferenceJobsByCategory: Map<FrontendInferenceJobType, Array<InferenceJob>>,
|
||||
}){
|
||||
|
||||
) => void;
|
||||
inferenceJobs: Array<InferenceJob>;
|
||||
inferenceJobsByCategory: Map<FrontendInferenceJobType, Array<InferenceJob>>;
|
||||
}) {
|
||||
const { enqueueInferenceJob } = props;
|
||||
const { t } = useLocalize("VideoMotionCapture");
|
||||
enum pageStates { VIDEO_PROVISION, SHOW_JOB_STATUS }
|
||||
const { VIDEO_PROVISION, SHOW_JOB_STATUS} = pageStates;
|
||||
enum pageStates {
|
||||
VIDEO_PROVISION,
|
||||
SHOW_JOB_STATUS,
|
||||
}
|
||||
const { VIDEO_PROVISION, SHOW_JOB_STATUS } = pageStates;
|
||||
const [pageState, setPageState] = useState<{
|
||||
index:number,
|
||||
inputMediaToken: string,
|
||||
jobToken: string,
|
||||
resultMediaToken: string
|
||||
}>({ index: VIDEO_PROVISION, inputMediaToken: "", jobToken: "", resultMediaToken: ""});
|
||||
|
||||
const handlePageState = (
|
||||
{tokenType, token }:{tokenType:string, token:string | undefined}
|
||||
) => {
|
||||
if(token && tokenType === "jobToken"){
|
||||
index: number;
|
||||
inputMediaToken: string;
|
||||
jobToken: string;
|
||||
resultMediaToken: string;
|
||||
}>({
|
||||
index: VIDEO_PROVISION,
|
||||
inputMediaToken: "",
|
||||
jobToken: "",
|
||||
resultMediaToken: "",
|
||||
});
|
||||
|
||||
const handlePageState = ({
|
||||
tokenType,
|
||||
token,
|
||||
}: {
|
||||
tokenType: string;
|
||||
token: string | undefined;
|
||||
}) => {
|
||||
if (token && tokenType === "jobToken") {
|
||||
setPageState({
|
||||
...pageState,
|
||||
index: SHOW_JOB_STATUS,
|
||||
jobToken: token
|
||||
})
|
||||
jobToken: token,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const { pathname } = useLocation();
|
||||
|
||||
if (pathname === `/video-mocap` || pathname === `/video-mocap/`) {
|
||||
return <Redirect to={`/video-mocap/upload`} />;
|
||||
}
|
||||
|
||||
const tabs = [
|
||||
{
|
||||
label: t("tabTitle.upload"),
|
||||
content: <TabContentUpload t={t} pageStateCallback={handlePageState} />,
|
||||
to: "/video-mocap/upload",
|
||||
padding: true,
|
||||
},
|
||||
{
|
||||
label: t("tabTitle.library"),
|
||||
content: <TabContentLibrary t={t} pageStateCallback={handlePageState} />,
|
||||
to: "/video-mocap/select-media",
|
||||
padding: true,
|
||||
},
|
||||
];
|
||||
|
||||
return (
|
||||
<div className="container-panel py-4">
|
||||
<div className="panel p-4">
|
||||
|
||||
{/*Header section*/}
|
||||
<div className="row g-5">
|
||||
<h1 className="fw-bold">{t("headings.title")}</h1>
|
||||
<p className="fa-light-txt opacity-75 mt-1">{t("headings.subtitle")}</p>
|
||||
</div>
|
||||
|
||||
|
||||
<div className="row g-5 mt-1">
|
||||
|
||||
<Container type="panel" className="mb-5">
|
||||
<PageHeader
|
||||
title={t("headings.title")}
|
||||
subText={t("headings.subtitle")}
|
||||
/>
|
||||
<Panel>
|
||||
<div className="row g-0">
|
||||
{/*Video Provision Tabs & Job Statuses*/}
|
||||
<div className="col-12 col-md-6">
|
||||
{ pageState.index === VIDEO_PROVISION &&
|
||||
<PageVideoProvision
|
||||
t={t}
|
||||
pageStateCallback={handlePageState}
|
||||
/>
|
||||
}
|
||||
{ pageState.index === SHOW_JOB_STATUS &&
|
||||
{pageState.index === VIDEO_PROVISION && <Tabs tabs={tabs} />}
|
||||
{pageState.index === SHOW_JOB_STATUS && (
|
||||
<PageInferenceStatuses
|
||||
{...{
|
||||
t,
|
||||
enqueueInferenceJob,
|
||||
pageStates,
|
||||
pageState,
|
||||
pageStateCallback: handlePageState
|
||||
pageStateCallback: handlePageState,
|
||||
}}
|
||||
/>
|
||||
}
|
||||
)}
|
||||
</div>
|
||||
{/*ENDS Video Chooser Tabs*/}
|
||||
|
||||
|
||||
<div className="col-12 col-md-6">
|
||||
<BasicVideo
|
||||
title="Video -> Mocap Sample"
|
||||
src="/videos/face-animator-instruction-en.mp4"
|
||||
/>
|
||||
<Panel padding={true} clear={true}>
|
||||
<BasicVideo
|
||||
title="Video -> Mocap Sample"
|
||||
src="/videos/face-animator-instruction-en.mp4"
|
||||
/>
|
||||
</Panel>
|
||||
</div>
|
||||
|
||||
</div>{/*2nd row*/}
|
||||
|
||||
</div>{/*panel*/}
|
||||
</div>
|
||||
)
|
||||
</div>
|
||||
{/*2nd row*/}
|
||||
</Panel>
|
||||
{/*panel*/}
|
||||
</Container>
|
||||
);
|
||||
}
|
||||
+23
-27
@@ -1,31 +1,27 @@
|
||||
import SelectSearcher from "components/common/SelectSearcher/SelectSearcher";
|
||||
import React from "react";
|
||||
|
||||
export default function TabContentLibrary(props: {
|
||||
t: Function,
|
||||
pageStateCallback: Function
|
||||
}){
|
||||
const { t } = props
|
||||
return(
|
||||
<div
|
||||
className="tab-pane fade py-4"
|
||||
id="vmcLibrary"
|
||||
>
|
||||
<div className="row">
|
||||
<div className="col-12">
|
||||
<div className="d-flex gap-3">
|
||||
<div className="flex-grow-1">
|
||||
<input className="form-control w-100" placeholder={t("input.filenamePlaceholder")} />
|
||||
</div>
|
||||
<button className="btn btn-primary">{t("button.select")}</button>
|
||||
</div>
|
||||
</div>
|
||||
<div className="col-12 py-4">
|
||||
<div className="d-flex justify-content-end">
|
||||
<button className="btn btn-primary" disabled>{t("button.generate")}</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
t: Function;
|
||||
pageStateCallback: Function;
|
||||
}) {
|
||||
return (
|
||||
<div>
|
||||
<SelectSearcher
|
||||
label="Select a Video Media"
|
||||
tabs={[
|
||||
{
|
||||
label: "All Videos",
|
||||
searcherKey: "allVideos",
|
||||
mediaTypeFilter: "",
|
||||
},
|
||||
{
|
||||
label: "Bookmarked",
|
||||
searcherKey: "bookmarkedVideos",
|
||||
mediaTypeFilter: "",
|
||||
},
|
||||
]}
|
||||
/>
|
||||
</div>
|
||||
|
||||
)
|
||||
}
|
||||
);
|
||||
}
|
||||
+112
-101
@@ -1,24 +1,30 @@
|
||||
import React, { useEffect, useState } from "react";
|
||||
import { v4 as uuidv4 } from "uuid";
|
||||
|
||||
import { UploadMedia } from '@storyteller/components/src/api/media_files/UploadMedia'
|
||||
import {
|
||||
EnqueueVideoMotionCapture
|
||||
} from "@storyteller/components/src/api/video_mocap";
|
||||
import { UploadMedia } from "@storyteller/components/src/api/media_files/UploadMedia";
|
||||
import { EnqueueVideoMotionCapture } from "@storyteller/components/src/api/video_mocap";
|
||||
import { useFile } from "hooks";
|
||||
|
||||
import VideoInput from "v2/view/pages/video_mocap/components/VideoInput";
|
||||
|
||||
export default function TabContentUpload(props:{
|
||||
t: Function
|
||||
pageStateCallback: (data:{tokenType:string, token:string | undefined}) => void
|
||||
}){
|
||||
const { t, pageStateCallback } = props
|
||||
const videoProps = useFile({})
|
||||
export default function TabContentUpload(props: {
|
||||
t: Function;
|
||||
pageStateCallback: (data: {
|
||||
tokenType: string;
|
||||
token: string | undefined;
|
||||
}) => void;
|
||||
}) {
|
||||
const { t, pageStateCallback } = props;
|
||||
const videoProps = useFile({});
|
||||
enum tabStates {
|
||||
NO_FILE, FILE_STAGED, FILE_UPLOADING, FILE_UPLOADED, MOCAPNET
|
||||
NO_FILE,
|
||||
FILE_STAGED,
|
||||
FILE_UPLOADING,
|
||||
FILE_UPLOADED,
|
||||
MOCAPNET,
|
||||
}
|
||||
const { NO_FILE, FILE_STAGED, FILE_UPLOADING, FILE_UPLOADED, MOCAPNET } = tabStates;
|
||||
const { NO_FILE, FILE_STAGED, FILE_UPLOADING, FILE_UPLOADED, MOCAPNET } =
|
||||
tabStates;
|
||||
const [tabState, setTabState] = useState<number>(NO_FILE);
|
||||
const [token, setToken] = useState<string>("");
|
||||
|
||||
@@ -26,105 +32,110 @@ export default function TabContentUpload(props:{
|
||||
uuid_idempotency_token: uuidv4(),
|
||||
file: videoProps.file,
|
||||
source: "file",
|
||||
type:"video",
|
||||
type: "video",
|
||||
});
|
||||
|
||||
const handleUploadVideo = ()=>{
|
||||
setTabState(FILE_UPLOADING)
|
||||
UploadMedia(makeRequest()).then((res=>{
|
||||
if(res.success && "media_file_token" in res){
|
||||
setToken(res.media_file_token)
|
||||
const handleUploadVideo = () => {
|
||||
setTabState(FILE_UPLOADING);
|
||||
UploadMedia(makeRequest()).then(res => {
|
||||
if (res.success && "media_file_token" in res) {
|
||||
setToken(res.media_file_token);
|
||||
}
|
||||
}));
|
||||
}
|
||||
useEffect(()=>{
|
||||
if (token!=="") setTabState(FILE_UPLOADED)
|
||||
}, [token, FILE_UPLOADED])
|
||||
});
|
||||
};
|
||||
useEffect(() => {
|
||||
if (token !== "") setTabState(FILE_UPLOADED);
|
||||
}, [token, FILE_UPLOADED]);
|
||||
|
||||
const handleEnqueueMocapNet = ()=>{
|
||||
const handleEnqueueMocapNet = () => {
|
||||
const request = {
|
||||
video_source: token,
|
||||
uuid_idempotency_token: uuidv4()
|
||||
}
|
||||
EnqueueVideoMotionCapture(request)
|
||||
.then(res=>{
|
||||
pageStateCallback({
|
||||
tokenType: "jobToken",
|
||||
token: res.inference_job_token
|
||||
})
|
||||
uuid_idempotency_token: uuidv4(),
|
||||
};
|
||||
EnqueueVideoMotionCapture(request).then(res => {
|
||||
pageStateCallback({
|
||||
tokenType: "jobToken",
|
||||
token: res.inference_job_token,
|
||||
});
|
||||
setTabState(MOCAPNET)
|
||||
}
|
||||
});
|
||||
setTabState(MOCAPNET);
|
||||
};
|
||||
// contains upload inout state and controls, see docs
|
||||
if (tabState === NO_FILE || tabState === FILE_STAGED){
|
||||
return(
|
||||
<div className="tab-pane fade show active py-4" id="vmcUpload">
|
||||
<div className="row">
|
||||
<div className="col-12">
|
||||
<VideoInput {...{t, ...videoProps,
|
||||
onStateChange: () => setTabState(videoProps.file ? FILE_STAGED : NO_FILE),
|
||||
}}/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="row py-3">
|
||||
<div className="col-12">
|
||||
<div className="d-flex justify-content-end gap-3">
|
||||
<button
|
||||
className="btn btn-primary"
|
||||
disabled={tabState!==FILE_STAGED}
|
||||
onClick={handleUploadVideo}
|
||||
>{t("button.upload")}</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
} else if (tabState === FILE_UPLOADING){
|
||||
return(
|
||||
<div className="tab-pane fade show active py-4" id="vmcUpload">
|
||||
<div className="row">
|
||||
<div className="col-12">
|
||||
<h2>{t("tab.message.fileUploading")}</h2>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}else if (tabState === FILE_UPLOADED){
|
||||
return(
|
||||
<div className="tab-pane fade show active py-4" id="vmcUpload">
|
||||
<div className="row">
|
||||
<div className="col-12">
|
||||
<h2>{t("tab.message.fileUploaded")}</h2>
|
||||
</div>
|
||||
<div className="col-12">
|
||||
<button
|
||||
className="btn btn-primary"
|
||||
onClick={handleEnqueueMocapNet}
|
||||
>{t("button.generate")}</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
} else if (tabState === MOCAPNET){
|
||||
return(
|
||||
<div className="tab-pane fade show active py-4" id="vmcUpload">
|
||||
<div className="row">
|
||||
<div className="col-12">
|
||||
<h2>{t("tab.message.mocapNetRequesting")}</h2>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}else {
|
||||
return(
|
||||
<div className="tab-pane fade show active py-4" id="vmcUpload">
|
||||
if (tabState === NO_FILE || tabState === FILE_STAGED) {
|
||||
return (
|
||||
<div>
|
||||
<div className="row">
|
||||
<div className="col-12">
|
||||
<h1>{t("message.UnknownError")}</h1>
|
||||
<div className="col-12">
|
||||
<VideoInput
|
||||
{...{
|
||||
t,
|
||||
...videoProps,
|
||||
onStateChange: () =>
|
||||
setTabState(videoProps.file ? FILE_STAGED : NO_FILE),
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="row py-3">
|
||||
<div className="col-12">
|
||||
<div className="d-flex justify-content-end gap-3">
|
||||
<button
|
||||
className="btn btn-primary"
|
||||
disabled={tabState !== FILE_STAGED}
|
||||
onClick={handleUploadVideo}
|
||||
>
|
||||
{t("button.upload")}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
);
|
||||
} else if (tabState === FILE_UPLOADING) {
|
||||
return (
|
||||
<div className="tab-pane fade show active py-4" id="vmcUpload">
|
||||
<div className="row">
|
||||
<div className="col-12">
|
||||
<h2>{t("tab.message.fileUploading")}</h2>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
} else if (tabState === FILE_UPLOADED) {
|
||||
return (
|
||||
<div className="tab-pane fade show active py-4" id="vmcUpload">
|
||||
<div className="row">
|
||||
<div className="col-12">
|
||||
<h2>{t("tab.message.fileUploaded")}</h2>
|
||||
</div>
|
||||
<div className="col-12">
|
||||
<button className="btn btn-primary" onClick={handleEnqueueMocapNet}>
|
||||
{t("button.generate")}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
} else if (tabState === MOCAPNET) {
|
||||
return (
|
||||
<div className="tab-pane fade show active py-4" id="vmcUpload">
|
||||
<div className="row">
|
||||
<div className="col-12">
|
||||
<h2>{t("tab.message.mocapNetRequesting")}</h2>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
} else {
|
||||
return (
|
||||
<div className="tab-pane fade show active py-4" id="vmcUpload">
|
||||
<div className="row">
|
||||
<div className="col-12">
|
||||
<h1>{t("message.UnknownError")}</h1>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user