Skip to content

Commit

Permalink
Merge branch development into aa/creating-multiple-tasks-uploading-video
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexeyAlexeevXperienceAI committed Aug 24, 2022
2 parents f70aa2e + 54c25d7 commit a42d531
Show file tree
Hide file tree
Showing 19 changed files with 1,037 additions and 279 deletions.
8 changes: 4 additions & 4 deletions cvat-ui/src/actions/share-actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,16 @@ const shareActions = {

export type ShareActions = ActionUnion<typeof shareActions>;

export function loadShareDataAsync(directory: string, success: () => void, failure: () => void): ThunkAction {
return async (dispatch): Promise<void> => {
export function loadShareDataAsync(directory: string): ThunkAction {
return async (dispatch): Promise<ShareFileInfo[]> => {
try {
dispatch(shareActions.loadShareData());
const values = await core.server.share(directory);
success();
dispatch(shareActions.loadShareDataSuccess(values as ShareFileInfo[], directory));
return (values as ShareFileInfo[]);
} catch (error) {
failure();
dispatch(shareActions.loadShareDataFailed(error));
throw error;
}
};
}
69 changes: 8 additions & 61 deletions cvat-ui/src/actions/tasks-actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@ export enum TasksActionTypes {
DELETE_TASK = 'DELETE_TASK',
DELETE_TASK_SUCCESS = 'DELETE_TASK_SUCCESS',
DELETE_TASK_FAILED = 'DELETE_TASK_FAILED',
CREATE_TASK = 'CREATE_TASK',
CREATE_TASK_STATUS_UPDATED = 'CREATE_TASK_STATUS_UPDATED',
CREATE_TASK_SUCCESS = 'CREATE_TASK_SUCCESS',
CREATE_TASK_FAILED = 'CREATE_TASK_FAILED',
UPDATE_TASK = 'UPDATE_TASK',
UPDATE_TASK_SUCCESS = 'UPDATE_TASK_SUCCESS',
UPDATE_TASK_FAILED = 'UPDATE_TASK_FAILED',
Expand Down Expand Up @@ -302,50 +298,9 @@ export function deleteTaskAsync(taskInstance: any): ThunkAction<Promise<void>, {
};
}

function createTask(): AnyAction {
const action = {
type: TasksActionTypes.CREATE_TASK,
payload: {},
};

return action;
}

function createTaskSuccess(taskId: number): AnyAction {
const action = {
type: TasksActionTypes.CREATE_TASK_SUCCESS,
payload: {
taskId,
},
};

return action;
}

function createTaskFailed(error: any): AnyAction {
const action = {
type: TasksActionTypes.CREATE_TASK_FAILED,
payload: {
error,
},
};

return action;
}

function createTaskUpdateStatus(status: string): AnyAction {
const action = {
type: TasksActionTypes.CREATE_TASK_STATUS_UPDATED,
payload: {
status,
},
};

return action;
}

export function createTaskAsync(data: any): ThunkAction<Promise<void>, {}, {}, AnyAction> {
return async (dispatch: ActionCreator<Dispatch>): Promise<any> => {
export function createTaskAsync(data: any, onProgress: (status: string) => void):
ThunkAction<Promise<void>, {}, {}, AnyAction> {
return async (): Promise<any> => {
const description: any = {
name: data.basic.name,
labels: data.labels,
Expand Down Expand Up @@ -402,26 +357,18 @@ export function createTaskAsync(data: any): ThunkAction<Promise<void>, {}, {}, A

if (gitPlugin) {
gitPlugin.callbacks.onStatusChange = (status: string): void => {
dispatch(createTaskUpdateStatus(status));
onProgress(status);
};
gitPlugin.data.task = taskInstance;
gitPlugin.data.repos = data.advanced.repository;
gitPlugin.data.format = data.advanced.format;
gitPlugin.data.lfs = data.advanced.lfs;
}
}

dispatch(createTask());
try {
const savedTask = await taskInstance.save((status: string, progress: number): void => {
dispatch(createTaskUpdateStatus(status + (progress !== null ? ` ${Math.floor(progress * 100)}%` : '')));
});
dispatch(createTaskSuccess(savedTask.id));
return savedTask;
} catch (error) {
dispatch(createTaskFailed(error));
throw error;
}
const savedTask = await taskInstance.save((status: string): void => {
onProgress(status);
});
return savedTask;
};
}

Expand Down
3 changes: 3 additions & 0 deletions cvat-ui/src/assets/multi-plus-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,19 @@

import React, { RefObject } from 'react';
import Input from 'antd/lib/input';
import Text from 'antd/lib/typography/Text';
import Tooltip from 'antd/lib/tooltip';
import Form, { FormInstance } from 'antd/lib/form';
import { Store } from 'antd/lib/form/interface';

export interface BaseConfiguration {
name: string;
}

interface Props {
onSubmit(values: BaseConfiguration): void;
onChange(values: BaseConfiguration): void;
isMultiTask: boolean;
exampleMultiTaskName?: string;
defaultValue?: string;
}

export default class BasicConfigurationForm extends React.PureComponent<Props> {
Expand All @@ -25,13 +29,23 @@ export default class BasicConfigurationForm extends React.PureComponent<Props> {
this.inputRef = React.createRef<Input>();
}

componentDidMount(): void {
const { defaultValue, onChange } = this.props;
onChange({
name: defaultValue || '',
});
}

private handleChangeName(e: React.ChangeEvent<HTMLInputElement>): void {
const { onChange } = this.props;
onChange({
name: e.target.value,
});
}

public submit(): Promise<void> {
const { onSubmit } = this.props;
if (this.formRef.current) {
return this.formRef.current.validateFields().then((values: Store): Promise<void> => {
onSubmit({ name: values.name });
return Promise.resolve();
});
return this.formRef.current.validateFields();
}

return Promise.reject(new Error('Form ref is empty'));
Expand All @@ -50,6 +64,8 @@ export default class BasicConfigurationForm extends React.PureComponent<Props> {
}

public render(): JSX.Element {
const { isMultiTask, exampleMultiTaskName, defaultValue } = this.props;

return (
<Form ref={this.formRef} layout='vertical'>
<Form.Item
Expand All @@ -62,9 +78,46 @@ export default class BasicConfigurationForm extends React.PureComponent<Props> {
message: 'Task name cannot be empty',
},
]}
initialValue={defaultValue}
>
<Input ref={this.inputRef} />
<Input
ref={this.inputRef}
onChange={(e) => this.handleChangeName(e)}
/>
</Form.Item>
{isMultiTask ? (
<Text type='secondary'>
<Tooltip title={() => (
<>
You can substitute in the template:
<ul>
<li>
some_text - any text
</li>
<li>
{'{{'}
index
{'}}'}
&nbsp;- index file in set
</li>
<li>
{'{{'}
file_name
{'}}'}
&nbsp;- name of file
</li>
</ul>
Example:&nbsp;
<i>
{exampleMultiTaskName || 'Task name 1 - video_1.mp4'}
</i>
</>
)}
>
When forming the name, a template is used.
</Tooltip>
</Text>
) : null}
</Form>
);
}
Expand Down
Loading

0 comments on commit a42d531

Please sign in to comment.