From d503c8a2e08d3d43ca0b1fd146d16d272420e3d4 Mon Sep 17 00:00:00 2001 From: Gabe Kangas Date: Mon, 28 Nov 2022 20:22:26 -0800 Subject: [PATCH] Updates to the admin to reflect new stream keys and admin password split --- web/components/MainLayout.tsx | 4 + web/components/Offline.tsx | 10 +- .../config/EditInstanceDetails2.tsx | 14 +- web/pages/admin/config/streamkeys/index.tsx | 174 ++++++++++++++++++ web/types/config-section.ts | 8 +- web/utils/apis.ts | 3 + web/utils/config-constants.tsx | 6 +- web/utils/server-status-context.tsx | 3 +- 8 files changed, 205 insertions(+), 17 deletions(-) create mode 100644 web/pages/admin/config/streamkeys/index.tsx diff --git a/web/components/MainLayout.tsx b/web/components/MainLayout.tsx index 3227eb478..3d1a01926 100644 --- a/web/components/MainLayout.tsx +++ b/web/components/MainLayout.tsx @@ -173,6 +173,10 @@ export const MainLayout: FC = ({ children }) => { label: Server Setup, key: 'config-server-details', }, + { + label: Server Setup, + key: 'config-streamkeys', + }, { label: Video, key: 'config-video', diff --git a/web/components/Offline.tsx b/web/components/Offline.tsx index 4c4ebadf0..99d7ff761 100644 --- a/web/components/Offline.tsx +++ b/web/components/Offline.tsx @@ -26,7 +26,7 @@ export const Offline: FC = ({ logs = [], config }) => { const serverStatusData = useContext(ServerStatusContext); const { serverConfig } = serverStatusData || {}; - const { streamKey, rtmpServerPort } = serverConfig; + const { rtmpServerPort } = serverConfig; const instanceUrl = global.window?.location.hostname || ''; let rtmpURL; @@ -58,11 +58,11 @@ export const Offline: FC = ({ logs = [], config }) => { )} - Stream Key: + Streaming Keys: + + + View - - ********************* - ), diff --git a/web/components/config/EditInstanceDetails2.tsx b/web/components/config/EditInstanceDetails2.tsx index dbcca5739..e12084489 100644 --- a/web/components/config/EditInstanceDetails2.tsx +++ b/web/components/config/EditInstanceDetails2.tsx @@ -9,7 +9,7 @@ import { TEXTFIELD_PROPS_FFMPEG, TEXTFIELD_PROPS_RTMP_PORT, TEXTFIELD_PROPS_SOCKET_HOST_OVERRIDE, - TEXTFIELD_PROPS_STREAM_KEY, + TEXTFIELD_PROPS_ADMIN_PASSWORD, TEXTFIELD_PROPS_WEB_PORT, } from '../../utils/config-constants'; import { UpdateArgs } from '../../types/config-section'; @@ -24,7 +24,7 @@ export const EditInstanceDetails = () => { const { serverConfig } = serverStatusData || {}; - const { streamKey, ffmpegPath, rtmpServerPort, webServerPort, yp, socketHostOverride } = + const { adminPassword, ffmpegPath, rtmpServerPort, webServerPort, yp, socketHostOverride } = serverConfig; const [copyIsVisible, setCopyVisible] = useState(false); @@ -33,7 +33,7 @@ export const EditInstanceDetails = () => { useEffect(() => { setFormDataValues({ - streamKey, + adminPassword, ffmpegPath, rtmpServerPort, webServerPort, @@ -89,10 +89,10 @@ export const EditInstanceDetails = () => {
{ + try { + await fetchData(UPDATE_STREAM_KEYS, { + method: 'POST', + auth: true, + data: { value: keys }, + }); + } catch (error) { + console.error(error); + setError(error); + } +}; + +const AddKeyForm = ({ setShowAddKeyForm, setFieldInConfigState, streamKeys, setError }) => { + const handleAddKey = (newkey: any) => { + const updatedKeys = [...streamKeys, newkey]; + + console.log(updatedKeys); + setFieldInConfigState({ + fieldName: 'streamKeys', + value: updatedKeys, + }); + + saveKeys(updatedKeys, setError); + + setShowAddKeyForm(false); + }; + + return ( +
+ + + + + + + + +
+ ); +}; + +const AddKeyButton = ({ setShowAddKeyForm }) => ( + +); + +const StreamKeys = () => { + const serverStatusData = useContext(ServerStatusContext); + const { serverConfig, setFieldInConfigState } = serverStatusData || {}; + const { streamKeys } = serverConfig; + const [showAddKeyForm, setShowAddKeyForm] = useState(false); + const [showKeyMap, setShowKeyMap] = useState({}); + const [error, setError] = useState(null); + + const handleDeleteKey = keyToRemove => { + const newKeys = streamKeys.filter(k => k !== keyToRemove); + setFieldInConfigState({ + fieldName: 'streamKeys', + value: newKeys, + }); + saveKeys(newKeys, setError); + }; + + const handleToggleShowKey = key => { + setShowKeyMap({ + ...showKeyMap, + [key]: !showKeyMap[key], + }); + }; + + const columns = [ + { + title: 'Key', + dataIndex: 'key', + key: 'key', + render: text => ( + + {showKeyMap[text] ? text : '**********'} + +