Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

User interface with React and antd #811

Merged
merged 31 commits into from
Oct 31, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
3f46768
Fixed links for analytics and help
bsekachev Oct 22, 2019
3e26c79
Delete task functionality
bsekachev Oct 22, 2019
2e60eb4
Added navigation for create and open task
bsekachev Oct 22, 2019
f0b5065
Added icon for help
bsekachev Oct 22, 2019
5ecb5b0
Added easy plugin checker
bsekachev Oct 22, 2019
b80b827
Header dependes on installed plugins
bsekachev Oct 22, 2019
15fbb00
Menu depends on installed plugins
bsekachev Oct 22, 2019
ef73d4e
Shared actions menu component, base layout for task page
bsekachev Oct 23, 2019
9775d76
Minor fix
bsekachev Oct 23, 2019
5f1bcd8
Better delete handling
bsekachev Oct 23, 2019
34f9216
Task page based (relations with redux, base layout)
bsekachev Oct 24, 2019
6b60837
Added attribute form
bsekachev Oct 25, 2019
a1909c6
Refactoring
bsekachev Oct 25, 2019
410bb22
Finished label creator
bsekachev Oct 25, 2019
e83120a
First version
bsekachev Oct 28, 2019
dbea443
added missed file
bsekachev Oct 29, 2019
db8a811
Updated label constructor
bsekachev Oct 29, 2019
072ed42
Sync handle
bsekachev Oct 29, 2019
24238e8
Added jobs table
bsekachev Oct 30, 2019
1f7006e
Added job assignee
bsekachev Oct 30, 2019
cfc1ba3
A couple of changes
bsekachev Oct 30, 2019
ca665d5
updated text colors
bsekachev Oct 30, 2019
b4a9a57
Save updated labels on server
bsekachev Oct 30, 2019
94fca96
Style changes
bsekachev Oct 31, 2019
8595dd1
Added imports plugin, updated webpack
bsekachev Oct 31, 2019
b0a4d7a
Refactoring
bsekachev Oct 31, 2019
650d86b
Editable bug tracker
bsekachev Oct 31, 2019
5231a5b
Clean task update
bsekachev Oct 31, 2019
e526821
Change assignee
bsekachev Oct 31, 2019
d37d30a
Removed extra comments
bsekachev Oct 31, 2019
11b7a57
Fiexd test
bsekachev Oct 31, 2019
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
40 changes: 31 additions & 9 deletions cvat-core/src/api-implementation.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,26 @@
const { ArgumentError } = require('./exceptions');
const { Task } = require('./session');

function attachUsers(task, users) {
if (task.assignee !== null) {
[task.assignee] = users.filter((user) => user.id === task.assignee);
}

for (const segment of task.segments) {
for (const job of segment.jobs) {
if (job.assignee !== null) {
[job.assignee] = users.filter((user) => user.id === job.assignee);
}
}
}

if (task.owner !== null) {
[task.owner] = users.filter((user) => user.id === task.owner);
}

return task;
}

function implementAPI(cvat) {
cvat.plugins.list.implementation = PluginRegistry.list;
cvat.plugins.register.implementation = PluginRegistry.register.bind(cvat);
Expand Down Expand Up @@ -116,9 +136,10 @@

// If task was found by its id, then create task instance and get Job instance from it
if (tasks !== null && tasks.length) {
tasks[0].owner = await serverProxy.users.getUsers(tasks[0].owner);
tasks[0].assignee = await serverProxy.users.getUsers(tasks[0].assignee);
const task = new Task(tasks[0]);
const users = (await serverProxy.users.getUsers())
.map((userData) => new User(userData));
const task = new Task(attachUsers(tasks[0], users));

return filter.jobID ? task.jobs
.filter((job) => job.id === filter.jobID) : task.jobs;
}
Expand Down Expand Up @@ -161,13 +182,14 @@
}
}

const users = await serverProxy.users.getUsers();
const users = (await serverProxy.users.getUsers())
.map((userData) => new User(userData));
const tasksData = await serverProxy.tasks.getTasks(searchParams.toString());
const tasks = tasksData.map((task) => {
[task.owner] = users.filter((user) => user.id === task.owner);
[task.assignee] = users.filter((user) => user.id === task.assignee);
return new Task(task);
});
const tasks = tasksData
.map((task) => attachUsers(task, users))
.map((task) => new Task(task));


tasks.count = tasksData.count;

return tasks;
Expand Down
24 changes: 11 additions & 13 deletions cvat-core/src/session.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
const { ArgumentError } = require('./exceptions');
const { TaskStatus } = require('./enums');
const { Label } = require('./labels');
const User = require('./user');

function buildDublicatedAPI(prototype) {
Object.defineProperties(prototype, {
Expand Down Expand Up @@ -536,19 +537,19 @@
get: () => data.id,
},
/**
* Identifier of a user who is responsible for the job
* Instance of a user who is responsible for the job
* @name assignee
* @type {integer}
* @type {module:API.cvat.classes.User}
* @memberof module:API.cvat.classes.Job
* @instance
* @throws {module:API.cvat.exceptions.ArgumentError}
*/
assignee: {
get: () => data.assignee,
set: () => (assignee) => {
if (!Number.isInteger(assignee) || assignee < 0) {
set: (assignee) => {
if (assignee !== null && !(assignee instanceof User)) {
throw new ArgumentError(
'Value must be a non negative integer',
'Value must be a user instance',
);
}
data.assignee = assignee;
Expand Down Expand Up @@ -817,10 +818,10 @@
*/
assignee: {
get: () => data.assignee,
set: () => (assignee) => {
if (!Number.isInteger(assignee) || assignee < 0) {
set: (assignee) => {
if (assignee !== null && !(assignee instanceof User)) {
throw new ArgumentError(
'Value must be a non negative integer',
'Value must be a user instance',
);
}
data.assignee = assignee;
Expand Down Expand Up @@ -957,11 +958,7 @@
}
}

if (typeof (data.id) === 'undefined') {
data.labels = [...labels];
} else {
data.labels = data.labels.concat([...labels]);
}
data.labels = [...labels];
},
},
/**
Expand Down Expand Up @@ -1313,6 +1310,7 @@
if (typeof (this.id) !== 'undefined') {
// If the task has been already created, we update it
const taskData = {
assignee: this.assignee ? this.assignee.id : null,
name: this.name,
bug_tracker: this.bugTracker,
z_order: this.zOrder,
Expand Down
2 changes: 1 addition & 1 deletion cvat-core/tests/api/tasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ describe('Feature: save a task', () => {
}],
});

result[0].labels = [newLabel];
result[0].labels = [...result[0].labels, newLabel];
result[0].save();

result = await window.cvat.tasks.get({
Expand Down
1 change: 1 addition & 0 deletions cvat-ui/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ module.exports = {
'@typescript-eslint/indent': ['warn', 4],
'@typescript-eslint/no-explicit-any': [0],
'no-restricted-syntax': [0, {'selector': 'ForOfStatement'}],
'no-plusplus': [0],
},
'settings': {
'import/resolver': {
Expand Down
Loading