Skip to content

Commit

Permalink
React-UI: settings (#1164)
Browse files Browse the repository at this point in the history
* Image filters: brightness, contrast, saturation
* Auto saving
* Frame auto fit
* Player speed
* Leave confirmation for unsaved changes
  • Loading branch information
ActiveChooN committed Feb 27, 2020
1 parent 90d594d commit 5645cdf
Show file tree
Hide file tree
Showing 20 changed files with 653 additions and 121 deletions.
16 changes: 8 additions & 8 deletions cvat-core/src/session.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,6 @@
return result;
},

async hasUnsavedChanges() {
const result = await PluginRegistry
.apiWrapper.call(this, prototype.annotations.hasUnsavedChanges);
return result;
},

async merge(objectStates) {
const result = await PluginRegistry
.apiWrapper.call(this, prototype.annotations.merge, objectStates);
Expand All @@ -107,6 +101,12 @@
.apiWrapper.call(this, prototype.annotations.exportDataset, format);
return result;
},

hasUnsavedChanges() {
const result = prototype.annotations
.hasUnsavedChanges.implementation.call(this);
return result;
},
},
writable: true,
}),
Expand Down Expand Up @@ -381,14 +381,14 @@
* @async
*/
/**
* Indicate if there are any changes in
* Method indicates if there are any changes in
* annotations which haven't been saved on a server
* </br><b> This function cannot be wrapped with a plugin </b>
* @method hasUnsavedChanges
* @memberof Session.annotations
* @returns {boolean}
* @throws {module:API.cvat.exceptions.PluginError}
* @instance
* @async
*/
/**
* Export as a dataset.
Expand Down
44 changes: 22 additions & 22 deletions cvat-core/tests/api/annotations.js
Original file line number Diff line number Diff line change
Expand Up @@ -341,11 +341,11 @@ describe('Feature: save annotations', () => {
zOrder: 0,
});

expect(await task.annotations.hasUnsavedChanges()).toBe(false);
expect(task.annotations.hasUnsavedChanges()).toBe(false);
await task.annotations.put([state]);
expect(await task.annotations.hasUnsavedChanges()).toBe(true);
expect(task.annotations.hasUnsavedChanges()).toBe(true);
await task.annotations.save();
expect(await task.annotations.hasUnsavedChanges()).toBe(false);
expect(task.annotations.hasUnsavedChanges()).toBe(false);
annotations = await task.annotations.get(0);
expect(annotations).toHaveLength(length + 1);
});
Expand All @@ -354,23 +354,23 @@ describe('Feature: save annotations', () => {
const task = (await window.cvat.tasks.get({ id: 101 }))[0];
const annotations = await task.annotations.get(0);

expect(await task.annotations.hasUnsavedChanges()).toBe(false);
expect(task.annotations.hasUnsavedChanges()).toBe(false);
annotations[0].occluded = true;
await annotations[0].save();
expect(await task.annotations.hasUnsavedChanges()).toBe(true);
expect(task.annotations.hasUnsavedChanges()).toBe(true);
await task.annotations.save();
expect(await task.annotations.hasUnsavedChanges()).toBe(false);
expect(task.annotations.hasUnsavedChanges()).toBe(false);
});

test('delete & save annotations for a task', async () => {
const task = (await window.cvat.tasks.get({ id: 101 }))[0];
const annotations = await task.annotations.get(0);

expect(await task.annotations.hasUnsavedChanges()).toBe(false);
expect(task.annotations.hasUnsavedChanges()).toBe(false);
await annotations[0].delete();
expect(await task.annotations.hasUnsavedChanges()).toBe(true);
expect(task.annotations.hasUnsavedChanges()).toBe(true);
await task.annotations.save();
expect(await task.annotations.hasUnsavedChanges()).toBe(false);
expect(task.annotations.hasUnsavedChanges()).toBe(false);
});

test('create & save annotations for a job', async () => {
Expand All @@ -387,11 +387,11 @@ describe('Feature: save annotations', () => {
zOrder: 0,
});

expect(await job.annotations.hasUnsavedChanges()).toBe(false);
expect(job.annotations.hasUnsavedChanges()).toBe(false);
await job.annotations.put([state]);
expect(await job.annotations.hasUnsavedChanges()).toBe(true);
expect(job.annotations.hasUnsavedChanges()).toBe(true);
await job.annotations.save();
expect(await job.annotations.hasUnsavedChanges()).toBe(false);
expect(job.annotations.hasUnsavedChanges()).toBe(false);
annotations = await job.annotations.get(0);
expect(annotations).toHaveLength(length + 1);
});
Expand All @@ -400,23 +400,23 @@ describe('Feature: save annotations', () => {
const job = (await window.cvat.jobs.get({ jobID: 100 }))[0];
const annotations = await job.annotations.get(0);

expect(await job.annotations.hasUnsavedChanges()).toBe(false);
expect(job.annotations.hasUnsavedChanges()).toBe(false);
annotations[0].points = [0, 100, 200, 300];
await annotations[0].save();
expect(await job.annotations.hasUnsavedChanges()).toBe(true);
expect(job.annotations.hasUnsavedChanges()).toBe(true);
await job.annotations.save();
expect(await job.annotations.hasUnsavedChanges()).toBe(false);
expect(job.annotations.hasUnsavedChanges()).toBe(false);
});

test('delete & save annotations for a job', async () => {
const job = (await window.cvat.jobs.get({ jobID: 100 }))[0];
const annotations = await job.annotations.get(0);

expect(await job.annotations.hasUnsavedChanges()).toBe(false);
expect(job.annotations.hasUnsavedChanges()).toBe(false);
await annotations[0].delete();
expect(await job.annotations.hasUnsavedChanges()).toBe(true);
expect(job.annotations.hasUnsavedChanges()).toBe(true);
await job.annotations.save();
expect(await job.annotations.hasUnsavedChanges()).toBe(false);
expect(job.annotations.hasUnsavedChanges()).toBe(false);
});

test('delete & save annotations for a job when there are a track and a shape with the same id', async () => {
Expand Down Expand Up @@ -658,11 +658,11 @@ describe('Feature: clear annotations', () => {
expect(annotations.length).not.toBe(0);
annotations[0].occluded = true;
await annotations[0].save();
expect(await task.annotations.hasUnsavedChanges()).toBe(true);
expect(task.annotations.hasUnsavedChanges()).toBe(true);
await task.annotations.clear(true);
annotations = await task.annotations.get(0);
expect(annotations.length).not.toBe(0);
expect(await task.annotations.hasUnsavedChanges()).toBe(false);
expect(task.annotations.hasUnsavedChanges()).toBe(false);
});

test('clear annotations with reload in a job', async () => {
Expand All @@ -671,11 +671,11 @@ describe('Feature: clear annotations', () => {
expect(annotations.length).not.toBe(0);
annotations[0].occluded = true;
await annotations[0].save();
expect(await job.annotations.hasUnsavedChanges()).toBe(true);
expect(job.annotations.hasUnsavedChanges()).toBe(true);
await job.annotations.clear(true);
annotations = await job.annotations.get(0);
expect(annotations.length).not.toBe(0);
expect(await job.annotations.hasUnsavedChanges()).toBe(false);
expect(job.annotations.hasUnsavedChanges()).toBe(false);
});

test('clear annotations with bad reload parameter', async () => {
Expand Down
Loading

0 comments on commit 5645cdf

Please sign in to comment.