diff --git a/.github/workflows/pr-release.yml b/.github/workflows/pr-release.yml new file mode 100644 index 0000000..0cdede3 --- /dev/null +++ b/.github/workflows/pr-release.yml @@ -0,0 +1,32 @@ +name: Build and Tag Docker Image on PR + +on: + pull_request: + types: [opened, synchronize] + +jobs: + build: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + - uses: actions/checkout@v3 + + - uses: docker/setup-buildx-action@v3 + + - uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract PR number + id: pr-number + run: echo "PR_NUMBER=${{ github.event.number }}" >> $GITHUB_ENV + + - name: Build and push Docker image + run: | + docker build --build-arg VERSION=pr-${{ env.PR_NUMBER }} \ + -t ghcr.io/${{ github.repository }}:pr-${{ env.PR_NUMBER }} . diff --git a/Dockerfile b/Dockerfile index 782e1f9..629fe2f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,6 +3,7 @@ # Install dependencies only when needed FROM node:18-alpine AS deps # Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed. + RUN apk add --no-cache libc6-compat WORKDIR /app COPY package.json ./ @@ -10,6 +11,7 @@ RUN npm install --frozen-lockfile # Rebuild the source code only when needed FROM node:18-alpine AS builder + WORKDIR /app COPY --from=deps /app/node_modules ./node_modules COPY . . diff --git a/bun.lockb b/bun.lockb index a8bbfdd..e85a8f7 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/docker-compose.build.yml b/docker-compose.build.yml index 3c431eb..23e85e3 100644 --- a/docker-compose.build.yml +++ b/docker-compose.build.yml @@ -10,5 +10,3 @@ services: - "3000:3000" env_file: - .env - environment: - - BUILD_VERSION=${BUILD_VERSION} diff --git a/next.config.mjs b/next.config.mjs index ee15efb..65ab7b9 100644 --- a/next.config.mjs +++ b/next.config.mjs @@ -1,11 +1,5 @@ /** @type {import('next').NextConfig} */ -import { readFileSync } from 'fs'; - -const { version } = JSON.parse(readFileSync('./package.json', 'utf-8')); - -console.log(`Version: ${version}`); - const nextConfig = { reactStrictMode: false, output: 'standalone', @@ -13,7 +7,7 @@ const nextConfig = { unoptimized: true, }, env: { - VERSION: process.env.BUILD_VERSION || version, + VERSION: process.env.VERSION, }, }; diff --git a/package.json b/package.json index cb37978..9b01e46 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "immich-power-tools", - "version": "0.6.1", + "version": "0.8.0", "private": true, "scripts": { "dev": "next dev", @@ -17,6 +17,7 @@ "@radix-ui/react-avatar": "^1.1.0", "@radix-ui/react-dialog": "^1.1.1", "@radix-ui/react-dropdown-menu": "^2.1.1", + "@radix-ui/react-hover-card": "^1.1.1", "@radix-ui/react-icons": "^1.3.0", "@radix-ui/react-label": "^2.1.0", "@radix-ui/react-popover": "^1.1.1", @@ -30,6 +31,7 @@ "@tanstack/react-table": "^8.20.1", "@types/cookie": "^0.6.0", "@types/qs": "^6.9.15", + "@types/react-calendar-heatmap": "^1.6.7", "axios": "^1.7.4", "chrono-node": "^1.4.9", "class-variance-authority": "^0.7.0", @@ -44,6 +46,7 @@ "pg": "^8.12.0", "qs": "^6.13.0", "react": "^18", + "react-calendar-heatmap": "^1.9.0", "react-day-picker": "9.0.8", "react-dom": "^18", "react-grid-gallery": "^1.0.1", diff --git a/src/components/albums/potential-albums/PotentialAlbumsDates.tsx b/src/components/albums/potential-albums/PotentialAlbumsDates.tsx index 31c537e..5710ec2 100644 --- a/src/components/albums/potential-albums/PotentialAlbumsDates.tsx +++ b/src/components/albums/potential-albums/PotentialAlbumsDates.tsx @@ -6,6 +6,9 @@ import React, { use, useEffect, useState } from "react"; import PotentialDateItem from "./PotentialDateItem"; import { usePotentialAlbumContext } from "@/contexts/PotentialAlbumContext"; import { useRouter } from "next/router"; +import { Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectTrigger, SelectValue } from "@/components/ui/select"; +import { Button } from "@/components/ui/button"; +import { ArrowDown, ArrowUp, ArrowUpDownIcon, SortAsc, SortDesc } from "lucide-react"; export default function PotentialAlbumsDates() { const router = useRouter(); @@ -13,13 +16,17 @@ export default function PotentialAlbumsDates() { const [dateRecords, setDateRecords] = React.useState< IPotentialAlbumsDatesResponse[] >([]); + const [filters, setFilters] = useState<{ sortBy: string, sortOrder: string }>({ sortBy: "date", sortOrder: "desc" }); const [loading, setLoading] = useState(false); const [errorMessage, setErrorMessage] = useState(null); const fetchData = async () => { - return listPotentialAlbumsDates({}) + return listPotentialAlbumsDates({ + sortBy: filters.sortBy, + sortOrder: filters.sortOrder, + }) .then(setDateRecords) .catch(setErrorMessage) .finally(() => setLoading(false)); @@ -31,15 +38,38 @@ export default function PotentialAlbumsDates() { pathname: router.pathname, query: { startDate: date }, }) - }; + useEffect(() => { fetchData(); - }, []); + }, [filters]); return ( -
+
+
+ +
+ +
+
+ {dateRecords.map((record) => ( { + return formatDate(parseDate(record.date, "yyyy-MM-dd").toISOString(), "do MMM yyyy") + }, [record.date]) return (
-

{record.date}

-

{record.asset_count} Orphan Assets

+

{dateLabel}

+

{record.asset_count} Orphan Assets

); } diff --git a/src/components/analytics/exif/AssetHeatMap.tsx b/src/components/analytics/exif/AssetHeatMap.tsx new file mode 100644 index 0000000..efb3259 --- /dev/null +++ b/src/components/analytics/exif/AssetHeatMap.tsx @@ -0,0 +1,145 @@ +import React, { useEffect, useState } from "react"; +import { getHeatMapData } from "@/handlers/api/analytics.handler"; +import { useConfig } from "@/contexts/ConfigContext"; +import { Tooltip } from "@/components/ui/tooltip"; + +type HeatMapEntry = { + date: string; + count: number; +}; + +export default function AssetHeatMap() { + const { exImmichUrl } = useConfig(); + + const [heatMapData, setHeatMapData] = useState([]); + const [loading, setLoading] = useState(false); + const [weeksPerMonth, setWeeksPerMonth] = useState([]); // Store weeks per month + + const fetchHeatMapData = async () => { + setLoading(true); + try { + const data = await getHeatMapData(); + setHeatMapData(formatHeatMapData(data)); + } finally { + setLoading(false); + } + }; + + useEffect(() => { + fetchHeatMapData(); + }, []); + + const currentDate = new Date(); + const months: string[] = []; + + // Build an array of the last 12 months + for (let i = 0; i < 12; i++) { + months.push(currentDate.toLocaleString("default", { month: "short" })); + currentDate.setMonth(currentDate.getMonth() - 1); + } + months.reverse(); + + // Flatten heatMapData to calculate min and max counts + const flattenedData = heatMapData.flat(); + const minCount = Math.min(...flattenedData.map((entry) => entry.count)); + const maxCount = Math.max(...flattenedData.map((entry) => entry.count)); + + // Check if a week contains a date with the first day of the month + const hasFirstDayOfMonth = (arr: HeatMapEntry[]) => { + return arr.some((entry) => new Date(entry.date).getDate() === 1); + }; + + const getColor = (count: number) => { + if (count === -1) return ""; + + // Calculate thresholds based on the data range + const range = maxCount - minCount; + const threshold1 = minCount + range * 0.2; + const threshold2 = minCount + range * 0.4; + const threshold3 = minCount + range * 0.6; + const threshold4 = minCount + range * 0.8; + if (count === 0) return "bg-zinc-800"; + if (count <= threshold1) return "bg-green-200"; + if (count <= threshold2) return "bg-green-400"; + if (count <= threshold3) return "bg-green-500"; + if (count <= threshold4) return "bg-green-600"; + return "bg-green-800"; + }; + + const formatHeatMapData = (data: HeatMapEntry[]) => { + const chunks = []; + const weeksPerMonthTemp: number[] = []; + let previousMonthIndex = 0; + + for (let i = 0; i < data.length; i += 7) { + const thisWeek = data.slice(i, i + 7); + chunks.push(thisWeek); + + if (hasFirstDayOfMonth(thisWeek)) { + const changeWeek = (i - previousMonthIndex) / 7; + previousMonthIndex = i; + weeksPerMonthTemp.push(changeWeek); + } + } + weeksPerMonthTemp.reverse(); + setWeeksPerMonth(weeksPerMonthTemp); + return chunks; + }; + + return ( +
+

Past Year

+ {loading ? ( +

Loading...

+ ) : ( +
+ + + + {weeksPerMonth.map((weeks, index) => ( + + ))} + + + + {heatMapData[0]?.map((_, rowIndex) => ( + + {heatMapData.map((column, colIndex) => ( + + ))} + + ))} + +
+ {months[index]} +
+ { + column[rowIndex]?.date ? ( + + +
+ ) :
+ + } +
+
+ )} +
+ ); +} diff --git a/src/components/assets/assets-options/AssetOffsetDialog.tsx b/src/components/assets/assets-options/AssetOffsetDialog.tsx new file mode 100644 index 0000000..081f8e1 --- /dev/null +++ b/src/components/assets/assets-options/AssetOffsetDialog.tsx @@ -0,0 +1,128 @@ +import React, { useEffect, useState } from 'react' +import { IAsset } from '@/types/asset'; +import { Dialog, DialogTitle, DialogHeader, DialogContent } from '@/components/ui/dialog'; +import { Label } from '@/components/ui/label'; +import { Input } from '@/components/ui/input'; +import { Button } from '@/components/ui/button'; +import { formatDate, offsetDate } from '@/helpers/date.helper'; +import LazyImage from '@/components/ui/lazy-image'; +import Image from 'next/image'; +import { updateAssets } from '@/handlers/api/asset.handler'; +import { useToast } from '@/components/ui/use-toast'; + +interface IProps { + assets: IAsset[]; + open: boolean; + toggleOpen: (open: boolean) => void; +} + +export default function AssetOffsetDialog({ assets: _assets, open, toggleOpen }: IProps) { + const { toast } = useToast(); + const [assets, setAssets] = useState(_assets); + const [offsetData, setOffsetData] = useState<{ days: number, hours: number, minutes: number, seconds: number, years: number }>({ + days: 0, + hours: 0, + minutes: 0, + seconds: 0, + years: 0 + }); + const [loading, setLoading] = useState(false); + const [assetStatus, setAssetStatus] = useState>({}); + + const handleChange = (key: keyof typeof offsetData, value: number) => { + setOffsetData({ ...offsetData, [key]: value }); + } + + const handleSubmit = async (e: React.FormEvent) => { + e.preventDefault(); + console.log(offsetData); + setLoading(true); + const promises = assets.map(async (asset) => { + setAssetStatus({ [asset.id]: 'pending' }); + await updateAssets({ + ids: [asset.id], + dateTimeOriginal: offsetDate(asset.dateTimeOriginal, offsetData) + }) + .then(() => { + setLoading(false); + toggleOpen(false); + }) + .catch((error) => { + setLoading(false); + setAssetStatus({ [asset.id]: 'error' }); + }) + }); + await Promise.all(promises); + setLoading(false); + toggleOpen(false); + toast({ + title: 'Asset dates offset', + description: 'Asset dates have been offset', + }) + } + + + useEffect(() => { + setAssets(_assets); + }, [_assets]); + + return ( + + + + Offset Asset Dates + +
+
+ + handleChange("years", parseInt(e.target.value))} /> +
+
+ + handleChange("days", parseInt(e.target.value))} /> +
+
+ + handleChange("hours", parseInt(e.target.value))} /> +
+
+ + handleChange("minutes", parseInt(e.target.value))} /> +
+
+ + handleChange("seconds", parseInt(e.target.value))} /> +
+ +
+
+ {assets.map((asset) => ( +
+
+ {assetStatus[asset.id] === 'pending' ?
+

Offsetting...

+
: ( +
{formatDate(offsetDate(asset.dateTimeOriginal, offsetData), 'PPpp')}
+ )} + {asset.originalFileName} +
{formatDate(asset.dateTimeOriginal, 'PPpp')}
+
+
+ ))} +
+
+
+ ) +} diff --git a/src/components/assets/assets-options/AssetsOptions.tsx b/src/components/assets/assets-options/AssetsOptions.tsx new file mode 100644 index 0000000..cb65e53 --- /dev/null +++ b/src/components/assets/assets-options/AssetsOptions.tsx @@ -0,0 +1,31 @@ +import { Button } from '@/components/ui/button' +import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from '@/components/ui/dropdown-menu'; +import { IAsset } from '@/types/asset'; +import { DotsVerticalIcon, HamburgerMenuIcon } from '@radix-ui/react-icons'; +import { Clock, PlusIcon } from 'lucide-react' +import React, { useState } from 'react' +import AssetOffsetDialog from './AssetOffsetDialog'; + +interface IProps { + onAdd?: () => void; + assets: IAsset[]; +} +export default function AssetsOptions({ onAdd, assets }: IProps) { + const [open, setOpen] = useState(false); + + return ( + <> + + + + + + setOpen(true)}> + Offset Asset Dates + + + + {open && } + + ) +} diff --git a/src/components/assets/missing-location/MissingLocationDateItem.tsx b/src/components/assets/missing-location/MissingLocationDateItem.tsx index 650625a..dde352b 100644 --- a/src/components/assets/missing-location/MissingLocationDateItem.tsx +++ b/src/components/assets/missing-location/MissingLocationDateItem.tsx @@ -1,8 +1,9 @@ import { useMissingLocationContext } from "@/contexts/MissingLocationContext"; import { IMissingLocationDatesResponse } from "@/handlers/api/asset.handler"; +import { parseDate, formatDate } from "@/helpers/date.helper"; import { cn } from "@/lib/utils"; -import React from "react"; +import React, { useMemo } from "react"; interface IProps { record: IMissingLocationDatesResponse; @@ -10,6 +11,10 @@ interface IProps { } export default function MissingLocationDateItem({ record, onSelect }: IProps) { const { startDate } = useMissingLocationContext() + const dateLabel = useMemo(() => { + if (!record.date) return "Unknown" + return formatDate(parseDate(record.date, "yyyy-MM-dd").toISOString(), "do MMM yyyy") + }, [record.date]) return (
-

{record.date}

-

{record.asset_count} W/O Location

+

{dateLabel}

+

{record.asset_count} Orphan Assets

); } diff --git a/src/components/assets/missing-location/MissingLocationDates.tsx b/src/components/assets/missing-location/MissingLocationDates.tsx index 41f6216..d7c6fad 100644 --- a/src/components/assets/missing-location/MissingLocationDates.tsx +++ b/src/components/assets/missing-location/MissingLocationDates.tsx @@ -4,6 +4,9 @@ import { IMissingLocationDatesResponse, listMissingLocationDates } from "@/handl import MissingLocationDateItem from "./MissingLocationDateItem"; import { useMissingLocationContext } from "@/contexts/MissingLocationContext"; import { useRouter } from "next/router"; +import { Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectTrigger, SelectValue } from "@/components/ui/select"; +import { Button } from "@/components/ui/button"; +import { SortAsc, SortDesc } from "lucide-react"; export default function MissingLocationDates() { const { updateContext } = useMissingLocationContext(); @@ -11,12 +14,16 @@ export default function MissingLocationDates() { const [dateRecords, setDateRecords] = React.useState< IMissingLocationDatesResponse[] >([]); + const [filters, setFilters] = useState<{ sortBy: string, sortOrder: string }>({ sortBy: "date", sortOrder: "desc" }); const [loading, setLoading] = useState(false); const [errorMessage, setErrorMessage] = useState(null); const fetchData = async () => { - return listMissingLocationDates({}) + return listMissingLocationDates({ + sortBy: filters.sortBy, + sortOrder: filters.sortOrder, + }) .then(setDateRecords) .catch(setErrorMessage) .finally(() => setLoading(false)); @@ -30,12 +37,37 @@ export default function MissingLocationDates() { }); }; + + useEffect(() => { fetchData(); - }, []); + }, [filters]); return ( -
+
+
+ +
+ +
+
+ {dateRecords.map((record) => ( {errorMessage}
; return ( -
+
{people.map((person) => ( ))} diff --git a/src/components/people/PersonMergeDropdown.tsx b/src/components/people/PersonMergeDropdown.tsx index 92db3e9..28ab97c 100644 --- a/src/components/people/PersonMergeDropdown.tsx +++ b/src/components/people/PersonMergeDropdown.tsx @@ -103,47 +103,47 @@ export function PersonMergeDropdown({ setSelectedPeople(selectedPeople.filter((p) => p.id !== value.id)); return; } - if (selectedPeople.length >= 5) { - toast({ - title: "Error", - description: "You can only merge 5 people at a time", - }); - return; - } else { - setSelectedPeople([...selectedPeople, value]); - } + setSelectedPeople([...selectedPeople, value]); if (primaryPerson.name.length === 0 && value.name.length > 0) { setPrimaryPerson(value); } - }; + + const handleMerge = () => { if (selectedPeople.length === 0) { return; } + const personIds = selectedPeople.map((p) => p.id); setMerging(true); - return mergePerson(person.id, personIds) - .then(() => { - onRemove?.(person); - }) - .then(() => { + + const mergeInBatches = async (ids: string[], index: number = 0) => { + if (index >= ids.length) { setOpen(false); toast({ title: "Success", description: "People merged successfully", }); - }) - .catch(() => { + setMerging(false); + return; + } + + const batch = ids.slice(index, index + 5); + try { + await mergePerson(person.id, batch); + mergeInBatches(ids, index + 5); + } catch { toast({ title: "Error", description: "Failed to merge people", }); - }) - .finally(() => { setMerging(false); - }); + } + }; + + mergeInBatches(personIds); }; const handleRemove = (value: IPerson) => { diff --git a/src/components/ui/hover-card.tsx b/src/components/ui/hover-card.tsx new file mode 100644 index 0000000..863ff01 --- /dev/null +++ b/src/components/ui/hover-card.tsx @@ -0,0 +1,27 @@ +import * as React from "react" +import * as HoverCardPrimitive from "@radix-ui/react-hover-card" + +import { cn } from "@/lib/utils" + +const HoverCard = HoverCardPrimitive.Root + +const HoverCardTrigger = HoverCardPrimitive.Trigger + +const HoverCardContent = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, align = "center", sideOffset = 4, ...props }, ref) => ( + +)) +HoverCardContent.displayName = HoverCardPrimitive.Content.displayName + +export { HoverCard, HoverCardTrigger, HoverCardContent } diff --git a/src/components/ui/linechardots.tsx b/src/components/ui/linechardots.tsx new file mode 100644 index 0000000..748b1c6 --- /dev/null +++ b/src/components/ui/linechardots.tsx @@ -0,0 +1,100 @@ +import { CartesianGrid, LabelList, Line, LineChart, XAxis, YAxis } from "recharts"; + +import { + ChartConfig, + ChartContainer, + ChartTooltip, + ChartTooltipContent, +} from "@/components/ui/chart"; +import { useMemo } from "react"; +import { CHART_COLORS } from "@/config/constants/chart.constant"; + +export interface ILineChartData { + label: string; + value: number; +} + +interface ChartProps { + data: ILineChartData[]; + topLabel?: string; + loading?: boolean; + errorMessage?: string | null; +} + +export function LineChartDots({ + data: _data, + topLabel, + loading, + errorMessage, +}: ChartProps) { + const data = useMemo( + () => + _data.map((item, index) => ({ + ...item, + fill: CHART_COLORS[index] || "#000000", + })), + [_data] + ); + + const chartConfig = useMemo(() => { + let config: ChartConfig = {}; + data.map((data) => { + config[data.label as string] = { + label: data.label, + color: "hsl(var(--chart-1))", + }; + }); + return config; + }, [data]); + + if (loading) { + return

Loading...

; + } + + if (errorMessage) { + return

{errorMessage}

; + } + + return ( + + + + {/* Added YAxis for the count */} + + + } + /> + + + chartConfig[value]?.label + } + /> + + + + ); +} diff --git a/src/components/ui/radarchartdpts.tsx b/src/components/ui/radarchartdpts.tsx new file mode 100644 index 0000000..51ddc39 --- /dev/null +++ b/src/components/ui/radarchartdpts.tsx @@ -0,0 +1,78 @@ +"use client" + +import { TrendingUp } from "lucide-react" +import { PolarAngleAxis, PolarGrid, Radar, RadarChart } from "recharts" + +import { + Card, + CardContent, + CardDescription, + CardFooter, + CardHeader, + CardTitle, +} from "@/components/ui/card" +import { + ChartConfig, + ChartContainer, + ChartTooltip, + ChartTooltipContent, +} from "@/components/ui/chart" +import { useMemo } from "react" +import { CHART_COLORS } from "@/config/constants/chart.constant" + +export const description = "A radar chart with dots" +export interface IRadarChartData { + label: string; + value: number; + color?: string; // Add color property here +} + +interface ChartProps { + data: IRadarChartData[]; + topLabel?: string; + loading?: boolean; + errorMessage?: string | null; +} + +const chartConfig = { + label: { + label: "label", + color: "#FF0000", + }, +} satisfies ChartConfig + +export default function RadarChartDots({ data: _data, topLabel, loading, errorMessage }: ChartProps) { + const chartData = _data + + return ( + + + + + + } /> + + {/* Set grid color to white */} + ( + + )} + /> + + + + + ) +} diff --git a/src/components/ui/tooltip.tsx b/src/components/ui/tooltip.tsx index 53407fc..226fee5 100644 --- a/src/components/ui/tooltip.tsx +++ b/src/components/ui/tooltip.tsx @@ -26,14 +26,22 @@ const TooltipContent = React.forwardRef< TooltipContent.displayName = TooltipPrimitive.Content.displayName -const Tooltip: React.FC> = ({ +export interface ITooltipProps extends React.ComponentProps { + content: string +} +const Tooltip: React.FC = ({ children, + content, ...props }) => ( - {children} - + + {children} + + +

{content}

+
) 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/config/environment.ts b/src/config/environment.ts index 08dc3b2..e68cc52 100644 --- a/src/config/environment.ts +++ b/src/config/environment.ts @@ -1,5 +1,5 @@ export const ENV = { - IMMICH_URL: (process.env.IMMICH_URL || 'http://immich_server:3001') as string, + IMMICH_URL: (process.env.IMMICH_URL || 'http://immich_server:2283') as string, EXTERNAL_IMMICH_URL: (process.env.EXTERNAL_IMMICH_URL || process.env.IMMICH_URL) as string, IMMICH_API_KEY: process.env.IMMICH_API_KEY as string, DATABASE_URL: (process.env.DATABASE_URL || `postgresql://${process.env.DB_USERNAME}:${process.env.DB_PASSWORD}@${(process.env.DB_HOST || 'immich_postgres')}:${(process.env.DB_PORT || '5432')}/${process.env.DB_DATABASE_NAME}`), diff --git a/src/config/routes.ts b/src/config/routes.ts index 1cb02e1..4bfe2f8 100644 --- a/src/config/routes.ts +++ b/src/config/routes.ts @@ -36,5 +36,10 @@ export const ASSET_VIDEO_PATH = (id: string) => BASE_PROXY_ENDPOINT + "/asset/vi export const SEARCH_PLACES_PATH = BASE_PROXY_ENDPOINT + "/search/places"; +//Analytics + +export const ASSET_STATISTICS = BASE_PROXY_ENDPOINT + "/assets/statistics"; +export const LIVE_PHOTO_STATISTICS = BASE_API_ENDPOINT + "/analytics/statistics/livephoto"; +export const HEATMAP_DATA = BASE_API_ENDPOINT + "/analytics/statistics/heatmap"; // Common -export const GET_FILTERS = BASE_API_ENDPOINT + "/filters/asset-filters"; \ No newline at end of file +export const GET_FILTERS = BASE_API_ENDPOINT + "/filters/asset-filters"; diff --git a/src/handlers/api/album.handler.ts b/src/handlers/api/album.handler.ts index 7b35bb7..9097c0b 100644 --- a/src/handlers/api/album.handler.ts +++ b/src/handlers/api/album.handler.ts @@ -7,6 +7,8 @@ import { IAsset } from "@/types/asset"; interface IPotentialAlbumsDatesFilters { startDate?: string; endDate?: string; + sortBy?: string; + sortOrder?: string; } export interface IPotentialAlbumsDatesResponse { date: string; diff --git a/src/handlers/api/analytics.handler.ts b/src/handlers/api/analytics.handler.ts index 8215137..0daf406 100644 --- a/src/handlers/api/analytics.handler.ts +++ b/src/handlers/api/analytics.handler.ts @@ -1,4 +1,4 @@ -import { EXIF_DISTRIBUTION_PATH } from "@/config/routes"; +import { ASSET_STATISTICS, EXIF_DISTRIBUTION_PATH, HEATMAP_DATA, LIVE_PHOTO_STATISTICS } from "@/config/routes"; import API from "@/lib/api"; export type ISupportedEXIFColumns = @@ -7,3 +7,15 @@ export type ISupportedEXIFColumns = export const getExifDistribution = async (column: ISupportedEXIFColumns) => { return API.get(EXIF_DISTRIBUTION_PATH(column)); }; + +export const getAssetStatistics = async () => { + return API.get(ASSET_STATISTICS); +} + +export const getLivePhotoStatistics = async () => { + return API.get(LIVE_PHOTO_STATISTICS); +} + +export const getHeatMapData = async () => { + return API.get(HEATMAP_DATA); +} \ No newline at end of file diff --git a/src/handlers/api/asset.handler.ts b/src/handlers/api/asset.handler.ts index 040d6e7..664f4b5 100644 --- a/src/handlers/api/asset.handler.ts +++ b/src/handlers/api/asset.handler.ts @@ -12,6 +12,8 @@ import { IAsset } from "@/types/asset"; interface IMissingAssetAlbumsFilters { startDate?: string; endDate?: string; + sortBy?: string; + sortOrder?: string; } export interface IMissingLocationDatesResponse { date: string; @@ -37,6 +39,7 @@ export interface IUpdateAssetsParams { ids: string[]; latitude?: number; longitude?: number; + dateTimeOriginal?: string; } export const updateAssets = async (params: IUpdateAssetsParams) => { diff --git a/src/helpers/date.helper.ts b/src/helpers/date.helper.ts index 2f72fc2..9cabed2 100644 --- a/src/helpers/date.helper.ts +++ b/src/helpers/date.helper.ts @@ -1,4 +1,4 @@ -import { format, parse } from "date-fns" +import { addSeconds, addHours, addMinutes, format, parse, addYears } from "date-fns" export const formatDate = (date: string, outputFormat?: string): string => { return format(date, outputFormat || "PPP") @@ -13,3 +13,21 @@ export const addDays = (date: Date, days: number): Date => { result.setDate(result.getDate() + days); return result; } + + +export const offsetDate = (date: string, offset: { + years: number, + days: number, + hours: number, + minutes: number, + seconds: number +}): string => { + console.log(offset) + const parsedDate = new Date(date); + const result = addYears(parsedDate, offset.years || 0) + const result2 = addDays(result, offset.days || 0) + const result3 = addHours(result2, offset.hours || 0) + const result4 = addMinutes(result3, offset.minutes || 0) + const result5 = addSeconds(result4, offset.seconds || 0) + return result5.toISOString() +} \ No newline at end of file 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.albumName}

+ +

{album.assetCount} assets

+
+
+ ))} +
+ ) + } + return ( + +
+ {renderContent()} + + ) +} diff --git a/src/pages/albums/potential-albums.tsx b/src/pages/albums/potential-albums.tsx index b7aa580..796cc5a 100644 --- a/src/pages/albums/potential-albums.tsx +++ b/src/pages/albums/potential-albums.tsx @@ -2,6 +2,7 @@ import AlbumCreateDialog from "@/components/albums/AlbumCreateDialog"; import AlbumSelectorDialog from "@/components/albums/AlbumSelectorDialog"; import PotentialAlbumsAssets from "@/components/albums/potential-albums/PotentialAlbumsAssets"; import PotentialAlbumsDates from "@/components/albums/potential-albums/PotentialAlbumsDates"; +import AssetsOptions from "@/components/assets/assets-options/AssetsOptions"; import PageLayout from "@/components/layouts/PageLayout"; import Header from "@/components/shared/Header"; import { Badge } from "@/components/ui/badge"; @@ -14,7 +15,7 @@ import PotentialAlbumContext, { import { addAssetToAlbum, createAlbum } from "@/handlers/api/album.handler"; import { IAlbum, IAlbumCreate } from "@/types/album"; import { useRouter } from "next/router"; -import React from "react"; +import React, { useMemo } from "react"; export default function PotentialAlbums() { const { toast } = useToast(); @@ -28,6 +29,8 @@ export default function PotentialAlbums() { assets: [], }); + const selectedAssets = useMemo(() => config.assets.filter((a) => config.selectedIds.includes(a.id)), [config.assets, config.selectedIds]) ; + const handleSelect = (album: IAlbum) => { return addAssetToAlbum(album.id, config.selectedIds) .then(() => { @@ -65,7 +68,7 @@ export default function PotentialAlbums() { }] }) } - + return (
a.id)} /> + { }} /> } /> diff --git a/src/pages/analytics/exif.tsx b/src/pages/analytics/exif.tsx index fc944dd..6a98b65 100644 --- a/src/pages/analytics/exif.tsx +++ b/src/pages/analytics/exif.tsx @@ -1,7 +1,20 @@ import { Inter } from "next/font/google"; import PageLayout from "@/components/layouts/PageLayout"; import Header from "@/components/shared/Header"; -import EXIFDistribution, { IEXIFDistributionProps } from "@/components/analytics/exif/EXIFDistribution"; +import EXIFDistribution, { + IEXIFDistributionProps, +} from "@/components/analytics/exif/EXIFDistribution"; +import { + Card, + CardContent, + CardDescription, + CardFooter, + CardHeader, + CardTitle, +} from "@/components/ui/card"; +import AssetHeatMap from "@/components/analytics/exif/AssetHeatMap"; +import { useEffect, useState } from "react"; +import { getAssetStatistics, getLivePhotoStatistics } from "@/handlers/api/analytics.handler"; const inter = Inter({ subsets: ["latin"] }); @@ -42,36 +55,86 @@ const exifCharts: IEXIFDistributionProps[] = [ description: "Distribution of ISO", }, { - column: 'exposureTime', - title: 'Exposure Time', - description: 'Distribution of exposure time' + column: "exposureTime", + title: "Exposure Time", + description: "Distribution of exposure time", }, { - column: 'lensModel', - title: 'Lens Model', - description: 'Distribution of lens model' + column: "lensModel", + title: "Lens Model", + description: "Distribution of lens model", }, { - column: 'projectionType', - title: 'Projection Type', - description: 'Distribution of projection type' - } -] + column: "projectionType", + title: "Projection Type", + description: "Distribution of projection type", + }, +]; export default function ExifDataAnalytics() { + const [statistics, setStatistics] = useState({ images: 0, videos: 0, total: 0 }); + const [loading, setLoading] = useState(false); + const [livePhotoStatistics, setLivePhotoStatistics] = useState({ total: 0 }); + + const fetchLivePhotoStatistics = async () => { + setLoading(true); + try { + const data = await getLivePhotoStatistics(); + const livePhotoData = Array.isArray(data) && data.length ? data[0].value : 0; + setLivePhotoStatistics({ total: livePhotoData }); + } finally { + setLoading(false); + } + }; + + const fetchStatisticsData = async () => { + setLoading(true); + try { + const data = await getAssetStatistics(); + setStatistics(data); + } finally { + setLoading(false); + } + }; + + useEffect(() => { + fetchStatisticsData(); + fetchLivePhotoStatistics(); + }, []); + return ( -
+
+
+ {["Total", "Images", "Videos"].map((type, i) => ( + + + {type} + + + {loading ? "Loading..." : statistics[type.toLowerCase() as keyof typeof statistics].toLocaleString()} + + + ))} + + + Live Photos + + + {loading ? "Loading..." : livePhotoStatistics.total.toLocaleString()} + + +
+
{exifCharts.map((chart) => ( - ))} +
); diff --git a/src/pages/api/albums/potential-albums-assets.ts b/src/pages/api/albums/potential-albums-assets.ts index 0cd9bfe..080fb8f 100644 --- a/src/pages/api/albums/potential-albums-assets.ts +++ b/src/pages/api/albums/potential-albums-assets.ts @@ -21,9 +21,9 @@ const SELECT_ORPHAN_PHOTOS = (date: string, ownerId: string) => a."sidecarPath", a."thumbhash", a."deletedAt", - a."localDateTime", e."exifImageWidth", - e."exifImageHeight" + e."exifImageHeight", + e."dateTimeOriginal" FROM assets a LEFT JOIN @@ -35,7 +35,7 @@ const SELECT_ORPHAN_PHOTOS = (date: string, ownerId: string) => WHERE aaa."albumsId" IS NULL AND a."ownerId" = '${ownerId}' - AND a."localDateTime"::date = '${date}' + AND e."dateTimeOriginal"::date = '${date}' AND a."isVisible" = true `); diff --git a/src/pages/api/albums/potential-albums-dates.ts b/src/pages/api/albums/potential-albums-dates.ts index cb2c751..1998ac7 100644 --- a/src/pages/api/albums/potential-albums-dates.ts +++ b/src/pages/api/albums/potential-albums-dates.ts @@ -1,25 +1,30 @@ // Next.js API route support: https://nextjs.org/docs/api-routes/introduction import { CHART_COLORS } from "@/config/constants/chart.constant"; import { db } from "@/config/db"; +import { IPotentialAlbumsDatesResponse } from "@/handlers/api/album.handler"; import { getCurrentUser } from "@/handlers/serverUtils/user.utils"; +import { parseDate } from "@/helpers/date.helper"; import { exif } from "@/schema"; import { count, desc, isNotNull, ne, sql } from "drizzle-orm"; import type { NextApiRequest, NextApiResponse } from "next"; const SELECT_ORPHAN_PHOTOS = (ownerId: string) => sql` SELECT - DATE(a."localDateTime") AS "date", + DATE(e."dateTimeOriginal") AS "date", COUNT(a."id") AS "asset_count" FROM "assets" a LEFT JOIN "albums_assets_assets" aaa ON a."id" = aaa."assetsId" +LEFT JOIN + "exif" e ON a."id" = e."assetId" WHERE aaa."albumsId" IS NULL AND a."ownerId" = ${ownerId} AND a."isVisible" = true + AND e."dateTimeOriginal" IS NOT NULL GROUP BY - DATE(a."localDateTime") + DATE(e."dateTimeOriginal") ORDER BY "asset_count" DESC; `; @@ -29,8 +34,22 @@ export default async function handler( res: NextApiResponse ) { try { + const { sortBy = "date", sortOrder = "desc" } = req.query; const currentUser = await getCurrentUser(req) - const { rows } = await db.execute(SELECT_ORPHAN_PHOTOS(currentUser.id)); + const data = await db.execute(SELECT_ORPHAN_PHOTOS(currentUser.id)) as any; + const rows = data.rows as IPotentialAlbumsDatesResponse[]; + + if (sortBy === "date") { + rows.sort((a, b) => { + const aDate = parseDate(a.date, "yyyy-MM-dd"); + const bDate = parseDate(b.date, "yyyy-MM-dd"); + return sortOrder === "asc" ? aDate.getTime() - bDate.getTime() : bDate.getTime() - aDate.getTime(); + }); + } else if (sortBy === "asset_count") { + rows.sort((a, b) => { + return sortOrder === "asc" ? a.asset_count - b.asset_count : b.asset_count - a.asset_count; + }); + } return res.status(200).json(rows); } catch (error: any) { res.status(500).json({ diff --git a/src/pages/api/analytics/statistics/heatmap.tsx b/src/pages/api/analytics/statistics/heatmap.tsx new file mode 100644 index 0000000..d330b1a --- /dev/null +++ b/src/pages/api/analytics/statistics/heatmap.tsx @@ -0,0 +1,69 @@ +// Next.js API route support: https://nextjs.org/docs/api-routes/introduction +import { db } from "@/config/db"; +import { getCurrentUser } from "@/handlers/serverUtils/user.utils"; +import { assets, exif } from "@/schema"; +import { and, count, desc, eq, gte, isNotNull, ne, sql, } from "drizzle-orm"; +import type { NextApiRequest, NextApiResponse } from "next"; + +// Helper function to format date as YYYY-MM-DD +function formatDate(date: Date) { + return date.toISOString().split('T')[0]; +} + +function fillMissingDates(data: any[]) { + const today = new Date(); + + // Set the start date as one year ago, excluding the current month in the previous year + const oneYearAgo = new Date(today.getFullYear() - 1, today.getMonth() + 1, 1); // First day of the next month last year + + const existingDates = new Set(data.map(item => item.date)); + + const filledData = []; + + // Iterate from today to one year ago, but skip the current month from last year + for (let d = new Date(today); d >= oneYearAgo; d.setDate(d.getDate() - 1)) { + const dateStr = formatDate(d); + + // Skip dates in the current month of the previous year + if (d.getFullYear() === today.getFullYear() - 1 && d.getMonth() === today.getMonth()) { + continue; + } + + if (existingDates.has(dateStr)) { + filledData.push(data.find(item => item.date === dateStr)); + } else { + filledData.push({ date: dateStr, count: 0 }); + } + } + + // Sort the filled data in descending order + filledData.sort((a, b) => a.date.localeCompare(b.date)); + return filledData; +} +export default async function handler( + req: NextApiRequest, + res: NextApiResponse +) { + + try { + const currentUser = await getCurrentUser(req); + const dataFromDB = await db.select({ + date: sql`DATE(${assets.fileCreatedAt})`.as('date'), + count: count(), + }) + .from(assets) + .where( + and( + eq(assets.ownerId, currentUser.id), + gte(assets.fileCreatedAt, sql`CURRENT_DATE - INTERVAL '1 YEAR'`)) + ) + .groupBy(sql`DATE(${assets.fileCreatedAt})`) + .orderBy(sql`DATE(${assets.fileCreatedAt}) DESC`) + const updatedData = fillMissingDates(dataFromDB); + return res.status(200).json(updatedData); + } catch (error: any) { + res.status(500).json({ + error: error?.message, + }); + } +} diff --git a/src/pages/api/analytics/statistics/livephoto.tsx b/src/pages/api/analytics/statistics/livephoto.tsx new file mode 100644 index 0000000..8eb670c --- /dev/null +++ b/src/pages/api/analytics/statistics/livephoto.tsx @@ -0,0 +1,31 @@ +// Next.js API route support: https://nextjs.org/docs/api-routes/introduction +import { CHART_COLORS } from "@/config/constants/chart.constant"; +import { db } from "@/config/db"; +import { getCurrentUser } from "@/handlers/serverUtils/user.utils"; +import { assets, exif } from "@/schema"; +import { and, count, desc, eq, isNotNull, ne } from "drizzle-orm"; +import type { NextApiRequest, NextApiResponse } from "next"; + + +export default async function handler( + req: NextApiRequest, + res: NextApiResponse +) { + + try { + const currentUser = await getCurrentUser(req); + const dataFromDB = await db.select({ + value: count(), + }) + .from(assets) + .where(and( + eq(assets.ownerId, currentUser.id), + isNotNull(assets.livePhotoVideoId)) + ); + return res.status(200).json(dataFromDB); + } catch (error: any) { + res.status(500).json({ + error: error?.message, + }); + } +} diff --git a/src/pages/api/assets/missing-location-assets.ts b/src/pages/api/assets/missing-location-assets.ts index 4847b53..d1e7ced 100644 --- a/src/pages/api/assets/missing-location-assets.ts +++ b/src/pages/api/assets/missing-location-assets.ts @@ -43,6 +43,7 @@ export default async function handler( exifImageWidth: exif.exifImageWidth, exifImageHeight: exif.exifImageHeight, ownerId: assets.ownerId, + dateTimeOriginal: exif.dateTimeOriginal, }) .from(assets) .leftJoin(exif, eq(exif.assetId, assets.id)) diff --git a/src/pages/api/assets/missing-location-dates.ts b/src/pages/api/assets/missing-location-dates.ts index ca57e77..831731b 100644 --- a/src/pages/api/assets/missing-location-dates.ts +++ b/src/pages/api/assets/missing-location-dates.ts @@ -1,7 +1,9 @@ // Next.js API route support: https://nextjs.org/docs/api-routes/introduction import { CHART_COLORS } from "@/config/constants/chart.constant"; import { db } from "@/config/db"; +import { IMissingLocationDatesResponse } from "@/handlers/api/asset.handler"; import { getCurrentUser } from "@/handlers/serverUtils/user.utils"; +import { parseDate } from "@/helpers/date.helper"; import { assets, exif } from "@/schema"; import { and, count, desc, eq, isNotNull, isNull, ne, sql } from "drizzle-orm"; import type { NextApiRequest, NextApiResponse } from "next"; @@ -11,7 +13,13 @@ export default async function handler( res: NextApiResponse ) { try { + const { sortBy = "date", sortOrder = "desc" } = req.query; const currentUser = await getCurrentUser(req); + if (!currentUser) { + return res.status(401).json({ + error: "Unauthorized", + }); + } const rows = await db .select({ asset_count: desc(count(assets.id)), @@ -22,12 +30,25 @@ export default async function handler( .where(and( isNull(exif.latitude), isNotNull(assets.createdAt), + isNotNull(exif.dateTimeOriginal), eq(assets.type, "VIDEO"), - eq(assets.ownerId, currentUser.id), + eq(assets.ownerId, currentUser.id), eq(assets.isVisible, true), )) .groupBy(sql`DATE(${exif.dateTimeOriginal})`) - .orderBy(desc(count(assets.id))); + .orderBy(desc(count(assets.id))) as IMissingLocationDatesResponse[]; + + if (sortBy === "date") { + rows.sort((a, b) => { + const aDate = parseDate(a.date, "yyyy-MM-dd"); + const bDate = parseDate(b.date, "yyyy-MM-dd"); + return sortOrder === "asc" ? aDate.getTime() - bDate.getTime() : bDate.getTime() - aDate.getTime(); + }); + } else if (sortBy === "asset_count") { + rows.sort((a, b) => { + return sortOrder === "asc" ? a.asset_count - b.asset_count : b.asset_count - a.asset_count; + }); + } return res.status(200).json(rows); } catch (error: any) { res.status(500).json({ diff --git a/src/pages/api/immich-proxy/[...path].ts b/src/pages/api/immich-proxy/[...path].ts index c7641f7..31f597b 100644 --- a/src/pages/api/immich-proxy/[...path].ts +++ b/src/pages/api/immich-proxy/[...path].ts @@ -14,10 +14,15 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse) try { const response = await fetch(targetUrl, { method: req.method, - headers: getUserHeaders(currentUser), + headers: { + ...getUserHeaders(currentUser), + 'Accept-Encoding': 'gzip, deflate, br', + }, body: req.method !== 'GET' && req.method !== 'HEAD' ? JSON.stringify(req.body) : null, }) + // Log response headers for debugging + console.log('Response Headers:', response.headers); // Forward the status code res.status(response.status) @@ -28,7 +33,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse) res.setHeader(key, value) }) - // Stream the response body + // Stream the response body const reader = response.body?.getReader() if (reader) { while (true) { @@ -38,8 +43,8 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse) } } res.end() - } catch (error) { + } catch (error: any) { console.error('Proxy error:', error) - res.status(500).json({ error }) + res.status(500).json({ error: error?.message }) } } \ No newline at end of file diff --git a/src/pages/assets/missing-locations.tsx b/src/pages/assets/missing-locations.tsx index c299609..6921532 100644 --- a/src/pages/assets/missing-locations.tsx +++ b/src/pages/assets/missing-locations.tsx @@ -1,6 +1,7 @@ import AlbumSelectorDialog from "@/components/albums/AlbumSelectorDialog"; import PotentialAlbumsAssets from "@/components/albums/potential-albums/PotentialAlbumsAssets"; import PotentialAlbumsDates from "@/components/albums/potential-albums/PotentialAlbumsDates"; +import AssetsOptions from "@/components/assets/assets-options/AssetsOptions"; import MissingLocationAssets from "@/components/assets/missing-location/MissingLocationAssets"; import MissingLocationDates from "@/components/assets/missing-location/MissingLocationDates"; import TagMissingLocationDialog from "@/components/assets/missing-location/TagMissingLocationDialog/TagMissingLocationDialog"; @@ -17,7 +18,7 @@ import { updateAssets } from "@/handlers/api/asset.handler"; import { IPlace } from "@/types/common"; import { useRouter } from "next/router"; -import React from "react"; +import React, { useMemo } from "react"; export default function MissingLocations() { const { toast } = useToast(); @@ -30,6 +31,8 @@ export default function MissingLocations() { assets: [], }); + const selectedAssets = useMemo(() => config.assets.filter((a) => config.selectedIds.includes(a.id)), [config.assets, config.selectedIds]) ; + const handleSubmit = (place: IPlace) => { return updateAssets({ ids: config.selectedIds, @@ -78,6 +81,7 @@ export default function MissingLocations() { )} + { }} /> } /> 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'), +}); diff --git a/src/types/asset.d.ts b/src/types/asset.d.ts index 25e1491..545dfc5 100644 --- a/src/types/asset.d.ts +++ b/src/types/asset.d.ts @@ -17,6 +17,7 @@ export interface IAsset { url: string; previewUrl: string; videoURL?: string; + dateTimeOriginal: string; } export interface IAssetThumbhash {