@ -1,21 +1,25 @@
import { Component , OnInit } from "@angular/core" ;
import { Component , OnInit , Input } from "@angular/core" ;
import { Router } from "@angular/router" ;
import { Router } from "@angular/router" ;
import { PlatformLocation } from "@angular/common" ;
import { PlatformLocation } from "@angular/common" ;
import { IdentityService } from "../../services" ;
import { IdentityService } from "../../services" ;
import { NotificationService } from "../../services" ;
import { NotificationService } from "../../services" ;
import { ICreateWizardUser } from "../../interfaces" ;
@Component ( {
@Component ( {
selector : "wizard-local-admin" ,
templateUrl : "./createadmin.component.html" ,
templateUrl : "./createadmin.component.html" ,
} )
} )
export class CreateAdminComponent implements OnInit {
export class CreateAdminComponent implements OnInit {
@Input ( ) user : ICreateWizardUser ;
public username : string ;
public username : string ;
public password : string ;
public password : string ;
public baseUrl : string ;
public baseUrl : string ;
constructor ( private identityService : IdentityService , private notificationService : NotificationService ,
constructor ( private location : PlatformLocation ) { }
private router : Router , private location : PlatformLocation ) { }
public ngOnInit ( ) : void {
public ngOnInit ( ) : void {
const base = this . location . getBaseHrefFromDOM ( ) ;
const base = this . location . getBaseHrefFromDOM ( ) ;
@ -24,15 +28,4 @@ export class CreateAdminComponent implements OnInit {
}
}
}
}
public createUser() {
this . identityService . createWizardUser ( { username : this.username , password : this.password , usePlexAdminAccount : false } ) . subscribe ( x = > {
if ( x . result ) {
this . router . navigate ( [ "login" ] ) ;
} else {
if ( x . errors . length > 0 ) {
this . notificationService . error ( x . errors [ 0 ] ) ;
}
}
} ) ;
}
}
}