import { Component, OnInit } from '@angular/core'; import { Router } from '@angular/router'; import { AnimationController, ModalController } from '@ionic/angular'; import { User } from 'src/app/models/user.model'; import { AuthService } from 'src/app/services/auth.service'; import { FingerprintPage } from 'src/app/shared/fingerprint/fingerprint.page'; import { PinPage } from 'src/app/shared/pin/pin.page'; @Component({ selector: 'app-profile', templateUrl: './profile.page.html', styleUrls: ['./profile.page.scss'], }) export class ProfileComponent implements OnInit { loggeduser: User; constructor(private modalController:ModalController, private authService: AuthService, private animationController: AnimationController, private router: Router) { this.loggeduser = authService.ValidatedUser; console.log(this.loggeduser.RoleDescription) } ngOnInit() {} close() { this.modalController.dismiss(); } async addPin() { const enterAnimation = (baseEl: any) => { const backdropAnimation = this.animationController.create() .addElement(baseEl.querySelector('ion-backdrop')!) .fromTo('opacity', '0.01', 'var(--backdrop-opacity)'); const wrapperAnimation = this.animationController.create() .addElement(baseEl.querySelector('.modal-wrapper')!) .keyframes([ { offset: 0, opacity: '1', right: '-100%' }, { offset: 1, opacity: '1', right: '0px' } ]); return this.animationController.create() .addElement(baseEl) .easing('ease-out') .duration(500) .addAnimation([backdropAnimation, wrapperAnimation]); } const leaveAnimation = (baseEl: any) => { return enterAnimation(baseEl).direction('reverse'); } const modal = await this.modalController.create({ enterAnimation, leaveAnimation, component: PinPage, cssClass: 'model profile-modal', componentProps: { } }); modal.present(); } async addFingerprint() { const enterAnimation = (baseEl: any) => { const backdropAnimation = this.animationController.create() .addElement(baseEl.querySelector('ion-backdrop')!) .fromTo('opacity', '0.01', 'var(--backdrop-opacity)'); const wrapperAnimation = this.animationController.create() .addElement(baseEl.querySelector('.modal-wrapper')!) .keyframes([ { offset: 0, opacity: '1', right: '-100%' }, { offset: 1, opacity: '1', right: '0px' } ]); return this.animationController.create() .addElement(baseEl) .easing('ease-out') .duration(500) .addAnimation([backdropAnimation, wrapperAnimation]); } const leaveAnimation = (baseEl: any) => { return enterAnimation(baseEl).direction('reverse'); } const modal = await this.modalController.create({ enterAnimation, leaveAnimation, component: FingerprintPage, cssClass: 'model profile-modal', componentProps: { } }); modal.present(); } logout() { this.router.navigate(['/']); } LoginPreferenceMethod(type: string) { let userData = JSON.parse(localStorage.getItem('UserData')) || {} if (userData.hasOwnProperty('loginPreference')) { if (userData.loginPreference != type) { if (type) { userData.loginPreference = type } } else { userData.loginPreference = 'none' } } else { userData.loginPreference = 'none' } localStorage.setItem('UserData', JSON.stringify(userData) ) } get userLoginPreference() { let userData = JSON.parse(localStorage.getItem('UserData')) || {} if (userData.hasOwnProperty('loginPreference')) { console.log( userData.loginPreference) return userData.loginPreference } else { return false } } }