Merge remote-tracking branch 'origin/master'

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