Path: blob/master/src/packages/next/components/statistics/active-users.tsx
1450 views
/*1* This file is part of CoCalc: Copyright © 2021 Sagemath, Inc.2* License: MS-RSL – see LICENSE.md for details3*/45import { Table } from "antd";6import { HistoricCounts } from "@cocalc/util/db-schema/stats";7import { Paragraph, Title } from "components/misc";8import { ZEROS } from "./misc";910interface Props {11active: HistoricCounts;12created: HistoricCounts;13hubServers: { host: string; clients: number }[];14style?: React.CSSProperties;15}1617const columns = [18{ title: "Accounts", dataIndex: "type", key: "type" },19{ title: "Hour", dataIndex: "1h", key: "1h" },20{ title: "Day", dataIndex: "1d", key: "1d" },21{ title: "Week", dataIndex: "7d", key: "7d" },22{ title: "Month", dataIndex: "30d", key: "30d" },23];2425// Data collection got not implemented right now, so disabling "connection" and replacing by26// active during the last hour, which is probably more meaningful, since people can just27// leave browsers connected.2829// function connectedUsers(hubServers): number {30// if (hubServers == null || hubServers.length === 0) {31// return 0;32// } else {33// return hubServers.map((x) => x.clients).reduce((s, t) => s + t);34// }35// }3637export default function ActiveUsers({ created, active, style }: Props) {38const rows = [39{ type: "In use", ...ZEROS, ...active },40{ type: "Created", ...ZEROS, ...created },41];42return (43<div style={style}>44<Title level={2}>Active Users: {active["1h"]}</Title>45<Paragraph>46Track the number of users that were recently active or created new47accounts below. There were {active["5min"]} users who edited a file48during the last 5 minutes.49</Paragraph>5051<Table52dataSource={rows}53columns={columns}54bordered55pagination={false}56rowKey={"type"}57/>58</div>59);60}616263