Commit 33d65db5 by Arturo Montejo Ráez

Merge branch 'issue702' into develop

parents 46f369eb ca3f0369
...@@ -5,7 +5,7 @@ buildscript { ...@@ -5,7 +5,7 @@ buildscript {
jcenter() jcenter()
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:2.2.3' classpath 'com.android.tools.build:gradle:2.3.0-alpha3'
// 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
......
...@@ -2,7 +2,7 @@ apply plugin: 'com.android.library' ...@@ -2,7 +2,7 @@ apply plugin: 'com.android.library'
android { android {
compileSdkVersion 21 compileSdkVersion 21
buildToolsVersion "21.1.2" buildToolsVersion '25.0.0'
defaultConfig { defaultConfig {
minSdkVersion 21 minSdkVersion 21
......
#Mon Aug 29 01:05:09 CEST 2016 #Sun Jan 15 10:11:11 CET 2017
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.14.1-all.zip distributionUrl=https\://services.gradle.org/distributions/gradle-3.2-all.zip
...@@ -11,7 +11,7 @@ android { ...@@ -11,7 +11,7 @@ android {
}*/ }*/
compileSdkVersion 24 compileSdkVersion 24
buildToolsVersion "23.0.2" buildToolsVersion '25.0.0'
defaultConfig { defaultConfig {
applicationId "com.yottacode.supervisor_tablet" applicationId "com.yottacode.supervisor_tablet"
minSdkVersion 21 minSdkVersion 21
......
...@@ -2,7 +2,7 @@ apply plugin: 'com.android.library' ...@@ -2,7 +2,7 @@ apply plugin: 'com.android.library'
android { android {
compileSdkVersion 24 compileSdkVersion 24
buildToolsVersion "23.0.2" buildToolsVersion '25.0.0'
defaultConfig { defaultConfig {
minSdkVersion 21 minSdkVersion 21
targetSdkVersion 22 targetSdkVersion 22
......
...@@ -3,7 +3,7 @@ apply plugin: 'com.android.application' ...@@ -3,7 +3,7 @@ apply plugin: 'com.android.application'
android { android {
compileSdkVersion 24 compileSdkVersion 24
buildToolsVersion "23.0.2" buildToolsVersion '25.0.0'
defaultConfig { defaultConfig {
applicationId "com.yottacode.watch" applicationId "com.yottacode.watch"
......
...@@ -11,7 +11,7 @@ android { ...@@ -11,7 +11,7 @@ android {
}*/ }*/
compileSdkVersion 24 compileSdkVersion 24
buildToolsVersion "23.0.2" buildToolsVersion '25.0.0'
defaultConfig { defaultConfig {
applicationId "com.yottacode.pictogram.yotta_tablet" applicationId "com.yottacode.pictogram.yotta_tablet"
minSdkVersion 21 minSdkVersion 21
...@@ -34,6 +34,10 @@ android { ...@@ -34,6 +34,10 @@ android {
resValue "string", "server", "https://pre.yottacode.com" resValue "string", "server", "https://pre.yottacode.com"
resValue "bool", "ssl_connect", "true" resValue "bool", "ssl_connect", "true"
} }
LocalFlavor {
resValue "string", "server", "http://192.168.1.36:1337"
resValue "bool", "ssl_connect", "false"
}
} }
} }
......
-- MySQL dump 10.13 Distrib 5.7.13, for Linux (x86_64)
--
-- Host: localhost Database: pictodbclean
-- ------------------------------------------------------
-- Server version 5.7.13
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
--
-- Table structure for table `pictocat`
--
DROP TABLE IF EXISTS `pictocat`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `pictocat` (
`id` int(11) NOT NULL,
`id_supercat` int(11) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='Identifies a category, which, itself, may belong to another category';
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `pictocat`
--
LOCK TABLES `pictocat` WRITE;
/*!40000 ALTER TABLE `pictocat` DISABLE KEYS */;
INSERT INTO `pictocat` VALUES (1,0),(2,1),(3,1),(4,0),(5,0),(6,1),(7,0),(8,1),(9,0),(10,0),(11,0),(12,0),(13,0),(14,0),(15,0),(16,0),(17,16),(18,16),(19,0),(20,0),(21,16),(22,0),(23,22),(24,16),(25,16),(26,0),(27,0),(28,0),(29,0),(30,29),(31,29),(32,29),(33,0),(34,0),(35,22),(36,0),(37,5),(38,0),(39,0),(40,12),(41,15),(42,0),(43,0),(44,0),(45,9),(46,0),(47,0),(48,0),(49,0),(50,0),(51,0),(52,0),(53,0),(54,53),(55,53),(56,53),(57,53),(58,53),(59,53),(60,53),(61,53),(62,53),(63,53),(64,53),(65,51),(66,20),(67,0),(68,0),(69,0),(70,0),(71,0),(72,20),(73,0),(74,0),(75,0),(76,71),(77,20),(78,51),(79,0),(80,0),(81,5),(82,22),(83,0),(84,0),(85,84),(86,84),(87,51),(88,0),(89,20),(90,0),(91,51),(92,80),(93,0),(94,0),(95,0),(96,0),(97,0),(98,97),(99,97),(100,80),(101,69),(102,51),(103,51),(104,0),(105,51),(106,69),(107,69),(108,0),(109,69),(110,69),(111,69),(112,69),(113,69),(114,0),(115,71),(116,0),(117,0),(118,0),(119,0),(120,0),(121,0),(122,0);
/*!40000 ALTER TABLE `pictocat` ENABLE KEYS */;
UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2017-01-17 9:48:07
...@@ -44,6 +44,20 @@ CREATE TABLE IF NOT EXISTS `action` ( ...@@ -44,6 +44,20 @@ CREATE TABLE IF NOT EXISTS `action` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1
COMMENT="This table registers and action performed by a user at a given time, all information of the action is in JSON format in the 'description' column and the operation performed is one of the possible for the 'type' column. NOTE: timestamps must support fractional seconds, so MySQL versions >= 5.6.4 are required."; COMMENT="This table registers and action performed by a user at a given time, all information of the action is in JSON format in the 'description' column and the operation performed is one of the possible for the 'type' column. NOTE: timestamps must support fractional seconds, so MySQL versions >= 5.6.4 are required.";
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `catexp`
--
CREATE TABLE IF NOT EXISTS `catexp`(
`id` int(11) NOT NULL AUTO_INCREMENT,
`id_cat` int(11) NOT NULL,
`lang` char(5),
`exp` varchar(30) NOT NULL,
PRIMARY KEY(`id`),
UNIQUE(exp,lang),
CHECK (lang IN ('es-es','en-gb','en-us'))
)
COMMENT="Stores the expressions available in several languages for a given category (id_cat)";
-- -------------------------------------------------------- -- --------------------------------------------------------
...@@ -180,6 +194,18 @@ COMMENT="Stablish access rights to pictos"; ...@@ -180,6 +194,18 @@ COMMENT="Stablish access rights to pictos";
-- -------------------------------------------------------- -- --------------------------------------------------------
-- --
-- Estructura de tabla para la tabla `pictocat`
--
CREATE TABLE IF NOT EXISTS `pictocat`(
`id` int(11) PRIMARY KEY,
`id_supercat` int(11)
)
COMMENT="Identifies a category, which, itself, may belong to another category";
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `picto_core` -- Estructura de tabla para la tabla `picto_core`
-- --
......
...@@ -55,7 +55,7 @@ thisTrigger: BEGIN ...@@ -55,7 +55,7 @@ thisTrigger: BEGIN
office.id=new.id_off; office.id=new.id_off;
INSERT INTO stu_picto(id_stu,id_pic,attributes) INSERT INTO stu_picto(id_stu,id_pic,attributes)
SELECT new.id,id_pic, concat('{"id_cat":', if (id_cat_pic is null, 'null',id_cat_pic), SELECT new.id,id_pic, concat('{"id_cat":', if (id_cat_pic is null, 'null', id_cat_pic),
',"coord_x":',coord_x, ',"coord_x":',coord_x,
',"coord_y":',coord_y, ',"coord_y":',coord_y,
',"status":"invisible"', ',"status":"invisible"',
......
...@@ -39,15 +39,15 @@ module.exports = { ...@@ -39,15 +39,15 @@ module.exports = {
.then(function (categories) { .then(function (categories) {
res.ok(categories); res.ok(categories);
}) })
.catch(function () { .catch(function (err) {
res.serverError(); throw err;
}); });
} else { } else {
res.badRequest(); res.badRequest();
} }
}) })
.catch(function () { .catch(function (err) {
res.serverError(); res.serverError(err);
}); });
}, },
......
...@@ -929,8 +929,6 @@ module.exports = { ...@@ -929,8 +929,6 @@ module.exports = {
// //
update_picto: function (req, res) { update_picto: function (req, res) {
var params = req.allParams(); var params = req.allParams();
console.log('Updating attributes for picto student ' + JSON.stringify(params));
console.log(JSON.stringify(params));
query = params.id_stuPicto ? { query = params.id_stuPicto ? {
id: params.id_stuPicto id: params.id_stuPicto
...@@ -946,7 +944,6 @@ module.exports = { ...@@ -946,7 +944,6 @@ module.exports = {
if (!updated) if (!updated)
throw new Error ("error on update"); throw new Error ("error on update");
console.log('Updated attributes for picto student:' + JSON.stringify(updated[0]));
// return res.json(updated[0]); // return res.json(updated[0]);
return res.ok({ return res.ok({
id: updated[0].id, // id of stu_picto id: updated[0].id, // id of stu_picto
...@@ -961,6 +958,69 @@ module.exports = { ...@@ -961,6 +958,69 @@ module.exports = {
}); });
}, },
/*
* Updates the category picto for all pictos in the student collection
* @param {request} req {
* 'id_stu': <student_id>,
* 'prev_id_stu_pic': <ID of previous category entry in stu_picto>,
* 'new_id_pic': <ID of the picto to be the replacement>
* }
* @param {response} res {
* 'id_stu_pic': <id of the new category in stu_picto>,
* 'attributes': <attributes of the new category picto>,
* 'picto': <picto information used as new category>
* }
*
*/
update_category: function (req, res) {
var params = req.allParams();
var attrs = {};
StuPicto.findOne(params.prev_id_stu_pic)
.then((sp) => {
if (!sp) throw new Error ("error on update");
// Get student to get language
Student.findOne(params.id_stu)
.then((s) => {
if (!s) throw new Error("Student not found");
PictoExp.findOne({id_pic: sp.picto, lang: s.lang})
.then((pe) => {
if (!pe) throw new Error ("Expression not found");
// store old picto id to update pictos in category
var old_picto = sp.picto;
if (sp.attributes.expression == undefined || sp.attributes.expression == null)
sp.attributes.expression = pe.text;
sp.picto = params.new_id_pic;
// Save modified stu_picto entry for category
sp.save((err) => {
if (err) throw err;
// Update attributes.id_cat for all pictos
StuPicto.find({id_stu: params.id_stu})
.then(sps => {
for (var i=0; i<sps.length; i++) {
if (sps[i].attributes.id_cat == old_picto) {
sps[i].attributes.id_cat = params.new_id_pic;
sps[i].save();
}
}
return res.ok(sp);
})
.catch(err => {throw err});
});
})
.catch(err => {throw err});
})
.catch(err => {throw err})
})
.catch(err => {
return res.serverError('Unable to update category for student: ' + err);
});
},
// update action // update action
// update picto atributes for a studentPicto // update picto atributes for a studentPicto
// //
......
/**
* catexp.js
*
* @description :: TODO: Write a short summary of how this model works and what it represents here.
* @docs :: http://sailsjs.org/#!documentation/models
*/
module.exports = {
tableName : 'catexp',
migrate : 'safe',
schema : true,
autoPK : false,
autoCreatedAt : false,
autoUpdatedAt : false,
attributes: {
id: {
type: "integer",
primaryKey: true,
unique: true
},
id_cat: {
type: "integer",
required: true,
model: 'PictoCat'
},
lang: {
required: true,
type: "string",
size: 5
},
exp: {
required: false,
type: "string",
size: 30
}
}
};
\ No newline at end of file
/**
* pictocat.js
*
* @description :: TODO: Write a short summary of how this model works and what it represents here.
* @docs :: http://sailsjs.org/#!documentation/models
*/
module.exports = {
tableName : 'pictocat',
migrate : 'safe',
schema : true,
autoPK : false,
autoCreatedAt : false,
autoUpdatedAt : false,
attributes: {
id: {
type: "integer",
primaryKey: true,
unique: true
},
id_supercat: {
type: "integer",
required: false
},
exps: {
collection: "CatExp",
via: 'id_cat'
}
}
};
\ No newline at end of file
...@@ -381,7 +381,7 @@ module.exports = { ...@@ -381,7 +381,7 @@ module.exports = {
var stuPictoToAdd = { var stuPictoToAdd = {
"id": stuPicto.id, "id": stuPicto.id,
"picto": stuPicto.picto, "picto": stuPicto.picto,
"expression": picto.expressions[0], "expression": stuPicto.attributes.expression ? stuPicto.attributes.expression : picto.expressions[0].text,
"attributes": stuPicto.attributes, "attributes": stuPicto.attributes,
"tags": picto.tags ? picto.tags : [] "tags": picto.tags ? picto.tags : []
}; };
......
...@@ -42,6 +42,7 @@ ...@@ -42,6 +42,7 @@
"categories": "Categories", "categories": "Categories",
"category_pictograms": "Category's pictograms", "category_pictograms": "Category's pictograms",
"change_password": "Change password", "change_password": "Change password",
"change_cat_picto": "Change category pictogram",
"change_picture": "Change picture", "change_picture": "Change picture",
"child": "Child", "child": "Child",
"click": "Click", "click": "Click",
...@@ -101,11 +102,12 @@ ...@@ -101,11 +102,12 @@
"error_on_request": "The request has not been processed. Please, check your fields", "error_on_request": "The request has not been processed. Please, check your fields",
"error_on_request_sup_not_found": "Account not found or it has not been activated", "error_on_request_sup_not_found": "Account not found or it has not been activated",
"error_on_upload": "Error on image upload. The maximum allowed size for images is 1 MB.", "error_on_upload": "Error on image upload. The maximum allowed size for images is 1 MB.",
"error_on_update": "Error on update",
"error_loading_pictos": "Error loading pictos information", "error_loading_pictos": "Error loading pictos information",
"error_general": "An error has been produced", "error_general": "An error has been produced",
"expand_navigation": "Expand navigation", "expand_navigation": "Expand navigation",
"expand_navigation": "Expand navigation", "expand_navigation": "Expand navigation",
"expression": "Expression:", "expression": "Expression",
"February": "February", "February": "February",
"feedback_picto": "Selection feedback", "feedback_picto": "Selection feedback",
"filter": "Filter", "filter": "Filter",
...@@ -244,6 +246,7 @@ ...@@ -244,6 +246,7 @@
"profile_picture": "Profile picture", "profile_picture": "Profile picture",
"read_picto": "Read picto", "read_picto": "Read picto",
"register": "Sign in", "register": "Sign in",
"reloading_pictos": "Reloading pictograms",
"remember": "Remember me", "remember": "Remember me",
"reports": "Reports", "reports": "Reports",
"request_change_password": "Request change password", "request_change_password": "Request change password",
......
...@@ -42,6 +42,7 @@ ...@@ -42,6 +42,7 @@
"categories": "Categorías", "categories": "Categorías",
"category_pictograms": "Pictogramas de la categoría", "category_pictograms": "Pictogramas de la categoría",
"change_password": "Cambiar contraseña", "change_password": "Cambiar contraseña",
"change_cat_picto": "Cambiar pictograma de la categoría",
"change_picture": "Cambiar fotografía", "change_picture": "Cambiar fotografía",
"child": "Niño", "child": "Niño",
"click": "Clic", "click": "Clic",
...@@ -93,7 +94,7 @@ ...@@ -93,7 +94,7 @@
"enormous": "Enorme", "enormous": "Enorme",
"expand_navigation": "Desplegar navegación", "expand_navigation": "Desplegar navegación",
"expand_navigation": "Desplegar navegación", "expand_navigation": "Desplegar navegación",
"expression": "Expresión:", "expression": "Expresión",
"error_adding_picto": "Error al añadir el picto", "error_adding_picto": "Error al añadir el picto",
"error_creating_session": "Error al crear sesión", "error_creating_session": "Error al crear sesión",
"error_deleting_picto": "Error borrando el picto", "error_deleting_picto": "Error borrando el picto",
...@@ -103,6 +104,7 @@ ...@@ -103,6 +104,7 @@
"error_only_support_images": "Sólo se soportan imágenes (ficheros JPG, PNG o GIF)", "error_only_support_images": "Sólo se soportan imágenes (ficheros JPG, PNG o GIF)",
"error_on_request": "Se ha producido un error. Por favor, compruebe los valores introducidos.", "error_on_request": "Se ha producido un error. Por favor, compruebe los valores introducidos.",
"error_on_request_sup_not_found": "La cuenta no existe o no ha sido activada", "error_on_request_sup_not_found": "La cuenta no existe o no ha sido activada",
"error_on_update": "Error al actualizar",
"error_on_upload": "Error al subir la imagen. Compruebe que el archivo no supera 1MB de tamaño.", "error_on_upload": "Error al subir la imagen. Compruebe que el archivo no supera 1MB de tamaño.",
"error_loading_pictos": "Error cargando información de los pictos", "error_loading_pictos": "Error cargando información de los pictos",
"error_general": "Se ha producido un error", "error_general": "Se ha producido un error",
...@@ -245,6 +247,7 @@ ...@@ -245,6 +247,7 @@
"read_picto": "Leer picto", "read_picto": "Leer picto",
"register": "Regístrate", "register": "Regístrate",
"register_button": "Registrar", "register_button": "Registrar",
"reloading_pictos": "Recargando pictogramas",
"remember": "No cerrar sesión", "remember": "No cerrar sesión",
"reports": "Informes", "reports": "Informes",
"request_change_password": "Solicitar cambio de contraseña", "request_change_password": "Solicitar cambio de contraseña",
......
...@@ -138,45 +138,6 @@ dashboardControllers.controller('AddPictoCtrl', function ( ...@@ -138,45 +138,6 @@ dashboardControllers.controller('AddPictoCtrl', function (
}; };
/** /**
* It replaces the image associated to a picto (making a
* POST request to /picto/upload) but keeping the rest of attributes.
* @param {Array of Objects} $files Array of pictos to be uploaded the file
* itself (as binary data) will be sent.
*/
$scope.changePictoImg = function ($files, id_pic) {
$files.forEach(function (file) {
if (file.type === 'image/jpeg' || file.type === 'image/png' || file.type === 'image/gif') {
$upload.upload({
url: '/picto/update',
method: 'UPDATE',
fields: { owner: supervisor.id, id_pic: id_pic},
file: file
}).success(function (picto) {
$translate('picto_upload_success').then(function (translation) {
ngToast.success(translation);
});
picto.expressions = [];
$scope.pictos.push(picto);
$scope.open_exp(picto);
}).error(function (err) {
if (err.code == "E_EXCEEDS_UPLOAD_LIMIT")
$translate('picto_upload_limit').then(function (translation) {
ngToast.danger(translation);
});
else
$translate('picto_upload_error').then(function (translation) {
ngToast.danger(translation);
});
});
} else {
$translate('invalid_file_type').then(function (translation) {
ngToast.danger(translation);
});
}
});
};
/**
* When a image file is selected it tries to upload it as custom picto (making a * When a image file is selected it tries to upload it as custom picto (making a
* POST request to /picto/upload). * POST request to /picto/upload).
* @param {Array of Objects} $files Array of pictos to be uploaded the file * @param {Array of Objects} $files Array of pictos to be uploaded the file
......
...@@ -52,7 +52,6 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec ...@@ -52,7 +52,6 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec
$scope.selectedCategory = $scope.emptyStudentPicto; $scope.selectedCategory = $scope.emptyStudentPicto;
$scope.studentPictos = {}; $scope.studentPictos = {};
$scope.freeCategoryPictos = null; $scope.freeCategoryPictos = null;
$scope.categories = [];
$scope.loadingPictos = true; $scope.loadingPictos = true;
$scope.isCategory = function (studentPicto) { $scope.isCategory = function (studentPicto) {
...@@ -109,10 +108,6 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec ...@@ -109,10 +108,6 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec
$scope.studentPictos[$scope.getCategoryId($scope.selectedCategory)] = $scope.studentPictos[$scope.getCategoryId($scope.selectedCategory)] =
$scope.studentPictos[$scope.getCategoryId($scope.selectedCategory)] || generateGrid(); $scope.studentPictos[$scope.getCategoryId($scope.selectedCategory)] || generateGrid();
if ($scope.isCategory(picto)) {
$scope.categories.push(picto);
}
// Categories disabled // Categories disabled
if (typeof freeCategoryPositionX === 'number' && if (typeof freeCategoryPositionX === 'number' &&
typeof freeCategoryPositionY === 'number') { typeof freeCategoryPositionY === 'number') {
...@@ -126,6 +121,7 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec ...@@ -126,6 +121,7 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec
$scope.getCategoryId(picto); $scope.getCategoryId(picto);
$scope.studentPictos[category] = $scope.studentPictos[category] || generateGrid(); $scope.studentPictos[category] = $scope.studentPictos[category] || generateGrid();
$scope.studentPictos[category][positionX][positionY] = picto; $scope.studentPictos[category][positionX][positionY] = picto;
console.log("picto placed at " + positionX + " " + positionY);
} }
}; };
...@@ -140,7 +136,6 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec ...@@ -140,7 +136,6 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec
// Get user's pictos // Get user's pictos
$http.get(config.backend + '/stu/' + $scope.studentData.id + '/pictos') $http.get(config.backend + '/stu/' + $scope.studentData.id + '/pictos')
.success(function (studentPictos) { .success(function (studentPictos) {
$scope.categories = [];
$scope.showFreeCategory = !$scope.studentData.attributes.categories; $scope.showFreeCategory = !$scope.studentData.attributes.categories;
studentPictos.forEach(placePicto); studentPictos.forEach(placePicto);
...@@ -310,7 +305,54 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec ...@@ -310,7 +305,54 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec
}); });
}; };
// Modal window to add pictos //
// Change category's pictogram
//
$scope.change_category = function (picto_cat) {
var modalInstance = $modal.open({
animation: true,
templateUrl: 'modules/student/views/addpicto.html',
controller: 'AddPictoCtrl',
size: 'lg',
resolve: {
student: function () {
return $scope.studentData;
},
supervisor: function () {
return $scope.user;
}
}
});
// Returned data from the modal window
modalInstance.result.then(function (pictoId) {
// Send the picto to the server
$http.put(config.backend + '/stu/' + $scope.studentData.id + '/cat', {
prev_id_stu_pic: picto_cat.id,
new_id_pic: pictoId
})
.success(function (studentPicto) {
console.log(JSON.stringify(studentPicto));
$scope.loadPictos();
// notify
io.socket.post('/stu/vocabulary', {
action: 'update',
attributes: {
id_stu: $scope.studentData.id,
stu_picto: studentPicto
}
}, function () {});
})
.error(function () {
ngToast.danger({ content: $translate.instant('error_updating_category') });
});
});
};
//
// Adds a new pictogram
//
$scope.open_add = function (col, row) { $scope.open_add = function (col, row) {
console.log(col + " " +row); console.log(col + " " +row);
var modalInstance = $modal.open({ var modalInstance = $modal.open({
...@@ -342,7 +384,7 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec ...@@ -342,7 +384,7 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec
} }
}) })
.success(function (studentPicto) { .success(function (studentPicto) {
console.log(studentPicto.attributes); console.log(studentPicto);
placePicto(studentPicto); placePicto(studentPicto);
io.socket.post('/stu/vocabulary', { io.socket.post('/stu/vocabulary', {
...@@ -355,9 +397,7 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec ...@@ -355,9 +397,7 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec
}) })
.error(function () { .error(function () {
$translate('error_adding_picto').then(function (translation) { ngToast.danger({ content: $translate.instant('error_adding_picto') });
ngToast.danger({ content: translation });
});
}); });
// not needed // not needed
...@@ -409,7 +449,7 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec ...@@ -409,7 +449,7 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec
}); });
// Returned data from the modal window // Returned data from the modal window
modalInstance.result.then(function (exp) { modalInstance.result.then(function (exp) {
studentPicto.expression.text = exp; studentPicto.expression = exp;
}); });
}; };
......
...@@ -3,109 +3,87 @@ ...@@ -3,109 +3,87 @@
// Please note that $modalInstance represents a modal window (instance) dependency. // Please note that $modalInstance represents a modal window (instance) dependency.
// It is not the same as the $modal service used above. // It is not the same as the $modal service used above.
dashboardControllers.controller('PictoConfigCtrl', function ($window, $scope, $modalInstance, $http, config, studentPicto, sup, stu) { dashboardControllers.controller('PictoConfigCtrl', function ($window, $scope, $translate, $modalInstance, $http, config, ngToast, studentPicto, sup, stu) {
// Last parameter passed from collections.js
// Basic data passed from the main window
// Student
$scope.stu = stu;
// Supervisor
$scope.sup = sup;
// Picto // Picto
$scope.studentPicto = studentPicto; $scope.studentPicto = JSON.parse(JSON.stringify(studentPicto));
// Input expression
if ($scope.studentPicto.attributes.expression==undefined || $scope.studentPicto.attributes.expression==null) /*
$scope.studentPicto.attributes.expression=studentPicto.expression.text; * Save changes introduced in dialog window
// Enable or Disable the button 'change' if the supervisor is the owner of the picto */
$scope.isOwner = (studentPicto.picto.owner == sup.id) ? true : false; $scope.save = function () {
// Change expression (if the picto is owned by the supervisor) if ($scope.studentPicto.expression != studentPicto.expression) {
$scope.change = function () { // Update picto expressio because user owns it
if (studentPicto.picto.owner == sup.id) {
// Comprobación del supervisor propietario del picto $http
if(studentPicto.picto.owner == sup.id){ .post(config.backend+'/picto/exp',
$http { 'picto': studentPicto.picto.id,
.post(config.backend+'/picto/exp', 'lang': sup.lang,
{ 'picto': studentPicto.picto.id, 'text': $scope.studentPicto.expression
'lang': $scope.sup.lang, })
'text': $scope.studentPicto.expression.text .success(function(data, status, headers, config) {
}) io.socket.post('/stu/vocabulary', {
.success(function(data, status, headers, config) { action: 'update',
console.log("Expression changed: " + JSON.stringify(data)+": "+$scope.studentPicto.expression.text); attributes: {
$scope.studentPicto.attributes.expression=$scope.studentPicto.expression.text; id_stu: stu.id,
// Close the modal instance stu_picto: {
//$modalInstance.close($scope.studentPicto.expression.text); id: data.id,
expression: data.expression,
// Notifcar cambio attributes: $scope.studentPicto.attributes,
io.socket.post('/stu/vocabulary', { picto: { id: data.picto }
action: 'update', }
attributes: {
id_stu: $scope.stu.id,
stu_picto: {
id: data.id,
expression: data.expression,
attributes: $scope.studentPicto.attributes,
picto: { id: data.picto }
} }
} }, function (res) {});
}, function (res) {console.log("Owned vocabulary emited: " + JSON.stringify(res.msg));}); })
.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); } else {
}); $scope.studentPicto.attributes.expression = $scope.studentPicto.expression;
}
} }
}; // Update attributes
$scope.update_properties = function(){
console.log("Atributos: " + JSON.stringify($scope.studentPicto.attributes));
$http $http
.put(config.backend+'/stu/'+ $scope.stu.id + '/picto/' + $scope.studentPicto.id, .put(config.backend+'/stu/'+ stu.id + '/picto/' + $scope.studentPicto.id,
{ {
'attributes': $scope.studentPicto.attributes 'attributes': $scope.studentPicto.attributes
}) })
.success(function(data, status, headers, config) { .success(function(data, status, headers, config) {
console.log("Properties updated");
// Close the modal instance
//$modalInstance.close($scope.expression);
// /////////////////////////////////////////////////////////////
// Websocket: Emit vocabulary update action
io.socket.post('/stu/vocabulary', { io.socket.post('/stu/vocabulary', {
action: 'update', action: 'update',
attributes: { attributes: {
id_stu: $scope.stu.id, id_stu: stu.id,
stu_picto: data stu_picto: data
} }
}, },
function(res) { function(res) {});
console.log("Vocabulary emited: " + JSON.stringify(res.msg));
});
///////////////////////////////////////////////////////////////
}) })
.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);
}); });
};
$scope.update_legend = function(){ // Update all lengends format
console.log("Legend: " + $scope.studentPicto.attributes.legend+" to be modified"); if ($scope.update_all_legend) {
$http
$http .put(config.backend+'/stu/'+ stu.id + '/legend/' + $scope.studentPicto.attributes.legend)
.put(config.backend+'/stu/'+ $scope.stu.id + '/legend/' + $scope.studentPicto.attributes.legend) .success(function(data, status, headers, config) {
.success(function(data, status, headers, config) { })
console.log("Legend updated"); .error(function(data, status, headers, config) {
console.log("Error from API: " + data.error);
});
}
// Close the modal instance studentPicto.expression = $scope.studentPicto.expression;
$modalInstance.close($scope.expression); studentPicto.attributes = $scope.studentPicto.attributes;
$modalInstance.close($scope.studentPicto.expression);
if ($scope.update_all_legend) {
ngToast.success({ content: $translate.instant('reloading_pictos') });
$window.location.reload(); $window.location.reload();
}); }
}; };
$scope.close = function () { $scope.close = function () {
// Lo que se devuelve a collection // Lo que se devuelve a collection
......
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
('empty-' + colIndex + '-' + rowIndex) ('empty-' + colIndex + '-' + rowIndex)
}}" }}"
draggable droppable drop="handleDrop" draggable droppable drop="handleDrop"
popover="{{studentPicto.attributes.expression==null ? studentPicto.expression.text : studentPicto.attributes.expression}}" popover="{{studentPicto != emptyStudentPicto ? studentPicto.expression : ''}}"
popover-trigger="mouseenter" popover-trigger="mouseenter"
ng-init="colIndex = $index" ng-init="colIndex = $index"
ng-repeat="studentPicto in studentPictoRow track by $index"> ng-repeat="studentPicto in studentPictoRow track by $index">
...@@ -41,13 +41,12 @@ ...@@ -41,13 +41,12 @@
<div <div
class="picto-legend-normal" class="picto-legend-normal"
ng-if="studentPicto.attributes.legend == 'normal'"> ng-if="studentPicto.attributes.legend == 'normal'">
{{ studentPicto.attributes.expression==null ? studentPicto.expression.text : studentPicto.attributes.expression }} {{ studentPicto.expression }}
</div> </div>
<div <div
class="picto-legend-full" class="picto-legend-full"
ng-if="studentPicto.attributes.legend == 'full'"> ng-if="studentPicto.attributes.legend == 'full'">
{{ studentPicto.attributes.expression==null ? studentPicto.expression.text : studentPicto.attributes.expression }} {{ studentPicto.expression }}
</div> </div>
<!-- /.picto-legend --> <!-- /.picto-legend -->
<img <img
...@@ -121,19 +120,19 @@ ...@@ -121,19 +120,19 @@
class="picto pull-left ng-class:{'picto-out': studentData.attributes.size == 'large' && (rowIndex > 3 || colIndex > 7)};" class="picto pull-left ng-class:{'picto-out': studentData.attributes.size == 'large' && (rowIndex > 3 || colIndex > 7)};"
ng-repeat="studentPicto in studentPictoRow track by $index" ng-repeat="studentPicto in studentPictoRow track by $index"
ng-init="colIndex = $index" ng-init="colIndex = $index"
popover="{{studentPicto.attributes.expression==null ? studentPicto.expression.text : studentPicto.attributes.expression}}" popover="{{ studentPicto != emptyStudentPicto ? studentPicto.expression : ''}}"
popover-trigger="mouseenter"> popover-trigger="mouseenter">
<!-- picto-legend --> <!-- picto-legend -->
<div <div
class="picto-legend-normal" class="picto-legend-normal"
ng-if="studentPicto.attributes.legend == 'normal'"> ng-if="studentPicto.attributes.legend == 'normal'">
{{ studentPicto.attributes.expression==null ? studentPicto.expression.text : studentPicto.attributes.expression }} {{ studentPicto.expression }}
</div> </div>
<div <div
class="picto-legend-full" class="picto-legend-full"
ng-if="studentPicto.attributes.legend == 'full'"> ng-if="studentPicto.attributes.legend == 'full'">
{{ studentPicto.attributes.expression==null ? studentPicto.expression.text : studentPicto.attributes.expression }} {{ studentPicto.expression }}
</div> </div>
<!-- /.picto-legend --> <!-- /.picto-legend -->
<img <img
...@@ -175,9 +174,13 @@ ...@@ -175,9 +174,13 @@
title="{{ studentPicto.attributes.status | translate}}"></i> title="{{ studentPicto.attributes.status | translate}}"></i>
</a> </a>
<a <a
ng-click="" ng-click="change_category(studentPicto)"
ng-if="studentPicto !== emptyStudentPicto && studentPicto.attributes.coord_y != '0'"
class="picto_cat_edit"> class="picto_cat_edit">
<i class="glyphicon glyphicon-picture" aria-hidden="true"></i> <i
class="glyphicon glyphicon-picture" aria-hidden="true"
title="{{ 'change_cat_picto' | translate}}">
</i>
</a> </a>
</div> </div>
<div <div
...@@ -222,7 +225,7 @@ ...@@ -222,7 +225,7 @@
class="picto-grid picto-category-grid" class="picto-grid picto-category-grid"
ng-if="selectedCategory !== emptyStudentPicto && !showFreeCategory" ng-if="selectedCategory !== emptyStudentPicto && !showFreeCategory"
ng-style="{ 'background-color': shadeColor(selectedCategory.attributes.color, 0.3) }"> ng-style="{ 'background-color': shadeColor(selectedCategory.attributes.color, 0.3) }">
<h3 class="picto-category-grid__title">{{ selectedCategory.expression.text }}</h3> <h3 class="picto-category-grid__title">{{ selectedCategory.expression }}</h3>
<div <div
ng-repeat="studentPictoRow in studentPictos[getCategoryId(selectedCategory)]" ng-repeat="studentPictoRow in studentPictos[getCategoryId(selectedCategory)]"
ng-init="rowIndex = $index" ng-init="rowIndex = $index"
...@@ -236,7 +239,7 @@ ...@@ -236,7 +239,7 @@
('empty-' + colIndex + '-' + rowIndex) ('empty-' + colIndex + '-' + rowIndex)
}}" }}"
draggable droppable drop="handleDrop" draggable droppable drop="handleDrop"
popover="{{studentPicto.attributes.expression==null ? studentPicto.expression.text : studentPicto.attributes.expression}}" popover="{{ studentPicto != emptyStudentPicto ? studentPicto.expression : '' }}"
popover-trigger="mouseenter" popover-trigger="mouseenter"
ng-repeat="studentPicto in studentPictoRow track by $index" ng-repeat="studentPicto in studentPictoRow track by $index"
ng-init="colIndex = $index"> ng-init="colIndex = $index">
...@@ -244,13 +247,13 @@ ...@@ -244,13 +247,13 @@
<div <div
class="picto-legend-normal" class="picto-legend-normal"
ng-if="studentPicto.attributes.legend == 'normal'"> ng-if="studentPicto.attributes.legend == 'normal'">
{{ studentPicto.attributes.expression==null ? studentPicto.expression.text : studentPicto.attributes.expression }} {{ studentPicto.expression }}
</div> </div>
<div <div
class="picto-legend-full" class="picto-legend-full"
ng-if="studentPicto.attributes.legend == 'full'"> ng-if="studentPicto.attributes.legend == 'full'">
{{ studentPicto.attributes.expression==null ? studentPicto.expression.text : studentPicto.attributes.expression }} {{ studentPicto.expression }}
</div> </div>
<!-- /.picto-legend --> <!-- /.picto-legend -->
<img <img
......
...@@ -6,73 +6,49 @@ ...@@ -6,73 +6,49 @@
<h4 class="modal-title" id="myModalLabel" translate>pictogram_setup</h4> <h4 class="modal-title" id="myModalLabel" translate>pictogram_setup</h4>
</div> </div>
<div class="modal-body"> <div class="modal-body">
<ul class="list-group"> <div class="form-group">
<label translate>expression</label>
<!-- Modificable sólo si es el propietario del picto -->
<div id="add_label" class="input-group">
<span class="input-group-addon glyphicon glyphicon-comment" aria-hidden="true"></span>
<input type="text" class="form-control" ng-model="studentPicto.expression" />
</div>
</div>
<li class="list-group-item"> <div class="form-group">
<label translate>expression</label> <label translate>legend</label><br/>
<!-- Modificable sólo si es el propietario del picto --> <div class="row">
<form ng-submit="isOwner ? change() : update_properties()"> <div class="col-md-6">
<div id="add_label" class="input-group"> <!-- <div class="checkbox">
<span class="input-group-addon glyphicon glyphicon-comment" aria-hidden="true"></span> <select class="form-control" data-toggle="toggle" ng-model="studentPicto.attributes.legend" ng-change="update_properties()">
<input type="text" class="form-control" ng-if="isOwner" ng-model="studentPicto.expression.text" /> <option value="none" selected>Sin leyenda</option>
<input type="text" class="form-control" ng-if="!isOwner" ng-model="studentPicto.attributes.expression" /> <option value="normal">Leyenda normal</option>
<span class="input-group-btn"> <option value="full">Solo leyenda</option>
<button class="btn btn-success" type="submit" ng-click="close()" translate>save</button> </select>
</span> </div> -->
</div> <input type="radio" ng-model="studentPicto.attributes.legend" value="none">
</form> <span translate>legend_none</span>
</li> <br/>
<input type="radio" ng-model="studentPicto.attributes.legend" value="normal">
<!-- <span translate>legend_normal</span>
<li class="list-group-item"> <br/>
<div class="checkbox"> <input type="radio" ng-model="studentPicto.attributes.legend" value="full">
<label><input data-toggle="toggle" type="checkbox" ng-model="studentPicto.attributes.magnify" ng-change="update_properties()"> Aumentado</label> <span translate>legend_full</span>
</div> </div>
</li> <div class="col-md-6">
--> <input type="checkbox" ng-model="update_all_legend" ng-init="update_all_legend=false">
<span translate>legend_apply_all</span>
<!-- <li class="list-group-item">
<div class="checkbox">
<label><input data-toggle="toggle" type="checkbox" ng-model="studentPicto.attributes.highlight" ng-change="update_properties()" translate> highlighted</label>
</div> </div>
</li> </div>
--> </div>
<li class="list-group-item"> <div class="row">
<div class="row"> <div class="col-md-12">
<div class="col-md-12"> <button class="btn btn-success pull-right" ng-click="save()" translate>save</button>
<label translate>legend</label><br/> <button class="btn btn-secondary margin-right10 pull-right" ng-click="close()" translate>cancel</button>
<!-- <div class="checkbox"> </div>
<select class="form-control" data-toggle="toggle" ng-model="studentPicto.attributes.legend" ng-change="update_properties()"> </div>
<option value="none" selected>Sin leyenda</option> </div>
<option value="normal">Leyenda normal</option>
<option value="full">Solo leyenda</option>
</select>
</div> -->
<input type="radio" ng-model="studentPicto.attributes.legend" value="none" ng-change="update_properties()">
<span translate>legend_none</span>
<br/>
<input type="radio" ng-model="studentPicto.attributes.legend" value="normal" ng-change="update_properties()">
<span translate>legend_normal</span>
<br/>
<input type="radio" ng-model="studentPicto.attributes.legend" value="full" ng-change="update_properties()">
<span translate>legend_full</span>
</div>
</div>
<hr>
<div class="row">
<div class="col-md-8">
<input type="checkbox" ng-model="update_all_legend" ng-init="update_all_legend=false">
<span translate>legend_apply_all</span>
</div>
<div class="col-md-4">
<div class="form-group text-center">
<button type="submit" class="btn btn-primary ng-scope" ng-click="update_all_legend ? update_legend() : close()" translate>apply</button>
</div>
</div>
</div>
</li>
</ul>
</div> </div>
<!-- End modal-body --> <!-- End modal-body -->
</div> </div>
...@@ -47,6 +47,10 @@ ...@@ -47,6 +47,10 @@
padding: 8px; padding: 8px;
} }
.margin-right10{
margin-right: 10px;
}
/* Evitar scrolling horizontal */ /* Evitar scrolling horizontal */
body{ body{
overflow-x: hidden; overflow-x: hidden;
......
...@@ -97,6 +97,7 @@ module.exports.policies = { ...@@ -97,6 +97,7 @@ module.exports.policies = {
update: ['tokenAuth'], update: ['tokenAuth'],
update_picto: ['tokenAuth', 'isSupervisorOfStudent'], update_picto: ['tokenAuth', 'isSupervisorOfStudent'],
update_legend: ['tokenAuth'], update_legend: ['tokenAuth'],
update_category: ['tokenAuth', 'isSupervisorOfStudent'],
login: true, login: true,
create: ['tokenAuth', 'isSupAdmin'], create: ['tokenAuth', 'isSupAdmin'],
upload: ['tokenAuth'], upload: ['tokenAuth'],
......
...@@ -83,6 +83,7 @@ module.exports.routes = { ...@@ -83,6 +83,7 @@ module.exports.routes = {
'PUT /stu/:id_stu/picto/:id_stuPicto': 'StudentController.update_picto', 'PUT /stu/:id_stu/picto/:id_stuPicto': 'StudentController.update_picto',
'PUT /stu/:id_stu/legend/:legend_value': 'StudentController.update_legend', 'PUT /stu/:id_stu/legend/:legend_value': 'StudentController.update_legend',
'PUT /stu/:id_stu/picto': 'StudentController.update_picto', 'PUT /stu/:id_stu/picto': 'StudentController.update_picto',
'PUT /stu/:id_stu/cat': 'StudentController.update_category',
'POST /stu/login': 'StudentController.login', 'POST /stu/login': 'StudentController.login',
'POST /stu': 'StudentController.create', 'POST /stu': 'StudentController.create',
'POST /stu/upload': 'StudentController.upload', 'POST /stu/upload': 'StudentController.upload',
......
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