Skip to content

Commit

Permalink
Fix immich authentication
Browse files Browse the repository at this point in the history
  • Loading branch information
j-a-n committed Sep 4, 2024
1 parent a2ec6e5 commit e064daa
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions wallpanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -841,13 +841,15 @@ 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';
this.imageOneBackground.style.top = 0;
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');
Expand All @@ -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';
Expand All @@ -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');
Expand All @@ -876,13 +880,15 @@ 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';
this.imageTwoBackground.style.top = 0;
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');
Expand All @@ -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';
Expand All @@ -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';
Expand Down Expand Up @@ -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 = [];
Expand Down Expand Up @@ -1943,27 +1954,27 @@ 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;
}
}

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);
}
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);
}
Expand Down

0 comments on commit e064daa

Please sign in to comment.