X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=webapp-frontend%2Fsrc%2Fapp%2Fservices%2Fcontrol%2Fcontrol.service.ts;h=24b4024a9184252d0e5ecac309e5e013ec9268a6;hb=a4c7cdd075d372de0ab352abc46359d88a570d90;hp=d75c25545205a7db070a152465ff0be27df7daa4;hpb=e2cbc4d0304646febf7e2cbe0dccdf9840189222;p=portal%2Fric-dashboard.git diff --git a/webapp-frontend/src/app/services/control/control.service.ts b/webapp-frontend/src/app/services/control/control.service.ts index d75c2554..24b4024a 100644 --- a/webapp-frontend/src/app/services/control/control.service.ts +++ b/webapp-frontend/src/app/services/control/control.service.ts @@ -1,15 +1,15 @@ /*- * ========================LICENSE_START================================= - * ORAN-OSC + * O-RAN-SC * %% * Copyright (C) 2019 AT&T Intellectual Property and Nokia * %% * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -18,74 +18,37 @@ * ========================LICENSE_END=================================== */ import { Injectable } from '@angular/core'; +import { HttpClient } from '@angular/common/http'; @Injectable() export class ControlService { -data = [{ - id: 1, - xAppName: 'Pendulum Control', - xAppType: 'Type1', - podId: 'dc-ric-app-b8c6668d8-56bjb', - k8Status: 'running', - age: '25 mins', - }, { - id: 2, - xAppName: 'Dual Connectivity', - xAppType: 'Type2', - podId: 'ac-ric-app-5ddbc59ffd-qc6rp', - k8Status: 'failed', - age: '5 mins', + constructor(private http: HttpClient) { + } + + getxAppInstances(xAppInstances) { + return this.http.get('api/xappmgr/xapps').subscribe( + (val: any[]) => { + xAppInstances(this.fetchInstance(val)); + } + ); + } + + undeployxApp(xapp) { + return this.http.delete(('api/xappmgr/xapps/' + xapp), { observe: 'response' }); + } + + fetchInstance(allxappdata) { + const xAppInstances = []; + for (const xappindex in allxappdata) { + const instancelist = allxappdata[xappindex].instances; + for (const instanceindex in instancelist) { + const instance = instancelist[instanceindex]; + instance.xapp = allxappdata[xappindex].name; + xAppInstances.push(instance); + } + } + return xAppInstances; + } - }, { - id: 3, - xAppName: 'ANR', - xAppType: 'Type1', - podId: 'dc-ric-app-694c45b75f-nqdtt', - k8Status: 'pending', - age: '55 mins', - }, { - id: 4, - xAppName: 'Admission Control', - xAppType: 'Type2', - podId: 'ac-ric-app-4ddfc59ffd-qc7tp', - k8Status: 'unkown', - age: '5 mins', - - }, { - id: 5, - xAppName: 'Admission Control', - xAppType: 'Type2', - podId: 'ac-ric-app-3ffgc59ffd-qc5rp', - k8Status: 'crashLoopBackoff', - age: '5 mins', - - }, { - id: 6, - xAppName: 'ANR', - xAppType: 'Type1', - podId: 'dc-ric-app-345f44r75f-nertt', - k8Status: 'completed', - age: '55 mins', - }, { - id: 7, - xAppName: 'Admission Control', - xAppType: 'Type2', - podId: 'ac-ric-app-5ddbc67ffd-qc6rp', - k8Status: 'completed', - age: '5 mins', - - }, { - id: 8, - xAppName: 'ANR', - xAppType: 'Type1', - podId: 'dc-ric-app-694c23b75f-nqdtt', - k8Status: 'completed', - age: '55 mins', - - }]; - - getData() { - return this.data; // @TODO implement the service to fetch the backend data - } }