import { Injectable } from '@angular/core'; import { HttpClient, HttpHeaders, HttpParams, HttpResponse } from '@angular/common/http'; import { Observable,throwError } from 'rxjs' import { timer, Subscription, pipe } from 'rxjs'; import { switchMap } from 'rxjs/operators'; // import {Http, ResponseContentType} from '@angular/http'; import { delay } from 'rxjs/operators'; import { Serverroom } from './serverroom'; import { nodeDetails, podDetails, nodesDropDownDetails, serviceDetails, deploymentData, currentDeployInfo, currentDeployDetails, dashboardInfo } from './datainterface'; import { retry,catchError } from 'rxjs/operators'; import { Edgeserver } from './edgeserver'; import { v4 as uuid } from 'uuid'; @Injectable({ providedIn: 'root' }) export class EliotserviceService { private baseUrl = 'http://159.138.5.177:8080/'; private _url = './../assets/data/post.json'; private nodes_url = './../assets/data/nodes.json'; private pods_url = './../assets/data/pods.json'; private nodes_array_url = './../assets/data/nodesdrop.json'; private services_url = './../assets/data/services.json'; private history_url = './../assets/data/history-test.json'; private dashboard_url = './../assets/data/dashboard-test.json'; private rooomDataUrl= this.baseUrl+'tempstatus'; private uuidUrl= this.baseUrl+'uuid'; private nodesUrl = this.baseUrl+'getnodes'; private podsUrl = this.baseUrl+'getpods'; private servicesUrl = this.baseUrl+'getservices'; private postRoom= this.baseUrl+'settemplimit'; private packageUploadUrl = this.baseUrl+'upload' private deployUrl = this.baseUrl+'deploy'; private historyIdUrl = this.baseUrl+'history/files'; private nodesArrayUrl = this.baseUrl+'nodesonly'; private historyUrl = this.baseUrl+'history'; private dashboardUrl = this.baseUrl+'dashboard'; private roles_url = './../assets/data/roles.json'; private current_deploy_url = './../assets/data/current-deploy.json'; constructor(private http:HttpClient) { } httpOptions = { headers: new HttpHeaders({ 'Content-Type':'application/json' }) } genUUID() { return uuid(); } getUUID() { return this.http.get(this.uuidUrl); } getRoomData(): Observable { return this.http.get(this.rooomDataUrl); } getRoomDa(): Observable { return timer(0, 4000) .pipe( switchMap(_ => this.http.get(this.rooomDataUrl)), ); } getNodesInfoo(): Observable { return this.http.get(this.nodes_url); } getPodsInfo(selectedVal: any): Observable { return this.http.get(this.pods_url, {params: selectedVal} ); } getNodesArray(): Observable { return this.http.get(this.nodes_array_url); } getServicesInfo(): Observable { return this.http.get(this.servicesUrl ); } getHistoryInfo(): Observable { // return this.http.get(this.historyUrl); return this.http.get(this.history_url); } // removable code getRoleName(): Observable { return this.http.get(this.roles_url); } getCurrentDeployInfo(): Observable{ return this.http.get(this.current_deploy_url) } // postDeploymentYaml(data): Observable { // return this.http.get(this.servicesUrl ); // } // post postHistoryId(data): Observable { // return this.http.post(this.deployUrl, data); return this.http.get(this.historyIdUrl, {params: data} ); } postDeploymentPackage(data): Observable { return this.http.post(this.packageUploadUrl, data); // return this.http // .post(this.deployUrl, // data, { // headers: { // 'Content-Type': 'multipart/form-data' // } // } // ); } postDeployRequest(data,nodeData): Observable { debugger; return this.http.post(this.deployUrl, data, nodeData); } getDashboardData(): Observable { return this.http.get(this.dashboard_url); } }