From d1fbd343307fa1fd5b266c15d17ab868171e507f Mon Sep 17 00:00:00 2001 From: umasoodch Date: Mon, 27 Jan 2020 16:36:14 +0300 Subject: [PATCH] added logic for attendance --- .../dashbored/AttensanceTrackingList.ts | 15 +++-- .../dashbored/attendance-tracking.response.ts | 10 +-- .../stats-button/stats-button.component.scss | 2 +- Mohem/src/app/home/home.page.html | 12 ++-- Mohem/src/app/home/home.page.scss | 44 ++++++++++++- Mohem/src/app/home/home.page.ts | 66 ++++++++++++------- 6 files changed, 107 insertions(+), 42 deletions(-) diff --git a/Mohem/src/app/hmg-common/services/dashbored/AttensanceTrackingList.ts b/Mohem/src/app/hmg-common/services/dashbored/AttensanceTrackingList.ts index e4b22244..b5083234 100644 --- a/Mohem/src/app/hmg-common/services/dashbored/AttensanceTrackingList.ts +++ b/Mohem/src/app/hmg-common/services/dashbored/AttensanceTrackingList.ts @@ -1,9 +1,10 @@ -export class AttendanceTrackingList{ - public SCHEDULED_HOURS :string; - public SPENT_HOURS : string; - public REMAINING_HOURS : string; - public RETURN_STATUS : string; - public RETURN_MSG : string; -} \ No newline at end of file +export class AttendanceTrackingList { + public P_REMAINING_HOURS: string; + public P_RETURN_MSG: string; + public P_RETURN_STATUS: string; + public P_SCHEDULED_HOURS: string; + public P_SHT_NAME: string; + public P_SPENT_HOURS: string; +} diff --git a/Mohem/src/app/hmg-common/services/dashbored/attendance-tracking.response.ts b/Mohem/src/app/hmg-common/services/dashbored/attendance-tracking.response.ts index 82ec2ae0..dd6ff457 100644 --- a/Mohem/src/app/hmg-common/services/dashbored/attendance-tracking.response.ts +++ b/Mohem/src/app/hmg-common/services/dashbored/attendance-tracking.response.ts @@ -1,8 +1,8 @@ -import { Response } from "src/app/hmg-common/services/models/response"; +import { Response } from 'src/app/hmg-common/services/models/response'; import { AttendanceTrackingList } from './AttensanceTrackingList'; - - export class AttendanceTrackingResponse extends Response{ - public GetGetAttendanceTrackingList : AttendanceTrackingList[]; - } \ No newline at end of file + +export class AttendanceTrackingResponse extends Response { + public GetGetAttendanceTrackingList: AttendanceTrackingList[]; + } diff --git a/Mohem/src/app/hmg-common/ui/stats-button/stats-button.component.scss b/Mohem/src/app/hmg-common/ui/stats-button/stats-button.component.scss index 272fad14..d2cfa8ae 100644 --- a/Mohem/src/app/hmg-common/ui/stats-button/stats-button.component.scss +++ b/Mohem/src/app/hmg-common/ui/stats-button/stats-button.component.scss @@ -24,7 +24,7 @@ .titleBox { display: block; span { - font-size: 35px; + font-size: 30px; font-weight: bold; color: black; text-align: left; diff --git a/Mohem/src/app/home/home.page.html b/Mohem/src/app/home/home.page.html index 603de802..f587bb81 100644 --- a/Mohem/src/app/home/home.page.html +++ b/Mohem/src/app/home/home.page.html @@ -2,7 +2,9 @@ DASHBOARD - +
+ +
@@ -139,7 +141,7 @@ --> -
+
Time Left Today - +
+
+ + Monthly Attendance
- diff --git a/Mohem/src/app/home/home.page.scss b/Mohem/src/app/home/home.page.scss index be31b62d..118eda9d 100644 --- a/Mohem/src/app/home/home.page.scss +++ b/Mohem/src/app/home/home.page.scss @@ -6,6 +6,18 @@ ion-row { .header-toolbar-new{ --background: #22c6b3; } +.profile-image-container{ + position: relative; + z-index: 999; + img { + width: 32px; + float: right; + margin-top: -42px; + border-radius: 20px; + height: 32px; + margin-right: 4px; + } +} ion-title{ color: white; position: absolute; @@ -98,6 +110,36 @@ ion-label{ width: 80%; text-align: center; font-size: 11px; - text-transform: uppercase;; + text-transform: uppercase; + } +} + +.attendance-timer { + position: fixed; + bottom: 20px; + right: 20px; + z-index: 2; + height: 112px; + width: 112px; + background-color: #094875; + border-radius: 50%; + display: inline-block; + img { + position: absolute; + left: 33%; + top: 8%; + width: 35%; + } + span { + position: absolute; + left: 50%; + top: 70%; + -webkit-transform: translate(-50%, -50%); + transform: translate(-50%, -50%); + color: white; + width: 80%; + text-align: center; + font-size: 11px; + text-transform: uppercase; } } diff --git a/Mohem/src/app/home/home.page.ts b/Mohem/src/app/home/home.page.ts index 08a232f5..fedf18e7 100644 --- a/Mohem/src/app/home/home.page.ts +++ b/Mohem/src/app/home/home.page.ts @@ -70,7 +70,7 @@ export class HomePage implements OnInit { icon: 'assets/icon/new-design/missing_swipe.png' }, { - title: 'Leave Balance', // getAccrualBalance ticket balance + title: 'Leave Balance', statsValue: 0, icon: 'assets/icon/new-design/leave_balance.png' }, @@ -108,15 +108,15 @@ export class HomePage implements OnInit { slidesPerView: 3.2, spaceBetween: 10 }; - public timeInSeconds: any = 0.15 * 60 * 60; - public time: any; public runTimer = false; public hasStarted = false; public hasFinished = false; public remainingTime: any; + public scheduledTime: any; + public isCheckedIn: any; public displayTime: any; public menuEntries: any; - public percent: any = 100 - ((this.timeInSeconds / 32400) * 100); + public percent: any; constructor( public ts: TranslatorService, @@ -146,18 +146,8 @@ export class HomePage implements OnInit { }); } - ionViewWillEnter() { - this.getAccrualBalance(); - } - ngOnInit() { this.getUserDetails(); - this.getMenu(); - this.setServicesPrivilage(); - this.initTimer(); - this.openNotificationsDashbored(); - this.showOpenMissingSwipes(); - this.showAttendanceTracking(); // this.getCount(); // this.events.subscribe('getNotCount', badge => { @@ -166,11 +156,10 @@ export class HomePage implements OnInit { } initTimer() { - this.time = this.timeInSeconds; this.runTimer = false; this.hasStarted = false; this.hasFinished = false; - this.remainingTime = this.timeInSeconds; + this.percent = 100 - ((this.remainingTime / this.scheduledTime) * 100); this.displayTime = this.getSecondsAsDigitalClock(this.remainingTime); this.startTimer(); } @@ -187,7 +176,7 @@ export class HomePage implements OnInit { this.remainingTime--; this.displayTime = this.getSecondsAsDigitalClock(this.remainingTime); if (this.remainingTime > 0) { - const newPercent: any = ((this.remainingTime / 32400) * 100).toFixed(2); + const newPercent: any = ((this.remainingTime / this.scheduledTime) * 100).toFixed(2); this.percent = 100 - newPercent; this.timerTick(); } else { @@ -262,7 +251,6 @@ export class HomePage implements OnInit { // } ionViewDidLoad() { - // this.getUserDetails(); this.geolocation .getCurrentPosition() .then(resp => { @@ -279,24 +267,31 @@ export class HomePage implements OnInit { } private getUserDetails() { + this.authService .loadAuthenticatedUser() .subscribe((user: AuthenticatedUser) => { if (user) { this.events.publish('setMenu'); this.userData = user; - // set User Info this.sharedData.setSharedData(this.userData, AuthenticatedUser.SHARED_DATA); - this.userImage = user.EMPLOYEE_IMAGE - ? 'data:image/png;base64,' + user.EMPLOYEE_IMAGE - : this.userImage; - console.log(user); + this.userImage = user.EMPLOYEE_IMAGE ? 'data:image/png;base64,' + user.EMPLOYEE_IMAGE : this.userImage; + this.callDashboardServices(); } else { console.log(user); } }); } + callDashboardServices() { + this.getMenu(); + this.setServicesPrivilage(); + this.openNotificationsDashbored(); + this.showOpenMissingSwipes(); + this.showAttendanceTracking(); + this.getAccrualBalance(); + } + public Vacation_Rule() { this.common.navigateForward('/vacation-rule/home'); } @@ -475,10 +470,29 @@ export class HomePage implements OnInit { }); } + convertInSeconds(time: any) { + const hours = parseInt(time[0], 10); + const minutes = parseInt(time[1], 10); + const seconds = (hours * 60 * 60) + (minutes * 60); + return seconds; + } + + convertAndAssignTime(data) { + console.log(data); + this.remainingTime = this.convertInSeconds(data.P_REMAINING_HOURS.split(':')); + this.scheduledTime = this.convertInSeconds(data.P_SCHEDULED_HOURS.split(':')); + this.isCheckedIn = this.remainingTime === this.scheduledTime ? true : false; + this.initTimer(); + console.log('remainingTime: ' + this.remainingTime); + console.log('scheduledTime: ' + this.scheduledTime); + console.log('isCheckedIn: ' + this.isCheckedIn); + } + showAttendanceTracking() { // spent hours left hours this.DS.getAttendanceTracking() .subscribe((result: AttendanceTrackingResponse) => { if (this.common.validResponse(result)) { - console.log(result); + const key = 'GetAttendanceTrackingList'; + this.convertAndAssignTime(result[key]); } }); } @@ -567,6 +581,10 @@ export class HomePage implements OnInit { } }); } + + openProfilePage() { + this.common.openProfile(); + } }