diff options
| author | Tim Keller <tjk@tjkeller.xyz> | 2025-05-05 22:56:56 -0500 |
|---|---|---|
| committer | Tim Keller <tjk@tjkeller.xyz> | 2025-05-05 22:56:56 -0500 |
| commit | f86d11c3ce1f04ee89da235d78447aed6d6d7130 (patch) | |
| tree | f253642b156ba296c9a5f9211ae95b62da3ccfb5 /src/immich.js | |
| parent | bae5fe5501117df1b16da1aeb3355056d6882648 (diff) | |
| download | immich-frame-f86d11c3ce1f04ee89da235d78447aed6d6d7130.tar.xz immich-frame-f86d11c3ce1f04ee89da235d78447aed6d6d7130.zip | |
albums page and a bunch of stuff
Diffstat (limited to 'src/immich.js')
| -rw-r--r-- | src/immich.js | 32 |
1 files changed, 26 insertions, 6 deletions
diff --git a/src/immich.js b/src/immich.js index d911007..d938fea 100644 --- a/src/immich.js +++ b/src/immich.js @@ -1,4 +1,4 @@ -export default class ImmichConnector { +class ImmichConnector { constructor(url, apiKey) { this.url = url this.apiKey = apiKey @@ -8,21 +8,41 @@ export default class ImmichConnector { return this.fetch("/albums") } - fetch(endpoint) { + #fetch(endpoint) { return fetch(this.url + "/api" + endpoint, { headers: { "x-api-key": this.apiKey } }) + } + + fetch(endpoint) { + return this.#fetch(endpoint) .then(response => { - if (!response.ok) { + if (!response.ok) throw new Error(`HTTP error! Status: ${response.status}`) - } return response.json() }) .then(data => { - console.log('Fetched data:', data) + return data }) .catch(error => { - console.error('Fetch error:', error) + console.error("Fetch error:", error) + }) + } + + fetchImageSrc(key, size) { + const url = `/assets/${key}/thumbnail` + (this.size ? `?size=${this.size}` : "") + return this.#fetch(url) + .then(response => { + if (!response.ok) + throw new Error(`HTTP error! Status: ${response.status}`) + return response.blob() + }) + .then(blob => { + return URL.createObjectURL(blob) }) } } + +const immichConnector = new ImmichConnector("http://192.168.1.13", "m5nqOoBc4uhAba21gZdCP3z8D3JT4GPxDXL2psd52EA") +document.immichConnector = immichConnector // FIXME TEMP +export default immichConnector |
