import { ChangeDetectorRef , Component , Inject , OnInit , ViewChild } from '@angular/core' ; import { Router } from '@angular/router' ; import { FormGroupDirective } from '@angular/forms' ; import { NbAuthService , NbLoginComponent , NB_AUTH_OPTIONS } from '@nebular/auth' ; import { ElectronService } from 'ngx-electron' ; import { RolesEnum } from '@gauzy/contracts' ; import { environment } from './../../../environments/environment' ; @ Component ( { selector : 'ngx-login' , templateUrl : './login.component.html' , styleUrls : [ './login.component.scss' ] } ) export class NgxLoginComponent extends NbLoginComponent implements OnInit { @ ViewChild ( 'form' ) private readonly form : FormGroupDirective ; isShown : boolean = false ; RolesEnum = RolesEnum ; isDemo : boolean = environment . DEMO ; constructor ( public readonly electronService , public readonly nbAuthService , public readonly cdr , public readonly router , @ Inject ( NB_AUTH_OPTIONS ) options ) { super ( nbAuthService , options , cdr , router ) ; } ngOnInit ( ) { this . autoFillCredential ( ) ; } collapseDemo ( ) { if ( this . isDemo ) { this . isShown = ! this . isShown ; } } /**
     * Autofill Super Admin Credential By Default
     */ autoFillCredential ( ) { if ( this . isDemo ) { this . user . email = environment . DEMO_SUPER_ADMIN_EMAIL ; this . user . password = environment . DEMO_SUPER_ADMIN_PASSWORD ; } } param role autoLogin ( role ) { if ( this . isDemo ) { switch ( role ) { case RolesEnum . SUPER_ADMIN : this . autoFillCredential ( ) ; break ; case RolesEnum . ADMIN : this . user . email = environment . DEMO_ADMIN_EMAIL ; this . user . password = environment . DEMO_ADMIN_PASSWORD ; break ; case RolesEnum . EMPLOYEE : this . user . email = environment . DEMO_EMPLOYEE_EMAIL ; this . user . password = environment . DEMO_EMPLOYEE_PASSWORD ; break ; default : break ; } this . form . ngSubmit . emit ( ) ; } } }