Skip to content

Commit

Permalink
alerts-ui: Set lang from user preferences after logging in
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexITC committed Feb 10, 2018
1 parent 3afcf6d commit 69cf0db
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
7 changes: 7 additions & 0 deletions alerts-ui/src/app/login/login.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { ErrorService } from '../error.service';
import { ReCaptchaService } from '../re-captcha.service';
import { NotificationService } from '../notification.service';
import { NavigatorService } from '../navigator.service';
import { LanguageService } from '../language.service';

@Component({
selector: 'app-login',
Expand Down Expand Up @@ -39,6 +40,7 @@ export class LoginComponent implements OnInit {
private authService: AuthService,
private notificationService: NotificationService,
private navigatorService: NavigatorService,
private languageService: LanguageService,
private translate: TranslateService,
public errorService: ErrorService,
public reCaptchaService: ReCaptchaService) {
Expand Down Expand Up @@ -88,6 +90,11 @@ export class LoginComponent implements OnInit {
this.translate.get('message.welcome')
.subscribe(msg => this.notificationService.info(`${msg} ${this.authService.getAuthenticatedUser().email}`));

// load lang from server
this.usersService
.getPreferences()
.subscribe(preferences => this.languageService.setLang(preferences.lang));

this.navigatorService.home();
}

Expand Down
6 changes: 6 additions & 0 deletions alerts-ui/src/app/users.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,10 @@ export class UsersService {

return this.http.put(url, data, httpOptions);
}

getPreferences(): Observable<any> {
const url = this.baseUrl + '/me/preferences';

return this.http.get(url);
}
}

0 comments on commit 69cf0db

Please sign in to comment.