Merge "Home page carousel"
[eliot.git] / blueprints / common / eliot-ui / frontend-src / src / app / eliotservice.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 // import {Http, ResponseContentType} from '@angular/http';
7
8 import { delay } from 'rxjs/operators';
9 import { Serverroom } from './serverroom';
10
11 import { nodeDetails, podDetails, nodesDropDownDetails, 
12         serviceDetails, deploymentData, currentDeployInfo,
13         currentDeployDetails, dashboardInfo } from './datainterface';
14
15
16 import { retry,catchError } from 'rxjs/operators';
17 import { Edgeserver } from './edgeserver';
18 import { v4 as uuid } from 'uuid';
19
20
21
22 @Injectable({
23   providedIn: 'root'
24 })
25 export class EliotserviceService {
26
27
28   private baseUrl = 'http://159.138.5.177:8080/';
29
30   private _url = './../assets/data/post.json';
31   private nodes_url = './../assets/data/nodes.json';
32   private pods_url = './../assets/data/pods.json';
33
34   private nodes_array_url = './../assets/data/nodesdrop.json';
35
36   private services_url = './../assets/data/services.json';
37   private history_url = './../assets/data/history-test.json';
38   private dashboard_url = './../assets/data/dashboard-test.json';
39
40   private rooomDataUrl= this.baseUrl+'tempstatus';
41   private uuidUrl= this.baseUrl+'uuid';
42   private nodesUrl = this.baseUrl+'getnodes';
43   private podsUrl = this.baseUrl+'getpods';
44   private servicesUrl = this.baseUrl+'getservices';
45   private postRoom= this.baseUrl+'settemplimit';
46   private packageUploadUrl = this.baseUrl+'upload'
47   private deployUrl = this.baseUrl+'deploy';
48   private historyIdUrl = this.baseUrl+'history/files';
49   private nodesArrayUrl = this.baseUrl+'nodesonly';
50
51   private historyUrl = this.baseUrl+'history';
52   private dashboardUrl = this.baseUrl+'dashboard';
53
54   private roles_url = './../assets/data/roles.json';
55   private current_deploy_url = './../assets/data/current-deploy.json';
56
57
58   constructor(private http:HttpClient) {
59   }
60
61   httpOptions = {
62     headers: new HttpHeaders({
63       'Content-Type':'application/json'
64     })
65   }
66   genUUID() {
67     return uuid();
68   }
69
70   getUUID() {
71     return this.http.get<any>(this.uuidUrl);
72   }
73
74   getRoomData(): Observable<any> {
75     return this.http.get<any>(this.rooomDataUrl);
76   }
77
78   getRoomDa(): Observable<any> {
79     return timer(0, 4000)
80         .pipe(
81            switchMap(_ => this.http.get(this.rooomDataUrl)),
82         );
83   }
84
85   getNodesInfoo(): Observable<nodeDetails> {
86     return this.http.get<nodeDetails>(this.nodes_url);
87   }
88
89   getPodsInfo(selectedVal: any): Observable<podDetails> {
90     return this.http.get<podDetails>(this.pods_url, {params: selectedVal} );
91   }
92
93   getNodesArray(): Observable<nodesDropDownDetails> {
94     return this.http.get<nodesDropDownDetails>(this.nodes_array_url);
95   }
96
97   getServicesInfo(): Observable<serviceDetails> {
98     return this.http.get<serviceDetails>(this.servicesUrl );
99   }
100
101   getHistoryInfo(): Observable<any> {
102     // return this.http.get<any>(this.historyUrl);
103     return this.http.get<any>(this.history_url);
104   }
105
106   // removable code
107   getRoleName(): Observable<any> {
108     return this.http.get<any>(this.roles_url);
109   }
110
111   getCurrentDeployInfo(): Observable<currentDeployDetails>{
112     return this.http.get<currentDeployDetails>(this.current_deploy_url)
113   }
114
115   // postDeploymentYaml(data): Observable<a> {
116   //   return this.http.get<serviceDetails>(this.servicesUrl );
117   // }
118
119   // post
120
121   postHistoryId(data): Observable<Blob> {
122     // return this.http.post<any>(this.deployUrl, data);
123     return this.http.get<Blob>(this.historyIdUrl, {params: data} );
124   }
125
126   postDeploymentPackage(data): Observable<any> {
127     return this.http.post<any>(this.packageUploadUrl, data);
128     // return this.http
129     // .post(this.deployUrl,
130     //   data, {
131     //     headers: {
132     //       'Content-Type': 'multipart/form-data'
133     //     }
134     //   }
135     // );
136   }
137
138
139   postDeployRequest(data,nodeData): Observable<any> {
140     debugger;
141     return this.http.post<any>(this.deployUrl, data, nodeData);
142   }
143
144   getDashboardData(): Observable<dashboardInfo> {
145     return this.http.get<dashboardInfo>(this.dashboard_url);
146   }
147
148
149
150 }
151