2022-03-11 10:53:32 -08:00
|
|
|
import {
|
|
|
|
|
Component,
|
|
|
|
|
EventEmitter,
|
|
|
|
|
Input,
|
|
|
|
|
OnInit,
|
|
|
|
|
Output,
|
|
|
|
|
ViewChild,
|
|
|
|
|
} from '@angular/core'
|
|
|
|
|
import { DomSanitizer } from '@angular/platform-browser'
|
|
|
|
|
import { PaperlessDocument } from 'src/app/data/paperless-document'
|
|
|
|
|
import { DocumentService } from 'src/app/services/rest/document.service'
|
|
|
|
|
import {
|
|
|
|
|
SettingsService,
|
|
|
|
|
SETTINGS_KEYS,
|
|
|
|
|
} from 'src/app/services/settings.service'
|
|
|
|
|
import { NgbPopover } from '@ng-bootstrap/ng-bootstrap'
|
|
|
|
|
import { DocumentListViewService } from 'src/app/services/document-list-view.service'
|
|
|
|
|
import { FILTER_FULLTEXT_MORELIKE } from 'src/app/data/filter-rule-type'
|
2020-10-27 01:10:18 +01:00
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
|
selector: 'app-document-card-large',
|
|
|
|
|
templateUrl: './document-card-large.component.html',
|
2022-03-11 10:53:32 -08:00
|
|
|
styleUrls: [
|
|
|
|
|
'./document-card-large.component.scss',
|
|
|
|
|
'../popover-preview/popover-preview.scss',
|
|
|
|
|
],
|
2020-10-27 01:10:18 +01:00
|
|
|
})
|
|
|
|
|
export class DocumentCardLargeComponent implements OnInit {
|
2022-03-11 10:53:32 -08:00
|
|
|
constructor(
|
|
|
|
|
private documentService: DocumentService,
|
|
|
|
|
private sanitizer: DomSanitizer,
|
|
|
|
|
private settingsService: SettingsService
|
|
|
|
|
) {}
|
2020-10-27 01:10:18 +01:00
|
|
|
|
2020-12-22 02:43:18 +01:00
|
|
|
@Input()
|
2020-12-26 01:08:54 +01:00
|
|
|
selected = false
|
|
|
|
|
|
2020-12-22 02:43:18 +01:00
|
|
|
@Output()
|
2021-01-14 10:56:30 -08:00
|
|
|
toggleSelected = new EventEmitter()
|
2020-12-22 02:43:18 +01:00
|
|
|
|
|
|
|
|
get selectable() {
|
2021-01-14 10:56:30 -08:00
|
|
|
return this.toggleSelected.observers.length > 0
|
2020-12-22 02:43:18 +01:00
|
|
|
}
|
|
|
|
|
|
2020-10-27 01:10:18 +01:00
|
|
|
@Input()
|
|
|
|
|
document: PaperlessDocument
|
|
|
|
|
|
2020-11-28 21:28:07 +01:00
|
|
|
@Output()
|
2020-12-03 20:28:17 +01:00
|
|
|
clickTag = new EventEmitter<number>()
|
2020-11-28 21:28:07 +01:00
|
|
|
|
|
|
|
|
@Output()
|
2020-12-03 20:28:17 +01:00
|
|
|
clickCorrespondent = new EventEmitter<number>()
|
2020-11-28 21:28:07 +01:00
|
|
|
|
2021-03-12 07:21:00 -08:00
|
|
|
@Output()
|
|
|
|
|
clickDocumentType = new EventEmitter<number>()
|
|
|
|
|
|
2021-03-17 22:25:22 +01:00
|
|
|
@Output()
|
2022-03-11 10:53:32 -08:00
|
|
|
clickMoreLike = new EventEmitter()
|
2021-03-17 22:25:22 +01:00
|
|
|
|
2021-02-24 13:02:26 -08:00
|
|
|
@ViewChild('popover') popover: NgbPopover
|
|
|
|
|
|
|
|
|
|
mouseOnPreview = false
|
|
|
|
|
popoverHidden = true
|
|
|
|
|
|
2020-12-17 21:36:21 +01:00
|
|
|
get searchScoreClass() {
|
2021-04-03 21:50:05 +02:00
|
|
|
if (this.document.__search_hit__) {
|
|
|
|
|
if (this.document.__search_hit__.score > 0.7) {
|
2022-03-11 10:53:32 -08:00
|
|
|
return 'success'
|
2021-04-03 21:50:05 +02:00
|
|
|
} else if (this.document.__search_hit__.score > 0.3) {
|
2022-03-11 10:53:32 -08:00
|
|
|
return 'warning'
|
2021-04-03 21:50:05 +02:00
|
|
|
} else {
|
2022-03-11 10:53:32 -08:00
|
|
|
return 'danger'
|
2021-04-03 21:50:05 +02:00
|
|
|
}
|
2020-12-17 21:36:21 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-11 10:53:32 -08:00
|
|
|
ngOnInit(): void {}
|
2020-10-27 01:10:18 +01:00
|
|
|
|
2021-02-25 13:57:45 +01:00
|
|
|
getIsThumbInverted() {
|
|
|
|
|
return this.settingsService.get(SETTINGS_KEYS.DARK_MODE_THUMB_INVERTED)
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-27 01:10:18 +01:00
|
|
|
getThumbUrl() {
|
|
|
|
|
return this.documentService.getThumbUrl(this.document.id)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
getDownloadUrl() {
|
|
|
|
|
return this.documentService.getDownloadUrl(this.document.id)
|
|
|
|
|
}
|
2020-11-28 14:50:14 +01:00
|
|
|
|
2021-03-06 14:50:38 -08:00
|
|
|
get previewUrl() {
|
2020-11-28 14:50:14 +01:00
|
|
|
return this.documentService.getPreviewUrl(this.document.id)
|
|
|
|
|
}
|
2021-02-24 13:02:26 -08:00
|
|
|
|
|
|
|
|
mouseEnterPreview() {
|
|
|
|
|
this.mouseOnPreview = true
|
|
|
|
|
if (!this.popover.isOpen()) {
|
|
|
|
|
// we're going to open but hide to pre-load content during hover delay
|
|
|
|
|
this.popover.open()
|
|
|
|
|
this.popoverHidden = true
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
if (this.mouseOnPreview) {
|
|
|
|
|
// show popover
|
|
|
|
|
this.popoverHidden = false
|
|
|
|
|
} else {
|
|
|
|
|
this.popover.close()
|
|
|
|
|
}
|
2022-03-11 10:53:32 -08:00
|
|
|
}, 600)
|
2021-02-24 13:02:26 -08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
mouseLeavePreview() {
|
|
|
|
|
this.mouseOnPreview = false
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
mouseLeaveCard() {
|
|
|
|
|
this.popover.close()
|
|
|
|
|
}
|
2021-03-17 22:25:22 +01:00
|
|
|
|
|
|
|
|
get contentTrimmed() {
|
|
|
|
|
return this.document.content.substr(0, 500)
|
|
|
|
|
}
|
2020-10-27 01:10:18 +01:00
|
|
|
}
|