Improve idle style of table

master
Max Ehrlicher-Schmidt 4 years ago
parent 33c859b4f1
commit a5826311ca

@ -63,6 +63,8 @@
showFirstLastButtons showFirstLastButtons
></mat-paginator> ></mat-paginator>
</div> </div>
<!-- Table -->
<div class="table-container"> <div class="table-container">
<table <table
mat-table mat-table
@ -72,6 +74,7 @@
cdkDropListOrientation="horizontal" cdkDropListOrientation="horizontal"
(cdkDropListDropped)="drop($event)" (cdkDropListDropped)="drop($event)"
[dataSource]="data" [dataSource]="data"
[ngClass]="{ 'idle-overlay': !isLoaded }"
> >
<!--- Note that these columns can be defined in any order. <!--- Note that these columns can be defined in any order.
The actual rendered columns are set as a property on the row definition" --> The actual rendered columns are set as a property on the row definition" -->
@ -361,14 +364,16 @@
*matHeaderRowDef="displayedColumns; sticky: true" *matHeaderRowDef="displayedColumns; sticky: true"
#headerRow #headerRow
></tr> ></tr>
<tr mat-row *matRowDef="let row; columns: displayedColumns"></tr> <tr
[ngClass]="{ 'idle-overlay': isProcessing }"
mat-row
*matRowDef="let row; columns: displayedColumns"
></tr>
</table> </table>
<mat-card
*ngIf="!isLoaded"
style="display: flex; justify-content: center; align-items: center"
>
<mat-spinner [diameter]="32"></mat-spinner>
</mat-card>
</div> </div>
<mat-spinner
class="idle-spinner"
*ngIf="!isLoaded || isProcessing"
[diameter]="48"
></mat-spinner>
</div> </div>

@ -26,8 +26,17 @@
margin-right: 0.5em; margin-right: 0.5em;
} }
} }
.idle-overlay {
filter: blur(5px);
}
.idle-spinner {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
z-index: 999;
}
.table-container { .table-container {
flex: 1;
width: auto; width: auto;
margin-left: 0.5em; margin-left: 0.5em;
margin-right: 0.5em; margin-right: 0.5em;
@ -69,4 +78,4 @@
} }
} }
} }
} }

@ -92,6 +92,7 @@ export class TableComponent implements AfterViewInit {
filterChanged: Subject<any> = new Subject<any>(); filterChanged: Subject<any> = new Subject<any>();
isLoaded = false; isLoaded = false;
isProcessing = false;
@Output() createEvent = new EventEmitter(); @Output() createEvent = new EventEmitter();
@Output() lockEvent = new EventEmitter(); @Output() lockEvent = new EventEmitter();
@ -151,11 +152,11 @@ export class TableComponent implements AfterViewInit {
}); });
this.dataService.tableData.subscribe((newTableDataSource) => { this.dataService.tableData.subscribe((newTableDataSource) => {
this.reloadingTable = false;
const tempDataSource = []; const tempDataSource = [];
if (newTableDataSource === null) { if (newTableDataSource === null) {
return; return;
} }
this.reloadingTable = false;
this.isLoaded = true; this.isLoaded = true;
for (const row of newTableDataSource) { for (const row of newTableDataSource) {
const oldRow = this.getRowById(row.id); const oldRow = this.getRowById(row.id);
@ -427,10 +428,10 @@ export class TableComponent implements AfterViewInit {
} }
applyFilters(): void { applyFilters(): void {
this.isLoaded = false; this.isProcessing = true;
setTimeout(() => { setTimeout(() => {
this.data.filter = (this.filters as unknown) as string; this.data.filter = (this.filters as unknown) as string;
this.isLoaded = true; this.isProcessing = false;
}); });
} }

Loading…
Cancel
Save