mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-04-02 13:45:10 -05:00
Properly display api errors on list filter & translate error message
This commit is contained in:
parent
0d1bcd3c13
commit
199fc6be94
@ -100,7 +100,7 @@
|
||||
<ng-container *ngTemplateOutlet="pagination"></ng-container>
|
||||
|
||||
<ng-container *ngIf="list.error ; else documentListNoError">
|
||||
<div class="alert alert-danger" role="alert">Error while loading documents: {{list.error}}</div>
|
||||
<div class="alert alert-danger" role="alert"><ng-container i18n>Error while loading documents</ng-container>: {{list.error}}</div>
|
||||
</ng-container>
|
||||
|
||||
<ng-template #documentListNoError>
|
||||
|
@ -9,7 +9,7 @@ import {
|
||||
import { PaperlessDocument } from '../data/paperless-document'
|
||||
import { PaperlessSavedView } from '../data/paperless-saved-view'
|
||||
import { DOCUMENT_LIST_SERVICE } from '../data/storage-keys'
|
||||
import { DocumentService } from './rest/document.service'
|
||||
import { DocumentService, DOCUMENT_SORT_FIELDS } from './rest/document.service'
|
||||
import { SettingsService, SETTINGS_KEYS } from './settings.service'
|
||||
|
||||
/**
|
||||
@ -160,7 +160,21 @@ export class DocumentListViewService {
|
||||
activeListViewState.currentPage = 1
|
||||
this.reload()
|
||||
} else {
|
||||
this.error = error.error
|
||||
let errorMessage
|
||||
if (Object.keys(error.error).length > 0) {
|
||||
// e.g. { archive_serial_number: Array<string> }
|
||||
errorMessage = Object.keys(error.error)
|
||||
.map((fieldName) => {
|
||||
const fieldError: Array<string> = error.error[fieldName]
|
||||
return `${
|
||||
DOCUMENT_SORT_FIELDS.find((f) => f.field == fieldName)?.name
|
||||
}: ${fieldError[0]}`
|
||||
})
|
||||
.join(', ')
|
||||
} else {
|
||||
errorMessage = error.error
|
||||
}
|
||||
this.error = errorMessage
|
||||
}
|
||||
},
|
||||
})
|
||||
|
Loading…
x
Reference in New Issue
Block a user