Skip to content

Commit

Permalink
Improve copy result output
Browse files Browse the repository at this point in the history
- With the improved output, it should be possible to make sense of the resulting numbers
  • Loading branch information
d22 committed Feb 13, 2024
1 parent 821b402 commit 070a91a
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 14 deletions.
30 changes: 30 additions & 0 deletions cloudapp/src/app/components/result/result.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,26 @@
<p>
{{ 'main.results.copyInfo' | translate }}
</p>
<mat-expansion-panel>
<mat-expansion-panel-header>
<mat-panel-title>
{{ 'main.results.rolesSelectedToCopyTitle' | translate : {count: copyResult.rolesSelectedToCopy.length} }}
</mat-panel-title>
</mat-expansion-panel-header>
<ul *ngFor="let role of copyResult.rolesSelectedToCopy">
<li><app-role-output [userRole]="role"></app-role-output></li>
</ul>
</mat-expansion-panel>
<mat-expansion-panel>
<mat-expansion-panel-header>
<mat-panel-title>
{{ 'main.results.skippedDuplicateRolesTitle' | translate : {count: copyResult.skippedDuplicateRoles.length} }}
</mat-panel-title>
</mat-expansion-panel-header>
<ul *ngFor="let role of copyResult.skippedDuplicateRoles">
<li><app-role-output [userRole]="role"></app-role-output></li>
</ul>
</mat-expansion-panel>
<mat-expansion-panel>
<mat-expansion-panel-header>
<mat-panel-title>
Expand All @@ -28,6 +48,16 @@
<li><app-role-output [userRole]="role"></app-role-output></li>
</ul>
</mat-expansion-panel>
<mat-expansion-panel>
<mat-expansion-panel-header>
<mat-panel-title>
{{ 'main.results.copiedRolesTitle' | translate : {count: copyResult.copiedRoles.length} }}
</mat-panel-title>
</mat-expansion-panel-header>
<ul *ngFor="let role of copyResult.copiedRoles">
<li><app-role-output [userRole]="role"></app-role-output></li>
</ul>
</mat-expansion-panel>
<mat-expansion-panel>
<mat-expansion-panel-header>
<mat-panel-title>
Expand Down
26 changes: 23 additions & 3 deletions cloudapp/src/app/services/userRoles.service.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Injectable } from '@angular/core'
import { from, Observable, of } from 'rxjs'
import { catchError, mergeMap, switchMap } from 'rxjs/operators'
import { catchError, map, mergeMap, switchMap } from 'rxjs/operators'
import { ValidationInfo } from '../models/validationInfo'
import { CompareResult } from '../types/compareResult.type'
import { CopyResult } from '../types/copyResult.type'
Expand All @@ -20,11 +20,22 @@ export class UserRolesService {
private arrayHelper: ArrayHelperService) { }

copy(sourceUser: UserDetailsChecked, selectedRoles: UserRole[], targetUser: UserDetails, replaceExistingRoles: boolean): Observable<CopyResult> {
let copyResult: Observable<CopyResult>
if (sourceUser.rolesValid) {
return this.copyValidRoles(selectedRoles, targetUser, replaceExistingRoles)
copyResult = this.copyValidRoles(selectedRoles, targetUser, replaceExistingRoles)
} else {
return this.copyOneByOne(selectedRoles, targetUser, replaceExistingRoles)
copyResult = this.copyOneByOne(selectedRoles, targetUser, replaceExistingRoles)
}

copyResult = copyResult.pipe(
map(copyResult => {
const duplicates: UserRole[] = this.arrayHelper.findDuplicates(sourceUser.user_role)
copyResult.skippedDuplicateRoles = this.arrayHelper.intersection(selectedRoles, duplicates)
return copyResult
})
)

return copyResult
}

