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
commit 4a47ae10109a4962641d99cdcdaa7eae0d1490a7 Author: Dmytro_Gnatyshyn <[email protected]> AuthorDate: Fri Jun 19 10:46:19 2020 +0300 Added custom pagination --- .../audit/audit-grid/audit-grid.component.html | 45 +++++++++++++++++++++- .../audit/audit-grid/audit-grid.component.scss | 21 ++++++++++ .../audit/audit-grid/audit-grid.component.ts | 25 ++++++++++++ .../resources/webapp/src/assets/styles/_theme.scss | 25 +++++++++++- 4 files changed, 112 insertions(+), 4 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 aa2365e..acb9f45 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 @@ -86,7 +86,27 @@ </div> </div> </td> - <td mat-footer-cell *matFooterCellDef class="table-footer"></td> + <td mat-footer-cell *matFooterCellDef class="table-footer"> + <div class="selected-items-wrapper"> + <span>Items per page:</span> + <div class="select-wrapper"> + <div class="mat-reset"> + <div class="control selector-wrapper"> + <mat-form-field> + <mat-label></mat-label> + <mat-select [(value)]="showItemsPrPage"> + <mat-option *ngFor="let item of itemsPrPage" [value]="item" (click)="setItemsPrPage(item)"> + {{ item }}</mat-option> + </mat-select> + <button class="caret"> + <i class="material-icons">keyboard_arrow_down</i> + </button> + </mat-form-field> + </div> + </div> + </div> + </div> + </td> </ng-container> <ng-container matColumnDef="date"> @@ -98,7 +118,27 @@ <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> - <td mat-footer-cell *matFooterCellDef class="table-footer"></td> + <td mat-footer-cell *matFooterCellDef class="table-footer"> + <div class="pagination-wrapper"> + <span> + <span>{{firstItem}}</span> - <span>{{lastItem}}</span> of <span>{{auditData?.length}}</span> + </span> + <span> + <span class="navigation-butts" [ngClass]="{'not-active': firstItem === 1}" (click)="loadItems('first')"> + <i class="material-icons">first_page</i> + </span> + <span class="navigation-butts" [ngClass]="{'not-active': firstItem === 1}" (click)="loadItems('previous')"> + <i class="material-icons">keyboard_arrow_left</i> + </span> + <span class="navigation-butts" [ngClass]="{'not-active': lastItem >= auditData?.length}" (click)="loadItems('next')"> + <i class="material-icons">keyboard_arrow_right</i> + </span> + <span class="navigation-butts" [ngClass]="{'not-active': lastItem >= auditData?.length}" (click)="loadItems('last')"> + <i class="material-icons">last_page</i> + </span> + </span> + </div> + </td> </ng-container> <ng-container matColumnDef="user-filter"> @@ -139,6 +179,7 @@ <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; sticky: true"--> <!-- class="header-row"></tr>--> 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 09b1baa..2daf193 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 @@ -235,3 +235,24 @@ padding-left: 5px; } } + +.selected-items-wrapper{ + display: flex; + align-items: center; + .select-wrapper{ + margin-left: 20px; + width: 80px; + } +} + +.pagination-wrapper{ + display: flex; + align-items: center; + justify-content: space-between; + .navigation-butts{ + cursor: pointer; + .not-active{ + color: lightgray; + } + } +} 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 def6d56..c8e2344 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 @@ -36,6 +36,11 @@ export class AuditGridComponent implements OnInit { public collapseFilterRow: boolean = true; public filterConfiguration: FilterAuditModel = new FilterAuditModel([], [], [], [], '', ''); public filterAuditData: FilterAuditModel = new FilterAuditModel([], [], [], [], '', ''); + public itemsPrPage: Number[] = [25, 50, 100]; + public showItemsPrPage: number = 25; + public firstItem: number = 1; + public lastItem: number = this.showItemsPrPage; + constructor( public dialogRef: MatDialogRef<AuditInfoDialogComponent>, @@ -92,6 +97,26 @@ export class AuditGridComponent implements OnInit { // console.log('Open audit info ' + action.action); this.dialog.open(AuditInfoDialogComponent, { data: {data: element.info, action: element.action}, panelClass: 'modal-sm' }); } + + public setItemsPrPage(item: number) { + this.lastItem = item; + } + + public loadItems(action) { + if (action === 'first') { + this.firstItem = 1; + this.lastItem = this.showItemsPrPage; + } else if (action === 'previous') { + this.firstItem = this.firstItem - this.showItemsPrPage; + this.lastItem = this.lastItem % this.showItemsPrPage === 0 ? this.lastItem - this.showItemsPrPage : this.lastItem - (this.lastItem % this.showItemsPrPage); + } else if (action === 'next') { + this.firstItem = this.firstItem + this.showItemsPrPage; + this.lastItem = (this.lastItem + this.showItemsPrPage) > this.auditData.length ? this.auditData.length : this.lastItem + this.showItemsPrPage; + } else if (action === 'last') { + this.firstItem = this.auditData.length % this.showItemsPrPage === 0 ? this.auditData.length - this.showItemsPrPage : this.auditData.length - (this.auditData.length % this.showItemsPrPage) + 1; + this.lastItem = this.auditData.length; + } + } } @Component({ diff --git a/services/self-service/src/main/resources/webapp/src/assets/styles/_theme.scss b/services/self-service/src/main/resources/webapp/src/assets/styles/_theme.scss index 43e9c50..deb477e 100644 --- a/services/self-service/src/main/resources/webapp/src/assets/styles/_theme.scss +++ b/services/self-service/src/main/resources/webapp/src/assets/styles/_theme.scss @@ -86,11 +86,13 @@ } } + + .selector-wrapper { display: flex; align-self: center; width: 100%; - height: 36px; + height: 25px; padding-left: 10px; font-family: 'Open Sans', sans-serif; font-size: 15px; @@ -130,6 +132,24 @@ } } + +.audit{ + .select-wrapper { + .mat-reset{ + .selector-wrapper{ + height: 25px; + .mat-form-field .mat-form-field-wrapper .mat-form-field-infix{ + padding-top: 5px; + } + .caret { + width: 25px; + height: 31px; + + } + } + } + } +} .multiple-select { border-bottom: 1px solid #dedbdb; padding: 0; @@ -319,7 +339,8 @@ span.mat-slide-toggle-content { .manage-roles, .project-form, -.selection { +.selection, +.audit{ .mat-form-field { width: 100%; } --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
