|
|
|
@ -1,18 +1,20 @@ |
|
|
|
|
|
|
|
/* eslint-disable react/prop-types */ |
|
|
|
import React, { useState, useEffect, useContext } from 'react'; |
|
|
|
import React, { useState, useEffect, useContext } from 'react'; |
|
|
|
import { timeFormat } from "d3-time-format"; |
|
|
|
import { timeFormat } from "d3-time-format"; |
|
|
|
import { Table, Row } from "antd"; |
|
|
|
import { Table, Row } from "antd"; |
|
|
|
import { formatDistanceToNow } from "date-fns"; |
|
|
|
import { formatDistanceToNow } from "date-fns"; |
|
|
|
import { UserOutlined} from "@ant-design/icons"; |
|
|
|
import { UserOutlined} from "@ant-design/icons"; |
|
|
|
|
|
|
|
import { SortOrder } from "antd/lib/table/interface"; |
|
|
|
import Chart from "./components/chart"; |
|
|
|
import Chart from "./components/chart"; |
|
|
|
import StatisticItem from "./components/statistic"; |
|
|
|
import StatisticItem from "./components/statistic"; |
|
|
|
|
|
|
|
|
|
|
|
import { BroadcastStatusContext } from './utils/broadcast-status-context'; |
|
|
|
import { BroadcastStatusContext } from '../utils/broadcast-status-context'; |
|
|
|
|
|
|
|
|
|
|
|
import { |
|
|
|
import { |
|
|
|
CONNECTED_CLIENTS, |
|
|
|
CONNECTED_CLIENTS, |
|
|
|
STREAM_STATUS, VIEWERS_OVER_TIME, |
|
|
|
STREAM_STATUS, VIEWERS_OVER_TIME, |
|
|
|
fetchData, |
|
|
|
fetchData, |
|
|
|
} from "./utils/apis"; |
|
|
|
} from "../utils/apis"; |
|
|
|
|
|
|
|
|
|
|
|
const FETCH_INTERVAL = 5 * 60 * 1000; // 5 mins
|
|
|
|
const FETCH_INTERVAL = 5 * 60 * 1000; // 5 mins
|
|
|
|
|
|
|
|
|
|
|
|
@ -78,14 +80,14 @@ export default function ViewersOverTime() { |
|
|
|
key: "username", |
|
|
|
key: "username", |
|
|
|
render: (username) => username || "-", |
|
|
|
render: (username) => username || "-", |
|
|
|
sorter: (a, b) => a.username - b.username, |
|
|
|
sorter: (a, b) => a.username - b.username, |
|
|
|
sortDirections: ["descend", "ascend"], |
|
|
|
sortDirections: ["descend", "ascend"] as SortOrder[], |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
{ |
|
|
|
title: "Messages sent", |
|
|
|
title: "Messages sent", |
|
|
|
dataIndex: "messageCount", |
|
|
|
dataIndex: "messageCount", |
|
|
|
key: "messageCount", |
|
|
|
key: "messageCount", |
|
|
|
sorter: (a, b) => a.messageCount - b.messageCount, |
|
|
|
sorter: (a, b) => a.messageCount - b.messageCount, |
|
|
|
sortDirections: ["descend", "ascend"], |
|
|
|
sortDirections: ["descend", "ascend"] as SortOrder[], |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
{ |
|
|
|
title: "Connected Time", |
|
|
|
title: "Connected Time", |
|
|
|
@ -106,34 +108,6 @@ export default function ViewersOverTime() { |
|
|
|
}, |
|
|
|
}, |
|
|
|
]; |
|
|
|
]; |
|
|
|
|
|
|
|
|
|
|
|
const timeFormatter = (tick) => { |
|
|
|
|
|
|
|
return timeFormat("%H:%M")(new Date(tick)); |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const CustomizedTooltip = (props) => { |
|
|
|
|
|
|
|
const { active, payload, label } = props; |
|
|
|
|
|
|
|
if (active) { |
|
|
|
|
|
|
|
const numViewers = payload && payload[0] && payload[0].value; |
|
|
|
|
|
|
|
const time = timeFormatter(label); |
|
|
|
|
|
|
|
const message = `${numViewers} viewer(s) at ${time}`; |
|
|
|
|
|
|
|
return ( |
|
|
|
|
|
|
|
<div className="custom-tooltip"> |
|
|
|
|
|
|
|
<p className="label">{message}</p> |
|
|
|
|
|
|
|
</div> |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return null; |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* |
|
|
|
|
|
|
|
geo data looks like this |
|
|
|
|
|
|
|
"geo": { |
|
|
|
|
|
|
|
"countryCode": "US", |
|
|
|
|
|
|
|
"regionName": "California", |
|
|
|
|
|
|
|
"timeZone": "America/Los_Angeles" |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
return ( |
|
|
|
<div> |
|
|
|
<div> |
|
|
|
<h2>Current Viewers</h2> |
|
|
|
<h2>Current Viewers</h2> |
|
|
|
|