Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions web/src/api/hooks/tasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,6 @@ export const useTasks: QueryHookType<UseTasksParamsType, PagedResponse<Task>> =
options
);

type TaskByIdParams = {
taskId: number;
};

type UsersForTaskParams = {
jobId: number;
};
Expand Down Expand Up @@ -153,15 +149,15 @@ const mapTaskFromApi = (apiTask: ApiTask): Task => {
return { ...task, user_id: user.id };
};

export const useTaskById: QueryHookType<TaskByIdParams, Task> = ({ taskId }) =>
export const useTaskById: QueryHookType<{ taskId?: number }, Task> = ({ taskId }) =>
useQuery(
['task', taskId],
async () =>
useBadgerFetch<ApiTask>({
url: `${namespace}/tasks/${taskId}`,
method: 'get'
})(),
{ select: mapTaskFromApi }
{ select: mapTaskFromApi, enabled: Boolean(taskId) }
);
export const useUsersForTask: QueryHookType<UsersForTaskParams, User[]> = ({ jobId }) =>
useQuery(['usersForTask', jobId], async () =>
Expand Down
2 changes: 1 addition & 1 deletion web/src/api/typings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ export type PageInfoObjs = {
after?: string;
data?: any;
links?: Link[];
children?: number[] | string[];
children?: (number | string)[];
segments?: number[][];
original_annotation_id?: number;
};
Expand Down
6 changes: 6 additions & 0 deletions web/src/api/typings/jobs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ export type Job = {
// TODO: check pipeline property
};

export type TJobUsers = {
owners: Job['owners'];
annotators: Job['annotators'];
validators: Job['validators'];
};

export type JobType =
| 'ExtractionWithAnnotationJob'
| 'AnnotationJob'
Expand Down
6 changes: 1 addition & 5 deletions web/src/api/typings/tasks.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { TUserShort } from 'api/typings';

export type ApiTask = {
id: number;
status: TaskStatus;
Expand Down Expand Up @@ -32,7 +30,7 @@ export type TaskModel = {
file_id: number;
pages: Array<number>;
job_id: number;
//todo: add dependecy from other models
//todo: add dependency from other models
user_id: string;
is_validation: boolean;
deadline: string;
Expand All @@ -56,5 +54,3 @@ export type TaskStats = {
export type TaskStatus = 'Pending' | 'Ready' | 'In Progress' | 'Finished';

export type ValidationPageStatus = 'Valid Page' | 'Invalid Page';

export type TTaskUsers = Record<'owners' | 'validators' | 'annotators', TUserShort[]>;
12 changes: 6 additions & 6 deletions web/src/components/task/task-modal/task-validation-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { IFormApi, IModal, Metadata, useArrayDataSource } from '@epam/uui';

import { TUserShort } from '../../../api/typings';
import styles from './task-modal.module.scss';
import { TTaskUsers } from 'api/typings/tasks';
import { TJobUsers } from 'api/typings/jobs';
import { DEFAULT_VALUES } from './constants';

export interface TaskValidationValues {
Expand All @@ -32,9 +32,8 @@ interface IProps extends IModal<TaskValidationValues> {
allValid: boolean;
invalidPages: number;
editedPageCount: number;
validSave: () => Promise<void>;
allUsers: TTaskUsers;
currentUser: string;
validSave: () => void;
allUsers: TJobUsers;
isOwner: boolean;
onRedirectAfterFinish: () => void;
}
Expand All @@ -44,15 +43,16 @@ export const FinishTaskValidationModal: FC<IProps> = (modalProps) => {
allUsers,
invalidPages,
editedPageCount,
isOwner,
allValid,
isOwner,
abort,
validSave,
onRedirectAfterFinish,
onSaveForm
} = modalProps;

const [validatorUserId, onValidatorUserIdChange] = useState(
allUsers.validators[0]?.id || allUsers.annotators[0]?.id
allUsers.validators[0] || allUsers.annotators[0]?.id
);
const [annotatorUserId, onAnnotatorUserIdChange] = useState(allUsers.annotators[0]?.id);

Expand Down
26 changes: 13 additions & 13 deletions web/src/components/task/task-sidebar-labels/task-sidebar-labels.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { useLazyLoading } from 'shared/hooks/lazy-loading';

type TaskSidebarLabelsViewProps = {
viewMode: boolean;
labels?: Category[];
categories?: Category[];
onValueChange: (value: Label[]) => void;
selectedLabels: Label[];
hasNextPage: boolean;
Expand All @@ -22,9 +22,9 @@ type TaskSidebarLabelsViewProps = {

const TaskSidebarLabelsView: FC<TaskSidebarLabelsViewProps> = ({
viewMode = false,
labels,
onValueChange,
categories,
selectedLabels,
onValueChange,
hasNextPage,
onFetchNext,
isLoading
Expand All @@ -37,7 +37,7 @@ const TaskSidebarLabelsView: FC<TaskSidebarLabelsViewProps> = ({
const { task } = useTaskAnnotatorContext();
const isDisabled = task?.status !== 'In Progress' && task?.status !== 'Ready';

if (!labels) {
if (!categories) {
return <Spinner color="sky" />;
}

Expand All @@ -46,17 +46,17 @@ const TaskSidebarLabelsView: FC<TaskSidebarLabelsViewProps> = ({
[selectedLabels]
);

const labelsArr = useMemo(() => labels.map(({ name, id }) => ({ name, id })), [labels]);
const labels = useMemo(() => categories.map(({ name, id }) => ({ name, id })), [categories]);

const dataSource = useArrayDataSource<Label, string, unknown>(
{ items: [...selectedLabels, ...labelsArr] },
[labelsArr]
{ items: [...selectedLabels, ...labels] },
[labels]
);

const renderData =
viewMode || isDisabled ? (
<FlexCell width="auto" style={{ overflow: 'hidden' }}>
{labelsArr.map(({ id, name }) => (
{labels.map(({ id, name }) => (
<Checkbox
cx={styles.checkbox}
label={name}
Expand All @@ -80,7 +80,7 @@ const TaskSidebarLabelsView: FC<TaskSidebarLabelsViewProps> = ({
maxTotalItems={100}
sorting={{ field: 'name', direction: 'asc' }}
onValueChange={(value) => {
onValueChange(labelsArr.filter((item) => value?.includes(item.id)));
onValueChange(labels.filter((item) => value?.includes(item.id)));
}}
/>
);
Expand All @@ -96,7 +96,7 @@ const TaskSidebarLabelsView: FC<TaskSidebarLabelsViewProps> = ({

type TaskSidebarLabelsProps = {
viewMode: boolean;
labels?: Category[];
categories?: Category[];
onLabelsSelected: (labels: Label[]) => void;
selectedLabels: Label[];
searchText: string;
Expand All @@ -108,7 +108,7 @@ type TaskSidebarLabelsProps = {

export const TaskSidebarLabels = ({
viewMode = false,
labels = [],
categories,
onLabelsSelected,
selectedLabels = [],
searchText,
Expand All @@ -128,10 +128,10 @@ export const TaskSidebarLabels = ({
size="24"
placeholder="Search by label name"
/>
{labels ? (
{categories ? (
<TaskSidebarLabelsView
viewMode={viewMode}
labels={labels}
categories={categories}
isLoading={isLoading}
hasNextPage={hasNextPage}
onFetchNext={onFetchNext}
Expand Down
16 changes: 8 additions & 8 deletions web/src/components/task/task-sidebar/image-tools/image-tools.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AnnotationImageToolType } from '../../../../shared';
import { AnnotationImageToolType, ToolNames } from '../../../../shared';
import React from 'react';
import { FlexRow, IconButton, Tooltip } from '@epam/loveship';

Expand All @@ -21,49 +21,49 @@ export const ImageTools = ({ onSelectTool, disabled }: ImageToolProps) => {
<Tooltip content="Pen" placement="bottom">
<IconButton
icon={penIcon}
onClick={() => onSelectTool('pen')}
onClick={() => onSelectTool(ToolNames.pen)}
isDisabled={disabled}
/>
</Tooltip>
<Tooltip content="Brush" placement="bottom">
<IconButton
icon={brushIcon}
onClick={() => onSelectTool('brush')}
onClick={() => onSelectTool(ToolNames.brush)}
isDisabled={disabled}
/>
</Tooltip>
<Tooltip content="Wand" placement="bottom">
<IconButton
icon={wandIcon}
onClick={() => onSelectTool('wand')}
onClick={() => onSelectTool(ToolNames.wand)}
isDisabled={disabled}
/>
</Tooltip>
<Tooltip content="Eraser" placement="bottom">
<IconButton
icon={eraserIcon}
onClick={() => onSelectTool('eraser')}
onClick={() => onSelectTool(ToolNames.eraser)}
isDisabled={disabled}
/>
</Tooltip>
<Tooltip content="DEXTR" placement="bottom">
<IconButton
icon={dextrIcon}
onClick={() => onSelectTool('dextr')}
onClick={() => onSelectTool(ToolNames.dextr)}
isDisabled={disabled}
/>
</Tooltip>
<Tooltip content="MaskRCNN" placement="bottom">
<IconButton
icon={maskrcnnIcon}
onClick={() => onSelectTool('rectangle')}
onClick={() => onSelectTool(ToolNames.rectangle)}
isDisabled={disabled}
/>
</Tooltip>
<Tooltip content="Select" placement="bottom">
<IconButton
icon={selectIcon}
onClick={() => onSelectTool('select')}
onClick={() => onSelectTool(ToolNames.select)}
isDisabled={disabled}
/>
</Tooltip>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,18 +98,18 @@ export const TaskSidebarLabelsLinks: FC<TaskSidebarLabelsLinksProps> = ({
return (
<FlexCell cx={styles.linksAndLabels}>
<MultiSwitch
size="30"
items={documentCategories}
value={documentCategoryType}
onValueChange={handleCategoryTypeChange}
/>

{documentCategoryType === DocumentCategoryType.Document ? (
<TaskSidebarLabels
isLoading={isFetching}
hasNextPage={Boolean(hasNextPage)}
onFetchNext={handleLoadNextPage}
viewMode={viewMode}
labels={categories}
categories={categories}
onLabelsSelected={onLabelsSelected}
selectedLabels={selectedLabels}
searchText={searchText}
Expand Down
9 changes: 6 additions & 3 deletions web/src/components/task/task-sidebar/task-sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ import {
AnnotationBoundMode,
AnnotationBoundType,
AnnotationImageToolType,
AnnotationLinksBoundType
AnnotationLinksBoundType,
ToolNames
} from 'shared';
import { Status } from 'shared/components/status';
import { mapStatusForValidationPage } from 'shared/helpers/map-statuses';
Expand Down Expand Up @@ -109,7 +110,8 @@ const TaskSidebar: FC<TaskSidebarProps> = ({ jobSettings, viewMode, isNextTaskPr
allValidated,
annotationSaved,
onFinishValidation,
notProcessedPages
notProcessedPages,
isDataTabDisabled
} = useTaskAnnotatorContext();
const {
tableModeColumns,
Expand Down Expand Up @@ -151,7 +153,7 @@ const TaskSidebar: FC<TaskSidebarProps> = ({ jobSettings, viewMode, isNextTaskPr
break;
case 'segmentation':
newSelectionType = 'polygon';
onChangeSelectedTool('pen');
onChangeSelectedTool(ToolNames.pen);

break;
default:
Expand Down Expand Up @@ -356,6 +358,7 @@ const TaskSidebar: FC<TaskSidebarProps> = ({ jobSettings, viewMode, isNextTaskPr
caption={tabName}
isLinkActive={tabValue === tabName}
onClick={() => setTabValue(tabName)}
isDisabled={tabName === 'Data' && isDataTabDisabled}
/>
))}
</FlexRow>
Expand Down
Loading