From 423e0768f98d7b35be5358a1048af99d0100539c Mon Sep 17 00:00:00 2001 From: shamoon <4887959+shamoon@users.noreply.github.com> Date: Wed, 23 Aug 2023 23:50:54 -0700 Subject: [PATCH] Improved error notifications --- src-ui/messages.xlf | 248 +++++++++--------- src-ui/setup-jest.ts | 6 +- .../common/toasts/toasts.component.html | 23 +- .../common/toasts/toasts.component.scss | 5 - .../common/toasts/toasts.component.spec.ts | 74 ++++-- .../common/toasts/toasts.component.ts | 43 ++- .../document-detail.component.spec.ts | 24 +- .../document-detail.component.ts | 25 +- .../bulk-editor/bulk-editor.component.ts | 5 +- .../document-notes.component.ts | 10 +- .../management-list.component.ts | 21 +- .../manage/settings/settings.component.ts | 66 +---- src-ui/src/app/services/toast.service.ts | 2 +- src-ui/src/theme.scss | 4 + 14 files changed, 296 insertions(+), 260 deletions(-) diff --git a/src-ui/messages.xlf b/src-ui/messages.xlf index 140d7b78c..e7c04174b 100644 --- a/src-ui/messages.xlf +++ b/src-ui/messages.xlf @@ -723,7 +723,7 @@ src/app/components/manage/settings/settings.component.ts - 648 + 641 @@ -774,19 +774,19 @@ src/app/components/document-list/bulk-editor/bulk-editor.component.ts - 324 + 323 src/app/components/document-list/bulk-editor/bulk-editor.component.ts - 364 + 363 src/app/components/document-list/bulk-editor/bulk-editor.component.ts - 402 + 401 src/app/components/document-list/bulk-editor/bulk-editor.component.ts - 440 + 439 @@ -1498,6 +1498,10 @@ src/app/components/common/edit-dialog/mail-rule-edit-dialog/mail-rule-edit-dialog.component.html 38 + + src/app/components/common/toasts/toasts.component.html + 14 + src/app/services/toast.service.ts 37 @@ -1587,7 +1591,7 @@ src/app/components/manage/management-list/management-list.component.ts - 194 + 192 src/app/components/manage/settings/settings.component.html @@ -2236,6 +2240,20 @@ 20 + + Status + + src/app/components/common/toasts/toasts.component.html + 12 + + + + Copy Raw Error + + src/app/components/common/toasts/toasts.component.html + 23 + + Hello , welcome to Paperless-ngx @@ -2452,7 +2470,7 @@ src/app/components/document-list/bulk-editor/bulk-editor.component.ts - 269 + 268 this string is used to separate processing, failed and added on the file upload widget @@ -2815,160 +2833,158 @@ Error retrieving suggestions. src/app/components/document-detail/document-detail.component.ts - 419 + 418 Document saved successfully. src/app/components/document-detail/document-detail.component.ts - 533 + 531 src/app/components/document-detail/document-detail.component.ts - 541 + 539 Error saving document src/app/components/document-detail/document-detail.component.ts - 546 + 543 src/app/components/document-detail/document-detail.component.ts - 591 + 584 Confirm delete src/app/components/document-detail/document-detail.component.ts - 620 + 610 src/app/components/manage/management-list/management-list.component.ts - 190 + 188 Do you really want to delete document ""? src/app/components/document-detail/document-detail.component.ts - 621 + 611 The files for this document will be deleted permanently. This operation cannot be undone. src/app/components/document-detail/document-detail.component.ts - 622 + 612 Delete document src/app/components/document-detail/document-detail.component.ts - 624 + 614 - - Error deleting document: + + Error deleting document src/app/components/document-detail/document-detail.component.ts - 644,646 + 633 Redo OCR confirm src/app/components/document-detail/document-detail.component.ts - 667 + 653 src/app/components/document-list/bulk-editor/bulk-editor.component.ts - 499 + 498 This operation will permanently redo OCR for this document. src/app/components/document-detail/document-detail.component.ts - 668 + 654 This operation cannot be undone. src/app/components/document-detail/document-detail.component.ts - 669 + 655 src/app/components/document-list/bulk-editor/bulk-editor.component.ts - 462 + 461 src/app/components/document-list/bulk-editor/bulk-editor.component.ts - 501 + 500 src/app/components/manage/settings/settings.component.ts - 759 + 746 src/app/components/manage/settings/settings.component.ts - 819 + 798 src/app/components/manage/settings/settings.component.ts - 886 + 857 src/app/components/manage/settings/settings.component.ts - 949 + 915 Proceed src/app/components/document-detail/document-detail.component.ts - 671 + 657 src/app/components/document-list/bulk-editor/bulk-editor.component.ts - 503 + 502 src/app/components/manage/settings/settings.component.ts - 761 + 748 src/app/components/manage/settings/settings.component.ts - 821 + 800 src/app/components/manage/settings/settings.component.ts - 888 + 859 src/app/components/manage/settings/settings.component.ts - 951 + 917 Redo OCR operation 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 - 679 + 665 - - Error executing operation: + + Error executing operation src/app/components/document-detail/document-detail.component.ts - 690,692 + 676 @@ -3104,31 +3120,29 @@ 125,127 - - Error executing bulk operation: + + Error executing bulk operation src/app/components/document-list/bulk-editor/bulk-editor.component.ts - 185,187 + 185 "" src/app/components/document-list/bulk-editor/bulk-editor.component.ts - 261 + 260 src/app/components/document-list/bulk-editor/bulk-editor.component.ts - 267 + 266 "" and "" src/app/components/document-list/bulk-editor/bulk-editor.component.ts - 263 + 262 This is for messages like 'modify "tag1" and "tag2"' @@ -3136,7 +3150,7 @@ and "" src/app/components/document-list/bulk-editor/bulk-editor.component.ts - 271,273 + 270,272 this is for messages like 'modify "tag1", "tag2" and "tag3"' @@ -3144,14 +3158,14 @@ Confirm tags assignment src/app/components/document-list/bulk-editor/bulk-editor.component.ts - 288 + 287 This operation will add the tag "" to selected document(s). src/app/components/document-list/bulk-editor/bulk-editor.component.ts - 294 + 293 @@ -3160,14 +3174,14 @@ )"/> to selected document(s). src/app/components/document-list/bulk-editor/bulk-editor.component.ts - 299,301 + 298,300 This operation will remove the tag "" from selected document(s). src/app/components/document-list/bulk-editor/bulk-editor.component.ts - 307 + 306 @@ -3176,7 +3190,7 @@ )"/> from selected document(s). src/app/components/document-list/bulk-editor/bulk-editor.component.ts - 312,314 + 311,313 @@ -3187,98 +3201,98 @@ )"/> on selected document(s). src/app/components/document-list/bulk-editor/bulk-editor.component.ts - 316,320 + 315,319 Confirm correspondent assignment src/app/components/document-list/bulk-editor/bulk-editor.component.ts - 357 + 356 This operation will assign the correspondent "" to selected document(s). src/app/components/document-list/bulk-editor/bulk-editor.component.ts - 359 + 358 This operation will remove the correspondent from selected document(s). src/app/components/document-list/bulk-editor/bulk-editor.component.ts - 361 + 360 Confirm document type assignment src/app/components/document-list/bulk-editor/bulk-editor.component.ts - 395 + 394 This operation will assign the document type "" to selected document(s). src/app/components/document-list/bulk-editor/bulk-editor.component.ts - 397 + 396 This operation will remove the document type from selected document(s). src/app/components/document-list/bulk-editor/bulk-editor.component.ts - 399 + 398 Confirm storage path assignment src/app/components/document-list/bulk-editor/bulk-editor.component.ts - 433 + 432 This operation will assign the storage path "" to selected document(s). src/app/components/document-list/bulk-editor/bulk-editor.component.ts - 435 + 434 This operation will remove the storage path from selected document(s). src/app/components/document-list/bulk-editor/bulk-editor.component.ts - 437 + 436 Delete confirm src/app/components/document-list/bulk-editor/bulk-editor.component.ts - 460 + 459 This operation will permanently delete selected document(s). src/app/components/document-list/bulk-editor/bulk-editor.component.ts - 461 + 460 Delete document(s) src/app/components/document-list/bulk-editor/bulk-editor.component.ts - 464 + 463 This operation will permanently redo OCR for selected document(s). src/app/components/document-list/bulk-editor/bulk-editor.component.ts - 500 + 499 @@ -3872,14 +3886,14 @@ Error saving note src/app/components/document-notes/document-notes.component.ts - 67 + 66 - - Error deleting note: + + Error deleting note src/app/components/document-notes/document-notes.component.ts - 85 + 80 @@ -4085,30 +4099,28 @@ Successfully updated . src/app/components/manage/management-list/management-list.component.ts - 166 + 165 Error occurred while saving . src/app/components/manage/management-list/management-list.component.ts - 171 + 170 Associated documents will not be deleted. src/app/components/manage/management-list/management-list.component.ts - 192 + 190 - - Error while deleting element: + + Error while deleting element src/app/components/manage/management-list/management-list.component.ts - 205,207 + 203 @@ -4500,252 +4512,252 @@ Error retrieving users src/app/components/manage/settings/settings.component.ts - 287 + 285 Error retrieving mail rules src/app/components/manage/settings/settings.component.ts - 314 + 309 Error retrieving mail accounts src/app/components/manage/settings/settings.component.ts - 323 + 317 Saved view "" deleted. src/app/components/manage/settings/settings.component.ts - 530 + 523 Settings saved src/app/components/manage/settings/settings.component.ts - 632 + 625 Settings were saved successfully. src/app/components/manage/settings/settings.component.ts - 633 + 626 Settings were saved successfully. Reload is required to apply some changes. src/app/components/manage/settings/settings.component.ts - 637 + 630 Reload now src/app/components/manage/settings/settings.component.ts - 638 + 631 Use system language src/app/components/manage/settings/settings.component.ts - 657 + 649 Use date format of display language src/app/components/manage/settings/settings.component.ts - 664 + 656 Error while storing settings on server. src/app/components/manage/settings/settings.component.ts - 684 + 676 Password has been changed, you will be logged out momentarily. src/app/components/manage/settings/settings.component.ts - 727 + 718 Saved user "". src/app/components/manage/settings/settings.component.ts - 734 + 725 Error saving user. src/app/components/manage/settings/settings.component.ts - 746 + 736 Confirm delete user account src/app/components/manage/settings/settings.component.ts - 757 + 744 This operation will permanently delete this user account. src/app/components/manage/settings/settings.component.ts - 758 + 745 Deleted user src/app/components/manage/settings/settings.component.ts - 767 + 754 Error deleting user. src/app/components/manage/settings/settings.component.ts - 775 + 761 Saved group "". src/app/components/manage/settings/settings.component.ts - 796 + 779 Error saving group. src/app/components/manage/settings/settings.component.ts - 806 + 788 Confirm delete user group src/app/components/manage/settings/settings.component.ts - 817 + 796 This operation will permanently delete this user group. src/app/components/manage/settings/settings.component.ts - 818 + 797 Deleted group src/app/components/manage/settings/settings.component.ts - 827 + 806 Error deleting group. src/app/components/manage/settings/settings.component.ts - 835 + 813 Saved account "". src/app/components/manage/settings/settings.component.ts - 861 + 836 Error saving account. src/app/components/manage/settings/settings.component.ts - 873 + 847 Confirm delete mail account src/app/components/manage/settings/settings.component.ts - 884 + 855 This operation will permanently delete this mail account. src/app/components/manage/settings/settings.component.ts - 885 + 856 Deleted mail account src/app/components/manage/settings/settings.component.ts - 894 + 865 Error deleting mail account. src/app/components/manage/settings/settings.component.ts - 903 + 874 Saved rule "". src/app/components/manage/settings/settings.component.ts - 924 + 894 Error saving rule. src/app/components/manage/settings/settings.component.ts - 936 + 905 Confirm delete mail rule src/app/components/manage/settings/settings.component.ts - 947 + 913 This operation will permanently delete this mail rule. src/app/components/manage/settings/settings.component.ts - 948 + 914 Deleted mail rule src/app/components/manage/settings/settings.component.ts - 957 + 923 Error deleting mail rule. src/app/components/manage/settings/settings.component.ts - 966 + 931 diff --git a/src-ui/setup-jest.ts b/src-ui/setup-jest.ts index ae2edc96b..65004742b 100644 --- a/src-ui/setup-jest.ts +++ b/src-ui/setup-jest.ts @@ -81,7 +81,11 @@ Object.defineProperty(window, 'sessionStorage', { value: mock() }) Object.defineProperty(window, 'getComputedStyle', { value: () => ['-webkit-appearance'], }) - +Object.defineProperty(navigator, 'clipboard', { + value: { + writeText: async () => {}, + }, +}) Object.defineProperty(window, 'ResizeObserver', { value: mock() }) HTMLCanvasElement.prototype.getContext = < diff --git a/src-ui/src/app/components/common/toasts/toasts.component.html b/src-ui/src/app/components/common/toasts/toasts.component.html index bfce90333..dd75455e0 100644 --- a/src-ui/src/app/components/common/toasts/toasts.component.html +++ b/src-ui/src/app/components/common/toasts/toasts.component.html @@ -5,9 +5,26 @@ (hidden)="toastService.closeToast(toast)">

