You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
195 lines
6.7 KiB
TypeScript
195 lines
6.7 KiB
TypeScript
import { Component, OnInit, ViewChild } 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 { WorkListRequest } from "../models/workListRequest";
|
|
import * as moment from "moment";
|
|
import { WorKListResponse } from "../models/workListResponse";
|
|
import { WorklistService } from "../service/worklist.service";
|
|
import { IonInfiniteScroll } from '@ionic/angular';
|
|
|
|
@Component({
|
|
selector: "app-home",
|
|
templateUrl: "./home.component.html",
|
|
styleUrls: ["./home.component.scss"]
|
|
})
|
|
export class HomeComponent implements OnInit {
|
|
// @ViewChild(Navbar) navBar: Navbar;
|
|
public static NOTIFICATION_DATA='notification_data';
|
|
public static NOTIFICATION_ARR='notification_arr';
|
|
@ViewChild(IonInfiniteScroll) infiniteScroll: IonInfiniteScroll;
|
|
private WorkListObj: WorkListRequest;
|
|
WorkListResObj: any; //WorKListResponse;
|
|
notificationType: string = "1";
|
|
pageNum: number = 1;
|
|
rowsNo: number;
|
|
noOfrows: number;
|
|
selectedValue: string = "";
|
|
FromUserName: string = "";
|
|
ItemKeyDisplayName: string = "";
|
|
SentDate: string = "";
|
|
Subject: string = "";
|
|
inputSearch: string = "";
|
|
HideDateInput: boolean = false;
|
|
HideTextInput: boolean = false;
|
|
InputDate: string;
|
|
IsReachEnd: boolean = false;
|
|
public direction = 'ltr';
|
|
constructor(
|
|
public common: CommonService,
|
|
public ts: TranslatorService,
|
|
public WorklistService: WorklistService
|
|
) {
|
|
this.WorkListObj = new WorkListRequest();
|
|
this.WorkListObj.P_NOTIFICATION_TYPE = "1";
|
|
this.WorkListObj.P_SEARCH_FROM_USER = "";
|
|
this.WorkListObj.P_SEARCH_SUBJECT = "";
|
|
this.WorkListObj.P_SEARCH_SENT_DATE = "";
|
|
this.WorkListObj.P_SEARCH_ITEM_TYPE_DSP_NAME = "";
|
|
this.WorkListObj.P_PAGE_NUM = 0;
|
|
this.WorkListObj.P_PAGE_LIMIT = 50; //number
|
|
}
|
|
|
|
ngOnInit() {
|
|
this.direction = TranslatorService.getCurrentDirection();
|
|
}
|
|
ionViewDidLoad() {
|
|
// this.navBar.backButtonClick = () => {
|
|
// // you can set a full custom history here if you want
|
|
// let pages = [
|
|
// {
|
|
// page: "HomePage"
|
|
// }
|
|
// ];
|
|
// this.navCtrl.setPages(pages);
|
|
// };
|
|
}
|
|
|
|
ionViewWillEnter() {
|
|
this.getAllPushNotificationFun();
|
|
}
|
|
getValueSelected(Value) {
|
|
this.selectedValue = Value.detail.value;
|
|
if (this.selectedValue == "1") {
|
|
this.HideDateInput = false;
|
|
this.HideTextInput = true;
|
|
} else if (this.selectedValue == "2") {
|
|
this.HideDateInput = false;
|
|
this.HideTextInput = true;
|
|
} else if (this.selectedValue == "3") {
|
|
this.HideDateInput = true;
|
|
this.HideTextInput = false;
|
|
} else if (this.selectedValue == "4") {
|
|
this.HideDateInput = false;
|
|
this.HideTextInput = true;
|
|
} else if (this.selectedValue == "5") {
|
|
this.HideDateInput = false;
|
|
this.HideTextInput = false;
|
|
}
|
|
}
|
|
|
|
getAllPushNotificationFun() {
|
|
this.WorkListObj.P_PAGE_NUM = 1;
|
|
this.IsReachEnd = false;
|
|
|
|
if (this.selectedValue == "1") {
|
|
this.WorkListObj.P_SEARCH_FROM_USER = this.inputSearch;
|
|
this.WorkListObj.P_SEARCH_ITEM_TYPE_DSP_NAME = "";
|
|
this.WorkListObj.P_SEARCH_SENT_DATE = "";
|
|
this.WorkListObj.P_SEARCH_SUBJECT = "";
|
|
} else if (this.selectedValue == "2") {
|
|
this.WorkListObj.P_SEARCH_FROM_USER = "";
|
|
this.WorkListObj.P_SEARCH_ITEM_TYPE_DSP_NAME = "";
|
|
this.WorkListObj.P_SEARCH_SENT_DATE = "";
|
|
this.WorkListObj.P_SEARCH_SUBJECT = this.inputSearch;
|
|
} else if (this.selectedValue == "3") {
|
|
this.WorkListObj.P_SEARCH_FROM_USER = "";
|
|
this.WorkListObj.P_SEARCH_ITEM_TYPE_DSP_NAME = "";
|
|
if (this.InputDate)
|
|
this.WorkListObj.P_SEARCH_SENT_DATE = moment(this.InputDate).format(
|
|
"DD-MMM-YYYY"
|
|
);
|
|
else this.WorkListObj.P_SEARCH_SENT_DATE = "";
|
|
this.WorkListObj.P_SEARCH_SUBJECT = "";
|
|
} else if (this.selectedValue == "4") {
|
|
this.WorkListObj.P_SEARCH_FROM_USER = "";
|
|
this.WorkListObj.P_SEARCH_ITEM_TYPE_DSP_NAME = this.inputSearch;
|
|
this.WorkListObj.P_SEARCH_SENT_DATE = "";
|
|
this.WorkListObj.P_SEARCH_SUBJECT = "";
|
|
} else if (this.selectedValue == "5") {
|
|
this.WorkListObj.P_SEARCH_FROM_USER = "";
|
|
this.WorkListObj.P_SEARCH_ITEM_TYPE_DSP_NAME = "";
|
|
this.WorkListObj.P_SEARCH_SENT_DATE = "";
|
|
this.WorkListObj.P_SEARCH_SUBJECT = "";
|
|
}
|
|
|
|
this.WorklistService.getWorkList(this.WorkListObj).subscribe(
|
|
(result: WorKListResponse) => {
|
|
this.handleWorkListResult(result);
|
|
}
|
|
);
|
|
} //End getNotifications
|
|
|
|
private handleWorkListResult(result) {
|
|
if (this.common.validResponse(result)) {
|
|
// this.sharedData.setSharedData(result, WorKListResponse.SHARED_DATA);
|
|
if (this.common.hasData(result.GetWorkList)) {
|
|
this.WorkListObj.P_PAGE_NUM++;
|
|
this.WorkListResObj = result.GetWorkList;
|
|
this.common.sharedService.setSharedData(this.WorkListResObj, HomeComponent.NOTIFICATION_ARR);
|
|
let lastItemIndex = this.WorkListResObj.length - 1;
|
|
if (result.GetWorkList[lastItemIndex]) {
|
|
let lastitem = result.GetWorkList[lastItemIndex];
|
|
if (lastitem.NO_OF_ROWS == lastitem.ROW_NUM) {
|
|
this.IsReachEnd = true;
|
|
} else {
|
|
this.IsReachEnd = false;
|
|
}
|
|
// this.navCtrl.push('SmsAuthenticatePage');
|
|
}
|
|
} else {
|
|
this.WorkListResObj = [];
|
|
}
|
|
}
|
|
}
|
|
|
|
openNotificationDetail(obj) {
|
|
this.common.sharedService.setSharedData(obj, HomeComponent.NOTIFICATION_DATA);
|
|
this.common.openWorklistMainPage();
|
|
//this.navCtrl.push("WorkListMainPage", { passNotificationList: obj });
|
|
}
|
|
onChangeView(selectedValue: any) {
|
|
this.WorkListObj.P_NOTIFICATION_TYPE = selectedValue.detail.value;
|
|
}
|
|
|
|
doInfinite(infiniteScroll) {
|
|
//this.pageNum= this.pageNum + 1;
|
|
|
|
if (!this.IsReachEnd) {
|
|
this.WorklistService.getWorkList(this.WorkListObj).subscribe(
|
|
(result: any) => {
|
|
if (this.common.validResponse(result)) {
|
|
this.WorkListObj.P_PAGE_NUM++;
|
|
if (this.common.hasData(result.GetWorkList)) {
|
|
result.GetWorkList.forEach(element => {
|
|
if (element.ROW_NUM == element.NO_OF_ROWS) {
|
|
this.IsReachEnd = true;
|
|
} else {
|
|
this.IsReachEnd = false;
|
|
}
|
|
this.WorkListResObj.push(element);
|
|
});
|
|
} // if list length >0
|
|
else {
|
|
this.IsReachEnd = true;
|
|
}
|
|
} // if response == 1
|
|
//this.pageNum++;
|
|
this.infiniteScroll.complete();
|
|
}
|
|
);
|
|
} else {
|
|
if (this.infiniteScroll) this.infiniteScroll.complete();
|
|
}
|
|
} //end infiniteScroll
|
|
}
|