Skip to content

Commit 8418521

Browse files
authored
feat(gui): added sort by affiliation to admin dashboard (apache#4150)
### What changes were proposed in this PR? This PR introduces sorting by affiliation to admin dashboard. In PR apache#4113 we introduced a new field `afiiliation` to `user` table. To allow admins to sort by affiliation to quickly navigate through users with affiliation, we added the sort by affiliation feature to the admin dashboard. It uses the same comparison logic as other sort functions. ### Any related issues, documentation, discussions? <!-- Please use this section to link other resources if not mentioned already. 1. If this PR fixes an issue, please include `Fixes apache#1234`, `Resolves apache#1234` or `Closes apache#1234`. If it is only related, simply mention the issue number. 2. If there is design documentation, please add the link. 3. If there is a discussion in the mailing list, please add the link. --> Improves apache#4118. ### Sample screenshot <img width="1796" height="1226" alt="image" src="https://github.com/user-attachments/assets/d6310e37-e58a-4df1-bfe4-af5959995ebb" /> ### How was this PR tested? <!-- If tests were added, say they were added here. Or simply mention that if the PR is tested with existing test cases. Make sure to include/update test cases that check the changes thoroughly including negative and positive cases if possible. If it was tested in a way different from regular unit tests, please clarify how you tested step by step, ideally copy and paste-able, so that other reviewers can test and check, and descendants can verify in the future. If tests were not added, please describe why they were not added and/or why it was difficult to add. --> Manually tested. ### Was this PR authored or co-authored using generative AI tooling? <!-- If generative AI tooling has been used in the process of authoring this PR, please include the phrase: 'Generated-by: ' followed by the name of the tool and its version. If no, write 'No'. Please refer to the [ASF Generative Tooling Guidance](https://www.apache.org/legal/generative-tooling.html) for details. --> No.
1 parent 62af7a3 commit 8418521

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

‎frontend/src/app/dashboard/component/admin/user/admin-user.component.html‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,11 @@
6969
nzType="search"></span>
7070
</nz-filter-trigger>
7171
</th>
72-
<th>Affiliation</th>
72+
<th
73+
[nzSortFn]="sortByAffiliation"
74+
[nzSortDirections]="['ascend', 'descend']">
75+
Affiliation
76+
</th>
7377
<th
7478
[nzSortFn]="sortByComment"
7579
[nzSortDirections]="['ascend', 'descend']"

‎frontend/src/app/dashboard/component/admin/user/admin-user.component.ts‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,11 @@ export class AdminUserComponent implements OnInit {
187187
return compare === 0 ? a.uid - b.uid : compare;
188188
};
189189

190+
public sortByAffiliation: NzTableSortFn<User> = (a: User, b: User) => {
191+
const compare = (b.affiliation || "").localeCompare(a.affiliation || "");
192+
return compare === 0 ? a.uid - b.uid : compare;
193+
};
194+
190195
reset(): void {
191196
this.nameSearchValue = "";
192197
this.emailSearchValue = "";

0 commit comments

Comments
 (0)