From 67c90b1da8d1370c52b88e17413b7e63eb339cc5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20H=C3=A4rtl?= Date: Wed, 16 Dec 2020 16:48:11 +0100 Subject: [PATCH] Attachments sidebar MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- lib/Service/AttachmentService.php | 8 ++- src/components/card/AttachmentList.vue | 83 ++++++++++++++++++++------ 2 files changed, 71 insertions(+), 20 deletions(-) diff --git a/lib/Service/AttachmentService.php b/lib/Service/AttachmentService.php index cfb4df917..6764252b5 100644 --- a/lib/Service/AttachmentService.php +++ b/lib/Service/AttachmentService.php @@ -42,6 +42,7 @@ use OCP\ICache; use OCP\ICacheFactory; use OCP\IDBConnection; use OCP\IL10N; +use OCP\IPreview; use OCP\Share\IShare; class AttachmentService { @@ -132,9 +133,11 @@ class AttachmentService { } private function getFilesAppAttachments($cardId) { + /** @var IPreview $previewManager */ + $previewManager = \OC::$server->get(IPreview::class); $userFolder = \OC::$server->getRootFolder()->getUserFolder($this->userId); $shares = $this->shareProvider->getSharedWithByType($cardId, IShare::TYPE_DECK, -1, 0); - return array_map(function (IShare $share) use ($cardId, $userFolder) { + return array_map(function (IShare $share) use ($cardId, $userFolder, $previewManager) { $file = $share->getNode(); $nodes = $userFolder->getById($file->getId()); $userNode = array_shift($nodes); @@ -152,7 +155,8 @@ class AttachmentService { 'extendedData' => [ 'filesize' => $file->getSize(), 'mimetype' => $file->getMimeType(), - 'info' => pathinfo($file->getName()) + 'info' => pathinfo($file->getName()), + 'hasPreview' => $previewManager->isAvailable($file), ] ]; }, $shares); diff --git a/src/components/card/AttachmentList.vue b/src/components/card/AttachmentList.vue index 7e1339ba1..048bffd73 100644 --- a/src/components/card/AttachmentList.vue +++ b/src/components/card/AttachmentList.vue @@ -22,9 +22,14 @@