mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-07-28 18:24:38 -05:00
skeleton user / group admin dialogs [WIP]
This commit is contained in:
@@ -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 }
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user