import { Injectable } from '@angular/core'; import * as globals from '../core/common'; import { Http, Response, } from '@angular/http'; import { IStaffActivity } from '../core/IStaffActivity'; import { Observable } from 'rxjs'; import { map, catchError } from 'rxjs/operators'; import { SelectItem } from 'primeng/api'; import { IStaff } from '../core/IStaff'; import { IOrganisation } from '../core/IOrganisation'; import { environment } from '../../environments/environment'; @Injectable({ providedIn: 'root' }) export class StaffActivityService { //------------------- Web API URL sections --------------------- private baseUrl = globals.serverBase + ''; private getDateRangeFilterUrl = globals.serverBase + '/api/Common/GetDateRangeFilters' constructor(private _http: Http) { } getStaffActivity(id:string): Observable { let apiURL = ''; // ------------ uncomment and configure this to call api ----------- if (environment.useDummyData == false) { apiURL = this.baseUrl + ''; // return this._http.get(this.apiURL, options) // .pipe(map((response: Response) => response.json()), // catchError(this.handleError)) } //dummy data for login history var StaffActivityList:IStaffActivity[]=[]; var org1:IOrganisation={ Id: 1, CompanyName: 'Whytes Chartered Accountants', Staff:25, Type:'Internal', Country:'Australia', Email:'info@whytes.com.au', Website:'https://whytes.com.au', Phone: '+6123334', TypeId: 1, IndustryId: 1, Industry: 'Accounting', LogoUrl: "https://www.whytes.com.au/images/whytes-logo-icon-large.png", PublicProfileNote: "

public profile details

", PrivateProfileNote: "private profile details", KeyWord: "keyword 1, keyword 2", localisationId:1 } var Staff : IStaff = { Id:"1", UniqueIdentifier:"abcd", FirstName: "Des", LastName: "", Email: "", RoleName: "Partner", Company: org1} var Staff2 : IStaff = { Id:"2", UniqueIdentifier:"efgh", FirstName: "Vin", LastName: "", Email: "", RoleName: "Manager", Company: org1} //dummy login history object StaffActivityList = [ { Id:1, Staff: Staff , Type:"Contact", Client:"Perth Charted Accountants", Stage:"Presentation scheduled", Subject:"Meeting", DueDate: "Due today", module: "1", DueDateValue: new Date('2019-06-30')}, { Id:2, Staff: Staff2 , Type:"Collection", Client:"Synergy Holdings", Stage:"85% Completed", Subject:"2018 Income tax complience", DueDate: "Due today 2.30 PM", module: "2",DueDateValue: new Date('2019-06-20')}, { Id:3, Staff: Staff2 , Type:"Contact", Client:"Prominet accounting", Stage:"-", Subject:"RE: expertential Meeting on 20 March 2019 @ 2PM", DueDate: "Due Friday 3:30 PM", module: "1",DueDateValue: new Date('2019-06-21')}, { Id:4, Staff: Staff , Type:"Expertential", Client:"Magnus holding", Stage:"50% Completed", Subject:"RE: MH018 – Magnus Holding Trademark case 1054A/108", DueDate: "Due Friday", module: "3",DueDateValue: new Date('2019-06-25')}, ]; //return dummy response to Component return this._http.get(apiURL) .pipe(map((response: Response) => StaffActivityList), catchError(this.handleError)) } getDateRangeFilters():Observable{ let apiURL =''; // ------------ uncomment and configure this to call api ----------- if (environment.useDummyData == false) { return this._http.get(this.getDateRangeFilterUrl) .pipe(map((response: Response) => response.json()), catchError(this.handleError)); } //dummy data for filters var FilterList:SelectItem[]=[]; //dummy filter list object FilterList = [ {label: "Due Today" , value: "2019-06-20"}, {label: "Due in next 5 days" , value: "2019-06-25"}, {label: "Due in next 7 days" , value: "2019-06-27"}, {label: "Due in next 10 days" , value: "2019-06-30"}, {label: "Due this month" , value: "2019-07-20"}, {label: "Due next month" , value: "2019-08-20"}, ] //return dummy response to Component return this._http.get(apiURL) .pipe(map((response: Response) => FilterList), catchError(this.handleError)) } getModulesList():Observable{ let apiURL = ''; // ------------ uncomment and configure this to call api ----------- if (environment.useDummyData == false) { //apiURL = this.baseUrl + ''; // return this._http.get(this.apiURL, options) // .pipe(map((response: Response) => response.json()), // catchError(this.handleError)) } //dummy data for filters var FilterList:SelectItem[]=[]; //dummy filter list object FilterList = [ {label: "Modules:All" , value: ""}, {label: "Modules:A" , value: "1"}, {label: "Modules:B" , value: "2"}, {label: "Modules:C" , value: "3"}, ] //return dummy response to Component return this._http.get(apiURL) .pipe(map((response: Response) => FilterList), catchError(this.handleError)) } //The function of handling the error private handleError(error: Response) { console.log("Error in staff activity service"); console.log(error); return Observable.throw(error.json().error || 'Server error'); } }