diff --git a/api/src/main/java/telegram/files/HttpVerticle.java b/api/src/main/java/telegram/files/HttpVerticle.java index 7ac62d3..fbca5f2 100644 --- a/api/src/main/java/telegram/files/HttpVerticle.java +++ b/api/src/main/java/telegram/files/HttpVerticle.java @@ -111,8 +111,9 @@ public class HttpVerticle extends AbstractVerticle { HealthChecks hc = HealthChecks.create(vertx); hc.register("http-server", Promise::complete); - router.get("/health").handler(HealthCheckHandler.createWithHealthChecks(hc)); router.get("/").handler(ctx -> ctx.response().end("Hello World!")); + router.get("/health").handler(HealthCheckHandler.createWithHealthChecks(hc)); + router.get("/version").handler(ctx -> ctx.json(new JsonObject().put("version", Start.VERSION))); router.route("/ws").handler(this::handleWebSocket); router.get("/settings").handler(this::handleSettings); diff --git a/web/src/components/about.tsx b/web/src/components/about.tsx new file mode 100644 index 0000000..f04ee99 --- /dev/null +++ b/web/src/components/about.tsx @@ -0,0 +1,119 @@ +import React from "react"; +import useSWR from "swr"; +import { Github, RefreshCw } from "lucide-react"; +import { + Card, + CardContent, + CardDescription, + CardHeader, + CardTitle, +} from "@/components/ui/card"; +import { request } from "@/lib/api"; +import Link from "next/link"; + +interface VersionData { + version: string; +} + +interface GitHubReleaseData { + tag_name: string; +} + +const fetcher = (url: string) => fetch(url).then((res) => res.json()); + +export default function About() { + const { data: apiData, error: apiError } = useSWR( + "/version", + request, + ); + const { data: githubData, error: githubError } = useSWR< + GitHubReleaseData, + Error + >( + "https://api.github.com/repos/jarvis2f/telegram-files/releases/latest", + fetcher, + ); + + const projectInfo = { + repository: "https://github.com/jarvis2f/telegram-files", + author: "Jarvis2f", + }; + + const currentVersion = apiData?.version ?? "Unknown"; + const isNewVersionAvailable = + githubData && githubData.tag_name !== currentVersion; + + return ( +
+ + + About This Project + + A simple telegram file downloader. + + + +
+
+

Author

+

{projectInfo.author}

+
+ +
+

+ Current Version +

+ {apiError ? ( +

Failed to load current version

+ ) : !apiData ? ( +
+ + Loading... +
+ ) : ( +

{currentVersion}

+ )} +
+ +
+

+ Latest Version +

+ {githubError ? ( +

Failed to load release data

+ ) : !githubData ? ( +
+ + Loading... +
+ ) : ( +

+ {githubData.tag_name} +

+ )} +
+ + {isNewVersionAvailable && ( +
+

+ A new version ({githubData?.tag_name}) is available! Update + now. +

+
+ )} + +
+ + + +
+
+
+
+
+ ); +} diff --git a/web/src/components/settings-dialog.tsx b/web/src/components/settings-dialog.tsx index 4e80918..75bc5ed 100644 --- a/web/src/components/settings-dialog.tsx +++ b/web/src/components/settings-dialog.tsx @@ -13,6 +13,7 @@ import FileStatistics from "@/components/file-statistics"; import { useTelegramAccount } from "@/hooks/use-telegram-account"; import Proxys from "@/components/proxys"; import SettingsForm from "@/components/settings-form"; +import About from "@/components/about"; export const SettingsDialog: React.FC = () => { const [isOpen, setIsOpen] = useState(false); @@ -46,11 +47,12 @@ export const SettingsDialog: React.FC = () => { General Statistics Proxys + About - +
{accountId ? ( @@ -63,7 +65,7 @@ export const SettingsDialog: React.FC = () => { )}
- +
{ />
+ + +