pcb demo code.
[ealt-edge.git] / example-apps / PDD / frontend-src / src / app / ealtservice.service.ts
1 import { Injectable } from '@angular/core';
2 import { HttpClient, HttpHeaders, HttpParams, HttpResponse } from '@angular/common/http';
3 import { Observable,throwError } from 'rxjs'
4 import { timer, Subscription, pipe } from 'rxjs';
5 import { switchMap } from 'rxjs/operators';
6
7 import { delay } from 'rxjs/operators';
8
9 import { nodeDetails } from './datainterface';
10
11
12 import { retry,catchError } from 'rxjs/operators';
13 import { v4 as uuid } from 'uuid';
14
15
16
17 @Injectable({
18   providedIn: 'root'
19 })
20 export class EaltserviceService {
21
22
23   private baseUrl = 'http://159.138.139.4:30281/';
24
25   private imageUploadUrl = this.baseUrl+'uploadimageinput';
26
27   private nodes_url = './../assets/data/nodes.json';
28   private packageUploadUrl = this.baseUrl+'uploadimageinput';
29   
30   private historyIdUrl = this.baseUrl+'history/files';
31
32   private outputImageUrl = this.baseUrl
33
34   private inputImageUrl = this.baseUrl
35
36   private pcbDetectUrl = this.baseUrl
37
38   private monitorImageUrl = 'http://159.138.33.54:30092' + '/v1/inventry/image'
39
40
41   constructor(private http:HttpClient) {
42   }
43
44   httpOptions = {
45     headers: new HttpHeaders({
46       'Content-Type':'application/json'
47     })
48   }
49
50   getNodesInfoo(): Observable<nodeDetails> {
51     return this.http.get<nodeDetails>(this.nodes_url);
52   }
53
54   postHistoryId(data): Observable<Blob> {
55     return this.http.get<Blob>(this.historyIdUrl, {params: data} );
56   }
57
58   postDeploymentPackage(data): Observable<any> {
59     return this.http.post<any>(this.packageUploadUrl, data);
60   }
61
62   postInputImages(data): Observable<any> {
63     return this.http.post<any>(this.imageUploadUrl, data)
64   }
65
66   getOutputImage(): Observable<any> {
67     debugger;
68     this.outputImageUrl = this.baseUrl + 'v1/pcb/resultimage';
69     return this.http.get<any>(this.outputImageUrl);
70   }
71
72   getInputImage(data): Observable<any> {
73     debugger;
74     this.inputImageUrl = this.baseUrl + 'v1/pcb/preview/' + data;
75     // return this.http.get<any>(this.monitorImageUrl);
76     return this.http.get<any>(this.inputImageUrl);
77   }
78
79   pcbDetect(data): Observable<any> {
80     debugger;
81     this.pcbDetectUrl = this.baseUrl + 'v1/pcb/detection/' + data;
82     return this.http.get<any>(this.pcbDetectUrl);
83   }
84
85 }