Solved issues #546 and #548

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