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

142 lines
3.1 KiB
TypeScript
Raw Normal View History

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-11-29 04:26:52 +01:00
import adminStyles from '../styles/styles.module.scss';
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 (
2020-11-29 03:43:59 +01:00
<div className={adminStyles.configSection}>
<Title level={2}>Social Handles</Title>
2020-11-01 08:01:37 +01:00
<Table
pagination={false}
columns={columns}
dataSource={config.instanceDetails.socialHandles}
2020-11-29 03:43:59 +01:00
rowKey="platform"
2020-11-01 08:01:37 +01:00
/>
</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-12-04 09:14:52 +01:00
value: instanceDetails.logo,
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 (
<>
2020-11-29 03:43:59 +01:00
<div className={adminStyles.configSection}>
<KeyValueTable title="Server details" data={data} />
</div>
<div className={adminStyles.configSection}>
<KeyValueTable title="Server configuration" data={configData} />
</div>
2020-10-28 08:53:24 +01:00
</>
);
}
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 (
2020-11-29 03:43:59 +01:00
<div className={adminStyles.configSection}>
<Title level={2}>Page content</Title>
2020-10-28 08:53:24 +01:00
<TextArea
disabled rows={4}
value={config.instanceDetails.extraPageContent}
/>
</div>
);
}
export default function ServerConfig() {
const serverStatusData = useContext(ServerStatusContext);
const { serverConfig: config } = serverStatusData || {};
return (
2020-11-29 03:43:59 +01:00
<>
<InstanceDetails config={config} />
<SocialHandles config={config} />
<PageContent config={config} />
<Title level={5}>Learn more about configuring Owncast <a href="https://owncast.online/docs/configuration">by visiting the documentation.</a></Title>
</>
2020-10-28 08:53:24 +01:00
);
}
2020-10-26 05:39:25 +01:00