mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-07-28 18:24:38 -05:00
functions for combined upload progress bars
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
|
||||
</ngx-file-drop>
|
||||
</form>
|
||||
<p>Uploading {{getStatusUploading().length}} files...</p>
|
||||
<div *ngFor="let status of getStatus()">
|
||||
<p>{{status.filename}}: {{status.message}}</p>
|
||||
<ngb-progressbar [value]="status.getProgress()" [max]="1" [striped]="true" [animated]="!isFinished(status)" [type]="getType(status)">
|
||||
|
@@ -18,7 +18,23 @@ export class UploadFileWidgetComponent implements OnInit {
|
||||
) { }
|
||||
|
||||
getStatus() {
|
||||
return this.consumerStatusService.consumerStatus
|
||||
return this.consumerStatusService.getConsumerStatus()
|
||||
}
|
||||
|
||||
getStatusUploading() {
|
||||
return this.consumerStatusService.getConsumerStatus(FileStatusPhase.UPLOADING)
|
||||
}
|
||||
|
||||
getTotalUploadProgress() {
|
||||
let current = 0
|
||||
let max = 0
|
||||
|
||||
this.getStatusUploading().forEach(status => {
|
||||
current += status.currentPhaseProgress
|
||||
max += status.currentPhaseMaxProgress
|
||||
})
|
||||
|
||||
return current / Math.max(max, 1)
|
||||
}
|
||||
|
||||
isFinished(status: FileStatus) {
|
||||
@@ -58,14 +74,17 @@ export class UploadFileWidgetComponent implements OnInit {
|
||||
fileEntry.file((file: File) => {
|
||||
let formData = new FormData()
|
||||
formData.append('document', file, file.name)
|
||||
let status = this.consumerStatusService.newFileUpload()
|
||||
status.filename = file.name
|
||||
let status = this.consumerStatusService.newFileUpload(file.name)
|
||||
|
||||
status.message = "Connecting..."
|
||||
|
||||
this.documentService.uploadDocument(formData).subscribe(event => {
|
||||
if (event.type == HttpEventType.UploadProgress) {
|
||||
status.updateProgress(FileStatusPhase.UPLOADING, event.loaded, event.total)
|
||||
status.message = "Uploading..."
|
||||
} else if (event.type == HttpEventType.Response) {
|
||||
status.taskId = event.body["task_id"]
|
||||
status.message = "Upload complete."
|
||||
}
|
||||
|
||||
}, error => {
|
||||
|
Reference in New Issue
Block a user