1
0

Initial application generated by JHipster-5.8.2

This commit is contained in:
Michael Hoennig
2019-04-01 13:14:56 +02:00
commit e0b3d2a36d
404 changed files with 49698 additions and 0 deletions

View File

@ -0,0 +1,63 @@
import { Component, OnInit } from '@angular/core';
import { JhiLanguageService } from 'ng-jhipster';
import { AccountService, JhiLanguageHelper } from 'app/core';
@Component({
selector: 'jhi-settings',
templateUrl: './settings.component.html'
})
export class SettingsComponent implements OnInit {
error: string;
success: string;
settingsAccount: any;
languages: any[];
constructor(
private accountService: AccountService,
private languageService: JhiLanguageService,
private languageHelper: JhiLanguageHelper
) {}
ngOnInit() {
this.accountService.identity().then(account => {
this.settingsAccount = this.copyAccount(account);
});
this.languageHelper.getAll().then(languages => {
this.languages = languages;
});
}
save() {
this.accountService.save(this.settingsAccount).subscribe(
() => {
this.error = null;
this.success = 'OK';
this.accountService.identity(true).then(account => {
this.settingsAccount = this.copyAccount(account);
});
this.languageService.getCurrent().then(current => {
if (this.settingsAccount.langKey !== current) {
this.languageService.changeLanguage(this.settingsAccount.langKey);
}
});
},
() => {
this.success = null;
this.error = 'ERROR';
}
);
}
copyAccount(account) {
return {
activated: account.activated,
email: account.email,
firstName: account.firstName,
langKey: account.langKey,
lastName: account.lastName,
login: account.login,
imageUrl: account.imageUrl
};
}
}