Files
WrenchBoardIonic2023/src/app/store/tasks-data.service.ts
T
CHIEFSOFT\ameye 49f28cf777 add kids page
2024-02-08 07:24:25 -05:00

112 lines
3.5 KiB
TypeScript

import { Injectable } from '@angular/core';
import {Router} from "@angular/router";
import {SessionDataProviderService} from "./session-data-provider.service";
import {WrenchService} from "../services/wrench.service";
import { apiConst} from "../../constants/constant";
@Injectable({
providedIn: 'root'
})
export class TasksDataService {
active_job_count:number =0;
pastdue_job_count:number =0;
review_job_count:number =0;
completed_job_count:number =0;
session_image_server:string='';
curr_session:string='';
constructor(
private router: Router,
public sessionDataProviderService: SessionDataProviderService,
private wrenchService: WrenchService
) { }
usrData: {
action:number,
member_id: number,
uid: string, sessionid: string,
limit:20,
page:0,
offset: 0,
job_mode: string,
allstatus: number
};
jobsTotalInReviewData:any;
jobsInReviewData: [];
jobsTotalPastDueData:any;
jobsPastDueData: [];
jobsTotalData:any;
jobsReportTotalData:any;
jobsData: [];
async getJobsData(){
this.usrData = {
action: apiConst.WRENCHBOARD_JOB_USERACTIVE,
member_id: this.sessionDataProviderService.member_id,
uid: this.sessionDataProviderService.member_uid,
sessionid: this.sessionDataProviderService.session ,
limit:20,
page:0,
offset:0,
job_mode: 'ACTIVE',
allstatus: 100
};
this.curr_session = this.sessionDataProviderService.session;
this.wrenchService.getMyActiveJobsData(this.usrData).subscribe(
jobsTotalData => {
this.jobsTotalData = jobsTotalData;
console.log("getMyActiveJobsData RETURN->", this.jobsTotalData);
this.session_image_server = this.jobsTotalData.session_image_server;
let AllResult = this.jobsTotalData.result_list;
if ( AllResult != null ){
this.jobsData = AllResult.filter((item) => item.status_description == 'ACTIVE')
this.jobsPastDueData =AllResult.filter((item) => item.status_description == 'PASTDUE')
this.jobsInReviewData =AllResult.filter((item) => item.status_description == 'REVIEW')
this.active_job_count = this.jobsData?.length;
this.review_job_count = this.jobsInReviewData?.length;
this.pastdue_job_count = this.jobsPastDueData?.length;
}
// debugger;
}
);
}
jobsTotalCompletedData:any;
jobsCompletedData: [];
async getJobsHistoryData(){
this.usrData = {
action: apiConst.WRENCHBOARD_JOB_REPORT,
member_id: this.sessionDataProviderService.member_id,
uid: this.sessionDataProviderService.member_uid,
sessionid: this.sessionDataProviderService.session ,
limit:20,
page:0,
offset:0,
job_mode: 'COMPLETED',
allstatus: 100
};
this.curr_session = this.sessionDataProviderService.session;
this.wrenchService.getMyJobsReportData(this.usrData).subscribe(
jobsReportTotalData => {
this.jobsReportTotalData = jobsReportTotalData;
this.session_image_server = this.jobsReportTotalData.session_image_server;
let AllResult = this.jobsReportTotalData.result_list;
this.jobsCompletedData = AllResult.filter((item) => item.status_description == 'COMPLETED')
this.completed_job_count = this.jobsCompletedData?.length;
// debugger;
}
);
}
}