Different fixes for Release 0.5.0 Part 2 (#670)

* Fixed: Invalid labels parsing (#628)
* Updated changelog
* Improved error messages on a client side
* Updated changelog
* Fixed register
main
Boris Sekachev 7 years ago committed by Nikita Manovich
parent 553731ed70
commit e15340d625

1
.gitignore vendored

@ -1,5 +1,6 @@
# Project Specific # Project Specific
/data/ /data/
/models/
/share/ /share/
/static/ /static/
/db.sqlite3 /db.sqlite3

@ -23,12 +23,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed ### Changed
- Outside and keyframe buttons in the side panel for all interpolation shapes (they were only for boxes before) - Outside and keyframe buttons in the side panel for all interpolation shapes (they were only for boxes before)
- Improved error messages on client side (#511)
### Deprecated ### Deprecated
- -
### Removed ### Removed
- - "Flip images" has been removed. UI now contains rotation features.
### Fixed ### Fixed
- Incorrect width of shapes borders in some cases - Incorrect width of shapes borders in some cases
@ -41,6 +42,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Exception in attribute annotation mode when a label are switched to a value without any attributes - Exception in attribute annotation mode when a label are switched to a value without any attributes
- Handling of wrong labelamp json file in auto annotation (<https://github.com/opencv/cvat/issues/554>) - Handling of wrong labelamp json file in auto annotation (<https://github.com/opencv/cvat/issues/554>)
- No default attributes in dumped annotation (<https://github.com/opencv/cvat/issues/601>) - No default attributes in dumped annotation (<https://github.com/opencv/cvat/issues/601>)
- Required field "Frame Filter" on admin page during a task modifying (#666)
- Dump annotation errors for a task with several segments (#610, #500)
- Invalid label parsing during a task creating (#628)
- Button "Open Task" in the annotation view
- Creating a video task with 0 overlap
### Security ### Security
- -

@ -5,7 +5,6 @@
/* global /* global
require:false require:false
encodeURIComponent:false
*/ */
(() => { (() => {
@ -16,6 +15,19 @@
const store = require('store'); const store = require('store');
const config = require('./config'); const config = require('./config');
function generateError(errorData, baseMessage) {
if (errorData.response) {
const message = `${baseMessage}. `
+ `${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"
return new ServerError(message, 0);
}
class ServerProxy { class ServerProxy {
constructor() { constructor() {
const Axios = require('axios'); const Axios = require('axios');
@ -37,11 +49,7 @@
proxy: config.proxy, proxy: config.proxy,
}); });
} catch (errorData) { } catch (errorData) {
const code = errorData.response ? errorData.response.status : errorData.code; throw generateError(errorData, 'Could not get "about" information from the server');
throw new ServerError(
'Could not get "about" information from the server',
code,
);
} }
return response.data; return response.data;
@ -57,11 +65,7 @@
proxy: config.proxy, proxy: config.proxy,
}); });
} catch (errorData) { } catch (errorData) {
const code = errorData.response ? errorData.response.status : errorData.code; throw generateError(errorData, 'Could not get "share" information from the server');
throw new ServerError(
'Could not get "share" information from the server',
code,
);
} }
return response.data; return response.data;
@ -78,11 +82,7 @@
}, },
}); });
} catch (errorData) { } catch (errorData) {
const code = errorData.response ? errorData.response.status : errorData.code; throw generateError(errorData, 'Could not send an exception to the server');
throw new ServerError(
'Could not send an exception to the server',
code,
);
} }
} }
@ -95,11 +95,7 @@
proxy: config.proxy, proxy: config.proxy,
}); });
} catch (errorData) { } catch (errorData) {
const code = errorData.response ? errorData.response.status : errorData.code; throw generateError(errorData, 'Could not get annotation formats from the server');
throw new ServerError(
'Could not get annotation formats from the server',
code,
);
} }
return response.data; return response.data;
@ -118,13 +114,12 @@
}); });
response = await Axios.post(`${config.backendAPI}/auth/register`, data, { response = await Axios.post(`${config.backendAPI}/auth/register`, data, {
proxy: config.proxy, proxy: config.proxy,
headers: {
'Content-Type': 'application/json',
},
}); });
} catch (errorData) { } catch (errorData) {
const code = errorData.response ? errorData.response.status : errorData.code; throw generateError(errorData, `Could not register '${username}' user on the server`);
throw new ServerError(
`Could not register '${username}' user on the server`,
code,
);
} }
return response.data; return response.data;
@ -145,12 +140,7 @@
}, },
); );
} catch (errorData) { } catch (errorData) {
const code = errorData.response throw generateError(errorData, 'Could not login on a server');
? errorData.response.status : errorData.code;
throw new ServerError(
'Could not login on a server',
code,
);
} }
if (authenticationResponse.headers['set-cookie']) { if (authenticationResponse.headers['set-cookie']) {
@ -171,11 +161,7 @@
proxy: config.proxy, proxy: config.proxy,
}); });
} catch (errorData) { } catch (errorData) {
const code = errorData.response ? errorData.response.status : errorData.code; throw generateError(errorData, 'Could not logout from the server');
throw new ServerError(
'Could not logout from the server',
code,
);
} }
store.remove('token'); store.remove('token');
@ -205,11 +191,7 @@
proxy: config.proxy, proxy: config.proxy,
}); });
} catch (errorData) { } catch (errorData) {
const code = errorData.response ? errorData.response.status : errorData.code; throw generateError(errorData, 'Could not get tasks from a server');
throw new ServerError(
'Could not get tasks from a server',
code,
);
} }
response.data.results.count = response.data.count; response.data.results.count = response.data.count;
@ -227,11 +209,7 @@
}, },
}); });
} catch (errorData) { } catch (errorData) {
const code = errorData.response ? errorData.response.status : errorData.code; throw generateError(errorData, 'Could not save the task on the server');
throw new ServerError(
'Could not save the task on the server',
code,
);
} }
} }
@ -241,11 +219,7 @@
try { try {
await Axios.delete(`${backendAPI}/tasks/${id}`); await Axios.delete(`${backendAPI}/tasks/${id}`);
} catch (errorData) { } catch (errorData) {
const code = errorData.response ? errorData.response.status : errorData.code; throw generateError(errorData, 'Could not delete the task from the server');
throw new ServerError(
'Could not delete the task from the server',
code,
);
} }
} }
@ -267,10 +241,9 @@
} else if (response.data.state === 'Failed') { } else if (response.data.state === 'Failed') {
// If request has been successful, but task hasn't been created // If request has been successful, but task hasn't been created
// Then passed data is wrong and we can pass code 400 // Then passed data is wrong and we can pass code 400
reject(new ServerError( const message = 'Could not create the task on the server. '
'Could not create the task on the server', + `${response.data.message}.`;
400, reject(new ServerError(message, 400));
));
} else { } else {
// If server has another status, it is unexpected // If server has another status, it is unexpected
// Therefore it is server error and we can pass code 500 // Therefore it is server error and we can pass code 500
@ -280,13 +253,9 @@
)); ));
} }
} catch (errorData) { } catch (errorData) {
const code = errorData.response reject(
? errorData.response.status : errorData.code; generateError(errorData, 'Could not put task to the server'),
);
reject(new ServerError(
'Data uploading error occurred',
code,
));
} }
} }
@ -314,11 +283,7 @@
}, },
}); });
} catch (errorData) { } catch (errorData) {
const code = errorData.response ? errorData.response.status : errorData.code; throw generateError(errorData, 'Could not put task to the server');
throw new ServerError(
'Could not put task to the server',
code,
);
} }
onUpdate('The data is being uploaded to the server..'); onUpdate('The data is being uploaded to the server..');
@ -327,12 +292,13 @@
proxy: config.proxy, proxy: config.proxy,
}); });
} catch (errorData) { } catch (errorData) {
await deleteTask(response.data.id); try {
const code = errorData.response ? errorData.response.status : errorData.code; await deleteTask(response.data.id);
throw new ServerError( } catch (_) {
'Could not put data to the server', // ignore
code, }
);
throw generateError(errorData, 'Could not put data to the server');
} }
try { try {
@ -342,7 +308,6 @@
throw createException; throw createException;
} }
const createdTask = await getTasks(`?id=${response.id}`); const createdTask = await getTasks(`?id=${response.id}`);
return createdTask[0]; return createdTask[0];
} }
@ -356,11 +321,7 @@
proxy: config.proxy, proxy: config.proxy,
}); });
} catch (errorData) { } catch (errorData) {
const code = errorData.response ? errorData.response.status : errorData.code; throw generateError(errorData, 'Could not get jobs from a server');
throw new ServerError(
'Could not get jobs from a server',
code,
);
} }
return response.data; return response.data;
@ -377,11 +338,7 @@
}, },
}); });
} catch (errorData) { } catch (errorData) {
const code = errorData.response ? errorData.response.status : errorData.code; throw generateError(errorData, 'Could not save the job on the server');
throw new ServerError(
'Could not save the job on the server',
code,
);
} }
} }
@ -394,11 +351,7 @@
proxy: config.proxy, proxy: config.proxy,
}); });
} catch (errorData) { } catch (errorData) {
const code = errorData.response ? errorData.response.status : errorData.code; throw generateError(errorData, 'Could not get users from the server');
throw new ServerError(
'Could not get users from the server',
code,
);
} }
return response.data.results; return response.data.results;
@ -413,11 +366,7 @@
proxy: config.proxy, proxy: config.proxy,
}); });
} catch (errorData) { } catch (errorData) {
const code = errorData.response ? errorData.response.status : errorData.code; throw generateError(errorData, 'Could not get user data from the server');
throw new ServerError(
'Could not get user data from the server',
code,
);
} }
return response.data; return response.data;
@ -433,10 +382,9 @@
responseType: 'blob', responseType: 'blob',
}); });
} catch (errorData) { } catch (errorData) {
const code = errorData.response ? errorData.response.status : errorData.code; throw generateError(
throw new ServerError( errorData,
`Could not get frame ${frame} for the task ${tid} from the server`, `Could not get frame ${frame} for the task ${tid} from the server`,
code,
); );
} }
@ -452,10 +400,9 @@
proxy: config.proxy, proxy: config.proxy,
}); });
} catch (errorData) { } catch (errorData) {
const code = errorData.response ? errorData.response.status : errorData.code; throw generateError(
throw new ServerError( errorData,
`Could not get frame meta info for the task ${tid} from the server`, `Could not get frame meta info for the task ${tid} from the server`,
code,
); );
} }
@ -472,10 +419,9 @@
proxy: config.proxy, proxy: config.proxy,
}); });
} catch (errorData) { } catch (errorData) {
const code = errorData.response ? errorData.response.status : errorData.code; throw generateError(
throw new ServerError( errorData,
`Could not get annotations for the ${session} ${id} from the server`, `Could not get annotations for the ${session} ${id} from the server`,
code,
); );
} }
@ -504,10 +450,9 @@
}, },
}); });
} catch (errorData) { } catch (errorData) {
const code = errorData.response ? errorData.response.status : errorData.code; throw generateError(
throw new ServerError( errorData,
`Could not updated annotations for the ${session} ${id} on the server`, `Could not ${action} annotations for the ${session} ${id} on the server`,
code,
); );
} }
@ -535,13 +480,10 @@
resolve(); resolve();
} }
} catch (errorData) { } catch (errorData) {
const code = errorData.response reject(generateError(
? errorData.response.status : errorData.code; errorData,
const error = new ServerError(
`Could not upload annotations for the ${session} ${id}`, `Could not upload annotations for the ${session} ${id}`,
code, ));
);
reject(error);
} }
} }
@ -569,13 +511,10 @@
resolve(url); resolve(url);
} }
} catch (errorData) { } catch (errorData) {
const code = errorData.response reject(generateError(
? errorData.response.status : errorData.code; errorData,
const error = new ServerError(
`Could not dump annotations for the task ${id} from the server`, `Could not dump annotations for the task ${id} from the server`,
code, ));
);
reject(error);
} }
} }

@ -28,6 +28,7 @@ class TaskView {
async _remove() { async _remove() {
try { try {
await this._task.delete(); await this._task.delete();
this._disable();
} catch (exception) { } catch (exception) {
let { message } = exception; let { message } = exception;
if (exception instanceof window.cvat.exceptions.ServerError) { if (exception instanceof window.cvat.exceptions.ServerError) {
@ -35,8 +36,6 @@ class TaskView {
} }
showMessage(message); showMessage(message);
} }
this._disable();
} }
_update() { _update() {
@ -49,7 +48,7 @@ class TaskView {
$('#dashboardCancelUpdate').on('click', () => { $('#dashboardCancelUpdate').on('click', () => {
dashboardUpdateModal.remove(); dashboardUpdateModal.remove();
}); });
$('#dashboardSubmitUpdate').on('click', () => { $('#dashboardSubmitUpdate').on('click', async () => {
let jsonLabels = null; let jsonLabels = null;
try { try {
jsonLabels = LabelsInfo.deserialize($('#dashboardNewLabels').prop('value')); jsonLabels = LabelsInfo.deserialize($('#dashboardNewLabels').prop('value'));
@ -61,7 +60,7 @@ class TaskView {
try { try {
const labels = jsonLabels.map(label => new window.cvat.classes.Label(label)); const labels = jsonLabels.map(label => new window.cvat.classes.Label(label));
this._task.labels = labels; this._task.labels = labels;
this._task.save(); await this._task.save();
showMessage('Task has been successfully updated'); showMessage('Task has been successfully updated');
} catch (exception) { } catch (exception) {
let { message } = exception; let { message } = exception;

File diff suppressed because one or more lines are too long

@ -156,7 +156,7 @@ class LabelsInfo {
static deserialize(serialized) { static deserialize(serialized) {
const normalized = serialized.replace(/'+/g, '\'').replace(/"+/g, '"').replace(/\s+/g, ' ').trim(); const normalized = serialized.replace(/'+/g, '\'').replace(/\s+/g, ' ').trim();
const fragments = String.customSplit(normalized, ' '); const fragments = String.customSplit(normalized, ' ');
const deserialized = []; const deserialized = [];

Loading…
Cancel
Save