Commit 71361cbe by Pablo Molina

Solved #236, añadido ngToast en webapp.

- Añadida etiqueta `<toast></toast>` a index.html
- Actualizadas traducciones asociadas
- Cambiados los console.log por ngToast en los siguientes módulos:
  - admin/supervisors
  - login/login
  - login/login_admin
  - login/signin
  - student/addpicto
  - login/login_setting_password
  - student/setup
  - student/student
  - student/tags
  - supervisor/setup
  - supervisor/student
parent eb424d45
{
"rules": {
"comma-dangle": 0,
"func-names": 0,
"jsx-a11y/valid-aria-role": 0,
"jsx-a11y/img-uses-alt": 0,
"jsx-a11y/redundant-alt": 0,
"no-param-reassign": 0,
"no-var": 0,
"object-shorthand": 0,
"prefer-arrow-callback": 0,
"prefer-template": 0,
"strict": 0
}
}
......@@ -26,11 +26,11 @@
"alert": "Alert",
"all": "All",
"animation": "Animation",
"April": "April",
"April": "April",
"attributes_not_updated": "Changes not saved",
"attributes_updated": "Changes saved",
"attributes_updating": "Saving...",
"August": "August",
"August": "August",
"background": "Background",
"beep": "Beep",
"birthdate": "Birthdate",
......@@ -84,6 +84,10 @@
"english": "English",
"enlarge": "Enlarge",
"enormous": "Enormous",
"error_downloading_supervisors": "Error downloading supervisors",
"error_downloading_offices": "Error downloading offices",
"error_only_support_images": "Only images are supported (JPG, PNG or GIF files)",
"error_loading_pictos": "Error loading pictos information",
"expand_navigation": "Expand navigation",
"expand_navigation": "Expand navigation",
"expression": "Expression:",
......@@ -106,9 +110,9 @@
"instructions": "Instructions",
"invalid_fields": "Invalid values. Please, check fields introduced.",
"invisible": "Invisible. Clic for enable",
"January": "January",
"July": "July",
"June": "June",
"January": "January",
"July": "July",
"June": "June",
"language": "Language",
"large": "Large",
"last_session": "Last session",
......@@ -123,10 +127,10 @@
"login_success": "Login succeed. Welcome {{name}}",
"logout": "Log Out",
"man": "Man",
"March": "March",
"March": "March",
"mark": "Mark",
"max_licenses_reached": "Maximum number of licenses reached by the office",
"May": "May",
"May": "May",
"method_name_duplicated": "template already exists.Please, change the name",
"method_save": "Method saved as a new template",
"methods": "Methods",
......@@ -146,8 +150,8 @@
"num_peers": "Peers",
"num_sessions_per_day_in": "Sessions per day in",
"num_sessions_per_month_in": "Sessions per months in",
"objetive": "Objetive",
"October": "October",
"objetive": "Objetive",
"October": "October",
"office": "Office",
"office_added": "Office added",
"office_deleted": "Office deleted",
......@@ -156,7 +160,7 @@
"office_not_updated": "Office not updated",
"office_updated": "Office updated",
"offices": "Offices",
"own_labels": "Your labels",
"own_labels": "Your labels",
"own_pictos": "Your pictograms",
"pages": "Pages",
"password": "Password",
......@@ -196,7 +200,7 @@
"select_a_method": "-- Select a method --",
"select_method": "-- Select a method or create it --",
"send": "Send",
"September": "September",
"September": "September",
"serial": "Serial number",
"serial_created": "Serial number {{serial}} created",
"serial_list": "Free serial numbers",
......@@ -213,7 +217,7 @@
"spanish": "Spanish",
"started": "Started",
"state": "State",
"state_broken": "Broken",
"state_broken": "Broken",
"state_correct": "Correct",
"state_demonstration": "Demonstration",
"state_discarded": "Discarded",
......@@ -229,9 +233,9 @@
"student_pictograms": "Student's pictograms",
"student_updated": "Student updated",
"students": "Students",
"sup_not_added": "Supervisor not added to the student.",
"sup_not_added": "Supervisor not added to the student",
"sup_not_deleted": "The supervisor couldn't be deleted by the student",
"sup_not_found": "There is no supervisor account in Pictogram with this email.",
"sup_not_found": "There is no supervisor account in Pictogram with this email",
"supervisor_added": "Supervisor added",
"supervisor_deleted": "Supervisor deleted",
"supervisor_not_added": "Supervisor not added",
......@@ -258,8 +262,10 @@
"tries_per_instruction_method": "Tries per instruction of method",
"tries_per_months": "Tries per months in",
"tries_results_instruction": "Tries results in instruction",
"tutor_added": "Tutor added to the student",
"tutor_deleted": "Tutor removed from the student",
"tutor_not_added": "Tutor not added to the student.",
"tutor_not_deleted": "The tutor couldn't be deleted by the student",
"tutor_not_deleted": "Tutor couldn't be removed from the student",
"tutor_not_found": "There is no tutor account in Pictogram with this email.",
"tutors": "Parents or tutors",
"unlink": "Unlink",
......
......@@ -26,16 +26,16 @@
"alert": "Alerta",
"all": "Todos",
"animation": "Animación",
"April": "Abril",
"April": "Abril",
"attributes_not_updated": "Cambios no guardados",
"attributes_updated": "Cambios guardados",
"attributes_updating": "Guardando...",
"August": "Agosto",
"August": "Agosto",
"background": "Fondo",
"beep": "Pitido",
"birthdate": "Fecha de nacimiento",
"cancel": "Cancelar",
"cannot_delete_method": "No se pudo eliminar el método, tal vez porque existen sesiones asociadas.",
"cannot_delete_method": "No se pudo eliminar el método, tal vez porque existen sesiones asociadas.",
"categories": "Categorías",
"category_pictograms": "Pictogramas de la categoría",
"change_password": "Cambiar contraseña",
......@@ -87,6 +87,10 @@
"expand_navigation": "Desplegar navegación",
"expand_navigation": "Desplegar navegación",
"expression": "Expresión:",
"error_downloading_supervisors": "Error al descargar los supervisores",
"error_downloading_offices": "Error al descargar las oficinas",
"error_only_support_images": "Sólo se soportan imágenes (ficheros JPG, PNG o GIF)",
"error_loading_pictos": "Error cargando información de los pictos",
"February": "Febrero",
"feedback_picto": "Feedback al colocar un pictograma",
"filter": "Filtrar",
......@@ -106,9 +110,9 @@
"instructions": "Instrucciones",
"invalid_fields": "Valores inválidos. Compruebe los datos introducidos.",
"invisible": "Invisible. Clic para activar",
"January": "Enero",
"July": "Julio",
"June": "Junio",
"January": "Enero",
"July": "Julio",
"June": "Junio",
"language": "Idioma",
"large": "Grande",
"last_session": "Última sesión",
......@@ -123,10 +127,10 @@
"login_success": "Login correcto. Bienvenido {{name}}",
"logout": "Salir",
"man": "Hombre",
"March": "Marzo",
"March": "Marzo",
"mark": "Marcar",
"max_licenses_reached": "Número de licencias máximo alcanzado por la oficina",
"May": "Mayo",
"May": "Mayo",
"method_name_duplicated": "plantilla ya existe. Por favor, cambie el nombre",
"method_save": "Método guardado como nueva plantilla",
"methods": "Métodos",
......@@ -146,8 +150,8 @@
"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",
"October": "Octubre",
"objetive": "Objetivo",
"October": "Octubre",
"office": "Gabinete",
"office_added": "Gabinete añadido",
"office_deleted": "Gabinete eliminado",
......@@ -156,8 +160,8 @@
"office_not_updated": "El gabinete no se ha podido actualizar",
"office_updated": "Gabinete actualizado",
"offices": "Gabinetes",
"own_labels": "Propias",
"own_pictos": "Propios",
"own_labels": "Propias",
"own_pictos": "Propios",
"pages": "Páginas",
"password": "Contraseña",
"password_confirm": "Repita la contraseña",
......@@ -196,7 +200,7 @@
"select_a_method": "-- Selecciona un método --",
"select_method": "-- Selecciona un método o créalo --",
"send": "Enviar",
"September": "Septiembre",
"September": "Septiembre",
"serial": "Número de serie",
"serial_created": "Número de serie {{serial}} creado",
"serial_list": "Números de serie libres",
......@@ -258,9 +262,11 @@
"tries_per_instruction_method": "Ensayos por instrucción del método",
"tries_per_months": "Número de ensayos por meses en",
"tries_results_instruction": "Resultados ensayos en instrucción",
"tutor_not_added": "El tutor no se ha podido añadir al estudiante.",
"tutor_not_deleted": "El tutor no se ha podido desvincular del alumno.",
"tutor_not_found": "No hay ningún tutor en Pictoram con ese correo electrónico.",
"tutor_added": "Tutor añadido al estudiante",
"tutor_deleted": "Tutor desvinculado del estudiante",
"tutor_not_added": "El tutor no se ha podido añadir al estudiante",
"tutor_not_deleted": "El tutor no se ha podido desvincular del alumno",
"tutor_not_found": "No hay ningún tutor en Pictoram con ese correo electrónico",
"tutors": "Padres o tutores",
"undefined": "Sin definir",
"unlink": "Desvincular",
......
......@@ -81,6 +81,7 @@
<body ng-controller="MainCtrl">
<!-- <div ng-view></div> -->
<toast></toast>
<div ui-view></div>
<!-- Librería jQuery requerida por los plugins de JavaScript
......
......@@ -3,7 +3,7 @@
//--------------------------
// Admin Supervisors Controller
//--------------------------
dashboardControllers.controller('AdminSupervisorsCtrl', function AdminSupervisorsCtrl($scope, $window, $http, config) {
dashboardControllers.controller('AdminSupervisorsCtrl', function AdminSupervisorsCtrl($scope, $window, $http, config, $translate, ngToast) {
// The last parameter, config, is injected from config.js (defined in dashboardConfig module)
// Don't show the message at the begining
......@@ -25,26 +25,24 @@ dashboardControllers.controller('AdminSupervisorsCtrl', function AdminSupervisor
$http
.get(config.backend+'/sup')
.success(function(data, status, headers, config) {
// Add to list
$scope.supervisors = data;
console.log("Supervisors listed");
})
.error(function(data, status, headers, config) {
console.log("Error from API: " + data.error);
$translate('error_downloading_supervisors').then(function (translation) {
ngToast.danger({ content: translation });
});
});
// List of offices (for the select form)
$http
.get(config.backend+'/office/get_all')
.success(function(data, status, headers, config) {
// Add to list
$scope.offices = data;
console.log("Offices listed");
})
.error(function(data, status, headers, config) {
console.log("Error from API: " + data.error);
$translate('error_downloading_offices').then(function (translation) {
ngToast.danger({ content: translation });
});
});
// Reset form Supervisor
......@@ -69,7 +67,7 @@ dashboardControllers.controller('AdminSupervisorsCtrl', function AdminSupervisor
// Open Update Supervisor Form
$scope.update_supervisor = function(supervisor){
// Hide (if it's show) the add form
$scope.hidesupervisoradd = true;
// Show the update form
......@@ -87,7 +85,7 @@ dashboardControllers.controller('AdminSupervisorsCtrl', function AdminSupervisor
gender: supervisor.gender,
lang: supervisor.lang,
office: supervisor.office
};
};
};
// Save a Supervisor updated
......@@ -108,37 +106,33 @@ dashboardControllers.controller('AdminSupervisorsCtrl', function AdminSupervisor
$http
.put(config.backend+'/supervisor/'+supid, supervisor)
.success(function(data, status, headers, config) {
$scope.showmessagesupervisor = true;
$scope.alertsupervisor = "alert-success";
$scope.messagesupervisor = "supervisor_updated";
$translate('supervisor_updated').then(function (translation) {
ngToast.success({ content: translation });
});
// Update the view: Se recorre el array de objetos json para buscarlo
for(var i=0; i < $scope.supervisors.length; i++) {
if(supid == $scope.supervisors[i].id){
$scope.supervisors[i].name = data.name;
$scope.supervisors[i].surname = data.surname;
$scope.supervisors[i].address = data.address;
$scope.supervisors[i].country = data.country;
$scope.supervisors[i].email = data.email;
$scope.supervisors[i].phone = data.phone;
$scope.supervisors[i].gender = data.gender;
$scope.supervisors[i].lang = data.lang;
$scope.supervisors[i].office = data.office;
if(supid == $scope.supervisors[i].id){
$scope.supervisors[i].name = data.name;
$scope.supervisors[i].surname = data.surname;
$scope.supervisors[i].address = data.address;
$scope.supervisors[i].country = data.country;
$scope.supervisors[i].email = data.email;
$scope.supervisors[i].phone = data.phone;
$scope.supervisors[i].gender = data.gender;
$scope.supervisors[i].lang = data.lang;
$scope.supervisors[i].office = data.office;
}
}
// Delete the fields of the form to avoid data binding
// between the new element created and the form fields
$scope.resetForm();
console.log("Supervisor updated");
})
.error(function(data, status, headers, config) {
$scope.showmessagesupervisor = true;
$scope.alertsupervisor = "alert-danger";
$scope.messagesupervisor = "supervisor_not_updated";
console.log("Error from API: " + data.error);
$translate('supervisor_not_updated').then(function (translation) {
ngToast.danger({ content: translation });
});
});
};
......@@ -153,9 +147,9 @@ dashboardControllers.controller('AdminSupervisorsCtrl', function AdminSupervisor
$http
.post(config.backend+'/sup', supervisor)
.success(function(data, status, headers, config) {
$scope.showmessagesupervisor = true;
$scope.alertsupervisor = "alert-success";
$scope.messagesupervisor = "supervisor_added";
$translate('supervisor_added').then(function (translation) {
ngToast.success({ content: translation });
});
// Add to the list of supervisors in view
$scope.supervisors.push(data.user);
......@@ -164,15 +158,11 @@ dashboardControllers.controller('AdminSupervisorsCtrl', function AdminSupervisor
$scope.resetForm();
// Show the add form to new adding
$scope.hidesupervisoradd = false;
console.log("Supervisor added");
})
.error(function(data, status, headers, config) {
$scope.showmessagesupervisor = true;
$scope.alertsupervisor = "alert-danger";
$scope.messagesupervisor = "supervisor_not_added";
console.log("Error from API: " + data.error);
$translate('supervisor_not_added').then(function (translation) {
ngToast.danger({ content: translation });
});
});
};
......@@ -183,29 +173,25 @@ dashboardControllers.controller('AdminSupervisorsCtrl', function AdminSupervisor
$http
.delete(config.backend+'/supervisor/'+ supervisor.id)
.success(function(data, status, headers, config) {
// Eliminar de la vista: Se recorre el array de objetos json para buscarlo
for(var i=0; i < $scope.supervisors.length; i++) {
if(supervisor.id == $scope.supervisors[i].id)
if(supervisor.id == $scope.supervisors[i].id)
$scope.supervisors.splice(i,1);
}
console.log("Supervisor deleted:" + supervisor.name);
$scope.showmessagesupervisor = true;
$scope.alertsupervisor = "alert-success";
$scope.messagesupervisor = "supervisor_deleted";
$translate('supervisor_deleted').then(function (translation) {
ngToast.success({ content: translation });
});
// Empty the form
$scope.resetForm();
})
.error(function(data, status, headers, config) {
console.log("Error deleting supervisor from API: " + data.error);
console.log("It could be students associated");
$scope.showmessagesupervisor = true;
$scope.alertsupervisor = "alert-danger";
$scope.messagesupervisor = "supervisor_not_deleted";
$translate('supervisor_not_deleted').then(function (translation) {
ngToast.danger({ content: translation });
});
});
}
};
});
\ No newline at end of file
});
<!-- Admin Supervisors -->
<!-- Alert and success messages -->
<div ng-show="{{ 'showmessagesupervisor' }}" class="alert" ng-class="alertsupervisor">{{ messagesupervisor | translate }}</div>
<div class="row">
<div ng-class="{'col-md-12':hidesupervisoradd === true && hidesupervisorupdate === true, 'col-md-8':hidesupervisoradd === false || hidesupervisorupdate === false}">
......
/* global dashboardControllers */
'use strict';
//------------------
// Login Controller
//------------------
dashboardControllers.controller('LoginCtrl', function LoginCtrl($scope, $http, $window, $translate, $filter, $location, config, $stateParams) {
// The last parameter, config, is injected from config.js (defined in dashboardConfig module)
dashboardControllers.controller('LoginCtrl',
function LoginCtrl(
$scope,
$http,
$window,
$translate,
$filter,
$location,
config,
$stateParams,
ngToast) {
$scope.credentials = {
email: '',
password: '',
lang: 'es-es'
};
// Pop-up blocker check
// var popup = window.open('http://yottacode.com','','',true);
// setTimeout( function() {
// if(!popup || popup.outerHeight === 0) {
// alert("cáspita");
// } else {
// popup && popup.close();
// }
// }, 100);
// Array of key terms to translate
$translate(['login_success', 'login_fail']).then(function (translations) {
//notification_email = translations.email_match;
$scope.message_success = translations.login_success;
$scope.message_fail = translations.login_fail;
});
// Don't show the message at the begining
$scope.showmessage = false;
// Validation of account
// if the code has been sent in the url "...app/login/code/email"
if($stateParams.code && $stateParams.email){
console.log("Code: " + $stateParams.code + "\nEmail: " + $stateParams.email);
if ($stateParams.code && $stateParams.email) {
$http
.post(config.backend+'/sup/activate', $stateParams)
.success(function(data, status, headers, config) {
$scope.showmessage = true;
$scope.alert = "alert-success";
$scope.message = "account_activate";
console.log("Supervisor: " + data.user.name);
//console.log("Account validated: " + data.user.email + " --> " + data.user.active);
.post(config.backend + '/sup/activate', $stateParams)
.success(function () {
$translate('account_activate').then(function (translation) {
ngToast.success({ content: translation });
});
})
.error(function(data, status, headers, config) {
$scope.showmessage = true;
$scope.alert = "alert-danger";
$scope.message = "account_no_activate";
console.log("Account NOT validated! Error: " + data.error);
.error(function () {
$translate('account_no_activate').then(function (translation) {
ngToast.danger({ content: translation });
});
});
}
$scope.login = function () {
$http
.post(config.backend+'/sup/login', $scope.credentials)
.success(function(data, status, headers, config) {
// Save token and user data y sessionStorage
.post(config.backend + '/sup/login', $scope.credentials)
.success(function (data) {
$window.sessionStorage.token = data.token;
// Adapt language en-us to en-gb (the latter is the one supported for 'en')
if (data.user) {
if (data.user.lang === 'en-us')
if (data.user.lang === 'en-us') {
data.user.lang = 'en-gb';
}
$scope.lang = data.user.lang;
} else {
$translate.use($scope.lang);
}
else
console.log("ERROR: no data.user!");
$translate.use($scope.lang);
// Change
// Change
$window.sessionStorage.user = JSON.stringify(data.user);
// Quitar 4 líneas siguientes. Al hacer redirección no hace falta
$scope.showmessage = true;
$scope.alert = "alert-success";
$scope.message = "login_success";
$translate('login_success').then(function (translation) {
ngToast.success({ content: translation });
});
// Name in login success message
$scope.name = data.user.name;
console.log("logged in!");
// Redirección
$location.path('/students');
})
.error(function(data, status, headers, config) {
// Delete token if user fails to login
.error(function () {
delete $window.sessionStorage.token;
$scope.showmessage = true;
$scope.alert = "alert-danger";
$scope.message = "login_fail";
$translate('login_fail').then(function (translation) {
ngToast.danger({ content: translation });
});
});
}
});
\ No newline at end of file
};
});
......@@ -3,7 +3,7 @@
//------------------
// Login Controller
//------------------
dashboardControllers.controller('LoginAdminCtrl', function LoginAdminCtrl($scope, $http, $window, $translate, $location, config) {
dashboardControllers.controller('LoginAdminCtrl', function LoginAdminCtrl($scope, $http, $window, $translate, $location, config, ngToast) {
// The last parameter, config, is injected from config.js (defined in dashboardConfig module)
$scope.credentials = {
......@@ -11,16 +11,6 @@ dashboardControllers.controller('LoginAdminCtrl', function LoginAdminCtrl($scope
password: ''
};
// Array of key terms to translate
$translate(['login_success', 'login_fail']).then(function (translations) {
//notification_email = translations.email_match;
$scope.message_success = translations.login_success;
$scope.message_fail = translations.login_fail;
});
// Don't show the message at the begining
$scope.showmessage = false;
$scope.login = function () {
$http
.post(config.backend+'/admin/login', $scope.credentials)
......@@ -29,15 +19,18 @@ dashboardControllers.controller('LoginAdminCtrl', function LoginAdminCtrl($scope
$window.sessionStorage.token = data.token;
// Redirect to admin panel
$location.path('/devices');
$translate('login_success').then(function(translation) {
ngToast.success({ content: translation });
});
})
.error(function(data, status, headers, config) {
// Delete token if user fails to login
delete $window.sessionStorage.token;
$scope.showmessage = true;
$scope.alert = "alert-danger";
$scope.message = "login_fail";
$translate('login_fail').then(function(translation) {
ngToast.danger({ content: translation });
});
});
};
});
\ No newline at end of file
});
......@@ -3,33 +3,26 @@
//-----------------------------------
// Login Setting Password Controller
//-----------------------------------
dashboardControllers.controller('LoginSettingPasswordCtrl', function LoginSettingPasswordCtrl($scope, $http, $window, $translate, $location, config, $stateParams) {
// The last parameter, config, is injected from config.js (defined in dashboardConfig module)
dashboardControllers.controller('LoginSettingPasswordCtrl', function LoginSettingPasswordCtrl($scope, $http, $window, $translate, $location, config, $stateParams, ngToast) {
// Array of key terms to translate
$translate(['validate_success', 'validate_fail']).then(function (translations) {
//notification_email = translations.email_match;
$scope.message_success = translations.validate_success;
$scope.message_fail = translations.validate_fail;
});
// Don't show the message at the begining
$scope.showmessage = false;
$scope.showlink = false;
$scope.login_setting_password = function () {
// Validation of account
// if the code has been sent in the url "...app/login/code/email"
if($stateParams.code && $stateParams.email){
console.log("Code: " + $stateParams.code + "\nEmail: " + $stateParams.email);
if ($stateParams.code && $stateParams.email) {
// Validate password match
if($scope.password != $scope.password_confirm){
// ToDo: Highlight with Angular the input
$scope.showmessage = true;
$scope.alert = "alert-danger";
$scope.message = "password_match";
if ($scope.password != $scope.password_confirm) {
$translate([
'validate_fail',
'password_match'
], function (translations) {
ngToast.danger({
content: [
translations.validate_fail,
translations.password_match
].join(': ')
});
});
return;
}
......@@ -42,23 +35,15 @@ dashboardControllers.controller('LoginSettingPasswordCtrl', function LoginSettin
$http
.post(config.backend+'/sup/activate', data)
.success(function(data, status, headers, config) {
$scope.showmessage = true;
$scope.showlink = true;
$scope.hideform = true;
$scope.alert = "alert-success";
$scope.message = "validate_success";
console.log("Supervisor: " + data.user.name);
//console.log("Account validated: " + data.user.email + " --> " + data.user.active);
$translate('validate_success').then(function (translation) {
ngToast.success({ content: translation });
});
})
.error(function(data, status, headers, config) {
$scope.showmessage = true;
$scope.alert = "alert-danger";
$scope.message = "validate_fail";
console.log("Account NOT validated! Error: " + data.error);
$translate('validate_fail').then(function (translation) {
ngToast.danger({ content: translation });
});
});
}
};
});
\ No newline at end of file
});
/* global dashboardControllers */
'use strict';
//-------------------
// SignIn Controller
//-------------------
dashboardControllers.controller('SignInCtrl', function SignInCtrl($scope, $http, $window, reCAPTCHA, $translate, config) {
// The last parameter, config, is injected from config.js (defined in dashboardConfig module)
// The previous parameter, $translate, is a dependency injection to translate text in JavaScript controller code
// Data
dashboardControllers.controller('SignInCtrl',
function SignInCtrl($scope,
$http,
$window,
reCAPTCHA,
$translate,
config,
ngToast) {
$scope.formdata = {
name: '',
surname: '',
......@@ -23,69 +27,43 @@ dashboardControllers.controller('SignInCtrl', function SignInCtrl($scope, $http,
reCAPTCHA.setPublicKey('6LdLjh0TAAAAANblo_KUGNnmRZuIetOkdjdhj1b6');
/* NOT NECESSARY
// Array of key terms to translate
$translate(['password_match', 'email_match']).then(function (translations) {
//notification_email = translations.email_match;
$scope.email_message = translations.email_match;
$scope.password_message = translations.password_match;
});
*/
// Verificar. Si no es necesario eliminar
//reCAPTCHA.setPublicKey('gazpacho andaluz');
// Don't show the message at the begining
$scope.showmessage = false;
// Form submit
$scope.signin = function () {
//$scope.showmessage = false;
// Validate email match
if($scope.formdata.email != $scope.formdata.email_confirm){
// ToDo: Highlight with Angular the input
$scope.showmessage = true;
$scope.alert = "alert-danger";
$scope.message = "email_match";
if ($scope.formdata.email !== $scope.formdata.email_confirm) {
$translate('email_match').then(function (translation) {
ngToast.danger({ content: translation });
});
return;
}
// Validate password match
if($scope.formdata.password != $scope.formdata.password_confirm){
// ToDo: Highlight with Angular the input
$scope.showmessage = true;
$scope.alert = "alert-danger";
$scope.message = "password_match";
if ($scope.formdata.password !== $scope.formdata.password_confirm) {
$translate('password_match').then(function (translation) {
ngToast.danger({ content: translation });
});
return;
}
$scope.captcha = "";
$scope.captcha = '';
if($scope.signInForm.$valid) {
$scope.showdialog = true;
console.log('Form is valid');
}else{
if ($scope.signInForm.$valid) {
$scope.showdialog = true;
} else {
return;
}
$http
.post(config.backend+'/sup', $scope.formdata)
.success(function(data, status, headers, config) {
// ToDo: When this run well, redirect to main page
$scope.showmessage = true;
$scope.alert = "alert-success";
$scope.message = "user_created";
console.log("User created");
.post(config.backend + '/sup', $scope.formdata)
.success(function () {
$translate('user_created').then(function (translation) {
ngToast.success({ content: translation });
});
})
.error(function(data, status, headers, config) {
$scope.showmessage = true;
$scope.alert = "alert-danger";
$scope.message = "user_exists";
console.log("Error from API: " + status);
.error(function () {
$translate('user_exists').then(function (translation) {
ngToast.danger({ content: translation });
});
});
};
});
......@@ -13,14 +13,11 @@
<!-- LoginCtrl controls here, see app.js -->
<form name="loginForm" ng-submit="login()" novalidate>
<!-- Alert and success messages -->
<div ng-show="{{ 'showmessage' }}" class="alert" ng-class="alert" translate translate-value-name="{{name}}">{{message}}</div>
<div class="form-group">
<input type="email" class="form-control" id="login_email" placeholder="{{ 'your_email' | translate}}" required ng-model="credentials.email" ng-focus="showmessage = false" />
<input type="email" class="form-control" id="login_email" placeholder="{{ 'your_email' | translate}}" required ng-model="credentials.email" />
</div>
<div class="form-group">
<input type="password" class="form-control" id="login_password" placeholder="{{ 'your_password' | translate}}" required ng-model="credentials.password" ng-focus="showmessage = false" />
<input type="password" class="form-control" id="login_password" placeholder="{{ 'your_password' | translate}}" required ng-model="credentials.password" />
</div>
<div class="checkbox">
<label>
......
......@@ -12,9 +12,6 @@
<!-- Formulario -->
<!-- LoginAdminCtrl controls here, see app.js -->
<form name="loginForm" ng-submit="login()" novalidate>
<!-- Alert and success messages -->
<div ng-show="{{ 'showmessage' }}" class="alert" ng-class="alert" translate translate-value-name="{{name}}">{{message}}</div>
<h3 class="text-center" translate>admin_login</h3>
<div class="form-group">
......
......@@ -11,9 +11,6 @@
<img src="img/logo_pictogram.png" alt="Pictogram" title="Pictogram" />
</p>
<!-- Alert and success messages -->
<div ng-show="{{ 'showmessage' }}" class="alert" ng-class="alert" translate translate-value-name="{{name}}">{{message}}</div>
<div ng-show="{{ 'showlink' }}" class="text-center">
<a href="/app/#/login" translate>click_login</a>
</div>
......@@ -22,11 +19,11 @@
<form ng-hide="{{ 'hideform' }}" name="loginSettingPasswordForm" ng-submit="login_setting_password()">
<div class="form-group">
<input type="password" class="form-control" id="login_password" placeholder="{{ 'password_type' | translate}}" required ng-model="password" ng-focus="showmessage = false" />
<input type="password" class="form-control" id="login_password" placeholder="{{ 'password_type' | translate}}" required />
</div>
<div class="form-group">
<input type="password" class="form-control" id="login_password_confirm" placeholder="{{ 'password_confirm' | translate}}" required ng-model="password_confirm" ng-focus="showmessage = false" />
<input type="password" class="form-control" id="login_password_confirm" placeholder="{{ 'password_confirm' | translate}}" required ng-model="password_confirm" />
</div>
<p class="color_red text_sm text-center" ng-show="password != password_confirm" translate>password_match</p>
......
......@@ -18,10 +18,6 @@
<!-- Formulario -->
<form name="signInForm" role="form" ng-submit="signin()">
<!-- Alert and success messages -->
<div ng-show="{{ 'showmessage' }}" class="alert" ng-class="alert" translate translate-values="{name: formdata.name, surname: formdata.surname, email: formdata.email}">{{message}}</div>
<fieldset>
<legend translate>personal_data</legend>
<div class="form-group">
......
'use strict';
// Please note that $modalInstance represents a modal window (instance) dependency.
// It is not the same as the $modal service used above.
/* global dashboardControllers */
dashboardControllers.controller('TagsCtrl', function ($scope, $modalInstance, $http, config, stuPicto, sup) {
// Last parameter passed from collections.js
// Basic data passed from the main window
'use strict';
/**
* TagsCtrl
*/
dashboardControllers.controller('TagsCtrl', function TagsCtrl(
$scope,
$modalInstance,
$http,
config,
stuPicto,
sup,
$translate,
ngToast) {
// Supervisor
$scope.sup = sup;
// List of general tags
......@@ -15,66 +22,62 @@ dashboardControllers.controller('TagsCtrl', function ($scope, $modalInstance, $h
$scope.ownTags = [];
// Request of general tags
$http
.get(config.backend+'/picto/' + stuPicto.picto.id)
.success(function(data, status, headers, config) {
// Add to lists
$scope.tags = data.tags;
$scope.ownTags = data.tagsSup;
console.log("Tags recovered");
})
.error(function(data, status, headers, config) {
console.log("Error from API: " + data.error);
});
$http.get(config.backend + '/picto/' + stuPicto.picto.id)
.success(function (data) {
$scope.tags = data.tags;
$scope.ownTags = data.tagsSup;
})
.error(function () {
$translate('error_loading_pictos').then(function (translation) {
ngToast.danger({ content: translation });
});
});
// Add own tag
$scope.add = function () {
$http
.post(config.backend+'/picto/tag',
{ 'picto': stuPicto.picto.id,
'supervisor': $scope.sup.id,
'tag': $scope.tagToAdd,
'lang': $scope.sup.lang
})
.success(function(data, status, headers, config) {
console.log("Tag added: " + JSON.stringify(data));
$scope.ownTags.push(data);
$scope.tagToAdd = "";
})
.error(function(data, status, headers, config) {
console.log("Error from API: " + data.error);
});
$http.post(config.backend + '/picto/tag',
{
picto: stuPicto.picto.id,
supervisor: $scope.sup.id,
tag: $scope.tagToAdd,
lang: $scope.sup.lang
}
)
.success(function (data) {
$scope.ownTags.push(data);
$scope.tagToAdd = '';
})
.error(function () {
// TODO show error with ngToast
});
};
// Destroy own tag
$scope.del = function (tag) {
$http
.delete(config.backend+'/picto/tag/' + tag.id)
.success(function(data, status, headers, config) {
console.log("Tag destroyed: " + JSON.stringify(data));
// Eliminar de la vista: Se recorre el array de objetos json para buscarlo
for(var i=0; i < $scope.ownTags.length; i++) {
if(tag.id == $scope.ownTags[i].id)
$scope.ownTags.splice(i,1);
$http.delete(config.backend + '/picto/tag/' + tag.id)
.success(function () {
var i;
// TODO show success with ngToast
// Eliminar de la vista: Se recorre el array de objetos json para buscarlo
for (i = 0; i < $scope.ownTags.length; i++) {
if (tag.id === $scope.ownTags[i].id) {
$scope.ownTags.splice(i, 1);
}
})
.error(function(data, status, headers, config) {
console.log("Error from API: " + data.error);
});
}
})
.error(function () {
// TODO show error with ngToast
});
};
$scope.close = function () {
$modalInstance.close("Ejemplo de elemento devuelto");
// TODO ¿?¿?
$modalInstance.close('Ejemplo de elemento devuelto');
};
// No usado
$scope.cancel = function () {
// TODO ¿?¿?
$modalInstance.dismiss('cancel');
};
});
<toast></toast>
<!-- Instrucction tab-->
<div class="panel panel-default student_tab_panel">
......
<div class="panel panel-default student_tab_panel">
<div class="panel-body">
<!-- Alert and success messages -->
<div ng-show="{{ 'showmessagestudent' }}" class="alert" ng-class="alertstudent">{{ messagestudent | translate }}</div>
<div class="panel-body">
<div class="row">
<!-- Parte izquierda: Datos personales -->
<div class="col-md-6">
......@@ -19,7 +15,7 @@
</div>
<!-- Preview -->
<img class="thumbnail preview" ng-src="{{studentData.pic}}" />
<img class="thumbnail preview" ng-src="{{studentData.pic}}" />
<!-- Fin Cambiar imagen de perfil -->
<!-- Datos personales del alumno -->
......@@ -100,7 +96,7 @@
<!-- Supervisores (terapeutas) del alumno -->
<div id="student_sups">
<h4 translate>supervisors</h4>
<!-- Buscador de supervisores -->
<!-- Buscador de supervisores -->
<p>
<form role="search" ng-submit="search_sup()">
<div class="input-group">
......@@ -117,11 +113,9 @@
<!-- Alert and success messages for supervisor found -->
<div ng-show="{{ 'showmessagesupfound' }}" class="alert alert-info">
<!-- Imagen de perfil del tutor -->
<img ng-src="{{supToAdd.pic}}" class="profile" alt="" title="" /> {{ supToAdd.name }} {{ supToAdd.surname }}
<img ng-src="{{supToAdd.pic}}" class="profile" alt="" title="" /> {{ supToAdd.name }} {{ supToAdd.surname }}
<a class="btn btn-default btn-lg pull-right" role="button" ng-click="add_sup()" translate>add</a>
</div>
<div ng-show="{{ 'showmessagesupnotfound' }}" class="alert alert-warning">{{ messagesup | translate }}</div>
<!-- Fin de buscador de supervisores -->
<!-- Supervisores asignados -->
......@@ -135,14 +129,14 @@
</a>
</li>
</ul>
<!-- Fin de Supervisores asignados -->
<!-- Fin de Supervisores asignados -->
</div>
<!-- Fin de id student-sups -->
<!-- Tutores (Padres) -->
<div id="student_tutors">
<h4>{{ 'tutors' | translate }}</h4>
<!-- Buscador de tutores -->
<!-- Buscador de tutores -->
<p>
<form role="search" ng-submit="search_tutor()">
<div class="input-group">
......@@ -159,11 +153,9 @@
<!-- Alert and success messages for tutor found -->
<div ng-show="{{ 'showmessagetutorfound' }}" class="alert alert-info">
<!-- Imagen de perfil del tutor -->
<img ng-src="{{tutorToAdd.pic}}" class="profile" alt="" title="" /> {{ tutorToAdd.name }} {{ tutorToAdd.surname }}
<img ng-src="{{tutorToAdd.pic}}" class="profile" alt="" title="" /> {{ tutorToAdd.name }} {{ tutorToAdd.surname }}
<a class="btn btn-default btn-sm pull-right" role="button" ng-click="add_tutor()" translate>add</a>
</div>
<div ng-show="{{ 'showmessagetutornotfound' }}" class="alert alert-warning">{{ messagetutor | translate }}</div>
<!-- Fin de buscador de tutores -->
<!-- Tutores asignados -->
......@@ -177,7 +169,7 @@
</a>
</li>
</ul>
<!-- Fin de Tutores asignados -->
<!-- Fin de Tutores asignados -->
<!-- Info message -->
<div class="alert alert-info">{{ 'supervisor_note' | translate }}</div>
......@@ -187,7 +179,7 @@
<!-- Student devices -->
<div id="student_devices">
<h4 translate>devices</h4>
<!-- Formulario para introducir ID de dispositivo -->
<!-- Formulario para introducir ID de dispositivo -->
<p>
<form role="search" ng-submit="associate_dev()">
<div class="input-group">
......@@ -208,17 +200,17 @@
<!-- Dispositivos asignados -->
<ul class="list-group" id="user_devices">
<li class="list-group-item" ng-repeat="dev in studentDevices">
<span class="glyphicon glyphicon-phone" aria-hidden="true"></span> {{dev.desc}}
<span class="glyphicon glyphicon-phone" aria-hidden="true"></span> {{dev.desc}}
<!-- aquí mejor stusupdev.id -->
<a ng-click="delete_device(dev.id)" class="delete_device" title="{{ 'unlink' | translate }}">
<span class="color_red glyphicon glyphicon-remove-circle" aria-hidden="true"></span>
</a>
</li>
</ul>
<!-- Fin de Dispositivos asignados -->
<!-- Fin de Dispositivos asignados -->
</div>
<!-- Fin de id student-devices -->
</div>
</div>
</div>
<!-- Fin de row -->
......@@ -239,9 +231,9 @@
<legend translate>pictograms</legend>
<div class="input-group">
<label>{{ 'background' | translate }}:
<label>{{ 'background' | translate }}:
<input id="picto_background" type="color" ng-model="studentData.attributes.picto_background" ng-mouseleave="update_attributes()" />
</label>
</label>
</div>
<h4>{{ 'size' | translate }}:</h4>
......@@ -293,9 +285,9 @@
<legend translate>phrase_tape</legend>
<div class="input-group">
<label>{{ 'background' | translate }}:
<label>{{ 'background' | translate }}:
<input id="phrase_background" type="color" ng-model="studentData.attributes.phrase_background" ng-mouseleave="update_attributes()" />
</label>
</label>
</div>
<h4>{{ 'place_pictos' | translate }}:</h4>
......@@ -306,7 +298,7 @@
<label class="btn btn-success" ng-model="studentData.attributes.input_selection" btn-radio="'press'" ng-change="update_attributes()">{{ 'press' | translate }}</label>
-->
<label class="btn btn-success" ng-model="studentData.attributes.input_selection" btn-radio="'drag'" ng-change="update_attributes()">{{ 'drag' | translate }}</label>
</div>
</div>
<h4>{{ 'feedback_picto' | translate }}:</h4>
<div class="btn-group">
......@@ -315,7 +307,7 @@
<label class="btn btn-success" ng-model="studentData.attributes.input_feedback.read" btn-checkbox ng-change="update_attributes()">{{ 'read_picto' | translate }}</label>
<label class="btn btn-success" ng-model="studentData.attributes.input_feedback.highlight" btn-checkbox ng-change="update_attributes()">{{ 'highlight' | translate }}</label>
</div>
</fieldset>
<!-- Ajustes de voz -->
......@@ -349,6 +341,6 @@
<!-- Fin de Configuración de los dispositivos -->
</div>
<!-- Fin de panel body -->
</div>
<!-- Fin de panel -->
\ No newline at end of file
<!-- Fin de panel -->
/* global dashboardControllers */
'use strict';
//------------------
// Setup Controller
//------------------
dashboardControllers.controller('SetupCtrl', function SetupCtrl($scope, $http, $window, $translate, $location, $upload, config) {
// The last parameter, config, is injected from config.js (defined in dashboardConfig module)
/**
* SetupCtrl
*/
dashboardControllers.controller('SetupCtrl', function SetupCtrl(
$scope,
$http,
$window,
$translate,
$location,
$upload,
ngToast,
config) {
var user;
// Don't show the message at the begining
$scope.showmessage = false;
// Restore user values from sessionStorage
var user = JSON.parse($window.sessionStorage.user);
// Fill the form with the user data
user = JSON.parse($window.sessionStorage.user);
$scope.formdata = user;
// Testing --> DELETE
console.log("User id: " + user.id.toString());
console.log("User id to hashcode: " + user.id.toString().hashCode());
// When a picture is selected, launch the request
$scope.onFileSelect = function($files) {
//$files: an array of files selected, each file has name, size, and type.
for (var i = 0; i < $files.length; i++) {
var file = $files[i];
// Check accepted file types
if(file.type == "image/jpeg" || file.type == "image/png" || file.type == "image/gif"){
// Get the file extension
var extension = file.name.split('.').pop();
var filename = user.id + file.name;
console.log("Archivo: " + filename);
$scope.onFileSelect = function ($files) {
var i;
var file;
var extension;
var filename;
for (i = 0; i < $files.length; i++) {
file = $files[i]; // { name, size, type }
if (file.type === 'image/jpeg' || file.type === 'image/png' || file.type === 'image/gif') {
extension = file.name.split('.').pop();
filename = user.id + file.name;
$upload.upload({
url: '/sup/upload', //upload.php script, node.js route, or servlet url
method: 'POST', // or 'PUT',
// Fields to sent in the body of the request
fields: {'filename': filename, 'extension': extension, 'folder': 'supervisors', 'id': user.id},
// or ['1.jpg', '2.jpg', ...] // to modify the name of the file(s)
file: file, // or list of files ($files) for html5 only
}).progress(function(evt) {
console.log('percent: ' + parseInt(100.0 * evt.loaded / evt.total));
}).success(function(data, status, headers, config) {
// file is uploaded successfully
console.log(JSON.stringify(data.file));
// Assign the new image with new name
$scope.user.pic = "/upload/supervisors/" + data.file.name;
//$scope.picture = user.id + "." + extension + "?t=" + new Date().getTime();
// Modify the user in session
var user = JSON.parse($window.sessionStorage.user);
url: '/sup/upload', // upload.php script, node.js route, or servlet url
method: 'POST', // or 'PUT',
fields: {
filename: filename,
extension: extension,
folder: 'supervisors',
id: user.id
},
file: file
})
.progress(function () {
// TODO show file upload progress to user
})
.success(function (data) {
// TODO show success ngToast
$scope.user.pic = '/upload/supervisors/' + data.file.name;
user.pic = $scope.user.pic;
$window.sessionStorage.user = JSON.stringify(user);
});
}else{
alert("It's only supported JPG, PNG and GIF files");
} else {
$translate('error_only_support_images').then(function (translation) {
ngToast.error({ content: translation });
});
}
}
};
// Form submit
$scope.setup = function () {
var supervisor;
var actualEmail;
//$scope.showmessage = false;
// Validate password match
if($scope.formdata.password != $scope.formdata.password_confirm){
// ToDo: Highlight with Angular the input
$scope.showmessage = true;
$scope.alert = "alert-danger";
$scope.message = "password_match";
if ($scope.formdata.password !== $scope.formdata.password_confirm) {
$translate('password_match').then(function (translation) {
ngToast.danger({ content: translation });
});
return;
}
if($scope.setupForm.$valid) {
// $scope.showdialog = true;
console.log('Form is valid');
}else{
if (!$scope.setupForm.$valid) {
$translate('invalid_fields').then(function (translation) {
ngToast.danger({ content: translation });
});
return;
}
var supervisor = $scope.formdata;
var actual_email = JSON.parse($window.sessionStorage.user).email;
supervisor = $scope.formdata;
actualEmail = JSON.parse($window.sessionStorage.user).email;
// Comprobation for new email
// If no change, it is deleted from supervisor object
if(supervisor.email == actual_email)
if (supervisor.email === actualEmail) {
delete supervisor.email;
// console.log($scope.formdata.uploadFile);
}
$http
.put(config.backend+'/sup', supervisor)
.success(function(data, status, headers, config) {
// ToDo: When this run well, redirect to main page
$scope.showmessage = true;
$scope.alert = "alert-success";
$scope.message = "data_saved";
$http.put(config.backend + '/sup', supervisor)
.success(function (data) {
$translate('data_saved').then(function (translation) {
ngToast.success({ content: translation });
});
// Modify the name in the header
$scope.name = data.name + " " + data.surname;
$scope.name = data.name + ' ' + data.surname;
// Modify the user data in session
user.name = data.name;
user.surname = data.surname;
......@@ -113,16 +114,11 @@ dashboardControllers.controller('SetupCtrl', function SetupCtrl($scope, $http, $
delete user.password_confirm;
$window.sessionStorage.user = JSON.stringify(user);
console.log("User modified");
})
.error(function(data, status, headers, config) {
$scope.showmessage = true;
$scope.alert = "alert-danger";
$scope.message = "data_no_saved";
console.log("Error from API: " + data.error);
.error(function () {
$translate('data_no_saved').then(function (translation) {
ngToast.danger({ content: translation });
});
});
};
});
\ No newline at end of file
});
......@@ -9,9 +9,6 @@
<!-- Formulario -->
<form name="setupForm" enctype="multipart/form-data" role="form" ng-submit="setup()">
<!-- Alert and success messages -->
<div ng-show="{{ 'showmessage' }}" class="alert" ng-class="alert" translate>{{message}}</div>
<!-- Change profile picture -->
<input type="file" ng-file-select="onFileSelect($files)" ng-model="picFile" accept="image/*">
......@@ -102,4 +99,3 @@
</div>
<toast></toast>
<!-- StudentsCtrl controls here, see app.js -->
<div class="panel panel-default">
<!-- Default panel contents -->
......
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