Commit cde7a3cb by Fernando Martínez Santiago

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

parents 7737f075 889b9572
......@@ -46,9 +46,9 @@
<!--Semantic grammar -->
<string name="loadingGrammar">Por favor espere, cargando gramática semántica</string>
<string name="naturalgrammar">SUpO_ES</string>
<string name="pictogrammar">SUpO_PICTOES</string>
<string name="grammar">SUpO_ES</string>
<string name="nogrammar">Advertencia: Lenguaje no soportado</string>
<string name="pictogrammar">SUpO_PICTOES</string>
<item type="integer" name="maxInTape">8</item>
......
......@@ -45,8 +45,10 @@
<!--Semantic grammar -->
<string name="loadingGrammar">Please wait, loading semmantic grammar</string>
<string name="naturalgrammar">SUpO_EN</string>
<string name="grammar">SUpO_EN</string>
<string name="nogrammar">Warning: unknown language</string>
<string name="pictogrammar">SUpO_PICTOEN</string>
<!--Upload local img -->
<string name="enterImgLabel">Introduzca etiqueta de la imagen</string>
......
......@@ -538,6 +538,7 @@ module.exports = {
//
delete_picto: function(req, res) {
var params = req.allParams();
console.log(JSON.stringify(params));
StuPicto.destroy({id: params.id_stuPicto}).exec(function (err, destroyed) {
if (err) {
......@@ -545,11 +546,11 @@ module.exports = {
return res.json(500, {error: 'Not removed picto for student'});
}
if (destroyed) {
console.log("Removed picto for the student" );
console.log("Removed picto "+destroyed[0].id_pic+ "for the student ");
return res.json({
"id": destroyed[0].id,
"attributes": JSON.parse(destroyed[0].attributes),
"picto": destroyed[0].id_pic
id: destroyed[0].id,
attributes: JSON.parse(destroyed[0].attributes),
picto: { id: destroyed[0].id_pic }
});
}
});
......@@ -560,7 +561,7 @@ module.exports = {
//
update_picto: function(req, res) {
var params = req.allParams();
console.log("Updating attributes for picto student "+ params);
console.log("Updating attributes for picto student "+ JSON.stringify(params));
console.log(JSON.stringify(params));
query=params.id_stuPicto ? {id: params.id_stuPicto}
......@@ -572,7 +573,12 @@ module.exports = {
}
if (updated) {
console.log("Updated attributes for picto student:"+JSON.stringify(updated[0]));
return res.json(updated[0]);
// return res.json(updated[0]);
return res.json({
id: updated[0].id,
attributes: updated[0].attributes,
picto: { id:updated[0].picto }
});
}
});
},
......@@ -665,6 +671,11 @@ module.exports = {
if (req.isSocket) {
sails.log.debug("Inside /stu/subscribe - isSocket");
sails.sockets.join(req.socket, roomName);
sails.io.sockets.in(roomName).clients(function(err, ids) {
sails.log.debug("number of clients in room: " + ids.length);
if (!err)
sails.io.to(roomName).emit('update_peers', {count: ids.length});
});
res.json({
msg: "Subscribed to student " + roomName
});
......@@ -691,8 +702,8 @@ module.exports = {
sails.sockets.leave(req.socket, rooms[i]);
sails.log.debug("Unsusbscribe from room " + rooms[i]);
}
res.json({
res.json({
msg: "Unsubscribed from all rooms"
});
}
......
......@@ -143,6 +143,7 @@
"normal": "Normal",
"notes": "Notes",
"November": "November",
"num_peers": "Peers",
"num_sessions_per_day_in": "Sessions per day in",
"num_sessions_per_month_in": "Sessions per months in",
"objetive": "Objetive",
......
......@@ -143,6 +143,7 @@
"normal": "Normal",
"notes": "Notas",
"November": "Noviembre",
"num_peers": "Conectados",
"num_sessions_per_day_in": "Número de sesiones por día en",
"num_sessions_per_month_in": "Número de sesiones por meses en",
"objetive": "Objetivo",
......
......@@ -136,7 +136,7 @@ dashboardControllers.controller('AddPictoCtrl', function ($scope, $modalInstance
};
$scope.alert = { type: 'danger', msg: 'Category is full of pictos.', show: false };
//
// Close alert message
//
......@@ -352,6 +352,7 @@ dashboardControllers.controller('AddPictoCtrl', function ($scope, $modalInstance
})
.error(function(data, status, headers, config) {
console.log("Error from API: " + data.error);
alert('Pictogram is already part of this vocabulary');
});
}
......
......@@ -23,7 +23,8 @@ dashboardControllers.controller('StudentCtrl', function StudentCtrl($scope, conf
id: '',
name: ''
},
stuSup: []
stuSup: [],
num_peers: 1
};
// For the user form data in setup section
......@@ -34,6 +35,30 @@ dashboardControllers.controller('StudentCtrl', function StudentCtrl($scope, conf
// from the abstract parent (it has no url)
$scope.studentData.id = $state.$current.locals.globals.$stateParams.idStudent;
//
// WebSockets communication
//
io.socket.on('update_peers', function(data) {
console.log(data.count + ' peers connected');
$scope.studentData.num_peers = data.count;
});
io.socket.on('reconnect', function () {
// Subscribe to student's socket room
console.log("reconnecting to socket");
io.socket.post('/stu/subscribe', {
action: 'subscribe',
attributes:{
id_stu: $scope.studentData.id
},
token: $window.sessionStorage.token
},
function(res) {
console.log("Connected to student: " + res.msg);
});
});
// ----------------------------------------------------------------------
//
// Load student account information
......@@ -244,24 +269,6 @@ dashboardControllers.controller('StudentCtrl', function StudentCtrl($scope, conf
console.log("Error from API: " + data.error);
});
//
// WebSockets communication
//
io.socket.on('reconnect', function () {
// Subscribe to student's socket room
console.log("reconnecting to socket");
io.socket.post('/stu/subscribe', {
action: 'subscribe',
attributes:{
id_stu: $scope.studentData.id
},
token: $window.sessionStorage.token
},
function(res) {
console.log("Connected to student: " + res.msg);
});
});
/*
// Events handling
io.socket.on('action', function(data) {
......
......@@ -23,6 +23,7 @@
<div style="margin-left: 5px"><h4>{{studentData.name}} {{studentData.surname}}</h4></div>
<div style="margin-left: 5px" class="text-left">{{studentData.current_method | translate}}</div>
<div style="margin-left: 5px" class="text-left">{{studentData.current_instruction | translate}}</div>
<div style="margin-left: 5px; color: green" class="text-left">{{ 'num_peers' | translate}} : {{studentData.num_peers}}</div>
</div>
</div>
<div class="row">
......@@ -49,4 +50,4 @@
</div>
</div>
</nav>
<!-- Fin cabecera alumno -->
\ No newline at end of file
<!-- Fin cabecera alumno -->
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