import { Component, EventEmitter, Input, Output, ViewChild, } from '@angular/core' import { PaperlessDocument } from 'src/app/data/paperless-document' import { DocumentService } from 'src/app/services/rest/document.service' import { SettingsService } from 'src/app/services/settings.service' import { NgbPopover } from '@ng-bootstrap/ng-bootstrap' import { SETTINGS_KEYS } from 'src/app/data/paperless-uisettings' @Component({ selector: 'app-document-card-large', templateUrl: './document-card-large.component.html', styleUrls: [ './document-card-large.component.scss', '../popover-preview/popover-preview.scss', ], }) export class DocumentCardLargeComponent { constructor( private documentService: DocumentService, private settingsService: SettingsService ) {} @Input() selected = false @Output() toggleSelected = new EventEmitter() get selectable() { return this.toggleSelected.observers.length > 0 } @Input() document: PaperlessDocument @Output() clickTag = new EventEmitter() @Output() clickCorrespondent = new EventEmitter() @Output() clickDocumentType = new EventEmitter() @Output() clickStoragePath = new EventEmitter() @Output() clickMoreLike = new EventEmitter() @ViewChild('popover') popover: NgbPopover mouseOnPreview = false popoverHidden = true get searchScoreClass() { if (this.document.__search_hit__) { if (this.document.__search_hit__.score > 0.7) { return 'success' } else if (this.document.__search_hit__.score > 0.3) { return 'warning' } else { return 'danger' } } } get searchCommentHighlights() { let highlights = [] if ( this.document['__search_hit__'] && this.document['__search_hit__'].comment_highlights ) { // only show comments with a match highlights = ( this.document['__search_hit__'].comment_highlights as string ) .split(',') .filter((higlight) => higlight.includes(' { if (this.mouseOnPreview) { // show popover this.popoverHidden = false } else { this.popover.close() } }, 600) } } mouseLeavePreview() { this.mouseOnPreview = false } mouseLeaveCard() { this.popover.close() } get contentTrimmed() { return ( this.document.content.substr(0, 500) + (this.document.content.length > 500 ? '...' : '') ) } }