Skip to content

Commit

Permalink
Merge pull request #2370 from openvinotoolkit/dk/user-search
Browse files Browse the repository at this point in the history
User search field
  • Loading branch information
Boris Sekachev authored Nov 11, 2020
2 parents a916e65 + 8c22003 commit 8334f06
Show file tree
Hide file tree
Showing 33 changed files with 406 additions and 397 deletions.
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,33 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [1.2.0-beta] - Unreleased

### Added

-

### Changed

-

### Deprecated

-

### Removed

-

### Fixed

-

### Security

-

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

### Added

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

### Changed

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

- Removed Z-Order flag from task creation process


### Fixed

- Fixed multiple errors which arises when polygon is of length 5 or less (<https://github.com/opencv/cvat/pull/2100>)
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,4 +124,5 @@ Other ways to ask questions and get our support:
- [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/)

## Projects using CVAT

- [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.
1 change: 1 addition & 0 deletions cvat-core/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

module.exports = {
env: {
amd: true,
node: false,
browser: true,
es6: true,
Expand Down
2 changes: 1 addition & 1 deletion cvat-core/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion cvat-core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cvat-core",
"version": "3.8.1",
"version": "3.9.0",
"description": "Part of Computer Vision Tool which presents an interface for client-side integration",
"main": "babel.config.js",
"scripts": {
Expand Down
37 changes: 12 additions & 25 deletions cvat-core/src/api-implementation.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,6 @@
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 @@ -122,15 +102,24 @@

cvat.users.get.implementation = async (filter) => {
checkFilter(filter, {
id: isInteger,
self: isBoolean,
search: isString,
limit: isInteger,
});

let users = null;
if ('self' in filter && filter.self) {
users = await serverProxy.users.getSelf();
users = [users];
} else {
users = await serverProxy.users.getUsers();
const searchParams = {};
for (const key in filter) {
if (filter[key] && key !== 'self') {
searchParams[key] = filter[key];
}
}
users = await serverProxy.users.getUsers(new URLSearchParams(searchParams).toString());
}

users = users.map((user) => new User(user));
Expand Down Expand Up @@ -163,8 +152,7 @@

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

return filter.jobID ? task.jobs.filter((job) => job.id === filter.jobID) : task.jobs;
}
Expand Down Expand Up @@ -203,9 +191,8 @@
}
}

const users = (await serverProxy.users.getUsers()).map((userData) => new User(userData));
const tasksData = await serverProxy.tasks.getTasks(searchParams.toString());
const tasks = tasksData.map((task) => attachUsers(task, users)).map((task) => new Task(task));
const tasks = tasksData.map((task) => new Task(task));

tasks.count = tasksData.count;

Expand Down
14 changes: 4 additions & 10 deletions cvat-core/src/server-proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -500,20 +500,14 @@
}
}

async function getUsers(id = null) {
async function getUsers(filter = 'page_size=all') {
const { backendAPI } = config;

let response = null;
try {
if (id === null) {
response = await Axios.get(`${backendAPI}/users?page_size=all`, {
proxy: config.proxy,
});
} else {
response = await Axios.get(`${backendAPI}/users/${id}`, {
proxy: config.proxy,
});
}
response = await Axios.get(`${backendAPI}/users?${filter}`, {
proxy: config.proxy,
});
} catch (errorData) {
throw generateError(errorData);
}
Expand Down
9 changes: 7 additions & 2 deletions cvat-core/src/session.js
Original file line number Diff line number Diff line change
Expand Up @@ -686,6 +686,8 @@
}
}

if (data.assignee) data.assignee = new User(data.assignee);

Object.defineProperties(
this,
Object.freeze({
Expand Down Expand Up @@ -883,6 +885,9 @@
}
}

if (data.assignee) data.assignee = new User(data.assignee);
if (data.owner) data.owner = new User(data.owner);

data.labels = [];
data.jobs = [];
data.files = Object.freeze({
Expand Down Expand Up @@ -1440,7 +1445,7 @@
if (this.id) {
const jobData = {
status: this.status,
assignee: this.assignee ? this.assignee.id : null,
assignee_id: this.assignee ? this.assignee.id : null,
};

await serverProxy.jobs.saveJob(this.id, jobData);
Expand Down Expand Up @@ -1649,7 +1654,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,
assignee_id: this.assignee ? this.assignee.id : null,
name: this.name,
bug_tracker: this.bugTracker,
labels: [...this.labels.map((el) => el.toJSON())],
Expand Down
36 changes: 30 additions & 6 deletions cvat-core/tests/mocks/dummy-data.mock.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,11 @@ const tasksDummyData = {
name: 'Test',
size: 1,
mode: 'annotation',
owner: 1,
owner: {
url: 'http://localhost:7000/api/v1/users/1',
id: 1,
username: 'admin',
},
assignee: null,
bug_tracker: '',
created_date: '2019-09-05T11:59:22.987942Z',
Expand Down Expand Up @@ -194,7 +198,11 @@ const tasksDummyData = {
name: 'Image Task',
size: 9,
mode: 'annotation',
owner: 1,
owner: {
url: 'http://localhost:7000/api/v1/users/1',
id: 1,
username: 'admin',
},
assignee: null,
bug_tracker: '',
created_date: '2019-06-18T13:05:08.941304+03:00',
Expand Down Expand Up @@ -239,7 +247,11 @@ const tasksDummyData = {
name: 'Video Task',
size: 5002,
mode: 'interpolation',
owner: 1,
owner: {
url: 'http://localhost:7000/api/v1/users/1',
id: 1,
username: 'admin',
},
assignee: null,
bug_tracker: '',
created_date: '2019-06-21T16:34:49.199691+03:00',
Expand Down Expand Up @@ -558,7 +570,11 @@ const tasksDummyData = {
name: 'Test Task',
size: 5002,
mode: 'interpolation',
owner: 2,
owner: {
url: 'http://localhost:7000/api/v1/users/2',
id: 2,
username: 'bsekache',
},
assignee: null,
bug_tracker: '',
created_date: '2019-05-16T13:08:00.621747+03:00',
Expand Down Expand Up @@ -767,7 +783,11 @@ const tasksDummyData = {
name: 'Video',
size: 75,
mode: 'interpolation',
owner: 1,
owner: {
url: 'http://localhost:7000/api/v1/users/1',
id: 1,
username: 'admin',
},
assignee: null,
bug_tracker: '',
created_date: '2019-05-15T11:40:19.487999+03:00',
Expand Down Expand Up @@ -964,7 +984,11 @@ const tasksDummyData = {
name: 'Labels Set',
size: 9,
mode: 'annotation',
owner: 1,
owner: {
url: 'http://localhost:7000/api/v1/users/1',
id: 1,
username: 'admin',
},
assignee: null,
bug_tracker: 'http://bugtracker.com/issue12345',
created_date: '2019-05-13T15:35:29.871003+03:00',
Expand Down
13 changes: 8 additions & 5 deletions cvat-core/tests/mocks/server-proxy.mock.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ class ServerProxy {
const object = tasksDummyData.results.filter((task) => task.id === id)[0];
for (const prop in taskData) {
if (
Object.prototype.hasOwnProperty.call(taskData, prop) &&
Object.prototype.hasOwnProperty.call(object, prop)
Object.prototype.hasOwnProperty.call(taskData, prop)
&& Object.prototype.hasOwnProperty.call(object, prop)
) {
object[prop] = taskData[prop];
}
Expand All @@ -110,7 +110,10 @@ class ServerProxy {
name: taskData.name,
size: 5000,
mode: 'interpolation',
owner: 2,
owner: {
id: 2,
username: 'bsekache',
},
assignee: null,
bug_tracker: taskData.bug_tracker,
created_date: '2019-05-16T13:08:00.621747+03:00',
Expand Down Expand Up @@ -175,8 +178,8 @@ class ServerProxy {

for (const prop in jobData) {
if (
Object.prototype.hasOwnProperty.call(jobData, prop) &&
Object.prototype.hasOwnProperty.call(object, prop)
Object.prototype.hasOwnProperty.call(jobData, prop)
&& Object.prototype.hasOwnProperty.call(object, prop)
) {
object[prop] = jobData[prop];
}
Expand Down
Loading

0 comments on commit 8334f06

Please sign in to comment.