Backend url is environment specific in some locations 77/140177/2
authorFiete Ostkamp <Fiete.Ostkamp@telekom.de>
Sun, 9 Feb 2025 12:18:28 +0000 (13:18 +0100)
committerFiete Ostkamp <Fiete.Ostkamp@telekom.de>
Mon, 10 Feb 2025 08:04:41 +0000 (09:04 +0100)
- use `window.location.origin` to make the backend url working for both
  local (localhost) and remote (uui.example.com) deployments

Issue-ID: USECASEUI-865
Change-Id: Idf5b6fe8a04ce744fc4cb9986c10977e60548820
Signed-off-by: Fiete Ostkamp <Fiete.Ostkamp@telekom.de>
13 files changed:
usecaseui-portal/src/app/core/models/dataInterface.ts
usecaseui-portal/src/app/core/services/homes.service.ts
usecaseui-portal/src/app/core/services/intentBase.service.ts
usecaseui-portal/src/app/core/services/managemencs.service.ts
usecaseui-portal/src/app/core/services/networkHttpservice.service.ts
usecaseui-portal/src/app/core/services/onboard.service.ts
usecaseui-portal/src/app/core/services/serviceList.service.ts
usecaseui-portal/src/app/datainterface.ts [deleted file]
usecaseui-portal/src/app/views/services/sotn-management/manage-service/manage-service.component.ts
usecaseui-portal/src/app/views/services/sotn-management/monitor-service/monitor-service.component.ts
usecaseui-portal/src/app/views/services/sotn-management/order-service/order-service.component.ts
usecaseui-portal/src/environments/environment.prod.ts
usecaseui-portal/src/environments/environment.ts

index d367fe1..578096e 100644 (file)
@@ -1,11 +1,6 @@
-enum baseUrl{
-    baseUrl = '/api/usecaseui-server/v1'  //online
-    // baseUrl = 'https://192.168.235.25:30283/api/usecaseui-server/v1'    //local two
-}
-
 interface servicesTableData {
     total:number,
     tableList:string[]
 }
 
-export {servicesTableData , baseUrl}
+export {servicesTableData}
index 98d60b5..322bbd0 100644 (file)
     limitations under the License.
 */
 import { Injectable } from '@angular/core';
