Repetitive generation of licenses

parent 30ddc4c8
...@@ -1007,7 +1007,7 @@ module.exports = { ...@@ -1007,7 +1007,7 @@ module.exports = {
if (updateStudentError) { if (updateStudentError) {
throw updateStudentError; throw updateStudentError;
} }
res.ok(); res.ok({file: {name: student.pic}});
}); });
} catch (updateAvatarError) { } catch (updateAvatarError) {
fs.unlinkSync(newAvatarFileDescriptor); fs.unlinkSync(newAvatarFileDescriptor);
...@@ -1016,7 +1016,7 @@ module.exports = { ...@@ -1016,7 +1016,7 @@ module.exports = {
}); });
}) })
.catch(function (err) { .catch(function (err) {
res.badRequest("Could not find supervisor: " + err); res.badRequest("Could not find student: " + err);
}); });
}, },
......
...@@ -557,6 +557,7 @@ module.exports = { ...@@ -557,6 +557,7 @@ module.exports = {
}); });
}) })
.catch(function (err) { .catch(function (err) {
res.badRequest("Could not find supervisor: " + err);
}); });
}, },
......
...@@ -47,9 +47,8 @@ module.exports = { ...@@ -47,9 +47,8 @@ module.exports = {
toJSON: function () { toJSON: function () {
var stuPicto = this.toObject(); var stuPicto = this.toObject();
if (typeof stuPicto.attributes !== 'object') { if (typeof stuPicto.attributes !== 'object')
stuPicto.attributes = JSON.parse(stuPicto.attributes); stuPicto.attributes = JSON.parse(stuPicto.attributes);
}
stuPicto.attributes = StuPicto.getValidAttributes(stuPicto.attributes); stuPicto.attributes = StuPicto.getValidAttributes(stuPicto.attributes);
return stuPicto; return stuPicto;
} }
...@@ -90,7 +89,8 @@ module.exports = { ...@@ -90,7 +89,8 @@ module.exports = {
highlight: false, highlight: false,
color: null, color: null,
expression: null, expression: null,
legend: 'none' legend: 'none',
delete_strip_after_delivery: true
}; };
if (typeof attributes === 'object') { if (typeof attributes === 'object') {
...@@ -127,11 +127,12 @@ module.exports = { ...@@ -127,11 +127,12 @@ module.exports = {
if (typeof validAttributes.legend !== 'string') { if (typeof validAttributes.legend !== 'string') {
delete validAttributes.legend; delete validAttributes.legend;
} }
if( validAttributes.legend !== 'none' && if (!((/^(none|normal|full)$/).test(validAttributes.legend))) {
validAttributes.legend !== 'normal' &&
validAttributes.legend !== 'full'){
delete validAttributes.legend; delete validAttributes.legend;
} }
if (typeof validAttributes.delete_strip_after_delivery !== 'boolean') {
delete validAttributes.delete_strip_after_delivery;
}
if (typeof validAttributes.highlight !== 'boolean') { if (typeof validAttributes.highlight !== 'boolean') {
delete validAttributes.highlight; delete validAttributes.highlight;
} }
......
...@@ -67,6 +67,7 @@ ...@@ -67,6 +67,7 @@
"days_from_first_trie": "days from first trie", "days_from_first_trie": "days from first trie",
"December": "December", "December": "December",
"delete": "Delete", "delete": "Delete",
"delete_strip_after_delivery": "Empty strip after delivery",
"delete_template": "Delete from templates", "delete_template": "Delete from templates",
"description": "Description", "description": "Description",
"device_setup": "Device setup", "device_setup": "Device setup",
...@@ -114,6 +115,7 @@ ...@@ -114,6 +115,7 @@
"highlight": "highlight", "highlight": "highlight",
"highlighted": "Highlighted", "highlighted": "Highlighted",
"hours": "hours", "hours": "hours",
"how_many": "How many?",
"input_selection": "How to place a pictogram", "input_selection": "How to place a pictogram",
"instruction": "Instruction", "instruction": "Instruction",
"instruction_begin": "Begin instruction", "instruction_begin": "Begin instruction",
...@@ -142,9 +144,10 @@ ...@@ -142,9 +144,10 @@
"license_expires": "License expires on ", "license_expires": "License expires on ",
"license_expired": "License expired on ", "license_expired": "License expired on ",
"license_invalid": "Invalid license number", "license_invalid": "Invalid license number",
"licenses_left": "{{number}} licenses left",
"license_missing": "Account without license", "license_missing": "Account without license",
"license_number": "License number", "license_number": "License number",
"licenses_created": "Licenses created",
"licenses_left": "{{number}} licenses left",
"light_up": "Light up", "light_up": "Light up",
"link": "Link", "link": "Link",
"loading_pictos": "Loading pictos", "loading_pictos": "Loading pictos",
......
...@@ -67,6 +67,7 @@ ...@@ -67,6 +67,7 @@
"days_from_first_trie": "días desde el primer ensayo", "days_from_first_trie": "días desde el primer ensayo",
"December": "Diciembre", "December": "Diciembre",
"delete": "Eliminar", "delete": "Eliminar",
"delete_strip_after_delivery": "Limpiar cinta tras entrega",
"delete_template": "Eliminar de plantillas", "delete_template": "Eliminar de plantillas",
"description": "Descripción", "description": "Descripción",
"device_setup": "Configuración del dispositivo", "device_setup": "Configuración del dispositivo",
...@@ -114,6 +115,7 @@ ...@@ -114,6 +115,7 @@
"highlight": "Resaltar", "highlight": "Resaltar",
"highlighted": "Resaltado", "highlighted": "Resaltado",
"hours": "horas", "hours": "horas",
"how_many": "¿Cuántas?",
"input_selection": "Cómo colocar un pictograma", "input_selection": "Cómo colocar un pictograma",
"instruction": "Instrucción", "instruction": "Instrucción",
"instruction_begin": "Primer intento", "instruction_begin": "Primer intento",
...@@ -128,7 +130,7 @@ ...@@ -128,7 +130,7 @@
"June": "Junio", "June": "Junio",
"language": "Idioma", "language": "Idioma",
"large": "Grande", "large": "Grande",
"large_picto": "Pictograms grandes", "large_picto": "Pictogramas grandes",
"last_session": "Última sesión", "last_session": "Última sesión",
"legend": "Leyenda", "legend": "Leyenda",
"legend_none":"Sin leyenda", "legend_none":"Sin leyenda",
...@@ -145,6 +147,7 @@ ...@@ -145,6 +147,7 @@
"license_invalid": "Licencia inválida", "license_invalid": "Licencia inválida",
"license_number": "Número de licencia", "license_number": "Número de licencia",
"license_missing": "Cuenta sin licencia", "license_missing": "Cuenta sin licencia",
"licenses_created": "Licencias creadas",
"light_up": "Iluminar", "light_up": "Iluminar",
"link": "Vincular", "link": "Vincular",
"loading_pictos": "Cargando pictos", "loading_pictos": "Cargando pictos",
......
...@@ -8,28 +8,30 @@ dashboardControllers.controller('AdminLicensesCtrl', function AdminLicensesCtrl( ...@@ -8,28 +8,30 @@ dashboardControllers.controller('AdminLicensesCtrl', function AdminLicensesCtrl(
// Don't show the message at the begining // Don't show the message at the begining
$scope.showmessagesupervisor = false; $scope.showmessagesupervisor = false;
$scope.new_numbers = [];
$scope.formdatalicense = { $scope.formdatalicense = {
duration: '' duration: 1,
repeat: 1
}; };
// This generates a new license and registers it in the database // This generates a new license and registers it in the database
$scope.create_license = function(supervisor){ $scope.create_licenses = function(supervisor) {
$scope.new_numbers = [];
for (var i = 0; i < $scope.formdatalicense.repeat; i++) {
$http $http
.post(config.backend+'/license', $scope.formdatalicense) .post(config.backend+'/license', $scope.formdatalicense)
.success(function(data, status, headers, config) { .success(function(data, status, headers, config) {
$scope.formdatalicense.duration = ''; $scope.new_numbers.push(data.number.substr(0,4) +
$scope.new_number = data.number.substr(0,4) +
"-" + data.number.substr(4,4) + "-" + data.number.substr(4,4) +
"-" + data.number.substr(8,4) + "-" + data.number.substr(8,4) +
"-" + data.number.substr(12,4); "-" + data.number.substr(12,4));
console.log($scope.new_number);
$scope.duration_registered = data.duration;
}) })
.error(function(data, status, headers, config) { .error(function(data, status, headers, config) {
ngToast.danger({content: $translate.instant('error_general')}); ngToast.danger({content: $translate.instant('error_general')});
console.log("Error from API: " + data.error); console.log("Error from API: " + data.error);
}); });
}
$scope.duration_registered = $scope.formdatalicense.duration;
}; };
}); });
...@@ -9,12 +9,18 @@ ...@@ -9,12 +9,18 @@
<h3 translate>licenses</h3> <h3 translate>licenses</h3>
<form role="form" ng-submit="create_license()"> <form role="form" ng-submit="create_licenses()">
<div class="form-group"> <div class="form-group">
<label translate>duration_in_months</label>
<input type="number" class="form-control" id="setup_duration" placeholder="{{ 'duration_in_months' | translate }}" required ng-model="formdatalicense.duration" required/> <input type="number" class="form-control" id="setup_duration" placeholder="{{ 'duration_in_months' | translate }}" required ng-model="formdatalicense.duration" required/>
</div> </div>
<div class="form-group">
<label translate>how_many</label>
<input type="number" class="form-control" id="setup_repeat" placeholder="{{ 'how_many' | translate }}" ng-model="formdatalicense.repeat" required/>
</div>
<div class="form-group text-center"> <div class="form-group text-center">
<button type="submit" class="btn btn-primary" translate>generate</button> <button type="submit" class="btn btn-primary" translate>generate</button>
</div> </div>
...@@ -24,8 +30,11 @@ ...@@ -24,8 +30,11 @@
</div> </div>
<div class="col-md-4"> <div class="col-md-4">
<div ng-show="new_number.length > 16" class="alert alert-info"> <div ng-show="new_numbers.length > 0" class="alert alert-info">
<p>{{ 'license_created' | translate }}: <strong>{{ new_number }}</strong></p> <p>{{ 'licenses_created' | translate }}:</p><p>&nbsp;</p>
<div ng-repeat="number in new_numbers track by $index">
<p> <strong>{{ number }}</strong></p>
</div>
<p>{{ 'duration_in_months' | translate }}: {{ duration_registered }}</p> <p>{{ 'duration_in_months' | translate }}: {{ duration_registered }}</p>
</div> </div>
</div> </div>
......
...@@ -34,6 +34,7 @@ dashboardControllers.controller('StudentSetupCtrl', function StudentSetupCtrl( ...@@ -34,6 +34,7 @@ dashboardControllers.controller('StudentSetupCtrl', function StudentSetupCtrl(
var file; var file;
var extension; var extension;
var filename; var filename;
console.log("selected!!");
for (i = 0; i < $files.length; i++) { for (i = 0; i < $files.length; i++) {
file = $files[i]; // { name, size, type } file = $files[i]; // { name, size, type }
...@@ -59,6 +60,7 @@ dashboardControllers.controller('StudentSetupCtrl', function StudentSetupCtrl( ...@@ -59,6 +60,7 @@ dashboardControllers.controller('StudentSetupCtrl', function StudentSetupCtrl(
}) })
.success(function (data) { .success(function (data) {
ngToast.success({ content: $translate.instant('student_updated') }); ngToast.success({ content: $translate.instant('student_updated') });
console.log(JSON.stringify(data));
$scope.studentData.pic = '/upload/studentAvatar/' + data.file.name; $scope.studentData.pic = '/upload/studentAvatar/' + data.file.name;
}); });
} else { } else {
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
<img class="thumbnail preview" ng-src="{{studentData.pic}}" /> <img class="thumbnail preview" ng-src="{{studentData.pic}}" />
<!-- Fin Cambiar imagen de perfil --> <!-- Fin Cambiar imagen de perfil -->
<div class="form-group"> <div class="form-group">
<input type="file" class="filestyle"> <input type="file" class="filestyle" ng-file-select="onFileSelect($files)" ng-model="picFile" accept="image/*">
</div> </div>
</div> </div>
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
<input type="password" class="form-control" id="setup_password2" placeholder="{{ 'password_confirm' | translate }}" ng-model="formUser.password_confirm"/> <input type="password" class="form-control" id="setup_password2" placeholder="{{ 'password_confirm' | translate }}" ng-model="formUser.password_confirm"/>
</div> </div>
<div class="form-group"> <div class="form-group">
<span translate>license_number</span>: <label translate>license_number</label>
<input type="text" id="setup_license" mask="9999-9999-9999-9999" clean="true" placeholder="{{ 'license_number' | translate }}" ng-model="formUser.license_number" required> <input type="text" id="setup_license" mask="9999-9999-9999-9999" clean="true" placeholder="{{ 'license_number' | translate }}" ng-model="formUser.license_number" required>
<br/> <br/>
<span ng-show="studentData.license && !studentData.license_expired" class="text-info"> <span ng-show="studentData.license && !studentData.license_expired" class="text-info">
...@@ -58,16 +58,16 @@ ...@@ -58,16 +58,16 @@
<div class="col-md-6"> <div class="col-md-6">
<div class="form-group"> <div class="form-group">
<span translate>name</span>: <label translate>name</label>
<input type="text" class="form-control" id="student_personal_edit_name" placeholder="{{ 'name' | translate }}" ng-model="formUser.name" required /> <input type="text" class="form-control" id="student_personal_edit_name" placeholder="{{ 'name' | translate }}" ng-model="formUser.name" required />
</div> </div>
<div class="form-group"> <div class="form-group">
<span translate>surname</span>: <label translate>surname</label>
<input type="text" class="form-control" id="student_personal_edit_surname" placeholder="{{ 'surname' | translate }}" ng-model="formUser.surname" required /> <input type="text" class="form-control" id="student_personal_edit_surname" placeholder="{{ 'surname' | translate }}" ng-model="formUser.surname" required />
</div> </div>
<div class="form-group"> <div class="form-group">
<label translate>birthdate</label>
<p class="input-group"> <p class="input-group">
<span translate>birthdate</span>:
<input type="text" class="form-control" datepicker-popup=" {{ 'day_format' | translate }}" ng-model="formUser.birthdate" placeholder="{{ 'birthdate' | translate }}" is-open="opened" close-text="{{'close' | translate}}" required /> <input type="text" class="form-control" datepicker-popup=" {{ 'day_format' | translate }}" ng-model="formUser.birthdate" placeholder="{{ 'birthdate' | translate }}" is-open="opened" close-text="{{'close' | translate}}" required />
<span class="input-group-btn"> <span class="input-group-btn">
<button type="button" class="btn btn-default" ng-click="openCalendar($event)"><i class="glyphicon glyphicon-calendar"></i></button> <button type="button" class="btn btn-default" ng-click="openCalendar($event)"><i class="glyphicon glyphicon-calendar"></i></button>
...@@ -80,7 +80,7 @@ ...@@ -80,7 +80,7 @@
<fieldset> <fieldset>
<div class="form-group"> <div class="form-group">
<span translate>gender</span>: <label translate>gender</label>
<select class="form-control" name="student_gender" id="student_gender" ng-model="formUser.gender" required> <select class="form-control" name="student_gender" id="student_gender" ng-model="formUser.gender" required>
<option value=" ">&nsp;</option> <option value=" ">&nsp;</option>
<option value="F" translate>woman</option> <option value="F" translate>woman</option>
...@@ -88,7 +88,7 @@ ...@@ -88,7 +88,7 @@
</select> </select>
</div> </div>
<div class="form-group"> <div class="form-group">
<span translate>country</span>: <label translate>country</label>
<select class="form-control" name="student_country" id="student_country" ng-model="formUser.country" required> <select class="form-control" name="student_country" id="student_country" ng-model="formUser.country" required>
<option value="ES">España</option> <option value="ES">España</option>
<option value="US">United States</option> <option value="US">United States</option>
...@@ -98,7 +98,7 @@ ...@@ -98,7 +98,7 @@
</div> </div>
<div class="form-group"> <div class="form-group">
<span translate>language</span>: <label translate>language</label>
<select class="form-control" name="supervisor_language" id="supervisor_language" ng-model="formUser.lang"> <select class="form-control" name="supervisor_language" id="supervisor_language" ng-model="formUser.lang">
<option value="es-es">Español</option> <option value="es-es">Español</option>
<option value="en-gb">English</option> <option value="en-gb">English</option>
...@@ -136,8 +136,8 @@ ...@@ -136,8 +136,8 @@
<form role="form" class="form"> <form role="form" class="form">
<fieldset> <fieldset>
<span translate>categories</span>:
<div class="form-group"> <div class="form-group">
<label translate>categories</label>
<div class="input-group"> <div class="input-group">
<span class="input-group-addon"> <span class="input-group-addon">
<input type="checkbox" <input type="checkbox"
...@@ -145,11 +145,11 @@ ...@@ -145,11 +145,11 @@
ng-model="studentData.attributes.categories" ng-model="studentData.attributes.categories"
ng-change="update_attributes()"> ng-change="update_attributes()">
</span> </span>
<label class="form-control" for="studentSetupUseCategories">{{ 'use_categories' | translate }}</label> <span class="form-control" for="studentSetupUseCategories">{{ 'use_categories' | translate }}</span>
</div> </div>
</div> </div>
<span translate>picto_size</span>:
<div class="form-group"> <div class="form-group">
<label translate>picto_size</label>
<div class="input-group"> <div class="input-group">
<span class="input-group-addon"> <span class="input-group-addon">
<input type="radio" <input type="radio"
...@@ -158,9 +158,9 @@ ...@@ -158,9 +158,9 @@
ng-model="studentData.attributes.size" ng-model="studentData.attributes.size"
ng-change="update_attributes()"> ng-change="update_attributes()">
</span> </span>
<label class="form-control" for="studentSetupPictoSizeSmall"> <span class="form-control" for="studentSetupPictoSizeSmall">
{{ 'small_picto' | translate }} {{ 'small_picto' | translate }}
</label> </span>
</div> </div>
<div class="input-group"> <div class="input-group">
<span class="input-group-addon"> <span class="input-group-addon">
...@@ -170,9 +170,9 @@ ...@@ -170,9 +170,9 @@
ng-model="studentData.attributes.size" ng-model="studentData.attributes.size"
ng-change="update_attributes()"> ng-change="update_attributes()">
</span> </span>
<label class="form-control" for="studentSetupPictoSizeLarge"> <span class="form-control" for="studentSetupPictoSizeLarge">
{{ 'large_picto' | translate }} {{ 'large_picto' | translate }}
</label> </span>
</div> </div>
</div> </div>
</fieldset> </fieldset>
...@@ -181,7 +181,7 @@ ...@@ -181,7 +181,7 @@
<div class="col-md-6"> <div class="col-md-6">
<fieldset> <fieldset>
<span translate>feedback_picto</span>: <label translate>feedback_picto</label>
<div class="input-group"> <div class="input-group">
<span class="input-group-addon"> <span class="input-group-addon">
<input type="checkbox" <input type="checkbox"
...@@ -189,7 +189,7 @@ ...@@ -189,7 +189,7 @@
ng-model="studentData.attributes.input_feedback.vibration" ng-model="studentData.attributes.input_feedback.vibration"
ng-change="update_attributes()"> ng-change="update_attributes()">
</span> </span>
<label class="form-control" for="studentSetupVibrateOnTouch">{{ 'vibration' | translate }}</label> <span class="form-control" for="studentSetupVibrateOnTouch">{{ 'vibration' | translate }}</span>
</div> </div>
<div class="input-group"> <div class="input-group">
<span class="input-group-addon"> <span class="input-group-addon">
...@@ -198,7 +198,7 @@ ...@@ -198,7 +198,7 @@
ng-model="studentData.attributes.input_feedback.beep" ng-model="studentData.attributes.input_feedback.beep"
ng-change="update_attributes()"> ng-change="update_attributes()">
</span> </span>
<label class="form-control" for="studentSetupBeepOnTouch">{{ 'beep' | translate }}</label> <span class="form-control" for="studentSetupBeepOnTouch">{{ 'beep' | translate }}</span>
</div> </div>
<div class="input-group"> <div class="input-group">
<span class="input-group-addon"> <span class="input-group-addon">
...@@ -207,7 +207,7 @@ ...@@ -207,7 +207,7 @@
ng-model="studentData.attributes.input_feedback.read" ng-model="studentData.attributes.input_feedback.read"
ng-change="update_attributes()"> ng-change="update_attributes()">
</span> </span>
<label class="form-control" for="studentSetupReadOnTouch">{{ 'read_picto' | translate }}</label> <span class="form-control" for="studentSetupReadOnTouch">{{ 'read_picto' | translate }}</span>
</div> </div>
<div class="input-group"> <div class="input-group">
<span class="input-group-addon"> <span class="input-group-addon">
...@@ -216,9 +216,20 @@ ...@@ -216,9 +216,20 @@
ng-model="studentData.attributes.input_feedback.highlight" ng-model="studentData.attributes.input_feedback.highlight"
ng-change="update_attributes()"> ng-change="update_attributes()">
</span> </span>
<label class="form-control" for="studentSetupHighlightOnTouch"> <span class="form-control" for="studentSetupHighlightOnTouch">
{{ 'highlight' | translate }} {{ 'highlight' | translate }}
</label> </span>
</div>
<div class="input-group">
<span class="input-group-addon">
<input type="checkbox"
id="studentSetupDeleteStripAfterDelivery"
ng-model="studentData.attributes.input_feedback.delete_strip_after_delivery"
ng-change="update_attributes()">
</span>
<span class="form-control" for="studentSetupDeleteStripAfterDelivery">
{{ 'delete_strip_after_delivery' | translate }}
</span>
</div> </div>
</fieldset> </fieldset>
<!-- DISABLED, NOT IMPLEMENTED YET <!-- DISABLED, NOT IMPLEMENTED YET
......
...@@ -110,6 +110,12 @@ html { ...@@ -110,6 +110,12 @@ html {
} }
/* Sticky footer: pie de página con idiomas*/ /* Sticky footer: pie de página con idiomas*/
div.footer-space {
height: 67px;
width: 100%;
clear: both;
}
div.languages{ div.languages{
position: absolute; position: absolute;
bottom: 0; bottom: 0;
......
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