mirror of
https://github.com/owncast/owncast.git
synced 2025-11-02 20:23:29 +08:00
- start a README to document config admin later - update constants - add instanceUrl field to public details; if empty, then turn off yp.enabled. - edit YP/Directory settings; hide if instanceUrl is empty - update toggleswitch logic
This commit is contained in:
@ -1,4 +1,4 @@
|
|||||||
// rename to "directory"
|
// Note: references to "yp" in the app are likely related to Owncast Directory
|
||||||
import React, { useContext, useEffect } from 'react';
|
import React, { useContext, useEffect } from 'react';
|
||||||
import { Typography, Form } from 'antd';
|
import { Typography, Form } from 'antd';
|
||||||
|
|
||||||
|
|||||||
@ -3,9 +3,11 @@ import { Typography, Form } from 'antd';
|
|||||||
|
|
||||||
import TextField, { TEXTFIELD_TYPE_TEXTAREA } from './components/config/form-textfield';
|
import TextField, { TEXTFIELD_TYPE_TEXTAREA } from './components/config/form-textfield';
|
||||||
|
|
||||||
import EditInstanceTags from './components/config/tags';
|
import EditInstanceTags from './components/config/edit-tags';
|
||||||
|
import EditDirectoryDetails from './components/config/edit-directory';
|
||||||
|
|
||||||
import { ServerStatusContext } from '../utils/server-status-context';
|
import { ServerStatusContext } from '../utils/server-status-context';
|
||||||
|
import { TEXTFIELD_DEFAULTS, postConfigUpdateToAPI } from './components/config/constants';
|
||||||
|
|
||||||
const { Title } = Typography;
|
const { Title } = Typography;
|
||||||
|
|
||||||
@ -15,25 +17,50 @@ export default function PublicFacingDetails() {
|
|||||||
const serverStatusData = useContext(ServerStatusContext);
|
const serverStatusData = useContext(ServerStatusContext);
|
||||||
const { serverConfig } = serverStatusData || {};
|
const { serverConfig } = serverStatusData || {};
|
||||||
|
|
||||||
const { instanceDetails = {} } = serverConfig;
|
const { instanceDetails, yp } = serverConfig;
|
||||||
console.log(serverConfig)
|
const { instanceDetails: instanceDetailsDefaults, yp: ypDefaults } = TEXTFIELD_DEFAULTS;
|
||||||
|
|
||||||
|
const initialValues = {
|
||||||
|
...instanceDetails,
|
||||||
|
...yp,
|
||||||
|
};
|
||||||
|
|
||||||
|
const defaultFields = {
|
||||||
|
...instanceDetailsDefaults,
|
||||||
|
...ypDefaults,
|
||||||
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
form.setFieldsValue({...instanceDetails});
|
form.setFieldsValue(initialValues);
|
||||||
}, [instanceDetails]);
|
}, [instanceDetails]);
|
||||||
|
|
||||||
|
|
||||||
const handleResetValue = (fieldName: string) => {
|
const handleResetValue = (fieldName: string) => {
|
||||||
form.setFieldsValue({ [fieldName]: instanceDetails[fieldName]});
|
const defaultValue = defaultFields[fieldName] && defaultFields[fieldName].defaultValue || '';
|
||||||
|
|
||||||
|
form.setFieldsValue({ [fieldName]: initialValues[fieldName] || defaultValue });
|
||||||
|
}
|
||||||
|
|
||||||
|
// if instanceUrl is empty, we should also turn OFF the `enabled` field of directory.
|
||||||
|
const handleSubmitInstanceUrl = () => {
|
||||||
|
if (form.getFieldValue('instanceUrl') === '') {
|
||||||
|
if (yp.enabled === true) {
|
||||||
|
const { apiPath } = TEXTFIELD_DEFAULTS.yp.enabled;
|
||||||
|
postConfigUpdateToAPI({
|
||||||
|
apiPath,
|
||||||
|
data: { value: false },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const extraProps = {
|
const extraProps = {
|
||||||
handleResetValue,
|
handleResetValue,
|
||||||
initialValues: instanceDetails,
|
initialValues,
|
||||||
|
configPath: 'instanceDetails',
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<div className="config-public-details-form">
|
||||||
<Title level={2}>Edit your public facing instance details</Title>
|
<Title level={2}>Edit your public facing instance details</Title>
|
||||||
|
|
||||||
<div className="config-public-details-container">
|
<div className="config-public-details-container">
|
||||||
@ -42,10 +69,18 @@ export default function PublicFacingDetails() {
|
|||||||
form={form}
|
form={form}
|
||||||
layout="vertical"
|
layout="vertical"
|
||||||
>
|
>
|
||||||
<TextField fieldName="name" {...extraProps} />
|
<TextField
|
||||||
<TextField fieldName="summary" type={TEXTFIELD_TYPE_TEXTAREA} {...extraProps} />
|
fieldName="instanceUrl"
|
||||||
|
{...extraProps}
|
||||||
|
configPath="yp"
|
||||||
|
onSubmit={handleSubmitInstanceUrl}
|
||||||
|
/>
|
||||||
|
|
||||||
<TextField fieldName="title" {...extraProps} />
|
<TextField fieldName="title" {...extraProps} />
|
||||||
<TextField fieldName="streamTitle" {...extraProps} />
|
<TextField fieldName="streamTitle" {...extraProps} />
|
||||||
|
<TextField fieldName="name" {...extraProps} />
|
||||||
|
<TextField fieldName="summary" type={TEXTFIELD_TYPE_TEXTAREA} {...extraProps} />
|
||||||
|
<TextField fieldName="logo" {...extraProps} />
|
||||||
</Form>
|
</Form>
|
||||||
</div>
|
</div>
|
||||||
<div className="misc-fields">
|
<div className="misc-fields">
|
||||||
@ -53,11 +88,11 @@ export default function PublicFacingDetails() {
|
|||||||
<br/>
|
<br/>
|
||||||
add tags comp */}
|
add tags comp */}
|
||||||
<EditInstanceTags />
|
<EditInstanceTags />
|
||||||
|
<br/><br/>
|
||||||
|
<EditDirectoryDetails />
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -4,6 +4,7 @@ import { Typography, Form } from 'antd';
|
|||||||
import TextField, { TEXTFIELD_TYPE_NUMBER, TEXTFIELD_TYPE_PASSWORD, TEXTFIELD_TYPE_TEXTAREA } from './components/config/form-textfield';
|
import TextField, { TEXTFIELD_TYPE_NUMBER, TEXTFIELD_TYPE_PASSWORD, TEXTFIELD_TYPE_TEXTAREA } from './components/config/form-textfield';
|
||||||
|
|
||||||
import { ServerStatusContext } from '../utils/server-status-context';
|
import { ServerStatusContext } from '../utils/server-status-context';
|
||||||
|
import { TEXTFIELD_DEFAULTS } from './components/config/constants';
|
||||||
|
|
||||||
const { Title } = Typography;
|
const { Title } = Typography;
|
||||||
|
|
||||||
@ -13,27 +14,30 @@ export default function ConfigServerDetails() {
|
|||||||
const serverStatusData = useContext(ServerStatusContext);
|
const serverStatusData = useContext(ServerStatusContext);
|
||||||
const { serverConfig } = serverStatusData || {};
|
const { serverConfig } = serverStatusData || {};
|
||||||
|
|
||||||
const { ffmpegPath, streamKey, webServerPort } = serverConfig;
|
const { ffmpegPath, streamKey, webServerPort, rtmpServerPort } = serverConfig;
|
||||||
|
|
||||||
const streamDetails = {
|
const initialValues = {
|
||||||
ffmpegPath, streamKey, webServerPort
|
ffmpegPath,
|
||||||
|
streamKey,
|
||||||
|
webServerPort,
|
||||||
|
rtmpServerPort,
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
form.setFieldsValue({...streamDetails});
|
form.setFieldsValue(initialValues);
|
||||||
}, [serverStatusData]);
|
}, [serverStatusData]);
|
||||||
|
|
||||||
|
|
||||||
const handleResetValue = (fieldName: string) => {
|
const handleResetValue = (fieldName: string) => {
|
||||||
form.setFieldsValue({ [fieldName]: streamDetails[fieldName]});
|
const defaultValue = TEXTFIELD_DEFAULTS[fieldName] && TEXTFIELD_DEFAULTS[fieldName].defaultValue || '';
|
||||||
|
|
||||||
|
form.setFieldsValue({ [fieldName]: initialValues[fieldName] || defaultValue });
|
||||||
}
|
}
|
||||||
|
|
||||||
const extraProps = {
|
const extraProps = {
|
||||||
handleResetValue,
|
handleResetValue,
|
||||||
initialValues: streamDetails,
|
initialValues,
|
||||||
|
configPath: '',
|
||||||
};
|
};
|
||||||
|
|
||||||
console.log(streamDetails)
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Title level={2}>Edit your Server's details</Title>
|
<Title level={2}>Edit your Server's details</Title>
|
||||||
@ -46,6 +50,7 @@ export default function ConfigServerDetails() {
|
|||||||
<TextField fieldName="streamKey" type={TEXTFIELD_TYPE_PASSWORD} {...extraProps} />
|
<TextField fieldName="streamKey" type={TEXTFIELD_TYPE_PASSWORD} {...extraProps} />
|
||||||
<TextField fieldName="ffmpegPath" type={TEXTFIELD_TYPE_TEXTAREA} {...extraProps} />
|
<TextField fieldName="ffmpegPath" type={TEXTFIELD_TYPE_TEXTAREA} {...extraProps} />
|
||||||
<TextField fieldName="webServerPort" type={TEXTFIELD_TYPE_NUMBER} {...extraProps} />
|
<TextField fieldName="webServerPort" type={TEXTFIELD_TYPE_NUMBER} {...extraProps} />
|
||||||
|
<TextField fieldName="rtmpServerPort" type={TEXTFIELD_TYPE_NUMBER} {...extraProps} />
|
||||||
</Form>
|
</Form>
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
|
|||||||
@ -1,16 +1,3 @@
|
|||||||
|
|
||||||
.ant-btn-primary:hover, .ant-btn-primary:focus {
|
|
||||||
background-color: white;
|
|
||||||
color: #40a9ff;
|
|
||||||
}
|
|
||||||
.ant-btn-primary:focus {
|
|
||||||
box-shadow: 0px 1px 3px 2px rgba(90,103,216, .25)
|
|
||||||
}
|
|
||||||
.ant-input-affix-wrapper,
|
|
||||||
.ant-btn {
|
|
||||||
transition-delay: 0s;
|
|
||||||
transition-duration: 0.15s;
|
|
||||||
}
|
|
||||||
.config-public-details-container {
|
.config-public-details-container {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
@ -22,19 +9,34 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.misc-fields {
|
.misc-fields {
|
||||||
border: 1px solid var(--owncast-purple);
|
// border: 1px solid var(--owncast-purple);
|
||||||
padding: 2em;
|
padding: 2em;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.status-message {
|
||||||
|
margin: 1rem 0;
|
||||||
|
min-height: 1.25em;
|
||||||
|
font-size: .75rem;
|
||||||
|
&.success {
|
||||||
|
color: var(--ant-success);
|
||||||
|
}
|
||||||
|
&.error {
|
||||||
|
color: var(--ant-error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// form-textfield
|
||||||
|
// form-textfield
|
||||||
.textfield-container {
|
.textfield-container {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
align-items: flex-end;
|
align-items: flex-start;
|
||||||
justify-content: flex-end;
|
justify-content: flex-end;
|
||||||
position: relative;
|
position: relative;
|
||||||
|
width: 314px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.textfield {
|
.textfield {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
@ -68,6 +70,30 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// form-toggleswitch
|
||||||
|
// form-toggleswitch
|
||||||
|
.toggleswitch-container {
|
||||||
|
.status-message {
|
||||||
|
margin-top: .25rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.toggleswitch {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: flex-start;
|
||||||
|
.label {
|
||||||
|
font-weight: bold;
|
||||||
|
color: var(--owncast-purple);
|
||||||
|
}
|
||||||
|
.info { margin-left: .5rem }
|
||||||
|
.ant-form-item {
|
||||||
|
margin: 0 .75rem 0 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TAGS STUFF
|
||||||
|
// TAGS STUFF
|
||||||
.tag-current-tags {
|
.tag-current-tags {
|
||||||
.ant-tag {
|
.ant-tag {
|
||||||
margin: .1rem;
|
margin: .1rem;
|
||||||
@ -102,15 +128,4 @@
|
|||||||
width: 16em;
|
width: 16em;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.add-new-status {
|
|
||||||
margin: 1em 0;
|
|
||||||
min-height: 1.25em;
|
|
||||||
font-size: .75rem;
|
|
||||||
&.success {
|
|
||||||
color: var(--ant-success);
|
|
||||||
}
|
|
||||||
&.error {
|
|
||||||
color: var(--ant-error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|||||||
@ -30,10 +30,28 @@ pre {
|
|||||||
background-color: $owncast-purple;
|
background-color: $owncast-purple;
|
||||||
}
|
}
|
||||||
|
|
||||||
// misc system overrides
|
|
||||||
|
// GENERAL ANT FORM OVERRIDES
|
||||||
|
// GENERAL ANT FORM OVERRIDES
|
||||||
.ant-card {
|
.ant-card {
|
||||||
border-radius: .5em;
|
border-radius: .5em;
|
||||||
}
|
}
|
||||||
|
.ant-btn-primary:hover, .ant-btn-primary:focus {
|
||||||
|
background-color: white;
|
||||||
|
color: #40a9ff;
|
||||||
|
}
|
||||||
|
.ant-btn.ant-btn-primary:focus {
|
||||||
|
border: 1px solid var(--owncast-purple);
|
||||||
|
@media (prefers-color-scheme: dark) {
|
||||||
|
border-color: white;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.ant-input-affix-wrapper,
|
||||||
|
.ant-btn {
|
||||||
|
transition-delay: 0s;
|
||||||
|
transition-duration: 0.15s;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@media (prefers-color-scheme: dark) {
|
@media (prefers-color-scheme: dark) {
|
||||||
@import "~antd/dist/antd.dark";
|
@import "~antd/dist/antd.dark";
|
||||||
|
|||||||
@ -1,10 +1,21 @@
|
|||||||
// TS types for elements on the Config pages
|
// TS types for elements on the Config pages
|
||||||
|
|
||||||
export interface TextFieldProps {
|
export interface TextFieldProps {
|
||||||
handleResetValue: ({ fieldName }) => void;
|
handleResetValue?: (fieldName) => void;
|
||||||
fieldName: string;
|
fieldName: string;
|
||||||
initialValues: any;
|
initialValues?: any;
|
||||||
type: string;
|
type?: string;
|
||||||
|
configPath?: string;
|
||||||
|
required?: boolean;
|
||||||
|
disabled?: boolean;
|
||||||
|
onSubmit?: () => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ToggleSwitchProps {
|
||||||
|
fieldName: string;
|
||||||
|
initialValues?: any;
|
||||||
|
configPath?: string;
|
||||||
|
disabled?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface UpdateArgs {
|
export interface UpdateArgs {
|
||||||
@ -12,3 +23,37 @@ export interface UpdateArgs {
|
|||||||
value: string;
|
value: string;
|
||||||
path?: string;
|
path?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface ApiPostArgs {
|
||||||
|
apiPath: string,
|
||||||
|
data: object,
|
||||||
|
onSuccess?: () => {},
|
||||||
|
onError?: () => {},
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ConfigDirectoryFields {
|
||||||
|
enabled: boolean;
|
||||||
|
instanceUrl: string,
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ConfigInstanceDetailsFields {
|
||||||
|
extraPageContent: string;
|
||||||
|
logo: string;
|
||||||
|
name: string;
|
||||||
|
nsfw: boolean;
|
||||||
|
streamTitle: string;
|
||||||
|
summary: string;
|
||||||
|
tags: string[];
|
||||||
|
title: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ConfigDetails {
|
||||||
|
ffmpegPath: string;
|
||||||
|
instanceDetails: ConfigInstanceDetailsFields;
|
||||||
|
rtmpServerPort: string;
|
||||||
|
s3: any; // tbd
|
||||||
|
streamKey: string;
|
||||||
|
webServerPort: string;
|
||||||
|
yp: ConfigDirectoryFields;
|
||||||
|
videoSettings: any; // tbd
|
||||||
|
}
|
||||||
@ -2,15 +2,27 @@ import React, { useState, useEffect } from 'react';
|
|||||||
import PropTypes, { any } from 'prop-types';
|
import PropTypes, { any } from 'prop-types';
|
||||||
|
|
||||||
import { STATUS, fetchData, FETCH_INTERVAL, SERVER_CONFIG } from './apis';
|
import { STATUS, fetchData, FETCH_INTERVAL, SERVER_CONFIG } from './apis';
|
||||||
import { UpdateArgs } from '../types/config-section';
|
import { ConfigDetails, UpdateArgs } from '../types/config-section';
|
||||||
|
|
||||||
export const initialServerConfigState = {
|
export const initialServerConfigState: ConfigDetails = {
|
||||||
streamKey: '',
|
streamKey: '',
|
||||||
instanceDetails: {
|
instanceDetails: {
|
||||||
|
extraPageContent: '',
|
||||||
|
logo: '',
|
||||||
|
name: '',
|
||||||
|
nsfw: false,
|
||||||
|
streamTitle: '',
|
||||||
|
summary: '',
|
||||||
tags: [],
|
tags: [],
|
||||||
|
title: '',
|
||||||
},
|
},
|
||||||
|
ffmpegPath: '',
|
||||||
|
rtmpServerPort: '',
|
||||||
|
webServerPort: '',
|
||||||
|
s3: {},
|
||||||
yp: {
|
yp: {
|
||||||
enabled: false,
|
enabled: false,
|
||||||
|
instanceUrl: '',
|
||||||
},
|
},
|
||||||
videoSettings: {
|
videoSettings: {
|
||||||
videoQualityVariants: [
|
videoQualityVariants: [
|
||||||
|
|||||||
Reference in New Issue
Block a user