59 files changed
+526
-160
No files matched your search
+2
-1
@@ -15,4 +15,5 @@ GEMINI_API_KEY="" # Gemini API Key for parsing search query in "Find"
|
||||
|
||||
# Immich Share Link
|
||||
IMMICH_SHARE_LINK_KEY="" # Share link key for Immich
|
||||
POWER_TOOLS_ENDPOINT_URL="" # URL of the Power Tools endpoint (Used for share links)
|
||||
POWER_TOOLS_ENDPOINT_URL="" # URL of the Power Tools endpoint (Used for share links)
|
||||
JWT_SECRET="" # JWT Secret for authentication
|
||||
+5
-1
@@ -6,5 +6,9 @@
|
||||
"files": ["remotion/*.{ts,tsx}"],
|
||||
"extends": ["plugin:@remotion/recommended"]
|
||||
}
|
||||
]
|
||||
],
|
||||
"rules": {
|
||||
"react-hooks/exhaustive-deps": "off",
|
||||
"@next/next/no-img-element": "off"
|
||||
}
|
||||
}
|
||||
@@ -57,6 +57,12 @@ services:
|
||||
- "8001:3000"
|
||||
env_file:
|
||||
- .env
|
||||
healthcheck:
|
||||
test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:3000/api/health"]
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
start_period: 40s
|
||||
|
||||
volumes:
|
||||
model-cache:
|
||||
|
||||
@@ -8,3 +8,9 @@ services:
|
||||
- "3000:3000"
|
||||
env_file:
|
||||
- .env
|
||||
healthcheck:
|
||||
test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:3000/api/health"]
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
start_period: 40s
|
||||
+4
-1
@@ -34,9 +34,11 @@
|
||||
"@radix-ui/react-tooltip": "^1.1.2",
|
||||
"@remotion/cli": "4.0.232",
|
||||
"@remotion/eslint-plugin": "^4.0.232",
|
||||
"@tanstack/react-query": "^5.69.0",
|
||||
"@tanstack/react-table": "^8.20.1",
|
||||
"@types/cookie": "^0.6.0",
|
||||
"@types/qs": "^6.9.15",
|
||||
"@types/react-autosuggest": "^10.1.11",
|
||||
"@types/react-calendar-heatmap": "^1.6.7",
|
||||
"@vis.gl/react-google-maps": "^1.4.2",
|
||||
"axios": "^1.7.4",
|
||||
@@ -57,13 +59,13 @@
|
||||
"pg": "^8.12.0",
|
||||
"qs": "^6.13.0",
|
||||
"react": "^18",
|
||||
"react-autosuggest": "^10.1.0",
|
||||
"react-day-picker": "9.0.8",
|
||||
"react-dom": "^18",
|
||||
"react-grid-gallery": "^1.0.1",
|
||||
"react-hot-toast": "^2.5.1",
|
||||
"react-leaflet": "^4.2.1",
|
||||
"react-mentions": "^4.4.10",
|
||||
"react-query": "^3.39.3",
|
||||
"recharts": "^2.12.7",
|
||||
"remotion": "4.0.232",
|
||||
"sass": "^1.77.8",
|
||||
@@ -78,6 +80,7 @@
|
||||
"@semantic-release/github": "^10.1.7",
|
||||
"@semantic-release/npm": "^12.0.1",
|
||||
"@semantic-release/release-notes-generator": "^14.0.1",
|
||||
"@tanstack/eslint-plugin-query": "^5.68.0",
|
||||
"@types/jsonwebtoken": "^9.0.6",
|
||||
"@types/leaflet": "^1.9.15",
|
||||
"@types/node": "^20",
|
||||
|
||||
@@ -6,11 +6,9 @@ import { IAsset } from '@/types/asset'
|
||||
import React, { useEffect, useMemo, useRef, useState } from 'react'
|
||||
import { ExternalLink, Hourglass } from 'lucide-react';
|
||||
import { useRouter } from 'next/router';
|
||||
import { CalendarArrowUp } from 'lucide-react';
|
||||
import Lightbox from 'yet-another-react-lightbox';
|
||||
import Captions from 'yet-another-react-lightbox/plugins/captions';
|
||||
import LazyImage from '@/components/ui/lazy-image';
|
||||
import Image from 'next/image';
|
||||
import { Button } from "@/components/ui/button";
|
||||
import Link from "next/link";
|
||||
|
||||
|
||||
@@ -1,22 +1,19 @@
|
||||
import React, { useEffect, useMemo, useState } from 'react'
|
||||
import { IAlbum } from '@/types/album'
|
||||
import { IPerson } from '@/types/person'
|
||||
import { getAlbumPeople } from '@/handlers/api/album.handler'
|
||||
import Loader from '@/components/ui/loader'
|
||||
import LazyImage from '@/components/ui/lazy-image'
|
||||
import { PERSON_THUBNAIL_PATH } from '@/config/routes'
|
||||
import Link from 'next/link'
|
||||
import { useConfig } from '@/contexts/ConfigContext'
|
||||
import { Tooltip } from '@/components/ui/tooltip'
|
||||
import { cn } from '@/lib/utils'
|
||||
import { Accordion, AccordionContent, AccordionItem, AccordionTrigger } from '@/components/ui/accordion'
|
||||
import { Users, X } from 'lucide-react'
|
||||
import { useRouter } from 'next/router'
|
||||
import Image from 'next/image'
|
||||
import { PersonMergeDropdown } from '@/components/people/PersonMergeDropdown'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import { updatePerson } from '@/handlers/api/people.handler'
|
||||
import { Checkbox } from '@/components/ui/checkbox'
|
||||
import { Input } from '@/components/ui/input'
|
||||
|
||||
interface AlbumPeopleProps {
|
||||
album: IAlbum
|
||||
@@ -40,11 +37,16 @@ export default function AlbumPeople({ album, onSelect, readOnly }: AlbumPeoplePr
|
||||
const [hidingPerson, setHidingPerson] = useState<boolean>(false)
|
||||
const [selectionMode, setSelectionMode] = useState<boolean>(false)
|
||||
const [selectedPeople, setSelectedPeople] = useState<string[]>([])
|
||||
const [searchQuery, setSearchQuery] = useState<string>("")
|
||||
|
||||
const selectedPerson = useMemo(() => {
|
||||
return people.find((person) => query.faceId === person.id)
|
||||
}, [people, query.faceId])
|
||||
|
||||
const filteredPeople = useMemo(() => {
|
||||
return people.filter((person) => person.name.toLowerCase().includes(searchQuery.toLowerCase()))
|
||||
}, [people, searchQuery])
|
||||
|
||||
const fetchPeople = async () => {
|
||||
return getAlbumPeople(album.id).then((people) => {
|
||||
setPeople(people)
|
||||
@@ -102,7 +104,12 @@ export default function AlbumPeople({ album, onSelect, readOnly }: AlbumPeoplePr
|
||||
|
||||
return (
|
||||
<div className="overflow-y-auto min-w-[200px] sticky top-0 py-4 max-h-[calc(100vh-60px)] min-h-[calc(100vh-60px)] border-r border-gray-200 dark:border-zinc-800 flex flex-col gap-2 px-2">
|
||||
|
||||
<Input
|
||||
placeholder="Search"
|
||||
className="w-full"
|
||||
value={searchQuery}
|
||||
onChange={(e) => setSearchQuery(e.target.value)}
|
||||
/>
|
||||
{selectedPerson && (
|
||||
<div className='flex flex-col gap-2 bg-white dark:bg-zinc-900 p-2 rounded-md'>
|
||||
<div className='flex items-center gap-2'>
|
||||
@@ -172,7 +179,7 @@ export default function AlbumPeople({ album, onSelect, readOnly }: AlbumPeoplePr
|
||||
)}
|
||||
</div>
|
||||
<div className="flex flex-col overflow-x-hidden gap-2">
|
||||
{people.map((person) => (
|
||||
{filteredPeople.map((person) => (
|
||||
<div
|
||||
className={cn(
|
||||
'flex items-center gap-2 cursor-pointer hover:bg-gray-300 dark:hover:bg-gray-700 rounded-md p-1',
|
||||
|
||||
@@ -4,9 +4,9 @@ import { listPotentialAlbumsAssets } from "@/handlers/api/album.handler";
|
||||
import type { IAsset } from "@/types/asset";
|
||||
import React, { type MouseEvent, useEffect, useMemo, useState } from "react";
|
||||
import { Gallery } from "react-grid-gallery";
|
||||
import Lightbox, { SlideImage, SlideTypes } from "yet-another-react-lightbox";
|
||||
import Lightbox from "yet-another-react-lightbox";
|
||||
import Captions from "yet-another-react-lightbox/plugins/captions";
|
||||
import { CalendarArrowDown, CalendarArrowUp, Hourglass } from "lucide-react";
|
||||
import { CalendarArrowUp, Hourglass } from "lucide-react";
|
||||
import Video from "yet-another-react-lightbox/plugins/video";
|
||||
import { useConfig } from "@/contexts/ConfigContext";
|
||||
import LazyGridImage from "@/components/ui/lazy-grid-image";
|
||||
|
||||
@@ -2,13 +2,13 @@ import {
|
||||
IPotentialAlbumsDatesResponse,
|
||||
listPotentialAlbumsDates,
|
||||
} from "@/handlers/api/album.handler";
|
||||
import React, { use, useEffect, useState } from "react";
|
||||
import React, { 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";
|
||||
import { SortAsc, SortDesc } from "lucide-react";
|
||||
|
||||
export default function PotentialAlbumsDates() {
|
||||
const router = useRouter();
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import React, { use, useEffect, useState } from "react";
|
||||
import { usePotentialAlbumContext } from "@/contexts/PotentialAlbumContext";
|
||||
import { IMissingLocationDatesResponse, listMissingLocationAlbums, listMissingLocationDates } from "@/handlers/api/asset.handler";
|
||||
import React, { useEffect, useState } from "react";
|
||||
import { listMissingLocationAlbums, listMissingLocationDates } from "@/handlers/api/asset.handler";
|
||||
import MissingLocationDateItem from "./MissingLocationDateItem";
|
||||
import { useMissingLocationContext } from "@/contexts/MissingLocationContext";
|
||||
import { useRouter } from "next/router";
|
||||
|
||||
@@ -7,8 +7,8 @@ import L, { LatLngExpression } from 'leaflet';
|
||||
import 'leaflet-defaulticon-compatibility/dist/leaflet-defaulticon-compatibility.webpack.css'; // Re-uses images from ~leaflet package
|
||||
import 'leaflet-defaulticon-compatibility';
|
||||
|
||||
import { MapContainer, Marker, Popup, TileLayer, useMap, useMapEvents } from "react-leaflet";
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
import { MapContainer, TileLayer, useMapEvents } from "react-leaflet";
|
||||
import { useState } from "react";
|
||||
import { IPlace } from "@/types/common";
|
||||
import CustomMarker from "./CustomMarker";
|
||||
|
||||
|
||||
-1
@@ -2,7 +2,6 @@ import ErrorBlock from "@/components/shared/ErrorBlock";
|
||||
import { Button } from "@/components/ui/button";
|
||||
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Label } from "@/components/ui/label";
|
||||
import Loader from "@/components/ui/loader";
|
||||
import { useToast } from "@/components/ui/use-toast";
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
-2
@@ -2,13 +2,11 @@ import ErrorBlock from "@/components/shared/ErrorBlock";
|
||||
import { Button } from "@/components/ui/button";
|
||||
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Label } from "@/components/ui/label";
|
||||
import Loader from "@/components/ui/loader";
|
||||
import { useToast } from "@/components/ui/use-toast";
|
||||
import { searchPlaces } from "@/handlers/api/common.handler";
|
||||
import { cn } from "@/lib/utils";
|
||||
import { IPlace } from "@/types/common";
|
||||
import clsx from "clsx";
|
||||
import { Check } from "lucide-react";
|
||||
import React, { useRef, useState } from "react";
|
||||
|
||||
|
||||
+1
-6
@@ -1,16 +1,11 @@
|
||||
|
||||
import ErrorBlock from "@/components/shared/ErrorBlock";
|
||||
import { Button } from "@/components/ui/button";
|
||||
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Label } from "@/components/ui/label";
|
||||
import Loader from "@/components/ui/loader";
|
||||
import { useToast } from "@/components/ui/use-toast";
|
||||
import { searchPlaces } from "@/handlers/api/common.handler";
|
||||
import { cn } from "@/lib/utils";
|
||||
import { IPlace } from "@/types/common";
|
||||
import { Check } from "lucide-react";
|
||||
import React, { useMemo, useRef, useState } from "react";
|
||||
import React, { useMemo, useState } from "react";
|
||||
|
||||
interface TagMissingLocationSearchLatLongProps {
|
||||
onSubmit: (place: IPlace) => Promise<any>;
|
||||
|
||||
@@ -3,8 +3,6 @@ import inputStyle from './findInputStyle'
|
||||
import { MentionsInput, Mention } from 'react-mentions'
|
||||
import { searchPeople } from '@/handlers/api/people.handler';
|
||||
import mentionStyle from './findMentionStyle';
|
||||
import classNames from './FindInput.module.css';
|
||||
|
||||
|
||||
interface FindInputProps {
|
||||
onSearch: (query: string) => void;
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
import React from "react";
|
||||
import Header from "../shared/Header";
|
||||
import { cn } from "@/lib/utils";
|
||||
import Head from "next/head";
|
||||
|
||||
|
||||
interface IProps {
|
||||
children: React.ReactNode[] | React.ReactNode;
|
||||
|
||||
@@ -11,7 +11,6 @@ import { LoginForm } from "../auth/LoginForm";
|
||||
import { useConfig } from "@/contexts/ConfigContext";
|
||||
import { Toaster } from "react-hot-toast";
|
||||
import { useRouter } from "next/router";
|
||||
import PageLayout from "./PageLayout";
|
||||
|
||||
type RootLayoutProps = {
|
||||
children: ReactNode;
|
||||
|
||||
@@ -16,11 +16,11 @@ import { Input } from "../ui/input";
|
||||
import { IPersonListFilters } from "@/handlers/api/people.handler";
|
||||
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "../ui/select";
|
||||
import { removeNullOrUndefinedProperties } from "@/helpers/data.helper";
|
||||
import { ParsedUrlQueryInput } from "querystring";
|
||||
|
||||
export function PeopleFilters() {
|
||||
const router = useRouter();
|
||||
const { updateContext, page, maximumAssetCount, type = "all", query = "", visibility = "all" } = usePeopleFilterContext();
|
||||
const filters = usePeopleFilterContext();
|
||||
const { updateContext, page, maximumAssetCount, type = "all", query = "", visibility = "all" } = filters;
|
||||
|
||||
const handleChange = (data: Partial<IPersonListFilters>) => {
|
||||
updateContext(data);
|
||||
@@ -69,7 +69,10 @@ export function PeopleFilters() {
|
||||
}}
|
||||
/>
|
||||
|
||||
<Select value={type} onValueChange={(value) => handleChange({ type: value })}>
|
||||
<Select value={type} onValueChange={(value) => handleChange({
|
||||
...removeNullOrUndefinedProperties(filters),
|
||||
type: value as "all" | "nameless" | "named"
|
||||
})}>
|
||||
<SelectTrigger>
|
||||
<SelectValue placeholder="Person Type" />
|
||||
</SelectTrigger>
|
||||
@@ -80,7 +83,10 @@ export function PeopleFilters() {
|
||||
</SelectContent>
|
||||
</Select>
|
||||
|
||||
<Select value={visibility} onValueChange={(value) => handleChange({ visibility: value as "all" | "visible" | "hidden" })}>
|
||||
<Select value={visibility} onValueChange={(value) => handleChange({
|
||||
...removeNullOrUndefinedProperties(filters),
|
||||
visibility: value as "all" | "visible" | "hidden"
|
||||
})}>
|
||||
<SelectTrigger>
|
||||
<SelectValue placeholder="Visibility" />
|
||||
</SelectTrigger>
|
||||
|
||||
@@ -1,11 +1,6 @@
|
||||
import { IPerson } from "@/types/person";
|
||||
import React, { useState } from "react";
|
||||
import { DatePicker } from "../ui/datepicker";
|
||||
import { updatePerson } from "@/handlers/api/people.handler";
|
||||
import { formatDate } from "@/helpers/date.helper";
|
||||
import { Button } from "../ui/button";
|
||||
import { Switch } from "../ui/switch";
|
||||
import { Label } from "../ui/label";
|
||||
|
||||
interface IProps {
|
||||
person: IPerson;
|
||||
|
||||
@@ -1,17 +1,19 @@
|
||||
import { IPerson } from "@/types/person";
|
||||
import React, { useState } from "react";
|
||||
import React, { useRef, useState } from "react";
|
||||
import { Avatar } from "../ui/avatar";
|
||||
import { updatePerson } from "@/handlers/api/people.handler";
|
||||
import { mergePerson, searchPeople, updatePerson } from "@/handlers/api/people.handler";
|
||||
import { PersonMergeDropdown } from "./PersonMergeDropdown";
|
||||
import PersonBirthdayCell from "./PersonBirthdayCell";
|
||||
import clsx from "clsx";
|
||||
import Link from "next/link";
|
||||
import { ArrowUpRight, Info, Search } from "lucide-react";
|
||||
import { ArrowUpRight, Info } from "lucide-react";
|
||||
import { useConfig } from "@/contexts/ConfigContext";
|
||||
import { useToast } from "../ui/use-toast";
|
||||
import { Badge } from "../ui/badge";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import ShareAssetsTrigger from "../shared/ShareAssetsTrigger";
|
||||
import { Autocomplete, AutocompleteOption } from "../ui/autocomplete";
|
||||
import { AlertDialog, IAlertDialogActions } from "../ui/alert-dialog";
|
||||
interface IProps {
|
||||
person: IPerson;
|
||||
onRemove: (person: IPerson) => void;
|
||||
@@ -22,6 +24,8 @@ export default function PersonItem({ person, onRemove }: IProps) {
|
||||
const [editMode, setEditMode] = useState(false);
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [formData, setFormData] = useState(person);
|
||||
const selectedPerson = useRef<AutocompleteOption | null>(null);
|
||||
const mergeDialogRef = useRef<IAlertDialogActions>(null);
|
||||
|
||||
const handleEdit = () => {
|
||||
if (formData.name && formData.name !== person.name) {
|
||||
@@ -62,12 +66,16 @@ export default function PersonItem({ person, onRemove }: IProps) {
|
||||
isHidden: hidden,
|
||||
}));
|
||||
})
|
||||
.catch(() => {})
|
||||
.catch(() => { })
|
||||
.finally(() => {
|
||||
setLoading(false);
|
||||
});
|
||||
};
|
||||
|
||||
const handleMerge = async (option: AutocompleteOption) => {
|
||||
await mergePerson(person.id, [option.value]);
|
||||
};
|
||||
|
||||
return (
|
||||
<div
|
||||
className={clsx(
|
||||
@@ -79,11 +87,11 @@ export default function PersonItem({ person, onRemove }: IProps) {
|
||||
)}
|
||||
>
|
||||
<div className="relative w-full h-auto group">
|
||||
<Avatar
|
||||
className="w-full min-h-full h-auto rounded-lg"
|
||||
src={person.thumbnailPath}
|
||||
alt={person.name}
|
||||
/>
|
||||
<Avatar
|
||||
className="w-full min-h-full h-auto rounded-lg"
|
||||
src={person.thumbnailPath}
|
||||
alt={person.name}
|
||||
/>
|
||||
<div className="absolute bottom-2 w-full flex justify-center items-center">
|
||||
<Badge variant={"secondary"} className="text-xs !font-medium font-mono">{person.assetCount} Assets</Badge>
|
||||
</div>
|
||||
@@ -103,13 +111,13 @@ export default function PersonItem({ person, onRemove }: IProps) {
|
||||
</Link>
|
||||
</div>
|
||||
<div className="absolute top-2 right-2 flex flex-col gap-2">
|
||||
<PersonMergeDropdown person={person} onRemove={onRemove}/>
|
||||
<PersonMergeDropdown person={person} onRemove={onRemove} />
|
||||
<Button variant="outline" className="!py-0.5 !px-2 text-xs h-7" onClick={() => {
|
||||
handleHide(!formData.isHidden);
|
||||
}}>
|
||||
{formData.isHidden ? "Show" : "Hide"}
|
||||
</Button>
|
||||
<ShareAssetsTrigger filters={{ personIds: [person.id] }} buttonProps={{ variant: "outline", className: "!py-0.5 !px-2 text-xs h-7" }} />
|
||||
{formData.isHidden ? "Show" : "Hide"}
|
||||
</Button>
|
||||
<ShareAssetsTrigger filters={{ personIds: [person.id] }} buttonProps={{ variant: "outline", className: "!py-0.5 !px-2 text-xs h-7" }} />
|
||||
</div>
|
||||
</div>
|
||||
{!editMode ? (
|
||||
@@ -126,7 +134,11 @@ export default function PersonItem({ person, onRemove }: IProps) {
|
||||
)}
|
||||
</h2>
|
||||
) : (
|
||||
<input
|
||||
<Autocomplete
|
||||
loadOptions={(query: string) => searchPeople(query).then((people) => people.map((person: any) => ({
|
||||
label: person.name, value: person.id,
|
||||
imageUrl: person.thumbnailPath
|
||||
})))}
|
||||
type="text"
|
||||
className="text-lg font-semibold text-center w-full px-2 py-1 rounded-lg"
|
||||
defaultValue={formData.name}
|
||||
@@ -135,18 +147,32 @@ export default function PersonItem({ person, onRemove }: IProps) {
|
||||
onChange={(e) => {
|
||||
setFormData({ ...formData, name: e.target.value });
|
||||
}}
|
||||
onKeyDown={(e) => {
|
||||
if (e.key === "Enter") {
|
||||
handleEdit();
|
||||
}
|
||||
value={formData.name}
|
||||
onOptionSelect={(value) => {
|
||||
mergeDialogRef.current?.open();
|
||||
selectedPerson.current = value;
|
||||
}}
|
||||
createNewLabel="Create"
|
||||
disabled={loading}
|
||||
onBlur={handleEdit}
|
||||
onCreateNew={(value) => {
|
||||
handleEdit();
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
<div className="flex flex-col gap-2">
|
||||
<PersonBirthdayCell person={person} />
|
||||
</div>
|
||||
|
||||
<AlertDialog
|
||||
ref={mergeDialogRef}
|
||||
title="Merge Person"
|
||||
description="Are you sure you want to merge this person with the selected person?"
|
||||
onConfirm={() => {
|
||||
if (selectedPerson.current) {
|
||||
handleMerge(selectedPerson.current);
|
||||
}
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
import { ASSET_THUMBNAIL_PATH } from '@/config/routes';
|
||||
import { useConfig } from '@/contexts/ConfigContext';
|
||||
import { ExternalLink } from 'lucide-react';
|
||||
import Image from 'next/image';
|
||||
import Link from 'next/link';
|
||||
import React, { useMemo } from 'react'
|
||||
|
||||
@@ -2,7 +2,6 @@ import { listAlbums } from '@/handlers/api/album.handler';
|
||||
import { IAlbum } from '@/types/album';
|
||||
import React, { useEffect, useState } from 'react'
|
||||
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '../ui/select';
|
||||
import { X } from 'lucide-react';
|
||||
|
||||
interface IAlbumDropdownProps {
|
||||
albumIds?: string[];
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
import { useConfig } from '@/contexts/ConfigContext';
|
||||
import { Link } from 'lucide-react';
|
||||
import React from 'react'
|
||||
|
||||
interface ErrorBlockProps {
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { Button } from '@/components/ui/button'
|
||||
import React from 'react'
|
||||
|
||||
interface FloatingBarProps {
|
||||
|
||||
@@ -1,23 +1,7 @@
|
||||
import React, { useMemo } from "react";
|
||||
import Link from "next/link";
|
||||
import {
|
||||
Home,
|
||||
LineChart,
|
||||
Menu,
|
||||
Package,
|
||||
Package2,
|
||||
ShoppingCart,
|
||||
Users,
|
||||
} from "lucide-react";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { Menu } from "lucide-react";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import {
|
||||
Card,
|
||||
CardContent,
|
||||
CardDescription,
|
||||
CardHeader,
|
||||
CardTitle,
|
||||
} from "@/components/ui/card";
|
||||
import { Sheet, SheetContent, SheetTrigger } from "@/components/ui/sheet";
|
||||
import Head from "next/head";
|
||||
import { sidebarNavs } from "@/config/constants/sidebarNavs";
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import React, { useCallback } from 'react'
|
||||
import React, { useCallback, useMemo, useState } from 'react'
|
||||
import { IPerson } from '@/types/person';
|
||||
import { cn } from '@/lib/utils';
|
||||
import LazyImage from '../ui/lazy-image';
|
||||
import { PERSON_THUBNAIL_PATH } from '@/config/routes';
|
||||
import { Input } from '../ui/input';
|
||||
|
||||
interface PeopleListProps {
|
||||
people: IPerson[];
|
||||
@@ -11,14 +11,25 @@ interface PeopleListProps {
|
||||
}
|
||||
|
||||
export default function PeopleList({ people, onSelect, selectedIds }: PeopleListProps) {
|
||||
|
||||
const [searchQuery, setSearchQuery] = useState<string>("")
|
||||
|
||||
const filteredPeople = useMemo(() => {
|
||||
return people.filter((person) => person.name.toLowerCase().includes(searchQuery.toLowerCase()))
|
||||
}, [people, searchQuery])
|
||||
|
||||
const isSelected = useCallback((person: IPerson) => {
|
||||
return selectedIds?.includes(person.id)
|
||||
}, [selectedIds])
|
||||
|
||||
return (
|
||||
<div className="flex flex-col overflow-x-hidden gap-2">
|
||||
{people.map((person) => (
|
||||
<div className="flex flex-col overflow-x-hidden gap-2 px-2 pt-2">
|
||||
<Input
|
||||
placeholder="Search"
|
||||
className="w-full"
|
||||
value={searchQuery}
|
||||
onChange={(e) => setSearchQuery(e.target.value)}
|
||||
/>
|
||||
{filteredPeople.map((person) => (
|
||||
<div
|
||||
className={cn(
|
||||
'flex items-center gap-2 cursor-pointer hover:bg-gray-300 dark:hover:bg-gray-700 rounded-md p-1',
|
||||
|
||||
@@ -9,7 +9,6 @@ import { Label } from '@radix-ui/react-label';
|
||||
import { Switch } from '../ui/switch';
|
||||
import { Select, SelectValue, SelectContent, SelectItem, SelectTrigger } from '../ui/select';
|
||||
|
||||
|
||||
interface ShareAssetsTriggerProps {
|
||||
filters: ShareLinkFilters
|
||||
buttonProps?: ButtonProps
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import React from "react";
|
||||
import { Button } from "../ui/button";
|
||||
import { useTheme } from "next-themes";
|
||||
import { Moon, Sun } from "lucide-react";
|
||||
import { cn } from "@/lib/utils";
|
||||
@@ -15,7 +14,7 @@ export default function ThemeSwitcher() {
|
||||
<button
|
||||
onClick={toggleTheme}
|
||||
className={cn(
|
||||
"p-1 rounded-md rounded-full transition-all duration-300 border border-primary text-primary",
|
||||
"p-1 rounded-full transition-all duration-300 border border-primary text-primary",
|
||||
)}
|
||||
>
|
||||
{theme === "light" ? <Moon size={10} /> : <Sun size={10} />}
|
||||
|
||||
@@ -128,7 +128,7 @@ const AlertDialogCancel = React.forwardRef<
|
||||
AlertDialogCancel.displayName = AlertDialogPrimitive.Cancel.displayName
|
||||
|
||||
|
||||
export interface INewChangelogButtonActions {
|
||||
export interface IAlertDialogActions {
|
||||
open: () => void
|
||||
}
|
||||
interface AlertDialogProps extends AlertDialogPrimitive.AlertDialogProps {
|
||||
@@ -142,7 +142,7 @@ interface AlertDialogProps extends AlertDialogPrimitive.AlertDialogProps {
|
||||
disabled?: boolean
|
||||
}
|
||||
|
||||
const AlertDialog = React.forwardRef<INewChangelogButtonActions, Partial<AlertDialogProps>>(({
|
||||
const AlertDialog = React.forwardRef<IAlertDialogActions, Partial<AlertDialogProps>>(({
|
||||
children,
|
||||
title,
|
||||
description,
|
||||
|
||||
@@ -0,0 +1,251 @@
|
||||
import * as React from "react"
|
||||
import { Input } from "./input"
|
||||
import { cn } from "@/lib/utils"
|
||||
import { Avatar, AvatarImage } from "./avatar"
|
||||
|
||||
export interface AutocompleteOption {
|
||||
label: string
|
||||
value: string
|
||||
imageUrl?: string
|
||||
}
|
||||
|
||||
export interface AutocompleteProps extends React.InputHTMLAttributes<HTMLInputElement> {
|
||||
options?: AutocompleteOption[]
|
||||
value: string
|
||||
onOptionSelect: (value: AutocompleteOption) => void
|
||||
placeholder?: string
|
||||
className?: string
|
||||
loadOptions?: (inputValue: string) => Promise<AutocompleteOption[]>
|
||||
initialValue?: string
|
||||
isLoading?: boolean
|
||||
onCreateNew?: (inputValue: string) => void
|
||||
createNewLabel?: string
|
||||
}
|
||||
|
||||
const Autocomplete = React.forwardRef<HTMLInputElement, AutocompleteProps>(
|
||||
({
|
||||
options: staticOptions,
|
||||
value,
|
||||
onOptionSelect,
|
||||
placeholder,
|
||||
className,
|
||||
loadOptions,
|
||||
initialValue,
|
||||
isLoading: externalLoading,
|
||||
onCreateNew,
|
||||
createNewLabel = "Create new",
|
||||
...props
|
||||
}, forwardedRef) => {
|
||||
const [open, setOpen] = React.useState(false)
|
||||
const [inputValue, setInputValue] = React.useState(initialValue || value)
|
||||
const [options, setOptions] = React.useState<AutocompleteOption[]>(staticOptions || [])
|
||||
const [isLoading, setIsLoading] = React.useState(false)
|
||||
const [selectedIndex, setSelectedIndex] = React.useState(-1)
|
||||
const containerRef = React.useRef<HTMLDivElement>(null)
|
||||
const inputRef = React.useRef<HTMLInputElement>(null)
|
||||
const debounceTimeout = React.useRef<NodeJS.Timeout>()
|
||||
|
||||
// Find the label for the current value
|
||||
const currentLabel = React.useMemo(() => {
|
||||
if (!value) return ""
|
||||
const option = options.find(opt => opt.value === value)
|
||||
return option?.label || value
|
||||
}, [value, options])
|
||||
|
||||
React.useEffect(() => {
|
||||
setInputValue(initialValue || currentLabel)
|
||||
}, [initialValue, currentLabel])
|
||||
|
||||
// Close dropdown when clicking outside
|
||||
React.useEffect(() => {
|
||||
const handleClickOutside = (event: MouseEvent) => {
|
||||
if (containerRef.current && !containerRef.current.contains(event.target as Node)) {
|
||||
setOpen(false)
|
||||
setSelectedIndex(-1)
|
||||
}
|
||||
}
|
||||
|
||||
document.addEventListener("mousedown", handleClickOutside)
|
||||
return () => document.removeEventListener("mousedown", handleClickOutside)
|
||||
}, [])
|
||||
|
||||
// Handle async loading of options
|
||||
React.useEffect(() => {
|
||||
if (!loadOptions) return
|
||||
|
||||
const loadOptionsAsync = async () => {
|
||||
if (!inputValue.trim()) {
|
||||
setOptions([])
|
||||
return
|
||||
}
|
||||
|
||||
setIsLoading(true)
|
||||
try {
|
||||
const results = await loadOptions(inputValue)
|
||||
setOptions(results)
|
||||
} catch (error) {
|
||||
console.error('Error loading options:', error)
|
||||
setOptions([])
|
||||
} finally {
|
||||
setIsLoading(false)
|
||||
}
|
||||
}
|
||||
|
||||
// Debounce the search to avoid too many API calls
|
||||
if (debounceTimeout.current) {
|
||||
clearTimeout(debounceTimeout.current)
|
||||
}
|
||||
debounceTimeout.current = setTimeout(loadOptionsAsync, 300)
|
||||
|
||||
return () => {
|
||||
if (debounceTimeout.current) {
|
||||
clearTimeout(debounceTimeout.current)
|
||||
}
|
||||
}
|
||||
}, [inputValue, loadOptions])
|
||||
|
||||
const filteredOptions = loadOptions
|
||||
? options
|
||||
: (staticOptions || []).filter((option) =>
|
||||
option.label.toLowerCase().includes(inputValue.toLowerCase())
|
||||
)
|
||||
|
||||
const showCreateNew = onCreateNew && inputValue.trim() && !isLoading
|
||||
const totalOptions = filteredOptions.length + (showCreateNew ? 1 : 0)
|
||||
|
||||
const handleKeyDown = (e: React.KeyboardEvent<HTMLInputElement | HTMLDivElement>) => {
|
||||
if (!open) {
|
||||
if (e.key === 'ArrowDown' || e.key === 'ArrowUp') {
|
||||
e.preventDefault()
|
||||
setOpen(true)
|
||||
setSelectedIndex(showCreateNew ? 0 : -1)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
switch (e.key) {
|
||||
case 'ArrowDown':
|
||||
e.preventDefault()
|
||||
setSelectedIndex((prev) => {
|
||||
const next = prev + 1
|
||||
return next >= totalOptions ? 0 : next
|
||||
})
|
||||
break
|
||||
case 'ArrowUp':
|
||||
e.preventDefault()
|
||||
setSelectedIndex((prev) => {
|
||||
const next = prev - 1
|
||||
return next < 0 ? totalOptions - 1 : next
|
||||
})
|
||||
break
|
||||
case 'Enter':
|
||||
e.preventDefault()
|
||||
if (showCreateNew && selectedIndex === 0) {
|
||||
onCreateNew(inputValue.trim())
|
||||
setOpen(false)
|
||||
setSelectedIndex(-1)
|
||||
} else if (selectedIndex >= (showCreateNew ? 1 : 0) && selectedIndex < totalOptions) {
|
||||
const option = filteredOptions[selectedIndex - (showCreateNew ? 1 : 0)]
|
||||
setInputValue(option.label)
|
||||
onOptionSelect(option)
|
||||
setOpen(false)
|
||||
setSelectedIndex(-1)
|
||||
}
|
||||
break
|
||||
case 'Escape':
|
||||
e.preventDefault()
|
||||
setOpen(false)
|
||||
setSelectedIndex(-1)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<div
|
||||
ref={containerRef}
|
||||
className="relative w-full"
|
||||
onKeyDown={handleKeyDown}
|
||||
tabIndex={-1}
|
||||
>
|
||||
<Input
|
||||
ref={(node) => {
|
||||
// Handle both the forwarded ref and our internal ref
|
||||
if (typeof forwardedRef === 'function') {
|
||||
forwardedRef(node)
|
||||
}
|
||||
if (node) {
|
||||
(inputRef as React.MutableRefObject<HTMLInputElement | null>).current = node
|
||||
}
|
||||
}}
|
||||
value={inputValue}
|
||||
onFocus={() => {
|
||||
setOpen(true)
|
||||
setSelectedIndex(showCreateNew ? 0 : -1)
|
||||
}}
|
||||
onKeyDown={handleKeyDown}
|
||||
placeholder={placeholder}
|
||||
className={cn("w-full", className)}
|
||||
{...props}
|
||||
onChange={(e) => {
|
||||
setInputValue(e.target.value)
|
||||
setSelectedIndex(showCreateNew ? 0 : -1)
|
||||
props.onChange?.(e)
|
||||
}}
|
||||
/>
|
||||
{open && (filteredOptions.length > 0 || isLoading || showCreateNew) && (
|
||||
<div className="absolute left-0 right-0 top-full z-50 mt-1 max-h-[300px] overflow-auto rounded-md border bg-popover shadow-md">
|
||||
{isLoading ? (
|
||||
<div className="px-3 py-2 text-sm text-muted-foreground">
|
||||
Loading...
|
||||
</div>
|
||||
) : (
|
||||
<>
|
||||
{showCreateNew && (
|
||||
<button
|
||||
className={cn(
|
||||
"w-full px-3 py-2 text-left text-sm text-primary hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground focus:outline-none",
|
||||
selectedIndex === 0 && "bg-accent text-accent-foreground"
|
||||
)}
|
||||
onClick={() => {
|
||||
onCreateNew(inputValue.trim())
|
||||
setOpen(false)
|
||||
setSelectedIndex(-1)
|
||||
}}
|
||||
>
|
||||
{createNewLabel} "{inputValue.trim()}"
|
||||
</button>
|
||||
)}
|
||||
{filteredOptions.map((option, index) => (
|
||||
<button
|
||||
key={option.value}
|
||||
className={cn(
|
||||
"w-full px-3 py-2 text-left text-sm hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground focus:outline-none flex items-center gap-2",
|
||||
(showCreateNew ? index + 1 : index) === selectedIndex && "bg-accent text-accent-foreground"
|
||||
)}
|
||||
onClick={() => {
|
||||
setInputValue(option.label)
|
||||
onOptionSelect(option)
|
||||
setOpen(false)
|
||||
setSelectedIndex(-1)
|
||||
}}
|
||||
>
|
||||
{option.imageUrl && (
|
||||
<Avatar className="w-6 h-6 rounded-full" src={option.imageUrl} alt={option.label} />
|
||||
)}
|
||||
<span className="truncate">
|
||||
{option.label}
|
||||
</span>
|
||||
</button>
|
||||
))}
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
)
|
||||
|
||||
Autocomplete.displayName = "Autocomplete"
|
||||
|
||||
export { Autocomplete }
|
||||
@@ -0,0 +1,15 @@
|
||||
import { cn } from "@/lib/utils"
|
||||
|
||||
function Skeleton({
|
||||
className,
|
||||
...props
|
||||
}: React.HTMLAttributes<HTMLDivElement>) {
|
||||
return (
|
||||
<div
|
||||
className={cn("animate-pulse rounded-md bg-primary/10", className)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
export { Skeleton }
|
||||
@@ -0,0 +1,3 @@
|
||||
import { QueryClient } from "@tanstack/react-query";
|
||||
|
||||
export const queryClient = new QueryClient();
|
||||
@@ -68,4 +68,6 @@ export const FIND_ASSETS = BASE_API_ENDPOINT + "/find/search";
|
||||
export const SHARE_LINK_PATH = (token: string) => BASE_API_ENDPOINT + "/share-link/" + token;
|
||||
export const SHARE_LINK_GENERATE_PATH = BASE_API_ENDPOINT + "/share-link/generate";
|
||||
export const SHARE_LINK_ASSETS_PATH = (token: string) => BASE_API_ENDPOINT + "/share-link/" + token + "/assets";
|
||||
export const SHARE_LINK_PEOPLE_PATH = (token: string) => BASE_API_ENDPOINT + "/share-link/" + token + "/people";
|
||||
export const SHARE_LINK_PEOPLE_PATH = (token: string) => BASE_API_ENDPOINT + "/share-link/" + token + "/people";
|
||||
export const SHARE_LINK_DOWNLOAD_PATH = (token: string) => BASE_API_ENDPOINT + "/share-link/" + token + "/download";
|
||||
export const DOWNLOAD_ASSETS_PATH = BASE_PROXY_ENDPOINT + "/download/archive";
|
||||
@@ -1,6 +1,7 @@
|
||||
|
||||
import {
|
||||
SHARE_LINK_ASSETS_PATH,
|
||||
SHARE_LINK_DOWNLOAD_PATH,
|
||||
SHARE_LINK_GENERATE_PATH,
|
||||
SHARE_LINK_PATH,
|
||||
SHARE_LINK_PEOPLE_PATH
|
||||
@@ -22,4 +23,8 @@ export const generateShareLink = async (filters: ShareLinkFilters) => {
|
||||
|
||||
export const getShareLinkPeople = async (token: string) => {
|
||||
return API.get(SHARE_LINK_PEOPLE_PATH(token));
|
||||
}
|
||||
|
||||
export const downloadShareLink = async (token: string, assetIds: string[]) => {
|
||||
return API.post(SHARE_LINK_DOWNLOAD_PATH(token), { assetIds });
|
||||
}
|
||||
@@ -4,7 +4,7 @@ import { z } from "zod";
|
||||
import { removeNullOrUndefinedProperties } from "./data.helper";
|
||||
|
||||
const gemini = new GoogleGenerativeAI(ENV.GEMINI_API_KEY);
|
||||
const model = gemini.getGenerativeModel({ model: "gemini-1.5-flash" });
|
||||
const model = gemini.getGenerativeModel({ model: "gemini-2.0-flash" });
|
||||
|
||||
interface FindQuery {
|
||||
query: string;
|
||||
@@ -80,9 +80,12 @@ export const parseFindQuery = async (query: string): Promise<FindQuery> => {
|
||||
}
|
||||
});
|
||||
|
||||
console.log("response from gemini", response.text());
|
||||
|
||||
const parsedResponse = JSON.parse(response.text()) as FindQuery;
|
||||
const cleanedResponse = {
|
||||
...parsedResponse
|
||||
};
|
||||
|
||||
return removeNullOrUndefinedProperties(cleanedResponse) as any as FindQuery;
|
||||
}
|
||||
+9
-5
@@ -5,6 +5,8 @@ import { ThemeProvider } from "next-themes";
|
||||
import { ENV } from "@/config/environment";
|
||||
import ConfigContext, { ConfigContextType } from "@/contexts/ConfigContext";
|
||||
import { useRef } from "react";
|
||||
import { queryClient } from "@/config/queryClient";
|
||||
import { QueryClientProvider } from "@tanstack/react-query";
|
||||
interface AppPropsWithProps extends AppProps {
|
||||
props: ConfigContextType;
|
||||
}
|
||||
@@ -13,11 +15,13 @@ const App = ({ Component, pageProps, ...props }: AppPropsWithProps) => {
|
||||
|
||||
return (
|
||||
<ConfigContext.Provider value={intialData.current}>
|
||||
<ThemeProvider attribute="class" storageKey="theme">
|
||||
<RootLayout>
|
||||
<Component {...pageProps} />
|
||||
</RootLayout>
|
||||
</ThemeProvider>
|
||||
<QueryClientProvider client={queryClient}>
|
||||
<ThemeProvider attribute="class" storageKey="theme">
|
||||
<RootLayout>
|
||||
<Component {...pageProps} />
|
||||
</RootLayout>
|
||||
</ThemeProvider>
|
||||
</QueryClientProvider>
|
||||
</ConfigContext.Provider>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -66,10 +66,6 @@ export default function PotentialAlbums() {
|
||||
return createAlbum({
|
||||
...formData,
|
||||
assetIds: config.selectedIds,
|
||||
albumUsers: [{
|
||||
role: "editor",
|
||||
userId: id,
|
||||
}]
|
||||
}).then(() => {
|
||||
toast({
|
||||
title: "Album created",
|
||||
|
||||
@@ -3,13 +3,10 @@ import { NextApiRequest } from "next";
|
||||
import { db } from "@/config/db";
|
||||
import { getCurrentUser } from "@/handlers/serverUtils/user.utils";
|
||||
import { NextApiResponse } from "next";
|
||||
import { albums } from "@/schema/albums.schema";
|
||||
import { count, desc, eq, min, max, sql, and, asc, isNotNull } from "drizzle-orm";
|
||||
import { and, eq, isNotNull } from "drizzle-orm";
|
||||
import { assets } from "@/schema/assets.schema";
|
||||
import { albumsAssetsAssets } from "@/schema/albumAssetsAssets.schema";
|
||||
import { users } from "@/schema/users.schema";
|
||||
import { assetFaces, exif, person } from "@/schema";
|
||||
import { IAlbum } from "@/types/album";
|
||||
|
||||
export default async function handler(
|
||||
req: NextApiRequest,
|
||||
|
||||
@@ -4,12 +4,10 @@ import { db } from "@/config/db";
|
||||
import { getCurrentUser } from "@/handlers/serverUtils/user.utils";
|
||||
import { NextApiResponse } from "next";
|
||||
import { albums } from "@/schema/albums.schema";
|
||||
import { count, desc, eq, min, max, sql, and, asc, isNotNull } from "drizzle-orm";
|
||||
import { count, desc, eq, and, isNotNull } from "drizzle-orm";
|
||||
import { assets } from "@/schema/assets.schema";
|
||||
import { albumsAssetsAssets } from "@/schema/albumAssetsAssets.schema";
|
||||
import { users } from "@/schema/users.schema";
|
||||
import { assetFaces, exif, person } from "@/schema";
|
||||
import { IAlbum } from "@/types/album";
|
||||
import { assetFaces, person } from "@/schema";
|
||||
|
||||
export default async function handler(
|
||||
req: NextApiRequest,
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { NextApiRequest } from "next";
|
||||
|
||||
import { db } from "@/config/db";
|
||||
import { getCurrentUser } from "@/handlers/serverUtils/user.utils";
|
||||
import { NextApiResponse } from "next";
|
||||
import { albums } from "@/schema/albums.schema";
|
||||
import { count, eq, min, max, sql, and } from "drizzle-orm";
|
||||
|
||||
@@ -7,7 +7,6 @@ import { albums } from "@/schema/albums.schema";
|
||||
import { count, desc, eq, min, max, sql, and, sum, isNotNull } from "drizzle-orm";
|
||||
import { assets } from "@/schema/assets.schema";
|
||||
import { albumsAssetsAssets } from "@/schema/albumAssetsAssets.schema";
|
||||
import { users } from "@/schema/users.schema";
|
||||
import { assetFaces, exif, person } from "@/schema";
|
||||
import { IAlbum } from "@/types/album";
|
||||
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
// 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 { isFlipped } from "@/helpers/asset.helper";
|
||||
import { exif } from "@/schema";
|
||||
import { count, desc, isNotNull, ne, sql } from "drizzle-orm";
|
||||
import { sql } from "drizzle-orm";
|
||||
import type { NextApiRequest, NextApiResponse } from "next";
|
||||
|
||||
const SELECT_ORPHAN_PHOTOS = (date: string, ownerId: string) =>
|
||||
@@ -39,6 +36,8 @@ const SELECT_ORPHAN_PHOTOS = (date: string, ownerId: string) =>
|
||||
AND a."ownerId" = '${ownerId}'
|
||||
AND e."dateTimeOriginal"::date = '${date}'
|
||||
AND a."isVisible" = true
|
||||
ORDER BY
|
||||
e."dateTimeOriginal" DESC
|
||||
`);
|
||||
|
||||
export default async function handler(
|
||||
|
||||
@@ -4,12 +4,10 @@ import { IPotentialAlbumsDatesResponse } from "@/handlers/api/album.handler";
|
||||
import { getCurrentUser } from "@/handlers/serverUtils/user.utils";
|
||||
import { parseDate } from "@/helpers/date.helper";
|
||||
import { albumsAssetsAssets } from "@/schema/albumAssetsAssets.schema";
|
||||
import { albums } from "@/schema/albums.schema";
|
||||
import { assets } from "@/schema/assets.schema";
|
||||
import { exif } from "@/schema/exif.schema";
|
||||
import { and, count, desc, eq, gte, isNotNull, isNull, sql } from "drizzle-orm";
|
||||
import { and, count, desc, eq, isNotNull, isNull, sql } from "drizzle-orm";
|
||||
import type { NextApiRequest, NextApiResponse } from "next";
|
||||
import { number } from "zod";
|
||||
|
||||
|
||||
export default async function handler(
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
// 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";
|
||||
|
||||
@@ -2,7 +2,6 @@ import { db } from "@/config/db";
|
||||
import { getCurrentUser } from "@/handlers/serverUtils/user.utils";
|
||||
import { humanizeBytes } from "@/helpers/string.helper";
|
||||
import { assets, exif, users } from "@/schema";
|
||||
import { Value } from "@radix-ui/react-select";
|
||||
import { desc, eq } from "drizzle-orm";
|
||||
import { sum } from "drizzle-orm";
|
||||
import { NextApiResponse } from "next";
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
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 { albumsAssetsAssets } from "@/schema/albumAssetsAssets.schema";
|
||||
import { albums } from "@/schema/albums.schema";
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
// 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";
|
||||
|
||||
@@ -1,19 +1,20 @@
|
||||
import { db } from '@/config/db';
|
||||
import { ENV } from '@/config/environment';
|
||||
import { getCurrentUser } from '@/handlers/serverUtils/user.utils';
|
||||
import { cleanUpAsset, cleanUpAssets, isFlipped } from '@/helpers/asset.helper';
|
||||
import { cleanUpAsset, isFlipped } from '@/helpers/asset.helper';
|
||||
import { parseFindQuery } from '@/helpers/gemini.helper';
|
||||
import { assetFaces, assets, person } from '@/schema';
|
||||
import { person } from '@/schema';
|
||||
import { Person } from '@/schema/person.schema';
|
||||
import { and, eq, inArray } from 'drizzle-orm';
|
||||
import { inArray } from 'drizzle-orm';
|
||||
import { NextApiRequest, NextApiResponse } from 'next';
|
||||
|
||||
export default async function search(req: NextApiRequest, res: NextApiResponse) {
|
||||
const { query } = req.body;
|
||||
const currentUser = await getCurrentUser(req);
|
||||
const parsedQuery = await parseFindQuery(query as string);
|
||||
const { personIds } = parsedQuery;
|
||||
const url = ENV.IMMICH_URL + "/api/search/smart";
|
||||
try {
|
||||
const { query } = req.body;
|
||||
const currentUser = await getCurrentUser(req);
|
||||
const parsedQuery = await parseFindQuery(query as string);
|
||||
const { personIds } = parsedQuery;
|
||||
const url = ENV.IMMICH_URL + "/api/search/smart";
|
||||
|
||||
let dbPeople: Person[] = [];
|
||||
if (personIds) {
|
||||
@@ -57,7 +58,11 @@ export default async function search(req: NextApiRequest, res: NextApiResponse)
|
||||
},
|
||||
});
|
||||
}).catch(err => {
|
||||
res.status(500).json({ error: err.message });
|
||||
res.status(500).json({ message: err.message });
|
||||
});
|
||||
} catch (err: any) {
|
||||
console.error(err);
|
||||
res.status(500).json({ message: err.message || "Failed to parse query" });
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
import { NextApiRequest, NextApiResponse } from 'next';
|
||||
|
||||
export default function handler(req: NextApiRequest, res: NextApiResponse) {
|
||||
if (req.method !== 'GET') {
|
||||
return res.status(405).json({ message: 'Method not allowed' });
|
||||
}
|
||||
|
||||
return res.status(200).json({ status: 'healthy' });
|
||||
}
|
||||
@@ -1,5 +1,3 @@
|
||||
// pages/api/proxy/[...path].ts
|
||||
|
||||
import { ENV } from '@/config/environment';
|
||||
import { getCurrentUser } from '@/handlers/serverUtils/user.utils';
|
||||
import { getUserHeaders } from '@/helpers/user.helper';
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
// 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 { stringToBoolean } from "@/helpers/data.helper";
|
||||
import { assetFaces, assets, exif, person } from "@/schema";
|
||||
import { assetFaces, person } from "@/schema";
|
||||
import { faceSearch } from "@/schema/faceSearch.schema";
|
||||
import { and, cosineDistance, desc, eq, gt, ne, sql } from "drizzle-orm";
|
||||
import type { NextApiRequest, NextApiResponse } from "next";
|
||||
|
||||
@@ -2,7 +2,7 @@ import { db } from "@/config/db";
|
||||
import { ENV } from "@/config/environment";
|
||||
import { desc, gte, lte } from "drizzle-orm";
|
||||
import { eq, inArray } from "drizzle-orm";
|
||||
import { assetFaces, assets, exif, person } from "@/schema";
|
||||
import { assetFaces, assets, exif } from "@/schema";
|
||||
import { and } from "drizzle-orm";
|
||||
import { JsonWebTokenError, sign, verify } from "jsonwebtoken";
|
||||
import { NextApiResponse } from "next";
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
import { ENV } from "@/config/environment";
|
||||
import { JsonWebTokenError, verify } from "jsonwebtoken";
|
||||
import { NextApiResponse } from "next";
|
||||
|
||||
import { NextApiRequest } from "next";
|
||||
import { getUserHeaders } from "@/helpers/user.helper";
|
||||
|
||||
interface ShareLinkFilters {
|
||||
personIds: string[];
|
||||
albumIds: string[];
|
||||
startDate: string;
|
||||
endDate: string;
|
||||
}
|
||||
|
||||
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
|
||||
const { token } = req.query;
|
||||
const { assetIds } = req.body;
|
||||
try {
|
||||
if (!token) {
|
||||
return res.status(404).json({ message: "Token not found" });
|
||||
}
|
||||
if (req.method !== "POST") {
|
||||
return res.status(405).json({ message: "Method not allowed" });
|
||||
}
|
||||
|
||||
const decoded = verify(token as string, ENV.JWT_SECRET);
|
||||
|
||||
if (!decoded) {
|
||||
return res.status(401).json({ message: "Unauthorized" });
|
||||
}
|
||||
|
||||
const targetUrl = `${ENV.IMMICH_URL}/api/download/archive`;
|
||||
|
||||
const response = await fetch(targetUrl, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ assetIds }),
|
||||
headers: getUserHeaders({ isUsingShareKey: true }, {
|
||||
'Content-Type': 'application/json',
|
||||
}),
|
||||
})
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`HTTP error! status: ${response.status}`)
|
||||
}
|
||||
|
||||
// Get the image data from the response
|
||||
const imageBuffer = await response.arrayBuffer()
|
||||
|
||||
// Set the appropriate headers for the image response
|
||||
res.setHeader('Content-Type', response.headers.get('Content-Type') || 'image/png')
|
||||
res.setHeader('Content-Length', imageBuffer.byteLength)
|
||||
|
||||
// Send the image data
|
||||
res.send(Buffer.from(imageBuffer))
|
||||
|
||||
} catch (error) {
|
||||
if (error instanceof JsonWebTokenError) {
|
||||
return res.status(401).json({ message: "Please check your link and try again. Looks like it's expired." });
|
||||
}
|
||||
return res.status(500).json({ message: (error as Error).message });
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,5 @@
|
||||
// pages/api/proxy.js
|
||||
|
||||
import { appConfig } from "@/config/app.config";
|
||||
import { getCurrentUser, loginUser } from "@/handlers/serverUtils/user.utils";
|
||||
import { loginUser } from "@/handlers/serverUtils/user.utils";
|
||||
import { serializeCookie } from "@/lib/cookie";
|
||||
import { NextApiRequest, NextApiResponse } from "next";
|
||||
|
||||
|
||||
@@ -3,9 +3,7 @@ import MissingLocationDates from "@/components/assets/missing-location/MissingLo
|
||||
import TagMissingLocationDialog from "@/components/assets/missing-location/TagMissingLocationDialog/TagMissingLocationDialog";
|
||||
import PageLayout from "@/components/layouts/PageLayout";
|
||||
import Header from "@/components/shared/Header";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { useToast } from "@/components/ui/use-toast";
|
||||
import MissingLocationContext, {
|
||||
IMissingLocationConfig,
|
||||
} from "@/contexts/MissingLocationContext";
|
||||
|
||||
@@ -1,18 +1,13 @@
|
||||
import "yet-another-react-lightbox/styles.css";
|
||||
import FindInput from '@/components/find/FindInput';
|
||||
import PageLayout from '@/components/layouts/PageLayout';
|
||||
import Header from '@/components/shared/Header';
|
||||
import Loader from '@/components/ui/loader';
|
||||
import { ASSET_PREVIEW_PATH, ASSET_THUMBNAIL_PATH } from '@/config/routes';
|
||||
import { ASSET_PREVIEW_PATH } from '@/config/routes';
|
||||
import { useConfig } from '@/contexts/ConfigContext';
|
||||
import { findAssets } from '@/handlers/api/asset.handler';
|
||||
import { IAsset } from '@/types/asset';
|
||||
import { ArrowUpRight, Captions, Megaphone, Search, Speaker, TriangleAlert, WandSparkles } from 'lucide-react';
|
||||
import Image from 'next/image';
|
||||
import { Search, TriangleAlert, WandSparkles } from 'lucide-react';
|
||||
import React, { useMemo, useState } from 'react'
|
||||
import Lightbox from 'yet-another-react-lightbox';
|
||||
import { Button } from "@/components/ui/button";
|
||||
import Link from "next/link";
|
||||
import AssetGrid from "@/components/shared/AssetGrid";
|
||||
import FloatingBar from "@/components/shared/FloatingBar";
|
||||
import AssetsBulkDeleteButton from "@/components/shared/AssetsBulkDeleteButton";
|
||||
@@ -39,6 +34,7 @@ export default function FindPage() {
|
||||
const [assets, setAssets] = useState<IAsset[]>([]);
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [filters, setFilters] = useState<IFindFilters>({});
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
|
||||
const slides = useMemo(
|
||||
() =>
|
||||
@@ -76,6 +72,9 @@ export default function FindPage() {
|
||||
setAssets(assets);
|
||||
setFilters(_filters);
|
||||
})
|
||||
.catch((error: any) => {
|
||||
setError(error.message || error.error || "Failed to fetch assets");
|
||||
})
|
||||
.finally(() => {
|
||||
setLoading(false);
|
||||
});
|
||||
@@ -87,7 +86,7 @@ export default function FindPage() {
|
||||
|
||||
const handleDelete = (ids: string[]) => {
|
||||
setSelectedIds([]);
|
||||
setAssets(assets.filter((asset) => !ids.includes(asset.id)));
|
||||
setAssets(assets.filter((asset) => !ids.includes(asset.id)));
|
||||
|
||||
}
|
||||
|
||||
@@ -111,6 +110,18 @@ export default function FindPage() {
|
||||
<Loader />
|
||||
</div>
|
||||
}
|
||||
else if (error) {
|
||||
return (
|
||||
|
||||
<div className="flex justify-center items-center h-full flex-col gap-2">
|
||||
<TriangleAlert className='w-10 h-10 text-muted-foreground' />
|
||||
<p className='text-lg font-bold'>Oops, something went wrong</p>
|
||||
<p className='text-sm text-muted-foreground max-w-md text-center'>
|
||||
Error: {error}
|
||||
</p>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
else if (query.length === 0) {
|
||||
return (
|
||||
<div className="flex justify-center flex-col gap-2 items-center h-full">
|
||||
|
||||
@@ -2,12 +2,9 @@ import PageLayout from '@/components/layouts/PageLayout';
|
||||
import PersonAlbumList from '@/components/people/info/PersonAlbumList';
|
||||
import PersonCityList from '@/components/people/info/PersonCityList';
|
||||
import Header from '@/components/shared/Header';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import Loader from '@/components/ui/loader';
|
||||
import { ASSET_THUMBNAIL_PATH, PERSON_THUBNAIL_PATH } from '@/config/routes';
|
||||
import { useConfig } from '@/contexts/ConfigContext';
|
||||
import { PERSON_THUBNAIL_PATH } from '@/config/routes';
|
||||
import { getPersonInfo } from '@/handlers/api/person.handler';
|
||||
import { IAlbum } from '@/types/album';
|
||||
import { IPerson } from '@/types/person'
|
||||
import { GalleryThumbnails, MapPin, Plus } from 'lucide-react';
|
||||
import Image from 'next/image';
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import PageLayout from '@/components/layouts/PageLayout'
|
||||
import Header from '@/components/shared/Header'
|
||||
import Loader from '@/components/ui/loader'
|
||||
import React, { useEffect, useMemo, useState } from 'react'
|
||||
import React, { useEffect, useState } from 'react'
|
||||
import { useRouter } from 'next/router'
|
||||
import { Camera } from 'lucide-react'
|
||||
import { humanizeNumber } from '@/helpers/string.helper'
|
||||
|
||||
Reference in new issue
Block a user