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
The following commit(s) were added to refs/heads/DLAB-1571 by this push:
new 280922b [DLAB-1649]: Added possibility to sort by project/user/charges
new 5ebb9c8 Merge remote-tracking branch 'origin/DLAB-1571' into DLAB-1571
280922b is described below
commit 280922b1576791b988e3ab1f2e78f185a40add36
Author: Dmytro Gnatyshyn <[email protected]>
AuthorDate: Thu Mar 26 18:06:07 2020 +0200
[DLAB-1649]: Added possibility to sort by project/user/charges
---
.../reporting-grid/reporting-grid.component.html | 34 ++++++++++----
.../reporting-grid/reporting-grid.component.scss | 40 +++++++++++++++-
.../reporting-grid/reporting-grid.component.ts | 24 +++++++++-
.../src/app/reporting/reporting.component.ts | 54 +++++-----------------
4 files changed, 97 insertions(+), 55 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 0fb0fde..0eb86a4 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
@@ -22,7 +22,7 @@
<ng-container matColumnDef="name">
<th mat-header-cell *matHeaderCellDef class="env_name">
- <span class="label"> Environment name </span>
+ <div class="label"><span class="text"> Environment name</span></div>
<button mat-icon-button aria-label="More" class="ar"
(click)="toggleFilterRow()">
<i class="material-icons">
<span *ngIf="filteredReportData.dlab_id.length > 0; else
dlab_id_filtered">filter_list</span>
@@ -36,7 +36,13 @@
<ng-container matColumnDef="user">
<th mat-header-cell *matHeaderCellDef class="th_user">
- <span class="label"> User </span>
+ <div class="sort">
+ <div class="sort-arrow up" (click)="sortBy('user', 'down')"
[ngClass]="{'active': !!this.active['userdown']}"></div>
+ <div class="sort-arrow down" (click)="sortBy('user', 'up')"
[ngClass]="{'active': !!this.active['userup']}"></div>
+ </div>
+ <div class="label">
+ <span class="text"> User </span>
+ </div>
<button mat-icon-button aria-label="More" class="ar"
(click)="toggleFilterRow()">
<i class="material-icons">
<span *ngIf="filteredReportData.users.length > 0; else
user_filtered">filter_list</span>
@@ -50,7 +56,11 @@
<ng-container matColumnDef="project">
<th mat-header-cell *matHeaderCellDef class="th_project">
- <span class="label">Project</span>
+ <div class="sort">
+ <div class="sort-arrow up" (click)="sortBy('project', 'down')"
[ngClass]="{'active': !!this.active['projectdown']}"></div>
+ <div class="sort-arrow down" (click)="sortBy('project', 'up')"
[ngClass]="{'active': !!this.active['projectup']}"></div>
+ </div>
+ <div class="label"><span class="text">Project</span></div>
<button mat-icon-button aria-label="More" class="ar"
(click)="toggleFilterRow()">
<i class="material-icons">
<span *ngIf="filteredReportData.projects.length > 0; else
project_filtered">filter_list</span>
@@ -64,7 +74,7 @@
<ng-container matColumnDef="type">
<th mat-header-cell *matHeaderCellDef class="th_type">
- <span class="label"> Resource Type </span>
+ <div class="label"><span class="text"> Resource Type</span> </div>
<button mat-icon-button aria-label="More" class="ar"
(click)="toggleFilterRow()">
<i class="material-icons">
<span *ngIf="filteredReportData.resource_type.length > 0; else
type_filtered">filter_list</span>
@@ -78,7 +88,7 @@
<ng-container matColumnDef="status">
<th mat-header-cell *matHeaderCellDef class="th_status">
- <span class="label"> Status </span>
+ <div class="label"><span class="text"> Status</span> </div>
<button mat-icon-button aria-label="More" class="ar"
(click)="toggleFilterRow()">
<i class="material-icons">
<span *ngIf="filteredReportData.statuses.length > 0; else
status_filtered">filter_list</span>
@@ -96,7 +106,7 @@
<ng-container matColumnDef="shape">
<th mat-header-cell *matHeaderCellDef class="th_shape">
- <span class="label"> Instance size</span>
+ <div class="label"><span class="text"> Instance size</span></div>
<button mat-icon-button aria-label="More" class="ar"
(click)="toggleFilterRow()">
<i class="material-icons">
<span
@@ -113,7 +123,7 @@
<ng-container matColumnDef="service">
<th mat-header-cell *matHeaderCellDef class="service">
- <span class="label"> Product </span>
+ <div class="label"><span class="text"> Product</span> </div>
<button mat-icon-button aria-label="More" class="ar"
(click)="toggleFilterRow()">
<i class="material-icons">
<span
@@ -131,7 +141,13 @@
<ng-container matColumnDef="charge" stickyEnd>
<th mat-header-cell *matHeaderCellDef class="th_charges">
- <span class="label"> Service Charges </span>
+ <div class="label">
+ <div class="sort">
+ <div class="sort-arrow up" (click)="sortBy('cost', 'down')"
[ngClass]="{'active': !!this.active['costdown']}"></div>
+ <div class="sort-arrow down" (click)="sortBy('cost', 'up')"
[ngClass]="{'active': !!this.active['costup']}"></div>
+ </div>
+ <span class="text">Service Charges</span>
+ </div>
</th>
<td mat-cell *matCellDef="let element">
@@ -211,7 +227,7 @@
<tr mat-header-row *matHeaderRowDef="displayedColumns; sticky: true"
class="header-row"></tr>
- <tr [hidden]="!collapseFilterRow || !PROVIDER" mat-header-row
*matHeaderRowDef="displayedFilterColumns; sticky: true"
+ <tr [hidden]="!collapseFilterRow" mat-header-row
*matHeaderRowDef="displayedFilterColumns; sticky: true"
class="filter-row"></tr>
<tr mat-row *matRowDef="let row; columns: displayedColumns;"
class="content-row"></tr>
diff --git
a/services/self-service/src/main/resources/webapp/src/app/reporting/reporting-grid/reporting-grid.component.scss
b/services/self-service/src/main/resources/webapp/src/app/reporting/reporting-grid/reporting-grid.component.scss
index ead2ba6..1e8082b 100644
---
a/services/self-service/src/main/resources/webapp/src/app/reporting/reporting-grid/reporting-grid.component.scss
+++
b/services/self-service/src/main/resources/webapp/src/app/reporting/reporting-grid/reporting-grid.component.scss
@@ -120,6 +120,7 @@
min-width: 140px;
padding-right: 15px;
text-align: right;
+
.label {
padding-top: 0;
}
@@ -151,20 +152,55 @@
.header-row {
position: unset;
+
.th_charges {
padding-top: 0;
+
.label {
padding-top: 12px;
}
}
+
.label {
display: inline-block;
padding-top: 13px;
vertical-align: super !important;
- padding-left: 15px;
+
+ .text{
+ padding-left: 15px;
+ }
+ }
+
+ .sort{
+ position: absolute;
+ bottom: 20px;
+
+ &-arrow{
+ width: 6px;
+ height: 6px;
+ border: 3px solid transparent;
+ border-bottom: 3px solid rgba(0,0,0,.54);
+ border-left: 3px solid rgba(0,0,0,.54);
+ cursor: pointer;
+
+ &.active{
+ border-bottom: 3px solid #35afd5;
+ border-left: 3px solid #35afd5;
+ }
+ }
+
+ .down{
+ transform: rotate(-45deg);
+ }
+
+ .up{
+ transform: rotate(135deg);
+ }
}
}
+
+
.filter-row {
.actions {
text-align: right;
@@ -203,6 +239,7 @@
border-top: 1px solid #E0E0E0;
transform: translateY(-1px);
border-bottom: none;
+
&.total-cost{
min-width: 140px;
padding-left: 0 !important;
@@ -211,7 +248,6 @@
@media screen and (max-width: 1280px) {
.dashboard_table.reporting {
-
.env_name,
.service,
.th_type,
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 29914e5..3d99814 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
@@ -38,12 +38,12 @@ export class ReportingGridComponent implements OnInit {
reportData: Array<any> = [];
fullReport: Array<any>;
isFiltered: boolean = false;
+ active: object = {};
@ViewChild('nameFilter', { static: false }) filter;
@Output() filterReport: EventEmitter<{}> = new EventEmitter();
@Output() resetRangePicker: EventEmitter<boolean> = new EventEmitter();
- @Input() PROVIDER: string;
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'];
@@ -65,6 +65,25 @@ export class ReportingGridComponent implements OnInit {
}
}
+ sortBy(sortItem, direction) {
+ let report: Array<object>;
+ if (direction === 'down') {
+ report = this.reportData.sort((a, b) => (a[sortItem] > b[sortItem]) ? 1 :
((b[sortItem] > a[sortItem]) ? -1 : 0));
+ }
+ if (direction === 'up') {
+ report = this.reportData.sort((a, b) => (a[sortItem] < b[sortItem]) ? 1 :
((b[sortItem] < a[sortItem]) ? -1 : 0));
+ }
+ this.refreshData(this.fullReport, report);
+ this.removeSorting();
+ this.active[sortItem + direction] = true;
+ }
+
+ removeSorting() {
+ for (const item in this.active) {
+ this.active[item] = false;
+ }
+ }
+
toggleFilterRow(): void {
this.collapseFilterRow = !this.collapseFilterRow;
}
@@ -76,11 +95,12 @@ export class ReportingGridComponent implements OnInit {
filter_btnClick(): void {
this.filterReport.emit(this.filteredReportData);
this.isFiltered = true;
+ this.removeSorting();
}
resetFiltering(): void {
this.filteredReportData.defaultConfigurations();
-
+ this.removeSorting();
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 e2b30b3..3d04931 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
@@ -21,14 +21,14 @@
import { Component, OnInit, OnDestroy, ViewChild } from '@angular/core';
import { ToastrService } from 'ngx-toastr';
-import {BillingReportService, EndpointService, HealthStatusService} from
'../core/services';
+import {BillingReportService, HealthStatusService} from '../core/services';
import { ReportingGridComponent } from
'./reporting-grid/reporting-grid.component';
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',
@@ -39,15 +39,15 @@ import {logger} from 'codelyzer/util/logger';
(setRangeOption)="setRangeOption($event)">
</dlab-toolbar>
<mat-divider></mat-divider>
- <dlab-reporting-grid [PROVIDER]="PROVIDER"
(filterReport)="filterReport($event)"
(resetRangePicker)="resetRangePicker()"></dlab-reporting-grid>
+ <dlab-reporting-grid (filterReport)="filterReport($event)"
(resetRangePicker)="resetRangePicker()"></dlab-reporting-grid>
</div>
`,
styles: [`
footer {
position: fixed;
- left: 0px;
- bottom: 0px;
+ left: 0;
+ bottom: 0;
width: 100%;
background: #a1b7d1;
color: #ffffff;
@@ -69,14 +69,12 @@ export class ReportingComponent implements OnInit,
OnDestroy {
data: any;
billingEnabled: boolean;
admin: boolean;
- public PROVIDER: string;
constructor(
private billingReportService: BillingReportService,
private healthStatusService: HealthStatusService,
public toastr: ToastrService,
private progressBarService: ProgressBarService,
- private endpointService: EndpointService,
) { }
ngOnInit() {
@@ -87,39 +85,13 @@ export class ReportingComponent implements OnInit,
OnDestroy {
this.clearStorage();
}
- getBillingProvider() {
- if (this.admin) {
- this.endpointService.getEndpointsData().subscribe(list => {
- const endpoints = JSON.parse(JSON.stringify(list));
- 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();
- }
- }
- }, e => {
- this.PROVIDER = 'azure';
- if (this.PROVIDER) {
- this.rebuildBillingReport();
- }
- }) ;
- } else {
- this.PROVIDER = 'azure';
- if (this.PROVIDER) {
- this.rebuildBillingReport();
- }
- }
- }
-
getGeneralBillingData() {
setTimeout(() => {this.progressBarService.startProgressBar(); } , 0);
this.billingReportService.getGeneralBillingData(this.reportData)
.subscribe(data => {
this.data = data;
this.reportingGrid.refreshData(this.data, this.data.report_lines);
- this.reportingGrid.setFullReport(this.data.full_report);
+ this.reportingGrid.setFullReport(this.data.is_full);
this.reportingToolbar.reportData = this.data;
if (!localStorage.getItem('report_period')) {
@@ -140,13 +112,11 @@ export class ReportingComponent implements OnInit,
OnDestroy {
}, () => this.progressBarService.stopProgressBar());
}
- rebuildBillingReport($event?): void {
- if (this.PROVIDER) {
- this.clearStorage();
- this.resetRangePicker();
- this.reportData.defaultConfigurations();
- this.getGeneralBillingData();
- }
+ rebuildBillingReport(): void {
+ this.clearStorage();
+ this.resetRangePicker();
+ this.reportData.defaultConfigurations();
+ this.getGeneralBillingData();
}
exportBillingReport(): void {
@@ -229,7 +199,7 @@ export class ReportingComponent implements OnInit,
OnDestroy {
.subscribe((result: any) => {
this.billingEnabled = result.billingEnabled;
this.admin = result.admin;
- this.getBillingProvider();
+ this.rebuildBillingReport();
});
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]