fix: model filter by worker

This commit is contained in:
jialin
2025-04-01 10:56:50 +08:00
parent eff88528d3
commit 7e8b5f1f63
12 changed files with 72 additions and 182 deletions
@@ -127,32 +127,26 @@ export default function useDrawing(props: {
offCtx!.setTransform(scale, 0, 0, scale, translateX, translateY); offCtx!.setTransform(scale, 0, 0, scale, translateX, translateY);
}, []); }, []);
const getTransformedPoint = useCallback( const getTransformedPoint = (offsetX: number, offsetY: number) => {
(offsetX: number, offsetY: number) => { const { current: scale } = autoScale;
const { current: scale } = autoScale; console.log('lineWidth:----------', lineWidth, autoScale.current);
console.log('lineWidth:----------', lineWidth, autoScale.current);
const { x: translateX, y: translateY } = translatePos.current; const { x: translateX, y: translateY } = translatePos.current;
const transformedX = (offsetX - translateX) / scale; const transformedX = (offsetX - translateX) / scale;
const transformedY = (offsetY - translateY) / scale; const transformedY = (offsetY - translateY) / scale;
return { return {
x: transformedX, x: transformedX,
y: transformedY y: transformedY
}; };
}, };
[]
);
const getTransformLineWidth = useCallback( const getTransformLineWidth = (w = 1) => {
(w = 1) => { console.log('lineWidth:', lineWidth, autoScale.current);
console.log('lineWidth:', lineWidth, autoScale.current); const width = w || lineWidth;
const width = w || lineWidth; return width / autoScale.current;
return width / autoScale.current; };
},
[lineWidth]
);
const drawLine = useCallback( const drawLine = useCallback(
( (
+30 -30
View File
@@ -27,6 +27,7 @@ const LoadWrapper = styled.div<{ width?: number; height?: number }>`
width: ${(props) => `${props.width}px` || '100%'}; width: ${(props) => `${props.width}px` || '100%'};
z-index: 100; z-index: 100;
`; `;
const Loading = (props: { width: number; height: number }) => { const Loading = (props: { width: number; height: number }) => {
const { width, height } = props; const { width, height } = props;
return ( return (
@@ -161,37 +162,35 @@ const CanvasImageEditor: React.FC<CanvasImageEditorProps> = forwardRef(
link.click(); link.click();
}, [generateMask]); }, [generateMask]);
const drawFillRect = useCallback( const drawFillRect = (
( ctx: CanvasRenderingContext2D,
ctx: CanvasRenderingContext2D, stroke: Stroke | Point[],
stroke: Stroke | Point[], options: {
options: { lineWidth?: number;
lineWidth?: number; color: string;
color: string; isInitial?: boolean;
isInitial?: boolean; }
} ) => {
) => { const { color, isInitial } = options;
const { color, isInitial } = options;
stroke.forEach((point) => { stroke.forEach((point) => {
const { x, y } = getTransformedPoint(point.x, point.y); const { x, y } = getTransformedPoint(point.x, point.y);
const width = getTransformLineWidth(point.lineWidth); const width = getTransformLineWidth(point.lineWidth);
if (isInitial) { console.log('Drawing stroke:', point, width);
ctx.save(); if (isInitial) {
ctx.fillStyle = 'rgba(0,0,0,1)'; ctx.save();
ctx.globalCompositeOperation = 'destination-out'; ctx.fillStyle = 'rgba(0,0,0,1)';
ctx.fillRect(x - width / 2, y - width / 2, width, width); ctx.globalCompositeOperation = 'destination-out';
ctx.restore();
}
// draw the new stroke
ctx.globalCompositeOperation = 'source-over';
ctx.fillStyle = color;
ctx.fillRect(x - width / 2, y - width / 2, width, width); ctx.fillRect(x - width / 2, y - width / 2, width, width);
}); ctx.restore();
}, }
[getTransformLineWidth, getTransformedPoint]
); // draw the new stroke
ctx.globalCompositeOperation = 'source-over';
ctx.fillStyle = color;
ctx.fillRect(x - width / 2, y - width / 2, width, width);
});
};
const onReset = useCallback(() => { const onReset = useCallback(() => {
clearOverlayCanvas(); clearOverlayCanvas();
@@ -210,12 +209,13 @@ const CanvasImageEditor: React.FC<CanvasImageEditorProps> = forwardRef(
const overlayCanvas = overlayCanvasRef.current!; const overlayCanvas = overlayCanvasRef.current!;
const overlayCtx = overlayCanvas.getContext('2d')!; const overlayCtx = overlayCanvas.getContext('2d')!;
strokes.forEach((stroke: Point[]) => { strokes.forEach((stroke: Point[], index) => {
drawFillRect(overlayCtx, stroke, { drawFillRect(overlayCtx, stroke, {
color: COLOR, color: COLOR,
isInitial: isInitial isInitial: isInitial
}); });
}); });
console.log('Loading mask pixels-------:');
}; };
const redrawStrokes = (strokes: Stroke[]) => { const redrawStrokes = (strokes: Stroke[]) => {
+1 -1
View File
@@ -60,7 +60,7 @@ interface FilterBarProps {
handleClickPrimary: (item: any) => void; handleClickPrimary: (item: any) => void;
rowSelection: any; rowSelection: any;
actionItems: ActionItem[]; actionItems: ActionItem[];
selectOptions?: Global.BaseListItem<string>[]; selectOptions?: Global.BaseOption<string | number>[];
showSelect?: boolean; showSelect?: boolean;
buttonText: string; buttonText: string;
buttonIcon?: React.ReactNode; buttonIcon?: React.ReactNode;
+12 -12
View File
@@ -87,13 +87,13 @@ const WrapperBox = styled.div`
// wrapper // wrapper
const InnerWrapper = styled.div.attrs<{ const InnerWrapper = styled.div.attrs<{
noWrapperStyle?: boolean; $noWrapperStyle?: boolean;
nolabel?: boolean; $nolabel?: boolean;
}>((props) => ({ }>((props) => ({
className: classNames({ className: classNames({
__wrapper__: true, __wrapper__: true,
'no-wrapper-style': props.noWrapperStyle, 'no-wrapper-style': props.$noWrapperStyle,
'no-label': props.nolabel 'no-label': props.$nolabel
}) })
}))` }))`
position: relative; position: relative;
@@ -118,13 +118,13 @@ const InnerWrapper = styled.div.attrs<{
// label // label
export const Label = styled.div.attrs<{ export const Label = styled.div.attrs<{
isFocus?: boolean; $isFocus?: boolean;
hasPrefix?: boolean; $hasPrefix?: boolean;
}>((props) => ({ }>((props) => ({
className: classNames({ className: classNames({
'isfoucs-has-value': props.isFocus, 'isfoucs-has-value': props.$isFocus,
'blur-no-value': !props.isFocus, 'blur-no-value': !props.$isFocus,
'has-prefix': props.hasPrefix 'has-prefix': props.$hasPrefix
}) })
}))` }))`
position: absolute; position: absolute;
@@ -204,12 +204,12 @@ const Wrapper: FC<WrapperProps> = ({
return ( return (
<WrapperBox className={wrapperClass}> <WrapperBox className={wrapperClass}>
<InnerWrapper <InnerWrapper
noWrapperStyle={noWrapperStyle} $noWrapperStyle={noWrapperStyle}
nolabel={!label} $nolabel={!label}
onClick={onClick} onClick={onClick}
> >
{label && ( {label && (
<Label isFocus={isFocus} hasPrefix={hasPrefix} onClick={onClick}> <Label $isFocus={isFocus} $hasPrefix={hasPrefix} onClick={onClick}>
<LabelInfo <LabelInfo
label={label} label={label}
required={required} required={required}
+4
View File
@@ -900,3 +900,7 @@ body {
color: var(--ant-color-text-tertiary); color: var(--ant-color-text-tertiary);
font-weight: var(--font-weight-medium); font-weight: var(--font-weight-medium);
} }
.ant-progress-line {
font-size: var(--font-size-small);
}
@@ -79,6 +79,7 @@ const ParamsSettings: React.FC<ParamsSettingsProps> = forwardRef(
]) ])
); );
form.setFieldsValue(normalizedValues); form.setFieldsValue(normalizedValues);
console.log('handleValuesChange', normalizedValues, allValues);
onValuesChange?.(normalizedValues, { onValuesChange?.(normalizedValues, {
...allValues, ...allValues,
...normalizedValues ...normalizedValues
@@ -19,7 +19,7 @@ import _ from 'lodash';
import { PCA } from 'ml-pca'; import { PCA } from 'ml-pca';
import 'overlayscrollbars/overlayscrollbars.css'; import 'overlayscrollbars/overlayscrollbars.css';
import { Resizable } from 're-resizable'; import { Resizable } from 're-resizable';
import { import React, {
forwardRef, forwardRef,
useCallback, useCallback,
useEffect, useEffect,
@@ -438,9 +438,8 @@ const GroundEmbedding: React.FC<MessageProps> = forwardRef((props, ref) => {
if (changeValues.model) { if (changeValues.model) {
setScatterData([]); setScatterData([]);
setTokenResult(null); setTokenResult(null);
} else {
handleOnValuesChange(changeValues, allValues);
} }
handleOnValuesChange(changeValues, allValues);
}, },
[] []
); );
@@ -13,7 +13,7 @@ import { Button, Checkbox, Form, Input, Spin, Tag, Tooltip } from 'antd';
import classNames from 'classnames'; import classNames from 'classnames';
import _ from 'lodash'; import _ from 'lodash';
import 'overlayscrollbars/overlayscrollbars.css'; import 'overlayscrollbars/overlayscrollbars.css';
import { import React, {
forwardRef, forwardRef,
useCallback, useCallback,
useEffect, useEffect,
@@ -113,7 +113,6 @@ const GroundReranker: React.FC<MessageProps> = forwardRef((props, ref) => {
const [sortIndexMap, setSortIndexMap] = useState<number[]>([]); const [sortIndexMap, setSortIndexMap] = useState<number[]>([]);
const [queryValue, setQueryValue] = useState<string>(''); const [queryValue, setQueryValue] = useState<string>('');
const selectionTextRef = useRef<any>(null); const selectionTextRef = useRef<any>(null);
const [metaData, setMetaData] = useState<any>({});
const { initialize, updateScrollerPosition: updateDocumentScrollerPosition } = const { initialize, updateScrollerPosition: updateDocumentScrollerPosition } =
useOverlayScroller(); useOverlayScroller();
@@ -353,7 +352,6 @@ const GroundReranker: React.FC<MessageProps> = forwardRef((props, ref) => {
if (!multiplePasteEnable.current) return; if (!multiplePasteEnable.current) return;
const text = e.clipboardData.getData('text'); const text = e.clipboardData.getData('text');
if (text) { if (text) {
const currentContent = textList[index]?.text;
const dataLlist = text.split('\n').map((item: string) => { const dataLlist = text.split('\n').map((item: string) => {
return { return {
text: item?.trim(), text: item?.trim(),
@@ -432,9 +430,8 @@ const GroundReranker: React.FC<MessageProps> = forwardRef((props, ref) => {
const onValuesChange = useCallback((changedValues: any, allValues: any) => { const onValuesChange = useCallback((changedValues: any, allValues: any) => {
if (changedValues.model) { if (changedValues.model) {
setTokenResult(null); setTokenResult(null);
} else {
handleOnValuesChange(changedValues, allValues);
} }
handleOnValuesChange(changedValues, allValues);
}, []); }, []);
// useHotkeys( // useHotkeys(
@@ -1,106 +0,0 @@
import FieldComponent from '@/components/seal-form/field-component';
import { useIntl } from '@umijs/max';
import { Form } from 'antd';
import _ from 'lodash';
import {
forwardRef,
memo,
useCallback,
useEffect,
useId,
useImperativeHandle,
useMemo
} from 'react';
import { ParamsSchema } from '../config/types';
type ParamsSettingsProps = {
ref?: any;
style?: React.CSSProperties;
onValuesChange?: (changeValues: any, value: Record<string, any>) => void;
paramsConfig?: ParamsSchema[];
initialValues?: Record<string, any>;
extra?: React.ReactNode;
};
const ParamsSettings: React.FC<ParamsSettingsProps> = forwardRef(
({ onValuesChange, style, paramsConfig, initialValues, extra }, ref) => {
const intl = useIntl();
const [form] = Form.useForm();
const formId = useId();
useImperativeHandle(ref, () => ({
form
}));
useEffect(() => {
form.setFieldsValue({
...initialValues
});
}, [initialValues]);
const handleOnFinish = (values: any) => {
console.log('handleOnFinish', values);
};
const handleOnFinishFailed = (errorInfo: any) => {
console.log('handleOnFinishFailed', errorInfo);
};
const handleValuesChange = useCallback(
(changedValues: any, allValues: any) => {
onValuesChange?.(changedValues, allValues);
},
[onValuesChange]
);
const renderFields = useMemo(() => {
if (!paramsConfig) {
return null;
}
const formValues = form?.getFieldsValue();
return paramsConfig?.map((item: ParamsSchema) => {
return (
<Form.Item name={item.name} rules={item.rules} key={item.name}>
<FieldComponent
disabled={
item.disabledConfig
? item.disabledConfig?.when?.(formValues)
: item.disabled
}
description={
item.description?.isLocalized
? intl.formatMessage({ id: item.description.text })
: item.description?.text
}
onChange={null}
{..._.omit(item, [
'name',
'rules',
'disabledConfig',
'description'
])}
></FieldComponent>
</Form.Item>
);
});
}, [paramsConfig, intl]);
return (
<Form
style={{ ...style }}
name={formId}
form={form}
onValuesChange={handleValuesChange}
onFinish={handleOnFinish}
onFinishFailed={handleOnFinishFailed}
>
<div>
{renderFields}
{extra}
</div>
</Form>
);
}
);
export default memo(ParamsSettings);
+1
View File
@@ -77,6 +77,7 @@
border-radius: 4px; border-radius: 4px;
align-items: center; align-items: center;
transform: scale(0.85); transform: scale(0.85);
font-weight: var(--font-weight-500);
} }
} }
} }
@@ -529,7 +529,7 @@ const ModelFiles = () => {
handleDeleteByBatch={handleDeleteByBatch} handleDeleteByBatch={handleDeleteByBatch}
handleClickPrimary={handleClickDropdown} handleClickPrimary={handleClickDropdown}
handleSearch={handleSearch} handleSearch={handleSearch}
selectOptions={onLineSourceOptions} selectOptions={workersList}
handleInputChange={handleNameChange} handleInputChange={handleNameChange}
rowSelection={rowSelection} rowSelection={rowSelection}
actionItems={onLineSourceOptions} actionItems={onLineSourceOptions}
+2 -2
View File
@@ -308,8 +308,8 @@ const Workers: React.FC = () => {
borderRadius: 12 borderRadius: 12
}} }}
> >
<span className="font-600">{key}</span> <span>{key}</span>
<span className="text-tertiary">:{value}</span> <span>:{value}</span>
</AutoTooltip> </AutoTooltip>
); );
})} })}