diff --git a/src-ui/messages.xlf b/src-ui/messages.xlf index 58d8d0d4c..804a04774 100644 --- a/src-ui/messages.xlf +++ b/src-ui/messages.xlf @@ -612,42 +612,42 @@ Error retrieving config src/app/components/admin/config/config.component.ts - 103 + 104 Invalid JSON src/app/components/admin/config/config.component.ts - 129 + 132 Configuration updated src/app/components/admin/config/config.component.ts - 173 + 176 An error occurred updating configuration src/app/components/admin/config/config.component.ts - 178 + 181 File successfully updated src/app/components/admin/config/config.component.ts - 200 + 204 An error occurred uploading file src/app/components/admin/config/config.component.ts - 205 + 210 @@ -1375,7 +1375,7 @@ 340 - src/app/components/app-frame/toasts-dropdown/toasts-dropdown.component.html + src/app/components/app-frame/notifications-dropdown/notifications-dropdown.component.html 11 @@ -1500,64 +1500,64 @@ Use system language src/app/components/admin/settings/settings.component.ts - 76 + 79 Use date format of display language src/app/components/admin/settings/settings.component.ts - 79 + 82 Error retrieving users src/app/components/admin/settings/settings.component.ts - 220 + 224 src/app/components/admin/users-groups/users-groups.component.ts - 59 + 60 Error retrieving groups src/app/components/admin/settings/settings.component.ts - 239 + 246 src/app/components/admin/users-groups/users-groups.component.ts - 71 + 75 Settings were saved successfully. src/app/components/admin/settings/settings.component.ts - 535 + 544 Settings were saved successfully. Reload is required to apply some changes. src/app/components/admin/settings/settings.component.ts - 539 + 548 Reload now src/app/components/admin/settings/settings.component.ts - 540 + 549 An error occurred while saving settings. src/app/components/admin/settings/settings.component.ts - 550 + 559 src/app/components/app-frame/app-frame.component.ts @@ -2222,23 +2222,23 @@ src/app/components/admin/users-groups/users-groups.component.ts - 124 + 130 src/app/components/admin/users-groups/users-groups.component.ts - 177 + 187 src/app/components/manage/custom-fields/custom-fields.component.ts - 108 + 110 src/app/components/manage/mail/mail.component.ts - 195 + 200 src/app/components/manage/mail/mail.component.ts - 296 + 303 src/app/components/manage/management-list/management-list.component.ts @@ -2490,66 +2490,66 @@ Password has been changed, you will be logged out momentarily. src/app/components/admin/users-groups/users-groups.component.ts - 97 + 103 src/app/components/common/profile-edit-dialog/profile-edit-dialog.component.ts - 198 + 200 Saved user "". src/app/components/admin/users-groups/users-groups.component.ts - 104 + 110 Error saving user. src/app/components/admin/users-groups/users-groups.component.ts - 114 + 120 Confirm delete user account src/app/components/admin/users-groups/users-groups.component.ts - 122 + 128 This operation will permanently delete this user account. src/app/components/admin/users-groups/users-groups.component.ts - 123 + 129 Proceed src/app/components/admin/users-groups/users-groups.component.ts - 126 + 132 src/app/components/admin/users-groups/users-groups.component.ts - 179 + 189 src/app/components/document-detail/document-detail.component.ts - 958 + 964 src/app/components/document-detail/document-detail.component.ts - 1318 + 1324 src/app/components/document-detail/document-detail.component.ts - 1357 + 1363 src/app/components/document-detail/document-detail.component.ts - 1398 + 1404 src/app/components/document-list/bulk-editor/bulk-editor.component.ts @@ -2565,15 +2565,15 @@ src/app/components/manage/custom-fields/custom-fields.component.ts - 110 + 112 src/app/components/manage/mail/mail.component.ts - 197 + 202 src/app/components/manage/mail/mail.component.ts - 298 + 305 src/app/components/manage/management-list/management-list.component.ts @@ -2588,56 +2588,56 @@ Deleted user "" src/app/components/admin/users-groups/users-groups.component.ts - 132 + 139 Error deleting user "". src/app/components/admin/users-groups/users-groups.component.ts - 139 + 147 Saved group "". src/app/components/admin/users-groups/users-groups.component.ts - 159 + 168 Error saving group. src/app/components/admin/users-groups/users-groups.component.ts - 167 + 177 Confirm delete user group src/app/components/admin/users-groups/users-groups.component.ts - 175 + 185 This operation will permanently delete this user group. src/app/components/admin/users-groups/users-groups.component.ts - 176 + 186 Deleted group "" src/app/components/admin/users-groups/users-groups.component.ts - 185 + 196 Error deleting group "". src/app/components/admin/users-groups/users-groups.component.ts - 192 + 204 @@ -2915,14 +2915,14 @@ Error updating sidebar views src/app/components/app-frame/app-frame.component.ts - 248 + 249 An error occurred while saving update checking settings. src/app/components/app-frame/app-frame.component.ts - 269 + 272 @@ -3092,35 +3092,35 @@ Successfully updated object. src/app/components/app-frame/global-search/global-search.component.ts - 209 + 210 src/app/components/app-frame/global-search/global-search.component.ts - 247 + 253 Error occurred saving object. src/app/components/app-frame/global-search/global-search.component.ts - 212 + 215 src/app/components/app-frame/global-search/global-search.component.ts - 250 + 258 Clear All - src/app/components/app-frame/toasts-dropdown/toasts-dropdown.component.html + src/app/components/app-frame/notifications-dropdown/notifications-dropdown.component.html 16 No notifications - src/app/components/app-frame/toasts-dropdown/toasts-dropdown.component.html + src/app/components/app-frame/notifications-dropdown/notifications-dropdown.component.html 20 @@ -3157,7 +3157,7 @@ src/app/components/document-detail/document-detail.component.ts - 911 + 914 src/app/components/document-list/bulk-editor/bulk-editor.component.ts @@ -3318,22 +3318,22 @@ Saved field "". src/app/components/common/custom-fields-dropdown/custom-fields-dropdown.component.ts - 126 + 127 src/app/components/manage/custom-fields/custom-fields.component.ts - 89 + 90 Error saving field. src/app/components/common/custom-fields-dropdown/custom-fields-dropdown.component.ts - 135 + 137 src/app/components/manage/custom-fields/custom-fields.component.ts - 98 + 100 @@ -3395,7 +3395,7 @@ src/app/components/document-detail/document-detail.component.ts - 1375 + 1381 src/app/guards/dirty-saved-view.guard.ts @@ -4099,6 +4099,10 @@ src/app/components/common/edit-dialog/workflow-edit-dialog/workflow-edit-dialog.component.html 111 + + src/app/components/common/notification/notification.component.html + 30 + src/app/components/common/system-status-dialog/system-status-dialog.component.html 175 @@ -4111,10 +4115,6 @@ src/app/components/common/system-status-dialog/system-status-dialog.component.html 243 - - src/app/components/common/toast/toast.component.html - 30 - Only process attachments @@ -4523,11 +4523,11 @@ Totp deactivation failed src/app/components/common/edit-dialog/user-edit-dialog/user-edit-dialog.component.ts - 134 + 135 src/app/components/common/edit-dialog/user-edit-dialog/user-edit-dialog.component.ts - 139 + 142 @@ -5137,7 +5137,7 @@ Error emailing document src/app/components/common/email-document-dialog/email-document-dialog.component.ts - 69 + 70 @@ -5452,6 +5452,32 @@ 41 + + Status + + src/app/components/common/notification/notification.component.html + 28 + + + src/app/components/common/system-status-dialog/system-status-dialog.component.html + 47 + + + src/app/components/manage/mail/mail.component.html + 114 + + + src/app/components/manage/workflows/workflows.component.html + 19 + + + + Copy Raw Error + + src/app/components/common/notification/notification.component.html + 43 + + Read more @@ -5777,71 +5803,71 @@ Profile updated successfully src/app/components/common/profile-edit-dialog/profile-edit-dialog.component.ts - 195 + 196 Error saving profile src/app/components/common/profile-edit-dialog/profile-edit-dialog.component.ts - 207 + 210 Error generating auth token src/app/components/common/profile-edit-dialog/profile-edit-dialog.component.ts - 224 + 229 Error disconnecting social account src/app/components/common/profile-edit-dialog/profile-edit-dialog.component.ts - 249 + 254 Error fetching TOTP settings src/app/components/common/profile-edit-dialog/profile-edit-dialog.component.ts - 268 + 273 TOTP activated successfully src/app/components/common/profile-edit-dialog/profile-edit-dialog.component.ts - 289 + 295 Error activating TOTP src/app/components/common/profile-edit-dialog/profile-edit-dialog.component.ts - 291 + 298 src/app/components/common/profile-edit-dialog/profile-edit-dialog.component.ts - 297 + 305 TOTP deactivated successfully src/app/components/common/profile-edit-dialog/profile-edit-dialog.component.ts - 313 + 324 Error deactivating TOTP src/app/components/common/profile-edit-dialog/profile-edit-dialog.component.ts - 315 + 328 src/app/components/common/profile-edit-dialog/profile-edit-dialog.component.ts - 320 + 335 @@ -5933,14 +5959,14 @@ Error deleting link src/app/components/common/share-links-dialog/share-links-dialog.component.ts - 133 + 134 Error creating link src/app/components/common/share-links-dialog/share-links-dialog.component.ts - 161 + 166 @@ -5999,25 +6025,6 @@ 41 - - Status - - src/app/components/common/system-status-dialog/system-status-dialog.component.html - 47 - - - src/app/components/common/toast/toast.component.html - 28 - - - src/app/components/manage/mail/mail.component.html - 114 - - - src/app/components/manage/workflows/workflows.component.html - 19 - - Migration Status @@ -6131,13 +6138,6 @@ 241 - - Copy Raw Error - - src/app/components/common/toast/toast.component.html - 43 - - Hello , welcome to @@ -6163,7 +6163,7 @@ Error updating dashboard src/app/components/dashboard/dashboard.component.ts - 93 + 94 @@ -6868,21 +6868,21 @@ Error saving document src/app/components/document-detail/document-detail.component.ts - 880 + 881 Do you really want to move the document "" to the trash? src/app/components/document-detail/document-detail.component.ts - 912 + 915 Documents can be restored prior to permanent deletion. src/app/components/document-detail/document-detail.component.ts - 913 + 916 src/app/components/document-list/bulk-editor/bulk-editor.component.ts @@ -6893,7 +6893,7 @@ Move to trash src/app/components/document-detail/document-detail.component.ts - 915 + 918 src/app/components/document-list/bulk-editor/bulk-editor.component.ts @@ -6904,14 +6904,14 @@ Error deleting document src/app/components/document-detail/document-detail.component.ts - 934 + 938 Reprocess confirm src/app/components/document-detail/document-detail.component.ts - 954 + 960 src/app/components/document-list/bulk-editor/bulk-editor.component.ts @@ -6922,77 +6922,77 @@ This operation will permanently recreate the archive file for this document. src/app/components/document-detail/document-detail.component.ts - 955 + 961 The archive file will be re-generated with the current settings. src/app/components/document-detail/document-detail.component.ts - 956 + 962 Reprocess operation for "" will begin in the background. Close and re-open or reload this document after the operation has completed to see new content. src/app/components/document-detail/document-detail.component.ts - 966 + 972 Error executing operation src/app/components/document-detail/document-detail.component.ts - 977 + 983 Error downloading document src/app/components/document-detail/document-detail.component.ts - 1024 + 1030 Page Fit src/app/components/document-detail/document-detail.component.ts - 1103 + 1109 Split confirm src/app/components/document-detail/document-detail.component.ts - 1316 + 1322 This operation will split the selected document(s) into new documents. src/app/components/document-detail/document-detail.component.ts - 1317 + 1323 Split operation for "" will begin in the background. src/app/components/document-detail/document-detail.component.ts - 1333 + 1339 Error executing split operation src/app/components/document-detail/document-detail.component.ts - 1342 + 1348 Rotate confirm src/app/components/document-detail/document-detail.component.ts - 1355 + 1361 src/app/components/document-list/bulk-editor/bulk-editor.component.ts @@ -7003,60 +7003,60 @@ This operation will permanently rotate the original version of the current document. src/app/components/document-detail/document-detail.component.ts - 1356 + 1362 Rotation of "" will begin in the background. Close and re-open the document after the operation has completed to see the changes. src/app/components/document-detail/document-detail.component.ts - 1372 + 1378 Error executing rotate operation src/app/components/document-detail/document-detail.component.ts - 1384 + 1390 Delete pages confirm src/app/components/document-detail/document-detail.component.ts - 1396 + 1402 This operation will permanently delete the selected pages from the original document. src/app/components/document-detail/document-detail.component.ts - 1397 + 1403 Delete pages operation for "" will begin in the background. Close and re-open or reload this document after the operation has completed to see the changes. src/app/components/document-detail/document-detail.component.ts - 1412 + 1418 Error executing delete pages operation src/app/components/document-detail/document-detail.component.ts - 1421 + 1427 An error occurred loading tiff: src/app/components/document-detail/document-detail.component.ts - 1481 + 1487 src/app/components/document-detail/document-detail.component.ts - 1485 + 1491 @@ -8270,28 +8270,28 @@ Confirm delete field src/app/components/manage/custom-fields/custom-fields.component.ts - 106 + 108 This operation will permanently delete this field. src/app/components/manage/custom-fields/custom-fields.component.ts - 107 + 109 Deleted field "" src/app/components/manage/custom-fields/custom-fields.component.ts - 116 + 119 Error deleting field "". src/app/components/manage/custom-fields/custom-fields.component.ts - 125 + 129 @@ -8425,154 +8425,154 @@ Error retrieving mail rules src/app/components/manage/mail/mail.component.ts - 130 + 131 OAuth2 authentication success src/app/components/manage/mail/mail.component.ts - 138 + 142 OAuth2 authentication failed, see logs for details src/app/components/manage/mail/mail.component.ts - 149 + 154 Saved account "". src/app/components/manage/mail/mail.component.ts - 173 + 178 Error saving account. src/app/components/manage/mail/mail.component.ts - 185 + 190 Confirm delete mail account src/app/components/manage/mail/mail.component.ts - 193 + 198 This operation will permanently delete this mail account. src/app/components/manage/mail/mail.component.ts - 194 + 199 Deleted mail account "" src/app/components/manage/mail/mail.component.ts - 204 + 209 Error deleting mail account "". src/app/components/manage/mail/mail.component.ts - 215 + 220 Processing mail account "" src/app/components/manage/mail/mail.component.ts - 227 + 232 Error processing mail account "" src/app/components/manage/mail/mail.component.ts - 232 + 237 Saved rule "". src/app/components/manage/mail/mail.component.ts - 250 + 256 Error saving rule. src/app/components/manage/mail/mail.component.ts - 261 + 268 Rule "" enabled. src/app/components/manage/mail/mail.component.ts - 277 + 284 Rule "" disabled. src/app/components/manage/mail/mail.component.ts - 278 + 285 Error toggling rule "". src/app/components/manage/mail/mail.component.ts - 283 + 290 Confirm delete mail rule src/app/components/manage/mail/mail.component.ts - 294 + 301 This operation will permanently delete this mail rule. src/app/components/manage/mail/mail.component.ts - 295 + 302 Deleted mail rule "" src/app/components/manage/mail/mail.component.ts - 305 + 312 Error deleting mail rule "". src/app/components/manage/mail/mail.component.ts - 316 + 323 Permissions updated src/app/components/manage/mail/mail.component.ts - 340 + 347 Error updating permissions src/app/components/manage/mail/mail.component.ts - 345 + 352 src/app/components/manage/management-list/management-list.component.ts @@ -8737,14 +8737,14 @@ Objects deleted successfully src/app/components/manage/management-list/management-list.component.ts - 352 + 353 Error deleting objects src/app/components/manage/management-list/management-list.component.ts - 358 + 360 @@ -8807,14 +8807,14 @@ Views saved successfully. src/app/components/manage/saved-views/saved-views.component.ts - 158 + 159 Error while saving views. src/app/components/manage/saved-views/saved-views.component.ts - 163 + 165 diff --git a/src-ui/src/app/app.component.html b/src-ui/src/app/app.component.html index 5ffe4aebe..40322c0e3 100644 --- a/src-ui/src/app/app.component.html +++ b/src-ui/src/app/app.component.html @@ -1,4 +1,4 @@ - + diff --git a/src-ui/src/app/app.component.spec.ts b/src-ui/src/app/app.component.spec.ts index bc59f78dc..b4e46e3ed 100644 --- a/src-ui/src/app/app.component.spec.ts +++ b/src-ui/src/app/app.component.spec.ts @@ -14,14 +14,17 @@ import { TourNgBootstrapModule, TourService } from 'ngx-ui-tour-ng-bootstrap' import { Subject } from 'rxjs' import { routes } from './app-routing.module' import { AppComponent } from './app.component' -import { ToastsComponent } from './components/common/toasts/toasts.component' +import { NotificationListComponent } from './components/common/notification-list/notification-list.component' import { FileDropComponent } from './components/file-drop/file-drop.component' import { DirtySavedViewGuard } from './guards/dirty-saved-view.guard' import { PermissionsGuard } from './guards/permissions.guard' import { HotKeyService } from './services/hot-key.service' +import { + Notification, + NotificationService, +} from './services/notification.service' import { PermissionsService } from './services/permissions.service' import { SettingsService } from './services/settings.service' -import { Toast, ToastService } from './services/toast.service' import { FileStatus, WebsocketStatusService, @@ -33,7 +36,7 @@ describe('AppComponent', () => { let tourService: TourService let websocketStatusService: WebsocketStatusService let permissionsService: PermissionsService - let toastService: ToastService + let notificationService: NotificationService let router: Router let settingsService: SettingsService let hotKeyService: HotKeyService @@ -46,7 +49,7 @@ describe('AppComponent', () => { NgxFileDropModule, NgbModalModule, AppComponent, - ToastsComponent, + NotificationListComponent, FileDropComponent, NgxBootstrapIconsModule.pick(allIcons), ], @@ -62,7 +65,7 @@ describe('AppComponent', () => { websocketStatusService = TestBed.inject(WebsocketStatusService) permissionsService = TestBed.inject(PermissionsService) settingsService = TestBed.inject(SettingsService) - toastService = TestBed.inject(ToastService) + notificationService = TestBed.inject(NotificationService) router = TestBed.inject(Router) hotKeyService = TestBed.inject(HotKeyService) fixture = TestBed.createComponent(AppComponent) @@ -82,12 +85,14 @@ describe('AppComponent', () => { expect(document.body.classList).not.toContain('tour-active') })) - it('should display toast on document consumed with link if user has access', () => { + it('should display notification on document consumed with link if user has access', () => { const navigateSpy = jest.spyOn(router, 'navigate') jest.spyOn(permissionsService, 'currentUserCan').mockReturnValue(true) - let toast: Toast - toastService.getToasts().subscribe((toasts) => (toast = toasts[0])) - const toastSpy = jest.spyOn(toastService, 'show') + let notification: Notification + notificationService + .getNotifications() + .subscribe((notifications) => (notification = notifications[0])) + const notificationSpy = jest.spyOn(notificationService, 'show') const fileStatusSubject = new Subject() jest .spyOn(websocketStatusService, 'onDocumentConsumptionFinished') @@ -96,63 +101,65 @@ describe('AppComponent', () => { const status = new FileStatus() status.documentId = 1 fileStatusSubject.next(status) - expect(toastSpy).toHaveBeenCalled() - expect(toast.action).not.toBeUndefined() - toast.action() + expect(notificationSpy).toHaveBeenCalled() + expect(notification.action).not.toBeUndefined() + notification.action() expect(navigateSpy).toHaveBeenCalledWith(['documents', status.documentId]) }) - it('should display toast on document consumed without link if user does not have access', () => { + it('should display notification on document consumed without link if user does not have access', () => { jest.spyOn(permissionsService, 'currentUserCan').mockReturnValue(false) - let toast: Toast - toastService.getToasts().subscribe((toasts) => (toast = toasts[0])) - const toastSpy = jest.spyOn(toastService, 'show') + let notification: Notification + notificationService + .getNotifications() + .subscribe((notifications) => (notification = notifications[0])) + const notificationSpy = jest.spyOn(notificationService, 'show') const fileStatusSubject = new Subject() jest .spyOn(websocketStatusService, 'onDocumentConsumptionFinished') .mockReturnValue(fileStatusSubject) component.ngOnInit() fileStatusSubject.next(new FileStatus()) - expect(toastSpy).toHaveBeenCalled() - expect(toast.action).toBeUndefined() + expect(notificationSpy).toHaveBeenCalled() + expect(notification.action).toBeUndefined() }) - it('should display toast on document added', () => { + it('should display notification on document added', () => { jest.spyOn(permissionsService, 'currentUserCan').mockReturnValue(true) - const toastSpy = jest.spyOn(toastService, 'show') + const notificationSpy = jest.spyOn(notificationService, 'show') const fileStatusSubject = new Subject() jest .spyOn(websocketStatusService, 'onDocumentDetected') .mockReturnValue(fileStatusSubject) component.ngOnInit() fileStatusSubject.next(new FileStatus()) - expect(toastSpy).toHaveBeenCalled() + expect(notificationSpy).toHaveBeenCalled() }) it('should suppress dashboard notifications if set', () => { jest.spyOn(permissionsService, 'currentUserCan').mockReturnValue(true) jest.spyOn(settingsService, 'get').mockReturnValue(true) jest.spyOn(router, 'url', 'get').mockReturnValue('/dashboard') - const toastSpy = jest.spyOn(toastService, 'show') + const notificationSpy = jest.spyOn(notificationService, 'show') const fileStatusSubject = new Subject() jest .spyOn(websocketStatusService, 'onDocumentDetected') .mockReturnValue(fileStatusSubject) component.ngOnInit() fileStatusSubject.next(new FileStatus()) - expect(toastSpy).not.toHaveBeenCalled() + expect(notificationSpy).not.toHaveBeenCalled() }) - it('should display toast on document failed', () => { + it('should display notification on document failed', () => { jest.spyOn(permissionsService, 'currentUserCan').mockReturnValue(true) - const toastSpy = jest.spyOn(toastService, 'showError') + const notificationSpy = jest.spyOn(notificationService, 'showError') const fileStatusSubject = new Subject() jest .spyOn(websocketStatusService, 'onDocumentConsumptionFailed') .mockReturnValue(fileStatusSubject) component.ngOnInit() fileStatusSubject.next(new FileStatus()) - expect(toastSpy).toHaveBeenCalled() + expect(notificationSpy).toHaveBeenCalled() }) it('should support hotkeys', () => { diff --git a/src-ui/src/app/app.component.ts b/src-ui/src/app/app.component.ts index a6c4702b7..51de90414 100644 --- a/src-ui/src/app/app.component.ts +++ b/src-ui/src/app/app.component.ts @@ -2,11 +2,12 @@ import { Component, OnDestroy, OnInit, Renderer2 } from '@angular/core' import { Router, RouterOutlet } from '@angular/router' import { TourNgBootstrapModule, TourService } from 'ngx-ui-tour-ng-bootstrap' import { first, Subscription } from 'rxjs' -import { ToastsComponent } from './components/common/toasts/toasts.component' +import { NotificationListComponent } from './components/common/notification-list/notification-list.component' import { FileDropComponent } from './components/file-drop/file-drop.component' import { SETTINGS_KEYS } from './data/ui-settings' import { ComponentRouterService } from './services/component-router.service' import { HotKeyService } from './services/hot-key.service' +import { NotificationService } from './services/notification.service' import { PermissionAction, PermissionsService, @@ -14,7 +15,6 @@ import { } from './services/permissions.service' import { SettingsService } from './services/settings.service' import { TasksService } from './services/tasks.service' -import { ToastService } from './services/toast.service' import { WebsocketStatusService } from './services/websocket-status.service' @Component({ @@ -23,7 +23,7 @@ import { WebsocketStatusService } from './services/websocket-status.service' styleUrls: ['./app.component.scss'], imports: [ FileDropComponent, - ToastsComponent, + NotificationListComponent, TourNgBootstrapModule, RouterOutlet, ], @@ -36,7 +36,7 @@ export class AppComponent implements OnInit, OnDestroy { constructor( private settings: SettingsService, private websocketStatusService: WebsocketStatusService, - private toastService: ToastService, + private notificationService: NotificationService, private router: Router, private tasksService: TasksService, public tourService: TourService, @@ -91,7 +91,7 @@ export class AppComponent implements OnInit, OnDestroy { PermissionType.Document ) ) { - this.toastService.show({ + this.notificationService.show({ content: $localize`Document ${status.filename} was added to Paperless-ngx.`, delay: 10000, actionName: $localize`Open document`, @@ -100,7 +100,7 @@ export class AppComponent implements OnInit, OnDestroy { }, }) } else { - this.toastService.show({ + this.notificationService.show({ content: $localize`Document ${status.filename} was added to Paperless-ngx.`, delay: 10000, }) @@ -115,7 +115,7 @@ export class AppComponent implements OnInit, OnDestroy { if ( this.showNotification(SETTINGS_KEYS.NOTIFICATIONS_CONSUMER_FAILED) ) { - this.toastService.showError( + this.notificationService.showError( $localize`Could not add ${status.filename}\: ${status.message}` ) } @@ -130,7 +130,7 @@ export class AppComponent implements OnInit, OnDestroy { SETTINGS_KEYS.NOTIFICATIONS_CONSUMER_NEW_DOCUMENT ) ) { - this.toastService.show({ + this.notificationService.show({ content: $localize`Document ${status.filename} is being processed by Paperless-ngx.`, delay: 5000, }) diff --git a/src-ui/src/app/components/admin/config/config.component.spec.ts b/src-ui/src/app/components/admin/config/config.component.spec.ts index 191532590..818d49111 100644 --- a/src-ui/src/app/components/admin/config/config.component.spec.ts +++ b/src-ui/src/app/components/admin/config/config.component.spec.ts @@ -10,8 +10,8 @@ import { NgxBootstrapIconsModule, allIcons } from 'ngx-bootstrap-icons' import { of, throwError } from 'rxjs' import { OutputTypeConfig } from 'src/app/data/paperless-config' import { ConfigService } from 'src/app/services/config.service' +import { NotificationService } from 'src/app/services/notification.service' import { SettingsService } from 'src/app/services/settings.service' -import { ToastService } from 'src/app/services/toast.service' import { FileComponent } from '../../common/input/file/file.component' import { NumberComponent } from '../../common/input/number/number.component' import { SelectComponent } from '../../common/input/select/select.component' @@ -24,7 +24,7 @@ describe('ConfigComponent', () => { let component: ConfigComponent let fixture: ComponentFixture let configService: ConfigService - let toastService: ToastService + let notificationService: NotificationService let settingService: SettingsService beforeEach(async () => { @@ -51,7 +51,7 @@ describe('ConfigComponent', () => { }).compileComponents() configService = TestBed.inject(ConfigService) - toastService = TestBed.inject(ToastService) + notificationService = TestBed.inject(NotificationService) settingService = TestBed.inject(SettingsService) fixture = TestBed.createComponent(ConfigComponent) component = fixture.componentInstance @@ -60,7 +60,7 @@ describe('ConfigComponent', () => { it('should load config on init, show error if necessary', () => { const getSpy = jest.spyOn(configService, 'getConfig') - const errorSpy = jest.spyOn(toastService, 'showError') + const errorSpy = jest.spyOn(notificationService, 'showError') getSpy.mockReturnValueOnce( throwError(() => new Error('Error getting config')) ) @@ -78,7 +78,7 @@ describe('ConfigComponent', () => { it('should save config, show error if necessary', () => { const saveSpy = jest.spyOn(configService, 'saveConfig') - const errorSpy = jest.spyOn(toastService, 'showError') + const errorSpy = jest.spyOn(notificationService, 'showError') saveSpy.mockReturnValueOnce( throwError(() => new Error('Error saving config')) ) @@ -112,7 +112,7 @@ describe('ConfigComponent', () => { it('should upload file, show error if necessary', () => { const uploadSpy = jest.spyOn(configService, 'uploadFile') - const errorSpy = jest.spyOn(toastService, 'showError') + const errorSpy = jest.spyOn(notificationService, 'showError') uploadSpy.mockReturnValueOnce( throwError(() => new Error('Error uploading file')) ) diff --git a/src-ui/src/app/components/admin/config/config.component.ts b/src-ui/src/app/components/admin/config/config.component.ts index 76f6b8795..f89959abf 100644 --- a/src-ui/src/app/components/admin/config/config.component.ts +++ b/src-ui/src/app/components/admin/config/config.component.ts @@ -25,8 +25,8 @@ import { PaperlessConfigOptions, } from 'src/app/data/paperless-config' import { ConfigService } from 'src/app/services/config.service' +import { NotificationService } from 'src/app/services/notification.service' import { SettingsService } from 'src/app/services/settings.service' -import { ToastService } from 'src/app/services/toast.service' import { FileComponent } from '../../common/input/file/file.component' import { NumberComponent } from '../../common/input/number/number.component' import { SelectComponent } from '../../common/input/select/select.component' @@ -79,7 +79,7 @@ export class ConfigComponent constructor( private configService: ConfigService, - private toastService: ToastService, + private notificationService: NotificationService, private settingsService: SettingsService ) { super() @@ -100,7 +100,10 @@ export class ConfigComponent }, error: (e) => { this.loading = false - this.toastService.showError($localize`Error retrieving config`, e) + this.notificationService.showError( + $localize`Error retrieving config`, + e + ) }, }) @@ -170,11 +173,11 @@ export class ConfigComponent this.initialize(config) this.store.next(config) this.settingsService.initializeSettings().subscribe() - this.toastService.showInfo($localize`Configuration updated`) + this.notificationService.showInfo($localize`Configuration updated`) }, error: (e) => { this.loading = false - this.toastService.showError( + this.notificationService.showError( $localize`An error occurred updating configuration`, e ) @@ -197,11 +200,13 @@ export class ConfigComponent this.initialize(config) this.store.next(config) this.settingsService.initializeSettings().subscribe() - this.toastService.showInfo($localize`File successfully updated`) + this.notificationService.showInfo( + $localize`File successfully updated` + ) }, error: (e) => { this.loading = false - this.toastService.showError( + this.notificationService.showError( $localize`An error occurred uploading file`, e ) diff --git a/src-ui/src/app/components/admin/settings/settings.component.spec.ts b/src-ui/src/app/components/admin/settings/settings.component.spec.ts index c6eeaf896..28d0c9e1b 100644 --- a/src-ui/src/app/components/admin/settings/settings.component.spec.ts +++ b/src-ui/src/app/components/admin/settings/settings.component.spec.ts @@ -29,12 +29,15 @@ import { IfPermissionsDirective } from 'src/app/directives/if-permissions.direct import { PermissionsGuard } from 'src/app/guards/permissions.guard' import { CustomDatePipe } from 'src/app/pipes/custom-date.pipe' import { SafeHtmlPipe } from 'src/app/pipes/safehtml.pipe' +import { + Notification, + NotificationService, +} from 'src/app/services/notification.service' import { PermissionsService } from 'src/app/services/permissions.service' import { GroupService } from 'src/app/services/rest/group.service' import { UserService } from 'src/app/services/rest/user.service' import { SettingsService } from 'src/app/services/settings.service' import { SystemStatusService } from 'src/app/services/system-status.service' -import { Toast, ToastService } from 'src/app/services/toast.service' import { ConfirmButtonComponent } from '../../common/confirm-button/confirm-button.component' import { ConfirmDialogComponent } from '../../common/confirm-dialog/confirm-dialog.component' import { CheckComponent } from '../../common/input/check/check.component' @@ -66,7 +69,7 @@ describe('SettingsComponent', () => { let settingsService: SettingsService let activatedRoute: ActivatedRoute let viewportScroller: ViewportScroller - let toastService: ToastService + let notificationService: NotificationService let userService: UserService let permissionsService: PermissionsService let groupService: GroupService @@ -115,7 +118,7 @@ describe('SettingsComponent', () => { router = TestBed.inject(Router) activatedRoute = TestBed.inject(ActivatedRoute) viewportScroller = TestBed.inject(ViewportScroller) - toastService = TestBed.inject(ToastService) + notificationService = TestBed.inject(NotificationService) settingsService = TestBed.inject(SettingsService) settingsService.currentUser = users[0] userService = TestBed.inject(UserService) @@ -194,8 +197,8 @@ describe('SettingsComponent', () => { it('should support save local settings updating appearance settings and calling API, show error', () => { completeSetup() - const toastErrorSpy = jest.spyOn(toastService, 'showError') - const toastSpy = jest.spyOn(toastService, 'show') + const notificationErrorSpy = jest.spyOn(notificationService, 'showError') + const notificationSpy = jest.spyOn(notificationService, 'show') const storeSpy = jest.spyOn(settingsService, 'storeSettings') const appearanceSettingsSpy = jest.spyOn( settingsService, @@ -209,7 +212,7 @@ describe('SettingsComponent', () => { ) component.saveSettings() - expect(toastErrorSpy).toHaveBeenCalled() + expect(notificationErrorSpy).toHaveBeenCalled() expect(storeSpy).toHaveBeenCalled() expect(appearanceSettingsSpy).not.toHaveBeenCalled() expect(setSpy).toHaveBeenCalledTimes(29) @@ -217,14 +220,14 @@ describe('SettingsComponent', () => { // succeed storeSpy.mockReturnValueOnce(of(true)) component.saveSettings() - expect(toastSpy).toHaveBeenCalled() + expect(notificationSpy).toHaveBeenCalled() expect(appearanceSettingsSpy).toHaveBeenCalled() }) it('should offer reload if settings changes require', () => { completeSetup() - let toast: Toast - toastService.getToasts().subscribe((t) => (toast = t[0])) + let toast: Notification + notificationService.getNotifications().subscribe((t) => (toast = t[0])) component.initialize(true) // reset component.store.getValue()['displayLanguage'] = 'en-US' component.store.getValue()['updateCheckingEnabled'] = false @@ -258,7 +261,7 @@ describe('SettingsComponent', () => { }) it('should show errors on load if load users failure', () => { - const toastErrorSpy = jest.spyOn(toastService, 'showError') + const notificationErrorSpy = jest.spyOn(notificationService, 'showError') jest .spyOn(userService, 'listAll') .mockImplementation(() => @@ -266,11 +269,11 @@ describe('SettingsComponent', () => { ) completeSetup(userService) fixture.detectChanges() - expect(toastErrorSpy).toBeCalled() + expect(notificationErrorSpy).toBeCalled() }) it('should show errors on load if load groups failure', () => { - const toastErrorSpy = jest.spyOn(toastService, 'showError') + const notificationErrorSpy = jest.spyOn(notificationService, 'showError') jest .spyOn(groupService, 'listAll') .mockImplementation(() => @@ -278,7 +281,7 @@ describe('SettingsComponent', () => { ) completeSetup(groupService) fixture.detectChanges() - expect(toastErrorSpy).toBeCalled() + expect(notificationErrorSpy).toBeCalled() }) it('should load system status on initialize, show errors if needed', () => { diff --git a/src-ui/src/app/components/admin/settings/settings.component.ts b/src-ui/src/app/components/admin/settings/settings.component.ts index 8737be160..14f58bf23 100644 --- a/src-ui/src/app/components/admin/settings/settings.component.ts +++ b/src-ui/src/app/components/admin/settings/settings.component.ts @@ -43,6 +43,10 @@ import { User } from 'src/app/data/user' import { IfPermissionsDirective } from 'src/app/directives/if-permissions.directive' import { CustomDatePipe } from 'src/app/pipes/custom-date.pipe' import { DocumentListViewService } from 'src/app/services/document-list-view.service' +import { + Notification, + NotificationService, +} from 'src/app/services/notification.service' import { PermissionAction, PermissionType, @@ -55,7 +59,6 @@ import { SettingsService, } from 'src/app/services/settings.service' import { SystemStatusService } from 'src/app/services/system-status.service' -import { Toast, ToastService } from 'src/app/services/toast.service' import { CheckComponent } from '../../common/input/check/check.component' import { ColorComponent } from '../../common/input/color/color.component' import { PermissionsGroupComponent } from '../../common/input/permissions/permissions-group/permissions-group.component' @@ -181,7 +184,7 @@ export class SettingsComponent constructor( private documentListViewService: DocumentListViewService, - private toastService: ToastService, + private notificationService: NotificationService, private settings: SettingsService, @Inject(LOCALE_ID) public currentLocale: string, private viewportScroller: ViewportScroller, @@ -217,7 +220,10 @@ export class SettingsComponent this.users = r.results }, error: (e) => { - this.toastService.showError($localize`Error retrieving users`, e) + this.notificationService.showError( + $localize`Error retrieving users`, + e + ) }, }) } @@ -236,7 +242,10 @@ export class SettingsComponent this.groups = r.results }, error: (e) => { - this.toastService.showError($localize`Error retrieving groups`, e) + this.notificationService.showError( + $localize`Error retrieving groups`, + e + ) }, }) } @@ -531,7 +540,7 @@ export class SettingsComponent this.store.next(this.settingsForm.value) this.settings.updateAppearanceSettings() this.settings.initializeDisplayFields() - let savedToast: Toast = { + let savedToast: Notification = { content: $localize`Settings were saved successfully.`, delay: 5000, } @@ -543,10 +552,10 @@ export class SettingsComponent } } - this.toastService.show(savedToast) + this.notificationService.show(savedToast) }, error: (error) => { - this.toastService.showError( + this.notificationService.showError( $localize`An error occurred while saving settings.`, error ) diff --git a/src-ui/src/app/components/admin/trash/trash.component.spec.ts b/src-ui/src/app/components/admin/trash/trash.component.spec.ts index aa5a8af0f..fd9d8020c 100644 --- a/src-ui/src/app/components/admin/trash/trash.component.spec.ts +++ b/src-ui/src/app/components/admin/trash/trash.component.spec.ts @@ -12,7 +12,7 @@ import { import { NgxBootstrapIconsModule, allIcons } from 'ngx-bootstrap-icons' import { of, throwError } from 'rxjs' import { SafeHtmlPipe } from 'src/app/pipes/safehtml.pipe' -import { ToastService } from 'src/app/services/toast.service' +import { NotificationService } from 'src/app/services/notification.service' import { TrashService } from 'src/app/services/trash.service' import { ConfirmDialogComponent } from '../../common/confirm-dialog/confirm-dialog.component' import { PageHeaderComponent } from '../../common/page-header/page-header.component' @@ -38,7 +38,7 @@ describe('TrashComponent', () => { let fixture: ComponentFixture let trashService: TrashService let modalService: NgbModal - let toastService: ToastService + let notificationService: NotificationService let router: Router beforeEach(async () => { @@ -60,7 +60,7 @@ describe('TrashComponent', () => { fixture = TestBed.createComponent(TrashComponent) trashService = TestBed.inject(TrashService) modalService = TestBed.inject(NgbModal) - toastService = TestBed.inject(ToastService) + notificationService = TestBed.inject(NotificationService) router = TestBed.inject(Router) component = fixture.componentInstance fixture.detectChanges() @@ -88,13 +88,13 @@ describe('TrashComponent', () => { modalService.activeInstances.subscribe((instances) => { modal = instances[0] }) - const toastErrorSpy = jest.spyOn(toastService, 'showError') + const notificationErrorSpy = jest.spyOn(notificationService, 'showError') // fail first trashSpy.mockReturnValue(throwError(() => 'Error')) component.delete(documentsInTrash[0]) modal.componentInstance.confirmClicked.next() - expect(toastErrorSpy).toHaveBeenCalled() + expect(notificationErrorSpy).toHaveBeenCalled() trashSpy.mockReturnValue(of('OK')) component.delete(documentsInTrash[0]) @@ -109,13 +109,13 @@ describe('TrashComponent', () => { modalService.activeInstances.subscribe((instances) => { modal = instances[instances.length - 1] }) - const toastErrorSpy = jest.spyOn(toastService, 'showError') + const notificationErrorSpy = jest.spyOn(notificationService, 'showError') // fail first trashSpy.mockReturnValue(throwError(() => 'Error')) component.emptyTrash() modal.componentInstance.confirmClicked.next() - expect(toastErrorSpy).toHaveBeenCalled() + expect(notificationErrorSpy).toHaveBeenCalled() trashSpy.mockReturnValue(of('OK')) component.emptyTrash() @@ -131,12 +131,12 @@ describe('TrashComponent', () => { it('should support restore document, show error if needed', () => { const restoreSpy = jest.spyOn(trashService, 'restoreDocuments') const reloadSpy = jest.spyOn(component, 'reload') - const toastErrorSpy = jest.spyOn(toastService, 'showError') + const notificationErrorSpy = jest.spyOn(notificationService, 'showError') // fail first restoreSpy.mockReturnValue(throwError(() => 'Error')) component.restore(documentsInTrash[0]) - expect(toastErrorSpy).toHaveBeenCalled() + expect(notificationErrorSpy).toHaveBeenCalled() expect(reloadSpy).not.toHaveBeenCalled() restoreSpy.mockReturnValue(of('OK')) @@ -148,12 +148,12 @@ describe('TrashComponent', () => { it('should support restore all documents, show error if needed', () => { const restoreSpy = jest.spyOn(trashService, 'restoreDocuments') const reloadSpy = jest.spyOn(component, 'reload') - const toastErrorSpy = jest.spyOn(toastService, 'showError') + const notificationErrorSpy = jest.spyOn(notificationService, 'showError') // fail first restoreSpy.mockReturnValue(throwError(() => 'Error')) component.restoreAll() - expect(toastErrorSpy).toHaveBeenCalled() + expect(notificationErrorSpy).toHaveBeenCalled() expect(reloadSpy).not.toHaveBeenCalled() restoreSpy.mockReturnValue(of('OK')) @@ -167,7 +167,7 @@ describe('TrashComponent', () => { it('should offer link to restored document', () => { let toasts const navigateSpy = jest.spyOn(router, 'navigate') - toastService.getToasts().subscribe((allToasts) => { + notificationService.getNotifications().subscribe((allToasts) => { toasts = [...allToasts] }) jest.spyOn(trashService, 'restoreDocuments').mockReturnValue(of('OK')) diff --git a/src-ui/src/app/components/admin/trash/trash.component.ts b/src-ui/src/app/components/admin/trash/trash.component.ts index 1df6ceff4..625fa146f 100644 --- a/src-ui/src/app/components/admin/trash/trash.component.ts +++ b/src-ui/src/app/components/admin/trash/trash.component.ts @@ -10,8 +10,8 @@ import { NgxBootstrapIconsModule } from 'ngx-bootstrap-icons' import { delay, takeUntil, tap } from 'rxjs' import { Document } from 'src/app/data/document' import { SETTINGS_KEYS } from 'src/app/data/ui-settings' +import { NotificationService } from 'src/app/services/notification.service' import { SettingsService } from 'src/app/services/settings.service' -import { ToastService } from 'src/app/services/toast.service' import { TrashService } from 'src/app/services/trash.service' import { ConfirmDialogComponent } from '../../common/confirm-dialog/confirm-dialog.component' import { PageHeaderComponent } from '../../common/page-header/page-header.component' @@ -44,7 +44,7 @@ export class TrashComponent constructor( private trashService: TrashService, - private toastService: ToastService, + private notificationService: NotificationService, private modalService: NgbModal, private settingsService: SettingsService, private router: Router @@ -86,14 +86,14 @@ export class TrashComponent modal.componentInstance.buttonsEnabled = false this.trashService.emptyTrash([document.id]).subscribe({ next: () => { - this.toastService.showInfo( + this.notificationService.showInfo( $localize`Document "${document.title}" deleted` ) modal.close() this.reload() }, error: (err) => { - this.toastService.showError( + this.notificationService.showError( $localize`Error deleting document "${document.title}"`, err ) @@ -121,13 +121,13 @@ export class TrashComponent .emptyTrash(documents ? Array.from(documents) : null) .subscribe({ next: () => { - this.toastService.showInfo($localize`Document(s) deleted`) + this.notificationService.showInfo($localize`Document(s) deleted`) this.allToggled = false modal.close() this.reload() }, error: (err) => { - this.toastService.showError( + this.notificationService.showError( $localize`Error deleting document(s)`, err ) @@ -140,7 +140,7 @@ export class TrashComponent restore(document: Document) { this.trashService.restoreDocuments([document.id]).subscribe({ next: () => { - this.toastService.show({ + this.notificationService.show({ content: $localize`Document "${document.title}" restored`, delay: 5000, actionName: $localize`Open document`, @@ -151,7 +151,7 @@ export class TrashComponent this.reload() }, error: (err) => { - this.toastService.showError( + this.notificationService.showError( $localize`Error restoring document "${document.title}"`, err ) @@ -164,12 +164,12 @@ export class TrashComponent .restoreDocuments(documents ? Array.from(documents) : null) .subscribe({ next: () => { - this.toastService.showInfo($localize`Document(s) restored`) + this.notificationService.showInfo($localize`Document(s) restored`) this.allToggled = false this.reload() }, error: (err) => { - this.toastService.showError( + this.notificationService.showError( $localize`Error restoring document(s)`, err ) diff --git a/src-ui/src/app/components/admin/users-groups/users-groups.component.spec.ts b/src-ui/src/app/components/admin/users-groups/users-groups.component.spec.ts index 559b03f51..5c95aa8a2 100644 --- a/src-ui/src/app/components/admin/users-groups/users-groups.component.spec.ts +++ b/src-ui/src/app/components/admin/users-groups/users-groups.component.spec.ts @@ -14,11 +14,11 @@ import { Group } from 'src/app/data/group' import { User } from 'src/app/data/user' import { PermissionsGuard } from 'src/app/guards/permissions.guard' import { CustomDatePipe } from 'src/app/pipes/custom-date.pipe' +import { NotificationService } from 'src/app/services/notification.service' import { PermissionsService } from 'src/app/services/permissions.service' import { GroupService } from 'src/app/services/rest/group.service' import { UserService } from 'src/app/services/rest/user.service' import { SettingsService } from 'src/app/services/settings.service' -import { ToastService } from 'src/app/services/toast.service' import { ConfirmDialogComponent } from '../../common/confirm-dialog/confirm-dialog.component' import { GroupEditDialogComponent } from '../../common/edit-dialog/group-edit-dialog/group-edit-dialog.component' import { UserEditDialogComponent } from '../../common/edit-dialog/user-edit-dialog/user-edit-dialog.component' @@ -38,7 +38,7 @@ describe('UsersAndGroupsComponent', () => { let fixture: ComponentFixture let settingsService: SettingsService let modalService: NgbModal - let toastService: ToastService + let notificationService: NotificationService let userService: UserService let permissionsService: PermissionsService let groupService: GroupService @@ -59,7 +59,7 @@ describe('UsersAndGroupsComponent', () => { settingsService.currentUser = users[0] userService = TestBed.inject(UserService) modalService = TestBed.inject(NgbModal) - toastService = TestBed.inject(ToastService) + notificationService = TestBed.inject(NotificationService) permissionsService = TestBed.inject(PermissionsService) jest.spyOn(permissionsService, 'currentUserCan').mockReturnValue(true) jest @@ -104,13 +104,13 @@ describe('UsersAndGroupsComponent', () => { modalService.activeInstances.subscribe((refs) => (modal = refs[0])) component.editUser(users[0]) const editDialog = modal.componentInstance as UserEditDialogComponent - const toastErrorSpy = jest.spyOn(toastService, 'showError') - const toastInfoSpy = jest.spyOn(toastService, 'showInfo') + const notificationErrorSpy = jest.spyOn(notificationService, 'showError') + const notificationInfoSpy = jest.spyOn(notificationService, 'showInfo') editDialog.failed.emit() - expect(toastErrorSpy).toBeCalled() + expect(notificationErrorSpy).toBeCalled() settingsService.currentUser = users[1] // simulate logged in as different user editDialog.succeeded.emit(users[0]) - expect(toastInfoSpy).toHaveBeenCalledWith( + expect(notificationInfoSpy).toHaveBeenCalledWith( `Saved user "${users[0].username}".` ) component.editUser() @@ -123,18 +123,18 @@ describe('UsersAndGroupsComponent', () => { component.deleteUser(users[0]) const deleteDialog = modal.componentInstance as ConfirmDialogComponent const deleteSpy = jest.spyOn(userService, 'delete') - const toastErrorSpy = jest.spyOn(toastService, 'showError') - const toastInfoSpy = jest.spyOn(toastService, 'showInfo') + const notificationErrorSpy = jest.spyOn(notificationService, 'showError') + const notificationInfoSpy = jest.spyOn(notificationService, 'showInfo') const listAllSpy = jest.spyOn(userService, 'listAll') deleteSpy.mockReturnValueOnce( throwError(() => new Error('error deleting user')) ) deleteDialog.confirm() - expect(toastErrorSpy).toBeCalled() + expect(notificationErrorSpy).toBeCalled() deleteSpy.mockReturnValueOnce(of(true)) deleteDialog.confirm() expect(listAllSpy).toHaveBeenCalled() - expect(toastInfoSpy).toHaveBeenCalledWith('Deleted user "user1"') + expect(notificationInfoSpy).toHaveBeenCalledWith('Deleted user "user1"') }) it('should logout current user if password changed, after delay', fakeAsync(() => { @@ -163,12 +163,12 @@ describe('UsersAndGroupsComponent', () => { modalService.activeInstances.subscribe((refs) => (modal = refs[0])) component.editGroup(groups[0]) const editDialog = modal.componentInstance as GroupEditDialogComponent - const toastErrorSpy = jest.spyOn(toastService, 'showError') - const toastInfoSpy = jest.spyOn(toastService, 'showInfo') + const notificationErrorSpy = jest.spyOn(notificationService, 'showError') + const notificationInfoSpy = jest.spyOn(notificationService, 'showInfo') editDialog.failed.emit() - expect(toastErrorSpy).toBeCalled() + expect(notificationErrorSpy).toBeCalled() editDialog.succeeded.emit(groups[0]) - expect(toastInfoSpy).toHaveBeenCalledWith( + expect(notificationInfoSpy).toHaveBeenCalledWith( `Saved group "${groups[0].name}".` ) component.editGroup() @@ -181,18 +181,18 @@ describe('UsersAndGroupsComponent', () => { component.deleteGroup(groups[0]) const deleteDialog = modal.componentInstance as ConfirmDialogComponent const deleteSpy = jest.spyOn(groupService, 'delete') - const toastErrorSpy = jest.spyOn(toastService, 'showError') - const toastInfoSpy = jest.spyOn(toastService, 'showInfo') + const notificationErrorSpy = jest.spyOn(notificationService, 'showError') + const notificationInfoSpy = jest.spyOn(notificationService, 'showInfo') const listAllSpy = jest.spyOn(groupService, 'listAll') deleteSpy.mockReturnValueOnce( throwError(() => new Error('error deleting group')) ) deleteDialog.confirm() - expect(toastErrorSpy).toBeCalled() + expect(notificationErrorSpy).toBeCalled() deleteSpy.mockReturnValueOnce(of(true)) deleteDialog.confirm() expect(listAllSpy).toHaveBeenCalled() - expect(toastInfoSpy).toHaveBeenCalledWith('Deleted group "group1"') + expect(notificationInfoSpy).toHaveBeenCalledWith('Deleted group "group1"') }) it('should get group name', () => { @@ -202,7 +202,7 @@ describe('UsersAndGroupsComponent', () => { }) it('should show errors on load if load users failure', () => { - const toastErrorSpy = jest.spyOn(toastService, 'showError') + const notificationErrorSpy = jest.spyOn(notificationService, 'showError') jest .spyOn(userService, 'listAll') .mockImplementation(() => @@ -210,11 +210,11 @@ describe('UsersAndGroupsComponent', () => { ) completeSetup(userService) fixture.detectChanges() - expect(toastErrorSpy).toBeCalled() + expect(notificationErrorSpy).toBeCalled() }) it('should show errors on load if load groups failure', () => { - const toastErrorSpy = jest.spyOn(toastService, 'showError') + const notificationErrorSpy = jest.spyOn(notificationService, 'showError') jest .spyOn(groupService, 'listAll') .mockImplementation(() => @@ -222,6 +222,6 @@ describe('UsersAndGroupsComponent', () => { ) completeSetup(groupService) fixture.detectChanges() - expect(toastErrorSpy).toBeCalled() + expect(notificationErrorSpy).toBeCalled() }) }) diff --git a/src-ui/src/app/components/admin/users-groups/users-groups.component.ts b/src-ui/src/app/components/admin/users-groups/users-groups.component.ts index 9ed73cde4..3d3f27fa9 100644 --- a/src-ui/src/app/components/admin/users-groups/users-groups.component.ts +++ b/src-ui/src/app/components/admin/users-groups/users-groups.component.ts @@ -5,11 +5,11 @@ import { Subject, first, takeUntil } from 'rxjs' import { Group } from 'src/app/data/group' import { User } from 'src/app/data/user' import { IfPermissionsDirective } from 'src/app/directives/if-permissions.directive' +import { NotificationService } from 'src/app/services/notification.service' import { PermissionsService } from 'src/app/services/permissions.service' import { GroupService } from 'src/app/services/rest/group.service' import { UserService } from 'src/app/services/rest/user.service' import { SettingsService } from 'src/app/services/settings.service' -import { ToastService } from 'src/app/services/toast.service' import { ConfirmDialogComponent } from '../../common/confirm-dialog/confirm-dialog.component' import { EditDialogMode } from '../../common/edit-dialog/edit-dialog.component' import { GroupEditDialogComponent } from '../../common/edit-dialog/group-edit-dialog/group-edit-dialog.component' @@ -39,7 +39,7 @@ export class UsersAndGroupsComponent constructor( private usersService: UserService, private groupsService: GroupService, - private toastService: ToastService, + private notificationService: NotificationService, private modalService: NgbModal, public permissionsService: PermissionsService, private settings: SettingsService @@ -56,7 +56,10 @@ export class UsersAndGroupsComponent this.users = r.results }, error: (e) => { - this.toastService.showError($localize`Error retrieving users`, e) + this.notificationService.showError( + $localize`Error retrieving users`, + e + ) }, }) @@ -68,7 +71,10 @@ export class UsersAndGroupsComponent this.groups = r.results }, error: (e) => { - this.toastService.showError($localize`Error retrieving groups`, e) + this.notificationService.showError( + $localize`Error retrieving groups`, + e + ) }, }) } @@ -93,14 +99,14 @@ export class UsersAndGroupsComponent newUser.id === this.settings.currentUser.id && (modal.componentInstance as UserEditDialogComponent).passwordIsSet ) { - this.toastService.showInfo( + this.notificationService.showInfo( $localize`Password has been changed, you will be logged out momentarily.` ) setTimeout(() => { window.location.href = `${window.location.origin}/accounts/logout/?next=/accounts/login/?next=/` }, 2500) } else { - this.toastService.showInfo( + this.notificationService.showInfo( $localize`Saved user "${newUser.username}".` ) this.usersService.listAll().subscribe((r) => { @@ -111,7 +117,7 @@ export class UsersAndGroupsComponent modal.componentInstance.failed .pipe(takeUntil(this.unsubscribeNotifier)) .subscribe((e) => { - this.toastService.showError($localize`Error saving user.`, e) + this.notificationService.showError($localize`Error saving user.`, e) }) } @@ -129,13 +135,15 @@ export class UsersAndGroupsComponent this.usersService.delete(user).subscribe({ next: () => { modal.close() - this.toastService.showInfo($localize`Deleted user "${user.username}"`) + this.notificationService.showInfo( + $localize`Deleted user "${user.username}"` + ) this.usersService.listAll().subscribe((r) => { this.users = r.results }) }, error: (e) => { - this.toastService.showError( + this.notificationService.showError( $localize`Error deleting user "${user.username}".`, e ) @@ -156,7 +164,9 @@ export class UsersAndGroupsComponent modal.componentInstance.succeeded .pipe(takeUntil(this.unsubscribeNotifier)) .subscribe((newGroup) => { - this.toastService.showInfo($localize`Saved group "${newGroup.name}".`) + this.notificationService.showInfo( + $localize`Saved group "${newGroup.name}".` + ) this.groupsService.listAll().subscribe((r) => { this.groups = r.results }) @@ -164,7 +174,7 @@ export class UsersAndGroupsComponent modal.componentInstance.failed .pipe(takeUntil(this.unsubscribeNotifier)) .subscribe((e) => { - this.toastService.showError($localize`Error saving group.`, e) + this.notificationService.showError($localize`Error saving group.`, e) }) } @@ -182,13 +192,15 @@ export class UsersAndGroupsComponent this.groupsService.delete(group).subscribe({ next: () => { modal.close() - this.toastService.showInfo($localize`Deleted group "${group.name}"`) + this.notificationService.showInfo( + $localize`Deleted group "${group.name}"` + ) this.groupsService.listAll().subscribe((r) => { this.groups = r.results }) }, error: (e) => { - this.toastService.showError( + this.notificationService.showError( $localize`Error deleting group "${group.name}".`, e ) diff --git a/src-ui/src/app/components/app-frame/app-frame.component.html b/src-ui/src/app/components/app-frame/app-frame.component.html index b3d515274..d2fd2c34e 100644 --- a/src-ui/src/app/components/app-frame/app-frame.component.html +++ b/src-ui/src/app/components/app-frame/app-frame.component.html @@ -30,7 +30,7 @@
    - +