React & Antd UI: Export dataset, refactoring & fixes (#872)
* Automatic label matching (by the same name) in model running window * Improved create task window * Improved upload model window * Fixed: error window showed twice * Updated CONTRIBUTING.md * Removed token before login, fixed dump submenu (adjustment), fixed case when empty models list displayed * Export as dataset, better error showing system * Removed extra requests, improved UI * Fixed a name of a format * Show inference progress * Fixed model loading after a model was uploadedmain
parent
9cb48ef2c2
commit
911b4e9229
@ -0,0 +1,24 @@
|
||||
import { AnyAction } from 'redux';
|
||||
|
||||
export enum NotificationsActionType {
|
||||
RESET_ERRORS = 'RESET_ERRORS',
|
||||
RESET_MESSAGES = 'RESET_MESSAGES',
|
||||
}
|
||||
|
||||
export function resetErrors(): AnyAction {
|
||||
const action = {
|
||||
type: NotificationsActionType.RESET_ERRORS,
|
||||
payload: {},
|
||||
};
|
||||
|
||||
return action;
|
||||
}
|
||||
|
||||
export function resetMessages(): AnyAction {
|
||||
const action = {
|
||||
type: NotificationsActionType.RESET_MESSAGES,
|
||||
payload: {},
|
||||
};
|
||||
|
||||
return action;
|
||||
}
|
||||
@ -0,0 +1,38 @@
|
||||
import React from 'react';
|
||||
|
||||
import {
|
||||
Menu,
|
||||
Button,
|
||||
Icon,
|
||||
} from 'antd';
|
||||
|
||||
import Text from 'antd/lib/typography/Text';
|
||||
|
||||
interface DumperItemComponentProps {
|
||||
taskInstance: any;
|
||||
exporter: any;
|
||||
exportActivity: string | null;
|
||||
onExportDataset: (task: any, exporter: any) => void;
|
||||
}
|
||||
|
||||
export default function DumperItemComponent(props: DumperItemComponentProps) {
|
||||
const task = props.taskInstance;
|
||||
const { exporter } = props;
|
||||
const pending = !!props.exportActivity;
|
||||
|
||||
return (
|
||||
<Menu.Item className='cvat-actions-menu-export-submenu-item' key={exporter.name}>
|
||||
<Button block={true} type='link' disabled={pending}
|
||||
onClick={() => {
|
||||
props.onExportDataset(task, exporter);
|
||||
}}>
|
||||
<Icon type='export'/>
|
||||
<Text strong={props.exporter.is_default}>
|
||||
{exporter.name}
|
||||
</Text>
|
||||
{pending && <Icon type='loading'/>}
|
||||
</Button>
|
||||
</Menu.Item>
|
||||
);
|
||||
}
|
||||
|
||||
@ -0,0 +1,340 @@
|
||||
import { AnyAction } from 'redux';
|
||||
|
||||
import { AuthActionTypes } from '../actions/auth-actions';
|
||||
import { FormatsActionTypes } from '../actions/formats-actions';
|
||||
import { ModelsActionTypes } from '../actions/models-actions';
|
||||
import { ShareActionTypes } from '../actions/share-actions';
|
||||
import { TasksActionTypes } from '../actions/tasks-actions';
|
||||
import { UsersActionTypes } from '../actions/users-actions';
|
||||
import { NotificationsActionType } from '../actions/notification-actions';
|
||||
|
||||
import { NotificationsState } from './interfaces';
|
||||
|
||||
const defaultState: NotificationsState = {
|
||||
errors: {
|
||||
auth: {
|
||||
authorized: null,
|
||||
login: null,
|
||||
logout: null,
|
||||
register: null,
|
||||
},
|
||||
tasks: {
|
||||
fetching: null,
|
||||
updating: null,
|
||||
dumping: null,
|
||||
loading: null,
|
||||
exporting: null,
|
||||
deleting: null,
|
||||
creating: null,
|
||||
},
|
||||
formats: {
|
||||
fetching: null,
|
||||
},
|
||||
users: {
|
||||
fetching: null,
|
||||
},
|
||||
share: {
|
||||
fetching: null,
|
||||
},
|
||||
models: {
|
||||
creating: null,
|
||||
starting: null,
|
||||
fetching: null,
|
||||
deleting: null,
|
||||
inferenceStatusFetching: null,
|
||||
},
|
||||
},
|
||||
messages: {
|
||||
tasks: {
|
||||
loadingDone: '',
|
||||
},
|
||||
models: {
|
||||
inferenceDone: '',
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export default function (state = defaultState, action: AnyAction): NotificationsState {
|
||||
switch (action.type) {
|
||||
case AuthActionTypes.AUTHORIZED_FAILED: {
|
||||
return {
|
||||
...state,
|
||||
errors: {
|
||||
...state.errors,
|
||||
auth: {
|
||||
...state.errors.auth,
|
||||
authorized: action.payload.error,
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
case AuthActionTypes.LOGIN_FAILED: {
|
||||
return {
|
||||
...state,
|
||||
errors: {
|
||||
...state.errors,
|
||||
auth: {
|
||||
...state.errors.auth,
|
||||
login: action.payload.error,
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
case AuthActionTypes.LOGOUT_FAILED: {
|
||||
return {
|
||||
...state,
|
||||
errors: {
|
||||
...state.errors,
|
||||
auth: {
|
||||
...state.errors.auth,
|
||||
logout: action.payload.error,
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
case AuthActionTypes.REGISTER_FAILED: {
|
||||
return {
|
||||
...state,
|
||||
errors: {
|
||||
...state.errors,
|
||||
auth: {
|
||||
...state.errors.auth,
|
||||
register: action.payload.error,
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
case TasksActionTypes.EXPORT_DATASET_FAILED: {
|
||||
return {
|
||||
...state,
|
||||
errors: {
|
||||
...state.errors,
|
||||
tasks: {
|
||||
...state.errors.tasks,
|
||||
exporting: action.payload.error,
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
case TasksActionTypes.GET_TASKS_FAILED: {
|
||||
return {
|
||||
...state,
|
||||
errors: {
|
||||
...state.errors,
|
||||
tasks: {
|
||||
...state.errors.tasks,
|
||||
fetching: action.payload.error,
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
case TasksActionTypes.LOAD_ANNOTATIONS_FAILED: {
|
||||
return {
|
||||
...state,
|
||||
errors: {
|
||||
...state.errors,
|
||||
tasks: {
|
||||
...state.errors.tasks,
|
||||
loading: action.payload.error,
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
case TasksActionTypes.LOAD_ANNOTATIONS_SUCCESS: {
|
||||
const { task } = action.payload;
|
||||
return {
|
||||
...state,
|
||||
messages: {
|
||||
...state.messages,
|
||||
tasks: {
|
||||
...state.messages.tasks,
|
||||
loadingDone: `Annotations have been loaded to the task ${task.id}`,
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
case TasksActionTypes.UPDATE_TASK_FAILED: {
|
||||
return {
|
||||
...state,
|
||||
errors: {
|
||||
...state.errors,
|
||||
tasks: {
|
||||
...state.errors.tasks,
|
||||
updating: action.payload.error,
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
case TasksActionTypes.DUMP_ANNOTATIONS_FAILED: {
|
||||
return {
|
||||
...state,
|
||||
errors: {
|
||||
...state.errors,
|
||||
tasks: {
|
||||
...state.errors.tasks,
|
||||
dumping: action.payload.error,
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
case TasksActionTypes.DELETE_TASK_FAILED: {
|
||||
return {
|
||||
...state,
|
||||
errors: {
|
||||
...state.errors,
|
||||
tasks: {
|
||||
...state.errors.tasks,
|
||||
deleting: action.payload.error,
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
case TasksActionTypes.CREATE_TASK_FAILED: {
|
||||
return {
|
||||
...state,
|
||||
errors: {
|
||||
...state.errors,
|
||||
tasks: {
|
||||
...state.errors.tasks,
|
||||
creating: action.payload.error,
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
case FormatsActionTypes.GET_FORMATS_FAILED: {
|
||||
return {
|
||||
...state,
|
||||
errors: {
|
||||
...state.errors,
|
||||
formats: {
|
||||
...state.errors.formats,
|
||||
fetching: action.payload.error,
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
case UsersActionTypes.GET_USERS_FAILED: {
|
||||
return {
|
||||
...state,
|
||||
errors: {
|
||||
...state.errors,
|
||||
users: {
|
||||
...state.errors.users,
|
||||
fetching: action.payload.error,
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
case ShareActionTypes.LOAD_SHARE_DATA_FAILED: {
|
||||
return {
|
||||
...state,
|
||||
errors: {
|
||||
...state.errors,
|
||||
share: {
|
||||
...state.errors.share,
|
||||
fetching: action.payload.error,
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
case ModelsActionTypes.CREATE_MODEL_FAILED: {
|
||||
return {
|
||||
...state,
|
||||
errors: {
|
||||
...state.errors,
|
||||
models: {
|
||||
...state.errors.models,
|
||||
creating: action.payload.error,
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
case ModelsActionTypes.DELETE_MODEL_FAILED: {
|
||||
return {
|
||||
...state,
|
||||
errors: {
|
||||
...state.errors,
|
||||
models: {
|
||||
...state.errors.models,
|
||||
deleting: action.payload.error,
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
case ModelsActionTypes.GET_INFERENCE_STATUS_SUCCESS: {
|
||||
if (action.payload.activeInference.status === 'finished') {
|
||||
return {
|
||||
...state,
|
||||
messages: {
|
||||
...state.messages,
|
||||
models: {
|
||||
...state.messages.models,
|
||||
inferenceDone: `Automatic annotation finished for the task ${action.payload.taskID}`,
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
...state,
|
||||
};
|
||||
}
|
||||
case ModelsActionTypes.GET_INFERENCE_STATUS_FAILED: {
|
||||
return {
|
||||
...state,
|
||||
errors: {
|
||||
...state.errors,
|
||||
models: {
|
||||
...state.errors.models,
|
||||
inferenceStatusFetching: action.payload.error,
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
case ModelsActionTypes.GET_MODELS_FAILED: {
|
||||
return {
|
||||
...state,
|
||||
errors: {
|
||||
...state.errors,
|
||||
models: {
|
||||
...state.errors.models,
|
||||
fetching: action.payload.error,
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
case ModelsActionTypes.INFER_MODEL_FAILED: {
|
||||
return {
|
||||
...state,
|
||||
errors: {
|
||||
...state.errors,
|
||||
models: {
|
||||
...state.errors.models,
|
||||
starting: action.payload.error,
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
case NotificationsActionType.RESET_ERRORS: {
|
||||
return {
|
||||
...state,
|
||||
errors: {
|
||||
...defaultState.errors,
|
||||
},
|
||||
};
|
||||
}
|
||||
case NotificationsActionType.RESET_MESSAGES: {
|
||||
return {
|
||||
...state,
|
||||
messages: {
|
||||
...defaultState.messages,
|
||||
},
|
||||
};
|
||||
}
|
||||
default: {
|
||||
return {
|
||||
...state,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue