import { Injectable } from '@angular/core'; import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http'; import { DailyWorkTask } from '../models/dailyworktask.model'; import { AuthService } from '../services/auth.service'; import { User } from '../models/user.model'; import { environment } from 'src/environments/environment'; import { Observable } from 'rxjs'; @Injectable({ providedIn: 'root' }) export class ProcessesService { authheader = {}; loggeduser: User; headers: HttpHeaders; constructor(private http: HttpClient, user: AuthService) { this.loggeduser = user.ValidatedUser; this.headers = new HttpHeaders(); this.headers = this.headers.set('Authorization', this.loggeduser.BasicAuthKey); } GetTasksList(processname:string, onlycount:boolean): Observable { const geturl = environment.apiURL + 'tasks/List'; let params = new HttpParams(); params = params.set("ProcessName", processname); params = params.set("OnlyCount", onlycount.toString()); let options = { headers: this.headers, params: params }; return this.http.get(`${geturl}`, options); } GetTask(serialnumber:string): Observable{ const geturl = environment.apiURL + 'Tasks/FindTask'; let params = new HttpParams(); params = params.set("serialNumber", serialnumber); let options = { headers: this.headers, params: params }; return this.http.get(`${geturl}`, options); } GetTaskParticipants(folderId:string): Observable{ const geturl = environment.apiURL + 'Processes/GetUsersInDispash'; let params = new HttpParams(); params = params.set("folderId", folderId); let options = { headers: this.headers, params: params }; return this.http.get(`${geturl}`, options); } FindTaskDocId(serialnumber:string): Observable { const geturl = environment.apiURL + 'Tasks/FindExpedienteDocId'; let params = new HttpParams(); params = params.set("serialNumber", serialnumber); let options = { headers: this.headers, params: params }; return this.http.get(`${geturl}`, options); } GetMDOficialTasks(): Observable { const geturl = environment.apiURL + 'tasks/GetMDOficialTasks'; let options = { headers: this.headers, }; return this.http.get(`${geturl}`, options); } GetMDPersonalTasks(): Observable { const geturl = environment.apiURL + 'tasks/GetMDPersonalTasks'; let options = { headers: this.headers, }; return this.http.get(`${geturl}`, options); } GetToApprovedEvents(categoryname:string, count:string): Observable { const geturl = environment.apiURL + 'Tasks/ListByCategory'; let params = new HttpParams(); params = params.set("categoryname", categoryname); params = params.set("onlyCount", count); let options = { headers: this.headers, params: params, }; return this.http.get(`${geturl}`, options); } PostTaskAction(body:any){ const geturl = environment.apiURL + 'Tasks/Complete'; let options = { headers: this.headers, }; return this.http.post(`${geturl}`, body, options).toPromise().then(res =>{ console.log(res); }); } UpdateTaskStatus(FolderId:string): Observable{ const geturl = environment.apiURL + 'Tasks/UpdateTaskStatus'; let params = new HttpParams(); params = params.set("FolderId", FolderId); let options = { headers: this.headers, params: params }; return this.http.post(`${geturl}`,'', options); } postDespatcho(body:any){ const geturl = environment.apiURL + 'Processes/CreateDispatch'; let options = { headers: this.headers, }; return this.http.post(`${geturl}`, body, options).toPromise().then(res =>{ console.log(res); }); } postParecer(body:any){ const geturl = environment.apiURL + 'Processes/CreateParecer'; let options = { headers: this.headers, }; return this.http.post(`${geturl}`, body, options).toPromise().then(res =>{ console.log(res); }); } postDeferimento(body:any){ const geturl = environment.apiURL + 'Processes/CreateDeferimento'; let options = { headers: this.headers, }; return this.http.post(`${geturl}`, body, options).toPromise().then(res =>{ console.log(res); }); } GetActionsList(){ const geturl = environment.apiURL + 'presidentialActions'; let options = { headers: this.headers, }; console.log(options); return this.http.get(`${geturl}`, options); } GetSubjectType(){ const geturl = environment.apiURL + 'ecm/SubjectType'; let options = { headers: this.headers, }; return this.http.get(`${geturl}`, options); } }