Skip to content

Commit

Permalink
React & Antd: Dashboard migration (#892)
Browse files Browse the repository at this point in the history
* Removed old dashboard
* Getting all users
* Updated changelog
* Reimplemented login decorator
* Implicit host, scheme in docker-compose
* Fixed issue with pagination
* Implicit page size parameter for tasks
* Fixed linkedin icon, added links to tasks in notifications
* Configurable method for check plugin
  • Loading branch information
bsekachev authored and nmanovic committed Dec 4, 2019
1 parent dc7bfa9 commit 171a920
Show file tree
Hide file tree
Showing 55 changed files with 293 additions and 3,350 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ https://github.com/opencv/cvat/issues/750).

### Changed
- page_size parameter for all REST API methods
- React & Redux & Antd based dashboard

### Deprecated
-
Expand Down
85 changes: 31 additions & 54 deletions cvat-core/src/server-proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,14 @@
const store = require('store');
const config = require('./config');

function generateError(errorData, baseMessage) {
function generateError(errorData) {
if (errorData.response) {
const message = `${baseMessage}. `
+ `${errorData.message}. ${JSON.stringify(errorData.response.data) || ''}.`;
const message = `${errorData.message}. ${JSON.stringify(errorData.response.data) || ''}.`;
return new ServerError(message, errorData.response.status);
}

// Server is unavailable (no any response)
const message = `${baseMessage}. `
+ `${errorData.message}.`; // usually is "Error Network"
const message = `${errorData.message}.`; // usually is "Error Network"
return new ServerError(message, 0);
}

Expand All @@ -49,7 +47,7 @@
proxy: config.proxy,
});
} catch (errorData) {
throw generateError(errorData, 'Could not get "about" information from the server');
throw generateError(errorData);
}

return response.data;
Expand All @@ -65,7 +63,7 @@
proxy: config.proxy,
});
} catch (errorData) {
throw generateError(errorData, 'Could not get "share" information from the server');
throw generateError(errorData);
}

return response.data;
Expand All @@ -82,7 +80,7 @@
},
});
} catch (errorData) {
throw generateError(errorData, 'Could not send an exception to the server');
throw generateError(errorData);
}
}

Expand All @@ -95,7 +93,7 @@
proxy: config.proxy,
});
} catch (errorData) {
throw generateError(errorData, 'Could not get annotation formats from the server');
throw generateError(errorData);
}

return response.data;
Expand All @@ -111,7 +109,7 @@
});
response = JSON.parse(response.data);
} catch (errorData) {
throw generateError(errorData, 'Could not get export formats from the server');
throw generateError(errorData);
}

return response;
Expand All @@ -135,7 +133,7 @@
},
});
} catch (errorData) {
throw generateError(errorData, `Could not register '${username}' user on the server`);
throw generateError(errorData);
}

return response.data;
Expand All @@ -157,7 +155,7 @@
},
);
} catch (errorData) {
throw generateError(errorData, 'Could not login on a server');
throw generateError(errorData);
}

if (authenticationResponse.headers['set-cookie']) {
Expand All @@ -178,7 +176,7 @@
proxy: config.proxy,
});
} catch (errorData) {
throw generateError(errorData, 'Could not logout from the server');
throw generateError(errorData);
}

store.remove('token');
Expand Down Expand Up @@ -206,7 +204,7 @@
...data,
})).data;
} catch (errorData) {
throw generateError(errorData, 'Could not have done the request');
throw generateError(errorData);
}
}

Expand All @@ -215,11 +213,11 @@

let response = null;
try {
response = await Axios.get(`${backendAPI}/tasks?${filter}`, {
response = await Axios.get(`${backendAPI}/tasks?page_size=10&${filter}`, {
proxy: config.proxy,
});
} catch (errorData) {
throw generateError(errorData, 'Could not get tasks from a server');
throw generateError(errorData);
}

response.data.results.count = response.data.count;
Expand All @@ -237,7 +235,7 @@
},
});
} catch (errorData) {
throw generateError(errorData, 'Could not save the task on the server');
throw generateError(errorData);
}
}

Expand All @@ -247,7 +245,7 @@
try {
await Axios.delete(`${backendAPI}/tasks/${id}`);
} catch (errorData) {
throw generateError(errorData, `Could not delete the task ${id} from the server`);
throw generateError(errorData);
}
}

Expand All @@ -269,10 +267,7 @@
resolve(url);
}
} catch (errorData) {
reject(generateError(
errorData,
`Failed to export the task ${id} as a dataset`,
));
reject(generateError(errorData));
}
}

Expand Down Expand Up @@ -311,7 +306,7 @@
}
} catch (errorData) {
reject(
generateError(errorData, 'Could not put task to the server'),
generateError(errorData),
);
}
}
Expand Down Expand Up @@ -340,7 +335,7 @@
},
});
} catch (errorData) {
throw generateError(errorData, 'Could not put task to the server');
throw generateError(errorData);
}

onUpdate('The data is being uploaded to the server..');
Expand All @@ -355,7 +350,7 @@
// ignore
}

throw generateError(errorData, 'Could not put data to the server');
throw generateError(errorData);
}

