Commit 71a8171b by Germán Callejas Alcántara

Merge branch 'newsignup' of http://gitlab.ujaen.es/yotta/pictogram into newsignup

parents 087ffc09 93fada03
{ {
"account": "Account", "account": "Account",
"account_activate": "The account has been activated", "account_activate": "The account has been activated",
"account_desc_office": "Manage students, intervention teams along with all therapist related functionalities.",
"account_desc_therapist": "Manage pictograms, devices, record supervised sessions and get progress reports.",
"account_desc_tutor": "Configure your child's pictograms and his/her communication device.",
"account_no_activate": "The account could not be activated", "account_no_activate": "The account could not be activated",
"action-add": "Add picto", "action-add": "Add picto",
"action-delete": "Delete picto", "action-delete": "Delete picto",
......
{ {
"account": "Cuenta", "account": "Cuenta",
"account_activate": "La cuenta ha sido activada", "account_activate": "La cuenta ha sido activada",
"account_desc_office": "Gestione alumnos y equipos de intervención, además de todas las funcionalidades propias de un terapeuta.",
"account_desc_tutor": "Gestione los pictogramas de su hijo o hija y configure su dispositivo de comunicación.",
"account_desc_therapist": "Gestione pictogramas, dispositivos, grabe sesiones de terapia y obtenga estadísticas de progreso.",
"account_no_activate": "La cuenta no se ha podido activar", "account_no_activate": "La cuenta no se ha podido activar",
"action-add": "Añade picto", "action-add": "Añade picto",
"action-delete": "Elimina picto", "action-delete": "Elimina picto",
......
...@@ -17,8 +17,11 @@ function LoginCtrl( ...@@ -17,8 +17,11 @@ function LoginCtrl(
config, config,
$stateParams, $stateParams,
$timeout, $timeout,
ngToast) { ngToast,
CONSTANTS,
vcRecaptchaService) {
/* Slider object */
$scope.slide = { $scope.slide = {
state: 'login', state: 'login',
prev: 'login', prev: 'login',
...@@ -40,51 +43,32 @@ function LoginCtrl( ...@@ -40,51 +43,32 @@ function LoginCtrl(
} }
}; };
/*
LOGIN --------------------------
*/
/* Login credentials */
$scope.credentials = { $scope.credentials = {
email: '', email: '',
password: '', password: '',
lang: 'es-es' lang: 'es-es'
}; };
$scope.office = { /* Login function */
logoUrl : 'img/logo_pictogram.png',
name : 'Pictogram'
};
// Corporate login, office code has been passed
if ($stateParams.office) {
$http
.get(config.backend + '/office/' + $stateParams.office)
.success(function (data) {
$scope.office = data;
});
}
$scope.login = function () { $scope.login = function () {
$scope.submitted = true; $scope.submitted = true;
$http $http
.post(config.backend + '/sup/login', $scope.credentials) .post(config.backend + '/sup/login', $scope.credentials)
.success(function (data) { .success(function (data) {
// default logo to Pictogram logo data.user.isTutor = data.user.role == 'tutor';
if (!data.user.office) {
data.user.office = $scope.office;
data.user.isTutor = true;
} else
data.user.isTutor = false;
if (data.user.office.logoUrl.length < 5)
data.user.office.logoUrl = 'img/logo_pictogram.png';
$window.sessionStorage.token = data.token; $window.sessionStorage.token = data.token;
//User data correct //User data correct
if (data.user) { if (data.user) {
// Adapt language en-us to en-gb (the latter is the one supported for 'en') // Adapt language en-us to en-gb (the latter is the one supported for 'en')
if (data.user.lang === 'en-us') { if (data.user.lang === 'en-us')
data.user.lang = 'en-gb'; data.user.lang = 'en-gb';
}
//Update $scope
$scope.lang = data.user.lang; $scope.lang = data.user.lang;
//Update $translate
$translate.use($scope.lang); $translate.use($scope.lang);
} else { } else {
//No user data, use default lang //No user data, use default lang
...@@ -93,10 +77,7 @@ function LoginCtrl( ...@@ -93,10 +77,7 @@ function LoginCtrl(
// Change // Change
$window.sessionStorage.user = JSON.stringify(data.user); $window.sessionStorage.user = JSON.stringify(data.user);
ngToast.success($translate('login_success'));
$translate('login_success').then(function (translation) {
ngToast.success({ content: translation });
});
// Name in login success message // Name in login success message
$scope.name = data.user.name; $scope.name = data.user.name;
...@@ -107,13 +88,69 @@ function LoginCtrl( ...@@ -107,13 +88,69 @@ function LoginCtrl(
.error(function (err) { .error(function (err) {
$scope.submitted = false; $scope.submitted = false;
delete $window.sessionStorage.token; delete $window.sessionStorage.token;
if (err.search("without students") > 0) { if (err.search("without students") > 0)
ngToast.warning($translate.instant('no_students_for_user')); ngToast.warning($translate.instant('no_students_for_user'));
} else if (err.search("not been activated") > 0) { else if (err.search("not been activated") > 0)
ngToast.danger($translate.instant('inactive_account')); ngToast.danger($translate.instant('inactive_account'));
} else { else
ngToast.danger($translate.instant("login_fail")); ngToast.danger($translate.instant("login_fail"));
});
};
/*
SIGNUP ------------------------------
*/
/* form data */
var formdata_empty = {
name: '',
email: '',
password: '',
password_confirm: '',
lang: '00',
role: '',
};
$scope.minlength = CONSTANTS.password_minlength;
$scope.reset = function () {
$scope.formdata = formdata_empty;
};
$scope.reset();
// Signup form submit
$scope.signup = function () {
if ($scope.formdata.password.length < CONSTANTS.password_minlength) {
ngToast.danger({ content: $translate.instant('password_short', {minlength: CONSTANTS.password_minlength}) });
return;
} }
if (!$scope.formdata.disclaimer_accepted) {
ngToast.danger({ content: $translate.instant('disclaimer_requested') });
return;
}
if (!$scope.formdata.role) {
ngToast.danger({ content: $translate.instant('case_requested') });
return;
}
if (!$scope.signInForm.$valid)
return;
$http
.post(config.backend + '/sup', $scope.formdata)
.success(function () {
ngToast.success({ content: $translate.instant('user_created', { name: $scope.formdata.name, surname: $scope.formdata.surname }) });
$scope.reset();
})
.error(function () {
ngToast.danger({ content: $translate.instant('user_exists', {email: $scope.formdata.email}) });
}); });
}; };
}); });
...@@ -47,29 +47,8 @@ function SignInCtrl($scope, ...@@ -47,29 +47,8 @@ function SignInCtrl($scope,
$scope.reset(); $scope.reset();
// Get the list of offices // Signup form submit
$http $scope.signup = function () {
.get(config.backend + '/office/get_all')
.success(function (offices) {
$scope.offices = offices;
})
.error(function () {
ngToast.danger({ content: $translate.instant('server_error') });
});
// Copy fields from supervisor to office
$scope.copyFields = function () {
$scope.formdata.office.address = $scope.formdata.address;
$scope.formdata.office.postalCode = $scope.formdata.postalCode;
$scope.formdata.office.country = $scope.formdata.country;
$scope.formdata.office.lang = $scope.formdata.lang;
$scope.formdata.office.email = $scope.formdata.email;
$scope.formdata.office.phone1 = $scope.formdata.phone;
$scope.formdata.office.contactPerson = $scope.formdata.name + " " + $scope.formdata.surname;
};
// Form submit
$scope.signin = function () {
// Validate email match // Validate email match
if ($scope.formdata.email !== $scope.formdata.email_confirm) { if ($scope.formdata.email !== $scope.formdata.email_confirm) {
ngToast.danger({ content: $translate.instant('email_match') }); ngToast.danger({ content: $translate.instant('email_match') });
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<div class="header-image"> <div class="header-image">
<div class="row"> <div class="row">
<div class="col-md-12 text-center"> <div class="col-md-12 text-center">
<img ng-src="{{office.logoUrl}}" alt="{{office.name}}" title="{{office.name}}"> <img ng-src="img/logo_pictogram.png" alt="Pictogram" title="Pictogram">
</div> </div>
</div> </div>
</div> </div>
...@@ -86,38 +86,59 @@ ...@@ -86,38 +86,59 @@
</div> </div>
</div> </div>
<form name="signupForm" role="form" ng-submit="signup()">
<!-- <!--
SLIDE 2: Account selection SLIDE 2: Account selection
--> -->
<div ng-class="slide.back ? 'switch-animation-back' : 'switch-animation'" ng-switch-when="accounts"> <div ng-class="slide.back ? 'switch-animation-back' : 'switch-animation'" ng-switch-when="accounts">
<h2 translate>select_account</h2> <h2 translate>select_account</h2>
<div class="row"> <div class="row">
<div class="col-md-4"> <div class="col-md-4">
<legend translate>parents_tutor</legend> <legend translate>parents_tutor</legend>
<div class="text-center"> <div class="text-center">
<a ng-click="slide.rightTo('tutor')"><img src="img/parents.png" alt="{{'parents_tutor' | translate}}" title="{{'parents_tutor' | translate}}" /></a> <a ng-click="slide.rightTo('tutor'); formdata.role = 'tutor'">
</div> <img src="img/parents.png" alt="{{'parents_tutor' | translate}}" title="{{'parents_tutor' | translate}}"
<div> ng-class="{'small-img': hover_tutor}"
<p translate>tutor_account_desc</p> ng-mouseenter="hover_tutor = true"
ng-mouseleave="hover_tutor = false"/>
</a>
</div> </div>
</div> </div>
<div class="col-md-4"> <div class="col-md-4">
<legend translate>therapist</legend> <legend translate>therapist</legend>
<div class="text-center"> <div class="text-center">
<a ng-click="slide.rightTo('therapist')"><img src="img/therapist.png" alt="{{'therapist' | translate}}" title="{{'therapist' | translate}}" /></a> <a ng-click="slide.rightTo('therapist'); formdata.role = 'therapist'">
</div> <img src="img/therapist.png" alt="{{'therapist' | translate}}" title="{{'therapist' | translate}}"
<div> ng-class="{'small-img': hover_therapist}"
<p translate>therapist_account_desc</p> ng-mouseenter="hover_therapist = true"
ng-mouseleave="hover_therapist = false"/>
</a>
</div> </div>
</div> </div>
<div class="col-md-4"> <div class="col-md-4">
<legend translate>office_center</legend> <legend translate>office_center</legend>
<div class="text-center"> <div class="text-center">
<a ng-click="slide.rightTo('office')"><img src="img/office.jpg" alt="{{'office_center' | translate}}" title="{{'office_center' | translate}}" /></a> <a ng-click="slide.rightTo('office'); formdata.role = 'office'">
<img src="img/office.jpg" alt="{{'office_center' | translate}}" title="{{'office_center' | translate}}"
ng-class="{'small-img': hover_office}"
ng-mouseenter="hover_office = true"
ng-mouseleave="hover_office = false"/>
</a>
</div>
</div>
</div>
<div class="row">
<div class="col-md-4">
<p translate>account_desc_tutor</p>
</div> </div>
<div> <div class="col-md-4">
<p translate>office_account_desc</p> <p translate>account_desc_therapist</p>
</div> </div>
<div class="col-md-4">
<p translate>account_desc_office</p>
</div> </div>
</div> </div>
</div> </div>
...@@ -135,16 +156,17 @@ ...@@ -135,16 +156,17 @@
<input type="hidden" ng-model="formdata.role" value="tutor"></input> <input type="hidden" ng-model="formdata.role" value="tutor"></input>
<div class="form-group"> <div class="form-group">
<label translate>email</label> <label translate>email</label>
<input type="email" class="form-control" placeholder="{{ 'email' | translate }}" ng-model="formdata.email"/> <input type="email" class="form-control" placeholder="{{ 'email' | translate }}" required required ng-model="formdata.email"/>
</div> </div>
<fieldset> <fieldset>
<label translate>password</label> <label translate>password</label>
<span class="color_red text_sm pull-right" ng-show="formdata.password != formdata.password_confirm" translate>password_match</span> <span class="color_red text_sm pull-right" ng-show="formdata.password != formdata.password_confirm" translate>password_match</span>
<span class="color_red text_sm pull-right" ng-show="formdata.password.length < minlength" translate>password_short</span>
<div class="form-group"> <div class="form-group">
<input type="password" class="form-control" id="signin_password1" placeholder="{{ 'password_type' | translate }}"/> <input type="password" class="form-control" id="signin_password1" placeholder="{{ 'password_type' | translate }}" required ng-model="formdata.password"/>
</div> </div>
<div class="form-group"> <div class="form-group">
<input type="password" class="form-control" id="signin_password2" placeholder="{{ 'password_confirm' | translate }}"/> <input type="password" class="form-control" id="signin_password2" placeholder="{{ 'password_confirm' | translate }}" required ng-model="formdata.password_confirm"/>
</div> </div>
</fieldset> </fieldset>
<div class="form-group"> <div class="form-group">
...@@ -164,7 +186,7 @@ ...@@ -164,7 +186,7 @@
<button class="btn btn-default" ng-click="slide.leftTo('accounts')">&lt;&lt; {{ 'back' | translate }} </button> <button class="btn btn-default" ng-click="slide.leftTo('accounts')">&lt;&lt; {{ 'back' | translate }} </button>
</div> </div>
<div class="col-md-4"> <div class="col-md-4">
<button class="btn btn-primary float-right" ng-click="slide.rightTo('confirmation')">{{ 'create_account' | translate }} &gt;&gt; </button> <button type="submit" class="btn btn-primary" ng-disabled="signupForm.$invalid" ng-click="slide.rightTo('confirmation')">{{ 'create_account' | translate }} &gt;&gt; </button>
</div> </div>
</div> </div>
</div> </div>
...@@ -182,16 +204,16 @@ ...@@ -182,16 +204,16 @@
<div class="form-group col-md-4" id="tutor_form"> <div class="form-group col-md-4" id="tutor_form">
<div class="form-group"> <div class="form-group">
<label translate>email</label> <label translate>email</label>
<input type="email" class="form-control" placeholder="{{ 'email' | translate }}" ng-model="formdata.office.email"/> <input type="email" class="form-control" placeholder="{{ 'email' | translate }}" required ng-model="formdata.office.email"/>
</div> </div>
<fieldset> <fieldset>
<label translate>password</label> <label translate>password</label>
<span class="color_red text_sm pull-right" ng-show="formdata.password != formdata.password_confirm" translate>password_match</span> <span class="color_red text_sm pull-right" ng-show="formdata.password != formdata.password_confirm" translate>password_match</span>
<div class="form-group"> <div class="form-group">
<input type="password" class="form-control" id="signin_password1" placeholder="{{ 'password_type' | translate }}"/> <input type="password" class="form-control" id="signin_password1" placeholder="{{ 'password_type' | translate }}" required ng-model="formdata.password"/>
</div> </div>
<div class="form-group"> <div class="form-group">
<input type="password" class="form-control" id="signin_password2" placeholder="{{ 'password_confirm' | translate }}"/> <input type="password" class="form-control" id="signin_password2" placeholder="{{ 'password_confirm' | translate }}" required ng-model="formdata.password_confirm"/>
</div> </div>
</fieldset> </fieldset>
<div class="form-group"> <div class="form-group">
...@@ -209,7 +231,7 @@ ...@@ -209,7 +231,7 @@
<button class="btn btn-default" ng-click="slide.leftTo('accounts')">&lt;&lt; {{ 'back' | translate }} </button> <button class="btn btn-default" ng-click="slide.leftTo('accounts')">&lt;&lt; {{ 'back' | translate }} </button>
</div> </div>
<div class="col-md-4"> <div class="col-md-4">
<button class="btn btn-primary float-right" ng-click="slide.rightTo('confirmation'); formdata.role = 'therapist'">{{ 'create_account' | translate }} &gt;&gt; </button> <button type="submit" class="btn btn-primary" ng-disabled="signupForm.$invalid" ng-click="slide.rightTo('confirmation')">{{ 'create_account' | translate }} &gt;&gt; </button>
</div> </div>
</div> </div>
</div> </div>
...@@ -224,24 +246,22 @@ ...@@ -224,24 +246,22 @@
<img src="img/office.jpg" alt="{{'office_center' | translate}}" title="{{'office_center' | translate}}" /> <img src="img/office.jpg" alt="{{'office_center' | translate}}" title="{{'office_center' | translate}}" />
</div> </div>
<div class="form-group col-md-4" id="office_form"> <div class="form-group col-md-4" id="office_form">
<input type="hidden" ng-model="formdata.role" value="office"></input>
<div class="form-group"> <div class="form-group">
<label translate>office_name</label> <label translate>name</label>
<input type="text" class="form-control" placeholder="{{ 'office_name' | translate }}" ng-model="formdata.office.name"/> <input type="text" class="form-control" placeholder="{{ 'name' | translate }}" required ng-model="formdata.name"/>
</div> </div>
<div class="form-group"> <div class="form-group">
<label translate>email</label> <label translate>email</label>
<input type="email" class="form-control" placeholder="{{ 'email' | translate }}" ng-model="formdata.office.email"/> <input type="email" class="form-control" placeholder="{{ 'email' | translate }}" required ng-model="formdata.email"/>
</div> </div>
<fieldset> <fieldset>
<label translate>password</label> <label translate>password</label>
<span class="color_red text_sm pull-right" ng-show="formdata.password != formdata.password_confirm" translate>password_match</span> <span class="color_red text_sm pull-right" ng-show="formdata.password != formdata.password_confirm" translate>password_match</span>
<div class="form-group"> <div class="form-group">
<input type="password" class="form-control" id="signin_password1" placeholder="{{ 'password_type' | translate }}"/> <input type="password" class="form-control" id="signin_password1" placeholder="{{ 'password_type' | translate }}" required ng-model="formdata.password"/>
</div> </div>
<div class="form-group"> <div class="form-group">
<input type="password" class="form-control" id="signin_password2" placeholder="{{ 'password_confirm' | translate }}"/> <input type="password" class="form-control" id="signin_password2" placeholder="{{ 'password_confirm' | translate }}" required ng-model="formdata.password_confirm"/>
</div> </div>
</fieldset> </fieldset>
<div class="form-group"> <div class="form-group">
...@@ -259,11 +279,12 @@ ...@@ -259,11 +279,12 @@
<button class="btn btn-default" ng-click="slide.leftTo('accounts')">&lt;&lt; {{ 'back' | translate }} </button> <button class="btn btn-default" ng-click="slide.leftTo('accounts')">&lt;&lt; {{ 'back' | translate }} </button>
</div> </div>
<div class="col-md-4"> <div class="col-md-4">
<button class="btn btn-primary float-right" ng-click="slide.rightTo('confirmation')">{{ 'create_account' | translate }} &gt;&gt; </button> <button type="submit" class="btn btn-primary" ng-disabled="signupForm.$invalid" ng-click="slide.rightTo('confirmation')">{{ 'create_account' | translate }} &gt;&gt; </button>
</div> </div>
</div> </div>
</div> </div>
</form>
<!-- <!--
SLIDE 6: Confirmation message SLIDE 6: Confirmation message
...@@ -277,12 +298,6 @@ ...@@ -277,12 +298,6 @@
</div> </div>
<!--
SLIDE 7: Change password
-->
<div ng-class="slide.back ? 'switch-animation-back' : 'switch-animation'" ng-switch-when="change_password">
</div>
</div> </div>
</div> </div>
<div class="col-md-2"> <div class="col-md-2">
......
...@@ -1103,6 +1103,12 @@ input.editable.scene-name { ...@@ -1103,6 +1103,12 @@ input.editable.scene-name {
float: right; float: right;
} }
/* Cambiar tamaño imagen */
.small-img {
margin-top: 25px;
width: 200px;
}
/* Estilos para ngSwitch */ /* Estilos para ngSwitch */
.switch-panel-body { .switch-panel-body {
position:relative; position:relative;
......
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