|
|
|
@@ -27,7 +27,17 @@ import Search from "@mui/icons-material/Search"; |
|
|
|
import PageTitleBar from "@/components/PageTitleBar"; |
|
|
|
import { NEXT_PUBLIC_API_URL } from "@/config/api"; |
|
|
|
import { clientAuthFetch } from "@/app/utils/clientAuthFetch"; |
|
|
|
import { arrayToDateTimeString } from "@/app/utils/formatUtil"; |
|
|
|
import dayjs from "dayjs"; |
|
|
|
|
|
|
|
function formatApiDateTime(value: unknown): string { |
|
|
|
if (value == null) return "—"; |
|
|
|
if (Array.isArray(value)) { |
|
|
|
return arrayToDateTimeString(value as (number | undefined)[]); |
|
|
|
} |
|
|
|
const d = dayjs(value as string | number); |
|
|
|
return d.isValid() ? d.format("YYYY-MM-DD HH:mm:ss") : "—"; |
|
|
|
} |
|
|
|
import PrinterMonitorTab from "@/components/ClientMonitor/PrinterMonitorTab"; |
|
|
|
|
|
|
|
type ClientRow = { |
|
|
|
@@ -383,17 +393,17 @@ export default function ClientMonitorPage() { |
|
|
|
</TableCell> |
|
|
|
<TableCell> |
|
|
|
{formatAgo(row.secondsSinceHeartbeat)} |
|
|
|
{row.lastHeartbeat && ( |
|
|
|
<Typography variant="caption" display="block" color="text.secondary"> |
|
|
|
{dayjs(row.lastHeartbeat).format("HH:mm:ss")} |
|
|
|
</Typography> |
|
|
|
)} |
|
|
|
</TableCell> |
|
|
|
<TableCell> |
|
|
|
{row.lastActivity |
|
|
|
? dayjs(row.lastActivity).format("HH:mm:ss") |
|
|
|
: "—"} |
|
|
|
{row.lastHeartbeat && ( |
|
|
|
<Typography variant="caption" display="block" color="text.secondary"> |
|
|
|
{formatApiDateTime(row.lastHeartbeat).slice(11)} |
|
|
|
</Typography> |
|
|
|
)} |
|
|
|
</TableCell> |
|
|
|
<TableCell> |
|
|
|
{row.lastActivity |
|
|
|
? formatApiDateTime(row.lastActivity).slice(11) |
|
|
|
: "—"} |
|
|
|
</TableCell> |
|
|
|
</TableRow> |
|
|
|
); |
|
|
|
}) |
|
|
|
@@ -528,11 +538,7 @@ export default function ClientMonitorPage() { |
|
|
|
const st = STATUS_LABEL[row.status] ?? STATUS_LABEL.offline; |
|
|
|
return ( |
|
|
|
<TableRow key={`${row.id ?? row.recordedAt}-${row.deviceId}`} hover> |
|
|
|
<TableCell> |
|
|
|
{row.recordedAt |
|
|
|
? dayjs(row.recordedAt).format("YYYY-MM-DD HH:mm:ss") |
|
|
|
: "—"} |
|
|
|
</TableCell> |
|
|
|
<TableCell>{formatApiDateTime(row.recordedAt)}</TableCell> |
|
|
|
<TableCell> |
|
|
|
<Chip size="small" color={st.color} label={st.label} /> |
|
|
|
</TableCell> |
|
|
|
|