2021-07-28 09:29:14 +01:00
|
|
|
import { Component, OnInit } from '@angular/core';
|
2021-07-28 09:34:11 +01:00
|
|
|
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';
|
|
|
|
|
import { LocalstoreService } from 'src/app/store/localstore.service';
|
2021-07-28 16:27:10 +01:00
|
|
|
import { EditProfilePage } from './edit-profile/edit-profile.page';
|
2021-07-28 09:29:14 +01:00
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
|
selector: 'app-profile',
|
|
|
|
|
templateUrl: './profile.page.html',
|
|
|
|
|
styleUrls: ['./profile.page.scss'],
|
|
|
|
|
})
|
|
|
|
|
export class ProfilePage implements OnInit {
|
|
|
|
|
|
2021-07-28 09:34:11 +01:00
|
|
|
loggeduser: User;
|
|
|
|
|
userLoginPreference = ''
|
|
|
|
|
|
|
|
|
|
constructor(private modalController:ModalController,
|
|
|
|
|
private authService: AuthService,
|
|
|
|
|
private animationController: AnimationController,
|
|
|
|
|
private router: Router,
|
|
|
|
|
private localstoreService: LocalstoreService
|
|
|
|
|
) {
|
|
|
|
|
|
|
|
|
|
this.loggeduser = authService.ValidatedUser;
|
|
|
|
|
|
|
|
|
|
console.log(this.loggeduser.RoleDescription)
|
|
|
|
|
|
|
|
|
|
this.checkState()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ngOnInit() {}
|
|
|
|
|
|
|
|
|
|
close() {
|
|
|
|
|
this.modalController.dismiss();
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-28 16:27:10 +01:00
|
|
|
notImplemented(){}
|
2021-07-28 09:34:11 +01:00
|
|
|
|
2021-07-28 16:27:10 +01:00
|
|
|
logout() {
|
|
|
|
|
// clear local storage
|
|
|
|
|
window.localStorage.clear();
|
2021-07-28 09:34:11 +01:00
|
|
|
|
2021-07-28 16:27:10 +01:00
|
|
|
setTimeout(()=>{
|
|
|
|
|
window.location.pathname = '/'
|
|
|
|
|
location.reload();
|
|
|
|
|
}, 1000)
|
2021-07-28 09:34:11 +01:00
|
|
|
|
2021-07-28 16:27:10 +01:00
|
|
|
}
|
2021-07-28 09:34:11 +01:00
|
|
|
|
2021-07-28 16:27:10 +01:00
|
|
|
checkState() {
|
2021-07-28 09:34:11 +01:00
|
|
|
|
2021-07-28 16:27:10 +01:00
|
|
|
let userData = this.localstoreService.get('UserData', {})
|
|
|
|
|
|
|
|
|
|
if (userData.hasOwnProperty('loginPreference')) {
|
|
|
|
|
this.userLoginPreference = userData.loginPreference
|
|
|
|
|
} else {
|
|
|
|
|
this.userLoginPreference = ''
|
|
|
|
|
}
|
2021-07-28 09:34:11 +01:00
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-28 16:27:10 +01:00
|
|
|
async editProfile() {
|
2021-07-28 09:34:11 +01:00
|
|
|
|
|
|
|
|
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,
|
2021-07-28 16:27:10 +01:00
|
|
|
component: EditProfilePage,
|
2021-07-28 09:34:11 +01:00
|
|
|
cssClass: 'model profile-modal',
|
|
|
|
|
componentProps: {
|
|
|
|
|
}
|
|
|
|
|
});
|
2021-07-28 16:27:10 +01:00
|
|
|
return await modal.present();
|
2021-07-28 09:29:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|