You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dlab.apache.org by dg...@apache.org on 2020/01/27 10:01:03 UTC

[incubator-dlab] 01/01: [DLAB-1125]: Support a multiple cloud functionality

This is an automated email from the ASF dual-hosted git repository.

dgnatyshyn pushed a commit to branch DLAB-1125
in repository https://gitbox.apache.org/repos/asf/incubator-dlab.git

commit 1b9e6274b04a2abc8e37e1b0c4148ea5db81ef50
Author: Dmytro Gnatyshyn <di...@ukr.net>
AuthorDate: Mon Jan 27 12:00:36 2020 +0200

    [DLAB-1125]: Support a multiple cloud functionality
---
 .../administration/project/project-data.service.ts  |  8 ++++----
 .../project/project-list/project-list.component.ts  |  1 -
 .../reporting-grid/reporting-grid.component.html    | 12 ++++++------
 .../reporting-grid/reporting-grid.component.ts      |  3 ++-
 .../webapp/src/app/reporting/reporting.component.ts | 21 +++++++++++----------
 5 files changed, 23 insertions(+), 22 deletions(-)

diff --git a/services/self-service/src/main/resources/webapp/src/app/administration/project/project-data.service.ts b/services/self-service/src/main/resources/webapp/src/app/administration/project/project-data.service.ts
index c86d6d5..d4d721b 100644
--- a/services/self-service/src/main/resources/webapp/src/app/administration/project/project-data.service.ts
+++ b/services/self-service/src/main/resources/webapp/src/app/administration/project/project-data.service.ts
@@ -37,21 +37,21 @@ export class ProjectDataService {
   }
 
   private getProjectsList() {
+    let endpointsList;
+    this.endpointService.getEndpointsData().subscribe(list => endpointsList = list);
     this.projectService.getProjectsList()
       .pipe(
         mergeMap ((response: Project[]) => {
-          this.endpointService.getEndpointsData().subscribe((endpoints: any) => {
             if(response) {
               response.forEach(project => project.endpoints.forEach(endpoint => {
-                const filtredEndpoints =  endpoints.filter(v => v.name === endpoint.name);
+                const filtredEndpoints =  endpointsList.filter(v => v.name === endpoint.name);
                 if(filtredEndpoints.length){
-                  endpoint.endpointStatus = endpoints.filter(v => v.name === endpoint.name)[0].status;
+                  endpoint.endpointStatus = endpointsList.filter(v => v.name === endpoint.name)[0].status;
                 }else{
                   endpoint.endpointStatus = "N/A"
                 }
               }));
             }
-          });
           return of(response);
         }))
       .subscribe(
diff --git a/services/self-service/src/main/resources/webapp/src/app/administration/project/project-list/project-list.component.ts b/services/self-service/src/main/resources/webapp/src/app/administration/project/project-list/project-list.component.ts
index b245bfe..b57dd29 100644
--- a/services/self-service/src/main/resources/webapp/src/app/administration/project/project-list/project-list.component.ts
+++ b/services/self-service/src/main/resources/webapp/src/app/administration/project/project-list/project-list.component.ts
@@ -50,7 +50,6 @@ export class ProjectListComponent implements OnInit, OnDestroy {
     public toastr: ToastrService,
     private projectDataService: ProjectDataService,
     private progressBarService: ProgressBarService,
-    private endpointService: EndpointService,
     @Inject(MAT_DIALOG_DATA) public data: any,
     public dialogRef: MatDialogRef<ProjectListComponent>,
     public dialog: MatDialog,
diff --git a/services/self-service/src/main/resources/webapp/src/app/reporting/reporting-grid/reporting-grid.component.html b/services/self-service/src/main/resources/webapp/src/app/reporting/reporting-grid/reporting-grid.component.html
index 07b423b..5069a7c 100644
--- a/services/self-service/src/main/resources/webapp/src/app/reporting/reporting-grid/reporting-grid.component.html
+++ b/services/self-service/src/main/resources/webapp/src/app/reporting/reporting-grid/reporting-grid.component.html
@@ -30,7 +30,7 @@
           </i>
         </button>
       </th>
-      <td mat-cell *matCellDef="let element"> {{element[DICTIONARY['aws'].billing.dlabId]}} </td>
+      <td mat-cell *matCellDef="let element"> {{element[DICTIONARY[PROVIDER].billing.dlabId]}} </td>
       <td mat-footer-cell *matFooterCellDef> Total </td>
     </ng-container>
 
@@ -72,7 +72,7 @@
           </i>
         </button>
       </th>
-      <td mat-cell *matCellDef="let element"> {{element[DICTIONARY['aws'].billing.resourceType]}} </td>
+      <td mat-cell *matCellDef="let element"> {{element[DICTIONARY[PROVIDER].billing.resourceType]}} </td>
       <td mat-footer-cell *matFooterCellDef></td>
     </ng-container>
 
@@ -135,11 +135,11 @@
       </th>
 
       <td mat-cell *matCellDef="let element">
-        {{ element[DICTIONARY['aws'].billing.cost] }} {{ element[DICTIONARY['aws'].billing.currencyCode] }}
+        {{ element[DICTIONARY[PROVIDER].billing.cost] }} {{ element[DICTIONARY[PROVIDER].billing.currencyCode] }}
       </td>
       <td mat-footer-cell *matFooterCellDef>
         <span *ngIf="reportData?.length">{{ fullReport['cost_total'] }}
-          {{ fullReport[DICTIONARY['aws'].billing.currencyCode] }}</span>
+          {{ fullReport[DICTIONARY[PROVIDER].billing.currencyCode] }}</span>
       </td>
     </ng-container>
 
@@ -178,8 +178,8 @@
     <ng-container matColumnDef="shape-filter">
       <th mat-header-cell *matHeaderCellDef>
         <multi-select-dropdown *ngIf="filterConfiguration" (selectionChange)="onUpdate($event)"
-          [type]="[DICTIONARY['aws'].billing.instance_size]" [items]="filterConfiguration[DICTIONARY['aws'].billing.instance_size]"
-          [model]="filteredReportData[DICTIONARY['aws'].billing.instance_size]"></multi-select-dropdown>
+          [type]="[DICTIONARY[PROVIDER].billing.instance_size]" [items]="filterConfiguration[DICTIONARY[PROVIDER].billing.instance_size]"
+          [model]="filteredReportData[DICTIONARY[PROVIDER].billing.instance_size]"></multi-select-dropdown>
       </th>
     </ng-container>
     <ng-container matColumnDef="service-filter">
diff --git a/services/self-service/src/main/resources/webapp/src/app/reporting/reporting-grid/reporting-grid.component.ts b/services/self-service/src/main/resources/webapp/src/app/reporting/reporting-grid/reporting-grid.component.ts
index d303723..74308ab 100644
--- a/services/self-service/src/main/resources/webapp/src/app/reporting/reporting-grid/reporting-grid.component.ts
+++ b/services/self-service/src/main/resources/webapp/src/app/reporting/reporting-grid/reporting-grid.component.ts
@@ -37,6 +37,7 @@ export class ReportingGridComponent implements OnInit {
   reportData: Array<any> = [];
   fullReport: Array<any>;
   isFiltered: boolean = false;
+  private PROVIDER: string = 'aws';
 
   @ViewChild('nameFilter', { static: false }) filter;
 
@@ -45,7 +46,7 @@ export class ReportingGridComponent implements OnInit {
   displayedColumns: string[] = ['name', 'user', 'project', 'type', 'status', 'shape', 'service', 'charge'];
   displayedFilterColumns: string[] = ['name-filter', 'user-filter', 'project-filter', 'type-filter', 'status-filter', 'shape-filter', 'service-filter', 'actions'];
 
-  ngOnInit() { }
+  ngOnInit() {}
 
   onUpdate($event): void {
     this.filteredReportData[$event.type] = $event.model;
diff --git a/services/self-service/src/main/resources/webapp/src/app/reporting/reporting.component.ts b/services/self-service/src/main/resources/webapp/src/app/reporting/reporting.component.ts
index 033724b..83d7bc6 100644
--- a/services/self-service/src/main/resources/webapp/src/app/reporting/reporting.component.ts
+++ b/services/self-service/src/main/resources/webapp/src/app/reporting/reporting.component.ts
@@ -68,6 +68,7 @@ export class ReportingComponent implements OnInit, OnDestroy {
   data: any;
   billingEnabled: boolean;
   admin: boolean;
+  private PROVIDER: string = 'aws';
 
   constructor(
     private billingReportService: BillingReportService,
@@ -140,30 +141,30 @@ export class ReportingComponent implements OnInit, OnDestroy {
       if (item.project && projects.indexOf(item.project) === -1)
         projects.push(item.project);
 
-      if (item[DICTIONARY['aws'].billing.resourceType] && types.indexOf(item[DICTIONARY['aws'].billing.resourceType]) === -1)
-        types.push(item[DICTIONARY['aws'].billing.resourceType]);
+      if (item[DICTIONARY[this.PROVIDER].billing.resourceType] && types.indexOf(item[DICTIONARY[this.PROVIDER].billing.resourceType]) === -1)
+        types.push(item[DICTIONARY[this.PROVIDER].billing.resourceType]);
 
-      if (item[DICTIONARY['aws'].billing.instance_size]) {
-        if (item[DICTIONARY['aws'].billing.instance_size].indexOf('Master') > -1) {
-          for (let shape of item[DICTIONARY['aws'].billing.instance_size].split('\n')) {
+      if (item[DICTIONARY[this.PROVIDER].billing.instance_size]) {
+        if (item[DICTIONARY[this.PROVIDER].billing.instance_size].indexOf('Master') > -1) {
+          for (let shape of item[DICTIONARY[this.PROVIDER].billing.instance_size].split('\n')) {
             shape = shape.replace('Master: ', '');
             shape = shape.replace(/Slave:\s+\d+ x /, '');
             shape = shape.replace(/\s+/g, '');
 
             shapes.indexOf(shape) === -1 && shapes.push(shape);
           }
-        } else if (item[DICTIONARY['aws'].billing.instance_size].match(/\d x \S+/)) {
-          const parsedShape = item[DICTIONARY['aws'].billing.instance_size].match(/\d x \S+/)[0].split(' x ')[1];
+        } else if (item[DICTIONARY[this.PROVIDER].billing.instance_size].match(/\d x \S+/)) {
+          const parsedShape = item[DICTIONARY[this.PROVIDER].billing.instance_size].match(/\d x \S+/)[0].split(' x ')[1];
           if (shapes.indexOf(parsedShape) === -1) {
             shapes.push(parsedShape);
           }
         } else {
-          shapes.indexOf(item[DICTIONARY['aws'].billing.instance_size]) === -1 && shapes.push(item[DICTIONARY['aws'].billing.instance_size]);
+          shapes.indexOf(item[DICTIONARY[this.PROVIDER].billing.instance_size]) === -1 && shapes.push(item[DICTIONARY[this.PROVIDER].billing.instance_size]);
         }
       }
 
-      if (item[DICTIONARY['aws'].billing.service] && services.indexOf(item[DICTIONARY['aws'].billing.service]) === -1)
-        services.push(item[DICTIONARY['aws'].billing.service]);
+      if (item[DICTIONARY[this.PROVIDER].billing.service] && services.indexOf(item[DICTIONARY[this.PROVIDER].billing.service]) === -1)
+        services.push(item[DICTIONARY[this.PROVIDER].billing.service]);
     });
 
     if (!this.reportingGrid.filterConfiguration || !localStorage.getItem('report_config')) {


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@dlab.apache.org
For additional commands, e-mail: commits-help@dlab.apache.org