95 lines
1.8 KiB
JavaScript
95 lines
1.8 KiB
JavaScript
import { Space, Table } from "antd";
|
|
import { FormatDatetime, WebSocketContext } from "../../utils";
|
|
import { useContext } from "react";
|
|
import { Link } from "react-router-dom";
|
|
|
|
const columns = [
|
|
{
|
|
title: "Name",
|
|
dataIndex: "name",
|
|
key: "name",
|
|
},
|
|
{
|
|
title: "Used by",
|
|
dataIndex: "usedBy",
|
|
key: "usedBy",
|
|
},
|
|
{
|
|
title: "Last used",
|
|
dataIndex: "lastUsed",
|
|
key: "lastUsed",
|
|
},
|
|
{
|
|
title: "Registered at",
|
|
dataIndex: "registeredAt",
|
|
key: "registeredAt",
|
|
},
|
|
{
|
|
title: "User-Agent",
|
|
dataIndex: "userAgent",
|
|
key: "userAgent",
|
|
},
|
|
{
|
|
title: "Action",
|
|
dataIndex: "action",
|
|
key: "action",
|
|
render: (_, record) => (
|
|
<Space size="middle">
|
|
<Link to="#">Use scanner</Link>
|
|
</Space>
|
|
),
|
|
},
|
|
];
|
|
|
|
export default function Scanners() {
|
|
const webSocketContext = useContext(WebSocketContext);
|
|
|
|
const getTableItems = () => {
|
|
if (webSocketContext.Scanners === null) return [];
|
|
|
|
let items = [];
|
|
|
|
webSocketContext.Scanners.forEach((scanner) => {
|
|
items.push({
|
|
key: scanner.Id,
|
|
name: scanner.Name,
|
|
usedBy: scanner.UsedByUserId,
|
|
lastUsed: scanner.LastUsed,
|
|
registeredAt: FormatDatetime(scanner.RegisteredAt),
|
|
userAgent: scanner.UserAgent,
|
|
});
|
|
});
|
|
|
|
return items;
|
|
};
|
|
|
|
return (
|
|
<>
|
|
<h1 style={{ fontWeight: "bold", float: "left" }}>
|
|
Scanners (
|
|
{webSocketContext.Scanners === null
|
|
? "0"
|
|
: webSocketContext.Scanners.length}
|
|
)
|
|
</h1>
|
|
|
|
<Table columns={columns} dataSource={getTableItems()} />
|
|
</>
|
|
);
|
|
}
|
|
|
|
/*
|
|
<Popover
|
|
title="Scan this on mobile"
|
|
content={<QRCode value={"test"} bordered={false} />}
|
|
>
|
|
<Button
|
|
style={{ float: "right" }}
|
|
type="primary"
|
|
icon={<PlusOutlined />}
|
|
>
|
|
Add scanner
|
|
</Button>
|
|
</Popover>
|
|
*/
|