From a8f9640f68dd0b654a5411825560e642bf4b28e7 Mon Sep 17 00:00:00 2001 From: umasoodch Date: Sun, 26 Jan 2020 17:54:37 +0300 Subject: [PATCH] added remaining services for dashboard --- .../accrual-balances/home/home.component.ts | 20 ++--- .../dashbored/OpenMissingSwipesList.ts | 12 +-- .../services/dashbored/dashbored.service.ts | 28 +++---- .../models/GetOpenNotificationsList.ts | 17 ++-- .../dashbored/open-missing-swipes.response.ts | 8 +- .../stats-button/stats-button.component.scss | 2 +- Mohem/src/app/home/home.page.ts | 78 ++++++++++++++----- 7 files changed, 99 insertions(+), 66 deletions(-) diff --git a/Mohem/src/app/accrual-balances/home/home.component.ts b/Mohem/src/app/accrual-balances/home/home.component.ts index be5ffba5..d26f4574 100644 --- a/Mohem/src/app/accrual-balances/home/home.component.ts +++ b/Mohem/src/app/accrual-balances/home/home.component.ts @@ -1,13 +1,13 @@ -import { Component, OnInit } from "@angular/core"; -import { CommonService } from "src/app/hmg-common/services/common/common.service"; -import { TranslatorService } from "src/app/hmg-common/services/translator/translator.service"; -import { AuthenticationService } from "src/app/hmg-common/services/authentication/authentication.service"; -import { AccrualService } from "../services/accrual.service"; -import { AuthenticatedUser } from "src/app/hmg-common/services/authentication/models/authenticated-user"; +import { Component, OnInit } from '@angular/core'; +import { CommonService } from 'src/app/hmg-common/services/common/common.service'; +import { TranslatorService } from 'src/app/hmg-common/services/translator/translator.service'; +import { AuthenticationService } from 'src/app/hmg-common/services/authentication/authentication.service'; +import { AccrualService } from '../services/accrual.service'; +import { AuthenticatedUser } from 'src/app/hmg-common/services/authentication/models/authenticated-user'; @Component({ - selector: "app-home", - templateUrl: "./home.component.html", - styleUrls: ["./home.component.scss"] + selector: 'app-home', + templateUrl: './home.component.html', + styleUrls: ['./home.component.scss'] }) export class HomeComponent implements OnInit { Sdate: any; @@ -39,7 +39,7 @@ export class HomeComponent implements OnInit { let day = today.getDate(); let month = today.getMonth() + 1; let year = today.getFullYear(); - let todayDate = month + "/" + day + "/" + year; + let todayDate = month + '/' + day + '/' + year; let effectiveDate = todayDate; const request = { P_SELECTED_EMPLOYEE_NUMBER: this.emp_no, diff --git a/Mohem/src/app/hmg-common/services/dashbored/OpenMissingSwipesList.ts b/Mohem/src/app/hmg-common/services/dashbored/OpenMissingSwipesList.ts index 8b433128..33afe932 100644 --- a/Mohem/src/app/hmg-common/services/dashbored/OpenMissingSwipesList.ts +++ b/Mohem/src/app/hmg-common/services/dashbored/OpenMissingSwipesList.ts @@ -1,9 +1,5 @@ - - -export class OpenMissingSwipesList{ - public OPEN_MISSING_SWIPES :number; - public RETURN_STATUS : string; - public RETURN_MSG : string; - +export class OpenMissingSwipesList { + public P_OPEN_MISSING_SWIPES: number; + public P_RETURN_STATUS: string; + public P_RETURN_MSG: string; } - \ No newline at end of file diff --git a/Mohem/src/app/hmg-common/services/dashbored/dashbored.service.ts b/Mohem/src/app/hmg-common/services/dashbored/dashbored.service.ts index deeffdad..21fc550f 100644 --- a/Mohem/src/app/hmg-common/services/dashbored/dashbored.service.ts +++ b/Mohem/src/app/hmg-common/services/dashbored/dashbored.service.ts @@ -1,8 +1,8 @@ import { Injectable } from '@angular/core'; -import { AuthenticationService } from "src/app/hmg-common/services/authentication/authentication.service"; -import { ConnectorService } from "src/app/hmg-common/services/connector/connector.service"; +import { AuthenticationService } from 'src/app/hmg-common/services/authentication/authentication.service'; +import { ConnectorService } from 'src/app/hmg-common/services/connector/connector.service'; import { Observable } from 'rxjs'; -import { Request } from "src/app/hmg-common/services/models/request"; +import { Request } from 'src/app/hmg-common/services/models/request'; import { OrganizationSalariesResponse } from './organization-salaries.response'; import { OpenMissingSwipesResponse } from './open-missing-swipes.response'; import { PerformanceAppraisalResponse } from './performance-appraisal.response'; @@ -19,10 +19,10 @@ import {GetOpenNotificationsResponse} from './models/GetOpenNotificationsRespons providedIn: 'root' }) export class DashboredService { - public static organizationSalariesUrl="Services/ERP.svc/REST/GET_ORGANIZATIONS_SALARIES" - public static openmissingswipesUrl="Services/ERP.svc/REST/GET_OPEN_MISSING_SWIPES" - public static performanceappraisalUrl="Services/ERP.svc/REST/GET_Performance_Appraisal" - public static attendancetrackingUrl="Services/ERP.svc/REST/GET_Attendance_Tracking" + public static organizationSalariesUrl = 'Services/ERP.svc/REST/GET_ORGANIZATIONS_SALARIES'; + public static openMissingSwipesUrl = 'Services/ERP.svc/REST/GET_OPEN_MISSING_SWIPES'; + public static performanceappraisalUrl = 'Services/ERP.svc/REST/GET_Performance_Appraisal'; + public static attendancetrackingUrl = 'Services/ERP.svc/REST/GET_Attendance_Tracking'; public static getOpenPeriodDates = 'Services/ERP.svc/REST/GET_OPEN_PERIOD_DATES'; public static getOpenNotifications = 'Services/ERP.svc/REST/GET_OPEN_NOTIFICATIONS'; @@ -34,7 +34,7 @@ export class DashboredService { public authService: AuthenticationService, ) { } - public getOrganizationSalaries(onError ?:any ,oerrorLable ?:any):Observable{ + public getOrganizationSalaries(onError ?: any ,oerrorLable ?: any): Observable{ const request = new Request(); this.authService.authenticateRequest(request); return this.con.post( @@ -44,11 +44,11 @@ export class DashboredService { oerrorLable );} - public getOpenMissingSwipes(onError ?:any ,oerrorLable ?:any):Observable{ + public getOpenMissingSwipes(onError ?: any, oerrorLable ?: any): Observable { const request = new Request(); this.authService.authenticateRequest(request); return this.con.post( - DashboredService.openmissingswipesUrl, + DashboredService.openMissingSwipesUrl, request, onError, oerrorLable @@ -56,7 +56,7 @@ export class DashboredService { } - public getPerformanceAppraisal(onError ?:any ,oerrorLable ?:any):Observable{ + public getPerformanceAppraisal(onError ?: any ,oerrorLable ?: any): Observable{ const request = new Request(); this.authService.authenticateRequest(request); return this.con.post( @@ -66,7 +66,7 @@ export class DashboredService { oerrorLable ); } -public getAttendanceTracking(onError ?:any ,oerrorLable ?:any):Observable{ +public getAttendanceTracking(onError ?: any ,oerrorLable ?: any): Observable{ const request = new Request(); this.authService.authenticateRequest(request); return this.con.post( @@ -86,11 +86,11 @@ public getAttendanceTracking(onError ?:any ,oerrorLable ?:any):Observable { + public getSubordinatesLeaves( req: GetSubordinatesLeavesRequest,onError?: any, errorLabel?: string): Observable { this.authService.authenticateRequest(req); return this.con.post(DashboredService.getSubordinatesLeaves, req, onError, errorLabel); } - public getSubordinatesAttStatus( req:GetSubordinatesAttdStatusRequest, onError?: any, errorLabel?: string): Observable { + public getSubordinatesAttStatus( req: GetSubordinatesAttdStatusRequest, onError?: any, errorLabel?: string): Observable { this.authService.authenticateRequest(req); return this.con.post(DashboredService.getSubordinatesAttStatus, req, onError, errorLabel); } diff --git a/Mohem/src/app/hmg-common/services/dashbored/models/GetOpenNotificationsList.ts b/Mohem/src/app/hmg-common/services/dashbored/models/GetOpenNotificationsList.ts index baef1032..e2730ac6 100644 --- a/Mohem/src/app/hmg-common/services/dashbored/models/GetOpenNotificationsList.ts +++ b/Mohem/src/app/hmg-common/services/dashbored/models/GetOpenNotificationsList.ts @@ -1,11 +1,6 @@ -export class GetOpenNotificationsList - -{ -public ITEM_TYPE: number; - -public ITEM_TYPE_DISPLAY_NAME:number; - -public OPEN_NTF_NUMBER:number; - - -} \ No newline at end of file +export class GetOpenNotificationsList { + public ITEM_TYPE: number; + public ITEM_TYPE_DISPLAY_NAME: number; + public OPEN_NTF_NUMBER: number; + public P_OPEN_NTF_NUMBER: number; +} diff --git a/Mohem/src/app/hmg-common/services/dashbored/open-missing-swipes.response.ts b/Mohem/src/app/hmg-common/services/dashbored/open-missing-swipes.response.ts index 63945935..8fd977a1 100644 --- a/Mohem/src/app/hmg-common/services/dashbored/open-missing-swipes.response.ts +++ b/Mohem/src/app/hmg-common/services/dashbored/open-missing-swipes.response.ts @@ -2,7 +2,7 @@ import { Response } from "src/app/hmg-common/services/models/response"; import { OpenMissingSwipesList } from './OpenMissingSwipesList'; - - export class OpenMissingSwipesResponse extends Response{ -public GetGetOpenMissingSwipesList : OpenMissingSwipesList[]; - } \ No newline at end of file + +export class OpenMissingSwipesResponse extends Response{ + public GetGetOpenMissingSwipesList: OpenMissingSwipesList[]; +} 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 5c7cc59c..272fad14 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: 40px; + font-size: 35px; font-weight: bold; color: black; text-align: left; diff --git a/Mohem/src/app/home/home.page.ts b/Mohem/src/app/home/home.page.ts index cf6a55cf..08a232f5 100644 --- a/Mohem/src/app/home/home.page.ts +++ b/Mohem/src/app/home/home.page.ts @@ -32,7 +32,7 @@ import {GetSubordinatesLeavesRequest} from '../hmg-common/services/dashbored/mod import {GetOpenNotificationsResponse} from '../hmg-common/services/dashbored/models/GetOpenNotificationsResponse' import {GetSubordinatesAttdStatusResponse} from '../hmg-common/services/dashbored/models/GetSubordinatesAttdStatusResponse' import {GetSubordinatesLeavesResponse} from '../hmg-common/services/dashbored/models/GetSubordinatesLeavesResponse' - +import { AccrualService } from '../accrual-balances/services/accrual.service'; @Component({ selector: 'app-home', @@ -56,27 +56,27 @@ export class HomePage implements OnInit { public statsButtons = [ { title: 'Work List', - statsValue: '79', + statsValue: 0, icon: 'assets/icon/new-design/work_list.png' }, - // { - // title: 'Pending Request', - // statsValue: '13', - // icon: 'assets/icon/new-design/pending_request.png' - // }, + { + title: 'Pending Request', + statsValue: 13, + icon: 'assets/icon/new-design/pending_request.png' + }, { title: 'Missing Swipes', - statsValue: '99', + statsValue: 0, icon: 'assets/icon/new-design/missing_swipe.png' }, { title: 'Leave Balance', // getAccrualBalance ticket balance - statsValue: '02', + statsValue: 0, icon: 'assets/icon/new-design/leave_balance.png' }, { title: 'Ticket Balance', - statsValue: '01', + statsValue: 0, icon: 'assets/icon/new-design/ticket_balance.png' } ]; @@ -137,8 +137,8 @@ export class HomePage implements OnInit { private sanitizer: DomSanitizer, private file: File, private permissions: DevicePermissionsService, - public DS: DashboredService - + public DS: DashboredService, + public accrualService: AccrualService ) { this.events.subscribe('img-change', displayImg => { this.userImage = this.sanitizer.bypassSecurityTrustUrl('data:Image/*;base64,' + displayImg); @@ -146,11 +146,18 @@ 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 => { @@ -255,7 +262,7 @@ export class HomePage implements OnInit { // } ionViewDidLoad() { - this.getUserDetails(); + // this.getUserDetails(); this.geolocation .getCurrentPosition() .then(resp => { @@ -456,6 +463,10 @@ export class HomePage implements OnInit { showOpenMissingSwipes() { this.DS.getOpenMissingSwipes() .subscribe((result: OpenMissingSwipesResponse) => { + if (this.common.validResponse(result)) { + const key = 'GetOpenMissingSwipesList'; + this.statsButtons[2].statsValue = result[key].P_OPEN_MISSING_SWIPES; + } }); } @@ -466,6 +477,9 @@ export class HomePage implements OnInit { showAttendanceTracking() { // spent hours left hours this.DS.getAttendanceTracking() .subscribe((result: AttendanceTrackingResponse) => { + if (this.common.validResponse(result)) { + console.log(result); + } }); } @@ -478,15 +492,15 @@ export class HomePage implements OnInit { } openNotificationsDashbored() { // work list - this.DS.getOpenNotifications( () => {console.log('Error '); } ).subscribe((result: GetOpenNotificationsResponse) => { + this.DS.getOpenNotifications( () => { console.log('Error '); }).subscribe((result: GetOpenNotificationsResponse) => { if (this.common.validResponse(result)) { - console.log('response'); - console.log(result); + const key = 'P_OPEN_NTF_NUMBER'; + this.statsButtons[0].statsValue = result[key]; } }); } - getSubordinatesLeaves(){ + getSubordinatesLeaves() { const request: GetSubordinatesLeavesRequest = new GetSubordinatesLeavesRequest(); request.P_DATE_FROM = '/Date(1578603600000+0300)/'; // test request.P_DATE_TO = '/Date(1576011600000+0300)/'; // test @@ -521,10 +535,38 @@ export class HomePage implements OnInit { } else if (subMenu.REQUEST_TYPE === 'EIT') { this.common.openEitListPage(); } - if (subMenu.REQUEST_TYPE === 'PAYSLIP'){ + if (subMenu.REQUEST_TYPE === 'PAYSLIP') { this.common.openPayslipPage(); } } + + getAccrualBalance() { + const today = new Date(); + const day = today.getDate(); + const month = today.getMonth() + 1; + const year = today.getFullYear(); + const todayDate = month + '/' + day + '/' + year; + const effectiveDate = todayDate; + const request = { + P_SELECTED_EMPLOYEE_NUMBER: this.userData.EMPLOYEE_NUMBER, + P_EFFECTIVE_DATE: effectiveDate + }; + this.accrualService + .getAccrualBalances(request) + .subscribe((result: any) => { + if (this.common.validResponse(result)) { + let totalTicketsLeft = 0; + for (const accrualBalance of result.GetAccrualBalancesList) { + if (accrualBalance.ACCURAL_PLAN_NAME === 'HMG Annual Vacation Accrual Plan') { + this.statsButtons[3].statsValue = accrualBalance.ACCRUAL_NET_ENTITLEMENT; + } else { + totalTicketsLeft = totalTicketsLeft + accrualBalance.ACCRUAL_NET_ENTITLEMENT; + } + } + this.statsButtons[4].statsValue = totalTicketsLeft; + } + }); + } }