mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-18 15:44:36 +00:00
style and layout adjustments
This commit is contained in:
1 parent
f2168252d5
commit
c101f1985b
2 files changed
+117
-129
No files matched your search
+79
-89
@@ -1,33 +1,27 @@
|
||||
import React, {
|
||||
useState,
|
||||
} from "react";
|
||||
import { NavLink } from 'react-router-dom';
|
||||
import React, { useState } from "react";
|
||||
import { NavLink } from "react-router-dom";
|
||||
import { useParams, useHistory } from "react-router-dom";
|
||||
|
||||
import {
|
||||
Button,
|
||||
Panel,
|
||||
TextArea,
|
||||
WeightsCards,
|
||||
} from "components/common";
|
||||
import VideoQuickTrim, {QuickTrimData} from 'components/common/VideoQuickTrim';
|
||||
import { Button, Panel, TextArea, WeightsCards } from "components/common";
|
||||
import VideoQuickTrim, {
|
||||
QuickTrimData,
|
||||
} from "components/common/VideoQuickTrim";
|
||||
import { SelectModalV2 } from "components/common/SelectModal";
|
||||
import EnqueueVideoStyleTransfer from "@storyteller/components/src/api/video_styleTransfer";
|
||||
|
||||
|
||||
import { Action, State } from "../../reducer";
|
||||
import { initialValues } from "./defaultValues";
|
||||
import {
|
||||
mapRequest,
|
||||
VSTType,
|
||||
} from "./helpers";
|
||||
import { mapRequest, VSTType } from "./helpers";
|
||||
|
||||
import styleModels from "./styleModel";
|
||||
import SectionAdvanceOptions from "./sectionAdvanceOptions";
|
||||
|
||||
|
||||
export default function PageVSTApp({
|
||||
debug, t, pageState, dispatchPageState, parentPath
|
||||
debug,
|
||||
t,
|
||||
pageState,
|
||||
dispatchPageState,
|
||||
parentPath,
|
||||
}: {
|
||||
debug?: boolean;
|
||||
t: Function;
|
||||
@@ -42,104 +36,103 @@ export default function PageVSTApp({
|
||||
fileToken: pageState.mediaFileToken || mediaToken,
|
||||
});
|
||||
|
||||
const handleOnChange = (val:{[key: string]: number|string|boolean|undefined}) => {
|
||||
setVstValues((curr)=>({...curr, ...val}));
|
||||
}
|
||||
|
||||
const handleOnChange = (val: {
|
||||
[key: string]: number | string | boolean | undefined;
|
||||
}) => {
|
||||
setVstValues(curr => ({ ...curr, ...val }));
|
||||
};
|
||||
|
||||
const history = useHistory();
|
||||
const handleGenerate = ()=>{
|
||||
if(debug) console.log(vstValues)
|
||||
const handleGenerate = () => {
|
||||
if (debug) console.log(vstValues);
|
||||
|
||||
const request = mapRequest(vstValues);
|
||||
if (debug) console.log(request);
|
||||
EnqueueVideoStyleTransfer(request).then(res => {
|
||||
if (res.success && res.inference_job_token) {
|
||||
dispatchPageState({
|
||||
type: 'enqueueJobSuccess',
|
||||
type: "enqueueJobSuccess",
|
||||
payload: {
|
||||
inferenceJobToken: res.inference_job_token
|
||||
}
|
||||
})
|
||||
}else{
|
||||
inferenceJobToken: res.inference_job_token,
|
||||
},
|
||||
});
|
||||
} else {
|
||||
console.log(res);
|
||||
}
|
||||
})
|
||||
dispatchPageState({type: 'enqueueJob'})
|
||||
});
|
||||
dispatchPageState({ type: "enqueueJob" });
|
||||
history.push(`${parentPath}/jobs`);
|
||||
}
|
||||
};
|
||||
|
||||
return(
|
||||
<Panel className="mb-4 p-4">
|
||||
<div className="row g-3 mb-4">
|
||||
<div className="col-12 col-md-6">
|
||||
<VideoQuickTrim
|
||||
mediaToken={vstValues.fileToken}
|
||||
onSelect={(val:QuickTrimData)=>handleOnChange({
|
||||
trimStart: val.trimStartSeconds,
|
||||
trimEnd: val.trimEndSeconds
|
||||
})}
|
||||
onResponse={(res)=>{
|
||||
dispatchPageState({
|
||||
type: 'loadFileSuccess',
|
||||
payload: {
|
||||
mediaFile: res,
|
||||
mediaFileToken: pageState.mediaFileToken || mediaToken
|
||||
}
|
||||
});
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
return (
|
||||
<Panel padding={true}>
|
||||
<div className="row g-5 mb-4">
|
||||
<div className="col-12 col-md-6">
|
||||
<VideoQuickTrim
|
||||
mediaToken={vstValues.fileToken}
|
||||
onSelect={(val: QuickTrimData) =>
|
||||
handleOnChange({
|
||||
trimStart: val.trimStartSeconds,
|
||||
trimEnd: val.trimEndSeconds,
|
||||
})
|
||||
}
|
||||
onResponse={res => {
|
||||
dispatchPageState({
|
||||
type: "loadFileSuccess",
|
||||
payload: {
|
||||
mediaFile: res,
|
||||
mediaFileToken: pageState.mediaFileToken || mediaToken,
|
||||
},
|
||||
});
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
<div className="col-12 col-md-6 d-flex flex-column gap-3">
|
||||
<TextArea
|
||||
{...{
|
||||
label: t("input.label.prompt"),
|
||||
placeholder: t("input.placeholder.prompt"),
|
||||
onChange: (e:React.ChangeEvent<HTMLTextAreaElement>)=>handleOnChange({posPrompt: e.target.value}),
|
||||
value: vstValues.posPrompt,
|
||||
required: false,
|
||||
}}
|
||||
{...{
|
||||
label: t("input.label.prompt"),
|
||||
placeholder: t("input.placeholder.prompt"),
|
||||
onChange: (e: React.ChangeEvent<HTMLTextAreaElement>) =>
|
||||
handleOnChange({ posPrompt: e.target.value }),
|
||||
value: vstValues.posPrompt,
|
||||
required: false,
|
||||
}}
|
||||
/>
|
||||
<TextArea
|
||||
{...{
|
||||
label: t("input.label.negPrompt"),
|
||||
placeholder: t("input.placeholder.negPrompt"),
|
||||
onChange: (e:React.ChangeEvent<HTMLTextAreaElement>)=>handleOnChange({negPrompt: e.target.value}),
|
||||
value: vstValues.negPrompt,
|
||||
required: false,
|
||||
}}
|
||||
{...{
|
||||
label: t("input.label.negPrompt"),
|
||||
placeholder: t("input.placeholder.negPrompt"),
|
||||
onChange: (e: React.ChangeEvent<HTMLTextAreaElement>) =>
|
||||
handleOnChange({ negPrompt: e.target.value }),
|
||||
value: vstValues.negPrompt,
|
||||
required: false,
|
||||
}}
|
||||
/>
|
||||
|
||||
|
||||
<SelectModalV2
|
||||
modalTitle="Select Styles"
|
||||
label="Select Style"
|
||||
value={vstValues.sdModelTitle}
|
||||
onClear={()=>{
|
||||
setVstValues((curr)=>({
|
||||
onClear={() => {
|
||||
setVstValues(curr => ({
|
||||
...curr,
|
||||
sdModelToken: ""
|
||||
}))
|
||||
sdModelToken: "",
|
||||
}));
|
||||
}}
|
||||
>
|
||||
{styleModels.map((data:any, key:number)=>{
|
||||
const weightProps = {data}
|
||||
{styleModels.map((data: any, key: number) => {
|
||||
const weightProps = { data };
|
||||
console.log(data);
|
||||
return(
|
||||
<WeightsCards
|
||||
type="image_generation"
|
||||
props={weightProps}
|
||||
/>
|
||||
)
|
||||
return (
|
||||
<WeightsCards type="image_generation" props={weightProps} />
|
||||
);
|
||||
})}
|
||||
|
||||
</SelectModalV2>
|
||||
|
||||
<SectionAdvanceOptions
|
||||
<SectionAdvanceOptions
|
||||
onChange={handleOnChange}
|
||||
vstValues={vstValues}
|
||||
/>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
{/* <div className="row g-3 mt-4">
|
||||
@@ -151,10 +144,7 @@ export default function PageVSTApp({
|
||||
<div className="row g-3 mt-4">
|
||||
<div className="col-12 d-flex justify-content-between">
|
||||
<NavLink to={`${parentPath}`}>
|
||||
<Button
|
||||
label={t("button.cancel")}
|
||||
variant="primary"
|
||||
/>
|
||||
<Button label={t("button.cancel")} variant="secondary" />
|
||||
</NavLink>
|
||||
{/* <Button
|
||||
label="Fake Gen"
|
||||
@@ -174,4 +164,4 @@ export default function PageVSTApp({
|
||||
</div>
|
||||
</Panel>
|
||||
);
|
||||
};
|
||||
}
|
||||
+38
-40
@@ -1,4 +1,4 @@
|
||||
import React, {useState} from 'react';
|
||||
import React, { useState } from "react";
|
||||
|
||||
import {
|
||||
faBuildingColumns,
|
||||
@@ -9,18 +9,16 @@ import {
|
||||
// faSparkles,
|
||||
faText,
|
||||
faUser,
|
||||
|
||||
}
|
||||
from "@fortawesome/pro-solid-svg-icons";
|
||||
} from "@fortawesome/pro-solid-svg-icons";
|
||||
|
||||
import {
|
||||
// Accordion,
|
||||
Button,
|
||||
Label,
|
||||
// NumberSliderV2
|
||||
} from 'components/common';
|
||||
import { VSTType } from './helpers';
|
||||
import {
|
||||
} from "components/common";
|
||||
import { VSTType } from "./helpers";
|
||||
import {
|
||||
CNPreset,
|
||||
closeupPreset,
|
||||
halfbodyPreset,
|
||||
@@ -28,36 +26,36 @@ import {
|
||||
landscapePreset,
|
||||
typogPreset,
|
||||
defaultPreset,
|
||||
} from './cnPresets';
|
||||
|
||||
} from "./cnPresets";
|
||||
|
||||
export default function SectionAdvanceOptions({
|
||||
vstValues: vstVal,
|
||||
onChange: handleOnChange
|
||||
}:{
|
||||
vstValues : VSTType,
|
||||
onChange: (val:{[key: string]: number|string|boolean|undefined})=>void
|
||||
}){
|
||||
|
||||
const [preset, pickPreset] = useState<CNPreset>('default')
|
||||
function handlePreset(newPreset: CNPreset){
|
||||
switch (newPreset){
|
||||
case 'closeup':
|
||||
onChange: handleOnChange,
|
||||
}: {
|
||||
vstValues: VSTType;
|
||||
onChange: (val: {
|
||||
[key: string]: number | string | boolean | undefined;
|
||||
}) => void;
|
||||
}) {
|
||||
const [preset, pickPreset] = useState<CNPreset>("default");
|
||||
function handlePreset(newPreset: CNPreset) {
|
||||
switch (newPreset) {
|
||||
case "closeup":
|
||||
handleOnChange(closeupPreset);
|
||||
break;
|
||||
case 'halfbody':
|
||||
case "halfbody":
|
||||
handleOnChange(halfbodyPreset);
|
||||
break;
|
||||
case 'fullbody':
|
||||
case "fullbody":
|
||||
handleOnChange(fullbodyPreset);
|
||||
break;
|
||||
case 'landscape':
|
||||
case "landscape":
|
||||
handleOnChange(landscapePreset);
|
||||
break;
|
||||
case 'typog':
|
||||
case "typog":
|
||||
handleOnChange(typogPreset);
|
||||
break;
|
||||
case 'custom':
|
||||
case "custom":
|
||||
default:
|
||||
handleOnChange(defaultPreset);
|
||||
break;
|
||||
@@ -65,8 +63,8 @@ export default function SectionAdvanceOptions({
|
||||
pickPreset(newPreset);
|
||||
}
|
||||
return (
|
||||
<>
|
||||
<Label label="Video's Camera Angle"/>
|
||||
<div>
|
||||
<Label label="Video's Camera Angle" />
|
||||
{/* <div className="d-flex flex-wrap w-100">
|
||||
<div className="my-1 me-1">
|
||||
<Button
|
||||
@@ -90,48 +88,48 @@ export default function SectionAdvanceOptions({
|
||||
<Button
|
||||
icon={faStar}
|
||||
label="Default"
|
||||
isActive={preset==='default'}
|
||||
onClick={()=>handlePreset('default')}
|
||||
isActive={preset === "default"}
|
||||
onClick={() => handlePreset("default")}
|
||||
/>
|
||||
</div>
|
||||
<div className="m-1">
|
||||
<Button
|
||||
icon={faFaceViewfinder}
|
||||
label="Face Closeups"
|
||||
isActive={preset==='closeup'}
|
||||
onClick={()=>handlePreset('closeup')}
|
||||
isActive={preset === "closeup"}
|
||||
onClick={() => handlePreset("closeup")}
|
||||
/>
|
||||
</div>
|
||||
<div className="m-1">
|
||||
<Button
|
||||
icon={faUser}
|
||||
label="Half Body Shots"
|
||||
isActive={preset==='halfbody'}
|
||||
onClick={()=>handlePreset('halfbody')}
|
||||
isActive={preset === "halfbody"}
|
||||
onClick={() => handlePreset("halfbody")}
|
||||
/>
|
||||
</div>
|
||||
<div className="m-1">
|
||||
<Button
|
||||
icon={faPerson}
|
||||
label="Full Body Shots"
|
||||
isActive={preset==='fullbody'}
|
||||
onClick={()=>handlePreset('fullbody')}
|
||||
isActive={preset === "fullbody"}
|
||||
onClick={() => handlePreset("fullbody")}
|
||||
/>
|
||||
</div>
|
||||
<div className="m-1">
|
||||
<Button
|
||||
icon={faBuildingColumns}
|
||||
label="Architecture or Landscape"
|
||||
isActive={preset==='landscape'}
|
||||
onClick={()=>handlePreset('landscape')}
|
||||
isActive={preset === "landscape"}
|
||||
onClick={() => handlePreset("landscape")}
|
||||
/>
|
||||
</div>
|
||||
<div className="m-1">
|
||||
<Button
|
||||
icon={faText}
|
||||
label="Flat Logos, or Typographies"
|
||||
isActive={preset==='typog'}
|
||||
onClick={()=>handlePreset('typog')}
|
||||
isActive={preset === "typog"}
|
||||
onClick={() => handlePreset("typog")}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
@@ -268,6 +266,6 @@ export default function SectionAdvanceOptions({
|
||||
</div>
|
||||
</Accordion.Item>
|
||||
</Accordion> */}
|
||||
</>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user