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