owncast/web/pages/update-server-config.tsx

135 lines
2.7 KiB
TypeScript
Raw Normal View History

2020-11-01 08:01:37 +01:00
/* eslint-disable react/prop-types */
import React, { useContext } from 'react';
2020-10-26 05:39:25 +01:00
import { Table, Typography, Input } from 'antd';
2020-11-01 08:01:37 +01:00
import { isEmptyObject } from '../utils/format';
2020-10-29 18:16:13 +01:00
import KeyValueTable from "./components/key-value-table";
import { ServerStatusContext } from '../utils/server-status-context';
2020-10-26 05:39:25 +01:00
const { Title } = Typography;
const { TextArea } = Input;
2020-10-23 02:16:28 +02:00
2020-10-28 08:53:24 +01:00
function SocialHandles({ config }) {
if (!config) {
return null;
}
const columns = [
{
title: "Platform",
dataIndex: "platform",
key: "platform",
},
{
title: "URL",
dataIndex: "url",
key: "url",
2020-11-03 06:38:56 +01:00
render: (url) => <a href={url}>{url}</a>
2020-10-28 08:53:24 +01:00
},
];
2020-11-01 08:01:37 +01:00
if (!config.instanceDetails?.socialHandles) {
return null;
}
return (
<div>
<Title>Social Handles</Title>
<Table
pagination={false}
columns={columns}
dataSource={config.instanceDetails.socialHandles}
/>
</div>
);
2020-10-28 08:53:24 +01:00
}
function InstanceDetails({ config }) {
if (!config || isEmptyObject(config)) {
return null;
}
const { instanceDetails = {}, yp, streamKey, ffmpegPath, webServerPort } = config;
const data = [
{
name: "Server name",
value: instanceDetails.name,
},
{
name: "Title",
value: instanceDetails.title,
},
{
name: "Summary",
value: instanceDetails.summary,
},
{
name: "Logo",
2020-11-13 12:57:57 +01:00
value: instanceDetails.logo?.large,
2020-10-28 08:53:24 +01:00
},
{
name: "Tags",
2020-11-13 12:57:57 +01:00
value: instanceDetails.tags?.join(", "),
2020-10-28 08:53:24 +01:00
},
{
name: "NSFW",
2020-11-13 12:57:57 +01:00
value: instanceDetails.nsfw?.toString(),
2020-10-28 08:53:24 +01:00
},
{
name: "Shows in Owncast directory",
value: yp.enabled.toString(),
},
];
const configData = [
{
name: "Stream key",
value: streamKey,
},
{
name: "ffmpeg path",
value: ffmpegPath,
},
{
name: "Web server port",
value: webServerPort,
},
];
return (
<>
<KeyValueTable title="Server details" data={data} />
<KeyValueTable title="Server configuration" data={configData} />
</>
);
}
function PageContent({ config }) {
2020-11-01 08:01:37 +01:00
if (!config?.instanceDetails?.extraPageContent) {
2020-10-28 08:53:24 +01:00
return null;
}
return (
<div>
<Title>Page content</Title>
<TextArea
disabled rows={4}
value={config.instanceDetails.extraPageContent}
/>
</div>
);
}
export default function ServerConfig() {
const serverStatusData = useContext(ServerStatusContext);
const { serverConfig: config } = serverStatusData || {};
return (
<div>
2020-10-28 08:53:24 +01:00
<InstanceDetails config={config} />
<SocialHandles config={config} />
<PageContent config={config} />
</div>
2020-10-28 08:53:24 +01:00
);
}
2020-10-26 05:39:25 +01:00