Add server setting to disable chat (#61)
* Add server setting to disable chat * Prettified Code! Co-authored-by: gabek <gabek@users.noreply.github.com>
This commit is contained in:
@@ -4,6 +4,7 @@ import { CopyOutlined, RedoOutlined } from '@ant-design/icons';
|
|||||||
|
|
||||||
import { TEXTFIELD_TYPE_NUMBER, TEXTFIELD_TYPE_PASSWORD } from './form-textfield';
|
import { TEXTFIELD_TYPE_NUMBER, TEXTFIELD_TYPE_PASSWORD } from './form-textfield';
|
||||||
import TextFieldWithSubmit from './form-textfield-with-submit';
|
import TextFieldWithSubmit from './form-textfield-with-submit';
|
||||||
|
import ToggleSwitch from './form-toggleswitch';
|
||||||
|
|
||||||
import { ServerStatusContext } from '../../utils/server-status-context';
|
import { ServerStatusContext } from '../../utils/server-status-context';
|
||||||
import { AlertMessageContext } from '../../utils/alert-message-context';
|
import { AlertMessageContext } from '../../utils/alert-message-context';
|
||||||
@@ -13,6 +14,7 @@ import {
|
|||||||
TEXTFIELD_PROPS_RTMP_PORT,
|
TEXTFIELD_PROPS_RTMP_PORT,
|
||||||
TEXTFIELD_PROPS_STREAM_KEY,
|
TEXTFIELD_PROPS_STREAM_KEY,
|
||||||
TEXTFIELD_PROPS_WEB_PORT,
|
TEXTFIELD_PROPS_WEB_PORT,
|
||||||
|
FIELD_PROPS_DISABLE_CHAT,
|
||||||
} from '../../utils/config-constants';
|
} from '../../utils/config-constants';
|
||||||
|
|
||||||
import { UpdateArgs } from '../../types/config-section';
|
import { UpdateArgs } from '../../types/config-section';
|
||||||
@@ -27,7 +29,7 @@ export default function EditInstanceDetails() {
|
|||||||
|
|
||||||
const { serverConfig } = serverStatusData || {};
|
const { serverConfig } = serverStatusData || {};
|
||||||
|
|
||||||
const { streamKey, ffmpegPath, rtmpServerPort, webServerPort, yp } = serverConfig;
|
const { chatDisabled, streamKey, ffmpegPath, rtmpServerPort, webServerPort, yp } = serverConfig;
|
||||||
|
|
||||||
const [copyIsVisible, setCopyVisible] = useState(false);
|
const [copyIsVisible, setCopyVisible] = useState(false);
|
||||||
|
|
||||||
@@ -39,6 +41,7 @@ export default function EditInstanceDetails() {
|
|||||||
ffmpegPath,
|
ffmpegPath,
|
||||||
rtmpServerPort,
|
rtmpServerPort,
|
||||||
webServerPort,
|
webServerPort,
|
||||||
|
chatDisabled,
|
||||||
});
|
});
|
||||||
}, [serverConfig]);
|
}, [serverConfig]);
|
||||||
|
|
||||||
@@ -85,6 +88,10 @@ export default function EditInstanceDetails() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function handleChatDisableChange(disabled: boolean) {
|
||||||
|
handleFieldChange({ fieldName: 'chatDisabled', value: disabled });
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="edit-server-details-container">
|
<div className="edit-server-details-container">
|
||||||
<div className="field-container field-streamkey-container">
|
<div className="field-container field-streamkey-container">
|
||||||
@@ -138,6 +145,12 @@ export default function EditInstanceDetails() {
|
|||||||
onChange={handleFieldChange}
|
onChange={handleFieldChange}
|
||||||
onSubmit={showConfigurationRestartMessage}
|
onSubmit={showConfigurationRestartMessage}
|
||||||
/>
|
/>
|
||||||
|
<ToggleSwitch
|
||||||
|
fieldName="chatDisabled"
|
||||||
|
{...FIELD_PROPS_DISABLE_CHAT}
|
||||||
|
checked={formDataValues.chatDisabled}
|
||||||
|
onChange={handleChatDisableChange}
|
||||||
|
/>
|
||||||
|
|
||||||
{yp.enabled && (
|
{yp.enabled && (
|
||||||
<Collapse className="advanced-settings">
|
<Collapse className="advanced-settings">
|
||||||
|
|||||||
@@ -88,4 +88,5 @@ export interface ConfigDetails {
|
|||||||
webServerPort: string;
|
webServerPort: string;
|
||||||
yp: ConfigDirectoryFields;
|
yp: ConfigDirectoryFields;
|
||||||
videoSettings: VideoSettingsFields;
|
videoSettings: VideoSettingsFields;
|
||||||
|
chatDisabled: boolean;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ export const API_VIDEO_SEGMENTS = '/video/streamlatencylevel';
|
|||||||
export const API_VIDEO_VARIANTS = '/video/streamoutputvariants';
|
export const API_VIDEO_VARIANTS = '/video/streamoutputvariants';
|
||||||
export const API_WEB_PORT = '/webserverport';
|
export const API_WEB_PORT = '/webserverport';
|
||||||
export const API_YP_SWITCH = '/directoryenabled';
|
export const API_YP_SWITCH = '/directoryenabled';
|
||||||
|
export const API_CHAT_DISABLE = '/chat/disable';
|
||||||
|
|
||||||
export async function postConfigUpdateToAPI(args: ApiPostArgs) {
|
export async function postConfigUpdateToAPI(args: ApiPostArgs) {
|
||||||
const { apiPath, data, onSuccess, onError } = args;
|
const { apiPath, data, onSuccess, onError } = args;
|
||||||
@@ -159,6 +160,14 @@ export const DEFAULT_VARIANT_STATE: VideoVariant = {
|
|||||||
name: '',
|
name: '',
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const FIELD_PROPS_DISABLE_CHAT = {
|
||||||
|
apiPath: API_CHAT_DISABLE,
|
||||||
|
configPath: 'chatDisabled',
|
||||||
|
label: 'Disable chat',
|
||||||
|
tip: 'Hide the web chat interface.',
|
||||||
|
useSubmit: true,
|
||||||
|
};
|
||||||
|
|
||||||
export const VIDEO_VARIANT_SETTING_DEFAULTS = {
|
export const VIDEO_VARIANT_SETTING_DEFAULTS = {
|
||||||
// this one is currently unused
|
// this one is currently unused
|
||||||
audioBitrate: {
|
audioBitrate: {
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ export const initialServerConfigState: ConfigDetails = {
|
|||||||
ffmpegPath: '',
|
ffmpegPath: '',
|
||||||
rtmpServerPort: '',
|
rtmpServerPort: '',
|
||||||
webServerPort: '',
|
webServerPort: '',
|
||||||
|
chatDisabled: false,
|
||||||
s3: {
|
s3: {
|
||||||
accessKey: '',
|
accessKey: '',
|
||||||
acl: '',
|
acl: '',
|
||||||
|
|||||||
Reference in New Issue
Block a user