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

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

commit f74a6be709ebdabc525dc89f80861c9b2629d9a8
Author: Dmytro Gnatyshyn <[email protected]>
AuthorDate: Fri Mar 13 14:52:49 2020 +0200

    Changed billing for remote endpoint on UI
---
 .../reporting-grid/reporting-grid.component.html   | 22 ++++-----
 .../reporting-grid/reporting-grid.component.ts     |  2 +-
 .../src/app/reporting/reporting.component.ts       | 56 +++++++++++-----------
 .../app/reporting/toolbar/toolbar.component.html   |  2 +-
 .../multi-select-dropdown.component.html           |  3 +-
 .../webapp/src/dictionary/global.dictionary.ts     | 16 +++----
 6 files changed, 52 insertions(+), 49 deletions(-)

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 ae9da36..78e3cda 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
@@ -25,12 +25,12 @@
         <span class="label"> Environment name </span>
         <button mat-icon-button aria-label="More" class="ar" 
(click)="toggleFilterRow()">
           <i class="material-icons">
-            <span *ngIf="filteredReportData.dlabId.length > 0; else 
dlab_id_filtered">filter_list</span>
+            <span *ngIf="filteredReportData.dlab_id.length > 0; else 
dlab_id_filtered">filter_list</span>
             <ng-template #dlab_id_filtered>more_vert</ng-template>
           </i>
         </button>
       </th>
-      <td mat-cell *matCellDef="let element"> 
{{element[DICTIONARY[PROVIDER].billing.dlabId]}} </td>
+      <td mat-cell *matCellDef="let element"> {{element.dlabId}} </td>
       <td mat-footer-cell *matFooterCellDef class="table-footer"></td>
     </ng-container>
 
@@ -67,12 +67,12 @@
         <span class="label"> Resource Type </span>
         <button mat-icon-button aria-label="More" class="ar" 
(click)="toggleFilterRow()">
           <i class="material-icons">
-            <span *ngIf="filteredReportData.resourceTypes.length > 0; else 
type_filtered">filter_list</span>
+            <span *ngIf="filteredReportData.resource_type.length > 0; else 
type_filtered">filter_list</span>
             <ng-template #type_filtered>more_vert</ng-template>
           </i>
         </button>
       </th>
-      <td mat-cell *matCellDef="let element"> 
{{element[DICTIONARY[PROVIDER].billing.resourceType]}} </td>
+      <td mat-cell *matCellDef="let element"> {{element.resource_type | 
titlecase}} </td>
       <td mat-footer-cell *matFooterCellDef class="table-footer"></td>
     </ng-container>
 
@@ -106,7 +106,7 @@
         </button>
       </th>
       <td mat-cell *matCellDef="let element">
-        <span [outerHTML]="element['shapes'] | lineBreak"></span>
+        <span>{{element.shape}}</span>
       </td>
       <td mat-footer-cell *matFooterCellDef class="table-footer"></td>
     </ng-container>
@@ -135,11 +135,11 @@
       </th>
 
       <td mat-cell *matCellDef="let element">
-        {{ element[DICTIONARY[PROVIDER].billing.cost] }} {{ 
element[DICTIONARY[PROVIDER].billing.currencyCode] }}
+        {{ element.cost }} {{ element['currency'] }}
       </td>
       <td mat-footer-cell *matFooterCellDef class="table-footer">
-        Total <span *ngIf="reportData?.length"> {{ fullReport['cost_total'] }}
-          {{ fullReport[DICTIONARY[PROVIDER].billing.currencyCode] }}</span>
+        Total <span *ngIf="reportData?.length"> {{ fullReport['total_cost'] }}
+          {{ fullReport['currency'] }}</span>
       </td>
     </ng-container>
 
@@ -147,7 +147,7 @@
     <ng-container matColumnDef="name-filter">
       <th mat-header-cell *matHeaderCellDef>
         <input #nameFilter type="text" placeholder="Filter by environment 
name" class="form-control filter-field"
-          [value]="filtered?.dlab_id" (input)="filteredReportData.dlabId = 
$event.target.value" />
+          [value]="filtered?.dlab_id" (input)="filteredReportData.dlab_id = 
$event.target['value']" />
       </th>
     </ng-container>
     <ng-container matColumnDef="user-filter">
