pictos no mostrados en sesión, corregido

parent b791bd7d
......@@ -47,6 +47,9 @@ android {
LocalFlavor {
resValue "string", "server", "https://192.168.1.37:1337"
}
DevFlavor {
resValue "string", "server", "https://dev.yottacode.com"
}
DefaultFlavor {
resValue "string", "server", "https://pre.yottacode.com"
signingConfig signingConfigs.release_config
......
......@@ -1015,15 +1015,17 @@ module.exports = {
sails.log.debug("Inside action. Student:" + attributes.id_stu);
if (req.isSocket) {
sails.log.debug("websockets - room " + roomName);
sails.log.debug("websockets - room " + sails.hooks.rooms.student(attributes.id_stu));
// BROADCAST to everyone subscribed to this student
const socketToOmit = (req.isSocket) ? req.socket : undefined;
sails.hooks.events.broadcast(
sails.hooks.events.broadcastEvent(
sails.hooks.rooms.student(attributes.id_stu),
'action',
{
"action": action,
"attributes": attributes
name: 'action',
data: {
"action": action,
"attributes": attributes
}
},
socketToOmit
);
......@@ -1043,8 +1045,10 @@ module.exports = {
description: desc
})
.exec(function (err, created) {
if (err)
if (err) {
sails.log.error(err.details);
res.serverError(err.details);
}
else if (created)
res.json({
action: created
......@@ -1056,6 +1060,8 @@ module.exports = {
msg: "Action "+ action +" action from student " + attributes.id_stu
});
*/
} else {
sails.log.debug("No socket request for action");
}
},
......@@ -1070,7 +1076,7 @@ module.exports = {
if (req.isSocket) {
const socketToOmit = (req.isSocket) ? req.socket : undefined;
sails.hooks.events.broadcast(
sails.hooks.events.broadcastEvent(
sails.hooks.rooms.student(attributes.id_stu),
'action',
{
......
// @TODO 357
module.exports = {
// create action
// adds a try
//
create: function(req, res) {
var params = req.allParams();
if (!params.ws) return res.json(500, {error: "No workingSession defined"});
if (!params.begin) return res.json(500, {error: "No begin defined"});
if (!params.end) return res.json(500, {error: "No end defined"});
if (!params.actions) return res.json(500, {error: "No actions in try defined"});
if (!params.supervisor) return res.json(500, {error: "No supervisor in try defined"});
if (!params.student) return res.json(500, {error: "No student in try defined"});
Try.create({
"workingSession":params.ws,
"begin": params.begin,
"end": params.end
}).exec(function(err, tr){
if(err || !tr){
sails.log.debug("Creating new Try: " + err);
return res.json(500, {error: 'Try not created'});
}
if(tr){
var l_actions = [];
// with .eachSeries the order of resulting array will be equal
// to the original array
async.eachSeries(params.actions, function(a, callback) {
sails.log.debug("Loop adding actions: " + a.action + " to try " + tr.id);
var desc = null;
if(a.attributes.picto) desc = a.attributes.picto; // select, add and delete actions data
if(a.attributes.pictos) desc = a.attributes.pictos; // show action data
Action.create({
type: a.action,
timestamp: a.attributes.timestamp,
supervisor: params.supervisor,
student: params.student,
description: desc,
_try: tr.id
}).exec(function(err, action){
if(err || !action) sails.log.debug("Creating new "+ a.action +" action: " + err);
if(action){
sails.log.debug("Action Created: " + action.type);
l_actions.push(action);
}
callback();
});
// Finish function when each callback is done
// Optionaly it can be passed and err parameter
}, function(err){
if( err ) {
// One of the iterations produced an error.
// All processing will now stop.
console.log('An error ocurred with an action');
} else {
console.log('All actions have been processed successfully');
// Return the try
// with the array of actions
return res.json({
"id": tr.id,
"workingSession": tr.workingSession,
"begin": tr.begin,
"end": tr.end,
"actions": l_actions
});
}
});
/*
// InitSession Action
Action.create({
"type": "InitSession",
"timestamp": ws.begin,
"supervisor": ws.supervisor,
"student": ws.student,
}).exec(function(err, action){
if(err || !action) sails.log.debug("Creating new Action InitSession: " + err);
if(action) sails.log.debug("Created Action: " + action.type);
});
// TryInit Action
Action.create({
"type": "TryInit",
"timestamp": ws.begin,
"supervisor": ws.supervisor,
"student": ws.student,
"_try": tr.id
}).exec(function(err, action){
if(err || !action) sails.log.debug("Creating new Action TryInit: " + err);
if(action){
sails.log.debug("Created Action: " + action.type);
// Return the working session created
// with the array of one try (the first)
// with the array of one action (the first too)
return res.json({
"id": ws.id,
"begin": ws.begin,
"student": ws.student,
"supervisor": ws.supervisor,
"tries": [
{
"id": tr.id,
"instruction": tr.instruction,
"begin": tr.begin,
"workingSession": tr.workingSession,
"actions": [ action ]
}
]
});
}
});
*/
}
});
}
// create action
// adds a try
//
create: function(req, res) {
var params = req.allParams();
if (!params.ws) return res.json(500, {error: "No workingSession defined"});
if (!params.begin) return res.json(500, {error: "No begin defined"});
if (!params.end) return res.json(500, {error: "No end defined"});
if (!params.actions) return res.json(500, {error: "No actions in try defined"});
if (!params.supervisor) return res.json(500, {error: "No supervisor in try defined"});
if (!params.student) return res.json(500, {error: "No student in try defined"});
Try.create({
"workingSession":params.ws,
"begin": params.begin,
"end": params.end
}).exec(function(err, tr){
if(err || !tr){
sails.log.debug("Creating new Try: " + err);
return res.json(500, {error: 'Try not created'});
}
if(tr){
var l_actions = [];
// with .eachSeries the order of resulting array will be equal
// to the original array
async.eachSeries(params.actions, function(a, callback) {
sails.log.debug("Loop adding actions: " + a.action + " to try " + tr.id);
var desc = null;
if(a.attributes.picto) desc = a.attributes.picto; // select, add and delete actions data
if(a.attributes.pictos) desc = a.attributes.pictos; // show action data
Action.create({
type: a.action,
timestamp: a.attributes.timestamp,
supervisor: params.supervisor,
student: params.student,
description: desc,
_try: tr.id
}).exec(function(err, action){
if(err || !action) sails.log.debug("Creating new "+ a.action +" action: " + err);
if(action){
sails.log.debug("Action Created: " + action.type);
l_actions.push(action);
}
callback();
});
// Finish function when each callback is done
// Optionaly it can be passed and err parameter
}, function(err){
if( err ) {
// One of the iterations produced an error.
// All processing will now stop.
console.log('An error ocurred with an action');
} else {
console.log('All actions have been processed successfully');
// Return the try
// with the array of actions
return res.json({
"id": tr.id,
"workingSession": tr.workingSession,
"begin": tr.begin,
"end": tr.end,
"actions": l_actions
});
}
});
/*
// InitSession Action
Action.create({
"type": "InitSession",
"timestamp": ws.begin,
"supervisor": ws.supervisor,
"student": ws.student,
}).exec(function(err, action){
if(err || !action) sails.log.debug("Creating new Action InitSession: " + err);
if(action) sails.log.debug("Created Action: " + action.type);
});
// TryInit Action
Action.create({
"type": "TryInit",
"timestamp": ws.begin,
"supervisor": ws.supervisor,
"student": ws.student,
"_try": tr.id
}).exec(function(err, action){
if(err || !action) sails.log.debug("Creating new Action TryInit: " + err);
if(action){
sails.log.debug("Created Action: " + action.type);
// Return the working session created
// with the array of one try (the first)
// with the array of one action (the first too)
return res.json({
"id": ws.id,
"begin": ws.begin,
"student": ws.student,
"supervisor": ws.supervisor,
"tries": [
{
"id": tr.id,
"instruction": tr.instruction,
"begin": tr.begin,
"workingSession": tr.workingSession,
"actions": [ action ]
}
]
});
}
});
*/
}
});
}
};
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