mirror of
				https://github.com/paperless-ngx/paperless-ngx.git
				synced 2025-11-03 19:17:13 -05:00 
			
		
		
		
	automatically refresh tasks on file socket messages too
This commit is contained in:
		
							parent
							
								
									71b34aa3bd
								
							
						
					
					
						commit
						d4a5376f73
					
				@ -7,6 +7,7 @@ import { ConsumerStatusService } from './services/consumer-status.service'
 | 
				
			|||||||
import { ToastService } from './services/toast.service'
 | 
					import { ToastService } from './services/toast.service'
 | 
				
			||||||
import { NgxFileDropEntry } from 'ngx-file-drop'
 | 
					import { NgxFileDropEntry } from 'ngx-file-drop'
 | 
				
			||||||
import { UploadDocumentsService } from './services/upload-documents.service'
 | 
					import { UploadDocumentsService } from './services/upload-documents.service'
 | 
				
			||||||
 | 
					import { TasksService } from './services/tasks.service'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@Component({
 | 
					@Component({
 | 
				
			||||||
  selector: 'app-root',
 | 
					  selector: 'app-root',
 | 
				
			||||||
@ -27,7 +28,8 @@ export class AppComponent implements OnInit, OnDestroy {
 | 
				
			|||||||
    private consumerStatusService: ConsumerStatusService,
 | 
					    private consumerStatusService: ConsumerStatusService,
 | 
				
			||||||
    private toastService: ToastService,
 | 
					    private toastService: ToastService,
 | 
				
			||||||
    private router: Router,
 | 
					    private router: Router,
 | 
				
			||||||
    private uploadDocumentsService: UploadDocumentsService
 | 
					    private uploadDocumentsService: UploadDocumentsService,
 | 
				
			||||||
 | 
					    private tasksService: TasksService
 | 
				
			||||||
  ) {
 | 
					  ) {
 | 
				
			||||||
    let anyWindow = window as any
 | 
					    let anyWindow = window as any
 | 
				
			||||||
    anyWindow.pdfWorkerSrc = 'assets/js/pdf.worker.min.js'
 | 
					    anyWindow.pdfWorkerSrc = 'assets/js/pdf.worker.min.js'
 | 
				
			||||||
@ -65,6 +67,7 @@ export class AppComponent implements OnInit, OnDestroy {
 | 
				
			|||||||
    this.successSubscription = this.consumerStatusService
 | 
					    this.successSubscription = this.consumerStatusService
 | 
				
			||||||
      .onDocumentConsumptionFinished()
 | 
					      .onDocumentConsumptionFinished()
 | 
				
			||||||
      .subscribe((status) => {
 | 
					      .subscribe((status) => {
 | 
				
			||||||
 | 
					        this.tasksService.reload()
 | 
				
			||||||
        if (
 | 
					        if (
 | 
				
			||||||
          this.showNotification(SETTINGS_KEYS.NOTIFICATIONS_CONSUMER_SUCCESS)
 | 
					          this.showNotification(SETTINGS_KEYS.NOTIFICATIONS_CONSUMER_SUCCESS)
 | 
				
			||||||
        ) {
 | 
					        ) {
 | 
				
			||||||
@ -83,6 +86,7 @@ export class AppComponent implements OnInit, OnDestroy {
 | 
				
			|||||||
    this.failedSubscription = this.consumerStatusService
 | 
					    this.failedSubscription = this.consumerStatusService
 | 
				
			||||||
      .onDocumentConsumptionFailed()
 | 
					      .onDocumentConsumptionFailed()
 | 
				
			||||||
      .subscribe((status) => {
 | 
					      .subscribe((status) => {
 | 
				
			||||||
 | 
					        this.tasksService.reload()
 | 
				
			||||||
        if (
 | 
					        if (
 | 
				
			||||||
          this.showNotification(SETTINGS_KEYS.NOTIFICATIONS_CONSUMER_FAILED)
 | 
					          this.showNotification(SETTINGS_KEYS.NOTIFICATIONS_CONSUMER_FAILED)
 | 
				
			||||||
        ) {
 | 
					        ) {
 | 
				
			||||||
@ -95,6 +99,7 @@ export class AppComponent implements OnInit, OnDestroy {
 | 
				
			|||||||
    this.newDocumentSubscription = this.consumerStatusService
 | 
					    this.newDocumentSubscription = this.consumerStatusService
 | 
				
			||||||
      .onDocumentDetected()
 | 
					      .onDocumentDetected()
 | 
				
			||||||
      .subscribe((status) => {
 | 
					      .subscribe((status) => {
 | 
				
			||||||
 | 
					        this.tasksService.reload()
 | 
				
			||||||
        if (
 | 
					        if (
 | 
				
			||||||
          this.showNotification(
 | 
					          this.showNotification(
 | 
				
			||||||
            SETTINGS_KEYS.NOTIFICATIONS_CONSUMER_NEW_DOCUMENT
 | 
					            SETTINGS_KEYS.NOTIFICATIONS_CONSUMER_NEW_DOCUMENT
 | 
				
			||||||
 | 
				
			|||||||
@ -85,23 +85,23 @@
 | 
				
			|||||||
</ng-template>
 | 
					</ng-template>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
<ul ngbNav #nav="ngbNav" [(activeId)]="activeTab" class="nav-tabs">
 | 
					<ul ngbNav #nav="ngbNav" [(activeId)]="activeTab" class="nav-tabs">
 | 
				
			||||||
  <li ngbNavItem="incomplete">
 | 
					 | 
				
			||||||
    <a ngbNavLink i18n>Incomplete <span class="badge bg-secondary ms-1">{{tasksService.incompleteFileTasks.length}}</span></a>
 | 
					 | 
				
			||||||
    <ng-template ngbNavContent>
 | 
					 | 
				
			||||||
      <ng-container [ngTemplateOutlet]="tasksTemplate" [ngTemplateOutletContext]="{tasks:tasksService.incompleteFileTasks}"></ng-container>
 | 
					 | 
				
			||||||
    </ng-template>
 | 
					 | 
				
			||||||
  </li>
 | 
					 | 
				
			||||||
  <li ngbNavItem="completed">
 | 
					 | 
				
			||||||
    <a ngbNavLink i18n>Complete <span class="badge bg-secondary ms-1">{{tasksService.completedFileTasks.length}}</span></a>
 | 
					 | 
				
			||||||
    <ng-template ngbNavContent>
 | 
					 | 
				
			||||||
      <ng-container [ngTemplateOutlet]="tasksTemplate" [ngTemplateOutletContext]="{tasks:tasksService.completedFileTasks}"></ng-container>
 | 
					 | 
				
			||||||
    </ng-template>
 | 
					 | 
				
			||||||
  </li>
 | 
					 | 
				
			||||||
  <li ngbNavItem="failed">
 | 
					  <li ngbNavItem="failed">
 | 
				
			||||||
    <a ngbNavLink i18n>Failed <span class="badge bg-danger ms-1">{{tasksService.failedFileTasks.length}}</span></a>
 | 
					    <a ngbNavLink i18n>Failed <span *ngIf="tasksService.failedFileTasks.length > 0" class="badge bg-danger ms-1">{{tasksService.failedFileTasks.length}}</span></a>
 | 
				
			||||||
    <ng-template ngbNavContent>
 | 
					    <ng-template ngbNavContent>
 | 
				
			||||||
      <ng-container [ngTemplateOutlet]="tasksTemplate" [ngTemplateOutletContext]="{tasks:tasksService.failedFileTasks}"></ng-container>
 | 
					      <ng-container [ngTemplateOutlet]="tasksTemplate" [ngTemplateOutletContext]="{tasks:tasksService.failedFileTasks}"></ng-container>
 | 
				
			||||||
    </ng-template>
 | 
					    </ng-template>
 | 
				
			||||||
  </li>
 | 
					  </li>
 | 
				
			||||||
 | 
					  <li ngbNavItem="completed">
 | 
				
			||||||
 | 
					    <a ngbNavLink i18n>Complete <span *ngIf="tasksService.completedFileTasks.length > 0" class="badge bg-secondary ms-1">{{tasksService.completedFileTasks.length}}</span></a>
 | 
				
			||||||
 | 
					    <ng-template ngbNavContent>
 | 
				
			||||||
 | 
					      <ng-container [ngTemplateOutlet]="tasksTemplate" [ngTemplateOutletContext]="{tasks:tasksService.completedFileTasks}"></ng-container>
 | 
				
			||||||
 | 
					    </ng-template>
 | 
				
			||||||
 | 
					  </li>
 | 
				
			||||||
 | 
					  <li ngbNavItem="incomplete">
 | 
				
			||||||
 | 
					    <a ngbNavLink i18n>Incomplete <span *ngIf="tasksService.incompleteFileTasks.length > 0" class="badge bg-secondary ms-1">{{tasksService.incompleteFileTasks.length}}</span></a>
 | 
				
			||||||
 | 
					    <ng-template ngbNavContent>
 | 
				
			||||||
 | 
					      <ng-container [ngTemplateOutlet]="tasksTemplate" [ngTemplateOutletContext]="{tasks:tasksService.incompleteFileTasks}"></ng-container>
 | 
				
			||||||
 | 
					    </ng-template>
 | 
				
			||||||
 | 
					  </li>
 | 
				
			||||||
</ul>
 | 
					</ul>
 | 
				
			||||||
<div [ngbNavOutlet]="nav"></div>
 | 
					<div [ngbNavOutlet]="nav"></div>
 | 
				
			||||||
 | 
				
			|||||||
@ -55,9 +55,11 @@ export class TasksComponent implements OnInit, OnDestroy {
 | 
				
			|||||||
        modal.componentInstance.buttonsEnabled = false
 | 
					        modal.componentInstance.buttonsEnabled = false
 | 
				
			||||||
        modal.close()
 | 
					        modal.close()
 | 
				
			||||||
        this.tasksService.dismissTasks(tasks)
 | 
					        this.tasksService.dismissTasks(tasks)
 | 
				
			||||||
 | 
					        this.selectedTasks.clear()
 | 
				
			||||||
      })
 | 
					      })
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
      this.tasksService.dismissTasks(tasks)
 | 
					      this.tasksService.dismissTasks(tasks)
 | 
				
			||||||
 | 
					      this.selectedTasks.clear()
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -94,6 +96,6 @@ export class TasksComponent implements OnInit, OnDestroy {
 | 
				
			|||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  clearSelection() {
 | 
					  clearSelection() {
 | 
				
			||||||
    this.selectedTasks = new Set()
 | 
					    this.selectedTasks.clear()
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user