@@ -164,8 +164,8 @@
     </ng-container>
     <ng-container matColumnDef="type-filter">
       <th mat-header-cell *matHeaderCellDef>
-        <multi-select-dropdown *ngIf="filterConfiguration" 
(selectionChange)="onUpdate($event)" [type]="'resource_type'"
-          [items]="filterConfiguration.resourceTypes" 
[model]="filteredReportData.resourceTypes">
+        <multi-select-dropdown *ngIf="filterConfiguration" 
(selectionChange)="onUpdate($event)" [type]="['resource_type']"
+          [items]="filterConfiguration.resource_type" 
[model]="filteredReportData.resource_type">
         </multi-select-dropdown>
       </th>
     </ng-container>
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 1856688..29914e5 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
@@ -81,7 +81,7 @@ export class ReportingGridComponent implements OnInit {
   resetFiltering(): void {
     this.filteredReportData.defaultConfigurations();
 
-    this.filter.nativeElement.value = ''
+    this.filter.nativeElement.value = '';
     this.filterReport.emit(this.filteredReportData);
     this.resetRangePicker.emit(true);
   }
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 543c86e..8cfdcd9 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
@@ -28,6 +28,7 @@ import { ToolbarComponent } from 
'./toolbar/toolbar.component';
 import { FileUtils } from '../core/util';
 import { DICTIONARY, ReportingConfigModel } from 
'../../dictionary/global.dictionary';
 import {ProgressBarService} from '../core/services/progress-bar.service';
+import {logger} from 'codelyzer/util/logger';
 
 @Component({
   selector: 'dlab-reporting',
@@ -94,7 +95,6 @@ export class ReportingComponent implements OnInit, OnDestroy {
         const localEndpoint = endpoints.filter(endpoint => endpoint.name === 
'local');
         if (localEndpoint.length) {
           this.PROVIDER = localEndpoint[0].cloudProvider.toLowerCase();
-          console.log(this.PROVIDER);
           if (this.PROVIDER) {
             this.rebuildBillingReport();
           }
@@ -118,7 +118,7 @@ export class ReportingComponent implements OnInit, 
OnDestroy {
     this.billingReportService.getGeneralBillingData(this.reportData)
       .subscribe(data => {
         this.data = data;
-        this.reportingGrid.refreshData(this.data, this.data.lines);
+        this.reportingGrid.refreshData(this.data, this.data.report_lines);
         this.reportingGrid.setFullReport(this.data.full_report);
 
         this.reportingToolbar.reportData = this.data;
@@ -159,7 +159,7 @@ export class ReportingComponent implements OnInit, 
OnDestroy {
   getDefaultFilterConfiguration(data): void {
     const users = [], types = [], shapes = [], services = [], statuses = [], 
projects = [];
 
-    data.lines.forEach((item: any) => {
+    data.report_lines.forEach((item: any) => {
       if (item.user && users.indexOf(item.user) === -1)
         users.push(item.user);
 
@@ -169,30 +169,32 @@ export class ReportingComponent implements OnInit, 
OnDestroy {
       if (item.project && projects.indexOf(item.project) === -1)
         projects.push(item.project);
 
-      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['resource_type'] && types.indexOf(item['resource_type']) === -1)
+        types.push(item['resource_type']);
 
-      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[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[this.PROVIDER].billing.instance_size]) === -1 && 
shapes.push(item[DICTIONARY[this.PROVIDER].billing.instance_size]);
-        }
+      if (item.shape && types.indexOf(item.shape)) {
+        shapes.push(item.shape);
       }
-
-      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 (item.shapes.indexOf('Master') > -1) {
+        //   for (let shape of item.shapes.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.shapes.match(/\d x \S+/)) {
+        //   const parsedShape = item.shapes.match(/\d x \S+/)[0].split(' x 
')[1];
+        //   if (shapes.indexOf(parsedShape) === -1) {
+        //     shapes.push(parsedShape);
+        //   }
+        // } else {
+        //   shapes.indexOf(item.shapes) === -1 && shapes.push(item.shapes);
+        // }
+      // }
+
+      if (item.product && services.indexOf(item.product) === -1)
+        services.push(item.product);
     });
 
     if (!this.reportingGrid.filterConfiguration || 
!localStorage.getItem('report_config')) {
@@ -212,8 +214,8 @@ export class ReportingComponent implements OnInit, 
OnDestroy {
   }
 
   setRangeOption(dateRangeOption: any): void {
-    this.reportData.dateStart = dateRangeOption.start_date;
-    this.reportData.dateEnd = dateRangeOption.end_date;
+    this.reportData.date_start = dateRangeOption.start_date;
+    this.reportData.date_end = dateRangeOption.end_date;
     this.getGeneralBillingData();
   }
 
diff --git 
a/services/self-service/src/main/resources/webapp/src/app/reporting/toolbar/toolbar.component.html
 
b/services/self-service/src/main/resources/webapp/src/app/reporting/toolbar/toolbar.component.html
index 30de007..e79f3cb 100644
--- 
a/services/self-service/src/main/resources/webapp/src/app/reporting/toolbar/toolbar.component.html
+++ 
b/services/self-service/src/main/resources/webapp/src/app/reporting/toolbar/toolbar.component.html
@@ -34,7 +34,7 @@
     <ng-daterangepicker [(ngModel)]="value" [options]="options" 
(ngModelChange)="onChange($event)"></ng-daterangepicker>
   </div>
   <div class="action-butt">
-    <button mat-raised-button class="butt" (click)="export($event)" 
[disabled]="!reportData?.lines.length">
+    <button mat-raised-button class="butt" (click)="export($event)" 
[disabled]="!reportData?.report_lines.length">
       <i class="material-icons">file_download</i>Export
     </button>
     <button mat-raised-button class="butt" (click)="rebuild($event)">
diff --git 
a/services/self-service/src/main/resources/webapp/src/app/shared/form-controls/multi-select-dropdown/multi-select-dropdown.component.html
 
b/services/self-service/src/main/resources/webapp/src/app/shared/form-controls/multi-select-dropdown/multi-select-dropdown.component.html
index 7f58adf..60744c4 100644
--- 
a/services/self-service/src/main/resources/webapp/src/app/shared/form-controls/multi-select-dropdown/multi-select-dropdown.component.html
+++ 
b/services/self-service/src/main/resources/webapp/src/app/shared/form-controls/multi-select-dropdown/multi-select-dropdown.component.html
@@ -40,7 +40,8 @@
           <li role="presentation" *ngIf="model">
             <a href="#" class="list-item" role="menuitem" 
(click)="toggleSelectedOptions($event, model, item)">
               <span class="material-icons" *ngIf="model.indexOf(item) >= 
0">done</span>
-              {{item}}
+              <ng-container *ngIf="type[0] !== 
'resource_type'">{{item}}</ng-container>
+              <ng-container *ngIf="type[0] === 'resource_type'">{{item | 
titlecase}}</ng-container>
             </a>
           </li>
         </ng-template>
diff --git 
a/services/self-service/src/main/resources/webapp/src/dictionary/global.dictionary.ts
 
b/services/self-service/src/main/resources/webapp/src/dictionary/global.dictionary.ts
index f72aea2..26fe456 100644
--- 
a/services/self-service/src/main/resources/webapp/src/dictionary/global.dictionary.ts
+++ 
b/services/self-service/src/main/resources/webapp/src/dictionary/global.dictionary.ts
@@ -38,24 +38,24 @@ export class ReportingConfigModel {
   constructor(
     public users: Array<string>,
     public products: Array<string>,
-    public resourceTypes: Array<string>,
+    public resource_type: Array<string>,
     public statuses: Array<string>,
     public shapes: Array<string>,
-    public dateStart: string,
-    public dateEnd: string,
-    public dlabId: string,
+    public date_start: string,
+    public date_end: string,
+    public dlab_id: string,
     public projects: Array<string>
   ) { }
 
   defaultConfigurations(): void {
     this.users = [];
     this.products = [];
-    this.resourceTypes = [];
+    this.resource_type = [];
     this.statuses = [];
     this.shapes = [];
-    this.dateStart = '';
-    this.dateEnd = '';
-    this.dlabId = '';
+    this.date_start = '';
+    this.date_end = '';
+    this.dlab_id = '';
     this.projects = [];
   }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to