2021-02-18 12:44:35 +01:00
|
|
|
import { Component, OnInit } from '@angular/core';
|
2021-05-28 16:24:37 +01:00
|
|
|
import { Router } from '@angular/router';
|
2021-05-27 16:49:09 +01:00
|
|
|
import { AnimationController, ModalController } from '@ionic/angular';
|
2021-05-21 15:34:45 +01:00
|
|
|
import { User } from 'src/app/models/user.model';
|
|
|
|
|
import { AuthService } from 'src/app/services/auth.service';
|
2021-05-28 07:52:16 +01:00
|
|
|
import { FingerprintPage } from 'src/app/shared/fingerprint/fingerprint.page';
|
2021-05-27 16:49:09 +01:00
|
|
|
import { PinPage } from 'src/app/shared/pin/pin.page';
|
2021-02-18 12:44:35 +01:00
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
|
selector: 'app-profile',
|
2021-05-27 16:20:40 +01:00
|
|
|
templateUrl: './profile.page.html',
|
|
|
|
|
styleUrls: ['./profile.page.scss'],
|
2021-02-18 12:44:35 +01:00
|
|
|
})
|
|
|
|
|
export class ProfileComponent implements OnInit {
|
|
|
|
|
|
2021-05-21 15:34:45 +01:00
|
|
|
loggeduser: User;
|
|
|
|
|
|
|
|
|
|
constructor(private modalController:ModalController,
|
2021-05-27 16:49:09 +01:00
|
|
|
private authService: AuthService,
|
2021-05-28 16:24:37 +01:00
|
|
|
private animationController: AnimationController,
|
|
|
|
|
private router: Router) {
|
2021-05-27 16:49:09 +01:00
|
|
|
|
2021-05-21 15:34:45 +01:00
|
|
|
this.loggeduser = authService.ValidatedUser;
|
|
|
|
|
|
|
|
|
|
console.log(this.loggeduser.RoleDescription)
|
|
|
|
|
}
|
2021-02-18 12:44:35 +01:00
|
|
|
|
|
|
|
|
ngOnInit() {}
|
|
|
|
|
|
2021-05-27 16:49:09 +01:00
|
|
|
close() {
|
2021-02-18 12:44:35 +01:00
|
|
|
this.modalController.dismiss();
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-27 16:49:09 +01:00
|
|
|
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: {
|
|
|
|
|
}
|
|
|
|
|
});
|
2021-05-27 22:09:41 +01:00
|
|
|
|
|
|
|
|
modal.present();
|
2021-05-27 16:20:40 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2021-05-28 07:52:16 +01:00
|
|
|
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();
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-28 16:24:37 +01:00
|
|
|
logout() {
|
|
|
|
|
this.router.navigate(['/']);
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-01 11:47:09 +01:00
|
|
|
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'
|
|
|
|
|
}
|
2021-06-01 10:42:14 +01:00
|
|
|
|
2021-06-01 11:47:09 +01:00
|
|
|
localStorage.setItem('UserData', JSON.stringify(userData) )
|
|
|
|
|
}
|
2021-06-01 10:42:14 +01:00
|
|
|
|
2021-06-01 11:47:09 +01:00
|
|
|
get userLoginPreference() {
|
2021-06-01 10:42:14 +01:00
|
|
|
|
2021-06-01 11:47:09 +01:00
|
|
|
let userData = JSON.parse(localStorage.getItem('UserData')) || {}
|
2021-06-01 10:42:14 +01:00
|
|
|
|
2021-06-01 11:47:09 +01:00
|
|
|
if (userData.hasOwnProperty('loginPreference')) {
|
|
|
|
|
console.log( userData.loginPreference)
|
|
|
|
|
return userData.loginPreference
|
|
|
|
|
} else {
|
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-01 10:42:14 +01:00
|
|
|
}
|
|
|
|
|
|
2021-02-18 12:44:35 +01:00
|
|
|
}
|