skeleton user / group admin dialogs [WIP]

This commit is contained in:
Michael Shamoon
2022-11-13 07:23:33 -08:00
parent bf28a512c6
commit c7b46ac861
21 changed files with 515 additions and 34 deletions

View File

@@ -20,7 +20,7 @@ export enum PermissionType {
Log = 'admin.%s_logentry',
MailAccount = 'paperless_mail.%s_mailaccount',
MailRule = 'paperless_mail.%s_mailrule',
Auth = 'auth.%s_user',
User = 'auth.%s_user',
Admin = 'admin.%s_logentry',
}
@@ -46,4 +46,30 @@ export class PermissionsService {
private getPermissionCode(permission: PaperlessPermission): string {
return permission.type.replace('%s', permission.action)
}
public getPermissionKeys(permissionStr: string): {
actionKey: string
typeKey: string
} {
const matches = permissionStr.match(/\.(.+)_/)
let typeKey
let actionKey
if (matches?.length > 0) {
const action = matches[1]
const actionIndex = Object.values(PermissionAction).indexOf(
action as PermissionAction
)
if (actionIndex > -1) {
actionKey = Object.keys(PermissionAction)[actionIndex]
}
const typeIndex = Object.values(PermissionType).indexOf(
permissionStr.replace(action, '%s') as PermissionType
)
if (typeIndex > -1) {
typeKey = Object.keys(PermissionType)[typeIndex]
}
}
return { actionKey, typeKey }
}
}