bug of issues #311 and #310 fixed. Also, found bug when deleting method with…

bug of issues #311 and #310 fixed. Also, found bug when deleting method with sessions associated solved with an alert box
parent 5b85ebae
...@@ -36,6 +36,7 @@ sails/config/tmp.sql ...@@ -36,6 +36,7 @@ sails/config/tmp.sql
android/Pictogrammar/.idea android/Pictogrammar/.idea
.idea .idea
android/Pictogrammar/app/app.iml android/Pictogrammar/app/app.iml
android/Pictogrammar/Pictogrammar.iml
# Packages # # Packages #
############ ############
......
...@@ -38,6 +38,9 @@ android { ...@@ -38,6 +38,9 @@ android {
FernandoFlavor { FernandoFlavor {
resValue "string", "server", "https://127.0.0.1:9944" resValue "string", "server", "https://127.0.0.1:9944"
} }
ArturoFlavor {
resValue "string", "server", "https://192.168.1.37:1337"
}
DefaultFlavor { DefaultFlavor {
resValue "string", "server", "https://pre.yottacode.com:1337" resValue "string", "server", "https://pre.yottacode.com:1337"
} }
...@@ -47,9 +50,12 @@ android { ...@@ -47,9 +50,12 @@ android {
dependencies { dependencies {
compile fileTree(dir: 'libs', include: ['*.jar']) compile fileTree(dir: 'libs', include: ['*.jar'])
//compile fileTree(dir: 'E:\\Users\\Fernando\\Google Drive\\experimentos\\Pictogrammar\\android\\app\\libs', include: ['*.jar']) //compile fileTree(dir: 'E:\\Users\\Fernando\\Google Drive\\experimentos\\Pictogrammar\\android\\app\\libs', include: ['*.jar'])
compile 'com.google.android.gms:play-services:6.5.87' compile 'com.google.android.gms:play-services:8.4.0'
compile 'com.android.support:appcompat-v7:21.0.3' compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.github.nkzawa:socket.io-client:0.5.0' compile 'com.github.nkzawa:socket.io-client:0.5.0'
compile 'com.koushikdutta.async:androidasync:2.+' compile 'com.koushikdutta.async:androidasync:2.+'
compile 'com.android.support:support-v4:21.0.+' compile 'com.android.support:support-v4:23.1.1'
compile 'com.google.android.gms:play-services-ads:8.4.0'
compile 'com.google.android.gms:play-services-identity:8.4.0'
compile 'com.google.android.gms:play-services-gcm:8.4.0'
} }
...@@ -105,7 +105,7 @@ CREATE TABLE IF NOT EXISTS `instruction` ( ...@@ -105,7 +105,7 @@ CREATE TABLE IF NOT EXISTS `instruction` (
`name` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL, `name` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
`objective` varchar(512) COLLATE utf8_unicode_ci DEFAULT NULL, `objective` varchar(512) COLLATE utf8_unicode_ci DEFAULT NULL,
`status` varchar(60) COLLATE utf8_unicode_ci DEFAULT NULL CHECK (status IN ('started','finished')), `status` varchar(60) COLLATE utf8_unicode_ci DEFAULT NULL CHECK (status IN ('started','finished')),
`begin` timestamp, `begin` timestamp NULL,
`end` timestamp NULL, `end` timestamp NULL,
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ; ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ;
......
...@@ -219,7 +219,7 @@ module.exports = { ...@@ -219,7 +219,7 @@ module.exports = {
if (err || !instructions){ if (err || !instructions){
sails.log.debug("Destroy Instructions: " + err); sails.log.debug("Destroy Instructions: " + err);
return res.json(500, {error: "No instructions found"}); return res.json(500, {error: "Cannot delete instructions"});
} }
......
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
"beep": "Beep", "beep": "Beep",
"birthdate": "Birthdate", "birthdate": "Birthdate",
"cancel": "Cancel", "cancel": "Cancel",
"cannot_delete_method": "Method could not be deleted, maybe due to existing recorded sessions.",
"categories": "Categories", "categories": "Categories",
"change_password": "Change password", "change_password": "Change password",
"change_picture": "Change picture", "change_picture": "Change picture",
......
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
"beep": "Pitido", "beep": "Pitido",
"birthdate": "Fecha de nacimiento", "birthdate": "Fecha de nacimiento",
"cancel": "Cancelar", "cancel": "Cancelar",
"cannot_delete_method": "No se pudo eliminar el método, tal vez porque existen sesiones asociadas.",
"categories": "Categorías", "categories": "Categorías",
"change_password": "Cambiar contraseña", "change_password": "Cambiar contraseña",
"change_picture": "Cambiar fotografía", "change_picture": "Cambiar fotografía",
......
...@@ -186,3 +186,29 @@ dashboardApp.config(function (reCAPTCHAProvider) { ...@@ -186,3 +186,29 @@ dashboardApp.config(function (reCAPTCHAProvider) {
}); });
}); });
//
// New confirm service to avoid Firefox buggy confirm dialog window (which
// results in rootScope.inprog errors)
//
dashboardApp.factory("newconfirm", function ($window, $q, $timeout) {
// Define promise-based confirm() method.
function newconfirm(message) {
var defer = $q.defer();
$timeout(function () {
if ($window.confirm(message)) {
defer.resolve(true);
}
else {
defer.reject(false);
}
}, 0, false);
return defer.promise;
}
return newconfirm;
});
...@@ -8,6 +8,12 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec ...@@ -8,6 +8,12 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec
// For tab navigation (here too, if the user refresh the page...) // For tab navigation (here too, if the user refresh the page...)
$scope.nav.tab = 'collections'; $scope.nav.tab = 'collections';
// ----------------------------------------------------------------------
// Controller actions
//
// Reload student pictos (back from addpicto) // Reload student pictos (back from addpicto)
$scope.reload_pictos = function(){ $scope.reload_pictos = function(){
$http $http
...@@ -50,8 +56,8 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec ...@@ -50,8 +56,8 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec
//console.log(JSON.stringify($scope.pictosFromCategory)); //console.log(JSON.stringify($scope.pictosFromCategory));
// Clean the pcb // Clean the pcb
for (var i=0;i<rows;i++) { for (var i=0;i<$scope.pcb_rows;i++) {
for (var j=0;j<cols; j++) { for (var j=0;j<$scope.pcb_cols; j++) {
$scope.pcb[i][j]={'picto': {'uri': '/app/img/empty.gif'}, 'attributes': {'coord_x': i, 'coord_y': j}}; $scope.pcb[i][j]={'picto': {'uri': '/app/img/empty.gif'}, 'attributes': {'coord_x': i, 'coord_y': j}};
} }
} }
......
...@@ -3,12 +3,55 @@ ...@@ -3,12 +3,55 @@
//----------------------- //-----------------------
// Student Instructions Controller // Student Instructions Controller
//----------------------- //-----------------------
dashboardControllers.controller('StudentInstructionsCtrl', function StudentInstructionsCtrl($scope, $stateParams, $http, config, $window, $translate, $modal, ngToast) { dashboardControllers.controller('StudentInstructionsCtrl', function StudentInstructionsCtrl($scope, $stateParams, $http, config, $window, $translate, $modal, ngToast, newconfirm) {
// For tab navigation (here too, if the user refresh the page...) // For tab navigation (here too, if the user refresh the page...)
$scope.nav.tab = 'instructions'; $scope.nav.tab = 'instructions';
// ----------------------------------------------------------------------
// METHODS
// Load student methods and instructions
//
//
//
// Array with methods available in meta_methods
//
$scope.methods_available = [];
// Query to meta_methods to fill the select fill with precharged methods
// and supervisor template methods
$http
.get(config.backend+'/metamethods/' + $scope.user.id)
.success(function(data, status, headers, config) {
// Add to list
$scope.methods_available = data;
console.log("Meta Methods charged:");
console.log(JSON.stringify($scope.methods_available));
// Option to add new methods
$scope.methods_available.push({ id: 0, name: "Nuevo método" });
})
.error(function(data, status, headers, config) {
console.log("Error from API: " + data.error);
});
//
// Array with student methods (with instructions)
//
$scope.methods = [];
// Query to obtain an array of student methods
$http
.get(config.backend+'/stu/'+ $scope.studentData.id +'/methods')
.success(function(data, status, headers, config) {
// Add to list
$scope.methods = data;
console.log(JSON.stringify($scope.methods));
console.log("Methods recovered");
})
.error(function(data, status, headers, config) {
console.log("Error from API: " + data.error);
});
// //
// Get last method/instruction for this student // Get last method/instruction for this student
...@@ -102,11 +145,12 @@ dashboardControllers.controller('StudentInstructionsCtrl', function StudentInstr ...@@ -102,11 +145,12 @@ dashboardControllers.controller('StudentInstructionsCtrl', function StudentInstr
$scope.update_method = function(method){ $scope.update_method = function(method){
// Remove instructions as we only update title or description // Remove instructions as we only update title or description
delete method.instructions; var method_to_save = {};
console.log(JSON.stringify(method)); Object.assign(method_to_save, method);
delete method_to_save.instructions;
$http $http
.put(config.backend+'/method/' + method.id, method) .put(config.backend+'/method/' + method.id, method_to_save)
.success(function(data, status, headers, config) { .success(function(data, status, headers, config) {
console.log('Updated method:' + JSON.stringify(data)); console.log('Updated method:' + JSON.stringify(data));
}) })
...@@ -154,26 +198,34 @@ dashboardControllers.controller('StudentInstructionsCtrl', function StudentInstr ...@@ -154,26 +198,34 @@ dashboardControllers.controller('StudentInstructionsCtrl', function StudentInstr
// Delete method t and its instructions // Delete method t and its instructions
$scope.delete_method = function(method){ $scope.delete_method = function(method){
var deleteMet = $window.confirm('Are you absolutely sure you want to delete?'); $translate('confirmation').then(function(translation) {
if(deleteMet){ newconfirm(translation).then(function() {
$http $http
.delete(config.backend+'/method/' + method.id) .delete(config.backend+'/method/' + method.id)
.success(function(data, status, headers, config) { .success(function(data, status, headers, config) {
console.log('Delete Method and its Instructions'); console.log('Delete Method and its Instructions');
console.log('Method (with Instructions):' + JSON.stringify(data)); console.log('Method (with Instructions):' + JSON.stringify(data));
// Delete in view // Delete in view
for(var i=0; i<$scope.methods.length; i++) { for(var i=0; i<$scope.methods.length; i++) {
if($scope.methods[i].id == method.id){ if($scope.methods[i].id == method.id){
$scope.methods.splice(i,1); $scope.methods.splice(i,1);
break; break;
}
} }
}
})
}) .error(function(data, status, headers, config) {
.error(function(data, status, headers, config) { console.log("Error from API: " + data.error);
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
});
});
});
});
});
}; };
// Add instruction // Add instruction
......
...@@ -25,6 +25,24 @@ dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtr ...@@ -25,6 +25,24 @@ dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtr
// Read the last working session to show the last tries when session tab is opened // Read the last working session to show the last tries when session tab is opened
$scope.wsessions = []; $scope.wsessions = [];
//
// Array with student methods (with instructions)
//
$scope.methods = [];
// Query to obtain an array of student methods
$http
.get(config.backend+'/stu/'+ $scope.studentData.id +'/methods')
.success(function(data, status, headers, config) {
// Add to list
$scope.methods = data;
console.log(JSON.stringify($scope.methods));
console.log("Methods recovered");
})
.error(function(data, status, headers, config) {
console.log("Error from API: " + data.error);
});
// Query to obtain an array of only one working session (the last) with its tries/actions // Query to obtain an array of only one working session (the last) with its tries/actions
$http $http
.get(config.backend+'/stu/'+ $scope.studentData.id +'/lasttries') .get(config.backend+'/stu/'+ $scope.studentData.id +'/lasttries')
...@@ -207,8 +225,6 @@ dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtr ...@@ -207,8 +225,6 @@ dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtr
$scope.ws = { $scope.ws = {
id: data.id id: data.id
}; };
// List of tries --> empty // List of tries --> empty
// BORRAR después lo que no sirva // BORRAR después lo que no sirva
......
...@@ -102,13 +102,12 @@ dashboardControllers.controller('StudentCtrl', function StudentCtrl($scope, conf ...@@ -102,13 +102,12 @@ dashboardControllers.controller('StudentCtrl', function StudentCtrl($scope, conf
// Defined as JSON object to be available in in children as the same scope // Defined as JSON object to be available in in children as the same scope
$scope.nav = { $scope.nav = {
tab : 'collections' tab : 'collections'
}; };
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
// COLLECTION // COLLECTION
// Load student collection // Load student collection
// //
//
// List of all student pictos // List of all student pictos
$scope.studentPictos = []; $scope.studentPictos = [];
...@@ -124,13 +123,13 @@ dashboardControllers.controller('StudentCtrl', function StudentCtrl($scope, conf ...@@ -124,13 +123,13 @@ dashboardControllers.controller('StudentCtrl', function StudentCtrl($scope, conf
}; };
// Initialization of PCB (the tablet view) and PCB-Categories // Initialization of PCB (the tablet view) and PCB-Categories
var rows = 5, cols = 10; $scope.pcb_rows = 5, $scope.pcb_cols = 10;
$scope.pcb = new Array(); $scope.pcb_cat = new Array(); $scope.pcb = new Array(); $scope.pcb_cat = new Array();
// Set te empty elements // Set the empty elements
for (var i=0;i<rows;i++) { for (var i=0;i<$scope.pcb_rows;i++) {
$scope.pcb[i]=new Array(); $scope.pcb_cat[i]=new Array(); $scope.pcb[i]=new Array(); $scope.pcb_cat[i]=new Array();
for (var j=0;j<cols; j++) { for (var j=0;j<$scope.pcb_cols; j++) {
// Default value // Default value
$scope.pcb[i][j]={'picto': {'uri': '/app/img/empty.gif'}, 'attributes': {'coord_x': i, 'coord_y': j}}; $scope.pcb[i][j]={'picto': {'uri': '/app/img/empty.gif'}, 'attributes': {'coord_x': i, 'coord_y': j}};
$scope.pcb_cat[i][j]={'picto': {'uri': '/app/img/empty.gif'}, 'attributes': {'coord_x': i, 'coord_y': j}}; $scope.pcb_cat[i][j]={'picto': {'uri': '/app/img/empty.gif'}, 'attributes': {'coord_x': i, 'coord_y': j}};
...@@ -142,9 +141,7 @@ dashboardControllers.controller('StudentCtrl', function StudentCtrl($scope, conf ...@@ -142,9 +141,7 @@ dashboardControllers.controller('StudentCtrl', function StudentCtrl($scope, conf
.success(function(data, status, headers, config) { .success(function(data, status, headers, config) {
// Add to list // Add to list
$scope.studentPictos = data; $scope.studentPictos = data;
//console.log(JSON.stringify($scope.studentPictos)); //console.log(JSON.stringify($scope.pcb_cat));
console.log("Student pictos listed");
// Filtered only the categories pictos
$scope.pictosCategory = $filter('filter')($scope.studentPictos, {attributes: { id_cat: null }}); $scope.pictosCategory = $filter('filter')($scope.studentPictos, {attributes: { id_cat: null }});
console.log("Pictos Categories: " + JSON.stringify($scope.pictosCategory)); console.log("Pictos Categories: " + JSON.stringify($scope.pictosCategory));
// Build the pcb_cat with the coords of the pictos // Build the pcb_cat with the coords of the pictos
...@@ -153,60 +150,12 @@ dashboardControllers.controller('StudentCtrl', function StudentCtrl($scope, conf ...@@ -153,60 +150,12 @@ dashboardControllers.controller('StudentCtrl', function StudentCtrl($scope, conf
$scope.pcb_cat[pic.attributes.coord_x][pic.attributes.coord_y] = pic; $scope.pcb_cat[pic.attributes.coord_x][pic.attributes.coord_y] = pic;
console.log("Pic " + pic.id + ": " + pic.attributes.color ); console.log("Pic " + pic.id + ": " + pic.attributes.color );
} }
//console.log(JSON.stringify($scope.pcb_cat));
})
.error(function(data, status, headers, config) {
console.log("Error from API: " + data.error);
});
// ----------------------------------------------------------------------
// METHODS
// Load student methods and instructions
//
//
//
// Array with methods available in meta_methods
//
$scope.methods_available = [];
// Query to meta_methods to fill the select fill with precharged methods
// and supervisor template methods
$http
.get(config.backend+'/metamethods/' + $scope.user.id)
.success(function(data, status, headers, config) {
// Add to list
$scope.methods_available = data;
console.log("Meta Methods charged:");
console.log(JSON.stringify($scope.methods_available));
// Option to add new methods
$scope.methods_available.push({ id: 0, name: "Nuevo método" });
})
.error(function(data, status, headers, config) {
console.log("Error from API: " + data.error);
});
//
// Array with student methods (with instructions)
//
$scope.methods = [];
// Query to obtain an array of student methods
$http
.get(config.backend+'/stu/'+ $scope.studentData.id +'/methods')
.success(function(data, status, headers, config) {
// Add to list
$scope.methods = data;
console.log(JSON.stringify($scope.methods));
console.log("Methods recovered");
}) })
.error(function(data, status, headers, config) { .error(function(data, status, headers, config) {
console.log("Error from API: " + data.error); console.log("Error from API: " + data.error);
}); }); // Filtered only the categories pictos
//////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////
// Devices ///////////////////////////////////////////////////////////////// // Devices /////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////
......
...@@ -71,6 +71,7 @@ ...@@ -71,6 +71,7 @@
<div ng-repeat="row in pcb" class="filaPictos"> <div ng-repeat="row in pcb" class="filaPictos">
<div class="picto pull-left" ng-repeat="col in row track by $index" id="{{col.attributes.coord_x}}_{{col.attributes.coord_y}}" draggable droppable drop="handleDrop"> <div class="picto pull-left" ng-repeat="col in row track by $index" id="{{col.attributes.coord_x}}_{{col.attributes.coord_y}}" draggable droppable drop="handleDrop">
<img src='/app/img/redcross.png' alt='' class='disabled' ng-if="col.attributes.status == 'disabled'"/>
<img ng-src="{{col.picto.uri}}" popover="{{col.expression.text}}" popover-trigger="mouseenter" ng-class="{'novisible': col.attributes.status == 'invisible', 'deactivate': col.attributes.status == 'disabled'}" /> <img ng-src="{{col.picto.uri}}" popover="{{col.expression.text}}" popover-trigger="mouseenter" ng-class="{'novisible': col.attributes.status == 'invisible', 'deactivate': col.attributes.status == 'disabled'}" />
<div class="picto_options" ng-if="col.picto.uri != '/app/img/empty.gif'"> <div class="picto_options" ng-if="col.picto.uri != '/app/img/empty.gif'">
<a ng-click="delete_picto(col)" class="picto_remove" title="{{ 'delete' | translate}}"> <a ng-click="delete_picto(col)" class="picto_remove" title="{{ 'delete' | translate}}">
......
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