diff --git a/src/config/constants/sidebarNavs.tsx b/src/config/constants/sidebarNavs.tsx index a7d1b26..1da0988 100644 --- a/src/config/constants/sidebarNavs.tsx +++ b/src/config/constants/sidebarNavs.tsx @@ -1,4 +1,4 @@ -import { GalleryVerticalEnd, Home, Image, LocateOff, MapPinX, User } from "lucide-react"; +import { Album, GalleryHorizontal, GalleryVerticalEnd, Home, Image, LocateOff, MapPinX, User } from "lucide-react"; export const sidebarNavs = [ { @@ -21,4 +21,9 @@ export const sidebarNavs = [ link: "/assets/missing-locations", icon: , }, + { + title: "Albums", + link: "/albums", + icon: , + }, ]; diff --git a/src/pages/albums/index.tsx b/src/pages/albums/index.tsx new file mode 100644 index 0000000..ffc0c4b --- /dev/null +++ b/src/pages/albums/index.tsx @@ -0,0 +1,73 @@ +import { ASSET_THUMBNAIL_PATH } from '@/config/routes' +import PageLayout from '@/components/layouts/PageLayout' +import Header from '@/components/shared/Header' +import Loader from '@/components/ui/loader' +import { useConfig } from '@/contexts/ConfigContext' +import { listAlbums } from '@/handlers/api/album.handler' +import { IAlbum } from '@/types/album' +import Image from 'next/image' +import Link from 'next/link' +import React, { useEffect, useState } from 'react' + +export default function AlbumListPage() { +const { exImmichUrl } = useConfig() + const [albums, setAlbums] = useState([]) + const [loading, setLoading] = useState(false) + const [errorMessage, setErrorMessage] = useState('') + + const fetchAlbums = async () => { + setLoading(true) + listAlbums() + .then(setAlbums) + .catch((error) => { + setErrorMessage(error.message) + }) + .finally(() => { + setLoading(false) + }) + } + + useEffect(() => { + fetchAlbums() + }, []) + + const renderContent = () => { + + if (loading) { + return + } + else if (errorMessage) { + return {errorMessage} + } + return ( + + {albums.map((album) => ( + + + + + {album.albumName} + + {album.assetCount} assets + + + ))} + + ) + } + return ( + + + {renderContent()} + + ) +} diff --git a/src/schema/albums.schema.ts b/src/schema/albums.schema.ts new file mode 100644 index 0000000..f1ae628 --- /dev/null +++ b/src/schema/albums.schema.ts @@ -0,0 +1,14 @@ +import { pgTable, uuid, varchar, timestamp, boolean, text } from 'drizzle-orm/pg-core'; + +export const albums = pgTable('albums', { + id: uuid('id').defaultRandom().primaryKey().notNull(), + ownerId: uuid('ownerId').notNull(), + albumName: varchar('albumName').notNull().default('Untitled Album'), + createdAt: timestamp('createdAt', { withTimezone: true }).defaultNow().notNull(), + albumThumbnailAssetId: uuid('albumThumbnailAssetId'), + updatedAt: timestamp('updatedAt', { withTimezone: true }).defaultNow().notNull(), + description: text('description').notNull().default(''), + deletedAt: timestamp('deletedAt', { withTimezone: true }), + isActivityEnabled: boolean('isActivityEnabled').notNull().default(true), + order: varchar('order').notNull().default('desc'), +});
{album.assetCount} assets