@ -1,12 +1,13 @@
import { Component , Inject , OnInit } from "@angular/core" ;
import { Component , Inject , OnInit } from "@angular/core" ;
import { AuthService } from "../../../auth/auth.service" ;
import { AuthService } from "../../../auth/auth.service" ;
import { TranslateService } from "@ngx-translate/core" ;
import { TranslateService } from "@ngx-translate/core" ;
import { AvailableLanguages , ILanguage } from "./user-preference.constants" ;
import { AvailableLanguages } from "./user-preference.constants" ;
import { IdentityService , NotificationService , SettingsService, ValidationService } from "../../../services" ;
import { IdentityService , NotificationService , ValidationService } from "../../../services" ;
import { I CustomizationSettings, I User, UserType } from "../../../interfaces" ;
import { I User, UserType } from "../../../interfaces" ;
import { Md5 } from "ts-md5" ;
import { Md5 } from "ts-md5" ;
import { FormBuilder , FormGroup , Validators } from "@angular/forms" ;
import { FormBuilder , FormGroup , Validators } from "@angular/forms" ;
import { APP_BASE_HREF } from "@angular/common" ;
import { APP_BASE_HREF } from "@angular/common" ;
import { CustomizationFacade } from "../../../state/customization" ;
@Component ( {
@Component ( {
templateUrl : "./user-preference.component.html" ,
templateUrl : "./user-preference.component.html" ,
@ -22,21 +23,22 @@ export class UserPreferenceComponent implements OnInit {
public qrCodeEnabled : boolean ;
public qrCodeEnabled : boolean ;
public countries : string [ ] ;
public countries : string [ ] ;
public selectedCountry : string ;
public selectedCountry : string ;
public customizationSettings : ICustomizationSettings ;
public UserType = UserType ;
public UserType = UserType ;
public baseUrl : string ;
public baseUrl : string ;
public passwordForm : FormGroup ;
public passwordForm : FormGroup ;
private user : IUser ;
private user : IUser ;
private applicationUrl : string = this . customizationFacade . appUrl ( ) ;
private logo : string = this . customizationFacade . logo ( ) ;
constructor ( private authService : AuthService ,
constructor ( private authService : AuthService ,
private readonly translate : TranslateService ,
private readonly translate : TranslateService ,
private readonly notification : NotificationService ,
private readonly notification : NotificationService ,
private readonly identityService : IdentityService ,
private readonly identityService : IdentityService ,
private readonly settingsService : SettingsService ,
private readonly fb : FormBuilder ,
private readonly fb : FormBuilder ,
private readonly validationService : ValidationService ,
private readonly validationService : ValidationService ,
private readonly customizationFacade : CustomizationFacade ,
@Inject ( APP_BASE_HREF ) public internalBaseUrl : string ) { }
@Inject ( APP_BASE_HREF ) public internalBaseUrl : string ) { }
public async ngOnInit() {
public async ngOnInit() {
@ -47,14 +49,13 @@ export class UserPreferenceComponent implements OnInit {
if ( user . name ) {
if ( user . name ) {
this . username = user . name ;
this . username = user . name ;
}
}
this . customizationSettings = await this . settingsService . getCustomization ( ) . toPromise ( ) ;
this . selectedLang = this . translate . currentLang ;
this . selectedLang = this . translate . currentLang ;
const accessToken = await this . identityService . getAccessToken ( ) . toPromise ( ) ;
const accessToken = await this . identityService . getAccessToken ( ) . toPromise ( ) ;
this . qrCode = ` ${ this . customizationSettings. applicationUrl} | ${ accessToken } ` ;
this . qrCode = ` ${ this . applicationUrl} | ${ accessToken } ` ;
if ( ! this . customizationSettings. applicationUrl) {
if ( ! this . applicationUrl) {
this . qrCodeEnabled = false ;
this . qrCodeEnabled = false ;
} else {
} else {
this . qrCodeEnabled = true ;
this . qrCodeEnabled = true ;
@ -64,7 +65,6 @@ export class UserPreferenceComponent implements OnInit {
this . selectedCountry = this . user . streamingCountry ;
this . selectedCountry = this . user . streamingCountry ;
this . setProfileImageUrl ( this . user ) ;
this . setProfileImageUrl ( this . user ) ;
this . identityService . getSupportedStreamingCountries ( ) . subscribe ( x = > this . countries = x ) ;
this . identityService . getSupportedStreamingCountries ( ) . subscribe ( x = > this . countries = x ) ;
this . settingsService . getCustomization ( ) . subscribe ( x = > this . customizationSettings = x ) ;
this . passwordForm = this . fb . group ( {
this . passwordForm = this . fb . group ( {
password : [ null ] ,
password : [ null ] ,
@ -112,8 +112,8 @@ export class UserPreferenceComponent implements OnInit {
}
}
private getFallbackProfileImageUrl() {
private getFallbackProfileImageUrl() {
return this . customizationSettings? . logo
return this . logo
? this . customizationSettings. logo
? this . logo
: "https://raw.githubusercontent.com/Ombi-app/Ombi/gh-pages/img/android-chrome-512x512.png" ;
: "https://raw.githubusercontent.com/Ombi-app/Ombi/gh-pages/img/android-chrome-512x512.png" ;
}
}