ELIOT-UI Backend Code Added
[eliot.git] / blueprints / common / eliot-ui / frontend-src / src / app / myservice.service.ts
1 import { Injectable } from '@angular/core';
2 import { HttpClient, HttpHeaders, HttpParams } 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 import { Serverroom } from './serverroom';
9
10 import { nodeDetails, podDetails, nodesDropDownDetails, serviceDetails } from './../app/datainterface';
11
12
13 import { retry,catchError } from 'rxjs/operators';
14 import { Edgeserver } from './edgeserver';
15 import { v4 as uuid } from 'uuid';
16
17
18
19 @Injectable({
20   providedIn: 'root'
21 })
22 export class MyserviceService {
23
24
25   private baseUrl = 'http://localhost:8080/';
26
27   private _url = './../assets/data/post.json';
28   private nodes_url = './../assets/data/nodes.json';
29   private pods_url = './../assets/data/pods.json';
30
31   private nodes_array_url = './../assets/data/nodesdrop.json';
32
33   private services_url = './../assets/data/services.json';
34
35   private rooomDataUrl= this.baseUrl+'tempstatus';
36   private uuidUrl= this.baseUrl+'uuid';
37   private nodesUrl = this.baseUrl+'getnodes';
38   private podsUrl = this.baseUrl+'getpods';
39   private servicesUrl = this.baseUrl+'getservices';
40   private postRoom= this.baseUrl+'settemplimit';
41
42
43   constructor(private http:HttpClient) {
44   }
45
46   httpOptions = {
47     headers: new HttpHeaders({
48       'Content-Type':'application/json'
49     })
50   }
51   genUUID() {
52     return uuid();
53   }
54
55   getUUID() {
56     return this.http.get<any>(this.uuidUrl);
57   }
58
59   getRoomData(): Observable<any> {
60     return this.http.get<any>(this.rooomDataUrl);
61   }
62
63   getRoomDa(): Observable<any> {
64     return timer(0, 4000)
65         .pipe(
66            switchMap(_ => this.http.get(this.rooomDataUrl)),
67         );
68   }
69
70   getNodesInfoo(): Observable<nodeDetails> {
71     return this.http.get<nodeDetails>(this.nodesUrl);
72   }
73
74   getPodsInfo(selectedVal: any): Observable<podDetails> {
75     return this.http.get<podDetails>(this.podsUrl, {params: selectedVal} );
76   }
77
78   getNodesArray(): Observable<nodesDropDownDetails> {
79     return this.http.get<nodesDropDownDetails>(this.nodes_array_url);
80   }
81
82   getServicesInfo(): Observable<serviceDetails> {
83     return this.http.get<serviceDetails>(this.servicesUrl );
84   }
85
86 }
87