feat: reflect django permissions on UI

This commit is contained in:
Kaaybi
2022-11-11 18:33:04 +00:00
parent 1dc271723c
commit 4603813896
24 changed files with 301 additions and 113 deletions

View File

@@ -74,15 +74,27 @@ export class AppComponent implements OnInit, OnDestroy {
if (
this.showNotification(SETTINGS_KEYS.NOTIFICATIONS_CONSUMER_SUCCESS)
) {
this.toastService.show({
title: $localize`Document added`,
delay: 10000,
content: $localize`Document ${status.filename} was added to paperless.`,
actionName: $localize`Open document`,
action: () => {
this.router.navigate(['documents', status.documentId])
},
// TODO - Is this the only way to allow/disallow from permissions?
var canOpenDocuments = false
this.settings.permissions().subscribe((perm) => {
canOpenDocuments = perm.includes('documents.view_document')
})
if (canOpenDocuments)
this.toastService.show({
title: $localize`Document added`,
delay: 10000,
content: $localize`Document ${status.filename} was added to paperless.`,
actionName: $localize`Open document`,
action: () => {
this.router.navigate(['documents', status.documentId])
},
})
else
this.toastService.show({
title: $localize`Document added`,
delay: 10000,
content: $localize`Document ${status.filename} was added to paperless.`,
})
}
})
@@ -199,7 +211,12 @@ export class AppComponent implements OnInit, OnDestroy {
}
public get dragDropEnabled(): boolean {
return !this.router.url.includes('dashboard')
// TODO - Is this the only way to allow/disallow from permissions?
var canAddDocuments = false
this.settings.permissions().subscribe((perm) => {
canAddDocuments = perm.includes('documents.add_document')
})
return !this.router.url.includes('dashboard') && canAddDocuments
}
public fileOver() {