use XappMgrService to replace Catalog and Control 75/175/4
authorjh245g <jh245g@att.com>
Sun, 19 May 2019 21:23:13 +0000 (17:23 -0400)
committerjh245g <jh245g@att.com>
Tue, 21 May 2019 13:22:00 +0000 (09:22 -0400)
Change-Id: I431f24a5f55482c2fd2186db96507321cc6727bd

Signed-off-by: Jun (Nicolas) Hu <jh245g@att.com>
Change-Id: Idb48a2b028cb7dffe08e7e1ed765e87a2f4308d7

docs/release-notes.rst
webapp-frontend/src/app/app.module.ts
webapp-frontend/src/app/catalog/catalog.component.ts
webapp-frontend/src/app/control/control.component.ts
webapp-frontend/src/app/services/control/control.service.spec.ts [deleted file]
webapp-frontend/src/app/services/control/control.service.ts [deleted file]
webapp-frontend/src/app/services/xapp-mgr/xapp-mgr.service.spec.ts [moved from webapp-frontend/src/app/services/catalog/catalog.service.spec.ts with 85% similarity]
webapp-frontend/src/app/services/xapp-mgr/xapp-mgr.service.ts [moved from webapp-frontend/src/app/services/catalog/catalog.service.ts with 72% similarity]

index c544a9b..86c1791 100644 (file)
@@ -30,6 +30,7 @@ Version 1.0.3, 20 May 2019
 * Add simple page footer with copyright and version
 * Add AC and ANR xApp services
 * Rename signal service to E2 Manager service
+* Use XappMgrService to replace ControlService and CatalogService
 
 Version 1.0.2, 13 May 2019
 --------------------------
index e9dc34d..353e127 100644 (file)
@@ -37,8 +37,7 @@ import { LoginComponent } from './login/login.component';
 import { CatalogComponent } from './catalog/catalog.component';
 import { UiService } from './services/ui/ui.service';
 import { AdminService } from './services/admin/admin.service';
-import { CatalogService } from './services/catalog/catalog.service';
-import { ControlService } from './services/control/control.service';
+import { XappMgrService } from './services/xapp-mgr/xapp-mgr.service';
 import { DashboardService } from './services/dashboard/dashboard.service';
 import { E2ManagerService } from './services/e2-mgr/e2-mgr.service';
 import { SidenavListComponent } from './navigation/sidenav-list/sidenav-list.component';
@@ -128,8 +127,7 @@ import { AnrXappComponent } from './anr-xapp/anr-xapp.component';
   providers: [
       UiService,
       AdminService,
-      CatalogService,
-      ControlService,
+      XappMgrService,
       DashboardService,
       E2ManagerService
     ],
index f0fcbce..fd28f0a 100644 (file)
  * limitations under the License.
  * ========================LICENSE_END===================================
  */
-import { Component, Inject } from '@angular/core';
+import { Component, OnInit } from '@angular/core';
 import { LocalDataSource } from 'ng2-smart-table';
-import { CatalogService } from '../services/catalog/catalog.service';
+import { XappMgrService } from '../services/xapp-mgr/xapp-mgr.service';
 import { ConfirmDialogService } from './../services/ui/confirm-dialog.service'
 import { NotificationService } from './../services/ui/notification.service'
+import { XMXapp } from '../interfaces/xapp-mgr.types';
 
 @Component({
   selector: 'app-catalog',
   templateUrl: './catalog.component.html',
   styleUrls: ['./catalog.component.css']
 })