try {
Expand All @@ -378,7 +373,7 @@
proxy: config.proxy,
});
} catch (errorData) {
throw generateError(errorData, 'Could not get jobs from a server');
throw generateError(errorData);
}

return response.data;
Expand All @@ -395,7 +390,7 @@
},
});
} catch (errorData) {
throw generateError(errorData, 'Could not save the job on the server');
throw generateError(errorData);
}
}

Expand All @@ -405,7 +400,7 @@
let response = null;
try {
if (id === null) {
response = await Axios.get(`${backendAPI}/users`, {
response = await Axios.get(`${backendAPI}/users?page_size=all`, {
proxy: config.proxy,
});
} else {
Expand All @@ -414,7 +409,7 @@
});
}
} catch (errorData) {
throw generateError(errorData, 'Could not get users from the server');
throw generateError(errorData);
}

return response.data.results;
Expand All @@ -429,7 +424,7 @@
proxy: config.proxy,
});
} catch (errorData) {
throw generateError(errorData, 'Could not get user data from the server');
throw generateError(errorData);
}

return response.data;
Expand Down Expand Up @@ -466,10 +461,7 @@
responseType: 'blob',
});
} catch (errorData) {
throw generateError(
errorData,
`Could not get frame ${frame} for the task ${tid} from the server`,
);
throw generateError(errorData);
}

return response.data;
Expand All @@ -484,10 +476,7 @@
proxy: config.proxy,
});
} catch (errorData) {
throw generateError(
errorData,
`Could not get frame meta info for the task ${tid} from the server`,
);
throw generateError(errorData);
}

return response.data;
Expand All @@ -503,10 +492,7 @@
proxy: config.proxy,
});
} catch (errorData) {
throw generateError(
errorData,
`Could not get annotations for the ${session} ${id} from the server`,
);
throw generateError(errorData);
}

return response.data;
Expand Down Expand Up @@ -534,10 +520,7 @@
},
});
} catch (errorData) {
throw generateError(
errorData,
`Could not ${action} annotations for the ${session} ${id} on the server`,
);
throw generateError(errorData);
}

return response.data;
Expand All @@ -564,10 +547,7 @@
resolve();
}
} catch (errorData) {
reject(generateError(
errorData,
`Could not upload annotations for the ${session} ${id}`,
));
reject(generateError(errorData));
}
}

Expand Down Expand Up @@ -595,10 +575,7 @@
resolve(url);
}
} catch (errorData) {
reject(generateError(
errorData,
`Could not dump annotations for the task ${id} from the server`,
));
reject(generateError(errorData));
}
}

Expand Down
5 changes: 3 additions & 2 deletions cvat-ui/src/actions/models-actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -551,10 +551,11 @@ function inferModelSuccess(): AnyAction {
return action;
}

function inferModelFailed(error: any): AnyAction {
function inferModelFailed(error: any, taskID: number): AnyAction {
const action = {
type: ModelsActionTypes.INFER_MODEL_FAILED,
payload: {
taskID,
error,
},
};
Expand Down Expand Up @@ -599,7 +600,7 @@ export function inferModelAsync(

dispatch(getInferenceStatusAsync([taskInstance.id]));
} catch (error) {
dispatch(inferModelFailed(error));
dispatch(inferModelFailed(error, taskInstance.id));
return;
}

Expand Down
12 changes: 7 additions & 5 deletions cvat-ui/src/actions/tasks-actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,12 @@ ThunkAction<Promise<void>, {}, {}, AnyAction> {
return;
}

const array = Array.from(result);
const array = Array.from(result)
.filter((task: any) => task.jobs.length > 0);
const previews = [];
const promises = array
.map((task): string => (task as any).frames.preview());

dispatch(
getInferenceStatusAsync(
array.map(
Expand Down Expand Up @@ -441,23 +443,23 @@ function updateTask(): AnyAction {
return action;
}

function updateTaskSuccess(taskInstance: any): AnyAction {
function updateTaskSuccess(task: any): AnyAction {
const action = {
type: TasksActionTypes.UPDATE_TASK_SUCCESS,
payload: {
taskInstance,
task,
},
};

return action;
}

function updateTaskFailed(error: any, taskInstance: any): AnyAction {
function updateTaskFailed(error: any, task: any): AnyAction {
const action = {
type: TasksActionTypes.UPDATE_TASK_FAILED,
payload: {
error,
taskInstance,
task,
},
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
Alert,
Button,
Tooltip,
Modal,
message,
notification,
} from 'antd';
Expand Down Expand Up @@ -96,7 +95,7 @@ export default class CreateModelContent extends React.PureComponent<Props> {
const status = this.props.modelCreatingStatus
&& this.props.modelCreatingStatus !== 'CREATED' ? this.props.modelCreatingStatus : '';

const guideLink = 'https://github.com/opencv/cvat/tree/develop/cvat/apps/auto_annotation';
const guideLink = 'https://github.com/opencv/cvat/blob/develop/cvat/apps/auto_annotation/README.md';
return (
<Row type='flex' justify='start' align='middle' className='cvat-create-model-content'>
<Col span={24}>
Expand Down
Loading

0 comments on commit 171a920

Please sign in to comment.