Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemathinc
GitHub Repository: sagemathinc/cocalc
Path: blob/master/src/packages/next/components/statistics/active-users.tsx
5787 views
1
/*
2
* This file is part of CoCalc: Copyright © 2021 Sagemath, Inc.
3
* License: MS-RSL – see LICENSE.md for details
4
*/
5
6
import { Table } from "antd";
7
import { HistoricCounts } from "@cocalc/util/db-schema/stats";
8
import { Paragraph, Title } from "components/misc";
9
import { ZEROS } from "./misc";
10
import { PROJECTS_HEADING_WIDTH } from "./active-projects";
11
12
interface Props {
13
active: HistoricCounts;
14
created: HistoricCounts;
15
hubServers: { host: string; clients: number }[];
16
style?: React.CSSProperties;
17
}
18
19
const columns = [
20
{
21
title: "Accounts",
22
dataIndex: "type",
23
key: "type",
24
width: PROJECTS_HEADING_WIDTH,
25
},
26
{ title: "Hour", dataIndex: "1h", key: "1h" },
27
{ title: "Day", dataIndex: "1d", key: "1d" },
28
{ title: "Week", dataIndex: "7d", key: "7d" },
29
{ title: "Month", dataIndex: "30d", key: "30d" },
30
];
31
32
// Data collection got not implemented right now, so disabling "connection" and replacing by
33
// active during the last hour, which is probably more meaningful, since people can just
34
// leave browsers connected.
35
36
// function connectedUsers(hubServers): number {
37
// if (hubServers == null || hubServers.length === 0) {
38
// return 0;
39
// } else {
40
// return hubServers.map((x) => x.clients).reduce((s, t) => s + t);
41
// }
42
// }
43
44
export default function ActiveUsers({ created, active, style }: Props) {
45
const rows = [
46
{ type: "In use", ...ZEROS, ...active },
47
{ type: "Created", ...ZEROS, ...created },
48
];
49
return (
50
<div style={style}>
51
<Title level={2}>Active Users: {active["1h"]}</Title>
52
<Paragraph>
53
Track the number of users that were recently active or created new
54
accounts below. There were {active["5min"]} users who edited a file
55
during the last 5 minutes.
56
</Paragraph>
57
58
<Table
59
dataSource={rows}
60
columns={columns}
61
bordered
62
pagination={false}
63
rowKey={"type"}
64
/>
65
</div>
66
);
67
}
68
69