From 83de63b1e8c12b19b55bfc956c47cef271878d33 Mon Sep 17 00:00:00 2001 From: Gabe Kangas Date: Thu, 29 Oct 2020 10:16:13 -0700 Subject: [PATCH] Split up config sections into pages --- web/pages/components/key-value-table.tsx | 25 +++++ web/pages/components/main-layout.tsx | 48 +++++---- web/pages/storage.tsx | 85 +++++++++++++++ web/pages/update-server-config.tsx | 132 +---------------------- web/pages/video-config.tsx | 128 ++++++++++++++++++++++ 5 files changed, 268 insertions(+), 150 deletions(-) create mode 100644 web/pages/components/key-value-table.tsx create mode 100644 web/pages/storage.tsx create mode 100644 web/pages/video-config.tsx diff --git a/web/pages/components/key-value-table.tsx b/web/pages/components/key-value-table.tsx new file mode 100644 index 000000000..b9a45a7b6 --- /dev/null +++ b/web/pages/components/key-value-table.tsx @@ -0,0 +1,25 @@ +import { Table, Typography } from "antd"; + +const { Title } = Typography; + +export default function KeyValueTable({ title, data }) { + const columns = [ + { + title: "Name", + dataIndex: "name", + key: "name", + }, + { + title: "Value", + dataIndex: "value", + key: "value", + }, + ]; + + return ( +
+ {title} + + + ); +} diff --git a/web/pages/components/main-layout.tsx b/web/pages/components/main-layout.tsx index ab07d2982..9420e2971 100644 --- a/web/pages/components/main-layout.tsx +++ b/web/pages/components/main-layout.tsx @@ -46,14 +46,14 @@ export default function MainLayout(props) {

@@ -66,24 +66,38 @@ export default function MainLayout(props) { Home - } title="Stream Details"> + } + title="Stream Details" + > Viewers Hardware - { broadcastActive ? ( + {broadcastActive ? ( }> Disconnect Stream... - ) : null} + ) : null} - - } title="Utilities"> + + } + title="Utilities" + > Server Configuration + + Video Configuration + + + Storage + Change Stream Key @@ -94,19 +108,15 @@ export default function MainLayout(props) {
- - {statusMessage} - - - {statusIcon} - + {statusMessage} + {statusIcon}
- - {children} - - - + {children} + +
); diff --git a/web/pages/storage.tsx b/web/pages/storage.tsx new file mode 100644 index 000000000..8052d4477 --- /dev/null +++ b/web/pages/storage.tsx @@ -0,0 +1,85 @@ +import React, { useState, useEffect } from 'react'; +import { SERVER_CONFIG, fetchData, FETCH_INTERVAL } from './utils/apis'; +import KeyValueTable from './components/key-value-table'; + +function Storage({ config }) { + if (!config) { + return null; + } + + const data = [ + { + name: "Enabled", + value: config.s3.enabled.toString(), + }, + { + name: "Endpoint", + value: config.s3.endpoint, + }, + { + name: "Access Key", + value: config.s3.accessKey, + }, + { + name: "Secret", + value: config.s3.secret, + }, + { + name: "Bucket", + value: config.s3.bucket, + }, + { + name: "Region", + value: config.s3.region, + }, + ]; + return ; +} + +export default function ServerConfig() { + const [config, setConfig] = useState(); + + const getInfo = async () => { + try { + const result = await fetchData(SERVER_CONFIG); + console.log("viewers result", result) + + setConfig({ ...result }); + + } catch (error) { + setConfig({ ...config, message: error.message }); + } + }; + + useEffect(() => { + let getStatusIntervalId = null; + + getInfo(); + getStatusIntervalId = setInterval(getInfo, FETCH_INTERVAL); + + // returned function will be called on component unmount + return () => { + clearInterval(getStatusIntervalId); + } + }, []); + + return ( +
+

Server Config

+

+ Display this data all pretty, most things will be editable in the + future, not now. +

+
+ +
+
+ ); +} + diff --git a/web/pages/update-server-config.tsx b/web/pages/update-server-config.tsx index 782703047..8573b4048 100644 --- a/web/pages/update-server-config.tsx +++ b/web/pages/update-server-config.tsx @@ -2,31 +2,11 @@ import React, { useState, useEffect } from 'react'; import { Table, Typography, Input } from 'antd'; import { SERVER_CONFIG, fetchData, FETCH_INTERVAL } from './utils/apis'; import { isEmptyObject } from './utils/format'; +import KeyValueTable from "./components/key-value-table"; const { Title } = Typography; const { TextArea } = Input; -function KeyValueTable({ title, data }) { - const columns = [ - { - title: "Name", - dataIndex: "name", - key: "name", - }, - { - title: "Value", - dataIndex: "value", - key: "value", - }, - ]; - - return ( -
- {title} -

- - ); -} function SocialHandles({ config }) { if (!config) { @@ -121,114 +101,6 @@ function InstanceDetails({ config }) { ); } -function VideoVariants({ config }) { - if (!config) { - return null; - } - - const videoQualityColumns = [ - { - title: "Video bitrate", - dataIndex: "videoBitrate", - key: "videoBitrate", - render: (bitrate) => - bitrate === 0 || !bitrate ? "Passthrough" : `${bitrate} kbps`, - }, - { - title: "Framerate", - dataIndex: "framerate", - key: "framerate", - }, - { - title: "Encoder preset", - dataIndex: "encoderPreset", - key: "framerate", - }, - { - title: "Audio bitrate", - dataIndex: "audioBitrate", - key: "audioBitrate", - render: (bitrate) => - bitrate === 0 || !bitrate ? "Passthrough" : `${bitrate} kbps`, - }, - ]; - - const miscVideoSettingsColumns = [ - { - title: "Name", - dataIndex: "name", - key: "name", - }, - { - title: "Value", - dataIndex: "value", - key: "value", - }, - ]; - - const miscVideoSettings = [ - { - name: "Segment length", - value: config.videoSettings.segmentLengthSeconds, - }, - { - name: "Number of segments", - value: config.videoSettings.numberOfPlaylistItems, - }, - ]; - - return ( -
- Video configuration -
- -
- - ); -} - -function Storage({ config }) { - if (!config) { - return null; - } - - const data = [ - { - name: "Enabled", - value: config.s3.enabled.toString(), - }, - { - name: "Endpoint", - value: config.s3.endpoint, - }, - { - name: "Access Key", - value: config.s3.accessKey, - }, - { - name: "Secret", - value: config.s3.secret, - }, - { - name: "Bucket", - value: config.s3.bucket, - }, - { - name: "Region", - value: config.s3.region, - }, - ]; - return -} - function PageContent({ config }) { if (!config) { return null; @@ -287,8 +159,6 @@ export default function ServerConfig() { > - - {JSON.stringify(config)} diff --git a/web/pages/video-config.tsx b/web/pages/video-config.tsx new file mode 100644 index 000000000..53479d2de --- /dev/null +++ b/web/pages/video-config.tsx @@ -0,0 +1,128 @@ +import React, { useState, useEffect } from 'react'; +import { Table, Typography } from 'antd'; +import { SERVER_CONFIG, fetchData, FETCH_INTERVAL } from './utils/apis'; + +const { Title } = Typography; + + +function VideoVariants({ config }) { + if (!config) { + return null; + } + + const videoQualityColumns = [ + { + title: "Video bitrate", + dataIndex: "videoBitrate", + key: "videoBitrate", + render: (bitrate) => + bitrate === 0 || !bitrate ? "Passthrough" : `${bitrate} kbps`, + }, + { + title: "Framerate", + dataIndex: "framerate", + key: "framerate", + }, + { + title: "Encoder preset", + dataIndex: "encoderPreset", + key: "framerate", + }, + { + title: "Audio bitrate", + dataIndex: "audioBitrate", + key: "audioBitrate", + render: (bitrate) => + bitrate === 0 || !bitrate ? "Passthrough" : `${bitrate} kbps`, + }, + ]; + + const miscVideoSettingsColumns = [ + { + title: "Name", + dataIndex: "name", + key: "name", + }, + { + title: "Value", + dataIndex: "value", + key: "value", + }, + ]; + + const miscVideoSettings = [ + { + name: "Segment length", + value: config.videoSettings.segmentLengthSeconds, + }, + { + name: "Number of segments", + value: config.videoSettings.numberOfPlaylistItems, + }, + ]; + + return ( +
+ Video configuration +
+ +
+ + ); +} + +export default function VideoConfig() { + const [config, setConfig] = useState(); + + const getInfo = async () => { + try { + const result = await fetchData(SERVER_CONFIG); + console.log("viewers result", result) + + setConfig({ ...result }); + + } catch (error) { + setConfig({ ...config, message: error.message }); + } + }; + + useEffect(() => { + let getStatusIntervalId = null; + + getInfo(); + getStatusIntervalId = setInterval(getInfo, FETCH_INTERVAL); + + // returned function will be called on component unmount + return () => { + clearInterval(getStatusIntervalId); + } + }, []); + + return ( +
+

Server Config

+

+ Display this data all pretty, most things will be editable in the + future, not now. +

+
+ +
+
+ ); +} +