diff --git a/src-ui/messages.xlf b/src-ui/messages.xlf index 6175cf700..ec718acc6 100644 --- a/src-ui/messages.xlf +++ b/src-ui/messages.xlf @@ -2,6 +2,48 @@ + + Document added + + src/app/app.component.ts + 51 + + + + Document was added to paperless. + + src/app/app.component.ts + 51 + + + + Open document + + src/app/app.component.ts + 51 + + + + Could not add : + + src/app/app.component.ts + 59 + + + + New document detected + + src/app/app.component.ts + 65 + + + + Document is being processed by paperless. + + src/app/app.component.ts + 65 + + Documents @@ -482,35 +524,35 @@ Saved view "" deleted. src/app/components/manage/settings/settings.component.ts - 63 + 67 Settings saved successfully. src/app/components/manage/settings/settings.component.ts - 79 + 87 Use system language src/app/components/manage/settings/settings.component.ts - 83 + 91 Use date format of display language src/app/components/manage/settings/settings.component.ts - 87 + 95 Error while storing settings on server: src/app/components/manage/settings/settings.component.ts - 103 + 111 @@ -531,7 +573,7 @@ Saved views src/app/components/manage/settings/settings.component.html - 114 + 128 @@ -639,60 +681,109 @@ 98 + + Notifications + + src/app/components/manage/settings/settings.component.html + 102 + + + + Consumer status + + src/app/components/manage/settings/settings.component.html + 106 + + + + Show notifications when new documents are detected + + src/app/components/manage/settings/settings.component.html + 109 + + + + Show notifications when document consumption completes successfully + + src/app/components/manage/settings/settings.component.html + 110 + + + + Show notifications when document consumption fails + + src/app/components/manage/settings/settings.component.html + 111 + + + + Suppress notifications on dashboard + + src/app/components/manage/settings/settings.component.html + 112 + + + + This will suppress all consumer related status messages on the dashboard. + + src/app/components/manage/settings/settings.component.html + 112 + + Bulk editing src/app/components/manage/settings/settings.component.html - 102 + 116 Show confirmation dialogs src/app/components/manage/settings/settings.component.html - 106 + 120 Deleting documents will always ask for confirmation. src/app/components/manage/settings/settings.component.html - 106 + 120 Apply on close src/app/components/manage/settings/settings.component.html - 107 + 121 Appears on src/app/components/manage/settings/settings.component.html - 126 + 140 Show on dashboard src/app/components/manage/settings/settings.component.html - 129 + 143 Show in sidebar src/app/components/manage/settings/settings.component.html - 133 + 147 No saved views defined. src/app/components/manage/settings/settings.component.html - 143 + 157 @@ -1323,25 +1414,25 @@ 4 - - The document has been uploaded and will be processed by the consumer shortly. + + Connecting... src/app/components/dashboard/widgets/upload-file-widget/upload-file-widget.component.ts - 63 + 90 - - There was an error while uploading the document: + + Uploading... src/app/components/dashboard/widgets/upload-file-widget/upload-file-widget.component.ts - 71 + 95 - - An error has occurred while uploading the document. Sorry! + + Waiting for consumer... src/app/components/dashboard/widgets/upload-file-widget/upload-file-widget.component.ts - 75 + 98 @@ -1351,25 +1442,32 @@ 1 + + Dismiss completed + + src/app/components/dashboard/widgets/upload-file-widget/upload-file-widget.component.html + 4 + + Drop documents here or src/app/components/dashboard/widgets/upload-file-widget/upload-file-widget.component.html - 5 + 13 Browse files src/app/components/dashboard/widgets/upload-file-widget/upload-file-widget.component.html - 5 + 13 - - {VAR_PLURAL, plural, =1 {Uploading file...} =other {Uploading files...}} + + Open document src/app/components/dashboard/widgets/upload-file-widget/upload-file-widget.component.html - 13 + 40 @@ -1467,42 +1565,42 @@ English (US) src/app/services/settings.service.ts - 74 + 82 German src/app/services/settings.service.ts - 75 + 83 Dutch src/app/services/settings.service.ts - 76 + 84 French src/app/services/settings.service.ts - 77 + 85 Error src/app/services/toast.service.ts - 31 + 35 Information src/app/services/toast.service.ts - 35 + 39 diff --git a/src-ui/src/app/app.component.ts b/src-ui/src/app/app.component.ts index 43c23f2af..836a6f66a 100644 --- a/src-ui/src/app/app.component.ts +++ b/src-ui/src/app/app.component.ts @@ -1,9 +1,9 @@ -import { SettingsService } from './services/settings.service'; +import { SettingsService, SETTINGS_KEYS } from './services/settings.service'; import { Component, OnDestroy, OnInit } from '@angular/core'; import { Router } from '@angular/router'; import { Subscription } from 'rxjs'; import { ConsumerStatusService } from './services/consumer-status.service'; -import { Toast, ToastService } from './services/toast.service'; +import { ToastService } from './services/toast.service'; @Component({ selector: 'app-root', @@ -12,6 +12,7 @@ import { Toast, ToastService } from './services/toast.service'; }) export class AppComponent implements OnInit, OnDestroy { + newDocumentSubscription: Subscription; successSubscription: Subscription; failedSubscription: Subscription; @@ -23,23 +24,47 @@ export class AppComponent implements OnInit, OnDestroy { ngOnDestroy(): void { this.consumerStatusService.disconnect() - this.successSubscription.unsubscribe() - this.failedSubscription.unsubscribe() + if (this.successSubscription) { + this.successSubscription.unsubscribe() + } + if (this.failedSubscription) { + this.failedSubscription.unsubscribe() + } + if (this.newDocumentSubscription) { + this.newDocumentSubscription.unsubscribe() + } + } + + private showNotification(key) { + if (this.router.url == '/dashboard' && this.settings.get(SETTINGS_KEYS.NOTIFICATIONS_CONSUMER_SUPPRESS_ON_DASHBOARD)) { + return false + } + return this.settings.get(key) } ngOnInit(): void { this.consumerStatusService.connect() + this.successSubscription = this.consumerStatusService.onDocumentConsumptionFinished().subscribe(status => { - this.toastService.show({title: "Document added", delay: 10000, content: `Document ${status.filename} was added to paperless.`, actionName: "Open document", action: () => { - this.router.navigate(['documents', status.documentId]) - }}) + 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]) + }}) + } }) this.failedSubscription = this.consumerStatusService.onDocumentConsumptionFailed().subscribe(status => { - this.toastService.showError(`Could not consume ${status.filename}: ${status.message}`) + if (this.showNotification(SETTINGS_KEYS.NOTIFICATIONS_CONSUMER_FAILED)) { + this.toastService.showError($localize`Could not add ${status.filename}\: ${status.message}`) + } }) + this.newDocumentSubscription = this.consumerStatusService.onDocumentDetected().subscribe(status => { + if (this.showNotification(SETTINGS_KEYS.NOTIFICATIONS_CONSUMER_NEW_DOCUMENT)) { + this.toastService.show({title: $localize`New document detected`, delay: 5000, content: $localize`Document ${status.filename} is being processed by paperless.`}) + } + }) } } diff --git a/src-ui/src/app/components/dashboard/widgets/upload-file-widget/upload-file-widget.component.html b/src-ui/src/app/components/dashboard/widgets/upload-file-widget/upload-file-widget.component.html index c8104dae1..a9658bcf7 100644 --- a/src-ui/src/app/components/dashboard/widgets/upload-file-widget/upload-file-widget.component.html +++ b/src-ui/src/app/components/dashboard/widgets/upload-file-widget/upload-file-widget.component.html @@ -1,7 +1,7 @@
+

