-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
103 additions
and
10 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
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 |
---|---|---|
@@ -1,17 +1,76 @@ | ||
import { type RemoteGameProcess, type RemoteGameStatus, useGameProcList } from "@/renderer/lib/remote-game"; | ||
import { GameTypeImage } from "@components/GameTypeImage"; | ||
import { Button, Card, CardBody, Chip } from "@heroui/react"; | ||
import { Monitor } from "@pages/monitor/Monitor"; | ||
import { useParams } from "wouter"; | ||
import { ArrowRightIcon } from "lucide-react"; | ||
import { useTranslation } from "react-i18next"; | ||
import { useLocation, useParams } from "wouter"; | ||
|
||
export function MonitorView() { | ||
const { procId } = useParams<{ procId: string }>(); | ||
return <Monitor procId={procId} key={procId}/>; | ||
} | ||
|
||
if (procId) { | ||
return <Monitor procId={procId} key={procId}/>; | ||
} | ||
export function MonitorListView() { | ||
const procs = useGameProcList(); | ||
|
||
return <MonitorList/>; | ||
return <div className="w-full h-full overflow-y-auto"> | ||
<div className="grid grid-cols-2 gap-4 w-full"> | ||
{ | ||
procs.map(p => <MonitorItem proc={p} key={p.id}/>) | ||
} | ||
</div> | ||
</div>; | ||
} | ||
|
||
function MonitorList() { | ||
// TODO add game processes | ||
return <div className="w-full"></div>; | ||
const statusColors = { | ||
running: "success", | ||
crashed: "danger", | ||
exited: "default" | ||
} as const; | ||
|
||
function StatusChip({ status }: { status: RemoteGameStatus }) { | ||
const { t } = useTranslation("pages", { keyPrefix: "monitor.status" }); | ||
|
||
return <Chip | ||
variant="dot" | ||
color={statusColors[status]} | ||
> | ||
{t(status)} | ||
</Chip>; | ||
} | ||
|
||
function MonitorItem({ proc }: { proc: RemoteGameProcess }) { | ||
const { detail: { modLoader, stable, name, versionId }, status } = proc; | ||
const [, nav] = useLocation(); | ||
|
||
function revealProc() { | ||
nav(`/monitor/${proc.id}`); | ||
} | ||
|
||
return <Card> | ||
<CardBody> | ||
<div className="flex gap-4 items-center h-16 px-3"> | ||
<div className="h-full p-3 bg-content2 rounded-full"> | ||
<GameTypeImage loader={modLoader} stable={stable}/> | ||
</div> | ||
|
||
<div className="flex flex-col gap-1"> | ||
<div className="font-bold text-xl">{name}</div> | ||
<div className="text-foreground-400">{versionId}</div> | ||
</div> | ||
|
||
<div className="ml-auto flex gap-2 items-center"> | ||
<StatusChip status={status}/> | ||
</div> | ||
|
||
|
||
<div className="ml-4"> | ||
<Button isIconOnly color="primary" onPress={revealProc}> | ||
<ArrowRightIcon/> | ||
</Button> | ||
</div> | ||
</div> | ||
</CardBody> | ||
</Card>; | ||
} |