Layout updates to stream health stats and messages

This commit is contained in:
Gabe Kangas
2022-04-09 23:04:52 -07:00
parent 810e2e0aaa
commit 2621665f54
2 changed files with 47 additions and 20 deletions

View File

@@ -4,16 +4,19 @@ import Link from 'next/link';
import React, { useContext } from 'react'; import React, { useContext } from 'react';
import { ServerStatusContext } from '../utils/server-status-context'; import { ServerStatusContext } from '../utils/server-status-context';
export default function StreamHealthOverview() { interface StreamHealthOverviewProps {
showTroubleshootButton?: Boolean;
}
export default function StreamHealthOverview({
showTroubleshootButton,
}: StreamHealthOverviewProps) {
const serverStatusData = useContext(ServerStatusContext); const serverStatusData = useContext(ServerStatusContext);
const { health } = serverStatusData; const { health } = serverStatusData;
if (!health) { if (!health) {
return null; return null;
} }
const { healthy, healthPercentage, message, representation } = health; const { healthy, healthPercentage, message, representation } = health;
console.log(healthPercentage);
let color = '#3f8600'; let color = '#3f8600';
let icon: 'success' | 'info' | 'warning' | 'error' = 'info'; let icon: 'success' | 'info' | 'warning' | 'error' = 'info';
if (healthPercentage < 80) { if (healthPercentage < 80) {
@@ -26,7 +29,7 @@ export default function StreamHealthOverview() {
return ( return (
<div> <div>
<Row gutter={16}> <Row gutter={8}>
<Col span={12}> <Col span={12}>
<Statistic <Statistic
title="Healthy Stream" title="Healthy Stream"
@@ -44,7 +47,7 @@ export default function StreamHealthOverview() {
/> />
</Col> </Col>
</Row> </Row>
<Row style={{ display: representation < 100 ? 'grid' : 'none' }}> <Row style={{ display: representation < 100 && representation !== 0 ? 'grid' : 'none' }}>
<Typography.Text <Typography.Text
type="secondary" type="secondary"
style={{ textAlign: 'center', fontSize: '0.7em', opacity: '0.3' }} style={{ textAlign: 'center', fontSize: '0.7em', opacity: '0.3' }}
@@ -53,18 +56,23 @@ export default function StreamHealthOverview() {
unknown. unknown.
</Typography.Text> </Typography.Text>
</Row> </Row>
<Row gutter={16} style={{ display: message ? 'grid' : 'none', marginTop: '10px' }}> <Row
gutter={16}
style={{ width: '100%', display: message ? 'grid' : 'none', marginTop: '10px' }}
>
<Col span={24}> <Col span={24}>
<Alert <Alert
message={message} message={message}
type={icon} type={icon}
showIcon showIcon
action={ action={
showTroubleshootButton && (
<Link passHref href="/stream-health"> <Link passHref href="/stream-health">
<Button size="small" type="text" style={{ color: 'black' }}> <Button size="small" type="text" style={{ color: 'black' }}>
TROUBLESHOOT TROUBLESHOOT
</Button> </Button>
</Link> </Link>
)
} }
/> />
</Col> </Col>
@@ -72,3 +80,7 @@ export default function StreamHealthOverview() {
</div> </div>
); );
} }
StreamHealthOverview.defaultProps = {
showTroubleshootButton: true,
};

View File

@@ -1,10 +1,11 @@
/* eslint-disable react/no-unescaped-entities */ /* eslint-disable react/no-unescaped-entities */
// import { BulbOutlined, LaptopOutlined, SaveOutlined } from '@ant-design/icons'; // import { BulbOutlined, LaptopOutlined, SaveOutlined } from '@ant-design/icons';
import { Row, Col, Typography, Space, Statistic, Card, Alert } from 'antd'; import { Row, Col, Typography, Space, Statistic, Card, Alert, Spin } from 'antd';
import React, { ReactNode, useEffect, useState } from 'react'; import React, { ReactNode, useEffect, useState } from 'react';
import { ClockCircleOutlined, WarningOutlined, WifiOutlined } from '@ant-design/icons'; import { ClockCircleOutlined, WarningOutlined, WifiOutlined } from '@ant-design/icons';
import { fetchData, FETCH_INTERVAL, API_STREAM_HEALTH_METRICS } from '../utils/apis'; import { fetchData, FETCH_INTERVAL, API_STREAM_HEALTH_METRICS } from '../utils/apis';
import Chart from '../components/chart'; import Chart from '../components/chart';
import StreamHealthOverview from '../components/stream-health-overview';
interface TimedValue { interface TimedValue {
time: Date; time: Date;
@@ -90,10 +91,15 @@ export default function StreamHealth() {
const noData = ( const noData = (
<div> <div>
<Typography.Title>Stream Performance</Typography.Title> <Typography.Title>Stream Performance</Typography.Title>
<Typography.Paragraph> <Alert
type="info"
message="
Data has not yet been collected. Once a stream has begun and viewers are watching this page Data has not yet been collected. Once a stream has begun and viewers are watching this page
will be available. will be available."
</Typography.Paragraph> />
<Spin size="large">
<div style={{ marginTop: '50px', height: '100px' }} />
</Spin>
</div> </div>
); );
if (!errors?.length) { if (!errors?.length) {
@@ -259,6 +265,13 @@ export default function StreamHealth() {
insight into external players people may be using such as VLC, MPV, QuickTime, etc. insight into external players people may be using such as VLC, MPV, QuickTime, etc.
</Typography.Paragraph> </Typography.Paragraph>
<Space direction="vertical" size="middle"> <Space direction="vertical" size="middle">
<Row justify="space-around">
<Col style={{ width: '100%' }}>
<Card type="inner">
<StreamHealthOverview showTroubleshootButton={false} />
</Card>
</Col>
</Row>
<Row <Row
gutter={[16, 16]} gutter={[16, 16]}
justify="space-around" justify="space-around"
@@ -299,17 +312,19 @@ export default function StreamHealth() {
valueStyle={{ color: errorStatColor }} valueStyle={{ color: errorStatColor }}
prefix={<WarningOutlined style={{ marginRight: '5px' }} />} prefix={<WarningOutlined style={{ marginRight: '5px' }} />}
suffix="" suffix=""
/>{' '} />
</div> </div>
</Card> </Card>
</Col> </Col>
</Row> </Row>
<div style={{ textAlign: 'center', display: representation < 100 ? 'grid' : 'none' }}> <div style={{ textAlign: 'center', display: representation < 100 ? 'grid' : 'none' }}>
{representation !== 0 && (
<Typography.Paragraph style={{ opacity: '0.7', fontSize: '0.7em' }}> <Typography.Paragraph style={{ opacity: '0.7', fontSize: '0.7em' }}>
Provided playback metrics represent {representation}% of all known players. Specifics Provided playback metrics represent {representation}% of all known players. Specifics
around other players consuming this video stream are unknown. around other players consuming this video stream are unknown.
</Typography.Paragraph> </Typography.Paragraph>
)}
</div> </div>
<Card> <Card>