- 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:
gingervitis
2021-01-03 00:26:26 -08:00
committed by Gabe Kangas
parent c93aefa05d
commit c6e978f182
6 changed files with 402 additions and 114 deletions

View File

@@ -1,6 +1,8 @@
// DEFAULT VALUES
import React from 'react';
import { CheckCircleFilled, ExclamationCircleFilled } from '@ant-design/icons';
import { fetchData, SERVER_CONFIG_UPDATE_URL } from '../../../utils/apis';
import { ApiPostArgs } from '../../../types/config-section';
export const DEFAULT_NAME = 'Owncast User';
export const DEFAULT_TITLE = 'Owncast Server';
@@ -22,105 +24,169 @@ export const SUCCESS_STATES = {
};
export async function postConfigUpdateToAPI(args: ApiPostArgs) {
const {
apiPath,
data,
onSuccess,
onError,
} = args;
const result = await fetchData(`${SERVER_CONFIG_UPDATE_URL}${apiPath}`, {
data,
method: 'POST',
auth: true,
});
if (result.success && onSuccess) {
onSuccess();
} else if (onError) {
onError();
}
}
// Creating this so that it'll be easier to change values in one place, rather than looking for places to change it in a sea of JSX.
// key is the input's `fieldName`
// the structure of this mirrors config data
export const TEXTFIELD_DEFAULTS = {
name: {
apiPath: '/name',
defaultValue: DEFAULT_NAME,
maxLength: TEXT_MAXLENGTH,
placeholder: DEFAULT_NAME,
configPath: 'instanceDetails',
label: 'Server name',
tip: 'This is your name that shows up on things and stuff.',
},
instanceDetails: {
summary: {
apiPath: '/serversummary',
defaultValue: DEFAULT_NAME,
maxLength: TEXT_MAXLENGTH,
placeholder: DEFAULT_NAME,
configPath: 'instanceDetails',
label: 'Summary',
tip: 'A brief blurb about what your stream is about.',
},
title: {
apiPath: '/servertitle',
defaultValue: DEFAULT_NAME,
maxLength: TEXT_MAXLENGTH,
placeholder: DEFAULT_NAME,
configPath: 'instanceDetails',
label: 'Server Title',
tip: 'A brief blurb about what your stream is about.',
},
streamTitle: {
apiPath: '/streamtitle',
defaultValue: DEFAULT_NAME,
maxLength: TEXT_MAXLENGTH,
placeholder: DEFAULT_NAME,
configPath: 'instanceDetails',
label: 'Stream Title',
tip: 'The name of your stream today.',
},
// user name
name: {
apiPath: '/name',
defaultValue: '',
maxLength: TEXT_MAXLENGTH,
placeholder: 'username',
label: 'User name',
tip: 'Who are you? What name do you want viewers to know you?',
},
logo: {
apiPath: '/logo',
defaultValue: DEFAULT_NAME,
maxLength: TEXT_MAXLENGTH,
placeholder: DEFAULT_NAME,
configPath: 'instanceDetails',
label: 'Stream Title',
tip: 'A brief blurb about what your stream is about.',
},
// like "goth land"
title: {
apiPath: '/servertitle',
defaultValue: '',
maxLength: TEXT_MAXLENGTH,
placeholder: 'Owncast site name',
label: 'Server Name',
tip: 'The name of your Owncast server',
},
extraPageContent: {
apiPath: '/pagecontent',
placeholder: '',
configPath: 'instanceDetails',
label: 'Stream Key',
tip: 'Custom markup about yourself',
},
streamTitle: {
apiPath: '/streamtitle',
defaultValue: '',
maxLength: TEXT_MAXLENGTH,
placeholder: 'Doing cool things...',
label: 'Stream Title',
tip: 'What is your stream about today?',
},
summary: {
apiPath: '/serversummary',
defaultValue: '',
maxLength: 500,
placeholder: 'Summary',
label: 'Summary',
tip: 'A brief blurb about what your stream is about.',
},
logo: {
apiPath: '/logo',
defaultValue: '',
maxLength: 255,
placeholder: '/img/mylogo.png',
label: 'Logo',
tip: 'Path to your logo from website root',
},
extraPageContent: {
apiPath: '/pagecontent',
placeholder: '',
label: 'Extra page content',
tip: 'Custom markup about yourself',
},
nsfw: {
apiPath: '/nsfw',
placeholder: '',
label: 'NSFW?',
tip: "Turn this ON if you plan to steam explicit or adult content. You may want to respectfully set this flag so that unexpecting eyes won't accidentally see it from the Directory.",
},
//
tags: {
apiPath: '/tags',
defaultValue: '',
maxLength: 24,
placeholder: 'Add a new tag',
label: '',
tip: '',
},
},
streamKey: {
apiPath: '/key',
defaultValue: DEFAULT_NAME,
maxLength: TEXT_MAXLENGTH,
placeholder: DEFAULT_NAME,
configPath: '',
placeholder: 'abc123',
label: 'Stream Key',
tip: 'Secret stream key',
},
ffmpegPath: {
// apiPath: '/key',
defaultValue: DEFAULT_NAME,
maxLength: TEXT_MAXLENGTH,
placeholder: DEFAULT_NAME,
configPath: '',
label: 'FFmpeg Path',
tip: 'Absolute file path of the FFMPEG application on your server',
},
webServerPort: {
apiPath: '/port',
defaultValue: '',
maxLength: 6,
placeholder: DEFAULT_NAME,
configPath: '',
label: 'Server port',
tip: 'What port are you serving Owncast from? Default is :8080',
required: true,
},
//
tags: {
apiPath: '/tags',
ffmpegPath: {
apiPath: '/ffmpegpath',
defaultValue: DEFAULT_NAME,
maxLength: TEXT_MAXLENGTH,
placeholder: '/usr/local/bin/ffmpeg',
label: 'FFmpeg Path',
tip: 'Absolute file path of the FFMPEG application on your server',
required: true,
},
webServerPort: {
apiPath: '/webserverport',
defaultValue: '',
maxLength: 24,
placeholder: 'Add a new tag',
configPath: 'instanceDetails',
label: '',
tip: '',
maxLength: 6,
placeholder: '8080',
label: 'Owncast Server port',
tip: 'What port are you serving Owncast from? Default is :8080',
required: true,
},
rtmpServerPort: {
apiPath: '/rtmpserverport',
defaultValue: '1935',
maxLength: 6,
placeholder: DEFAULT_NAME,
label: 'RTMP port',
tip: 'What port are you receiving RTMP?',
required: true,
},
s3: {
// tbd
},
// YP options
yp: {
instanceUrl: {
apiPath: '/serverurl',
defaultValue: 'https://owncast.mysite.com',
maxLength: 255,
placeholder: 'url',
label: 'Instance URL',
tip: 'Please provide the url to your Owncast site if you enable this Directory setting.',
},
enabled: {
apiPath: '/directoryenabled',
defaultValue: false,
maxLength: 0,
placeholder: '',
label: 'Display in the Owncast Directory?',
tip: 'Turn this ON if you want to show up in the Owncast directory at https://directory.owncast.online.',
}
}
}