Skip to content

Commit 8334f06

Browse files
author
Boris Sekachev
authored
Merge pull request #2370 from openvinotoolkit/dk/user-search
User search field
2 parents a916e65 + 8c22003 commit 8334f06

33 files changed

+406
-397
lines changed

CHANGELOG.md

+8-1
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,33 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
88
## [1.2.0-beta] - Unreleased
99

1010
### Added
11+
1112
-
1213

1314
### Changed
15+
1416
-
1517

1618
### Deprecated
19+
1720
-
1821

1922
### Removed
23+
2024
-
2125

2226
### Fixed
27+
2328
-
2429

2530
### Security
31+
2632
-
2733

2834
## [1.2.0-alpha] - 2020-11-09
2935

3036
### Added
37+
3138
- Ability to login into CVAT-UI with token from api/v1/auth/login (<https://github.com/openvinotoolkit/cvat/pull/2234>)
3239
- Added layout grids toggling ('ctrl + alt + Enter')
3340
- Added password reset functionality (<https://github.com/opencv/cvat/pull/2058>)
@@ -48,6 +55,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
4855
- Optional chaining plugin for cvat-canvas and cvat-ui (<https://github.com/openvinotoolkit/cvat/pull/2249>)
4956
- MOTS png mask format support (<https://github.com/openvinotoolkit/cvat/pull/2198>)
5057
- Ability to correct upload video with a rotation record in the metadata (<https://github.com/openvinotoolkit/cvat/pull/2218>)
58+
- User search field for assignee fields (<https://github.com/openvinotoolkit/cvat/pull/2370>)
5159

5260
### Changed
5361

@@ -65,7 +73,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
6573

6674
- Removed Z-Order flag from task creation process
6775

68-
6976
### Fixed
7077

7178
- Fixed multiple errors which arises when polygon is of length 5 or less (<https://github.com/opencv/cvat/pull/2100>)

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -124,4 +124,5 @@ Other ways to ask questions and get our support:
124124
- [VentureBeat: Intel open-sources CVAT, a toolkit for data labeling](https://venturebeat.com/2019/03/05/intel-open-sources-cvat-a-toolkit-for-data-labeling/)
125125

126126
## Projects using CVAT
127+
127128
- [Onepanel](https://github.com/onepanelio/core) - Onepanel is an open source vision AI platform that fully integrates CVAT with scalable data processing and parallelized training pipelines.

cvat-core/.eslintrc.js

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
module.exports = {
66
env: {
7+
amd: true,
78
node: false,
89
browser: true,
910
es6: true,

cvat-core/package-lock.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cvat-core/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cvat-core",
3-
"version": "3.8.1",
3+
"version": "3.9.0",
44
"description": "Part of Computer Vision Tool which presents an interface for client-side integration",
55
"main": "babel.config.js",
66
"scripts": {

cvat-core/src/api-implementation.js

+12-25
Original file line numberDiff line numberDiff line change
@@ -17,26 +17,6 @@
1717
const { ArgumentError } = require('./exceptions');
1818
const { Task } = require('./session');
1919

20-
function attachUsers(task, users) {
21-
if (task.assignee !== null) {
22-
[task.assignee] = users.filter((user) => user.id === task.assignee);
23-
}
24-
25-
for (const segment of task.segments) {
26-
for (const job of segment.jobs) {
27-
if (job.assignee !== null) {
28-
[job.assignee] = users.filter((user) => user.id === job.assignee);
29-
}
30-
}
31-
}
32-
33-
if (task.owner !== null) {
34-
[task.owner] = users.filter((user) => user.id === task.owner);
35-
}
36-
37-
return task;
38-
}
39-
4020
function implementAPI(cvat) {
4121
cvat.plugins.list.implementation = PluginRegistry.list;
4222
cvat.plugins.register.implementation = PluginRegistry.register.bind(cvat);
@@ -122,15 +102,24 @@
122102

123103
cvat.users.get.implementation = async (filter) => {
124104
checkFilter(filter, {
105+
id: isInteger,
125106
self: isBoolean,
107+
search: isString,
108+
limit: isInteger,
126109
});
127110

128111
let users = null;
129112
if ('self' in filter && filter.self) {
130113
users = await serverProxy.users.getSelf();
131114
users = [users];
132115
} else {
133-
users = await serverProxy.users.getUsers();
116+
const searchParams = {};
117+
for (const key in filter) {
118+
if (filter[key] && key !== 'self') {
119+
searchParams[key] = filter[key];
120+
}
121+
}
122+
users = await serverProxy.users.getUsers(new URLSearchParams(searchParams).toString());
134123
}
135124

136125
users = users.map((user) => new User(user));
@@ -163,8 +152,7 @@
163152

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

169157
return filter.jobID ? task.jobs.filter((job) => job.id === filter.jobID) : task.jobs;
170158
}
@@ -203,9 +191,8 @@
203191
}
204192
}
205193

206-
const users = (await serverProxy.users.getUsers()).map((userData) => new User(userData));
207194
const tasksData = await serverProxy.tasks.getTasks(searchParams.toString());
208-
const tasks = tasksData.map((task) => attachUsers(task, users)).map((task) => new Task(task));
195+
const tasks = tasksData.map((task) => new Task(task));
209196

210197
tasks.count = tasksData.count;
211198

cvat-core/src/server-proxy.js

+4-10
Original file line numberDiff line numberDiff line change
@@ -500,20 +500,14 @@
500500
}
501501
}
502502

503-
async function getUsers(id = null) {
503+
async function getUsers(filter = 'page_size=all') {
504504
const { backendAPI } = config;
505505

506506
let response = null;
507507
try {
508-
if (id === null) {
509-
response = await Axios.get(`${backendAPI}/users?page_size=all`, {
510-
proxy: config.proxy,
511-
});
512-
} else {
513-
response = await Axios.get(`${backendAPI}/users/${id}`, {
514-
proxy: config.proxy,
515-
});
516-
}
508+
response = await Axios.get(`${backendAPI}/users?${filter}`, {
509+
proxy: config.proxy,
510+
});
517511
} catch (errorData) {
518512
throw generateError(errorData);
519513
}

cvat-core/src/session.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -686,6 +686,8 @@
686686
}
687687
}
688688

689+
if (data.assignee) data.assignee = new User(data.assignee);
690+
689691
Object.defineProperties(
690692
this,
691693
Object.freeze({
@@ -883,6 +885,9 @@
883885
}
884886
}
885887

888+
if (data.assignee) data.assignee = new User(data.assignee);
889+
if (data.owner) data.owner = new User(data.owner);
890+
886891
data.labels = [];
887892
data.jobs = [];
888893
data.files = Object.freeze({
@@ -1440,7 +1445,7 @@
14401445
if (this.id) {
14411446
const jobData = {
14421447
status: this.status,
1443-
assignee: this.assignee ? this.assignee.id : null,
1448+
assignee_id: this.assignee ? this.assignee.id : null,
14441449
};
14451450

14461451
await serverProxy.jobs.saveJob(this.id, jobData);
@@ -1649,7 +1654,7 @@
16491654
if (typeof this.id !== 'undefined') {
16501655
// If the task has been already created, we update it
16511656
const taskData = {
1652-
assignee: this.assignee ? this.assignee.id : null,
1657+
assignee_id: this.assignee ? this.assignee.id : null,
16531658
name: this.name,
16541659
bug_tracker: this.bugTracker,
16551660
labels: [...this.labels.map((el) => el.toJSON())],

cvat-core/tests/mocks/dummy-data.mock.js

+30-6
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,11 @@ const tasksDummyData = {
154154
name: 'Test',
155155
size: 1,
156156
mode: 'annotation',
157-
owner: 1,
157+
owner: {
158+
url: 'http://localhost:7000/api/v1/users/1',
159+
id: 1,
160+
username: 'admin',
161+
},
158162
assignee: null,
159163
bug_tracker: '',
160164
created_date: '2019-09-05T11:59:22.987942Z',
@@ -194,7 +198,11 @@ const tasksDummyData = {
194198
name: 'Image Task',
195199
size: 9,
196200
mode: 'annotation',
197-
owner: 1,
201+
owner: {
202+
url: 'http://localhost:7000/api/v1/users/1',
203+
id: 1,
204+
username: 'admin',
205+
},
198206
assignee: null,
199207
bug_tracker: '',
200208
created_date: '2019-06-18T13:05:08.941304+03:00',
@@ -239,7 +247,11 @@ const tasksDummyData = {
239247
name: 'Video Task',
240248
size: 5002,
241249
mode: 'interpolation',
242-
owner: 1,
250+
owner: {
251+
url: 'http://localhost:7000/api/v1/users/1',
252+
id: 1,
253+
username: 'admin',
254+
},
243255
assignee: null,
244256
bug_tracker: '',
245257
created_date: '2019-06-21T16:34:49.199691+03:00',
@@ -558,7 +570,11 @@ const tasksDummyData = {
558570
name: 'Test Task',
559571
size: 5002,
560572
mode: 'interpolation',
561-
owner: 2,
573+
owner: {
574+
url: 'http://localhost:7000/api/v1/users/2',
575+
id: 2,
576+
username: 'bsekache',
577+
},
562578
assignee: null,
563579
bug_tracker: '',
564580
created_date: '2019-05-16T13:08:00.621747+03:00',
@@ -767,7 +783,11 @@ const tasksDummyData = {
767783
name: 'Video',
768784
size: 75,
769785
mode: 'interpolation',
770-
owner: 1,
786+
owner: {
787+
url: 'http://localhost:7000/api/v1/users/1',
788+
id: 1,
789+
username: 'admin',
790+
},
771791
assignee: null,
772792
bug_tracker: '',
773793
created_date: '2019-05-15T11:40:19.487999+03:00',
@@ -964,7 +984,11 @@ const tasksDummyData = {
964984
name: 'Labels Set',
965985
size: 9,
966986
mode: 'annotation',
967-
owner: 1,
987+
owner: {
988+
url: 'http://localhost:7000/api/v1/users/1',
989+
id: 1,
990+
username: 'admin',
991+
},
968992
assignee: null,
969993
bug_tracker: 'http://bugtracker.com/issue12345',
970994
created_date: '2019-05-13T15:35:29.871003+03:00',

cvat-core/tests/mocks/server-proxy.mock.js

+8-5
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@ class ServerProxy {
9494
const object = tasksDummyData.results.filter((task) => task.id === id)[0];
9595
for (const prop in taskData) {
9696
if (
97-
Object.prototype.hasOwnProperty.call(taskData, prop) &&
98-
Object.prototype.hasOwnProperty.call(object, prop)
97+
Object.prototype.hasOwnProperty.call(taskData, prop)
98+
&& Object.prototype.hasOwnProperty.call(object, prop)
9999
) {
100100
object[prop] = taskData[prop];
101101
}
@@ -110,7 +110,10 @@ class ServerProxy {
110110
name: taskData.name,
111111
size: 5000,
112112
mode: 'interpolation',
113-
owner: 2,
113+
owner: {
114+
id: 2,
115+
username: 'bsekache',
116+
},
114117
assignee: null,
115118
bug_tracker: taskData.bug_tracker,
116119
created_date: '2019-05-16T13:08:00.621747+03:00',
@@ -175,8 +178,8 @@ class ServerProxy {
175178

176179
for (const prop in jobData) {
177180
if (
178-
Object.prototype.hasOwnProperty.call(jobData, prop) &&
179-
Object.prototype.hasOwnProperty.call(object, prop)
181+
Object.prototype.hasOwnProperty.call(jobData, prop)
182+
&& Object.prototype.hasOwnProperty.call(object, prop)
180183
) {
181184
object[prop] = jobData[prop];
182185
}

0 commit comments

Comments
 (0)