53aaeb62f9776fbdd426f0ed8ced829293448106
[ealt-edge.git] / example-apps / ROBO / RoboUI / src / app / robo.service.ts
1 import { Injectable } from '@angular/core';
2
3 import { HttpClient, HttpHeaders, HttpParams, HttpResponse } from '@angular/common/http';
4 import { Observable,throwError } from 'rxjs'
5 import { timer, Subscription, pipe } from 'rxjs';
6
7 import { cameraData, camerainfo, cameraDetails, monitorDetails, monitorinfo, cameraID, appsPvcs, backupRestore, monitorImage } from './datainterface'
8
9
10 @Injectable({
11   providedIn: 'root'
12 })
13 export class RoboService {
14
15   private baseUrl = 'http://localhost:30091';
16   private inventoryBaseUrl = 'http://localhost:30092';
17
18   private postCameraDetailsUrl = this.inventoryBaseUrl + '/v1/monitor/cameras'
19   private cameraDetailsUrl = this.inventoryBaseUrl + '/v1/monitor/cameras'
20   private monitorDetailsUrl = this.inventoryBaseUrl + '/v1/inventry/table'
21   private monitorImageUrl = this.inventoryBaseUrl + '/v1/inventry/image'
22   private triggerObjUrl = this.inventoryBaseUrl + '/v1/monitor/cameras/'
23   private appsPvcsDetailsUrl = this.baseUrl + '/v1/robo/apps-pvcs'
24   private backupRestoreDetailsUrl = this.baseUrl + '/v1/robo/backup-restore'
25   private postBackupDetailsUrl = this.baseUrl + '/v1/robo/backup'
26   private postRestoreDetailsUrl = this.baseUrl + '/v1/robo/restore'
27   private disasterUrl = this.baseUrl + '/v1/robo/disaster'
28
29   private cameraDetails_url = './../assets/data/camera.json'
30   private backupRestoreDetails_url = './../assets/data/backuprestore.json'
31   private appsPvcsDetails_url = './../assets/data/appspvc.json'
32   private monitorDetails_url = './../assets/data/inventory.json'
33
34
35   constructor(private http:HttpClient) { }
36   
37   httpOptions = {
38     headers: new HttpHeaders({
39       'Content-Type':'application/json'
40     })
41   }
42
43   httpOptionss = {
44     headers: new HttpHeaders({
45       'Content-Type':'application/json'
46     })
47   }
48
49   postCameraDetails(data): Observable<any> {
50     console.log(data);
51     debugger;
52     return this.http.post<any>(this.postCameraDetailsUrl, data)
53   }
54
55   getCameraInfo(): Observable<cameraDetails> {
56     debugger;
57     return this.http.get<cameraDetails>(this.cameraDetailsUrl);
58   }
59
60   getMonitorInfo(): Observable<monitorDetails> {
61     debugger;
62     return this.http.get<monitorDetails>(this.monitorDetailsUrl);
63   }
64
65   getMonitorImage(): Observable<any> {
66     debugger;
67     return this.http.get<any>(this.monitorImageUrl);
68   }
69
70
71   triggerDetection(data): Observable<any> {
72     console.log(data);
73     debugger;
74     this.triggerObjUrl = this.triggerObjUrl + data;
75     return this.http.get<any>(this.triggerObjUrl)
76   }
77
78   getAppsPvcsInfo(): Observable<appsPvcs> {
79     return this.http.get<appsPvcs>(this.appsPvcsDetailsUrl);
80   }
81
82   getBackupRestoreInfo(): Observable<any> {
83     return this.http.get<any>(this.backupRestoreDetailsUrl);
84   }
85
86   disturbCluster(): Observable<any> {
87     return this.http.get<any>(this.disasterUrl);
88   }
89
90   postBackup(data): Observable<any> {
91     console.log(data);
92     debugger;
93     return this.http.post<any>(this.postBackupDetailsUrl, data)
94   }
95
96   postRestore(data): Observable<any> {
97     console.log(data);
98     debugger;
99     return this.http.post<any>(this.postRestoreDetailsUrl, data)
100   }
101 }