-import { HttpClient, HttpHeaders, HttpParams, HttpResponse } from '@angular/common/http';
-import { Observable } from 'rxjs/Observable';
-import { baseUrl } from '../models/dataInterface';
+import { HttpClient, HttpParams } from '@angular/common/http';
+import { environment } from '@src/environments/environment';
 
 @Injectable()
 export class HomesService {
 
   constructor(private http: HttpClient) { }
-  baseUrl = baseUrl.baseUrl;
+  baseUrl = environment.backendUrl;
   url = {
     home_serviceData: this.baseUrl + "/uui-lcm/serviceNumByCustomer",
     home_alarmData: this.baseUrl + "/alarm/statusCount",
index a9c4187..f570254 100644 (file)
 */
 import { HttpClient, HttpParams } from '@angular/common/http';
 import { Injectable } from '@angular/core';
-import { baseUrl } from '../models/dataInterface';
+import { environment } from '@src/environments/environment';
 
 @Injectable()
 export class intentBaseService {
     constructor(private http: HttpClient) { }
 
-    baseUrl = baseUrl.baseUrl;
+    baseUrl = environment.backendUrl;
     url = {
       getInstanceId: this.baseUrl + "/intent/getInstanceId",
       createIntentInstance: this.baseUrl + "/intent/createIntentInstance",
@@ -47,7 +47,7 @@ export class intentBaseService {
     getInstanceId() {
         return this.http.get<any>(this.url["getInstanceId"]);
     }
-    
+
     createIntentInstance(requestBody) {
       return this.http.post<any>(this.url["createIntentInstance"], requestBody);
     }
@@ -55,7 +55,7 @@ export class intentBaseService {
     getInstanceList(requestBody) {
       return this.http.post<any>(this.url["getInstanceList"], requestBody);
     }
-    
+
     getInstanceStatus(requestBody) {
       return this.http.post<any>(this.url["getInstanceStatus"], requestBody);
     }
@@ -63,16 +63,16 @@ export class intentBaseService {
     queryInstancePerformanceData(requestBody) {
         return this.http.post<any>(this.url["queryInstancePerformanceData"], requestBody);
     }
-    
+
     getFinishedInstanceInfo() {
       return this.http.get<any>(this.url["getFinishedInstanceInfo"]);
     }
-    
+
     deleteIntentInstance(instanceId) {
         let params = new HttpParams({ fromObject: { "instanceId": instanceId } });
         return this.http.delete<any>(this.url.deleteIntentInstance, { params });
     }
-    
+
     activeIntentInstance(requestBody) {
       return this.http.post<any>(this.url["activeIntentInstance"], requestBody);
     }
@@ -84,7 +84,7 @@ export class intentBaseService {
     updateIntentInstance(requestBody) {
       return this.http.post<any>(this.url["updateIntentInstance"], requestBody);
     }
-    
+
     queryAccessNodeInfo() {
       return this.http.get<any>(this.url["queryAccessNodeInfo"]);
     }
index c8eed21..7dd9d94 100644 (file)
@@ -1,14 +1,13 @@
 import { Injectable } from '@angular/core';
-import { HttpClient, HttpHeaders, HttpParams, HttpResponse } from '@angular/common/http';
-import { Observable } from 'rxjs/Observable';
-import { baseUrl } from '../models/dataInterface';
+import { HttpClient, HttpParams } from '@angular/common/http';
+import { environment } from '@src/environments/environment';
 
 
 @Injectable()
 export class ManagemencsService {
 
     constructor(private http: HttpClient) { }
-    baseUrl = baseUrl.baseUrl;
+    baseUrl = environment.backendUrl;
 
     /* line up */
     url = {
index d558d48..73d6211 100644 (file)
@@ -15,8 +15,8 @@
     limitations under the License.
 */
 import { Injectable } from '@angular/core';
-import { HttpClient, HttpHeaders, HttpParams, HttpResponse } from '@angular/common/http';
-import { baseUrl } from '../models/dataInterface';
+import { HttpClient, HttpParams } from '@angular/common/http';
+import { environment } from '@src/environments/environment';
 
 
 @Injectable()
@@ -24,7 +24,7 @@ export class networkHttpservice {
 
     constructor(private http: HttpClient) { }
 
-    baseUrl = baseUrl.baseUrl;//Online environment
+    baseUrl = environment.backendUrl;
     url = {
         "getNetworkD3Data": this.baseUrl+"/uui-sotn/getNetWorkResources",
         "getLogicalLinksData": this.baseUrl+"/uui-sotn/getLogicalLinks",
index 20d9c24..472fcf6 100644 (file)
     limitations under the License.
 */
 import { Injectable } from '@angular/core';
-import { HttpClient, HttpHeaders, HttpParams, HttpResponse } from '@angular/common/http';
-import { Observable } from 'rxjs/Observable';
-import { baseUrl } from '../models/dataInterface';
+import { HttpClient, HttpParams } from '@angular/common/http';
+import { environment } from '@src/environments/environment';
 
 @Injectable()
 export class onboardService {
     constructor(private http: HttpClient) { }
 
-    baseUrl = baseUrl.baseUrl;
+    baseUrl =environment.backendUrl;
     url = {
         onboardTableData: this.baseUrl + "/uui-lcm/ns-packages",
         onboardDataVNF: this.baseUrl + "/uui-lcm/vnf-packages",
index 945d60c..1492d0d 100644 (file)
 import { Injectable } from '@angular/core';
 import { HttpClient, HttpHeaders, HttpParams, HttpResponse } from '@angular/common/http';
 import { Observable } from 'rxjs/Observable';
-import {  servicesTableData,baseUrl } from '../models/dataInterface';
-import { retry, catchError } from 'rxjs/operators';
+import { servicesTableData } from '../models/dataInterface';
+import { catchError } from 'rxjs/operators';
+import { environment } from '@src/environments/environment';
 
 @Injectable()
 export class ServiceListService {
 
   constructor(private http: HttpClient) { }
-  baseUrl = baseUrl.baseUrl;
-  
+  baseUrl = environment.backendUrl;
+
   url = {
     customers: this.baseUrl + "/uui-lcm/customers",
     serviceType: this.baseUrl + "/uui-lcm/customers/" + "*_*" + "/service-subscriptions",
@@ -219,7 +220,7 @@ export class ServiceListService {
     return this.http.get<any>(url);
   }
 
-  
+
   handleError(error) {
     let errorMessage = '';
     if (error.error instanceof ErrorEvent) {
diff --git a/usecaseui-portal/src/app/datainterface.ts b/usecaseui-portal/src/app/datainterface.ts
deleted file mode 100644 (file)
index 2ba1af9..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-enum baseUrl{
-    baseUrl = 'http://localhost:8082/api/usecaseui/server/v1'  //online
-    //baseUrl = 'http://172.19.44.223/api/usecaseui-server/v1'     //local one
-    //baseUrl = 'http://localhost:8082/api/usecaseui/server/v1'    //local two
-}
-export {baseUrl};
\ No newline at end of file
index 16aee4e..fa11985 100644 (file)
@@ -1,6 +1,6 @@
-import { Component, OnInit, SimpleChanges } from '@angular/core';
-import { HttpClient, HttpHeaders, HttpParams, HttpResponse } from '@angular/common/http';
-import { baseUrl } from '../../../../datainterface';
+import { Component, OnInit } from '@angular/core';
+import { HttpClient, HttpHeaders } from '@angular/common/http';
+import { environment } from '@src/environments/environment';
 @Component({
   selector: 'app-manage-service',
   templateUrl: './manage-service.component.html',
@@ -25,7 +25,7 @@ export class ManageServiceComponent implements OnInit {
   uniInfo = [];
   mapped: any;
   myKeys = [] as Array<any>;
-  baseUrl = baseUrl.baseUrl
+  baseUrl = environment.backendUrl;
   constructor(private http: HttpClient) { }
 
   ngOnInit() {
@@ -58,10 +58,10 @@ export class ManageServiceComponent implements OnInit {
     this.selectedServiceInstance="";
     let url = this.baseUrl + "/uui-lcm/Sotnservices/ServiceInstances/"+subscriptionType;
     this.http.get<any>(url,httpOptions).subscribe((data) => {
-      this.serviceInstanceList = data.serviceInstanceList; 
+      this.serviceInstanceList = data.serviceInstanceList;
     }, (err) => {
       console.log(err);
-    });    
+    });
   }
 
   deleteSelectedService() {
@@ -81,8 +81,8 @@ export class ManageServiceComponent implements OnInit {
   }
 
 
-  
-  getSubscribedSites() {  
+
+  getSubscribedSites() {
     console.log("on change");
      let httpOptions = {
       headers: new HttpHeaders({
index 6ad9821..9525488 100644 (file)
@@ -1,9 +1,7 @@
 import { Component, OnInit } from '@angular/core';
 import { Network, Node, Edge } from 'vis';
 import { HttpClient, HttpHeaders } from '@angular/common/http';
-import { Observable } from 'rxjs/Observable';
-import { baseUrl } from '../../../../datainterface';
-import { getLocaleDateFormat } from '@angular/common';
+import { environment } from '@src/environments/environment';
 @Component({
   selector: 'app-monitor-service',
   templateUrl: './monitor-service.component.html',
@@ -17,7 +15,7 @@ export class MonitorServiceComponent implements OnInit {
   serviceInstanceList = [] as Array<any>;
 
   selectedTopology:string = 'i18nTextDefine_serviceTopology';
-  baseUrl = baseUrl.baseUrl
+  baseUrl = environment.backendUrl;
 
   title = 'Network';
     public nodes: Node;
@@ -41,10 +39,10 @@ export class MonitorServiceComponent implements OnInit {
         topologyType:"i18nTextDefine_resourceTopology",
       }
     ];
-  
-    
+
+
     networkOptions = {
-      layout: { 
+      layout: {
           randomSeed: 15
       },
       nodes: {
@@ -115,10 +113,10 @@ export class MonitorServiceComponent implements OnInit {
     };
     let url = this.baseUrl + "/uui-lcm/Sotnservices/ServiceInstances/" + subscriptionType;
     this.http.get<any>(url,httpOptions).subscribe((data) => {
-      this.serviceInstanceList = data.serviceInstanceList; 
+      this.serviceInstanceList = data.serviceInstanceList;
     }, (err) => {
       console.log(err);
-    });    
+    });
   }
 
   getTopologyInfo (topo) {
@@ -158,7 +156,7 @@ export class MonitorServiceComponent implements OnInit {
               </thead>\
               <tbody>\
           ';
-          Object.entries(filteredNode[0].dataNode).forEach(entry => {                
+          Object.entries(filteredNode[0].dataNode).forEach(entry => {
               if( entry[1] !== "null")
               {
                   t1 += '<tr class="popup-table-row">\
@@ -166,7 +164,7 @@ export class MonitorServiceComponent implements OnInit {
                       <td class="monitor-table-td-th   ">'+ entry[1] + '</td>\
                   </tr>\
                   ';
-              }    
+              }
           });
           t1 += '</tbody>\
           </table>\
@@ -214,14 +212,14 @@ export class MonitorServiceComponent implements OnInit {
   }
 
   // Getting sitedata Based On Type and ID
-  getSelectedsubscriptionInfo() {       
+  getSelectedsubscriptionInfo() {
       this.getData("");
       if (this.intervalData) {
           clearInterval(this.intervalData);
-      }        
+      }
   }
 
-  
+
   ngOnDestroy() {
       console.log('clear interval');
       if (this.intervalData) {
index 1cfd00f..473681c 100644 (file)
@@ -1,12 +1,12 @@
 import { Component, OnInit, Output, EventEmitter } from '@angular/core';
 import {
-  FormBuilder,  
+  FormBuilder,
   FormGroup,
   Validators
 } from '@angular/forms';
 import { HttpClient, HttpHeaders } from '@angular/common/http';
 import { NzMessageService } from 'ng-zorro-antd';
-import { baseUrl } from '../../../../datainterface';
+import { environment } from '@src/environments/environment';
 
 @Component({
   selector: 'app-order-service',
@@ -20,7 +20,7 @@ export class OrderServiceComponent implements OnInit {
   siteData:object = {};
   buttonDisabled:boolean = false;
   intervalData:any;
-  baseUrl = baseUrl.baseUrl
+  baseUrl = environment.backendUrl;
   expandDataSet = [
     { rowIdx: 1, name: 'i18nTextDefine_serviceInformation', expand: true },
     { rowIdx: 2, name: 'i18nTextDefine_vpnInformation', expand: true },
@@ -28,7 +28,7 @@ export class OrderServiceComponent implements OnInit {
   ];
   uni = {};
   sotnUni = [];
-  
+
   @Output() childEvent = new EventEmitter<string>();
 
   constructor(private fb: FormBuilder, private http: HttpClient, private message: NzMessageService) { }
@@ -58,7 +58,7 @@ export class OrderServiceComponent implements OnInit {
     });
   }
 
-  
+
   numberOnly(event): boolean {
     const charCode = (event.which) ? event.which : event.keyCode;
     if (charCode > 31 && (charCode < 48 || charCode > 57)) {
@@ -78,7 +78,7 @@ export class OrderServiceComponent implements OnInit {
   deletesotnUni(data) {
     for(let i = 0; i < this.sotnUni.length; i++) {
       if(data.sotnuni_tpId == this.sotnUni[i].sotnuni_tpId) {
-        this.sotnUni.splice(i, 1); 
+        this.sotnUni.splice(i, 1);
       }
     }
   }
@@ -139,9 +139,9 @@ export class OrderServiceComponent implements OnInit {
        'Content-Type': 'application/json',
       })
     };
-    
+
     let url1 = this.baseUrl + '/uui-lcm/Sotnservices_unni';
-    this.http.post<any>(url1, body, httpOptions).subscribe((data) => { 
+    this.http.post<any>(url1, body, httpOptions).subscribe((data) => {
       let comp = this;
       this.message.info('Instantiation In Progress');
       this.intervalData = setInterval(() => {
index c966979..c0aa672 100644 (file)
@@ -1,3 +1,4 @@
 export const environment = {
   production: true,
+  backendUrl: window.location.origin + '/api/usecaseui-server/v1',
 };
index cf6bba0..c423f68 100644 (file)
@@ -5,4 +5,5 @@
 
 export const environment = {
   production: false,
+  backendUrl: window.location.origin + '/api/usecaseui-server/v1',
 };