diff options
Diffstat (limited to 'src/albums.js')
| -rw-r--r-- | src/albums.js | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/albums.js b/src/albums.js new file mode 100644 index 0000000..5628e6d --- /dev/null +++ b/src/albums.js @@ -0,0 +1,26 @@ +import immichConnector from "./immich.js" + +export default async function initAlbums(albumsPageContainer) { + // TODO empty cells animation + + const albumsContainer = albumsPageContainer.querySelector("#albums-container") + const albumTemplate = albumsPageContainer.querySelector("#album-template") + async function createAlbum(res) { + console.log(res.albumName, res.id, res.startDate, res.endDate, res.assetCount, res.shared) + const albumClone = albumTemplate.content.cloneNode(true) + albumClone.querySelector(".album-thumb").src = await immichConnector.fetchImageSrc(res.albumThumbnailAssetId) + albumClone.querySelector(".album-name").textContent = res.albumName + albumClone.querySelector(".album-assets-count").textContent = res.assetCount.toLocaleString() + if (!res.shared) + albumClone.querySelector(".album-shared").remove() + + albumsContainer.appendChild(albumClone) + } + + const albumsResponse = await immichConnector.fetchAlbums() + + for (const res of albumsResponse) + createAlbum(res) + + return true +} |
