blob: 388afdba01cc51ac83e8aa733e64c24287331edf [file] [log] [blame]
Sonsino, Ofir (os0695)ff76b5e2018-07-10 15:57:37 +03001import {Injectable} from '@angular/core';
Ittay Stern6f900cc2018-08-29 17:01:32 +03002import {Observable} from 'rxjs';
Sonsino, Ofir (os0695)ff76b5e2018-07-10 15:57:37 +03003import {ServiceInfoModel} from './serviceInfo.model';
Ittay Stern6f900cc2018-08-29 17:01:32 +03004import {HttpClient, HttpHeaders} from '@angular/common/http';
Sonsino, Ofir (os0695)ff76b5e2018-07-10 15:57:37 +03005import {Constants} from '../../utils/constants';
6import {forkJoin} from "rxjs/observable/forkJoin";
Ittay Stern6f900cc2018-08-29 17:01:32 +03007import * as _ from 'lodash';
8import {AuditStatus} from "./AuditStatus.model";
Sonsino, Ofir (os0695)ff76b5e2018-07-10 15:57:37 +03009
10@Injectable()
11export class ServiceInfoService {
12 constructor(private _http: HttpClient) {
13 }
14
Eylon Malind0a3e902019-12-02 10:55:37 +020015 getServicesJobInfo(showSpinner: boolean = true, serviceModelId: string = null): Observable<ServiceInfoModel[]> {
Sonsino, Ofir (os0695)ff76b5e2018-07-10 15:57:37 +030016 let pathQuery = Constants.Path.SERVICES_JOB_INFO_PATH;
Ittay Stern6f900cc2018-08-29 17:01:32 +030017 let headers = new HttpHeaders({'x-show-spinner': showSpinner.toString()});
Eylon Malind0a3e902019-12-02 10:55:37 +020018 let params = serviceModelId ? {serviceModelId} : {};
19 return this._http.get<ServiceInfoModel[]>(pathQuery, { headers: headers, params });
Sonsino, Ofir (os0695)ff76b5e2018-07-10 15:57:37 +030020 }
21
22 deleteJob(jobId: string): Observable<any> {
23 let pathQuery = Constants.Path.SERVICES_JOB_INFO_PATH + '/job/' + jobId;
24 return this._http.delete<any>(pathQuery).map(res => res);
25 }
26
27 hideJob(jobId: string): Observable<any> {
28 let pathQuery = Constants.Path.SERVICES_JOB_INFO_PATH + '/hide/' + jobId;
29 return this._http.post<any>(pathQuery, null).map(res => res);
30 }
31
Ittay Stern6f900cc2018-08-29 17:01:32 +030032 getJobAuditStatus(jobData: ServiceInfoModel) : Observable<Object[]>{
33 let pathQueryBySource: string = Constants.Path.SERVICES_JOB_INFO_PATH + Constants.Path.SERVICES_JOB_AUDIT_PATH + '/' + jobData.jobId + '?source=';
34 let pathQueryVID: string = pathQueryBySource + 'VID';
35 let pathQueryMSO: string;
36
37 // just call it
38 if(jobData.aLaCarte) {
39 let requestParams: string[] = [];
40 pathQueryMSO = Constants.Path.SERVICES_JOB_INFO_PATH + Constants.Path.SERVICES_JOB_AUDIT_PATH + '/' + jobData.jobId + '/mso';
41 if (!_.isEmpty(jobData.requestId)) {
42 requestParams[requestParams.length] = 'requestId=' + jobData.requestId;
43 }
44 if (!_.isEmpty(jobData.serviceInstanceId)) {
45 requestParams[requestParams.length] = 'serviceInstanceId=' + jobData.serviceInstanceId;
46 }
47 if (requestParams.length > 0) {
48 pathQueryMSO += '?' + requestParams.join('&');
49 }
50 }
51 else {
52 pathQueryMSO = pathQueryBySource + 'MSO';
53 }
54
Sonsino, Ofir (os0695)ff76b5e2018-07-10 15:57:37 +030055
56 let vidObs = this._http.get(pathQueryVID);
57 let msoObs = this._http.get(pathQueryMSO);
58 return forkJoin([vidObs, msoObs]);
59 }
60
Ittay Stern6f900cc2018-08-29 17:01:32 +030061 getInstanceAuditStatus(instanceId: string, type :string) : Observable<AuditStatus[]>{
62 let pathQuery: string = Constants.Path.SERVICES_JOB_INFO_PATH + Constants.Path.SERVICES_JOB_AUDIT_PATH + '/' + type + '/' + instanceId + '/mso';
63 return this._http.get<any>(pathQuery).map(res => res);
64 }
65
66 getAuditStatusForRetry(trackById: string) : Observable<AuditStatus>{
67 let pathQuery: string = Constants.Path.AUDIT_STATUS_FOR_RETRY_PATH + '/' + trackById ;
68 return this._http.get<any>(pathQuery).map(res => res);
69 }
Sonsino, Ofir (os0695)ff76b5e2018-07-10 15:57:37 +030070}