This is an automated email from the ASF dual-hosted git repository.
dgnatyshyn pushed a commit to branch audit
in repository https://gitbox.apache.org/repos/asf/incubator-dlab.git
The following commit(s) were added to refs/heads/audit by this push:
new 32c8727 Fixed bugs, refactored code
32c8727 is described below
commit 32c872734e984b37086b35308e01c46e2f3ce5e8
Author: Dmytro_Gnatyshyn <[email protected]>
AuthorDate: Mon Jun 22 17:10:27 2020 +0300
Fixed bugs, refactored code
---
.../audit/audit-grid/audit-grid.component.html | 64 ++++++++--------------
.../audit/audit-grid/audit-grid.component.scss | 4 ++
.../audit/audit-grid/audit-grid.component.ts | 47 ++++++++++------
.../webapp/src/assets/styles/_general.scss | 2 +
4 files changed, 60 insertions(+), 57 deletions(-)
diff --git
a/services/self-service/src/main/resources/webapp/src/app/reports/audit/audit-grid/audit-grid.component.html
b/services/self-service/src/main/resources/webapp/src/app/reports/audit/audit-grid/audit-grid.component.html
index c18b82e..fe79635 100644
---
a/services/self-service/src/main/resources/webapp/src/app/reports/audit/audit-grid/audit-grid.component.html
+++
b/services/self-service/src/main/resources/webapp/src/app/reports/audit/audit-grid/audit-grid.component.html
@@ -22,7 +22,7 @@
<ng-container matColumnDef="user">
<th mat-header-cell *matHeaderCellDef class="th_user label-header">
- <div class="label"><span> User</span></div>
+ <div class="label"><span class="audit-user"> User</span></div>
<button mat-icon-button aria-label="More" class="ar"
(click)="toggleFilterRow()">
<i class="material-icons">
<span *ngIf="filterAuditData.users.length > 0; else
user_filtered">filter_list</span>
@@ -30,7 +30,7 @@
</i>
</button>
</th>
- <td mat-cell *matCellDef="let element"><span class="table-item
user-col">{{element.user}}</span></td>
+ <td mat-cell *matCellDef="let element"><span class="table-item
user-col">{{element.user || 'N/A'}}</span></td>
<td mat-footer-cell *matFooterCellDef class="table-footer"></td>
</ng-container>
@@ -44,7 +44,7 @@
</i>
</button>
</th>
- <td mat-cell *matCellDef="let element"><span
class="table-item">{{element.project}}</span></td>
+ <td mat-cell *matCellDef="let element"><span
class="table-item">{{element.project || 'N/A'}}</span></td>
<td mat-footer-cell *matFooterCellDef class="table-footer"></td>
</ng-container>
@@ -58,25 +58,15 @@
</i>
</button>
</th>
- <td mat-cell *matCellDef="let element"><span
class="table-item">{{element.resourceName}}</span></td>
+ <td mat-cell *matCellDef="let element"><span
class="table-item">{{element.resourceName || 'N/A'}}</span></td>
<td mat-footer-cell *matFooterCellDef class="table-footer"></td>
</ng-container>
<ng-container matColumnDef="action">
<th mat-header-cell *matHeaderCellDef class="th_action label-header">
-<!-- <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"> Action </span>
</div>
-<!-- <button mat-icon-button aria-label="More" class="ar"
(click)="toggleFilterRow()">-->
-<!-- <i class="material-icons">-->
-<!-- <span *ngIf="filterAuditData.actions.length > 0; else
action_filtered">filter_list</span>-->
-<!-- <ng-template #action_filtered>more_vert</ng-template>-->
-<!-- </i>-->
-<!-- </button>-->
</th>
<td mat-cell *matCellDef=" let element">
<div class="action-wrapper">
@@ -111,10 +101,6 @@
<ng-container matColumnDef="date">
<th mat-header-cell *matHeaderCellDef class="th_date label-header">
-<!-- <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">Date</span></div>
</th>
<td mat-cell *matCellDef="let element"> {{element.timestamp | date:
'dd/MM/yyyy hh:mm:ss aa'}} </td>
@@ -124,23 +110,23 @@
<span>{{firstItem}}</span> - <span>{{(lastItem < allItems) ?
lastItem: allItems}}</span> of <span>{{allItems}}</span>
</span>
<span>
- <span [ngClass]="{'not-active': firstItem === 1}">
- <span class="navigation-butts" (click)="loadItems('first')"
[ngClass]="{'not-allowed': firstItem === 1}">
+ <span [ngClass]="{'not-active': isNavigationDisabled || firstItem
=== 1}">
+ <span class="navigation-butts"
(click)="loadItemsForPage('first')" [ngClass]="{'not-allowed': firstItem === 1
|| isNavigationDisabled}">
<i class="material-icons">first_page</i>
</span>
</span>
- <span [ngClass]="{'not-active': firstItem === 1}">
- <span class="navigation-butts" (click)="loadItems('previous')"
[ngClass]="{'not-allowed': firstItem === 1}">
+ <span [ngClass]="{'not-active': firstItem === 1 ||
isNavigationDisabled}">
+ <span class="navigation-butts"
(click)="loadItemsForPage('previous')" [ngClass]="{'not-allowed': firstItem ===
1 || isNavigationDisabled}">
<i class="material-icons">keyboard_arrow_left</i>
</span>
</span>
- <span [ngClass]="{'not-active': lastItem >= allItems}">
- <span class="navigation-butts" (click)="loadItems('next')"
[ngClass]="{'not-allowed': lastItem >= allItems}">
+ <span [ngClass]="{'not-active': lastItem >= allItems ||
isNavigationDisabled}">
+ <span class="navigation-butts"
(click)="loadItemsForPage('next')" [ngClass]="{'not-allowed': lastItem >=
allItems || isNavigationDisabled}">
<i class="material-icons">keyboard_arrow_right</i>
</span>
</span>
- <span [ngClass]="{'not-active': lastItem >= allItems}">
- <span class="navigation-butts" (click)="loadItems('last')"
[ngClass]="{'not-allowed': lastItem >= allItems}">
+ <span [ngClass]="{'not-active': lastItem >= allItems ||
isNavigationDisabled}">
+ <span class="navigation-butts"
(click)="loadItemsForPage('last')" [ngClass]="{'not-allowed': lastItem >=
allItems || isNavigationDisabled}">
<i class="material-icons">last_page</i>
</span>
</span>
@@ -172,40 +158,38 @@
<ng-container matColumnDef="actions-filter">
<th mat-header-cell *matHeaderCellDef class="filter-row-item">
-<!-- <multi-select-dropdown *ngIf="filterConfiguration"
(selectionChange)="onUpdate($event)" [type]="'actions'"-->
-<!-- [items]="filterConfiguration.actions"
[model]="filterAuditData.actions"></multi-select-dropdown>-->
</th>
</ng-container>
-<!-- <ng-container matColumnDef="date-filter">-->
-<!-- <th mat-header-cell *matHeaderCellDef class="filter-row-item">-->
-
-<!-- </th>-->
-<!-- </ng-container>-->
<ng-container matColumnDef="action-filter" stickyEnd>
<th mat-header-cell *matHeaderCellDef>
<div class="actions audit-actions">
-<!-- <button mat-icon-button class="btn reset"
(click)="resetFilterConfigurations()" [disabled]="filteredEnvironments.length
== 0 && !filtering">-->
<button mat-icon-button class="btn reset"
(click)="resetFilterConfigurations()">
<i class="material-icons">close</i>
</button>
- <button mat-icon-button class="btn apply" (click)="refreshAudit()">
-<!-- [disabled]="filteredEnvironments.length == 0 &&
!filtering">-->
+ <button mat-icon-button class="btn apply"
(click)="refreshAudit(true)" [disabled]="!didFilterChanged()">
<i class="material-icons">done</i>
</button>
</div>
</th>
</ng-container>
+ <ng-container matColumnDef="placeholder">
+ <td mat-footer-cell *matFooterCellDef colspan="5" class="info">
+ <span *ngIf="!filterConfiguration.users?.length;else noMatch">No data
available</span>
+ <ng-template #noMatch>
+ <span>No matches found</span>
+ </ng-template>
+ </td>
+ </ng-container>
+
<tr mat-header-row *matHeaderRowDef="displayedColumns; sticky: true"
class="header-row"></tr>
<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>
- <tr mat-footer-row *matFooterRowDef="displayedColumns"></tr>
+ <tr [hidden]="!auditData?.length" mat-footer-row
*matFooterRowDef="displayedColumns"></tr>
-<!-- <tr [hidden]="!auditData?.length" mat-footer-row
*matFooterRowDef="displayedColumns; sticky: true"-->
-<!-- class="header-row"></tr>-->
-<!-- <tr [hidden]="reportData?.length" mat-footer-row
*matFooterRowDef="['placeholder']"></tr>-->
+ <tr [hidden]="auditData?.length" mat-footer-row
*matFooterRowDef="['placeholder']"></tr>
</table>
</section>
diff --git
a/services/self-service/src/main/resources/webapp/src/app/reports/audit/audit-grid/audit-grid.component.scss
b/services/self-service/src/main/resources/webapp/src/app/reports/audit/audit-grid/audit-grid.component.scss
index 10e1184..b413a86 100644
---
a/services/self-service/src/main/resources/webapp/src/app/reports/audit/audit-grid/audit-grid.component.scss
+++
b/services/self-service/src/main/resources/webapp/src/app/reports/audit/audit-grid/audit-grid.component.scss
@@ -260,3 +260,7 @@
.audit-actions{
text-align: right;
}
+
+.audit-user{
+ padding-left: 14px;
+}
diff --git
a/services/self-service/src/main/resources/webapp/src/app/reports/audit/audit-grid/audit-grid.component.ts
b/services/self-service/src/main/resources/webapp/src/app/reports/audit/audit-grid/audit-grid.component.ts
index 107574c..0630773 100644
---
a/services/self-service/src/main/resources/webapp/src/app/reports/audit/audit-grid/audit-grid.component.ts
+++
b/services/self-service/src/main/resources/webapp/src/app/reports/audit/audit-grid/audit-grid.component.ts
@@ -40,6 +40,8 @@ export class AuditGridComponent implements OnInit {
public firstItem: number = 1;
public lastItem: number;
public allItems: number;
+ private copiedFilterAuditData: FilterAuditModel;
+ public isNavigationDisabled;
constructor(
@@ -51,7 +53,7 @@ export class AuditGridComponent implements OnInit {
ngOnInit() {}
- public refreshAudit() {
+ public refreshAudit(filter?) {
if (!this.showItemsPrPage) {
if (window.localStorage.getItem('audit_per_page')) {
this.showItemsPrPage = +window.localStorage.getItem('audit_per_page');
@@ -60,18 +62,20 @@ export class AuditGridComponent implements OnInit {
}
this.lastItem = this.showItemsPrPage;
}
- this.getAuditData();
+ this.getAuditData(filter);
}
- public getAuditData() {
- const page = Math.ceil(this.lastItem / this.showItemsPrPage);
+ public getAuditData(filter?) {
+ const page = filter ? 1 : Math.ceil(this.lastItem / this.showItemsPrPage);
+ this.copiedFilterAuditData =
JSON.parse(JSON.stringify(this.filterAuditData));
this.auditService.getAuditData(this.filterAuditData, page,
this.showItemsPrPage).subscribe(auditData => {
+ if (filter) this.changePage('first');
this.auditData = auditData[0].audit;
this.allItems = auditData[0]['page_count'];
this.filterConfiguration = new FilterAuditModel(
- auditData[0].user_filter,
- auditData[0].resource_name_filter,
- auditData[0].project_filter,
+ auditData[0].user_filter.filter(v => v),
+ auditData[0].resource_name_filter.filter(v => v),
+ auditData[0].project_filter.filter(v => v),
[],
'',
''
@@ -105,7 +109,7 @@ export class AuditGridComponent implements OnInit {
}
}
- public loadItems(action) {
+ private changePage(action) {
if (action === 'first') {
this.firstItem = 1;
this.lastItem = this.showItemsPrPage;
@@ -119,16 +123,25 @@ export class AuditGridComponent implements OnInit {
this.firstItem = this.allItems % this.showItemsPrPage === 0 ?
this.allItems - this.showItemsPrPage : this.allItems - (this.allItems %
this.showItemsPrPage) + 1;
this.lastItem = this.allItems;
}
+ }
+
+ public loadItemsForPage(action) {
+ this.changePage(action);
this.refreshAudit();
}
- resetFilterConfigurations() {
+ public resetFilterConfigurations() {
this.filterAuditData = FilterAuditModel.getDefault();
- this.refreshAudit();
- console.log(this.filterAuditData);
+ this.refreshAudit(true);
+ }
+
+ public didFilterChanged() {
+ this.isNavigationDisabled = JSON.stringify(this.copiedFilterAuditData) !==
JSON.stringify(this.filterAuditData);
+ return this.isNavigationDisabled;
}
}
+
@Component({
selector: 'audit-info-dialog',
template: `
@@ -137,7 +150,7 @@ export class AuditGridComponent implements OnInit {
<h4 class="modal-title">{{data.action | convertaction}}</h4>
<button type="button" class="close"
(click)="dialogRef.close()">×</button>
</header>
- <div mat-dialog-content class="content audit-info-content">
+ <div mat-dialog-content class="content audit-info-content"
[ngClass]="{'pb-40': actionList[0].length > 1}">
<mat-list *ngIf="actionList[0].length > 1;else message">
<mat-list-item class="list-header">
<div class="info-item-title">Action</div>
@@ -156,13 +169,12 @@ export class AuditGridComponent implements OnInit {
<div class="message-wrapper">
<p>{{data.data}}.</p>
</div>
- </ng-template>
- </div>
+ </ng-template></div>
</div>
`,
styles: [`
- .content { color: #718ba6; padding: 20px 50px; font-size: 14px;
font-weight: 400; margin: 0; }
- .info { color: #35afd5; }
+ .content { color: #718ba6; padding: 20px 30px; font-size: 14px;
font-weight: 400; margin: 0; }
+ .pb-40 { padding-bottom: 40px; }
.info .confirm-dialog { color: #607D8B; }
header { display: flex; justify-content: space-between; color: #607D8B; }
header h4 i { vertical-align: bottom; }
@@ -170,10 +182,11 @@ export class AuditGridComponent implements OnInit {
header a:hover i { color: #35afd5; cursor: pointer; }
.scrolling-content{overflow-y: auto; max-height: 200px; }
label{cursor: pointer}
- .message-wrapper{height: 100%; display: flex; align-items: center}
+ .message-wrapper{min-height: 70px;; display: flex; align-items: center}
.mat-list-wrapper{padding-top: 5px;}
.list-item{color: #718ba6; height: auto; line-height: 20px;}
.info-item-title{width: 35%; padding: 10px 0}
+ .list-header {padding-top: 5px;}
.info-item-data{width: 65%; text-align: left; padding: 10px 0}
diff --git
a/services/self-service/src/main/resources/webapp/src/assets/styles/_general.scss
b/services/self-service/src/main/resources/webapp/src/assets/styles/_general.scss
index 769b5ef..121fe6e 100644
---
a/services/self-service/src/main/resources/webapp/src/assets/styles/_general.scss
+++
b/services/self-service/src/main/resources/webapp/src/assets/styles/_general.scss
@@ -35,6 +35,8 @@ body.modal-open {
.mt-5 {margin-top: 5px}
+.pb-50 {padding-bottom: 50px;}
+
.txt-r {text-align: right }
.txt-l {text-align: left }
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]