-export class CatalogComponent {
+export class CatalogComponent implements OnInit{
 
   settings = {
     hideSubHeader: true,
@@ -62,17 +63,19 @@ export class CatalogComponent {
   source: LocalDataSource = new LocalDataSource();
 
   constructor(
-    private service: CatalogService,
+    private xappMgrSvc: XappMgrService,
     private confirmDialogService: ConfirmDialogService,
-    private notification: NotificationService) {
-    this.service.getAll().subscribe((val: any[]) => this.source.load(val));
+    private notification: NotificationService) { }
+
+  ngOnInit() {
+    this.xappMgrSvc.getAll().subscribe((xapps: XMXapp[]) => this.source.load(xapps));
   }
 
   onDeployxApp(event): void {
     this.confirmDialogService.openConfirmDialog('Are you sure you want to deploy this xApp?')
       .afterClosed().subscribe(res => {
         if (res) {
-          this.service.deployXapp(event.data.name).subscribe(
+          this.xappMgrSvc.deployXapp(event.data.name).subscribe(
             response => {
               switch (response.status) {
                 case 200:
index 1c88393..067077e 100644 (file)
  */
 import { Component, OnInit, ViewEncapsulation } from '@angular/core';
 import { LocalDataSource } from 'ng2-smart-table';
-import { ControlService } from '../services/control/control.service';
+import { XappMgrService } from '../services/xapp-mgr/xapp-mgr.service';
 import { Router } from '@angular/router';
 import { ConfirmDialogService } from './../services/ui/confirm-dialog.service'
 import { NotificationService } from './../services/ui/notification.service'
+import { XMXapp } from '../interfaces/xapp-mgr.types';
 
 
 @Component({
@@ -31,7 +32,7 @@ import { NotificationService } from './../services/ui/notification.service'
   styleUrls: ['./control.component.css'],
   encapsulation: ViewEncapsulation.Emulated,
 })
-export class ControlComponent {
+export class ControlComponent implements OnInit  {
 
   settings = {
     hideSubHeader: true,
@@ -82,11 +83,13 @@ export class ControlComponent {
   source: LocalDataSource = new LocalDataSource();
 
   constructor(
-    private service: ControlService,
+    private xappMgrSvc: XappMgrService,
     private router: Router,
     private confirmDialogService: ConfirmDialogService,
-    private notification: NotificationService) {
-    this.service.getxAppInstances((instances) => { this.source.load(instances); });
+    private notification: NotificationService) { }
+
+  ngOnInit() {
+    this.xappMgrSvc.getAll().subscribe((xapps: XMXapp[]) => this.source.load(this.getInstance(xapps)));
   }
 
   onxAppControlAction(event) {
@@ -109,9 +112,9 @@ export class ControlComponent {
     this.confirmDialogService.openConfirmDialog('Are you sure you want to undeploy this xApp ?')
       .afterClosed().subscribe(res => {
         if (res) {
-          this.service.undeployxApp(event.data.xapp).subscribe(
+          this.xappMgrSvc.undeployXapp(event.data.xapp).subscribe(
             response => {
-              this.service.getxAppInstances((instances) => { this.source.load(instances); });
+              this.xappMgrSvc.getAll().subscribe((xapps: XMXapp[]) => this.source.load(this.getInstance(xapps)));
               switch (response.status) {
                 case 200:
                   this.notification.success('xApp undeployed successfully!');
@@ -125,5 +128,19 @@ export class ControlComponent {
       });
   }
 
+  getInstance(allxappdata: XMXapp[]) {
+    const xAppInstances = [];
+    for (const xappindex in allxappdata) {
+      const instancelist = allxappdata[xappindex].instances;
+      for (const instanceindex in instancelist) {
+        var instance: any;
+        instance = instancelist[instanceindex];
+        instance.xapp = allxappdata[xappindex].name;
+        xAppInstances.push(instance);
+      }
+    }
+    return xAppInstances;
+  }
+
 
 }
diff --git a/webapp-frontend/src/app/services/control/control.service.spec.ts b/webapp-frontend/src/app/services/control/control.service.spec.ts
deleted file mode 100644 (file)
index 6ec98f8..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-/*-
- * ========================LICENSE_START=================================
- * 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ========================LICENSE_END===================================
- */
-import { TestBed } from '@angular/core/testing';
-
-import { ControlService } from './control.service';
-
-describe('ControlService', () => {
-  beforeEach(() => TestBed.configureTestingModule({}));
-
-  it('should be created', () => {
-    const service: ControlService = TestBed.get(ControlService);
-    expect(service).toBeTruthy();
-  });
-});
diff --git a/webapp-frontend/src/app/services/control/control.service.ts b/webapp-frontend/src/app/services/control/control.service.ts
deleted file mode 100644 (file)
index 24b4024..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-/*-
- * ========================LICENSE_START=================================
- * 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ========================LICENSE_END===================================
- */
-import { Injectable } from '@angular/core';
-import { HttpClient } from '@angular/common/http';
-
-@Injectable()
-export class ControlService {
-
-    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;
-    }
-
-}
@@ -7,9 +7,9 @@
  * 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.
  * limitations under the License.
  * ========================LICENSE_END===================================
  */
-import { TestBed } from '@angular/core/testing';
 
-import { CatalogService } from './catalog.service';
+import { TestBed } from '@angular/core/testing';
+import { XappMgrService } from './xapp-mgr.service';
 
-describe('CatalogService', () => {
+describe('XappMgrService', () => {
   beforeEach(() => TestBed.configureTestingModule({}));
 
   it('should be created', () => {
-    const service: CatalogService = TestBed.get(CatalogService);
+    const service: XappMgrService = TestBed.get(XappMgrService);
     expect(service).toBeTruthy();
   });
 });
 import { Injectable } from '@angular/core';
 import { HttpClient } from '@angular/common/http';
 import { Observable } from 'rxjs';
-import { XMXappInfo } from '../../interfaces/xapp-mgr.types';
+import { XMXappInfo, XMXapp} from '../../interfaces/xapp-mgr.types';
+
 
 @Injectable()
-export class CatalogService {
+export class XappMgrService {
 
   constructor(private httpClient: HttpClient) {
     // injects to variable httpClient
   }
 
-  getAll() {
-    return this.httpClient.get('api/xappmgr/xapps');
+  private basePath = 'api/xappmgr/xapps';
+
+  getAll(){
+    return this.httpClient.get<XMXapp[]>(this.basePath);
   }
 
   deployXapp(name: string) {
     const xappInfo: XMXappInfo = { xAppName: name };
-    return this.httpClient.post('api/xappmgr/xapps', xappInfo, { observe: 'response' });
+    return this.httpClient.post(this.basePath, xappInfo, { observe: 'response' });
+  }
+
+  undeployXapp(name: string) {
+    return this.httpClient.delete((this.basePath + '/' + name), { observe: 'response' });
   }
 
-}
+}
\ No newline at end of file