compare(sourceUser: UserDetailsChecked, targetUser: UserDetails): Observable<CompareResult> {
Expand Down Expand Up @@ -61,8 +72,11 @@ export class UserRolesService {
.pipe(
switchMap(userDetails => {
let copyResult: CopyResult = {
rolesSelectedToCopy: selectedRoles,
validRoles: targetUser.user_role,
copiedRoles: selectedRoles,
invalidRoles: [],
skippedDuplicateRoles: [],
targetUser: userDetails
}
return of(copyResult)
Expand Down Expand Up @@ -95,8 +109,11 @@ export class UserRolesService {
.pipe(
switchMap(userDetails => {
let copyResult: CopyResult = {
rolesSelectedToCopy: selectedRoles,
validRoles: roleState.valid,
invalidRoles: roleState.invalid,
copiedRoles: this.arrayHelper.removeItems(selectedRoles, roleState.invalid),
skippedDuplicateRoles: [],
targetUser: userDetails
}
return of(copyResult)
Expand All @@ -108,8 +125,11 @@ export class UserRolesService {
return this.userService.updateUser(targetUser).pipe(
switchMap(userDetails => {
let copyResult: CopyResult = {
rolesSelectedToCopy: selectedRoles,
validRoles: [],
invalidRoles: [],
copiedRoles: [],
skippedDuplicateRoles: roles,
targetUser: userDetails
}
return of(copyResult)
Expand Down
3 changes: 3 additions & 0 deletions cloudapp/src/app/types/copyResult.type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ import { UserDetails } from './userDetails.type'
import { UserRole } from './userRole.type'

export type CopyResult = {
rolesSelectedToCopy: UserRole[]
validRoles: UserRole[]
invalidRoles: UserRole[]
skippedDuplicateRoles: UserRole[]
copiedRoles: UserRole[]
targetUser: UserDetails
}
11 changes: 7 additions & 4 deletions cloudapp/src/i18n/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,20 @@
"replaceExistingRolesCheckboxLabel": "Bestehende Rollen ersetzen",
"resetButton": "Zurücksetzen",
"results": {
"copyInfo": "Falls diese Zahlen nicht korrekt aussehen, vergleichen sie die Rollen von Ziel und Quelle, um zu sehen, ob die Quelle Duplikate hat. Doppelte Rollen werden beim Kopieren reduziert.",
"copiedRolesTitle": "Tatsächlich kopierte Rollen: {{count}}",
"copyInfo": "Falls diese Zahlen nicht korrekt aussehen, nutzen sie die 'Vergleichen Funktion', um zu sehen, ob die Quelle Duplikate hat. Doppelte Rollen werden beim Kopieren reduziert.",
"intersection": "Überschneidung ({{count}})",
"invalidRolesTitle": "Ungültige Rollen, ausgelassen: {{count}}",
"noneYet": "Noch keine Ergebnisse",
"onlyInSoure": "Nur Quelle ({{count}})",
"onlyInTarget": "Nur Ziel ({{count}})",
"ready": "Resultate bereit",
"rolesSelectedToCopyTitle": "Gewählt für Kopie: {{count}}",
"skippedDuplicateRolesTitle": "Duplikate, ausgelassen: {{count}}",
"sourceDuplicates": "Duplikate auf Quelle ({{count}})",
"targetDuplicates": "Duplikate auf Ziel({{count}})",
"title": "Ergebnisse",
"validRolesTitle": "Gültige Rollen, kopiert: {{count}}"
"validRolesTitle": "Gültige Rollen, auf Ziel: {{count}}"
},
"rolesCopyToTargetInfo": "Rollen werden auf diesen Benutzer kopiert",
"searchUserInfo": "Benutzer Suchen",
Expand All @@ -70,9 +73,9 @@
"userIsNotAllowedInfo": "Sie haben nicht die nötigen Zugriffsrechte um die App zu verwenden."
},
"roleSelect": {
"deselectAll": "Alle abwählen",
"rolesSelected": "Gewählte Rollen",
"selectAll": "Alle auswählen",
"deselectAll": "Alle abwählen"
"selectAll": "Alle auswählen"
},
"validationDialog": {
"abortButtonLabel": "Abbrechen",
Expand Down
17 changes: 10 additions & 7 deletions cloudapp/src/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,20 @@
"replaceExistingRolesCheckboxLabel": "Replace existing roles",
"resetButton": "Reset",
"results": {
"copyInfo": "If this numbers seem incorrect, compare the roles of the users to see if the source user has duplicate roles. Duplicate roles are reduced during copying.",
"copiedRolesTitle": "Effectively copied roles: {{count}}",
"copyInfo": "If this numbers seem incorrect, use the 'compare function' to check if the source user has duplicate roles. Duplicate roles are reduced during copying.",
"intersection": "Intersection ({{count}})",
"invalidRolesTitle": "Invalid roles, skipped: {{count}}",
"noneYet": "perform action to see results",
"onlyInSoure": "Only on source ({{count}})",
"onlyInTarget": "Only on target ({{count}})",
"ready": "results ready",
"rolesSelectedToCopyTitle": "Selected to copy: {{count}}",
"skippedDuplicateRolesTitle": "Duplicate roles, skipped: {{count}}",
"sourceDuplicates": "Duplicates on source ({{count}})",
"targetDuplicates": "Duplicates on target ({{count}})",
"title": "Results",
"validRolesTitle": "Valid roles, copied: {{count}}"
"validRolesTitle": "Valid roles on target: {{count}}"
},
"rolesCopyToTargetInfo": "Roles will be copied to this user",
"searchUserInfo": "Search for a user",
Expand All @@ -69,11 +72,11 @@
"userIsNotAllowed": "Permission denied",
"userIsNotAllowedInfo": "You don't have the permission to use this app."
},
"roleSelect": {
"rolesSelected": "Selected roles",
"selectAll": "Select all",
"deselectAll": "Deselect all"
},
"roleSelect": {
"deselectAll": "Deselect all",
"rolesSelected": "Selected roles",
"selectAll": "Select all"
},
"validationDialog": {
"abortButtonLabel": "Cancel",
"introText": "Validation of roles failed: Not all roles of this user are valid.",
Expand Down

0 comments on commit 070a91a

Please sign in to comment.