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
/data/
/models/
/share/
/static/
/db.sqlite3

@ -23,12 +23,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed
- 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
-
### Removed
-
- "Flip images" has been removed. UI now contains rotation features.
### Fixed
- 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
- 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>)
- 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
-

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

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

File diff suppressed because one or more lines are too long

@ -156,7 +156,7 @@ class LabelsInfo {
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 deserialized = [];

Loading…
Cancel
Save