fix: updated immich endpoint usage to runtime env
Signed-off-by: Varun Raj <mailme@varunraj.in>
This commit is contained in:
1 parent
0d66fa458f
commit
3ad9e9eea3
9 files changed
+56
-49
No files matched your search
+1
-1
@@ -1,3 +1,3 @@
|
|||||||
NEXT_PUBLIC_IMMICH_URL=""
|
IMMICH_URL=""
|
||||||
IMMICH_API_KEY=""
|
IMMICH_API_KEY=""
|
||||||
DATABASE_URL=""
|
DATABASE_URL=""
|
||||||
@@ -42,7 +42,4 @@ jobs:
|
|||||||
docker build --build-arg VERSION=${{ env.VERSION }} \
|
docker build --build-arg VERSION=${{ env.VERSION }} \
|
||||||
--push -t varunraj/immich-power-tools:${{ env.VERSION }} \
|
--push -t varunraj/immich-power-tools:${{ env.VERSION }} \
|
||||||
-t varunraj/immich-power-tools:latest .
|
-t varunraj/immich-power-tools:latest .
|
||||||
env:
|
|
||||||
NEXT_PUBLIC_IMMICH_URL: http://192.168.0.200:3001
|
|
||||||
IMMICH_API_KEY: "immich-api-key"
|
|
||||||
DATABASE_URL: "dabaase-url"
|
|
||||||
@@ -32,7 +32,7 @@ docker compose up -d
|
|||||||
Copy paste the `.env.example` to `.env` and fill in the values.
|
Copy paste the `.env.example` to `.env` and fill in the values.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
NEXT_PUBLIC_IMMICH_URL="" # Immich API URL
|
IMMICH_URL="" # Immich API URL
|
||||||
IMMICH_API_KEY="" # Immich API Key
|
IMMICH_API_KEY="" # Immich API Key
|
||||||
DATABASE_URL="" # Postgress Database URL
|
DATABASE_URL="" # Postgress Database URL
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -12,41 +12,6 @@ import PersonHideCell from "./PersonHideCell";
|
|||||||
import { PeoplePagination } from "./PeoplePagination";
|
import { PeoplePagination } from "./PeoplePagination";
|
||||||
import { useRouter } from "next/router";
|
import { useRouter } from "next/router";
|
||||||
|
|
||||||
const columns: ColumnDef<IPerson>[] = [
|
|
||||||
{
|
|
||||||
header: "Name",
|
|
||||||
accessorKey: "name",
|
|
||||||
cell: ({ row }) => <PersonItem person={row.original} />,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
header: "Birth Date",
|
|
||||||
accessorKey: "birthDate",
|
|
||||||
cell: ({ row }) => <PersonBirthdayCell person={row.original} />,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
header: "Hidden",
|
|
||||||
accessorKey: "isHidden",
|
|
||||||
cell: ({ row }) => (
|
|
||||||
<PersonHideCell person={row.original} />
|
|
||||||
),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
header: "Link",
|
|
||||||
accessorKey: "id",
|
|
||||||
cell: ({ row }) => (
|
|
||||||
<Link href={`${ENV.IMMICH_URL}/people/${row.original.id}`} target="_blank">
|
|
||||||
View
|
|
||||||
</Link>
|
|
||||||
)
|
|
||||||
},
|
|
||||||
{
|
|
||||||
header: "Updated At",
|
|
||||||
accessorKey: "updatedAt",
|
|
||||||
cell: ({ row }) => <span>{new Date(
|
|
||||||
row.original.updatedAt
|
|
||||||
).toDateString()}</span>,
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
export default function PeopleList() {
|
export default function PeopleList() {
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
|
|||||||
@@ -9,11 +9,13 @@ import clsx from "clsx";
|
|||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import { ENV } from "@/config/environment";
|
import { ENV } from "@/config/environment";
|
||||||
import { ArrowUpRight } from "lucide-react";
|
import { ArrowUpRight } from "lucide-react";
|
||||||
|
import { useConfig } from "@/contexts/ConfigContext";
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
person: IPerson;
|
person: IPerson;
|
||||||
}
|
}
|
||||||
export default function PersonItem({ person }: IProps) {
|
export default function PersonItem({ person }: IProps) {
|
||||||
|
const { immichURL } = useConfig();
|
||||||
const [editMode, setEditMode] = useState(false);
|
const [editMode, setEditMode] = useState(false);
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
const [formData, setFormData] = useState(person);
|
const [formData, setFormData] = useState(person);
|
||||||
@@ -75,7 +77,7 @@ export default function PersonItem({ person }: IProps) {
|
|||||||
<div className="absolute top-2 left-2 group-hover:block hidden">
|
<div className="absolute top-2 left-2 group-hover:block hidden">
|
||||||
<Link
|
<Link
|
||||||
className="bg-green-300 block rounded-lg px-2 py-1 text-sm"
|
className="bg-green-300 block rounded-lg px-2 py-1 text-sm"
|
||||||
href={`${ENV.IMMICH_URL}/people/${person.id}`}
|
href={`${immichURL}/people/${person.id}`}
|
||||||
target="_blank"
|
target="_blank"
|
||||||
>
|
>
|
||||||
<ArrowUpRight size={16} />
|
<ArrowUpRight size={16} />
|
||||||
|
|||||||
@@ -11,12 +11,14 @@ import { useTheme } from "next-themes";
|
|||||||
|
|
||||||
import dynamic from "next/dynamic";
|
import dynamic from "next/dynamic";
|
||||||
import Image from "next/image";
|
import Image from "next/image";
|
||||||
|
import { useConfig } from "@/contexts/ConfigContext";
|
||||||
|
|
||||||
const ThemeSwitcher = dynamic(() => import("@/components/shared/ThemeSwitcher"), {
|
const ThemeSwitcher = dynamic(() => import("@/components/shared/ThemeSwitcher"), {
|
||||||
ssr: false,
|
ssr: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
export default function Sidebar() {
|
export default function Sidebar() {
|
||||||
|
const { immichURL } = useConfig();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const { pathname } = router;
|
const { pathname } = router;
|
||||||
|
|
||||||
@@ -58,8 +60,8 @@ export default function Sidebar() {
|
|||||||
<div>
|
<div>
|
||||||
<div className="flex flex-col gap-1 text-xs text-center py-2">
|
<div className="flex flex-col gap-1 text-xs text-center py-2">
|
||||||
<p className="text-muted-foreground font-mono">Connected to</p>
|
<p className="text-muted-foreground font-mono">Connected to</p>
|
||||||
<Link href={ENV.IMMICH_URL} target="_blank" className="font-mono">
|
<Link href={immichURL} target="_blank" className="font-mono">
|
||||||
{ENV.IMMICH_URL}
|
{immichURL}
|
||||||
</Link>
|
</Link>
|
||||||
</div>
|
</div>
|
||||||
<div className="border text-muted-foreground text-xs text-center py-2">
|
<div className="border text-muted-foreground text-xs text-center py-2">
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
export const ENV = {
|
export const ENV = {
|
||||||
IMMICH_URL: process.env.NEXT_PUBLIC_IMMICH_URL as string,
|
IMMICH_URL: process.env.IMMICH_URL as string,
|
||||||
IMMICH_API_KEY: process.env.IMMICH_API_KEY as string,
|
IMMICH_API_KEY: process.env.IMMICH_API_KEY as string,
|
||||||
DATABASE_URL: process.env.DATABASE_URL as string,
|
DATABASE_URL: process.env.DATABASE_URL as string,
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
import { createContext, useContext } from "react";
|
||||||
|
|
||||||
|
interface ConfigContextType {
|
||||||
|
immichURL: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
const ConfigContext = createContext<ConfigContextType>({
|
||||||
|
immichURL: "",
|
||||||
|
});
|
||||||
|
|
||||||
|
export default ConfigContext;
|
||||||
|
|
||||||
|
export const useConfig = () => {
|
||||||
|
const context = useContext(ConfigContext) as ConfigContextType;
|
||||||
|
return context;
|
||||||
|
}
|
||||||
+29
-4
@@ -1,9 +1,34 @@
|
|||||||
import RootLayout from "@/components/layouts/RootLayout";
|
import RootLayout from "@/components/layouts/RootLayout";
|
||||||
import "@/styles/globals.scss";
|
import "@/styles/globals.scss";
|
||||||
import type { AppProps } from "next/app";
|
import type { AppProps } from "next/app";
|
||||||
import { ThemeProvider } from 'next-themes'
|
import { ThemeProvider } from "next-themes";
|
||||||
|
import { ENV } from "@/config/environment";
|
||||||
|
import ConfigContext from "@/contexts/ConfigContext";
|
||||||
|
|
||||||
|
interface AppPropsWithProps extends AppProps {
|
||||||
export default function App({ Component, pageProps }: AppProps) {
|
props: {
|
||||||
return <ThemeProvider attribute="class" storageKey = 'theme'><RootLayout><Component {...pageProps} /></RootLayout></ThemeProvider>
|
immichURL: string;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
const App = ({ Component, pageProps, ...props }: AppPropsWithProps) => {
|
||||||
|
console.log("App -> pageProps", props);
|
||||||
|
return (
|
||||||
|
<ConfigContext.Provider value={props.props}>
|
||||||
|
<ThemeProvider attribute="class" storageKey="theme">
|
||||||
|
<RootLayout>
|
||||||
|
<Component {...pageProps} />
|
||||||
|
</RootLayout>
|
||||||
|
</ThemeProvider>
|
||||||
|
</ConfigContext.Provider>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
App.getInitialProps = async () => {
|
||||||
|
return {
|
||||||
|
props: {
|
||||||
|
immichURL: ENV.IMMICH_URL,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
export default App;
|
||||||
Reference in new issue
Block a user