Commit df429158 by Fernando Martínez Santiago

Merge branch 'develop' of http://scm.ujaen.es/softuno/pictogram into develop

parents 812265a4 391ccd87
...@@ -86,10 +86,14 @@ module.exports = { ...@@ -86,10 +86,14 @@ module.exports = {
if (!params.id_sup) if (!params.id_sup)
return res.badRequest("No supervisor defined"); return res.badRequest("No supervisor defined");
if (!params.lang)
return res.badRequest("No lang defined");
MetaMethod.create({ MetaMethod.create({
"name": params.name, "name": params.name,
"description": "", "description": "",
"supervisor": params.id_sup "supervisor": params.id_sup,
"lang": params.lang
}) })
.then(function(createdMethod){ .then(function(createdMethod){
return res.ok(createdMethod); return res.ok(createdMethod);
......
...@@ -132,16 +132,29 @@ module.exports = { ...@@ -132,16 +132,29 @@ module.exports = {
}, },
// FERNANDO: avoid method name duplicates /*
// * Saves a method as a template
// Saves a method as a template * @param {request} req
// * {
* id_stu: studentId,
* id_sup: supervisorID
* lang: student lang code
* }
* @param {response} res
* {
* id: methodId,
* supervisor: supervisorId
* lang: {string} language code
* description: {string}
* }
*/
save: function(req, res){ save: function(req, res){
var params = req.allParams(); var params = req.allParams();
if (!params.id_met) return res.json(500, {error: "No method defined"}); if (!params.id_met) return res.json(500, {error: "No method defined"});
if (!params.id_sup) return res.json(500, {error: "No supervisor defined"}); if (!params.id_sup) return res.json(500, {error: "No supervisor defined"});
if (!params.lang) return res.json(500, {error: "No lang defined"});
Method.findOne(params.id_met).populate('instructions').exec(function(err, method) { Method.findOne(params.id_met).populate('instructions').exec(function(err, method) {
if (err){ if (err){
...@@ -152,7 +165,8 @@ module.exports = { ...@@ -152,7 +165,8 @@ module.exports = {
MetaMethod.create({ MetaMethod.create({
"name": method.name, "name": method.name,
"description": method.description, "description": method.description,
"supervisor": params.id_sup "supervisor": params.id_sup,
"lang": params.lang
}).exec(function(err, createdMethod){ }).exec(function(err, createdMethod){
if (err){ if (err){
sails.log.debug("Create Method error: " + err); sails.log.debug("Create Method error: " + err);
......
...@@ -849,7 +849,15 @@ module.exports = { ...@@ -849,7 +849,15 @@ module.exports = {
* legend_size: '[small]/large', * legend_size: '[small]/large',
* expression: 'custom expression', * expression: 'custom expression',
* color: any valid HEX color or [null] * color: any valid HEX color or [null]
* } * },
* picto: {
* id: <pictoID>,
* source: <sourceID>,
* owner: <ownerID> or null,
* id: <pictoID>,
* uri: <URL to image>,
* category: <categoryID>
* }
* } * }
*/ */
add_picto: function (req, res) { add_picto: function (req, res) {
......
...@@ -571,7 +571,15 @@ module.exports = { ...@@ -571,7 +571,15 @@ module.exports = {
* legend_size: '[small]/large', * legend_size: '[small]/large',
* expression: 'custom expression', * expression: 'custom expression',
* color: any valid HEX color or [null] * color: any valid HEX color or [null]
* } * },
* picto: {
* id: <pictoID>,
* source: <sourceID>,
* owner: <ownerID> or null,
* id: <pictoID>,
* uri: <URL to image>,
* category: <categoryID>
* }
* } * }
*/ */
pictoInfo: function(id_stu_pic, cb) { pictoInfo: function(id_stu_pic, cb) {
......
...@@ -31,7 +31,9 @@ module.exports = function(req, res, next) { ...@@ -31,7 +31,9 @@ module.exports = function(req, res, next) {
// We have a token, let's verify and decode it // We have a token, let's verify and decode it
// //
sailsTokenAuth.verifyToken(token, function(err, token) { sailsTokenAuth.verifyToken(token, function(err, token) {
if (err) return res.json(401, {err: 'Invalid token ' + token}); if (err)
return res.json(401, {message: 'Invalid token: ' + err.message});
req.token = token; req.token = token;
next(); next();
}); });
......
...@@ -299,9 +299,10 @@ ...@@ -299,9 +299,10 @@
"serial_not_created": "Serial number couldn't be created", "serial_not_created": "Serial number couldn't be created",
"server_error": "An error has been reported when connecting to the server.", "server_error": "An error has been reported when connecting to the server.",
"session": "Session", "session": "Session",
"session_closed": "Pending session is now closed",
"session_mean_length": "Session mean length: {{hours}} hours", "session_mean_length": "Session mean length: {{hours}} hours",
"session_notes": "Session notes", "session_notes": "Session notes",
"session_closed": "Pending session is now closed", "session_recommendation": "If the session is going to be controlled from a tablet (using the app in therapist mode), please, do not use this page to avoid interferences.",
"sessions": "Sessions", "sessions": "Sessions",
"sessions_of": "Sessions of", "sessions_of": "Sessions of",
"setup": "Setup", "setup": "Setup",
......
...@@ -300,9 +300,10 @@ ...@@ -300,9 +300,10 @@
"serial_not_created": "No se ha podido crear el número de serie", "serial_not_created": "No se ha podido crear el número de serie",
"server_error": "No se ha podido conectar con el servidor.", "server_error": "No se ha podido conectar con el servidor.",
"session": "Sesión", "session": "Sesión",
"session_closed": "La sesión abierta está ahora cerrada",
"session_mean_length": "Duración media de sesión: {{hours}} horas", "session_mean_length": "Duración media de sesión: {{hours}} horas",
"session_notes": "Notas de sesión", "session_notes": "Notas de sesión",
"session_closed": "La sesión abierta está ahora cerrada", "session_recommendation": "Si la sesión se va a controlar desde una tablet (usando la app en modo terapeuta), por favor, no use esta página evitar interferencias.",
"sessions_of": "Sesiones de", "sessions_of": "Sesiones de",
"sessions": "Sesiones", "sessions": "Sesiones",
"setup": "Configuración", "setup": "Configuración",
......
...@@ -163,9 +163,9 @@ dashboardControllers.controller('AddPictoCtrl', function ( ...@@ -163,9 +163,9 @@ dashboardControllers.controller('AddPictoCtrl', function (
controller: 'CropImgCtrl', controller: 'CropImgCtrl',
size: 'lg', size: 'lg',
resolve: { resolve: {
picFile: () => {return $scope.picFile;}, picFile: () => {return $scope.picFile},
uploadFunc: () => {return $scope.upload;}, uploadFunc: () => {return $scope.upload},
progress: () => {return $scope.progress;} progress: () => {return $scope.progress}
} }
}); });
modalInstance.result.then(function () { modalInstance.result.then(function () {
...@@ -198,7 +198,8 @@ dashboardControllers.controller('AddPictoCtrl', function ( ...@@ -198,7 +198,8 @@ dashboardControllers.controller('AddPictoCtrl', function (
$scope.pictos.push(picto); $scope.pictos.push(picto);
$scope.load_own_pictos(); $scope.load_own_pictos();
cb(); cb();
$scope.close(picto.id); if (!onlyOwn)
$scope.close(picto.id);
}); });
}); });
}, },
......
...@@ -164,7 +164,7 @@ dashboardControllers.controller('StudentInstructionsCtrl', function StudentInstr ...@@ -164,7 +164,7 @@ dashboardControllers.controller('StudentInstructionsCtrl', function StudentInstr
$scope.save_as_template = function(method){ $scope.save_as_template = function(method){
$http $http
.post(config.backend+'/method/save', { 'id_met': method.id, 'id_sup': $scope.user.id }) .post(config.backend+'/method/save', { 'id_met': method.id, 'id_sup': $scope.user.id, 'lang': $scope.user.lang })
.then( //success .then( //success
function(data, status, headers, config) { function(data, status, headers, config) {
console.log('Saved method as template:' + JSON.stringify(data)); console.log('Saved method as template:' + JSON.stringify(data));
...@@ -180,7 +180,7 @@ dashboardControllers.controller('StudentInstructionsCtrl', function StudentInstr ...@@ -180,7 +180,7 @@ dashboardControllers.controller('StudentInstructionsCtrl', function StudentInstr
} }
,function(data, status, headers, config) { //error ,function(data, status, headers, config) { //error
console.log("Error from API: " + data.error+"("+data.status+")"); console.log("Error from API: " + data.error+"("+data.status+")");
ngToast.success({ ngToast.warning({
content: $translate.instant('method_name_duplicated', {method_name: method.name}), content: $translate.instant('method_name_duplicated', {method_name: method.name}),
timeout: 6000 // By default 4000 timeout: 6000 // By default 4000
}); });
......
...@@ -134,6 +134,8 @@ dashboardControllers.controller('StudentSetupCtrl', function StudentSetupCtrl( ...@@ -134,6 +134,8 @@ dashboardControllers.controller('StudentSetupCtrl', function StudentSetupCtrl(
$scope.formUser.username = data.username; $scope.formUser.username = data.username;
$scope.formUser.license_number = data.license ? data.license.number : ''; $scope.formUser.license_number = data.license ? data.license.number : '';
$scope.studentData.license = data.license ? data.license : null; $scope.studentData.license = data.license ? data.license : null;
$scope.formUser.password_confirm = '';
$scope.formUser.password = '';
$scope.updateLicenseExpiration(); $scope.updateLicenseExpiration();
// websocket emit update action // websocket emit update action
......
...@@ -44,7 +44,6 @@ ...@@ -44,7 +44,6 @@
</div> </div>
</button> </button>
</div> </div>
<!-- / number of sessions and dropdown button -->
<!-- controls for session recording--> <!-- controls for session recording-->
<div ng-show="studentData.num_peers<2 && section == 'new'" class="form-group"> <div ng-show="studentData.num_peers<2 && section == 'new'" class="form-group">
...@@ -97,6 +96,14 @@ ...@@ -97,6 +96,14 @@
</div> </div>
<!-- first row with instruction select and controls --> <!-- first row with instruction select and controls -->
<div class="alert alert-warning alert-dismissible" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
<span class="glyphicon glyphicon-exclamation-sign text-warning" aria-hidden="true"></span>
{{ 'session_recommendation' | translate }}
</div>
<div id="tries"> <div id="tries">
<!-- alert on non closed session --> <!-- alert on non closed session -->
<div class="alert alert-danger" role="alert" ng-show="ws_recover"> <div class="alert alert-danger" role="alert" ng-show="ws_recover">
......
...@@ -33,12 +33,13 @@ dashboardControllers.controller('InstructionsCtrl', function InstructionsCtrl($s ...@@ -33,12 +33,13 @@ dashboardControllers.controller('InstructionsCtrl', function InstructionsCtrl($s
// Functions // Functions
// //
// Add new method template (metamethod) selected to the student // Add new method template (metamethod)
$scope.add_method = function(){ $scope.add_method = function(){
var new_data = { var new_data = {
name: $translate.instant("new_method"), name: $translate.instant("new_method"),
id_sup: $scope.user.id id_sup: $scope.user.id,
lang: $scope.user.lang,
}; };
$http $http
......
...@@ -111,10 +111,12 @@ module.exports.pictogram = { ...@@ -111,10 +111,12 @@ module.exports.pictogram = {
} }
}, },
// TODO: errores should have a code (number) and a name (string) like "TokenExpired", "UserNotFound"...
error_codes: { error_codes: {
'DUPLICATED_PICTO': 1, 'DUPLICATED_PICTO': 1,
'OFFICE_NOT_FOUND': 2, 'OFFICE_NOT_FOUND': 2,
'SUPERVISOR_NOT_FOUND': 3, 'SUPERVISOR_NOT_FOUND': 3,
'STUDENT_NOT_FOUND': 4 'STUDENT_NOT_FOUND': 4,
'TOKEN_EXPIRED': 5
} }
}; };
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment