From ee92ab1136918a14902e412fc3472af0192b36a1 Mon Sep 17 00:00:00 2001 From: Michael Shamoon <4887959+nikonratm@users.noreply.github.com> Date: Wed, 24 Feb 2021 13:02:26 -0800 Subject: [PATCH] Support large cards --- .../document-card-large.component.html | 17 +++++-- .../document-card-large.component.scss | 23 ++++++++++ .../document-card-large.component.ts | 45 ++++++++++++++++++- 3 files changed, 80 insertions(+), 5 deletions(-) diff --git a/src-ui/src/app/components/document-list/document-card-large/document-card-large.component.html b/src-ui/src/app/components/document-list/document-card-large/document-card-large.component.html index a47f13653..fd68996fa 100644 --- a/src-ui/src/app/components/document-list/document-card-large/document-card-large.component.html +++ b/src-ui/src/app/components/document-list/document-card-large/document-card-large.component.html @@ -1,4 +1,4 @@ -
+
@@ -43,19 +43,30 @@  Edit - +  View + + +
+ +
+
+ + + +
 Download -
diff --git a/src-ui/src/app/components/document-list/document-card-large/document-card-large.component.scss b/src-ui/src/app/components/document-list/document-card-large/document-card-large.component.scss index c49de93b5..cf4e876d4 100644 --- a/src-ui/src/app/components/document-list/document-card-large/document-card-large.component.scss +++ b/src-ui/src/app/components/document-list/document-card-large/document-card-large.component.scss @@ -37,3 +37,26 @@ .doc-img-background-selected { background-color: $primaryFaded; } + +::ng-deep .popover { + max-width: 40rem; + + .preview { + min-width: 25rem; + min-height: 15rem; + max-height: 35rem; + overflow-y: scroll; + } + + .spinner-border { + position: absolute; + top: 4rem; + left: calc(50% - 0.5rem); + z-index: 0; + } +} + +.popover-hidden ::ng-deep .popover { + opacity: 0; + pointer-events: none; +} diff --git a/src-ui/src/app/components/document-list/document-card-large/document-card-large.component.ts b/src-ui/src/app/components/document-list/document-card-large/document-card-large.component.ts index f8bb9f518..d5168476b 100644 --- a/src-ui/src/app/components/document-list/document-card-large/document-card-large.component.ts +++ b/src-ui/src/app/components/document-list/document-card-large/document-card-large.component.ts @@ -1,7 +1,9 @@ -import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'; +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 { PaperlessDocumentMetadata } from 'src/app/data/paperless-document-metadata'; import { DocumentService } from 'src/app/services/rest/document.service'; +import { NgbPopover } from '@ng-bootstrap/ng-bootstrap'; @Component({ selector: 'app-document-card-large', @@ -40,6 +42,13 @@ export class DocumentCardLargeComponent implements OnInit { @Input() searchScore: number + @ViewChild('popover') popover: NgbPopover + + mouseOnPreview = false + popoverHidden = true + + metadata: PaperlessDocumentMetadata + get searchScoreClass() { if (this.searchScore > 0.7) { return "success" @@ -51,6 +60,9 @@ export class DocumentCardLargeComponent implements OnInit { } ngOnInit(): void { + this.documentService.getMetadata(this.document?.id).subscribe(result => { + this.metadata = result + }) } getDetailsAsString() { @@ -74,7 +86,36 @@ export class DocumentCardLargeComponent implements OnInit { return this.documentService.getDownloadUrl(this.document.id) } - getPreviewUrl() { + get previewUrl() { return this.documentService.getPreviewUrl(this.document.id) } + + getContentType() { + return this.metadata?.has_archive_version ? 'application/pdf' : this.metadata?.original_mime_type + } + + 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() + } + }, 600); + } + } + + mouseLeavePreview() { + this.mouseOnPreview = false + } + + mouseLeaveCard() { + this.popover.close() + } }