hermes-web-angular/src/app/policy-table/policy-table.component.html

69 lines
2.6 KiB
HTML
Raw Normal View History

<table mat-table [dataSource]="policies" class="mat-elevation-z8">
<!--- Note that these columns can be defined in any order.
The actual rendered columns are set as a property on the row definition" -->
<!-- Position Column -->
<ng-container matColumnDef="path">
<th mat-header-cell *matHeaderCellDef>Path</th>
2024-10-25 19:09:34 +00:00
<td mat-cell *matCellDef="let policy">
{{policy.path}}
</td>
</ng-container>
<ng-container matColumnDef="group">
<th mat-header-cell *matHeaderCellDef>Group</th>
<td mat-cell *matCellDef="let policy">
@if (policy.editing) {
2024-10-25 19:09:34 +00:00
<input type="text" [(ngModel)]="policy.temp_group_name" />
}
@if (!policy.editing) {
2024-10-25 19:09:34 +00:00
{{groups[policy.group_id].name}}
}
</td>
</ng-container>
<!-- Name Column -->
<ng-container matColumnDef="usage">
2024-10-25 19:09:34 +00:00
<th mat-header-cell *matHeaderCellDef>Usage per span</th>
<td mat-cell *matCellDef="let policy">
@if (policy.editing) {
<input type="number" [(ngModel)]="policy.usage" (keypress)="($event.charCode >= 48 && $event.charCode < 58)" />
}
@if (!policy.editing) {
{{policy.usage}}
}
</td>
</ng-container>
<!-- Weight Column -->
<ng-container matColumnDef="span">
2024-10-25 19:09:34 +00:00
<th mat-header-cell *matHeaderCellDef>Span (ms)</th>
<td mat-cell *matCellDef="let policy">
@if (policy.editing) {
<input type="number" [(ngModel)]="policy.span" (keypress)="($event.charCode >= 48 && $event.charCode < 58)" />
}
@if (!policy.editing) {
{{policy.span}}
}
</td>
</ng-container>
<!-- Symbol Column -->
<ng-container matColumnDef="actions">
<th mat-header-cell *matHeaderCellDef> Actions </th>
<td mat-cell *matCellDef="let policy">
@if (!policy.editing) {
<button mat-mini-fab (click)="edit(policy)"><mat-icon>edit</mat-icon></button>
<button mat-mini-fab (click)="delete(policy)"><mat-icon>delete</mat-icon></button>
}
@if (policy.editing) {
<button mat-mini-fab (click)="save(policy)"><mat-icon>save</mat-icon></button>
<button mat-mini-fab (click)="cancel(policy)"><mat-icon>cancel</mat-icon></button>
}
</td>
</ng-container>
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
</table>