From 859efbf03ab92045d8132727406d276d5966f805 Mon Sep 17 00:00:00 2001 From: Louis Chemineau Date: Thu, 4 Jan 2024 14:12:14 +0100 Subject: [PATCH] Add live photo support base on files metadata Signed-off-by: Louis Chemineau --- .../images/images-custom-list-loadmore.cy.ts | 6 +- cypress/e2e/images/images-custom-list.cy.ts | 8 +- cypress/e2e/images/images.cy.ts | 10 +- cypress/e2e/mixins/image.ts | 2 +- cypress/e2e/non-dav-files.cy.ts | 2 +- src/components/Images.vue | 193 ++++++++++++++---- src/components/Videos.vue | 24 +-- src/mixins/Mime.js | 5 + src/mixins/PreviewUrl.js | 25 +-- src/services/FileInfo.ts | 32 +-- src/services/FileList.ts | 23 +-- src/utils/fileUtils.ts | 11 +- src/utils/livePhotoUtils.ts | 48 +++++ .../utils/models.ts | 17 +- src/utils/previewUtils.ts | 50 +++++ 15 files changed, 319 insertions(+), 137 deletions(-) create mode 100644 src/utils/livePhotoUtils.ts rename js/viewer-node_modules_nextcloud_dialogs_dist_chunks_index-2b379907_mjs.js.LICENSE.txt => src/utils/models.ts (50%) create mode 100644 src/utils/previewUtils.ts diff --git a/cypress/e2e/images/images-custom-list-loadmore.cy.ts b/cypress/e2e/images/images-custom-list-loadmore.cy.ts index be89b097b..080cfab14 100644 --- a/cypress/e2e/images/images-custom-list-loadmore.cy.ts +++ b/cypress/e2e/images/images-custom-list-loadmore.cy.ts @@ -157,7 +157,7 @@ describe('Open custom list of images in viewer with pagination', function() { }) it('The image source is the preview url', function() { - cy.get('body > .viewer .modal-container img.viewer__file.viewer__file--active') + cy.get('body > .viewer .modal-container .viewer__file.viewer__file--active img') .should('have.attr', 'src') .and('contain', '/index.php/core/preview') }) @@ -191,7 +191,7 @@ describe('Open custom list of images in viewer with pagination', function() { }) it('The image source is the preview url', function() { - cy.get('body > .viewer .modal-container img.viewer__file.viewer__file--active') + cy.get('body > .viewer .modal-container .viewer__file.viewer__file--active img') .should('have.attr', 'src') .and('contain', '/index.php/core/preview') }) @@ -211,7 +211,7 @@ describe('Open custom list of images in viewer with pagination', function() { }) it('The image source is the preview url', function() { - cy.get('body > .viewer .modal-container img.viewer__file.viewer__file--active') + cy.get('body > .viewer .modal-container .viewer__file.viewer__file--active img') .should('have.attr', 'src') .and('contain', '/index.php/core/preview') }) diff --git a/cypress/e2e/images/images-custom-list.cy.ts b/cypress/e2e/images/images-custom-list.cy.ts index 72f576d4d..fc3ca87be 100644 --- a/cypress/e2e/images/images-custom-list.cy.ts +++ b/cypress/e2e/images/images-custom-list.cy.ts @@ -108,7 +108,7 @@ describe('Open custom images list in viewer', function() { }) it('The image source is the preview url', function() { - cy.get('body > .viewer .modal-container img.viewer__file.viewer__file--active') + cy.get('body > .viewer .modal-container .viewer__file.viewer__file--active img') .should('have.attr', 'src') .and('contain', '/index.php/core/preview') }) @@ -128,7 +128,7 @@ describe('Open custom images list in viewer', function() { }) it('The image source is the preview url', function() { - cy.get('body > .viewer .modal-container img.viewer__file.viewer__file--active') + cy.get('body > .viewer .modal-container .viewer__file.viewer__file--active img') .should('have.attr', 'src') .and('contain', '/index.php/core/preview') }) @@ -147,7 +147,7 @@ describe('Open custom images list in viewer', function() { }) it('The image source is the preview url', function() { - cy.get('body > .viewer .modal-container img.viewer__file.viewer__file--active') + cy.get('body > .viewer .modal-container .viewer__file.viewer__file--active img') .should('have.attr', 'src') .and('contain', '/index.php/core/preview') }) @@ -166,7 +166,7 @@ describe('Open custom images list in viewer', function() { }) it('The image source is the preview url', function() { - cy.get('body > .viewer .modal-container img.viewer__file.viewer__file--active') + cy.get('body > .viewer .modal-container .viewer__file.viewer__file--active img') .should('have.attr', 'src') .and('contain', '/index.php/core/preview') }) diff --git a/cypress/e2e/images/images.cy.ts b/cypress/e2e/images/images.cy.ts index dae523186..3c390b071 100644 --- a/cypress/e2e/images/images.cy.ts +++ b/cypress/e2e/images/images.cy.ts @@ -63,7 +63,7 @@ describe('Open images in viewer', function() { }) it('The image source is the preview url', function() { - cy.get('body > .viewer .modal-container img.viewer__file.viewer__file--active') + cy.get('body > .viewer .modal-container .viewer__file.viewer__file--active img') .should('have.attr', 'src') .and('contain', '/index.php/core/preview') }) @@ -97,7 +97,7 @@ describe('Open images in viewer', function() { }) it('The image source is the preview url', function() { - cy.get('body > .viewer .modal-container img.viewer__file.viewer__file--active') + cy.get('body > .viewer .modal-container .viewer__file.viewer__file--active img') .should('have.attr', 'src') .and('contain', '/index.php/core/preview') }) @@ -117,7 +117,7 @@ describe('Open images in viewer', function() { }) it('The image source is the preview url', function() { - cy.get('body > .viewer .modal-container img.viewer__file.viewer__file--active') + cy.get('body > .viewer .modal-container .viewer__file.viewer__file--active img') .should('have.attr', 'src') .and('contain', '/index.php/core/preview') }) @@ -138,7 +138,7 @@ describe('Open images in viewer', function() { }) it('The image source is the preview url', function() { - cy.get('body > .viewer .modal-container img.viewer__file.viewer__file--active') + cy.get('body > .viewer .modal-container .viewer__file.viewer__file--active img') .should('have.attr', 'src') .and('contain', '/index.php/core/preview') }) @@ -158,7 +158,7 @@ describe('Open images in viewer', function() { }) it('The image source is the preview url', function() { - cy.get('body > .viewer .modal-container img.viewer__file.viewer__file--active') + cy.get('body > .viewer .modal-container .viewer__file.viewer__file--active img') .should('have.attr', 'src') .and('contain', '/index.php/core/preview') }) diff --git a/cypress/e2e/mixins/image.ts b/cypress/e2e/mixins/image.ts index 6cccfee46..39095a348 100644 --- a/cypress/e2e/mixins/image.ts +++ b/cypress/e2e/mixins/image.ts @@ -81,7 +81,7 @@ export default function(fileName = 'image1.jpg', mimeType = 'image/jpeg', source }) it(`The image source is the ${source ? 'remote' : 'preview'} url`, function() { - cy.get('body > .viewer .modal-container img.viewer__file.viewer__file--active') + cy.get('body > .viewer .modal-container .viewer__file.viewer__file--active img') .should('have.attr', 'src') .and('contain', source ?? '/index.php/core/preview') }) diff --git a/cypress/e2e/non-dav-files.cy.ts b/cypress/e2e/non-dav-files.cy.ts index efbda1aba..33ab16144 100644 --- a/cypress/e2e/non-dav-files.cy.ts +++ b/cypress/e2e/non-dav-files.cy.ts @@ -83,7 +83,7 @@ describe('Open non-dav files in viewer', function() { }) it('The image source is the remote url', function() { - cy.get('body > .viewer .modal-container img.viewer__file.viewer__file--active') + cy.get('body > .viewer .modal-container .viewer__file.viewer__file--active img') .should('have.attr', 'src') .and('contain', source) }) diff --git a/src/components/Images.vue b/src/components/Images.vue index 2a80277fe..e1bf2612d 100644 --- a/src/components/Images.vue +++ b/src/components/Images.vue @@ -21,34 +21,82 @@ --> @@ -277,7 +379,14 @@ export default { $checkered-size: 8px; $checkered-color: #efefef; -img { +.image_container { + display: flex; + align-items: center; + height: 100%; + justify-content: center; +} + +img, video { max-width: 100%; max-height: 100%; align-self: center; @@ -312,4 +421,18 @@ img { cursor: move; } } + +.live-photo_play_button { + position: absolute; + top: 0; + // left: is set dynamically on the element itself + margin: 16px !important; + display: flex; + align-items: center; + border: none; + gap: 4px; + border-radius: var(--border-radius); + padding: 4px 8px; + background-color: var(--color-main-background-blur); +} diff --git a/src/components/Videos.vue b/src/components/Videos.vue index 0f0b85eac..bcfb7a41a 100644 --- a/src/components/Videos.vue +++ b/src/components/Videos.vue @@ -56,13 +56,13 @@