From 1b2824f5c10de30045749403b34e5d9a2b649709 Mon Sep 17 00:00:00 2001 From: Sultan Khan Date: Wed, 1 Jun 2022 17:25:45 +0300 Subject: [PATCH] worklist count fixed --- Mohem/src/app/home/home.page.ts | 31 +----- .../app/notification/home/home.component.ts | 104 +++++++++++------- 2 files changed, 66 insertions(+), 69 deletions(-) diff --git a/Mohem/src/app/home/home.page.ts b/Mohem/src/app/home/home.page.ts index 0c528134..bf34dab7 100644 --- a/Mohem/src/app/home/home.page.ts +++ b/Mohem/src/app/home/home.page.ts @@ -11,7 +11,6 @@ import { Geolocation } from '@ionic-native/geolocation/ngx'; import { BarcodeScanner } from '@ionic-native/barcode-scanner/ngx'; import { Device } from '@ionic-native/device/ngx'; import { attendanceSwipeScannerRequest } from './models/attendanceSwipe.Request'; -import { COCRequest } from 'src/app/notification/models/COCRequest'; import { Response } from 'src/app/hmg-common/services/models/response'; import { AttendanceService } from './services/attendance.services'; import { LoginRequest } from '../hmg-common/services/authentication/models/login.request'; @@ -42,9 +41,7 @@ import { NFC, Ndef } from "@ionic-native/nfc/ngx" import { DigitalIdComponent } from '../authentication/digital-id/digital-id.component'; import { FirebaseX } from '@ionic-native/firebase-x/ngx'; import { BusinessCardComponent } from "src/app/authentication/business-card/business-card.component"; -import * as moment from "moment"; -import { count } from 'console'; -import { HomeComponent } from "src/app/notification/home/home.component"; + @Component({ selector: 'app-home', templateUrl: './home.page.html', @@ -372,7 +369,6 @@ export class HomePage implements OnInit { callDashboardServices() { this.getMenu(); this.setServicesPrivilage(); - var isWorklistChanged = this.common.sharedService.getSharedData(HomeComponent.COUNT_CHANGED); if (this.common.getTotalNumberOfWorklistRequest()) { this.statsButtons[1].statsValue = this.common.getTotalNumberOfWorklistRequest(); } else { @@ -678,30 +674,9 @@ export class HomePage implements OnInit { this.workListService.getITGDetails('', '', this.isPostNoLoad).subscribe((result: any) => { this.common.sharedService.setSharedData(result, MenuResponse.ITG_COUNTS); this.common.filterKeys['ITG'] = result.TotalCount; - this.statsButtons[1].statsValue = Math.floor(this.countAllNotification + result.TotalCount); + this.statsButtons[1].statsValue = + Math.floor(this.countAllNotification + result.TotalCount); this.common.sharedService.setSharedData(this.statsButtons[1].statsValue, 'total-count'); - this.getCOCNotificationCount(); - this.common.stopLoading(); - }); - } - - getCOCNotificationCount() { - const request = new COCRequest(); - request.ItgPageSize = 1; - request.ItgPageNo = 1; - request.Date = moment(new Date()).format("YYYY-MM-DD"); - - this.workListService.getCOCCount(request, '', '', this.isPostNoLoad).subscribe((result: any) => { - console.log(result); - const countResult = result.Mohemm_ITG_Pending_Task_ResponseItem; - const totalCount = countResult.escalation + countResult.waitingToClose + countResult.waitingForAcceptance + countResult.extendTATRequest; - this.common.filterKeys['COC'] = totalCount; - - - this.statsButtons[1].statsValue = Math.floor(this.statsButtons[1].statsValue + totalCount); - - this.common.sharedService.setSharedData(this.statsButtons[1].statsValue, 'total-count'); - this.common.stopLoading(); }); } diff --git a/Mohem/src/app/notification/home/home.component.ts b/Mohem/src/app/notification/home/home.component.ts index c91860a5..d1cbcbcd 100644 --- a/Mohem/src/app/notification/home/home.component.ts +++ b/Mohem/src/app/notification/home/home.component.ts @@ -12,6 +12,7 @@ import { DatePipe } from '@angular/common'; import { GetOpenNotificationsResponse } from 'src/app/hmg-common/services/dashbored/models/GetOpenNotificationsResponse'; import { DashboredService } from 'src/app/hmg-common/services/dashbored/dashbored.service'; import { MenuResponse } from 'src/app/hmg-common/services/menu/models/menu-response'; +import { COCRequest } from '../models/COCRequest'; @Component({ selector: 'app-home', @@ -224,7 +225,12 @@ export class HomeComponent implements OnInit { this.resetData(); this.direction = TranslatorService.getCurrentLanguageName(); this.worklistNotifications = this.common.sharedService.getSharedData('worklistNotifications', false); - this.openNotificationsDashboard(); + + var isWorklistChanged = this.common.sharedService.getSharedData(HomeComponent.COUNT_CHANGED); + if (isWorklistChanged) { + this.openNotificationsDashboard() + } + this.openNotificationsDashboardLocal(); } } @@ -235,28 +241,10 @@ export class HomeComponent implements OnInit { this.getAllPushNotificationFun(); } - openNotificationsDashboard() { - // if (this.countChanged) { - - // this.DS.getOpenNotifications('', '', this.isPostNoLoad).subscribe((result: GetOpenNotificationsResponse) => { - // if (this.common.validResponse(result)) { - // this.countChanged = false; - // this.worklistNotifications = result; - // this.totalRequestCount = this.worklistNotifications.P_OPEN_NTF_NUMBER; - //this.resetFiltersUI(); - // this.assignDataToFilters(); - // this.common.sharedService.setSharedData(result, 'worklistNotifications'); + openNotificationsDashboardLocal() { this.Details(); this.callWorkListServices(); - // } - // }); - // } else { - // this.totalRequestCount = this.worklistNotifications.P_OPEN_NTF_NUMBER; - // this.resetFiltersUI(); - // this.assignDataToFilters(); - // this.Details(); - // this.callWorkListServices(); - // } + } assignDataToFilters() { @@ -651,30 +639,10 @@ export class HomeComponent implements OnInit { } Details() { - // var result = this.common.sharedService.getSharedData(MenuResponse.ITG_COUNTS, false); - // if (this.countChanged) { - // this.workListService.getITGDetails('', '', this.isPostNoLoad) - // .subscribe((result: any) => { - // this.countChanged = false; - // this.ITGCount = result.TotalCount; - // // this.totalRequestCount = this.totalRequestCount + result.TotalCount; - // this.data.datasets[0].data[4] = this.ITGCount; - // this.filters[4].value = result.TotalCount; - // this.receivedITGCount = true; - // }) - // } else { - - //this.workListService.getITGDetails('', '', this.isPostNoLoad) - //.subscribe((result: any) => { this.ITGCount = this.common.filterKeys['ITG'];//result.TotalCount; - // this.totalRequestCount = this.totalRequestCount + result.TotalCount; this.data.datasets[0].data[4] = this.common.filterKeys['ITG'];//this.ITGCount; this.filters[4].value = this.common.filterKeys['ITG']; this.receivedITGCount = true; - //}); - //} - - } searchBtn() { @@ -731,4 +699,58 @@ export class HomeComponent implements OnInit { } this.openITG(ITEM, NAME); } + + openNotificationsDashboard() { + this.common.startLoading(); + this.resetFiltersUI(); + this.totalRequestCount = 0; + this.DS.getOpenNotifications('', '', false).subscribe((result: GetOpenNotificationsResponse) => { + if (this.common.validResponse(result)) { + const key = 'P_OPEN_NTF_NUMBER'; + // this.totalRequestCount = ; + this.ITGCountAllNotification(result[key]); + this.common.sharedService.setSharedData( + result, + 'worklistNotifications' + ); + + this.common.setFilterValues(result['GetOpenNotificationsList']); + const values = this.common.getFiltersData(); + this.data = values.data; + this.filters = values.filters; + + } + }); + } + ITGCountAllNotification(count) { + this.workListService.getITGDetails('', '', this.isPostNoLoad).subscribe((result: any) => { + this.common.sharedService.setSharedData(result, MenuResponse.ITG_COUNTS); + this.common.filterKeys['ITG'] = result.TotalCount; + this.totalRequestCount = Math.floor(count + result.TotalCount); + this.common.sharedService.setSharedData(this.totalRequestCount, 'total-count'); + this.getCOCNotificationCount(); + this.common.stopLoading(); + }); + } + getCOCNotificationCount() { + const request = new COCRequest(); + request.ItgPageSize = 1; + request.ItgPageNo = 1; + request.Date = moment(new Date()).format("YYYY-MM-DD"); + + this.workListService.getCOCCount(request, '', '', this.isPostNoLoad).subscribe((result: any) => { + console.log(result); + const countResult = result.Mohemm_ITG_Pending_Task_ResponseItem; + const totalCount = countResult.escalation + countResult.waitingToClose + countResult.waitingForAcceptance + countResult.extendTATRequest; + this.common.filterKeys['COC'] = totalCount; + + + this.totalRequestCount = Math.floor(this.totalRequestCount + totalCount); + + this.common.sharedService.setSharedData(this.totalRequestCount, 'total-count'); + + this.common.stopLoading(); + }); + } + }