mirror of
https://github.com/GNS3/gns3-web-ui.git
synced 2025-06-11 11:41:35 +00:00
group management, add sort on all columns
This commit is contained in:
parent
596a11210f
commit
2e2a59f6f2
@ -23,19 +23,19 @@
|
|||||||
</ng-container>
|
</ng-container>
|
||||||
|
|
||||||
<ng-container matColumnDef="created_at">
|
<ng-container matColumnDef="created_at">
|
||||||
<th mat-header-cell *matHeaderCellDef> Creation date</th>
|
<th mat-header-cell *matHeaderCellDef mat-sort-header> Creation date</th>
|
||||||
<td mat-cell *matCellDef="let element"> {{element.created_at}} </td>
|
<td mat-cell *matCellDef="let element"> {{element.created_at}} </td>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
|
||||||
|
|
||||||
<ng-container matColumnDef="updated_at">
|
<ng-container matColumnDef="updated_at">
|
||||||
<th mat-header-cell *matHeaderCellDef> last update</th>
|
<th mat-header-cell *matHeaderCellDef mat-sort-header> last update</th>
|
||||||
<td mat-cell *matCellDef="let element"> {{element.updated_at}} </td>
|
<td mat-cell *matCellDef="let element"> {{element.updated_at}} </td>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
|
||||||
|
|
||||||
<ng-container matColumnDef="is_builtin">
|
<ng-container matColumnDef="is_builtin">
|
||||||
<th mat-header-cell *matHeaderCellDef> is build in</th>
|
<th mat-header-cell *matHeaderCellDef mat-sort-header> is build in</th>
|
||||||
<td mat-cell *matCellDef="let element"> {{element.is_builtin}} </td>
|
<td mat-cell *matCellDef="let element"> {{element.is_builtin}} </td>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
|
||||||
|
@ -66,13 +66,20 @@ export class GroupManagementComponent implements OnInit {
|
|||||||
const isAsc = sort.direction === 'asc';
|
const isAsc = sort.direction === 'asc';
|
||||||
switch (sort.active) {
|
switch (sort.active) {
|
||||||
case 'name':
|
case 'name':
|
||||||
return compare(a.name, b.name, isAsc);
|
return compare(a.name.toLowerCase(), b.name.toLowerCase(), isAsc);
|
||||||
|
case 'created_at':
|
||||||
|
return compare(a.created_at, b.created_at, isAsc);
|
||||||
|
case 'updated_at':
|
||||||
|
return compare(a.updated_at, b.updated_at, isAsc);
|
||||||
|
case 'is_builtin':
|
||||||
|
return compare(a.is_builtin.toString(), b.is_builtin.toString(), isAsc);
|
||||||
default:
|
default:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
function compare(a: number | string, b: number | string, isAsc: boolean) {
|
function compare(a: number | string, b: number | string, isAsc: boolean) {
|
||||||
|
|
||||||
return (a < b ? -1 : 1) * (isAsc ? 1 : -1);
|
return (a < b ? -1 : 1) * (isAsc ? 1 : -1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user