Path: blob/master/src/packages/next/components/statistics/active-users.tsx
5787 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";9import { PROJECTS_HEADING_WIDTH } from "./active-projects";1011interface Props {12active: HistoricCounts;13created: HistoricCounts;14hubServers: { host: string; clients: number }[];15style?: React.CSSProperties;16}1718const columns = [19{20title: "Accounts",21dataIndex: "type",22key: "type",23width: PROJECTS_HEADING_WIDTH,24},25{ title: "Hour", dataIndex: "1h", key: "1h" },26{ title: "Day", dataIndex: "1d", key: "1d" },27{ title: "Week", dataIndex: "7d", key: "7d" },28{ title: "Month", dataIndex: "30d", key: "30d" },29];3031// Data collection got not implemented right now, so disabling "connection" and replacing by32// active during the last hour, which is probably more meaningful, since people can just33// leave browsers connected.3435// function connectedUsers(hubServers): number {36// if (hubServers == null || hubServers.length === 0) {37// return 0;38// } else {39// return hubServers.map((x) => x.clients).reduce((s, t) => s + t);40// }41// }4243export default function ActiveUsers({ created, active, style }: Props) {44const rows = [45{ type: "In use", ...ZEROS, ...active },46{ type: "Created", ...ZEROS, ...created },47];48return (49<div style={style}>50<Title level={2}>Active Users: {active["1h"]}</Title>51<Paragraph>52Track the number of users that were recently active or created new53accounts below. There were {active["5min"]} users who edited a file54during the last 5 minutes.55</Paragraph>5657<Table58dataSource={rows}59columns={columns}60bordered61pagination={false}62rowKey={"type"}63/>64</div>65);66}676869