// import { Component, OnInit, Inject, OnDestroy } from '@angular/core'; // import { MsalService, MsalBroadcastService, MSAL_GUARD_CONFIG, MsalGuardConfiguration } from '@azure/msal-angular'; // import { AuthenticationResult, EventMessage, EventType, InteractionType, PopupRequest, RedirectRequest } from '@azure/msal-browser'; // import { Subject } from 'rxjs'; // import { Router } from '@angular/router'; // import { filter, takeUntil } from 'rxjs/operators'; // import { Spinkit } from 'ng-http-loader'; // import { FormGroup } from '@angular/forms'; // import { FormControl } from '@angular/forms'; // import { Validators } from '@angular/forms'; // import { UserProfileService } from '../../services/user-profile/user-profile.service'; // import { data } from 'jquery'; // import { CommonService } from '../../services/common.service'; // import { UserDeatils } from '../../models/user-profile/user-profile'; // import { environment } from 'src/environments/environment'; // // import { AuthService, SocialUser, FacebookLoginProvider, GoogleLoginProvider } from 'ng-social-login-module'; // declare var FB: any; // @Component({ // selector: 'app-login', // templateUrl: './login.component.html', // styleUrls: ['./login.component.css'] // }) // export class LoginComponent implements OnInit, OnDestroy { // public spinkit = Spinkit; // isIframe = false; // loggedIn = false; // private readonly _destroying$ = new Subject(); // _paramId: number = 1; // EditMyCompanyAPIResponse: any; // signInPageImageData: String = ""; // signInPageLogoData: String = ""; // customernumber: string; // mapingCustomber: string; // UserType: string; // CSUser: string; // form = new FormGroup({ // Email: new FormControl('', [Validators.required, Validators.email]), // Password: new FormControl('', Validators.required) // }); // formModel = { // Email: '', // Password: '' // } // LoginAPIResponse: any; // // user: SocialUser; // userDetailsData = new UserDeatils(); // // public users: any = SocialUser; // response; // eloquaFormName: string = "SidingCustomerPortalLoginInformation"; // constructor( // @Inject(MSAL_GUARD_CONFIG) private msalGuardConfig: MsalGuardConfiguration, // private authService: MsalService, // private msalBroadcastService: MsalBroadcastService, private router: Router, // private service: UserProfileService, // private common: CommonService // //private authServices: SocialAuthService, // // private socialservice: AuthService // //private service: EditMyCompanyService, // ) { } // ngOnInit(): void { // // this.socialservice.authState.subscribe(user => { // // this.user = user; // // }); // // Krunal - For removing sdk.js Error From Network tab - Starts // // (window as any).fbAsyncInit = function () { // // FB.init({ // // appId: '2315982045201628', // // cookie: true, // // xfbml: true, // // version: 'v3.1' // // }); // // FB.AppEvents.logPageView(); // // }; // // (function (d, s, id) { // // var js, fjs = d.getElementsByTagName(s)[0]; // // if (d.getElementById(id)) { return; } // // js = d.createElement(s); js.id = id; // // js.src = "https://connect.facebook.net/en_US/sdk.js"; // // fjs.parentNode.insertBefore(js, fjs); // // }(document, 'script', 'facebook-jssdk')); // // Krunal - For removing sdk.js Error From Network tab - Ends // if (localStorage.getItem('token') != null) // this.router.navigate(["/dashboard/dashboard"]); // this.isIframe = window !== window.parent && !window.opener; // this.checkAccount(); // this.msalBroadcastService.msalSubject$ // .pipe( // filter((msg: EventMessage) => msg.eventType === EventType.LOGIN_SUCCESS || msg.eventType === EventType.ACQUIRE_TOKEN_SUCCESS), // takeUntil(this._destroying$) // ) // .subscribe((result) => { // this.checkAccount(); // }); // this.authService.handleRedirectObservable().subscribe({ // next: (result: AuthenticationResult) => { // if (result) { // this.authService.instance.setActiveAccount(result.account); // sessionStorage.setItem('UserRole', 'Quoting'); // sessionStorage.setItem('UserID', result.uniqueId); // sessionStorage.setItem('token', result.idToken); // sessionStorage.setItem('Email', result.account.username); // sessionStorage.setItem('CustomerNumber', this.customernumber); // sessionStorage.setItem('MapingCustomer', this.mapingCustomber); // sessionStorage.setItem('UserType', this.UserType); // sessionStorage.setItem('CSUser', this.CSUser); // this.service.LoginSSO(result.account.username, data => { // this.LoginAPIResponse = data; // sessionStorage.setItem('Email', this.LoginAPIResponse.objResponse.responseContent.Email); // sessionStorage.setItem('CustomerNumber', this.LoginAPIResponse.objResponse.responseContent.CustomerNumber); // sessionStorage.setItem('MapingCustomer', this.LoginAPIResponse.objResponse.responseContent.MapingCustomer); // sessionStorage.setItem('UserType', this.LoginAPIResponse.objResponse.responseContent.UserType); // sessionStorage.setItem('CSUser', this.LoginAPIResponse.objResponse.responseContent.CSUser); // this.router.navigate(['/dashboard/dashboard']); // }, // (error) => { // console.error('Error: ' + error); // return error(error); // }); // this.router.navigate(['/dashboard/dashboard']); // this.loggedIn = this.authService.instance.getAllAccounts().length > 0; // } // }, // error: (error) => console.log(error) // }); // if (this.loggedIn) { // this.router.navigate(['/dashboard/dashboard']); // } // } // checkAccount() { // //this.loggedIn = this.authService.instance.getAllAccounts().length > 0; // //if (this.loggedIn) { // // this.router.navigate(['/admin']); // //this.authService.handleRedirectObservable().subscribe({ // // next: (result: AuthenticationResult) => { // // if (result) { // // this.authService.instance.setActiveAccount(result.account); // // localStorage.setItem("token", ""); // // console.log(result); // // console.log(result); // // //this.router.navigate(['/admin']); // // } // // }, // // error: (error) => console.log(error) // //}); // //} // } // // public socialSignIn(socialProvider: string) { // // let socialPlatformProvider; // // if (socialProvider === 'facebook') { // // socialPlatformProvider = FacebookLoginProvider.PROVIDER_ID; // // } // // else if (socialProvider === 'google') { // // socialPlatformProvider = GoogleLoginProvider.PROVIDER_ID; // // } // // this.socialservice.signIn(socialPlatformProvider).then(user => { // // this.user = user; // // this.Savesresponse(); // // }); // // } // // Savesresponse() { // // this.service.SaveLogin(this.user, data => { // // //this.userDetailsData = data // // this.LoginAPIResponse = data; // // sessionStorage.setItem('Email', this.LoginAPIResponse.objResponse.responseContent.Email); // // sessionStorage.setItem('CustomerNumber', this.LoginAPIResponse.objResponse.responseContent.CustomerNumber); // // sessionStorage.setItem('MapingCustomer', this.LoginAPIResponse.objResponse.responseContent.MapingCustomer); // // sessionStorage.setItem('UserType', this.LoginAPIResponse.objResponse.responseContent.UserType); // // sessionStorage.setItem('CSUser', this.LoginAPIResponse.objResponse.responseContent.CSUser); // // //localStorage.setItem('socialusers', JSON.stringify(this.userDetailsData)); // // //console.log(localStorage.setItem('socialusers', JSON.stringify(this.userDetailsData))); // // this.router.navigate(['/dashboard/dashboard']); // // }, // // (error) => { // // console.error('Error: ' + error); // // return error(error); // // }); // // } // //submitLogin() { // // FB.login((response) => { // // console.log('submitLogin', response); // // if (response.authResponse) { // // this.common.showSuccess("Login Successfuly", "Success"); // // } // // else { // // this.common.showError("Invalid Email address and password", "Authentication failed."); // // } // // }); // //} // // For removing sdk.js Error From Network tab // login() { // this.loggedIn = this.authService.instance.getAllAccounts().length > 0; // if (this.msalGuardConfig.interactionType === InteractionType.Popup) { // if (this.msalGuardConfig.authRequest) { // this.authService.loginPopup({ ...this.msalGuardConfig.authRequest } as PopupRequest) // .subscribe((response: AuthenticationResult) => { // this.authService.instance.setActiveAccount(response.account); // this.checkAccount(); // }); // } else { // this.authService.loginPopup() // .subscribe((response: AuthenticationResult) => { // this.authService.instance.setActiveAccount(response.account); // this.checkAccount(); // }); // } // } else { // if (this.msalGuardConfig.authRequest) { // this.authService.loginRedirect({ ...this.msalGuardConfig.authRequest } as RedirectRequest); // } else { // this.authService.loginRedirect(); // } // } // } // logins() { // this.formModel.Password = this.common.Encrypt(this.formModel.Password); // this.service.SaveLogin(this.formModel, data => { // this.LoginAPIResponse = data; // if (this.LoginAPIResponse.objResponse.statusCode == "200") { // if (environment.production) { // this.eloquaSubmit(); // } // sessionStorage.setItem('IsDashboard', '0'); // sessionStorage.setItem('token', this.LoginAPIResponse.Token); // sessionStorage.setItem('Email', this.LoginAPIResponse.objResponse.responseContent.Email); // sessionStorage.setItem('CustomerNumber', this.LoginAPIResponse.objResponse.responseContent.CustomerNumber); // sessionStorage.setItem('MapingCustomer', this.LoginAPIResponse.objResponse.responseContent.MapingCustomer); // sessionStorage.setItem('UserType', this.LoginAPIResponse.objResponse.responseContent.UserType); // sessionStorage.setItem('CSUser', this.LoginAPIResponse.objResponse.responseContent.CSUser); // this.router.navigate(['/dashboard/dashboard']); // } // else { // this.common.showError("Invalid Email address and password", "Authentication failed."); // } // }, // (error) => { // console.error('Error: ' + error); // return error(error); // }); // } // eloquaSubmit() { // const eloquaAPIURL = environment.eloquaAPIURL + "?emailAddress=" + encodeURIComponent(this.formModel.Email) + "&elqFormName=" + encodeURIComponent(this.eloquaFormName) + "&elqSiteID=" + environment.eloquaFormSiteId; // const XHR = new XMLHttpRequest(); // XHR.addEventListener('load', (event) => { // console.log("Eloqua Form Submitted Successfully.") // }); // XHR.addEventListener('error', (event) => { // console.log("Error while submitting Eloqua form.") // }); // XHR.open('POST', eloquaAPIURL); // XHR.send(null); // } // logout() { // this.router.navigate(['http://localhost:4200/']); // } // ngOnDestroy(): void { // this._destroying$.next(null); // this._destroying$.complete(); // } // }