Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/src/packages/next/components/statistics/active-users.tsx
Views: 687
/*1* This file is part of CoCalc: Copyright © 2021 Sagemath, Inc.2* License: MS-RSL – see LICENSE.md for details3*/45import { Table } from "antd";67import { HistoricCounts } from "@cocalc/util/db-schema/stats";8import { Paragraph, Title } from "components/misc";9import { ZEROS } from "./misc";1011interface Props {12active: HistoricCounts;13created: HistoricCounts;14hubServers: { host: string; clients: number }[];15style?: React.CSSProperties;16}1718const columns = [19{ title: "Accounts", dataIndex: "type", key: "type" },20{ title: "Hour", dataIndex: "1h", key: "1h" },21{ title: "Day", dataIndex: "1d", key: "1d" },22{ title: "Week", dataIndex: "7d", key: "7d" },23{ title: "Month", dataIndex: "30d", key: "30d" },24];2526function connectedUsers(hubServers): number {27if (hubServers == null || hubServers.length === 0) {28return 0;29} else {30return hubServers.map((x) => x.clients).reduce((s, t) => s + t);31}32}3334export default function ActiveUsers({35created,36active,37hubServers,38style,39}: Props) {40const rows = [41{ type: "In use", ...ZEROS, ...active },42{ type: "Created", ...ZEROS, ...created },43];44return (45<div style={style}>46<Title level={2}>Connected Users: {connectedUsers(hubServers)}</Title>47<Paragraph>48There are {connectedUsers(hubServers)} users connected right now; of49these {active["5min"]} actively edited a file in the last 5 minutes.50Track the number of users that were recently active or created new51accounts below.52</Paragraph>5354<Table55dataSource={rows}56columns={columns}57bordered58pagination={false}59rowKey={"type"}60/>61</div>62);63}646566