From e064daa217f9ee694859fdb9063a729dc9182ce4 Mon Sep 17 00:00:00 2001 From: Jan Schneider Date: Wed, 4 Sep 2024 14:22:47 +0200 Subject: [PATCH] Fix immich authentication --- wallpanel.js | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/wallpanel.js b/wallpanel.js index ce50dd7..08d00b1 100644 --- a/wallpanel.js +++ b/wallpanel.js @@ -841,6 +841,7 @@ class WallpanelView extends HuiView { this.imageOneContainer.style.left = 0; this.imageOneContainer.style.width = '100%'; this.imageOneContainer.style.height = '100%'; + this.imageOneContainer.style.border = 'none'; this.imageOneBackground.style.position = 'absolute'; this.imageOneBackground.style.pointerEvents = 'none'; @@ -848,6 +849,7 @@ class WallpanelView extends HuiView { this.imageOneBackground.style.left = 0; this.imageOneBackground.style.width = '100%'; this.imageOneBackground.style.height = '100%'; + this.imageOneBackground.style.border = 'none'; if (!this.screensaverRunning()) { this.imageOne.removeAttribute('style'); @@ -857,6 +859,7 @@ class WallpanelView extends HuiView { this.imageOne.style.width = '100%'; this.imageOne.style.height = '100%'; this.imageOne.style.objectFit = 'contain'; + this.imageOne.style.border = 'none'; this.imageOneInfoContainer.removeAttribute('style'); this.imageOneInfoContainer.style.position = 'absolute'; @@ -865,6 +868,7 @@ class WallpanelView extends HuiView { this.imageOneInfoContainer.style.left = 0; this.imageOneInfoContainer.style.width = '100%'; this.imageOneInfoContainer.style.height = '100%'; + this.imageOneInfoContainer.style.border = 'none'; if (!this.screensaverRunning()) { this.imageTwoContainer.removeAttribute('style'); @@ -876,6 +880,7 @@ class WallpanelView extends HuiView { this.imageTwoContainer.style.left = 0; this.imageTwoContainer.style.width = '100%'; this.imageTwoContainer.style.height = '100%'; + this.imageTwoContainer.style.border = 'none'; this.imageTwoBackground.style.position = 'absolute'; this.imageTwoBackground.style.pointerEvents = 'none'; @@ -883,6 +888,7 @@ class WallpanelView extends HuiView { this.imageTwoBackground.style.left = 0; this.imageTwoBackground.style.width = '100%'; this.imageTwoBackground.style.height = '100%'; + this.imageTwoBackground.style.border = 'none'; if (!this.screensaverRunning()) { this.imageTwo.removeAttribute('style'); @@ -892,6 +898,7 @@ class WallpanelView extends HuiView { this.imageTwo.style.width = '100%'; this.imageTwo.style.height = '100%'; this.imageTwo.style.objectFit = 'contain'; + this.imageTwo.style.border = 'none'; this.imageTwoInfoContainer.removeAttribute('style'); this.imageTwoInfoContainer.style.position = 'absolute'; @@ -900,6 +907,7 @@ class WallpanelView extends HuiView { this.imageTwoInfoContainer.style.left = 0; this.imageTwoInfoContainer.style.width = '100%'; this.imageTwoInfoContainer.style.height = '100%'; + this.imageTwoInfoContainer.style.border = 'none'; this.screensaverImageOverlay.removeAttribute('style'); this.screensaverImageOverlay.style.position = 'absolute'; @@ -1843,6 +1851,9 @@ class WallpanelView extends HuiView { } updateImageListFromImmichAPI(preload, preloadCallback = null) { + if (!config.immich_api_key) { + throw "immich_api_key not configured"; + } let wp = this; wp.updatingImageList = true; wp.imageList = []; @@ -1943,7 +1954,7 @@ class WallpanelView extends HuiView { } img.imageUrl = realUrl; logger.debug(`Updating image '${img.id}' from '${realUrl}'`); - if (imageSourceType() == "media-entity") { + if (["media-entity", "immich-api"].includes(imageSourceType())) { this.updateImageUrlWithHttpFetch(img, realUrl, headers); } else { img.src = realUrl; @@ -1951,12 +1962,7 @@ class WallpanelView extends HuiView { } updateImageUrlWithHttpFetch(img, url, headers) { - var http = new XMLHttpRequest(); - if (headers) { - for (const header in headers) { - http.setRequestHeader(header, headers[header]); - } - } + let http = new XMLHttpRequest(); http.onload = function() { if (this.status == 200 || this.status === 0) { img.src = "data:image/jpeg;base64," + arrayBufferToBase64(http.response); @@ -1964,6 +1970,11 @@ class WallpanelView extends HuiView { http = null; }; http.open("GET", url, true); + if (headers) { + for (const header in headers) { + http.setRequestHeader(header, headers[header]); + } + } http.responseType = "arraybuffer"; http.send(null); }