mirror of https://github.com/Ombi-app/Ombi
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
54 lines
1.8 KiB
54 lines
1.8 KiB
import { Component, OnInit } from "@angular/core";
|
|
import { AuthService } from "../../../auth/auth.service";
|
|
import { TranslateService } from "@ngx-translate/core";
|
|
import { AvailableLanguages, ILanguage } from "./user-preference.constants";
|
|
import { StorageService } from "../../../shared/storage/storage-service";
|
|
import { IdentityService, SettingsService } from "../../../services";
|
|
|
|
@Component({
|
|
templateUrl: "./user-preference.component.html",
|
|
styleUrls: ["./user-preference.component.scss"],
|
|
})
|
|
export class UserPreferenceComponent implements OnInit {
|
|
|
|
public username: string;
|
|
public selectedLang: string;
|
|
public availableLanguages = AvailableLanguages;
|
|
public qrCode: string;
|
|
public qrCodeEnabled: boolean;
|
|
|
|
constructor(private authService: AuthService,
|
|
private readonly translate: TranslateService,
|
|
private storage: StorageService,
|
|
private readonly identityService: IdentityService,
|
|
private readonly settingsService: SettingsService) { }
|
|
|
|
public async ngOnInit() {
|
|
const user = this.authService.claims();
|
|
if (user.name) {
|
|
this.username = user.name;
|
|
}
|
|
const customization = await this.settingsService.getCustomization().toPromise();
|
|
|
|
const accessToken = await this.identityService.getAccessToken().toPromise();
|
|
this.qrCode = `${customization.applicationUrl}|${accessToken}`;
|
|
|
|
if(!customization.applicationUrl) {
|
|
this.qrCodeEnabled = false;
|
|
} else {
|
|
this.qrCodeEnabled = true;
|
|
}
|
|
|
|
const selectedLang = this.storage.get("Language");
|
|
if (selectedLang) {
|
|
this.selectedLang = selectedLang;
|
|
}
|
|
}
|
|
|
|
public languageSelected() {
|
|
this.storage.save("Language", this.selectedLang);
|
|
this.translate.use(this.selectedLang);
|
|
}
|
|
|
|
}
|