-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6532384
commit 2a6d001
Showing
14 changed files
with
214 additions
and
214 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,6 @@ | ||
export { default as ControlPanelContainer } from './ControlPanelContainer' | ||
export { default as FlowContainer } from './FlowContainer' | ||
export { default as GalleryContainer } from './GalleryContainer' | ||
export { default as InputContainer } from './InputContainer' | ||
export { default as NodeContainer } from './NodeContainer' | ||
export { default as NodePickerContainer } from './NodePickerContainer' | ||
export { default as QueueContainer } from './QueueContainer' | ||
export { default as WorkflowPageContainer } from './WorkflowPageContainer' |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { darkLogo, lightLogo } from '@/components/Header/style' | ||
import { ThemeMode } from 'antd-style' | ||
import React from 'react' | ||
|
||
interface LogoProps { | ||
themeMode: ThemeMode | ||
size?: number | ||
style?: React.CSSProperties | ||
} | ||
|
||
const Logo: React.FC<LogoProps> = ({ themeMode, size = 20, style }) => ( | ||
<img src={themeMode === 'light' ? lightLogo : darkLogo} alt="logo" style={{ height: size, ...style }} /> | ||
) | ||
|
||
export default React.memo(Logo) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { type QueueItem } from '@/types' | ||
import { DeleteOutlined, LoadingOutlined } from '@ant-design/icons' | ||
import type { MenuProps } from 'antd' | ||
import { Spin } from 'antd' | ||
import Label from './Label' | ||
|
||
interface QueueListProps { | ||
queue: QueueItem[] | ||
onDeleteFromQueue: (id: number) => Promise<void> | ||
} | ||
|
||
const QueueList = ({ queue, onDeleteFromQueue }: QueueListProps): MenuProps['items'] => { | ||
if (queue.length === 0) | ||
return [ | ||
{ | ||
label: 'Empty queue', | ||
key: 0, | ||
}, | ||
] | ||
return queue.map((it, i) => ({ | ||
icon: i === 0 ? <Spin size="small" indicator={<LoadingOutlined spin />} /> : <DeleteOutlined />, | ||
onClick: () => void onDeleteFromQueue(it.id), | ||
label: ( | ||
<div style={{ marginLeft: 8 }}> | ||
<h5>Queue {it.id}</h5> | ||
<Label label="model" value={it.model === undefined ? 'N/A' : it.model} /> | ||
{it.prompts.map((prompt, i) => ( | ||
<Label key={i} label="prompt" value={prompt} /> | ||
))} | ||
</div> | ||
), | ||
key: it.id, | ||
})) | ||
} | ||
|
||
export default QueueList |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
import { useAppStore } from '@/store' | ||
import { GithubOutlined, LoadingOutlined } from '@ant-design/icons' | ||
import { Button, Dropdown, Space, Spin, message } from 'antd' | ||
import React, { ReactNode, useEffect, useState } from 'react' | ||
import { shallow } from 'zustand/shallow' | ||
import Logo from './Logo' | ||
import QueueList from './QueueList' | ||
import { ThemeList, View, themeIcon } from './style' | ||
|
||
interface HeaderProps { | ||
children?: ReactNode | ||
} | ||
const Header: React.FC<HeaderProps> = ({ children }) => { | ||
const [messageApi, messageHolder] = message.useMessage() | ||
const [count, setCount] = useState(0) | ||
|
||
const { themeMode, onSetThemeMode, onSubmit, queue, onDeleteFromQueue, promptError } = useAppStore( | ||
(st) => ({ | ||
themeMode: st.themeMode, | ||
onSetThemeMode: st.onSetThemeMode, | ||
onSubmit: st.onSubmit, | ||
queue: st.queue, | ||
onDeleteFromQueue: st.onDeleteFromQueue, | ||
promptError: st.promptError, | ||
}), | ||
shallow | ||
) | ||
|
||
useEffect(() => { | ||
if (promptError !== undefined) | ||
messageApi.open({ | ||
type: 'error', | ||
content: promptError, | ||
duration: 4, | ||
}) | ||
}, [promptError, count]) | ||
|
||
const handleRun = () => { | ||
onSubmit() | ||
setCount(count + 1) | ||
} | ||
|
||
return ( | ||
<> | ||
<View> | ||
<Logo themeMode={themeMode} /> | ||
<Space> | ||
{children} | ||
<a href="https://github.com/canisminor1990/kitchen-comfyui" target="_blank" rel="noreferrer"> | ||
<Button icon={<GithubOutlined />} /> | ||
</a> | ||
<Dropdown | ||
trigger={['click']} | ||
placement="bottomRight" | ||
menu={{ | ||
items: ThemeList({ onSetThemeMode }), | ||
}} | ||
> | ||
<Button icon={themeIcon[themeMode]} /> | ||
</Dropdown> | ||
<Dropdown.Button | ||
type="primary" | ||
trigger={['hover']} | ||
placement="bottomRight" | ||
onClick={handleRun} | ||
menu={{ items: QueueList({ queue, onDeleteFromQueue }) }} | ||
icon={ | ||
queue.length > 0 ? ( | ||
<Spin size="small" indicator={<LoadingOutlined spin style={{ color: '#fff' }} />} /> | ||
) : undefined | ||
} | ||
> | ||
Run Queue | ||
</Dropdown.Button> | ||
</Space> | ||
</View> | ||
{messageHolder} | ||
</> | ||
) | ||
} | ||
|
||
export default React.memo(Header) |
Oops, something went wrong.