mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-04-02 13:45:10 -05:00
Revert "Merge branch 'feature-frontend-task-queue' of github.com:paperless-ngx/paperless-ngx into feature-frontend-task-queue"
This reverts commit 011164bc32e639189bf9c7be0665199b61734e77, reversing changes made to 0a43ce9cedf5158f21bb6f9ecc6ba2fdab205a1e.
This commit is contained in:
parent
011164bc32
commit
0e34923114
@ -1,12 +1,24 @@
|
||||
<app-page-header title="File Tasks" i18n-title>
|
||||
<button class="btn btn-sm btn-outline-primary" (click)="tasksService.reload()">
|
||||
<svg class="sidebaricon" fill="currentColor">
|
||||
<use xlink:href="assets/bootstrap-icons.svg#arrow-clockwise"/>
|
||||
</svg> <ng-container i18n>Refresh</ng-container>
|
||||
</button>
|
||||
<div class="btn-toolbar col col-md-auto">
|
||||
<button class="btn btn-sm btn-outline-secondary me-2" (click)="clearSelection()" [hidden]="selectedTasks.size == 0">
|
||||
<svg class="sidebaricon" fill="currentColor">
|
||||
<use xlink:href="assets/bootstrap-icons.svg#x"/>
|
||||
</svg> <ng-container i18n>Clear selection</ng-container>
|
||||
</button>
|
||||
<button class="btn btn-sm btn-outline-primary me-4" (click)="dismissTasks()" [disabled]="tasksService.total == 0">
|
||||
<svg class="sidebaricon" fill="currentColor">
|
||||
<use xlink:href="assets/bootstrap-icons.svg#check2-all"/>
|
||||
</svg> <ng-container i18n>{{dismissButtonText}}</ng-container>
|
||||
</button>
|
||||
<button class="btn btn-sm btn-outline-primary" (click)="tasksService.reload()">
|
||||
<svg class="sidebaricon" fill="currentColor">
|
||||
<use xlink:href="assets/bootstrap-icons.svg#arrow-clockwise"/>
|
||||
</svg> <ng-container i18n>Refresh</ng-container>
|
||||
</button>
|
||||
</div>
|
||||
</app-page-header>
|
||||
|
||||
<ng-container *ngIf="!tasksService.completed && tasksService.loading">
|
||||
<ng-container *ngIf="!tasksService.completedFileTasks && tasksService.loading">
|
||||
<div class="spinner-border spinner-border-sm fw-normal ms-2 me-auto" role="status"></div>
|
||||
<div class="visually-hidden" i18n>Loading...</div>
|
||||
</ng-container>
|
||||
@ -17,8 +29,7 @@
|
||||
<tr>
|
||||
<th scope="col">
|
||||
<div class="form-check">
|
||||
<!-- [checked]="list.isSelected(d)" (click)="toggleSelected(d, $event); $event.stopPropagation();" -->
|
||||
<input type="checkbox" class="form-check-input" id="all-tasks">
|
||||
<input type="checkbox" class="form-check-input" id="all-tasks" [disabled]="currentTasks.length == 0" (click)="toggleAll($event); $event.stopPropagation();">
|
||||
<label class="form-check-label" for="all-tasks"></label>
|
||||
</div>
|
||||
</th>
|
||||
@ -32,8 +43,7 @@
|
||||
<tr *ngFor="let task of tasks">
|
||||
<th>
|
||||
<div class="form-check">
|
||||
<!-- [checked]="list.isSelected(d)" (click)="toggleSelected(d, $event); $event.stopPropagation();" -->
|
||||
<input type="checkbox" class="form-check-input" id="task{{task.id}}">
|
||||
<input type="checkbox" class="form-check-input" id="task{{task.id}}" [checked]="selectedTasks.has(task.id)" (click)="toggleSelected(task, $event); $event.stopPropagation();">
|
||||
<label class="form-check-label" for="task{{task.id}}"></label>
|
||||
</div>
|
||||
</th>
|
||||
@ -61,23 +71,23 @@
|
||||
</table>
|
||||
</ng-template>
|
||||
|
||||
<ul ngbNav #nav="ngbNav" class="nav-tabs">
|
||||
<li ngbNavItem>
|
||||
<a ngbNavLink i18n>Incomplete <span class="badge bg-secondary ms-1">{{tasksService.incomplete.length}}</span></a>
|
||||
<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.incomplete}"></ng-container>
|
||||
<ng-container [ngTemplateOutlet]="tasksTemplate" [ngTemplateOutletContext]="{tasks:tasksService.incompleteFileTasks}"></ng-container>
|
||||
</ng-template>
|
||||
</li>
|
||||
<li ngbNavItem>
|
||||
<a ngbNavLink i18n>Completed <span class="badge bg-secondary ms-1">{{tasksService.completed.length}}</span></a>
|
||||
<li ngbNavItem="completed">
|
||||
<a ngbNavLink i18n>Completed <span class="badge bg-secondary ms-1">{{tasksService.completedFileTasks.length}}</span></a>
|
||||
<ng-template ngbNavContent>
|
||||
<ng-container [ngTemplateOutlet]="tasksTemplate" [ngTemplateOutletContext]="{tasks:tasksService.completed}"></ng-container>
|
||||
<ng-container [ngTemplateOutlet]="tasksTemplate" [ngTemplateOutletContext]="{tasks:tasksService.completedFileTasks}"></ng-container>
|
||||
</ng-template>
|
||||
</li>
|
||||
<li ngbNavItem>
|
||||
<a ngbNavLink i18n>Failed <span class="badge bg-secondary ms-1">{{tasksService.failed.length}}</span></a>
|
||||
<li ngbNavItem="failed">
|
||||
<a ngbNavLink i18n>Failed <span class="badge bg-secondary ms-1">{{tasksService.failedFileTasks.length}}</span></a>
|
||||
<ng-template ngbNavContent>
|
||||
<ng-container [ngTemplateOutlet]="tasksTemplate" [ngTemplateOutletContext]="{tasks:tasksService.failed}"></ng-container>
|
||||
<ng-container [ngTemplateOutlet]="tasksTemplate" [ngTemplateOutletContext]="{tasks:tasksService.failedFileTasks}"></ng-container>
|
||||
</ng-template>
|
||||
</li>
|
||||
</ul>
|
||||
|
@ -9,8 +9,16 @@ import { TasksService } from 'src/app/services/tasks.service'
|
||||
styleUrls: ['./tasks.component.scss'],
|
||||
})
|
||||
export class TasksComponent implements OnInit, OnDestroy {
|
||||
public activeTab: string
|
||||
public selectedTasks: Set<number> = new Set()
|
||||
private unsubscribeNotifer = new Subject()
|
||||
|
||||
get dismissButtonText(): string {
|
||||
return this.selectedTasks.size > 0
|
||||
? $localize`Dismiss selected`
|
||||
: $localize`Dismiss all`
|
||||
}
|
||||
|
||||
constructor(public tasksService: TasksService) {}
|
||||
|
||||
ngOnInit() {
|
||||
@ -21,7 +29,50 @@ export class TasksComponent implements OnInit, OnDestroy {
|
||||
this.unsubscribeNotifer.next(true)
|
||||
}
|
||||
|
||||
acknowledgeTask(task: PaperlessTask) {
|
||||
throw new Error('Not implemented' + task)
|
||||
dismissTask(task: PaperlessTask) {
|
||||
this.dismissTasks(task)
|
||||
}
|
||||
|
||||
dismissTasks(task: PaperlessTask = undefined) {
|
||||
let tasks = task ? new Set([task.id]) : this.selectedTasks
|
||||
if (this.selectedTasks.size == 0)
|
||||
tasks = new Set(this.currentTasks.map((t) => t.id))
|
||||
this.tasksService.dismissTasks(tasks)
|
||||
}
|
||||
|
||||
toggleSelected(task: PaperlessTask) {
|
||||
this.selectedTasks.has(task.id)
|
||||
? this.selectedTasks.delete(task.id)
|
||||
: this.selectedTasks.add(task.id)
|
||||
}
|
||||
|
||||
get currentTasks(): PaperlessTask[] {
|
||||
let tasks: PaperlessTask[]
|
||||
switch (this.activeTab) {
|
||||
case 'incomplete':
|
||||
tasks = this.tasksService.incompleteFileTasks
|
||||
break
|
||||
case 'completed':
|
||||
tasks = this.tasksService.completedFileTasks
|
||||
break
|
||||
case 'failed':
|
||||
tasks = this.tasksService.failedFileTasks
|
||||
break
|
||||
default:
|
||||
break
|
||||
}
|
||||
return tasks
|
||||
}
|
||||
|
||||
toggleAll(event: PointerEvent) {
|
||||
if ((event.target as HTMLInputElement).checked) {
|
||||
this.selectedTasks = new Set(this.currentTasks.map((t) => t.id))
|
||||
} else {
|
||||
this.clearSelection()
|
||||
}
|
||||
}
|
||||
|
||||
clearSelection() {
|
||||
this.selectedTasks = new Set()
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,25 @@
|
||||
import { ObjectWithId } from './object-with-id'
|
||||
|
||||
export enum PaperlessTaskType {
|
||||
// just file tasks, for now
|
||||
File = 'file',
|
||||
}
|
||||
|
||||
export enum PaperlessTaskStatus {
|
||||
Incomplete = 'incomplete',
|
||||
Complete = 'complete',
|
||||
Failed = 'failed',
|
||||
Unknown = 'unknown',
|
||||
}
|
||||
|
||||
export interface PaperlessTask extends ObjectWithId {
|
||||
type: PaperlessTaskType
|
||||
|
||||
status: PaperlessTaskStatus
|
||||
|
||||
acknowledged: boolean
|
||||
|
||||
q_task_id: string
|
||||
task_id: string
|
||||
|
||||
name: string
|
||||
|
||||
|
@ -1,16 +1,13 @@
|
||||
import { HttpClient } from '@angular/common/http'
|
||||
import { Injectable } from '@angular/core'
|
||||
import { Observable } from 'rxjs'
|
||||
import { first, map } from 'rxjs/operators'
|
||||
import { PaperlessTask } from 'src/app/data/paperless-task'
|
||||
import {
|
||||
PaperlessTask,
|
||||
PaperlessTaskStatus,
|
||||
PaperlessTaskType,
|
||||
} from 'src/app/data/paperless-task'
|
||||
import { environment } from 'src/environments/environment'
|
||||
|
||||
interface TasksAPIResponse {
|
||||
incomplete: Array<PaperlessTask>
|
||||
completed: Array<PaperlessTask>
|
||||
failed: Array<PaperlessTask>
|
||||
}
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
@ -19,19 +16,26 @@ export class TasksService {
|
||||
|
||||
loading: boolean
|
||||
|
||||
private incompleteTasks: PaperlessTask[] = []
|
||||
public get incomplete(): PaperlessTask[] {
|
||||
return this.incompleteTasks
|
||||
private fileTasks: PaperlessTask[] = []
|
||||
|
||||
public get total(): number {
|
||||
return this.fileTasks?.length
|
||||
}
|
||||
|
||||
private completedTasks: PaperlessTask[] = []
|
||||
public get completed(): PaperlessTask[] {
|
||||
return this.completedTasks
|
||||
public get incompleteFileTasks(): PaperlessTask[] {
|
||||
return this.fileTasks.filter(
|
||||
(t) => t.status == PaperlessTaskStatus.Incomplete
|
||||
)
|
||||
}
|
||||
|
||||
private failedTasks: PaperlessTask[] = []
|
||||
public get failed(): PaperlessTask[] {
|
||||
return this.failedTasks
|
||||
public get completedFileTasks(): PaperlessTask[] {
|
||||
return this.fileTasks.filter(
|
||||
(t) => t.status == PaperlessTaskStatus.Complete
|
||||
)
|
||||
}
|
||||
|
||||
public get failedFileTasks(): PaperlessTask[] {
|
||||
return this.fileTasks.filter((t) => t.status == PaperlessTaskStatus.Failed)
|
||||
}
|
||||
|
||||
constructor(private http: HttpClient) {}
|
||||
@ -40,46 +44,23 @@ export class TasksService {
|
||||
this.loading = true
|
||||
|
||||
this.http
|
||||
.get<TasksAPIResponse>(`${this.baseUrl}consumption_tasks/`)
|
||||
.get<PaperlessTask[]>(`${this.baseUrl}tasks/`)
|
||||
.pipe(first())
|
||||
.subscribe((r) => {
|
||||
this.incompleteTasks = r.incomplete
|
||||
this.completedTasks = r.completed
|
||||
this.failedTasks = r.failed
|
||||
this.fileTasks = r.filter((t) => t.type == PaperlessTaskType.File) // they're all File tasks, for now
|
||||
this.loading = false
|
||||
return true
|
||||
})
|
||||
}
|
||||
|
||||
// private savedViews: PaperlessSavedView[] = []
|
||||
|
||||
// get allViews() {
|
||||
// return this.savedViews
|
||||
// }
|
||||
|
||||
// get sidebarViews() {
|
||||
// return this.savedViews.filter((v) => v.show_in_sidebar)
|
||||
// }
|
||||
|
||||
// get dashboardViews() {
|
||||
// return this.savedViews.filter((v) => v.show_on_dashboard)
|
||||
// }
|
||||
|
||||
// create(o: PaperlessSavedView) {
|
||||
// return super.create(o).pipe(tap(() => this.reload()))
|
||||
// }
|
||||
|
||||
// update(o: PaperlessSavedView) {
|
||||
// return super.update(o).pipe(tap(() => this.reload()))
|
||||
// }
|
||||
|
||||
// patchMany(objects: PaperlessSavedView[]): Observable<PaperlessSavedView[]> {
|
||||
// return combineLatest(objects.map((o) => super.patch(o))).pipe(
|
||||
// tap(() => this.reload())
|
||||
// )
|
||||
// }
|
||||
|
||||
// delete(o: PaperlessSavedView) {
|
||||
// return super.delete(o).pipe(tap(() => this.reload()))
|
||||
// }
|
||||
public dismissTasks(task_ids: Set<number>) {
|
||||
this.http
|
||||
.post(`${this.baseUrl}acknowledge_tasks/`, {
|
||||
tasks: [...task_ids],
|
||||
})
|
||||
.pipe(first())
|
||||
.subscribe((r) => {
|
||||
this.reload()
|
||||
})
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user