X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=webapp-frontend%2Fsrc%2Fapp%2Fservices%2Fapp-mgr%2Fapp-mgr.service.ts;h=7643da55f460f6af14611863f87854729d75590c;hb=refs%2Fchanges%2F72%2F2272%2F8;hp=33dd1cb6829a6f7da5e01e1f18262e89a3635c32;hpb=52b5162f9ca85034e0def247f4a4e5c1bda85191;p=portal%2Fric-dashboard.git diff --git a/webapp-frontend/src/app/services/app-mgr/app-mgr.service.ts b/webapp-frontend/src/app/services/app-mgr/app-mgr.service.ts index 33dd1cb6..7643da55 100644 --- a/webapp-frontend/src/app/services/app-mgr/app-mgr.service.ts +++ b/webapp-frontend/src/app/services/app-mgr/app-mgr.service.ts @@ -2,14 +2,14 @@ * ========================LICENSE_START================================= * O-RAN-SC * %% - * Copyright (C) 2019 AT&T Intellectual Property and Nokia + * Copyright (C) 2019 AT&T Intellectual Property * %% * 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. @@ -17,45 +17,55 @@ * limitations under the License. * ========================LICENSE_END=================================== */ -import { Injectable } from '@angular/core'; import { HttpClient, HttpResponse } from '@angular/common/http'; +import { Injectable } from '@angular/core'; import { Observable } from 'rxjs'; -import { XMXappInfo, XMDeployableApp, XMDeployedApp } from '../../interfaces/app-mgr.types'; +import { XMDeployableApp, XMDeployedApp, XMXappInfo } from '../../interfaces/app-mgr.types'; +import { DashboardService } from '../dashboard/dashboard.service'; @Injectable() export class AppMgrService { - constructor(private httpClient: HttpClient) { - // injects to variable httpClient - } + private component = 'appmgr'; + private xappsPath = 'xapps'; - private basePath = 'api/appmgr/xapps'; + constructor( + private dashboardSvc: DashboardService, + private httpClient: HttpClient) { + } - getDeployable(): Observable { - return this.httpClient.get(this.basePath + '/list'); + getDeployable(instanceKey: string): Observable { + const path = this.dashboardSvc.buildPath(this.component, instanceKey, this.xappsPath, 'list'); + return this.httpClient.get(path); } - getDeployed(): Observable { - return this.httpClient.get(this.basePath); + getDeployed(instanceKey: string): Observable { + const path = this.dashboardSvc.buildPath(this.component, instanceKey, this.xappsPath); + return this.httpClient.get(path); } - deployXapp(name: string): Observable> { + deployXapp(instanceKey: string, name: string): Observable> { const xappInfo: XMXappInfo = { name: name }; - return this.httpClient.post(this.basePath, xappInfo, { observe: 'response' }); + const path = this.dashboardSvc.buildPath(this.component, instanceKey, this.xappsPath); + return this.httpClient.post(path, xappInfo, { observe: 'response' }); } - undeployXapp(name: string): Observable> { - return this.httpClient.delete((this.basePath + '/' + name), { observe: 'response' }); + undeployXapp(instanceKey: string, name: string): Observable> { + const path = this.dashboardSvc.buildPath(this.component, instanceKey, this.xappsPath, name); + return this.httpClient.delete(path, { observe: 'response' }); } - getConfig(): Observable{ - return this.httpClient.get("/assets/mockdata/config.json"); - //return this.httpClient.get((this.basePath + '/config')); + getConfig(instanceKey: string): Observable { + // For demo purpose, pull example config from local + return this.httpClient.get('/assets/mockdata/config.json'); + // Once Xapp manager contains layout, should call backend to get xapp config + // const path = this.dashboardSvc.buildPath(this.component, instanceKey, 'config'); + // return this.httpClient.get(path); } - putConfig(config: any): Observable> { - return this.httpClient.post((this.basePath + '/config' ), config, { observe: 'response' }); + putConfig(instanceKey: string, config: any): Observable> { + const path = this.dashboardSvc.buildPath(this.component, instanceKey, 'config'); + return this.httpClient.put(path, config, { observe: 'response' }); } - }