From d5dfc27004a767c290bd39e59dc6ca4b535bdedb Mon Sep 17 00:00:00 2001 From: enadhilal Date: Thu, 2 Dec 2021 14:46:17 +0300 Subject: [PATCH] add service for worklist notification and STAMP --- .../services/connector/connector.service.ts | 4 +- .../service/work-list.main.service.ts | 63 +++++++++++++++++++ .../worklist-main/worklist-main.component.ts | 38 ++++++++++- .../worklist-setting.component.html | 7 ++- .../worklist-setting.component.ts | 55 +++++++--------- 5 files changed, 128 insertions(+), 39 deletions(-) diff --git a/Mohem/src/app/hmg-common/services/connector/connector.service.ts b/Mohem/src/app/hmg-common/services/connector/connector.service.ts index dc119ce4..c869c5ef 100644 --- a/Mohem/src/app/hmg-common/services/connector/connector.service.ts +++ b/Mohem/src/app/hmg-common/services/connector/connector.service.ts @@ -27,8 +27,8 @@ export class ConnectorService { public static retryTimes = 0; public static timeOut = 120 * 1000; - // public static host = 'https://uat.hmgwebservices.com/'; - public static host = 'https://hmgwebservices.com/'; + public static host = 'https://uat.hmgwebservices.com/'; + // public static host = 'https://hmgwebservices.com/'; constructor(public httpClient: HttpClient, public cs: CommonService, diff --git a/Mohem/src/app/notification/service/work-list.main.service.ts b/Mohem/src/app/notification/service/work-list.main.service.ts index a68047d4..a179e13d 100644 --- a/Mohem/src/app/notification/service/work-list.main.service.ts +++ b/Mohem/src/app/notification/service/work-list.main.service.ts @@ -30,6 +30,8 @@ export class WorklistMainService { public static getPRNotificationBody = "Services/ERP.svc/REST/GET_PR_NOTIFICATION_BODY"; public static getICNotificationBody = "Services/ERP.svc/REST/GET_ITEM_CREATION_NTF_BODY"; public static getBasicDetailNotificationBody = "Services/ERP.svc/REST/GET_BASIC_DET_NTF_BODY"; + public static getStampMSNotificationBody = "Services/ERP.svc/REST/GET_STAMP_MS_NOTIFICATION_BODY"; + public static getStampNSNotificationBody = "Services/ERP.svc/REST/GET_STAMP_NS_NOTIFICATION_BODY"; public static getAddressNotificationBody = "Services/ERP.svc/REST/GET_ADDRESS_NOTIFICATION_BODY"; public static getPOItemHistory = "Services/ERP.svc/REST/GET_PO_ITEM_HISTORY"; public static getMOItemHistory = "Services/ERP.svc/REST/GET_MO_ITEM_HISTORY"; @@ -41,6 +43,8 @@ export class WorklistMainService { public static getITGFormTaskCount = 'Services/COCWS.svc/REST/ITGGetTaskCountRequestType'; public static getITGFormTaskDetails = 'Services/COCWS.svc/REST/ITGFormsPendingTasks'; public static getITGFormDetails = 'Services/COCWS.svc/REST/ITGGetFormDetials'; + public static getWorklistNotificationURL = 'Services/ERP.svc/REST/GET_USER_ITEM_TYPES'; + public static updateWorklistNotificationURL = 'Services/ERP.svc/REST/UPDATE_USER_ITEM_TYPES'; @@ -124,6 +128,36 @@ export class WorklistMainService { ); } + public getStampMSNotificationBody( + WorkListBodyRequest: any, + onError?: any, + errorLabel?: string + ): Observable { + const request = WorkListBodyRequest; + this.authService.authenticateRequest(request); + return this.api.post( + WorklistMainService.getStampMSNotificationBody, + request, + onError, + errorLabel + ); + } + + public getStampNSNotificationBody( + WorkListBodyRequest: any, + onError?: any, + errorLabel?: string + ): Observable { + const request = WorkListBodyRequest; + this.authService.authenticateRequest(request); + return this.api.post( + WorklistMainService.getStampNSNotificationBody, + request, + onError, + errorLabel + ); + } + public getAddressNotificationBody( WorkListBodyRequest: any, onError?: any, @@ -346,4 +380,33 @@ export class WorklistMainService { } + public getWorklistNotifications( + onError?: any, + errorLabel?: string + ): Observable { + const request = new Request(); + this.authService.authenticateRequest(request); + return this.api.post( + WorklistMainService.getWorklistNotificationURL, + request, + onError, + errorLabel + ); + } + + public updateWorklistNotifications( + onError?: any, + errorLabel?: string + ): Observable { + const request = new Request(); + this.authService.authenticateRequest(request); + return this.api.post( + WorklistMainService.updateWorklistNotificationURL, + request, + onError, + errorLabel + ); + } + + } diff --git a/Mohem/src/app/notification/worklist-main/worklist-main.component.ts b/Mohem/src/app/notification/worklist-main/worklist-main.component.ts index 617e7b3d..e502ea5f 100644 --- a/Mohem/src/app/notification/worklist-main/worklist-main.component.ts +++ b/Mohem/src/app/notification/worklist-main/worklist-main.component.ts @@ -211,6 +211,8 @@ export class WorklistMainComponent implements OnInit { HomeComponent.NOTIFICATION_DATA, false ); + console.log('/////////////////////////////////////'); + console.log(this.getPassNotificationDetails); this.notificationArray = [] this.subordinatesleaveList = []; @@ -278,10 +280,30 @@ export class WorklistMainComponent implements OnInit { } else if (this.getPassNotificationDetails.REQUEST_TYPE === 'ADDRESS') { this.getAddressNotification(this.WorkListBodyObj); } else if (this.getPassNotificationDetails.REQUEST_TYPE === 'BASIC_DETAILS') { - this.getBasicDetailsNotification(this.WorkListBodyObj) + this.getBasicDetailsNotification(this.WorkListBodyObj); + } else if (this.getPassNotificationDetails.REQUEST_TYPE === 'STAMP_MS') { + this.getStampMSNotification(this.WorkListBodyObj); + } else if (this.getPassNotificationDetails.REQUEST_TYPE === 'STAMP_NS') { + this.getStampNSNotification(this.WorkListBodyObj); } } + getStampMSNotification(notificationBodyObj) { + this.worklistMainService + .getStampMSNotificationBody(notificationBodyObj) + .subscribe((result: PRNotificatonBodyResponse) => { + this.handleWorkListBodyResult(result, "STAMP_MS"); + }); + } + + getStampNSNotification(notificationBodyObj) { + this.worklistMainService + .getStampNSNotificationBody(notificationBodyObj) + .subscribe((result: PRNotificatonBodyResponse) => { + this.handleWorkListBodyResult(result, "STAMP_NS"); + }); + } + getBasicDetailsNotification(notificationBodyObj) { this.worklistMainService .getBasicDetailNotificationBody(notificationBodyObj) @@ -382,6 +404,20 @@ export class WorklistMainComponent implements OnInit { console.log(result); } } + else if (Type === "STAMP_MS"){ + if (result.GetBasicDetNtfBodyList) { + this.notificationBodyRes = + result.GetStampMsNotificationBodyList; + console.log(result); + } + } + else if (Type === "STAMP_NS"){ + if (result.GetBasicDetNtfBodyList) { + this.notificationBodyRes = + result.GetStampNsNotificationBodyList; + console.log(result); + } + } } } //End handleWorkListBodyResult diff --git a/Mohem/src/app/notification/worklist-setting/worklist-setting.component.html b/Mohem/src/app/notification/worklist-setting/worklist-setting.component.html index 93b94944..f7faf500 100644 --- a/Mohem/src/app/notification/worklist-setting/worklist-setting.component.html +++ b/Mohem/src/app/notification/worklist-setting/worklist-setting.component.html @@ -18,10 +18,11 @@ -

{{data.nameEn}}

-

{{data.nameAr}}

+

{{data.ITEM_TYPE}}

- + +     +

diff --git a/Mohem/src/app/notification/worklist-setting/worklist-setting.component.ts b/Mohem/src/app/notification/worklist-setting/worklist-setting.component.ts index a29fc5a1..07357490 100644 --- a/Mohem/src/app/notification/worklist-setting/worklist-setting.component.ts +++ b/Mohem/src/app/notification/worklist-setting/worklist-setting.component.ts @@ -1,6 +1,8 @@ import { Component, OnInit } from '@angular/core'; import { ModalController } from '@ionic/angular'; +import { CommonService } from 'src/app/hmg-common/services/common/common.service'; import { TranslatorService } from 'src/app/hmg-common/services/translator/translator.service'; +import { WorklistMainService } from '../service/work-list.main.service'; @Component({ selector: 'app-worklist-setting', @@ -9,45 +11,32 @@ import { TranslatorService } from 'src/app/hmg-common/services/translator/transl }) export class WorklistSettingComponent implements OnInit { - notificationList = [ - { - id: 0, - nameEn: "Human Resource (HR)", - nameAr: "الموارد البشرية (HR)", - isChecked: false - }, - { - id: 1, - nameEn: "Purchase Order (PO)", - nameAr: "امر شراء (PO)", - isChecked: false - }, - { - id: 2, - nameEn: "Purchase Requesr (PR)", - nameAr: "طلب شراء (PR)", - isChecked: false - }, - { - id: 3, - nameEn: "Move Request (MR)", - nameAr: "طلب نقل (MR)", - isChecked: false - }, - { - id: 4, - nameEn: "Item Creation (IC)", - nameAr: "انشاء عنصر (IC)", - isChecked: false - } - ]; + notificationList = []; public direction: string; - constructor(public modalController: ModalController, public ts: TranslatorService) { } + constructor( + public modalController: ModalController, + public ts: TranslatorService, + public common: CommonService, + public workListService: WorklistMainService,) { } + + ionViewWillEnter() { + this.workListService.getWorklistNotifications() + .subscribe((result: any) => { + result.GetUserItemTypesList.forEach(element => { + this.notificationList.push(element); + }); + }); + } ngOnInit() { this.direction = TranslatorService.getCurrentDirection(); + // list.forEach(element => { + // this.notificationList.push(element); + // }); + // console.log(this.notificationList); + }