Solved issues #546 and #548

parent a344738a
......@@ -5,7 +5,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
classpath 'com.android.tools.build:gradle:2.1.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
......
......@@ -128,6 +128,5 @@
<orderEntry type="library" exported="" name="ion-2.1.8" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="json-20090211" level="project" />
<orderEntry type="library" exported="" name="play-services-ads-lite-9.2.1" level="project" />
<orderEntry type="library" exported="" name="android-android-24" level="project" />
</component>
</module>
\ No newline at end of file
#Mon Jun 06 22:38:39 CEST 2016
#Mon Aug 29 01:05:09 CEST 2016
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
......@@ -22,7 +22,7 @@ android {
resValue "string", "server", "https://127.0.0.1:9944"
}
LocalFlavor {
resValue "string", "server", "https://192.168.1.37:1337"
resValue "string", "server", "https://192.168.1.36:1337"
}
DevFlavor {
resValue "string", "server", "https://dev.yottacode.com"
......
......@@ -35,84 +35,65 @@ module.exports = {
create: function(req, res) {
var params = req.allParams();
if (!params.id_mmethod) return res.json(500, {error: "No meta method defined"});
if (!params.id_stu) return res.json(500, {error: "No student defined"});
if (!params.id_mmethod) return res.badRequest("No meta method defined");
if (!params.id_stu) return res.badRequest("No student defined");
// Find meta method
MetaMethod.findOne({id: params.id_mmethod}).exec(function(err, mmethod) {
if (err || !mmethod){
sails.log.debug("Finding meta method: " + err);
return;
}
sails.log.debug("Meta method found:" + mmethod);
// Create new method by meta method
Method.create({ name: mmethod.name, description: mmethod.description, student: params.id_stu}).exec(function (err, created) {
if (err) {
sails.log.debug("Creating new method: " + err);
return res.json(500, {error: 'Method not created'});
}
if (created) {
// Find meta instructions associated to meta method
MetaInstruction.find({id_met: params.id_mmethod}).exec(function(err, minstructions) {
if (err || !minstructions || minstructions.length == 0){
sails.log.debug("Finding meta instructions of a meta method: " + err);
return;
}
sails.log.debug("Meta instructions found: " + JSON.stringify(minstructions));
var l_ins = [];
// Every meta instruction is going to be created in 'Instruction'
// with .eachSeries the order of resulting array will be equal
// to the original array
async.eachSeries(minstructions, function(mins, callback) {
sails.log.debug("Loop adding meta instruction: " + mins.name + " to method " + created.id);
Instruction.create({
method: created.id,
name: mins.name,
objective: mins.objective
}).exec(function(err, added){
if(err) sails.log.debug("Instruction.create: " + err);
if(added){
l_ins.push(added);
sails.log.debug("Instruction " + added.name + " added to method " + created.id);
}
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.
} else {
return res.json({
"name": created.name,
"description": created.description,
"id": created.id,
"student": created.id_stu,
"instructions": l_ins
});
}
});
MetaMethod.findOne({id: params.id_mmethod})
.then(mmethod => {
if (!mmethod)
throw new Error("Meta method not found");
// Create new method by meta method
return Method.create(
{
name: mmethod.name,
description: mmethod.description,
student: params.id_stu
})
.then(created => created)
.fail(err => {throw err});
})
.then(created => {
// Find meta instructions associated to meta method
MetaInstruction.find({id_met: params.id_mmethod})
.then(minstructions => {
if (!minstructions)
minstructions = [];
var l_ins = [];
// Every meta instruction is going to be created in 'Instruction'
// with .eachSeries the order of resulting array will be equal
// to the original array
async.eachSeries(minstructions, function(mins, next) {
Instruction.create({
method: created.id,
name: mins.name,
objective: mins.objective
})
.then(added => {
l_ins.push(added);
sails.log.debug("Instruction " + added.name + " added to method " + created.id);
})
.fail(err => {throw err})
.done(() => {next()});
},
function(err, results) {
if (err)
throw new Error("Error while looping through instructions");
return res.ok({
"name": created.name,
"description": created.description,
"id": created.id,
"student": created.id_stu,
"instructions": l_ins
});
}
});
});
})
.fail( err => {throw err});
})
.fail(err => {
return res.badRequest(err);
});
},
......
......@@ -55,7 +55,7 @@ module.exports = {
create: function(req, res) {
var params = req.allParams();
console.log(JSON.stringify(params));
sails.debug.log(JSON.stringify(params));
if (!params.id_sup) res.badRequest("No supervisor defined");
if (!params.id_ins) res.badRequest("No instruction defined");
......@@ -66,7 +66,7 @@ module.exports = {
data.supervisor = params.id_sup;
data.instruction = params.id_ins;
data.description = params.desc;
console.log("BEGIN " + params.begin);
sails.debug.log("BEGIN " + params.begin);
data.begin = params.begin; // data comes in ISO format
StuOpenTry.findOne({or: [ // pending open try?
......
......@@ -218,6 +218,7 @@
"serial_list": "Free serial numbers",
"serial_not_created": "Serial number couldn't be created",
"session": "Session",
"sessions": "Sessions",
"session_mean_length": "Session mean length: {{hours}} hours",
"session_notes": "Session notes",
"sessions": "Sessions",
......@@ -260,6 +261,7 @@
"surname": "Surname",
"tag_deleted": "Tag deleted",
"tape_background": "Tape background",
"template_deleted": "Template deleted",
"time_instruction_method": "Time instructions of method",
"time_hours": "Time: {{hours}} hours",
"time_sessions_per_days": "Time of sessions per days in",
......
......@@ -219,6 +219,7 @@
"serial_list": "Números de serie libres",
"serial_not_created": "No se ha podido crear el número de serie",
"session": "Sesión",
"sessions": "Sesiones",
"session_mean_length": "Duración media de sesión: {{hours}} horas",
"session_notes": "Notas de sesión",
"sessions": "Sesiones",
......@@ -261,6 +262,7 @@
"surname": "Apellidos",
"tag_deleted": "Etiqueta borrada",
"tape_background": "Fondo de la cinta",
"template_deleted": "Plantilla eliminada",
"time_hours": "Tiempo: {{hours}} horas",
"time_instruction_method": "Tiempo instrucciones del método",
"time_sessions_per_days": "Tiempo de sesiones por días en",
......
......@@ -5,6 +5,7 @@
<title>Pictogram Dashboard</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<link rel="stylesheet" href="css/main.css">
<link rel="icon" href="img/logo_pictogram.png" type='image/png'>
<script src="js/libs.js"></script>
<script src="js/main.js"></script>
</head>
......
......@@ -89,7 +89,7 @@ dashboardControllers.controller('StudentInstructionsCtrl', function StudentInstr
console.log("Error from API: " + data.error);
});
}else{
} else {
// Add method from templates
$http
.post(config.backend+'/method', {
......@@ -113,32 +113,32 @@ dashboardControllers.controller('StudentInstructionsCtrl', function StudentInstr
// Delete template
$scope.delete_template = function(){
var deleteTemp = $window.confirm('Are you absolutely sure you want to delete?');
// If the method template is property of the supervisor
if(deleteTemp && $scope.method_selected.supervisor == $scope.user.id){
$http
.delete(config.backend+'/method/template/' + $scope.method_selected.id)
.success(function(data, status, headers, config) {
console.log('Delete Method Template and its Instructions');
var myToastMsg = ngToast.success({
content: 'Eliminado método de plantillas',
timeout: 6000 // By default 4000
});
// Delete in select
for(var i=0; i<$scope.methods_available.length; i++) {
if($scope.methods_available[i].id == $scope.method_selected.id){
$scope.methods_available.splice(i,1);
$scope.method_selected = null;
break;
}
$translate('confirmation').then(function(translation) {
newconfirm(translation).then(function() {
if($scope.method_selected.supervisor == $scope.user.id){
$http
.delete(config.backend+'/method/template/' + $scope.method_selected.id)
.success(function(data, status, headers, config) {
console.log('Delete Method Template and its Instructions');
$translate('template_deleted').then(t => {ngToast.success({content: t})});
// Delete in select
for(var i=0; i<$scope.methods_available.length; i++) {
if($scope.methods_available[i].id == $scope.method_selected.id){
$scope.methods_available.splice(i,1);
$scope.method_selected = null;
break;
}
}
})
.error(function(data, status, headers, config) {
console.log("Error from API: " + data.error);
});
}
})
.error(function(data, status, headers, config) {
console.log("Error from API: " + data.error);
});
}
});
});
};
// Update method
......@@ -217,13 +217,13 @@ dashboardControllers.controller('StudentInstructionsCtrl', function StudentInstr
.error(function(data, status, headers, config) {
console.log("Error from API: " + data.error);
var myToastMsg = $translate('cannot_delete_method').then(function (translation) {
// Show message
ngToast.warning({
content: translation,
timeout: 6000 // By default 4000
// Show message
ngToast.warning({
content: translation,
timeout: 6000 // By default 4000
});
});
});
});
});
});
};
......
......@@ -36,7 +36,7 @@
<a href="/app/#/student/{{studentData.id}}/instructions" ng-click="nav.tab = 'instructions'"><span class="glyphicon glyphicon-tasks" aria-hidden="true"></span> {{ 'instructions' | translate }}</a>
</li>
<li role="presentation" ng-class="{'active' : nav.tab == 'session'}" ng-if="studentData.supervision == 2">
<a href="/app/#/student/{{studentData.id}}/session" ng-click="nav.tab = 'session'"><span class="glyphicon glyphicon-transfer" aria-hidden="true"></span> {{ 'session' | translate }}</a>
<a href="/app/#/student/{{studentData.id}}/session" ng-click="nav.tab = 'session'"><span class="glyphicon glyphicon-transfer" aria-hidden="true"></span> {{ 'sessions' | translate }}</a>
</li>
<li role="presentation" ng-class="{'active' : nav.tab == 'reports'}" ng-if="studentData.supervision != 1">
<a href="/app/#/student/{{studentData.id}}/reports" ng-click="nav.tab = 'reports'"><span class="glyphicon glyphicon-file" aria-hidden="true"></span> {{ 'reports' | translate }}</a>
......
......@@ -12,7 +12,7 @@
*/
module.exports.sockets = {
pingTimeout: 20000, // set timeout to 20 secs
/***************************************************************************
......@@ -38,7 +38,7 @@ afterDisconnect: function (session, socket, cb) {
var rooms=sails.hooks.rooms.getRoom(socket);
if (rooms)
for (var i = 0; i < rooms.length; i++) {
for (var i = 0; i < rooms.length; i++) {
console.log("Unubscribed room in socket afterDisconnect: " + rooms[i]);
sails.hooks.rooms.unsubscribeFromRoom(rooms[i], socket);
}
......@@ -54,12 +54,12 @@ afterDisconnect: function (session, socket, cb) {
* flashsockets by adding 'flashsocket' to this list: *
* *
***************************************************************************/
transports: [
// transports: [
// 'websocket'
// 'htmlfile',
// 'xhr-polling'
'polling'
]
// 'polling'
// ]
/***************************************************************************
* *
......
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