Merge remote-tracking branch 'origin/master'

parents faf359be d029a7bb
...@@ -638,22 +638,25 @@ VIEW `v_stu_last_instruction` AS ...@@ -638,22 +638,25 @@ VIEW `v_stu_last_instruction` AS
I.`name` AS `ins_name`, I.`name` AS `ins_name`,
M.`name` AS `met_name`, M.`name` AS `met_name`,
M.`id_stu` AS `id_stu` M.`id_stu` AS `id_stu`
from FROM
`working_session` AS WS join `working_session` AS WS join
`instruction` AS I join `instruction` AS I join
`method` AS M `method` AS M join
where (SELECT M.`id_stu`AS id_stu,
WS.`id_ins` =I.`id` MAX(WS.begin) AS TIME
and I.`id_met` = M.`id` FROM
and WS.`begin` = (SELECT `working_session` AS WS join
MAX(WS.begin) `instruction` AS I join
FROM `method` AS M
`working_session` AS WS join WHERE
`instruction` AS I join WS.`id_ins` =I.`id`
`method` AS M and I.`id_met` = M.`id`
WHERE group by M.`id_stu`) AS LAST_WS
WS.`id_ins` =I.`id` WHERE
and I.`id_met` = M.`id`); LAST_WS.TIME = WS.begin and
LAST_WS.id_stu = M.`id_stu` and
WS.`id_ins` =I.`id`
and I.`id_met` = M.`id`;
-- --
-- VIEW `v_stu_last_instruction` -- VIEW `v_stu_last_instruction`
......
...@@ -798,25 +798,28 @@ module.exports = { ...@@ -798,25 +798,28 @@ module.exports = {
sails.log.debug("Inside actions_batch"); sails.log.debug("Inside actions_batch");
if (!params.actions)
return res.json(400, {'error': "no actions"});
// We loop through the actions and store them in the database // We loop through the actions and store them in the database
async.forEach(params.actions, function(action, cb){ async.forEach(params.actions, function(action, cb){
var id_dev = null; var id_dev = null;
if (action.attributes.id_dev) if (action.attributes.id_dev)
var id_dev = action.attributes.id_dev; id_dev = action.attributes.id_dev;
var id_sup = null; var id_sup = null;
if(action.attributes.id_sup) if(action.attributes.id_sup)
id_sup = action.attributes.sup; id_sup = action.attributes.sup;
var id_stu = null; var id_stu = null;
if(action.attributes.id_stu) if (action.attributes.id_stu)
id_stu = action.attributes.id_stu; id_stu = action.attributes.id_stu;
var desc = null; var desc = null;
if(action.attributes.picto) if(action.attributes.picto)
desc = action.attributes.picto; // select, add and delete actions data desc = action.attributes.picto; // select, add and delete actions data
if(action.attributes.pictos) if(action.attributes.pictos)
desc = action.attributes.pictos; // show action data desc = action.attributes.pictos; // show action data
Action.create({ Action.create({
...@@ -827,19 +830,23 @@ module.exports = { ...@@ -827,19 +830,23 @@ module.exports = {
device: id_dev, device: id_dev,
description: desc description: desc
}).exec(function (err, created) { }).exec(function (err, created) {
if (err) if (err) {
sails.log.error(err.details); console.log(err.details);
sails.log.error(err.details);
return cb(err);
}
else if (created) else if (created)
count++; count++;
cb(); cb();
}); });
}, },
function(err) { // function called when loop is done function(err) { // function called when loop is done
if (err) { if (err) {
sails.log.error(err.details); console.log(err.details);
res.json({'error': err.details}); sails.log.error(err.details);
return res.json({'error': err.details});
} else } else
res.json({'result': 'Ok', 'total': count}); return res.json({'result': 'Ok', 'total': count});
}); });
}, },
......
module.exports = function(req, res, next) { module.exports = function(req, res, next) {
var token; var token = null;
// //
// Token comes in the header // Token comes in the header
...@@ -8,11 +8,10 @@ module.exports = function(req, res, next) { ...@@ -8,11 +8,10 @@ module.exports = function(req, res, next) {
var parts = req.headers.authorization.split(' '); var parts = req.headers.authorization.split(' ');
if (parts.length == 2) { if (parts.length == 2) {
var scheme = parts[0], var scheme = parts[0],
credentials = parts[1]; credentials = parts[1];
if (/^Bearer$/i.test(scheme)) { if (/^Bearer$/i.test(scheme))
token = credentials; token = credentials;
}
} else { } else {
return res.json(401, {err: 'Format is Authorization: Bearer [token]'}); return res.json(401, {err: 'Format is Authorization: Bearer [token]'});
} }
...@@ -24,7 +23,7 @@ module.exports = function(req, res, next) { ...@@ -24,7 +23,7 @@ module.exports = function(req, res, next) {
token = req.param('token'); token = req.param('token');
// We delete the token from param to not mess with blueprints // We delete the token from param to not mess with blueprints
delete req.query.token; delete req.query.token;
} else { } else { // No token provided
return res.json(401, {err: 'No Authorization header was found'}); return res.json(401, {err: 'No Authorization header was found'});
} }
...@@ -32,7 +31,7 @@ module.exports = function(req, res, next) { ...@@ -32,7 +31,7 @@ module.exports = function(req, res, next) {
// We have a token, let's verify it // We have a token, let's verify it
// //
sailsTokenAuth.verifyToken(token, function(err, token) { sailsTokenAuth.verifyToken(token, function(err, token) {
if (err) return res.json(401, {err: 'Invalid token'}); if (err) return res.json(401, {err: 'Invalid token ' + token});
req.token = token; req.token = token;
next(); next();
}); });
......
...@@ -581,7 +581,7 @@ textarea.editable{ ...@@ -581,7 +581,7 @@ textarea.editable{
min-height: 80px; min-height: 80px;
border: 1px solid #bbb; border: 1px solid #bbb;
border-radius: 4px; border-radius: 4px;
margin: 5px; margin: 5px 0px 5px 0px;
padding: 4px; padding: 4px;
position: relative; /* For positioning absolute the try_details that show actions */ position: relative; /* For positioning absolute the try_details that show actions */
} }
...@@ -670,7 +670,7 @@ textarea.editable{ ...@@ -670,7 +670,7 @@ textarea.editable{
#tries .try_time{ #tries .try_time{
float: right; float: right;
font-size: 15px; font-size: 15px;
margin: 8px 10px 0 0; margin: 8px 10px 0px 5px;
} }
/* Timer for the actual try */ /* Timer for the actual try */
...@@ -913,4 +913,19 @@ input[type=range]:focus::-ms-fill-upper { ...@@ -913,4 +913,19 @@ input[type=range]:focus::-ms-fill-upper {
} }
} }
\ No newline at end of file .numberCircle {
border-radius: 50%;
behavior: url(PIE.htc); /* remove if you don't care about IE8 */
width: 36px;
height: 36px;
padding: 8px;
background: #fff;
border: 2px solid #3071a9;
color: #3071a9;
text-align: center;
font: 32px Arial, sans-serif;
}
\ No newline at end of file
...@@ -178,9 +178,9 @@ ...@@ -178,9 +178,9 @@
<div class="list-group-item" ng-repeat="s in wsessions | orderBy: '-begin' | limitTo: numPerPage:(currentPage-1)*numPerPage"> <div class="list-group-item" ng-repeat="s in wsessions | orderBy: '-begin' | limitTo: numPerPage:(currentPage-1)*numPerPage">
<!-- <span class="badge">{{ s.tries.length }}</span> --> <!-- <span class="badge">{{ s.tries.length }}</span> -->
<div ng-show="showLastTry && wsessions.length > 0"> <div ng-show="showLastTry && wsessions.length > 0">
<h3> <h4>
{{ 'last_session' | translate}}: {{ studentData.current_method }}, {{ studentData.current_instruction }} ({{s.begin | date:'dd-MM-yyyy'}} ) <strong>{{ 'last_session' | translate}}</strong>: {{ studentData.current_method }}, {{ studentData.current_instruction }}
</h3> </h4>
<div ng-show="ws_recover" > <div ng-show="ws_recover" >
<table style="border: 1px solid #666666; padding:5px; background-color:#f5f5f5;" width="100%"> <table style="border: 1px solid #666666; padding:5px; background-color:#f5f5f5;" width="100%">
<td><h4> <td><h4>
...@@ -201,15 +201,11 @@ ...@@ -201,15 +201,11 @@
Ensayos <span class="badge">{{ s.tries.length }}</span> Ensayos <span class="badge">{{ s.tries.length }}</span>
</button> </button>
<table> <span ng-show="!showLastTry" class="list-group-item-heading color_green numberCircle">{{$index+1}}&nbsp;&nbsp;&nbsp;</span>
<td><h4 ng-show="!showLastTry" class="list-group-item-heading color_green">#{{$index+1}}&nbsp;&nbsp;&nbsp;</h4></td> <p style="text-align: left ; margin-bottom: 5px" class="list-group-item-text color_green"><b>{{ s.begin | date:'dd-MM-yyyy' }}</b> de
<td><h4 style="text-align: right;"class="list-group-item-heading color_green">{{ s.begin | date:'dd-MM-yyyy' }}</h4> {{ s.begin | date:'HH:mm' }} a {{ s.end | date:'HH:mm' }} </p>
<p style="text-align: right;" class="list-group-item-text color_green">{{ s.begin | date:'HH:mm' }} - {{ s.end | date:'HH:mm' }} </p> <textarea type="editable title" rows="2" id="ins_desc_ws" placeholder=" Notas de sesión" ng-model="s.description"
</td>
<td rowspan="2">&nbsp;<textarea type="editable title" rows="2" id="ins_desc_ws" placeholder=" Notas de sesión" ng-model="s.description"
ng-model-options="{ updateOn: 'blur' }" ng-change="update_ws(s)" cols="80"></textarea> ng-model-options="{ updateOn: 'blur' }" ng-change="update_ws(s)" cols="80"></textarea>
</td>
</table>
<!-- Collapse tries --> <!-- Collapse tries -->
<a class="session_details" ng-click="showTries = !showTries"> <a class="session_details" ng-click="showTries = !showTries">
<span ng-if="!showTries" class="glyphicon glyphicon-collapse-down color_green" aria-hidden="true"></span> <span ng-if="!showTries" class="glyphicon glyphicon-collapse-down color_green" aria-hidden="true"></span>
...@@ -221,8 +217,8 @@ ...@@ -221,8 +217,8 @@
<div ng-show="!is_currentOpenTry(t)"> <!--the current try is not showed--> <div ng-show="!is_currentOpenTry(t)"> <!--the current try is not showed-->
<!-- Pictos submitted by the student --> <!-- Pictos submitted by the student -->
<table width="100%"> <table width="100%">
<tr><td> <tr><td>
<div class="try_time color_blue pull-left">#{{$index+1}}</div>
<div class="pull-left" ng-repeat="p in t.actions"> <div class="pull-left" ng-repeat="p in t.actions">
<div class="picto" popover="{{ 'action-' + p.type | translate }}" popover-trigger="mouseenter"> <div class="picto" popover="{{ 'action-' + p.type | translate }}" popover-trigger="mouseenter">
<img ng-src="{{ p.description.picto.uri }}"> <img ng-src="{{ p.description.picto.uri }}">
...@@ -263,10 +259,12 @@ ...@@ -263,10 +259,12 @@
</div> </div>
</td></tr> </td></tr>
<tr><td> <tr><td>
<div class="try_time pull-left">
<div class="color_blue"><strong>{{t.begin | date:'dd-MM-yyyy' }}</strong> {{t.begin | date:'HH:mm:ss' }} - {{t.end | date:'HH:mm:ss' }}</div> <div class="try_time pull-left">
</div> <div class="color_blue"><strong> ({{$index+1}}) {{t.begin | date:'dd-MM-yyyy' }}</strong> de {{t.begin | date:'HH:mm:ss' }} a {{t.end | date:'HH:mm:ss' }}</div>
<!-- Collapse try notes --> </div>
<!-- Collapse try notes -->
<a class="try_details" ng-click="showTryNotes = !showTryNotes"> <a class="try_details" ng-click="showTryNotes = !showTryNotes">
<span ng-if="!showActions" class="glyphicon glyphicon-collapse-down" aria-hidden="true"></span> <span ng-if="!showActions" class="glyphicon glyphicon-collapse-down" aria-hidden="true"></span>
<span ng-if="showActions" class="glyphicon glyphicon-collapse-up" aria-hidden="true"></span> <span ng-if="showActions" class="glyphicon glyphicon-collapse-up" aria-hidden="true"></span>
......
...@@ -44,7 +44,7 @@ module.exports.policies = { ...@@ -44,7 +44,7 @@ module.exports.policies = {
list: ['tokenAuth', 'isAdmin'], list: ['tokenAuth', 'isAdmin'],
destroy: ['tokenAuth', 'isAdmin'], destroy: ['tokenAuth', 'isAdmin'],
students: ['tokenAuth'], students: ['tokenAuth'],
pictos: ['tokenAuth'], pictos: ['tokenAuth', 'isAdmin'],
upload: ['tokenAuth'] upload: ['tokenAuth']
}, },
DeviceController: { DeviceController: {
...@@ -76,11 +76,11 @@ module.exports.policies = { ...@@ -76,11 +76,11 @@ module.exports.policies = {
find: ['tokenAuth'], find: ['tokenAuth'],
findOne: ['tokenAuth'], findOne: ['tokenAuth'],
getInfo: ['tokenAuth'], getInfo: ['tokenAuth'],
create: ['tokenAuth', 'isSupAdmin'], // isSupAdmin too create: ['tokenAuth',], // isSupAdmin too
update: ['tokenAuth'], update: ['tokenAuth'],
delete: ['tokenAuth', 'isSupAdmin'], delete: ['tokenAuth'],
//destroy: ['tokenAuth'], // isSupAdmin too //destroy: ['tokenAuth'], // isSupAdmin too
devices: ['tokenAuth'], // isSupAdmin is supervisor of the devices: ['tokenAuth' ], // isSupAdmin is supervisor of the
supervisors: ['tokenAuth'], supervisors: ['tokenAuth'],
therapists: ['tokenAuth'], therapists: ['tokenAuth'],
tutors: ['tokenAuth'], // isSupervisorOfStudent falla en Student.supervisors tutors: ['tokenAuth'], // isSupervisorOfStudent falla en Student.supervisors
...@@ -93,7 +93,7 @@ module.exports.policies = { ...@@ -93,7 +93,7 @@ module.exports.policies = {
vocabulary: true, // websockets vocabulary: true, // websockets
action: true, // websockets action: true, // websockets
config: true, // websockets config: true, // websockets
pictos: ['tokenAuth', 'isSupervisorOfStudentOrIsStudent'], pictos: ['tokenAuth'],
add_picto: ['tokenAuth', 'isSupervisorOfStudent'], add_picto: ['tokenAuth', 'isSupervisorOfStudent'],
delete_picto: ['tokenAuth', 'isSupervisorOfStudent'], delete_picto: ['tokenAuth', 'isSupervisorOfStudent'],
update_picto: ['tokenAuth', 'isSupervisorOfStudent'], update_picto: ['tokenAuth', 'isSupervisorOfStudent'],
......
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