diff --git a/.env.sample b/.env.sample index 9789cbd..2570615 100644 --- a/.env.sample +++ b/.env.sample @@ -1,3 +1,3 @@ -NEXT_PUBLIC_IMMICH_URL="" +IMMICH_URL="" IMMICH_API_KEY="" DATABASE_URL="" \ No newline at end of file diff --git a/.github/workflows/docker-release.yml b/.github/workflows/docker-release.yml index 999e9d3..6ecbfd7 100644 --- a/.github/workflows/docker-release.yml +++ b/.github/workflows/docker-release.yml @@ -42,7 +42,4 @@ jobs: docker build --build-arg VERSION=${{ env.VERSION }} \ --push -t varunraj/immich-power-tools:${{ env.VERSION }} \ -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" \ No newline at end of file + \ No newline at end of file diff --git a/README.md b/README.md index 6fad2ac..a9025ac 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ docker compose up -d Copy paste the `.env.example` to `.env` and fill in the values. ```bash -NEXT_PUBLIC_IMMICH_URL="" # Immich API URL +IMMICH_URL="" # Immich API URL IMMICH_API_KEY="" # Immich API Key DATABASE_URL="" # Postgress Database URL ``` diff --git a/src/components/people/PeopleList.tsx b/src/components/people/PeopleList.tsx index 3aaec78..582bd8f 100644 --- a/src/components/people/PeopleList.tsx +++ b/src/components/people/PeopleList.tsx @@ -12,41 +12,6 @@ import PersonHideCell from "./PersonHideCell"; import { PeoplePagination } from "./PeoplePagination"; import { useRouter } from "next/router"; -const columns: ColumnDef[] = [ - { - header: "Name", - accessorKey: "name", - cell: ({ row }) => , - }, - { - header: "Birth Date", - accessorKey: "birthDate", - cell: ({ row }) => , - }, - { - header: "Hidden", - accessorKey: "isHidden", - cell: ({ row }) => ( - - ), - }, - { - header: "Link", - accessorKey: "id", - cell: ({ row }) => ( - - View - - ) - }, - { - header: "Updated At", - accessorKey: "updatedAt", - cell: ({ row }) => {new Date( - row.original.updatedAt - ).toDateString()}, - }, -]; export default function PeopleList() { const router = useRouter() diff --git a/src/components/people/PersonItem.tsx b/src/components/people/PersonItem.tsx index 96ea824..665d92f 100644 --- a/src/components/people/PersonItem.tsx +++ b/src/components/people/PersonItem.tsx @@ -9,11 +9,13 @@ import clsx from "clsx"; import Link from "next/link"; import { ENV } from "@/config/environment"; import { ArrowUpRight } from "lucide-react"; +import { useConfig } from "@/contexts/ConfigContext"; interface IProps { person: IPerson; } export default function PersonItem({ person }: IProps) { + const { immichURL } = useConfig(); const [editMode, setEditMode] = useState(false); const [loading, setLoading] = useState(false); const [formData, setFormData] = useState(person); @@ -75,7 +77,7 @@ export default function PersonItem({ person }: IProps) {
diff --git a/src/components/shared/Sidebar.tsx b/src/components/shared/Sidebar.tsx index aa63e6d..9e4c61c 100644 --- a/src/components/shared/Sidebar.tsx +++ b/src/components/shared/Sidebar.tsx @@ -11,12 +11,14 @@ import { useTheme } from "next-themes"; import dynamic from "next/dynamic"; import Image from "next/image"; +import { useConfig } from "@/contexts/ConfigContext"; const ThemeSwitcher = dynamic(() => import("@/components/shared/ThemeSwitcher"), { ssr: false, }); export default function Sidebar() { + const { immichURL } = useConfig(); const router = useRouter(); const { pathname } = router; @@ -58,8 +60,8 @@ export default function Sidebar() {

Connected to

- - {ENV.IMMICH_URL} + + {immichURL}
diff --git a/src/config/environment.ts b/src/config/environment.ts index ff98582..c956313 100644 --- a/src/config/environment.ts +++ b/src/config/environment.ts @@ -1,5 +1,5 @@ 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, DATABASE_URL: process.env.DATABASE_URL as string, } \ No newline at end of file diff --git a/src/contexts/ConfigContext.tsx b/src/contexts/ConfigContext.tsx new file mode 100644 index 0000000..53de163 --- /dev/null +++ b/src/contexts/ConfigContext.tsx @@ -0,0 +1,16 @@ +import { createContext, useContext } from "react"; + +interface ConfigContextType { + immichURL: string; +} + +const ConfigContext = createContext({ + immichURL: "", +}); + +export default ConfigContext; + +export const useConfig = () => { + const context = useContext(ConfigContext) as ConfigContextType; + return context; +} \ No newline at end of file diff --git a/src/pages/_app.tsx b/src/pages/_app.tsx index 031cca7..3582f7c 100644 --- a/src/pages/_app.tsx +++ b/src/pages/_app.tsx @@ -1,9 +1,34 @@ import RootLayout from "@/components/layouts/RootLayout"; import "@/styles/globals.scss"; 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"; - -export default function App({ Component, pageProps }: AppProps) { - return +interface AppPropsWithProps extends AppProps { + props: { + immichURL: string; + }; } +const App = ({ Component, pageProps, ...props }: AppPropsWithProps) => { + console.log("App -> pageProps", props); + return ( + + + + + + + + ); +}; + +App.getInitialProps = async () => { + return { + props: { + immichURL: ENV.IMMICH_URL, + }, + }; +}; + +export default App;