Commit 781be460 authored by George Kalampokis's avatar George Kalampokis

Nav Bar Language selector can properly be stored to the user's settings and is...

Nav Bar Language selector can properly be stored to the user's settings and is hidden on the User's profile page (ref #228)
parent 0bebdae1
......@@ -28,14 +28,14 @@ import java.util.Map;
* Created by ikalyvas on 5/30/2018.
*/
@Service("logger")
//@Service("logger")
public class HttpRemoteLogger extends AbstractBatchLogger implements Logger {
private RestTemplate rest;
private HttpHeaders headers;
private Environment environment;
@Autowired
//@Autowired
public HttpRemoteLogger(Environment environment) {
super(environment);
this.rest = new RestTemplate();
......
......@@ -36,7 +36,7 @@
</mat-menu>
</div> -->
<div class="col-md-auto" *ngIf="!(isAuthenticated() && onLanguageEditor())">
<div class="col-md-auto" *ngIf="!(isAuthenticated() && onInvalidUrl())">
<button mat-icon-button [matMenuTriggerFor]="languageMenu">
<mat-icon>language</mat-icon>
</button>
......
......@@ -9,9 +9,8 @@ import { BaseComponent } from '@common/base/base.component';
import { takeUntil } from 'rxjs/operators';
import { UserDialogComponent } from '../misc/navigation/user-dialog/user-dialog.component';
import { DATASETS_ROUTES, DMP_ROUTES, GENERAL_ROUTES } from '../sidebar/sidebar.component';
import { TranslateService } from '@ngx-translate/core';
import { Language } from '@app/models/language/Language';
import { LanguageService } from '@app/core/services/language/language.service';
import { UserService } from '@app/core/services/user/user.service';
const availableLanguages: any[] = require('../../../assets/resources/language.json');
......@@ -38,7 +37,8 @@ export class NavbarComponent extends BaseComponent implements OnInit {
private authentication: AuthService,
private dialog: MatDialog,
private progressIndicationService: ProgressIndicationService,
private languageService: LanguageService
private languageService: LanguageService,
private userService: UserService
) {
super();
this.location = location;
......@@ -72,8 +72,8 @@ export class NavbarComponent extends BaseComponent implements OnInit {
return !(!this.authentication.current());
}
public onLanguageEditor(): boolean {
return this.currentRoute === '/language-editor';
public onInvalidUrl(): boolean {
return this.currentRoute === '/language-editor' || this.currentRoute === '/profile';
}
sidebarOpen() {
......@@ -200,7 +200,24 @@ export class NavbarComponent extends BaseComponent implements OnInit {
}
onLanguageSelected(selectedLanguage: any) {
this.languageService.changeLanguage(selectedLanguage.value);
this.router.navigate([this.router.url]);
if (this.isAuthenticated()) {
const langMap = new Map<string, string>();
langMap.set('language', selectedLanguage.value);
this.userService.updateUserSettings({language: selectedLanguage})
.pipe(takeUntil(this._destroyed))
.subscribe((response) => {
this.languageService.changeLanguage(selectedLanguage.value);
this.authentication.me()
.pipe(takeUntil(this._destroyed))
.subscribe ( innerResponse =>
{this.router.navigate([this.router.url]);});
},
error => {
console.log(error);
});
} else {
this.languageService.changeLanguage(selectedLanguage.value);
this.router.navigate([this.router.url]);
}
}
}
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