mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-12-19 16:51:23 +01:00
tasks spec settings spec manage spec document-detail spec global permissions spec documents-list & dashboard specs tasks network requests settings network requests permissions network requests manage network request bulk-edit network requests Fix specs try to get playwright working on ci rename some specs reconfigure playwright config increase webserver timeout for ci fix report path
91 lines
2.6 KiB
TypeScript
91 lines
2.6 KiB
TypeScript
import { Component, Input, OnDestroy, OnInit } from '@angular/core'
|
|
import { Router } from '@angular/router'
|
|
import { Subscription } from 'rxjs'
|
|
import { PaperlessDocument } from 'src/app/data/paperless-document'
|
|
import { PaperlessSavedView } from 'src/app/data/paperless-saved-view'
|
|
import { ConsumerStatusService } from 'src/app/services/consumer-status.service'
|
|
import { DocumentService } from 'src/app/services/rest/document.service'
|
|
import { PaperlessTag } from 'src/app/data/paperless-tag'
|
|
import { FILTER_HAS_TAGS_ALL } from 'src/app/data/filter-rule-type'
|
|
import { OpenDocumentsService } from 'src/app/services/open-documents.service'
|
|
import { DocumentListViewService } from 'src/app/services/document-list-view.service'
|
|
import { ComponentWithPermissions } from 'src/app/components/with-permissions/with-permissions.component'
|
|
|
|
@Component({
|
|
selector: 'app-saved-view-widget',
|
|
templateUrl: './saved-view-widget.component.html',
|
|
styleUrls: ['./saved-view-widget.component.scss'],
|
|
})
|
|
export class SavedViewWidgetComponent
|
|
extends ComponentWithPermissions
|
|
implements OnInit, OnDestroy
|
|
{
|
|
loading: boolean = true
|
|
|
|
constructor(
|
|
private documentService: DocumentService,
|
|
private router: Router,
|
|
private list: DocumentListViewService,
|
|
private consumerStatusService: ConsumerStatusService,
|
|
public openDocumentsService: OpenDocumentsService
|
|
) {
|
|
super()
|
|
}
|
|
|
|
@Input()
|
|
savedView: PaperlessSavedView
|
|
|
|
documents: PaperlessDocument[] = []
|
|
|
|
subscription: Subscription
|
|
|
|
ngOnInit(): void {
|
|
this.reload()
|
|
this.subscription = this.consumerStatusService
|
|
.onDocumentConsumptionFinished()
|
|
.subscribe((status) => {
|
|
this.reload()
|
|
})
|
|
}
|
|
|
|
ngOnDestroy(): void {
|
|
this.subscription.unsubscribe()
|
|
}
|
|
|
|
reload() {
|
|
this.loading = this.documents.length == 0
|
|
this.documentService
|
|
.listFiltered(
|
|
1,
|
|
10,
|
|
this.savedView.sort_field,
|
|
this.savedView.sort_reverse,
|
|
this.savedView.filter_rules,
|
|
{ truncate_content: true }
|
|
)
|
|
.subscribe((result) => {
|
|
this.loading = false
|
|
this.documents = result.results
|
|
})
|
|
}
|
|
|
|
showAll() {
|
|
if (this.savedView.show_in_sidebar) {
|
|
this.router.navigate(['view', this.savedView.id])
|
|
} else {
|
|
this.router.navigate(['documents'], {
|
|
queryParams: { view: this.savedView.id },
|
|
})
|
|
}
|
|
}
|
|
|
|
clickTag(tag: PaperlessTag, event: MouseEvent) {
|
|
event.preventDefault()
|
|
event.stopImmediatePropagation()
|
|
|
|
this.list.quickFilter([
|
|
{ rule_type: FILTER_HAS_TAGS_ALL, value: tag.id.toString() },
|
|
])
|
|
}
|
|
}
|