diff --git a/apps/web/src/app/tools/reports/pages/weak-passwords-report.component.html b/apps/web/src/app/tools/reports/pages/weak-passwords-report.component.html index 9c5b587e60a..76d4398cc0f 100644 --- a/apps/web/src/app/tools/reports/pages/weak-passwords-report.component.html +++ b/apps/web/src/app/tools/reports/pages/weak-passwords-report.component.html @@ -39,7 +39,13 @@ {{ "owner" | i18n }} - + {{ "weakness" | i18n }} diff --git a/apps/web/src/app/tools/reports/pages/weak-passwords-report.component.ts b/apps/web/src/app/tools/reports/pages/weak-passwords-report.component.ts index c374ecd0e4a..8b781b77378 100644 --- a/apps/web/src/app/tools/reports/pages/weak-passwords-report.component.ts +++ b/apps/web/src/app/tools/reports/pages/weak-passwords-report.component.ts @@ -59,6 +59,7 @@ export class WeakPasswordsReportComponent extends CipherReportComponent implemen this.weakPasswordCiphers = []; this.filterStatus = [0]; this.findWeakPasswords(allCiphers); + this.weakPasswordCiphers = this.sortCiphers(this.weakPasswordCiphers, "score", false); } protected findWeakPasswords(ciphers: CipherView[]): void { @@ -112,6 +113,29 @@ export class WeakPasswordsReportComponent extends CipherReportComponent implemen this.filterCiphersByOrg(this.weakPasswordCiphers); } + onSortChange(field: string, event: Event) { + const target = event.target as HTMLInputElement; + const ascending = target.checked; + this.weakPasswordCiphers = this.sortCiphers(this.weakPasswordCiphers, field, ascending); + } + + protected sortCiphers( + ciphers: ReportResult[], + field: string, + ascending: boolean, + ): ReportResult[] { + return ciphers.sort((a, b) => { + const aValue = a[field as keyof ReportResult]; + const bValue = b[field as keyof ReportResult]; + + if (aValue === bValue) { + return 0; + } + const comparison = aValue > bValue ? 1 : -1; + return ascending ? comparison : -comparison; + }); + } + protected canManageCipher(c: CipherView): boolean { // this will only ever be false from the org view; return true;