{{toast.content}}

-
-      {{toast.error}}
-    
+
+
+
URL
+
{{ toast.error.url }}
+
Status
+
{{ toast.error.status }} {{ toast.error.statusText }}
+
Error
+
{{ getErrorText(toast.error) }}
+
+
+
+ +
+
+

diff --git a/src-ui/src/app/components/common/toasts/toasts.component.scss b/src-ui/src/app/components/common/toasts/toasts.component.scss index 0cac00330..52f8f8957 100644 --- a/src-ui/src/app/components/common/toasts/toasts.component.scss +++ b/src-ui/src/app/components/common/toasts/toasts.component.scss @@ -20,8 +20,3 @@ border-bottom-left-radius: inherit; border-bottom-right-radius: inherit; } - -pre { - white-space: pre-line; - --bs-bg-opacity: .25; -} diff --git a/src-ui/src/app/components/common/toasts/toasts.component.spec.ts b/src-ui/src/app/components/common/toasts/toasts.component.spec.ts index 404311ec5..4dd85305f 100644 --- a/src-ui/src/app/components/common/toasts/toasts.component.spec.ts +++ b/src-ui/src/app/components/common/toasts/toasts.component.spec.ts @@ -11,6 +11,32 @@ import { HttpClientTestingModule } from '@angular/common/http/testing' import { of } from 'rxjs' import { NgbModule } from '@ng-bootstrap/ng-bootstrap' +const toasts = [ + { + title: 'Title', + content: 'content', + delay: 5000, + }, + { + title: 'Error 1', + content: 'Error 1 content', + delay: 5000, + error: 'Error 1 string', + }, + { + title: 'Error 2', + content: 'Error 2 content', + delay: 5000, + error: { + url: 'https://example.com', + status: 500, + statusText: 'Internal Server Error', + message: 'Internal server error 500 message', + error: { detail: 'Error 2 message details' }, + }, + }, +] + describe('ToastsComponent', () => { let component: ToastsComponent let fixture: ComponentFixture @@ -24,20 +50,7 @@ describe('ToastsComponent', () => { { provide: ToastService, useValue: { - getToasts: () => - of([ - { - title: 'Title', - content: 'content', - delay: 5000, - }, - { - title: 'Error', - content: 'Error content', - delay: 5000, - error: new Error('Error message'), - }, - ]), + getToasts: () => of(toasts), }, }, ], @@ -85,10 +98,41 @@ describe('ToastsComponent', () => { fixture.detectChanges() expect(fixture.nativeElement.querySelector('details')).not.toBeNull() - expect(fixture.nativeElement.textContent).toContain('Error message') + expect(fixture.nativeElement.textContent).toContain('Error 1 content') component.ngOnDestroy() flush() discardPeriodicTasks() })) + + it('should show error details, support copy', fakeAsync(() => { + component.ngOnInit() + fixture.detectChanges() + + expect(fixture.nativeElement.querySelector('details')).not.toBeNull() + expect(fixture.nativeElement.textContent).toContain( + 'Error 2 message details' + ) + + const copySpy = jest.spyOn(navigator.clipboard, 'writeText') + component.copyError(toasts[2].error) + expect(copySpy).toHaveBeenCalled() + + component.ngOnDestroy() + flush() + discardPeriodicTasks() + })) + + it('should parse error text, add ellipsis', () => { + expect(component.getErrorText(toasts[2].error)).toEqual( + 'Error 2 message details' + ) + expect(component.getErrorText({ error: 'Error string no detail' })).toEqual( + 'Error string no detail' + ) + expect(component.getErrorText('Error string')).toEqual('') + expect( + component.getErrorText({ error: new Array(205).join('a') }) + ).toContain('...') + }) }) diff --git a/src-ui/src/app/components/common/toasts/toasts.component.ts b/src-ui/src/app/components/common/toasts/toasts.component.ts index 9d013c88a..aa304ac4d 100644 --- a/src-ui/src/app/components/common/toasts/toasts.component.ts +++ b/src-ui/src/app/components/common/toasts/toasts.component.ts @@ -10,17 +10,50 @@ import { Toast, ToastService } from 'src/app/services/toast.service' export class ToastsComponent implements OnInit, OnDestroy { constructor(private toastService: ToastService) {} - subscription: Subscription + private subscription: Subscription - toasts: Toast[] = [] + public toasts: Toast[] = [] + + public copied: boolean = false ngOnDestroy(): void { this.subscription?.unsubscribe() } ngOnInit(): void { - this.subscription = this.toastService - .getToasts() - .subscribe((toasts) => (this.toasts = toasts)) + this.subscription = this.toastService.getToasts().subscribe((toasts) => { + this.toasts = toasts + this.toasts.forEach((t) => { + if (typeof t.error === 'string') { + try { + t.error = JSON.parse(t.error) + } catch (e) {} + } + }) + }) + } + + public isDetailedError(error: any): boolean { + return ( + typeof error === 'object' && + 'status' in error && + 'statusText' in error && + 'url' in error && + 'message' in error && + 'error' in error + ) + } + + public copyError(error: any) { + navigator.clipboard.writeText(JSON.stringify(error)) + this.copied = true + setTimeout(() => { + this.copied = false + }, 3000) + } + + getErrorText(error: any) { + const text: string = error.error?.detail ?? error.error ?? '' + return `${text.slice(0, 200)}${text.length > 200 ? '...' : ''}` } } diff --git a/src-ui/src/app/components/document-detail/document-detail.component.spec.ts b/src-ui/src/app/components/document-detail/document-detail.component.spec.ts index bbee477cc..81f68f9d5 100644 --- a/src-ui/src/app/components/document-detail/document-detail.component.spec.ts +++ b/src-ui/src/app/components/document-detail/document-detail.component.spec.ts @@ -398,15 +398,12 @@ describe('DocumentDetailComponent', () => { const closeSpy = jest.spyOn(component, 'close') const updateSpy = jest.spyOn(documentService, 'update') const toastSpy = jest.spyOn(toastService, 'showError') - updateSpy.mockImplementation(() => - throwError(() => new Error('failed to save')) - ) + const error = new Error('failed to save') + updateSpy.mockImplementation(() => throwError(() => error)) component.save() expect(updateSpy).toHaveBeenCalled() expect(closeSpy).not.toHaveBeenCalled() - expect(toastSpy).toHaveBeenCalledWith( - 'Error saving document: failed to save' - ) + expect(toastSpy).toHaveBeenCalledWith('Error saving document', error) }) it('should show error toast on save but close if user can no longer edit', () => { @@ -450,15 +447,12 @@ describe('DocumentDetailComponent', () => { const closeSpy = jest.spyOn(component, 'close') const updateSpy = jest.spyOn(documentService, 'update') const toastSpy = jest.spyOn(toastService, 'showError') - updateSpy.mockImplementation(() => - throwError(() => new Error('failed to save')) - ) + const error = new Error('failed to save') + updateSpy.mockImplementation(() => throwError(() => error)) component.saveEditNext() expect(updateSpy).toHaveBeenCalled() expect(closeSpy).not.toHaveBeenCalled() - expect(toastSpy).toHaveBeenCalledWith( - 'Error saving document: failed to save' - ) + expect(toastSpy).toHaveBeenCalledWith('Error saving document', error) }) it('should show save button and save & close or save & next', () => { @@ -798,11 +792,7 @@ describe('DocumentDetailComponent', () => { .mockReturnValue(throwError(() => error)) const toastSpy = jest.spyOn(toastService, 'showError') initNormally() - expect(toastSpy).toHaveBeenCalledWith( - 'Error retrieving metadata', - 10000, - error - ) + expect(toastSpy).toHaveBeenCalledWith('Error retrieving metadata', error) }) function initNormally() { diff --git a/src-ui/src/app/components/document-detail/document-detail.component.ts b/src-ui/src/app/components/document-detail/document-detail.component.ts index 7337028da..b75e0783f 100644 --- a/src-ui/src/app/components/document-detail/document-detail.component.ts +++ b/src-ui/src/app/components/document-detail/document-detail.component.ts @@ -395,7 +395,6 @@ export class DocumentDetailComponent this.metadata = null this.toastService.showError( $localize`Error retrieving metadata`, - 10000, error ) }, @@ -417,7 +416,6 @@ export class DocumentDetailComponent this.suggestions = null this.toastService.showError( $localize`Error retrieving suggestions.`, - 10000, error ) }, @@ -542,11 +540,7 @@ export class DocumentDetailComponent close && this.close() } else { this.error = error.error - this.toastService.showError( - $localize`Error saving document` + - ': ' + - (error.error?.detail ?? error.message ?? JSON.stringify(error)) - ) + this.toastService.showError($localize`Error saving document`, error) } }, }) @@ -587,11 +581,7 @@ export class DocumentDetailComponent error: (error) => { this.networkActive = false this.error = error.error - this.toastService.showError( - $localize`Error saving document` + - ': ' + - (error.error?.detail ?? error.message ?? JSON.stringify(error)) - ) + this.toastService.showError($localize`Error saving document`, error) }, }) } @@ -640,11 +630,7 @@ export class DocumentDetailComponent this.close() }, error: (error) => { - this.toastService.showError( - $localize`Error deleting document: ${ - error.error?.detail ?? error.message ?? JSON.stringify(error) - }` - ) + this.toastService.showError($localize`Error deleting document`, error) modal.componentInstance.buttonsEnabled = true this.subscribeModalDelete(modal) }, @@ -687,9 +673,8 @@ export class DocumentDetailComponent modal.componentInstance.buttonsEnabled = true } this.toastService.showError( - $localize`Error executing operation: ${JSON.stringify( - error.error - )}` + $localize`Error executing operation`, + error ) }, }) diff --git a/src-ui/src/app/components/document-list/bulk-editor/bulk-editor.component.ts b/src-ui/src/app/components/document-list/bulk-editor/bulk-editor.component.ts index 57623ceaf..1b1186834 100644 --- a/src-ui/src/app/components/document-list/bulk-editor/bulk-editor.component.ts +++ b/src-ui/src/app/components/document-list/bulk-editor/bulk-editor.component.ts @@ -182,9 +182,8 @@ export class BulkEditorComponent modal.componentInstance.buttonsEnabled = true } this.toastService.showError( - $localize`Error executing bulk operation: ${JSON.stringify( - error.error - )}` + $localize`Error executing bulk operation`, + error ) }, }) diff --git a/src-ui/src/app/components/document-notes/document-notes.component.ts b/src-ui/src/app/components/document-notes/document-notes.component.ts index 01a104fb2..1ee6edd96 100644 --- a/src-ui/src/app/components/document-notes/document-notes.component.ts +++ b/src-ui/src/app/components/document-notes/document-notes.component.ts @@ -63,11 +63,7 @@ export class DocumentNotesComponent extends ComponentWithPermissions { }, error: (e) => { this.networkActive = false - this.toastService.showError( - $localize`Error saving note`, - 10000, - JSON.stringify(e) - ) + this.toastService.showError($localize`Error saving note`, e) }, }) } @@ -81,9 +77,7 @@ export class DocumentNotesComponent extends ComponentWithPermissions { }, error: (e) => { this.networkActive = false - this.toastService.showError( - $localize`Error deleting note: ${e.toString()}` - ) + this.toastService.showError($localize`Error deleting note`, e) }, }) } diff --git a/src-ui/src/app/components/manage/management-list/management-list.component.ts b/src-ui/src/app/components/manage/management-list/management-list.component.ts index b45c234ea..cfe82ec45 100644 --- a/src-ui/src/app/components/manage/management-list/management-list.component.ts +++ b/src-ui/src/app/components/manage/management-list/management-list.component.ts @@ -148,8 +148,7 @@ export abstract class ManagementListComponent activeModal.componentInstance.failed.subscribe((e) => { this.toastService.showError( $localize`Error occurred while creating ${this.typeName}.`, - 10000, - JSON.stringify(e) + e ) }) } @@ -169,8 +168,7 @@ export abstract class ManagementListComponent activeModal.componentInstance.failed.subscribe((e) => { this.toastService.showError( $localize`Error occurred while saving ${this.typeName}.`, - 10000, - JSON.stringify(e) + e ) }) } @@ -194,20 +192,19 @@ export abstract class ManagementListComponent activeModal.componentInstance.btnCaption = $localize`Delete` activeModal.componentInstance.confirmClicked.subscribe(() => { activeModal.componentInstance.buttonsEnabled = false - this.service.delete(object).subscribe( - (_) => { + this.service.delete(object).subscribe({ + next: () => { activeModal.close() this.reloadData() }, - (error) => { + error: (error) => { activeModal.componentInstance.buttonsEnabled = true this.toastService.showError( - $localize`Error while deleting element: ${JSON.stringify( - error.error - )}` + $localize`Error while deleting element`, + error ) - } - ) + }, + }) }) } 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 785e5d347..d692892ef 100644 --- a/src-ui/src/app/components/manage/settings/settings.component.ts +++ b/src-ui/src/app/components/manage/settings/settings.component.ts @@ -276,18 +276,13 @@ export class SettingsComponent error: (e) => { this.toastService.showError( $localize`Error retrieving groups`, - 10000, - JSON.stringify(e) + e ) }, }) }, error: (e) => { - this.toastService.showError( - $localize`Error retrieving users`, - 10000, - JSON.stringify(e) - ) + this.toastService.showError($localize`Error retrieving users`, e) }, }) } else if ( @@ -312,8 +307,7 @@ export class SettingsComponent error: (e) => { this.toastService.showError( $localize`Error retrieving mail rules`, - 10000, - JSON.stringify(e) + e ) }, }) @@ -321,8 +315,7 @@ export class SettingsComponent error: (e) => { this.toastService.showError( $localize`Error retrieving mail accounts`, - 10000, - JSON.stringify(e) + e ) }, }) @@ -646,8 +639,7 @@ export class SettingsComponent error: (error) => { this.toastService.showError( $localize`An error occurred while saving settings.`, - 10000, - JSON.stringify(error) + error ) }, }) @@ -682,8 +674,7 @@ export class SettingsComponent (error) => { this.toastService.showError( $localize`Error while storing settings on server.`, - 10000, - JSON.stringify(error) + error ) } ) @@ -742,11 +733,7 @@ export class SettingsComponent modal.componentInstance.failed .pipe(takeUntil(this.unsubscribeNotifier)) .subscribe((e) => { - this.toastService.showError( - $localize`Error saving user.`, - 10000, - JSON.stringify(e) - ) + this.toastService.showError($localize`Error saving user.`, e) }) } @@ -771,11 +758,7 @@ export class SettingsComponent }) }, error: (e) => { - this.toastService.showError( - $localize`Error deleting user.`, - 10000, - JSON.stringify(e) - ) + this.toastService.showError($localize`Error deleting user.`, e) }, }) }) @@ -802,11 +785,7 @@ export class SettingsComponent modal.componentInstance.failed .pipe(takeUntil(this.unsubscribeNotifier)) .subscribe((e) => { - this.toastService.showError( - $localize`Error saving group.`, - 10000, - JSON.stringify(e) - ) + this.toastService.showError($localize`Error saving group.`, e) }) } @@ -831,11 +810,7 @@ export class SettingsComponent }) }, error: (e) => { - this.toastService.showError( - $localize`Error deleting group.`, - 10000, - JSON.stringify(e) - ) + this.toastService.showError($localize`Error deleting group.`, e) }, }) }) @@ -869,11 +844,7 @@ export class SettingsComponent modal.componentInstance.failed .pipe(takeUntil(this.unsubscribeNotifier)) .subscribe((e) => { - this.toastService.showError( - $localize`Error saving account.`, - 10000, - JSON.stringify(e) - ) + this.toastService.showError($localize`Error saving account.`, e) }) } @@ -901,8 +872,7 @@ export class SettingsComponent error: (e) => { this.toastService.showError( $localize`Error deleting mail account.`, - 10000, - JSON.stringify(e) + e ) }, }) @@ -932,11 +902,7 @@ export class SettingsComponent modal.componentInstance.failed .pipe(takeUntil(this.unsubscribeNotifier)) .subscribe((e) => { - this.toastService.showError( - $localize`Error saving rule.`, - 10000, - JSON.stringify(e) - ) + this.toastService.showError($localize`Error saving rule.`, e) }) } @@ -962,11 +928,7 @@ export class SettingsComponent }) }, error: (e) => { - this.toastService.showError( - $localize`Error deleting mail rule.`, - 10000, - JSON.stringify(e) - ) + this.toastService.showError($localize`Error deleting mail rule.`, e) }, }) }) diff --git a/src-ui/src/app/services/toast.service.ts b/src-ui/src/app/services/toast.service.ts index ef282c522..b1caaf9b5 100644 --- a/src-ui/src/app/services/toast.service.ts +++ b/src-ui/src/app/services/toast.service.ts @@ -32,7 +32,7 @@ export class ToastService { this.toastsSubject.next(this.toasts) } - showError(content: string, delay: number = 10000, error: any = null) { + showError(content: string, error: any = null, delay: number = 10000) { this.show({ title: $localize`Error`, content: content, diff --git a/src-ui/src/theme.scss b/src-ui/src/theme.scss index 33748c81b..bcfceb6ec 100644 --- a/src-ui/src/theme.scss +++ b/src-ui/src/theme.scss @@ -249,6 +249,10 @@ $form-check-radio-checked-bg-image-dark: url("data:image/svg+xml,