fix: Model Manager jank / bugs / refinement

This commit is contained in:
blessedcoolant 2023-07-17 17:09:41 +12:00
parent cbd5be73d2
commit 98e6a56714
5 changed files with 31 additions and 12 deletions

View File

@ -1,7 +1,7 @@
import { Tab, TabList, TabPanel, TabPanels, Tabs } from '@chakra-ui/react'; import { Tab, TabList, TabPanel, TabPanels, Tabs } from '@chakra-ui/react';
import i18n from 'i18n'; import i18n from 'i18n';
import { ReactNode, memo } from 'react'; import { ReactNode, memo } from 'react';
import AddModelsPanel from './subpanels/AddModelsPanel'; import ImportModelsPanel from './subpanels/ImportModelsPanel';
import MergeModelsPanel from './subpanels/MergeModelsPanel'; import MergeModelsPanel from './subpanels/MergeModelsPanel';
import ModelManagerPanel from './subpanels/ModelManagerPanel'; import ModelManagerPanel from './subpanels/ModelManagerPanel';
@ -22,7 +22,7 @@ const tabs: ModelManagerTabInfo[] = [
{ {
id: 'importModels', id: 'importModels',
label: i18n.t('modelManager.importModels'), label: i18n.t('modelManager.importModels'),
content: <AddModelsPanel />, content: <ImportModelsPanel />,
}, },
{ {
id: 'mergeModels', id: 'mergeModels',

View File

@ -28,7 +28,9 @@ export default function AdvancedAddCheckpoint(
const advancedAddCheckpointForm = useForm<CheckpointModelConfig>({ const advancedAddCheckpointForm = useForm<CheckpointModelConfig>({
initialValues: { initialValues: {
model_name: model_path ? model_path.split('\\').splice(-1)[0] : '', model_name: model_path
? model_path.split('\\').splice(-1)[0].split('.')[0]
: '',
base_model: 'sd-1', base_model: 'sd-1',
model_type: 'main', model_type: 'main',
path: model_path ? model_path : '', path: model_path ? model_path : '',

View File

@ -36,6 +36,7 @@ export default function FoundModelsList() {
const quickAddHandler = useCallback( const quickAddHandler = useCallback(
(e: MouseEvent<HTMLButtonElement>) => { (e: MouseEvent<HTMLButtonElement>) => {
const model_name = e.currentTarget.id.split('\\').splice(-1)[0];
importMainModel({ importMainModel({
body: { body: {
location: e.currentTarget.id, location: e.currentTarget.id,
@ -46,7 +47,7 @@ export default function FoundModelsList() {
dispatch( dispatch(
addToast( addToast(
makeToast({ makeToast({
title: 'Added Model', title: `Added Model: ${model_name}`,
status: 'success', status: 'success',
}) })
) )
@ -72,7 +73,24 @@ export default function FoundModelsList() {
if (!searchFolder) return; if (!searchFolder) return;
if (!foundModels || foundModels.length === 0) { if (!foundModels || foundModels.length === 0) {
return <Flex>No Models Found</Flex>; return (
<Flex
sx={{
w: 'full',
h: 'full',
justifyContent: 'center',
alignItems: 'center',
height: 96,
userSelect: 'none',
bg: 'base.200',
_dark: {
bg: 'base.900',
},
}}
>
<Text variant="subtext">No Models Found</Text>
</Flex>
);
} }
return ( return (
@ -81,6 +99,7 @@ export default function FoundModelsList() {
flexDirection: 'column', flexDirection: 'column',
gap: 2, gap: 2,
w: '100%', w: '100%',
minW: '50%',
}} }}
> >
<Flex p={2} gap={2}> <Flex p={2} gap={2}>
@ -114,7 +133,7 @@ export default function FoundModelsList() {
}} }}
key={model} key={model}
> >
<Flex w="100%" sx={{ flexDirection: 'column' }}> <Flex w="100%" sx={{ flexDirection: 'column', minW: '25%' }}>
<Text sx={{ fontWeight: 600 }}> <Text sx={{ fontWeight: 600 }}>
{model.split('\\').slice(-1)[0]} {model.split('\\').slice(-1)[0]}
</Text> </Text>

View File

@ -6,7 +6,7 @@ import IAIIconButton from 'common/components/IAIIconButton';
import IAIInput from 'common/components/IAIInput'; import IAIInput from 'common/components/IAIInput';
import { memo, useCallback } from 'react'; import { memo, useCallback } from 'react';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { FaSearch, FaTrash } from 'react-icons/fa'; import { FaSearch, FaSync, FaTrash } from 'react-icons/fa';
import { setSearchFolder } from '../../store/modelManagerSlice'; import { setSearchFolder } from '../../store/modelManagerSlice';
type SearchFolderForm = { type SearchFolderForm = {
@ -91,7 +91,7 @@ function SearchFolderForm() {
<IAIIconButton <IAIIconButton
aria-label={t('modelManager.scanAgain')} aria-label={t('modelManager.scanAgain')}
tooltip={t('modelManager.scanAgain')} tooltip={t('modelManager.scanAgain')}
icon={<FaSearch />} icon={!searchFolder ? <FaSearch /> : <FaSync />}
fontSize={18} fontSize={18}
size="sm" size="sm"
type="submit" type="submit"

View File

@ -1,4 +1,4 @@
import { ButtonGroup, Divider, Flex } from '@chakra-ui/react'; import { ButtonGroup, Flex } from '@chakra-ui/react';
import IAIButton from 'common/components/IAIButton'; import IAIButton from 'common/components/IAIButton';
import { useState } from 'react'; import { useState } from 'react';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
@ -7,7 +7,7 @@ import ScanModels from './AddModelsPanel/ScanModels';
type AddModelTabs = 'add' | 'scan'; type AddModelTabs = 'add' | 'scan';
export default function AddModelsPanel() { export default function ImportModelsPanel() {
const [addModelTab, setAddModelTab] = useState<AddModelTabs>('add'); const [addModelTab, setAddModelTab] = useState<AddModelTabs>('add');
const { t } = useTranslation(); const { t } = useTranslation();
@ -32,8 +32,6 @@ export default function AddModelsPanel() {
</IAIButton> </IAIButton>
</ButtonGroup> </ButtonGroup>
<Divider />
{addModelTab == 'add' && <AddModels />} {addModelTab == 'add' && <AddModels />}
{addModelTab == 'scan' && <ScanModels />} {addModelTab == 'scan' && <ScanModels />}
</Flex> </Flex>