-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e533c0f
commit 16a9a75
Showing
8 changed files
with
221 additions
and
56 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
projects/dashboards/esg-indicator-service/src/app/quota-log/quota-log.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<div [class.hidden]="details()"> | ||
<table mat-table [dataSource]="source"> | ||
<ng-container matColumnDef="timestamp"> | ||
<th mat-header-cell *matHeaderCellDef>Timestamp</th> | ||
<td mat-cell *matCellDef="let element">{{ element.timestamp.toISOString() }}</td> | ||
</ng-container> | ||
|
||
<ng-container matColumnDef="computationId"> | ||
<th mat-header-cell *matHeaderCellDef>Computation</th> | ||
<td mat-cell *matCellDef="let element">{{ element.computationId }}</td> | ||
</ng-container> | ||
|
||
<ng-container matColumnDef="workflowId"> | ||
<th mat-header-cell *matHeaderCellDef>Workflow</th> | ||
<td mat-cell *matCellDef="let element">{{ element.workflowId }}</td> | ||
</ng-container> | ||
|
||
<ng-container matColumnDef="count"> | ||
<th mat-header-cell *matHeaderCellDef>Count</th> | ||
<td mat-cell *matCellDef="let element">{{ element.count }}</td> | ||
</ng-container> | ||
|
||
<ng-container matColumnDef="details"> | ||
<th mat-header-cell *matHeaderCellDef>Details</th> | ||
<td mat-cell *matCellDef="let element"> | ||
<button class="button" mat-icon-button (click)="showDetails(element)"> | ||
<mat-icon>zoom_in</mat-icon> | ||
</button> | ||
</td> | ||
</ng-container> | ||
|
||
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr> | ||
<tr mat-row *matRowDef="let row; columns: displayedColumns"></tr> | ||
</table> | ||
|
||
<div class="flex-container"> | ||
<button mat-button (click)="setUpSource()"><mat-icon>refresh</mat-icon>Refresh</button> | ||
|
||
<mat-paginator [pageSize]="5" [pageSizeOptions]="[5, 10, 20]"></mat-paginator> | ||
</div> | ||
</div> | ||
|
||
@if (details(); as details) { | ||
<div> | ||
<button class="button" mat-button (click)="hideDetails()"><mat-icon>arrow_back</mat-icon> Back</button> | ||
</div> | ||
<table mat-table [dataSource]="details"> | ||
<ng-container matColumnDef="name"> | ||
<th mat-header-cell *matHeaderCellDef>Operator</th> | ||
<td mat-cell *matCellDef="let element">{{ element.operatorName }}</td> | ||
</ng-container> | ||
|
||
<ng-container matColumnDef="path"> | ||
<th mat-header-cell *matHeaderCellDef>Path</th> | ||
<td mat-cell *matCellDef="let element">{{ element.operatorPath }}</td> | ||
</ng-container> | ||
|
||
<ng-container matColumnDef="count"> | ||
<th mat-header-cell *matHeaderCellDef>Count</th> | ||
<td mat-cell *matCellDef="let element">{{ element.count }}</td> | ||
</ng-container> | ||
|
||
<tr mat-header-row *matHeaderRowDef="displayedDetailsColumns"></tr> | ||
<tr mat-row *matRowDef="let row; columns: displayedDetailsColumns"></tr> | ||
</table> | ||
} | ||
|
||
<mat-progress-bar class="loading-indicator" mode="query" *ngIf="source.loading()"></mat-progress-bar> |
21 changes: 21 additions & 0 deletions
21
projects/dashboards/esg-indicator-service/src/app/quota-log/quota-log.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
:host { | ||
width: 100%; | ||
} | ||
|
||
mat-spinner { | ||
margin: 0.5rem auto; | ||
} | ||
|
||
table { | ||
width: 100%; | ||
} | ||
|
||
.flex-container { | ||
display: flex; | ||
justify-content: space-between; | ||
gap: 1rem; | ||
} | ||
|
||
.hidden { | ||
display: none; | ||
} |
101 changes: 101 additions & 0 deletions
101
projects/dashboards/esg-indicator-service/src/app/quota-log/quota-log.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
import {DataSource} from '@angular/cdk/collections'; | ||
import {AfterViewInit, ChangeDetectionStrategy, Component, signal, ViewChild} from '@angular/core'; | ||
import {Observable, Subject, tap} from 'rxjs'; | ||
import {MatPaginator, MatPaginatorModule} from '@angular/material/paginator'; | ||
import {UserService} from '@geoengine/common'; | ||
import {MatTableModule} from '@angular/material/table'; | ||
import {ComputationQuota, OperatorQuota} from '@geoengine/openapi-client'; | ||
import {MatButtonModule} from '@angular/material/button'; | ||
import {MatProgressBarModule} from '@angular/material/progress-bar'; | ||
import {MatIconModule} from '@angular/material/icon'; | ||
|
||
@Component({ | ||
selector: 'geoengine-quota-log', | ||
templateUrl: './quota-log.component.html', | ||
styleUrl: './quota-log.component.scss', | ||
standalone: true, | ||
imports: [MatTableModule, MatPaginatorModule, MatProgressBarModule, MatButtonModule, MatIconModule], | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
}) | ||
export class QuotaLogComponent implements AfterViewInit { | ||
@ViewChild(MatPaginator) paginator!: MatPaginator; | ||
|
||
readonly loadingSpinnerDiameterPx: number = 3 * parseFloat(getComputedStyle(document.documentElement).fontSize); | ||
|
||
source!: QuotaLogDataSource; | ||
|
||
displayedColumns: string[] = ['timestamp', 'computationId', 'workflowId', 'count', 'details']; | ||
displayedDetailsColumns: string[] = ['name', 'path', 'count']; | ||
|
||
readonly detailsVisible = signal(false); | ||
readonly details = signal<OperatorQuota[] | undefined>(undefined); | ||
|
||
constructor(private readonly userService: UserService) { | ||
this.setUpSource(); | ||
} | ||
|
||
ngAfterViewInit(): void { | ||
this.paginator.page.pipe(tap(() => this.loadQuotaLogsPage())).subscribe(); | ||
} | ||
|
||
async showDetails(element: ComputationQuota): Promise<void> { | ||
this.detailsVisible.set(true); | ||
const quota = await this.userService.computationQuota(element.computationId); | ||
this.details.set(quota); | ||
} | ||
|
||
hideDetails(): void { | ||
this.details.set(undefined); | ||
this.detailsVisible.set(false); | ||
} | ||
|
||
protected loadQuotaLogsPage(): void { | ||
this.source.loadQuotaLogs(this.paginator.pageIndex, this.paginator.pageSize); | ||
} | ||
|
||
protected setUpSource(): void { | ||
this.source = new QuotaLogDataSource(this.userService, this.paginator); | ||
this.source.loadQuotaLogs(0, 5); | ||
} | ||
} | ||
|
||
/** | ||
* A custom data source that allows fetching datasets for a virtual scroll source. | ||
*/ | ||
class QuotaLogDataSource extends DataSource<ComputationQuota> { | ||
readonly loading = signal(false); | ||
|
||
protected quotas$ = new Subject<Array<ComputationQuota>>(); | ||
|
||
constructor( | ||
private userService: UserService, | ||
private paginator: MatPaginator, | ||
) { | ||
super(); | ||
} | ||
|
||
connect(): Observable<Array<ComputationQuota>> { | ||
return this.quotas$.asObservable(); | ||
} | ||
|
||
/** | ||
* Clean up resources | ||
*/ | ||
disconnect(): void { | ||
this.quotas$.complete(); | ||
} | ||
|
||
loadQuotaLogs(pageIndex: number, pageSize: number): void { | ||
this.loading.set(true); | ||
|
||
this.userService.computationsQuota(pageIndex * pageSize, pageSize).then((logs) => { | ||
this.loading.set(false); | ||
if (this.paginator && logs.length === pageSize) { | ||
// we do not know the number of items in total, so instead for each full page set the length to show the "next" button | ||
this.paginator.length = (pageIndex + 1) * pageSize + 1; | ||
} | ||
|
||
this.quotas$.next(logs); | ||
}); | ||
} | ||
} |