-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(client): admin page to view all running dynamics
- Loading branch information
Ivo
committed
Apr 24, 2023
1 parent
62c9124
commit eeddab9
Showing
22 changed files
with
278 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"title": "Running Dynamics", | ||
"dynamic": { | ||
"path": "Folder on storage", | ||
"started-at": "Started at" | ||
}, | ||
"worker-empty": "There are no tasks running on this worker" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
apps/client/src/components/AdminRunningDynamicsList/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import { Server } from "lucide-react"; | ||
import { useRouter } from "next/router"; | ||
import { useTranslation } from "next-i18next"; | ||
|
||
import { GetAdminRunningDynamicsListResult } from "@app/queries/useAdminRunningDynamicsList"; | ||
|
||
interface AdminRunningDynamicsListProps { | ||
runningDynamics: GetAdminRunningDynamicsListResult; | ||
} | ||
|
||
export function AdminRunningDynamicsList({ | ||
runningDynamics | ||
}: AdminRunningDynamicsListProps) { | ||
const router = useRouter(); | ||
const { t } = useTranslation(["admin-running"]); | ||
|
||
return ( | ||
<div> | ||
{Object.keys(runningDynamics).map((worker) => { | ||
const dynamics = runningDynamics[worker]; | ||
|
||
return ( | ||
<div | ||
className="flex flex-col gap-2" | ||
key={worker} | ||
> | ||
<div className="flex items-center gap-x-2"> | ||
<Server className="h-4 w-4 stroke-gray-500" /> | ||
<p className="text-gray-500">{worker}</p> | ||
</div> | ||
{dynamics && dynamics.length > 0 ? ( | ||
<div className="flex flex-col gap-y-1 rounded-lg p-4 odd:bg-zinc-500/20 even:bg-zinc-500/10"> | ||
{dynamics.map((dynamic) => ( | ||
<div key={`${worker}_${dynamic.id}`}> | ||
<div className="flex gap-x-1"> | ||
<p>{t("admin-running:dynamic.path")}:</p> | ||
<p className="font-semibold">{dynamic.args[0]}</p> | ||
</div> | ||
<div className="flex gap-x-1"> | ||
<p>{t("admin-running:dynamic.started-at")}:</p> | ||
<p className="font-semibold"> | ||
{Intl.DateTimeFormat(router.locale, { | ||
day: "2-digit", | ||
month: "long", | ||
year: "numeric", | ||
hour: "2-digit", | ||
minute: "2-digit", | ||
second: "2-digit" | ||
}).format(new Date(dynamic.time_start * 1000))} | ||
</p> | ||
</div> | ||
</div> | ||
))} | ||
</div> | ||
) : ( | ||
<p>{t("admin-running:worker-empty")}</p> | ||
)} | ||
</div> | ||
); | ||
})} | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { Spinner } from "@app/components/Spinner"; | ||
|
||
export function FullPageLoader() { | ||
return ( | ||
<div className="flex flex-1 items-center justify-center"> | ||
<Spinner /> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import dynamic from "next/dynamic"; | ||
import { useTranslation } from "next-i18next"; | ||
|
||
import { FullPageLoader } from "@app/components/FullPageLoader"; | ||
import { SEO } from "@app/components/SEO"; | ||
import { Spinner } from "@app/components/Spinner"; | ||
import { withSSRAdmin } from "@app/hocs/withSSRAdmin"; | ||
import { withSSRTranslations } from "@app/hocs/withSSRTranslations"; | ||
import { useAdminRunningDynamicsList } from "@app/queries/useAdminRunningDynamicsList"; | ||
|
||
const AdminRunningDynamicsList = dynamic( | ||
() => | ||
import("@app/components/AdminRunningDynamicsList").then( | ||
(mod) => mod.AdminRunningDynamicsList | ||
), | ||
{ | ||
loading: () => <FullPageLoader />, | ||
ssr: false | ||
} | ||
); | ||
|
||
export const getServerSideProps = withSSRTranslations(withSSRAdmin(), { | ||
namespaces: ["admin-running"] | ||
}); | ||
|
||
export default function AdminSignup() { | ||
const { data, isRefetching, isLoading } = useAdminRunningDynamicsList(); | ||
const { t } = useTranslation(); | ||
|
||
return ( | ||
<> | ||
<SEO | ||
title={t("admin-running:title")} | ||
description={t("admin-running:description")} | ||
/> | ||
<h2 className="text-center text-2xl font-bold uppercase text-primary-700 dark:text-primary-400"> | ||
{t("admin-running:title")} | ||
</h2> | ||
|
||
{isLoading || isRefetching || !data ? ( | ||
<div className="flex flex-1 items-center justify-center"> | ||
<Spinner /> | ||
</div> | ||
) : ( | ||
<AdminRunningDynamicsList runningDynamics={data} /> | ||
)} | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.