Commit 2ecfe541 authored by Diego Rey's avatar Diego Rey
Browse files

Fix language switcher

parent f0e3cccd
......@@ -9,7 +9,13 @@
</div>
<div class="form-group">
<input type="password" [(ngModel)]=model.password (keyup.enter)=login() name="password" class="form-control input-underline input-lg" placeholder='{{ "i18n.object.password" | translate | titleCase }}'>
<input
type="password"
[(ngModel)]=model.password
(keyup.enter)=login()
name="password"
class="form-control input-underline input-lg"
placeholder='{{ "i18n.object.password" | translate | titleCase }}'>
</div>
<div class="form-group" style="margin-bottom: 0px; text-align: left;">
<div ngbDropdown class="d-inline-block language-switcher">
......
......@@ -37,6 +37,12 @@ export class LoginComponent implements OnInit {
) { }
ngOnInit() {
let currentSession = sessionStorage.getItem("currentUser");
let langCode = currentSession ? JSON.parse(currentSession).language : 'es';
if (langCode) {
this.model.language = this.getLanguageElementByCode(langCode);
}
// reset login status
this.authenticationService.logout();
......@@ -84,4 +90,15 @@ export class LoginComponent implements OnInit {
this.translate.use(this.model.language.code);
}
getLanguageElementByCode(code) {
let langElement = null;
for(let lang of this.languages) {
if (lang.code === code) {
langElement = lang;
break;
}
};
return langElement;
}
}
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 to comment