Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 25 additions & 12 deletions app/logs/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ interface LogEntry {
keyId: string;
uid?: string | null;
granted: boolean;
accessType: "oidc" | "mobile" | "physical";
}

interface LogsResponse {
Expand Down Expand Up @@ -342,28 +343,40 @@ function LogsPageInner() {
<th style={{ width: "22%" }}>Door</th>
<th style={{ width: "22%" }}>Username</th>
<th style={{ width: "18%" }}>Name</th>
<th style={{ width: "15%" }}>Keys</th>
<th style={{ width: "10%" }}>Access</th>
<th style={{ width: "16%" }}>Access method</th>
<th style={{ width: "12%" }}>Access</th>
</tr>
</thead>
<tbody>
{logs.map((entry) => (
<tr key={entry._id}>
<td style={{ whiteSpace: "nowrap" }}>{formatTimestamp(entry.timestamp)}</td>
<td>
{entry.doorName ?? <span className="font-monospace text-muted">{entry.door}</span>}
{entry.doorName ?? <span>{entry.door}</span>}
</td>
<td>
{entry.username ?? <span className="text-muted">unknown</span>}
{entry.username ?? <span>unknown</span>}
</td>
<td>{entry.name ?? <span className="text-muted">-</span>}</td>
<td>{entry.name ?? <span>-</span>}</td>
<td>
{entry.uid === undefined ? (
<span>-</span>
) : entry.uid === null ? (
"Mobile Key"
{entry.accessType === "oidc" ? (
"Remote Access"
) : entry.accessType === "mobile" ? (
<div>
<div>Mobile Key</div>
<div style={{ fontSize: "0.70rem" }}>
({entry.keyId})
</div>
</div>
) : entry.accessType === "physical" ? (
<div>
<div>Physical Key</div>
<div style={{ fontSize: "0.70rem" }}>
({entry.keyId})
</div>
</div>
) : (
<span className="font-monospace small">{entry.uid}</span>
<span>-</span>
)}
</td>
<td>
Expand All @@ -383,7 +396,7 @@ function LogsPageInner() {
className="card-footer d-grid align-items-center"
style={{ gridTemplateColumns: "1fr auto 1fr" }}
>
<small className="text-muted">
<small>
Page {pageIndex + 1} &nbsp;
</small>
<div className="justify-self-center">
Expand All @@ -402,4 +415,4 @@ export default function LogsPage() {
<LogsPageInner />
</AuthGate>
);
}
}
4 changes: 2 additions & 2 deletions components/AuthGate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
import { Container, Spinner } from "react-bootstrap";
import { useSession, signIn } from "next-auth/react";
import { AUTH_PROVIDER_ID, REFRESH_TOKEN_ERROR } from "@/lib/constants";
import { useEffect } from "react";
import { useEffect, type ReactNode } from "react";

export default function AuthGate({ children }) {
export default function AuthGate({ children }: {children: ReactNode}) {
const { data: session, status } = useSession({
required: true,
onUnauthenticated() {
Expand Down