mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-04-09 09:58:20 -05:00
changes
This commit is contained in:
parent
fcaaf7ce03
commit
e2456f4b3f
@ -1,10 +1,12 @@
|
|||||||
<app-widget-frame title="Document consumer status">
|
<app-widget-frame title="Document consumer status">
|
||||||
<div class="mb-2 border-bottom" *ngFor="let s of getStatus()">
|
<ng-container content>
|
||||||
<div class="mb-1"><strong>{{s.filename}}:</strong> {{s.message}}</div>
|
<div class="mb-2 border-bottom" *ngFor="let s of getStatus()">
|
||||||
<ngb-progressbar [type]="getType(s.status)" [value]="s.current_progress" [max]="s.max_progress" class="mb-2"></ngb-progressbar>
|
<div class="mb-1"><strong>{{s.filename}}:</strong> {{s.message}}</div>
|
||||||
<div *ngIf="isFinished(s)" class="mb-2">
|
<ngb-progressbar [type]="getType(s.status)" [value]="s.current_progress" [max]="s.max_progress" class="mb-2"></ngb-progressbar>
|
||||||
<button *ngIf="s.document_id" class="btn btn-sm btn-outline-primary mr-2" routerLink="/documents/{{s.document_id}}" (click)="dismiss(s)">Open document</button>
|
<div *ngIf="isFinished(s)" class="mb-2">
|
||||||
<button class="btn btn-sm btn-outline-secondary" (click)="dismiss(s)">Dismiss</button>
|
<button *ngIf="s.document_id" class="btn btn-sm btn-outline-primary mr-2" routerLink="/documents/{{s.document_id}}" (click)="dismiss(s)">Open document</button>
|
||||||
|
<button class="btn btn-sm btn-outline-secondary" (click)="dismiss(s)">Dismiss</button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</ng-container>
|
||||||
</app-widget-frame>
|
</app-widget-frame>
|
||||||
|
@ -29,7 +29,7 @@ export class UploadFileWidgetComponent implements OnInit {
|
|||||||
const formData = new FormData()
|
const formData = new FormData()
|
||||||
formData.append('document', file, file.name)
|
formData.append('document', file, file.name)
|
||||||
this.documentService.uploadDocument(formData).subscribe(result => {
|
this.documentService.uploadDocument(formData).subscribe(result => {
|
||||||
this.toastService.showInfo(The document has been uploaded and will be processed by the consumer shortly.")
|
this.toastService.showInfo("The document has been uploaded and will be processed by the consumer shortly.")
|
||||||
}, error => {
|
}, error => {
|
||||||
switch (error.status) {
|
switch (error.status) {
|
||||||
case 400: {
|
case 400: {
|
||||||
|
@ -76,7 +76,7 @@ export class DocumentListComponent implements OnInit {
|
|||||||
|
|
||||||
saveViewConfig() {
|
saveViewConfig() {
|
||||||
this.savedViewConfigService.updateConfig(this.list.savedView)
|
this.savedViewConfigService.updateConfig(this.list.savedView)
|
||||||
this.toastService.showToast(Toast.make("Information", `View "${this.list.savedView.title}" saved successfully.`))
|
this.toastService.showInfo(`View "${this.list.savedView.title}" saved successfully.`)
|
||||||
}
|
}
|
||||||
|
|
||||||
saveViewConfigAs() {
|
saveViewConfigAs() {
|
||||||
|
@ -43,6 +43,11 @@ class Consumer(LoggingMixin):
|
|||||||
{'type': 'status_update',
|
{'type': 'status_update',
|
||||||
'data': payload})
|
'data': payload})
|
||||||
|
|
||||||
|
def _fail(self, message):
|
||||||
|
self._send_progress(self.filename, 100, 100, 'FAILED',
|
||||||
|
message)
|
||||||
|
raise ConsumerError(f"{self.filename}: {message}")
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self.path = None
|
self.path = None
|
||||||
@ -56,8 +61,7 @@ class Consumer(LoggingMixin):
|
|||||||
|
|
||||||
def pre_check_file_exists(self):
|
def pre_check_file_exists(self):
|
||||||
if not os.path.isfile(self.path):
|
if not os.path.isfile(self.path):
|
||||||
raise ConsumerError("Cannot consume {}: It is not a file".format(
|
self._fail("File not found")
|
||||||
self.path))
|
|
||||||
|
|
||||||
def pre_check_duplicate(self):
|
def pre_check_duplicate(self):
|
||||||
with open(self.path, "rb") as f:
|
with open(self.path, "rb") as f:
|
||||||
@ -65,9 +69,7 @@ class Consumer(LoggingMixin):
|
|||||||
if Document.objects.filter(Q(checksum=checksum) | Q(archive_checksum=checksum)).exists(): # NOQA: E501
|
if Document.objects.filter(Q(checksum=checksum) | Q(archive_checksum=checksum)).exists(): # NOQA: E501
|
||||||
if settings.CONSUMER_DELETE_DUPLICATES:
|
if settings.CONSUMER_DELETE_DUPLICATES:
|
||||||
os.unlink(self.path)
|
os.unlink(self.path)
|
||||||
raise ConsumerError(
|
self._fail("Document is a duplicate")
|
||||||
"Not consuming {}: It is a duplicate.".format(self.filename)
|
|
||||||
)
|
|
||||||
|
|
||||||
def pre_check_directories(self):
|
def pre_check_directories(self):
|
||||||
os.makedirs(settings.SCRATCH_DIR, exist_ok=True)
|
os.makedirs(settings.SCRATCH_DIR, exist_ok=True)
|
||||||
@ -93,6 +95,9 @@ class Consumer(LoggingMixin):
|
|||||||
self.override_document_type_id = override_document_type_id
|
self.override_document_type_id = override_document_type_id
|
||||||
self.override_tag_ids = override_tag_ids
|
self.override_tag_ids = override_tag_ids
|
||||||
|
|
||||||
|
self._send_progress(self.filename, 0, 100, 'WORKING',
|
||||||
|
'Received new file.')
|
||||||
|
|
||||||
# this is for grouping logging entries for this particular file
|
# this is for grouping logging entries for this particular file
|
||||||
# together.
|
# together.
|
||||||
|
|
||||||
@ -112,7 +117,7 @@ class Consumer(LoggingMixin):
|
|||||||
|
|
||||||
parser_class = get_parser_class_for_mime_type(mime_type)
|
parser_class = get_parser_class_for_mime_type(mime_type)
|
||||||
if not parser_class:
|
if not parser_class:
|
||||||
raise ConsumerError(f"No parsers abvailable for {self.filename}")
|
self._fail("No parsers abvailable")
|
||||||
else:
|
else:
|
||||||
self.log("debug",
|
self.log("debug",
|
||||||
f"Parser: {parser_class.__name__} "
|
f"Parser: {parser_class.__name__} "
|
||||||
@ -120,8 +125,6 @@ class Consumer(LoggingMixin):
|
|||||||
|
|
||||||
# Notify all listeners that we're going to do some work.
|
# Notify all listeners that we're going to do some work.
|
||||||
|
|
||||||
self._send_progress(self.filename, 0, 100, 'WORKING', 'Consumption started')
|
|
||||||
|
|
||||||
document_consumption_started.send(
|
document_consumption_started.send(
|
||||||
sender=self.__class__,
|
sender=self.__class__,
|
||||||
filename=self.path,
|
filename=self.path,
|
||||||
@ -130,7 +133,7 @@ class Consumer(LoggingMixin):
|
|||||||
|
|
||||||
def progress_callback(current_progress, max_progress, message):
|
def progress_callback(current_progress, max_progress, message):
|
||||||
# recalculate progress to be within 20 and 80
|
# recalculate progress to be within 20 and 80
|
||||||
p = int((current_progress / max_progress) * 60 + 20)
|
p = int((current_progress / max_progress) * 50 + 20)
|
||||||
self._send_progress(self.filename, p, 100, "WORKING", message)
|
self._send_progress(self.filename, p, 100, "WORKING", message)
|
||||||
|
|
||||||
# This doesn't parse the document yet, but gives us a parser.
|
# This doesn't parse the document yet, but gives us a parser.
|
||||||
@ -167,9 +170,7 @@ class Consumer(LoggingMixin):
|
|||||||
self.log(
|
self.log(
|
||||||
"error",
|
"error",
|
||||||
f"Error while consuming document {self.filename}: {e}")
|
f"Error while consuming document {self.filename}: {e}")
|
||||||
self._send_progress(self.filename, 100, 100, 'FAILED',
|
self._fail(e)
|
||||||
"Failed: {}".format(e))
|
|
||||||
raise ConsumerError(e)
|
|
||||||
|
|
||||||
# Prepare the document classifier.
|
# Prepare the document classifier.
|
||||||
|
|
||||||
@ -246,9 +247,7 @@ class Consumer(LoggingMixin):
|
|||||||
f"The following error occured while consuming "
|
f"The following error occured while consuming "
|
||||||
f"{self.filename}: {e}"
|
f"{self.filename}: {e}"
|
||||||
)
|
)
|
||||||
self._send_progress(self.filename, 100, 100, 'FAILED',
|
self._fail(str(e))
|
||||||
"Failed: {}".format(e))
|
|
||||||
raise ConsumerError(e)
|
|
||||||
finally:
|
finally:
|
||||||
document_parser.cleanup()
|
document_parser.cleanup()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user