Notifications

+ +
+
+ Consumer status +
+
+ + + + +
+
+

Bulk editing

diff --git a/src-ui/src/app/components/manage/settings/settings.component.ts b/src-ui/src/app/components/manage/settings/settings.component.ts index 47f714c21..47c7b8d7b 100644 --- a/src-ui/src/app/components/manage/settings/settings.component.ts +++ b/src-ui/src/app/components/manage/settings/settings.component.ts @@ -26,6 +26,10 @@ export class SettingsComponent implements OnInit { 'displayLanguage': new FormControl(this.settings.getLanguage()), 'dateLocale': new FormControl(this.settings.get(SETTINGS_KEYS.DATE_LOCALE)), 'dateFormat': new FormControl(this.settings.get(SETTINGS_KEYS.DATE_FORMAT)), + 'notificationsConsumerNewDocument': new FormControl(this.settings.get(SETTINGS_KEYS.NOTIFICATIONS_CONSUMER_NEW_DOCUMENT)), + 'notificationsConsumerSuccess': new FormControl(this.settings.get(SETTINGS_KEYS.NOTIFICATIONS_CONSUMER_SUCCESS)), + 'notificationsConsumerFailed': new FormControl(this.settings.get(SETTINGS_KEYS.NOTIFICATIONS_CONSUMER_FAILED)), + 'notificationsConsumerSuppressOnDashboard': new FormControl(this.settings.get(SETTINGS_KEYS.NOTIFICATIONS_CONSUMER_SUPPRESS_ON_DASHBOARD)), }) savedViews: PaperlessSavedView[] @@ -73,6 +77,10 @@ export class SettingsComponent implements OnInit { this.settings.set(SETTINGS_KEYS.USE_NATIVE_PDF_VIEWER, this.settingsForm.value.useNativePdfViewer) this.settings.set(SETTINGS_KEYS.DATE_LOCALE, this.settingsForm.value.dateLocale) this.settings.set(SETTINGS_KEYS.DATE_FORMAT, this.settingsForm.value.dateFormat) + this.settings.set(SETTINGS_KEYS.NOTIFICATIONS_CONSUMER_NEW_DOCUMENT, this.settingsForm.value.notificationsConsumerNewDocument) + this.settings.set(SETTINGS_KEYS.NOTIFICATIONS_CONSUMER_SUCCESS, this.settingsForm.value.notificationsConsumerSuccess) + this.settings.set(SETTINGS_KEYS.NOTIFICATIONS_CONSUMER_FAILED, this.settingsForm.value.notificationsConsumerFailed) + this.settings.set(SETTINGS_KEYS.NOTIFICATIONS_CONSUMER_SUPPRESS_ON_DASHBOARD, this.settingsForm.value.notificationsConsumerSuppressOnDashboard) this.settings.setLanguage(this.settingsForm.value.displayLanguage) this.documentListViewService.updatePageSize() this.settings.updateDarkModeSettings() diff --git a/src-ui/src/app/services/consumer-status.service.ts b/src-ui/src/app/services/consumer-status.service.ts index a3c942499..feb04f3d6 100644 --- a/src-ui/src/app/services/consumer-status.service.ts +++ b/src-ui/src/app/services/consumer-status.service.ts @@ -65,19 +65,21 @@ export class ConsumerStatusService { private consumerStatus: FileStatus[] = [] - + private documentDetectedSubject = new Subject() private documentConsumptionFinishedSubject = new Subject() private documentConsumptionFailedSubject = new Subject() private get(taskId: string, filename?: string) { let status = this.consumerStatus.find(e => e.taskId == taskId) || this.consumerStatus.find(e => e.filename == filename && e.taskId == null) + let created = false if (!status) { status = new FileStatus() this.consumerStatus.push(status) + created = true } status.taskId = taskId status.filename = filename - return status + return {'status': status, 'created': created} } newFileUpload(filename: string): FileStatus { @@ -101,11 +103,17 @@ export class ConsumerStatusService { this.statusWebSocked.onmessage = (ev) => { let statusMessage: WebsocketConsumerStatusMessage = JSON.parse(ev['data']) - let status = this.get(statusMessage.task_id, statusMessage.filename) + let statusMessageGet = this.get(statusMessage.task_id, statusMessage.filename) + let status = statusMessageGet.status + let created = statusMessageGet.created + status.updateProgress(FileStatusPhase.PROCESSING, statusMessage.current_progress, statusMessage.max_progress) status.message = statusMessage.message status.documentId = statusMessage.document_id + if (created && statusMessage.status == 'STARTING') { + this.documentDetectedSubject.next(status) + } if (statusMessage.status == "SUCCESS") { status.phase = FileStatusPhase.SUCCESS this.documentConsumptionFinishedSubject.next(status) @@ -150,4 +158,8 @@ export class ConsumerStatusService { return this.documentConsumptionFailedSubject } + onDocumentDetected() { + return this.documentDetectedSubject + } + } diff --git a/src-ui/src/app/services/settings.service.ts b/src-ui/src/app/services/settings.service.ts index 041fb51ca..f3e437ada 100644 --- a/src-ui/src/app/services/settings.service.ts +++ b/src-ui/src/app/services/settings.service.ts @@ -23,7 +23,11 @@ export const SETTINGS_KEYS = { DARK_MODE_ENABLED: 'general-settings:dark-mode:enabled', USE_NATIVE_PDF_VIEWER: 'general-settings:document-details:native-pdf-viewer', DATE_LOCALE: 'general-settings:date-display:date-locale', - DATE_FORMAT: 'general-settings:date-display:date-format' + DATE_FORMAT: 'general-settings:date-display:date-format', + NOTIFICATIONS_CONSUMER_NEW_DOCUMENT: 'general-settings:notifications:consumer-new-documents', + NOTIFICATIONS_CONSUMER_SUCCESS: 'general-settings:notifications:consumer-success', + NOTIFICATIONS_CONSUMER_FAILED: 'general-settings:notifications:consumer-failed', + NOTIFICATIONS_CONSUMER_SUPPRESS_ON_DASHBOARD: 'general-settings:notifications:consumer-suppress-on-dashboard', } const SETTINGS: PaperlessSettings[] = [ @@ -34,7 +38,11 @@ const SETTINGS: PaperlessSettings[] = [ {key: SETTINGS_KEYS.DARK_MODE_ENABLED, type: "boolean", default: false}, {key: SETTINGS_KEYS.USE_NATIVE_PDF_VIEWER, type: "boolean", default: false}, {key: SETTINGS_KEYS.DATE_LOCALE, type: "string", default: ""}, - {key: SETTINGS_KEYS.DATE_FORMAT, type: "string", default: "mediumDate"} + {key: SETTINGS_KEYS.DATE_FORMAT, type: "string", default: "mediumDate"}, + {key: SETTINGS_KEYS.NOTIFICATIONS_CONSUMER_NEW_DOCUMENT, type: "boolean", default: true}, + {key: SETTINGS_KEYS.NOTIFICATIONS_CONSUMER_SUCCESS, type: "boolean", default: true}, + {key: SETTINGS_KEYS.NOTIFICATIONS_CONSUMER_FAILED, type: "boolean", default: true}, + {key: SETTINGS_KEYS.NOTIFICATIONS_CONSUMER_SUPPRESS_ON_DASHBOARD, type: "boolean", default: true}, ] @Injectable({