From a7d7bf22b897ef41e1f6a9c893f86b1ca4c43df0 Mon Sep 17 00:00:00 2001 From: Alan Grainger <16197738+alangrainger@users.noreply.github.com> Date: Fri, 11 Jul 2025 21:09:06 +0200 Subject: [PATCH] #101 Add loading spinner --- app/package-lock.json | 4 ++-- app/package.json | 2 +- app/public/style.css | 23 +++++++++++++++++++++++ app/public/web.js | 3 +++ app/src/immich.ts | 12 ++++++++++++ app/src/render.ts | 6 +----- app/views/gallery.ejs | 1 + 7 files changed, 43 insertions(+), 8 deletions(-) diff --git a/app/package-lock.json b/app/package-lock.json index 4c86e45..e07e758 100644 --- a/app/package-lock.json +++ b/app/package-lock.json @@ -1,12 +1,12 @@ { "name": "immich-public-proxy", - "version": "1.11.4", + "version": "1.11.5", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "immich-public-proxy", - "version": "1.11.4", + "version": "1.11.5", "license": "AGPL-3.0", "dependencies": { "archiver": "^7.0.1", diff --git a/app/package.json b/app/package.json index 58e933c..57d917c 100644 --- a/app/package.json +++ b/app/package.json @@ -1,6 +1,6 @@ { "name": "immich-public-proxy", - "version": "1.11.4", + "version": "1.11.5", "scripts": { "dev": "ts-node src/index.ts", "build": "npx tsc", diff --git a/app/public/style.css b/app/public/style.css index f4a46b0..114b1b3 100644 --- a/app/public/style.css +++ b/app/public/style.css @@ -68,3 +68,26 @@ html { #download-all { margin: auto 4px auto auto; } + +#loading-spinner { + text-align: center; + margin: 75px 0; +} +.loader { + width: 48px; + height: 48px; + border: 5px solid #888; + border-bottom-color: transparent; + border-radius: 50%; + display: inline-block; + box-sizing: border-box; + animation: rotation 1s linear infinite; +} +@keyframes rotation { + 0% { + transform: rotate(0deg); + } + 100% { + transform: rotate(360deg); + } +} diff --git a/app/public/web.js b/app/public/web.js index 499c6b7..4aaaeee 100644 --- a/app/public/web.js +++ b/app/public/web.js @@ -68,6 +68,9 @@ class LGallery { }) this.index += PER_PAGE this.lightGallery.refresh() + } else { + // Remove the loading spinner once all items are loaded + document.getElementById('loading-spinner')?.remove() } } } diff --git a/app/src/immich.ts b/app/src/immich.ts index 6aa67e7..2c91084 100644 --- a/app/src/immich.ts +++ b/app/src/immich.ts @@ -254,6 +254,18 @@ class Immich { return baseUrl + query } + /** + * Return the correct preview size, depending on the image MIME type + */ + getPreviewImageSize (asset: Asset) { + // For certain media types, use the original file rather than the preview + if (['image/gif'].includes(asset.originalMimeType || '')) { + return ImageSize.original + } else { + return ImageSize.preview + } + } + /** * Return the image data URL for a photo */ diff --git a/app/src/render.ts b/app/src/render.ts index b589512..7bcc9a4 100644 --- a/app/src/render.ts +++ b/app/src/render.ts @@ -119,11 +119,7 @@ class Render { } const thumbnailUrl = baseUrl + immich.photoUrl(share.key, asset.id, ImageSize.thumbnail) - - // For certain media types, use the original file rather than the preview - const originalSizeMimes = ['image/gif'] - - const previewUrl = immich.photoUrl(share.key, asset.id, originalSizeMimes.includes(asset.originalMimeType || '') ? ImageSize.original : ImageSize.preview) + const previewUrl = immich.photoUrl(share.key, asset.id, immich.getPreviewImageSize(asset)) const description = getConfigOption('ipp.showMetadata.description', false) && typeof asset?.exifInfo?.description === 'string' ? asset.exifInfo.description.replace(/'/g, ''') : '' // Create the full HTML element source to pass to the gallery view diff --git a/app/views/gallery.ejs b/app/views/gallery.ejs index b53d80a..ab81f26 100644 --- a/app/views/gallery.ejs +++ b/app/views/gallery.ejs @@ -35,6 +35,7 @@ %><%- item.html %> <% }) %> +