From 3cefa6f863c0e707feaceeff9fbe312f4eab3522 Mon Sep 17 00:00:00 2001 From: Jacob Su Date: Wed, 27 Nov 2024 10:56:29 +0800 Subject: [PATCH] fix forward item UI selection bug. missing `index` for the forword configs. --- ui/src/pages/ScenarioForward.js | 88 ++++++++++++++++----------------- 1 file changed, 44 insertions(+), 44 deletions(-) diff --git a/ui/src/pages/ScenarioForward.js b/ui/src/pages/ScenarioForward.js index 33704fbe..a658d38e 100644 --- a/ui/src/pages/ScenarioForward.js +++ b/ui/src/pages/ScenarioForward.js @@ -3,15 +3,15 @@ // // SPDX-License-Identifier: MIT // -import {Accordion, Badge, Button, Col, Form, Row, Table} from "react-bootstrap"; +import { Accordion, Badge, Button, Col, Form, Row, Table } from "react-bootstrap"; import React from "react"; -import {Token} from "../utils"; +import { Token } from "../utils"; import axios from "axios"; import moment from "moment"; -import {useErrorHandler} from "react-error-boundary"; -import {useSrsLanguage} from "../components/LanguageSwitch"; -import {useTranslation} from "react-i18next"; -import {SrsEnvContext} from "../components/SrsEnvContext"; +import { useErrorHandler } from "react-error-boundary"; +import { useSrsLanguage } from "../components/LanguageSwitch"; +import { useTranslation } from "react-i18next"; +import { SrsEnvContext } from "../components/SrsEnvContext"; export default function ScenarioForward() { const [init, setInit] = React.useState(); @@ -48,12 +48,12 @@ export default function ScenarioForward() { }, [init, secrets]); if (!activeKey) return <>; - return ; + return ; } -function ScenarioForwardImpl({defaultActiveKey, defaultSecrets}) { +function ScenarioForwardImpl({ defaultActiveKey, defaultSecrets }) { const language = useSrsLanguage(); - const {t} = useTranslation(); + const { t } = useTranslation(); const handleError = useErrorHandler(); const env = React.useContext(SrsEnvContext)[0]; @@ -108,7 +108,7 @@ function ScenarioForwardImpl({defaultActiveKey, defaultSecrets}) { // Load the configured forwarding from defaults. const existsConf = Object.values(defaultSecrets).find(e => e.platform.indexOf(`forwarding-${rindex}-`) === 0); if (existsConf) { - confs.push(existsConf); + confs.push({ ...existsConf, index: String(rindex) }); } else { confs.push({ platform: `forwarding-${rindex}-${rid}`, enabled: false, index: String(rindex), allowCustom: false, @@ -233,28 +233,28 @@ function ScenarioForwardImpl({defaultActiveKey, defaultSecrets}) { {t('plat.com.name')} * {conf.custom ? `(${t('helper.required')})` : `(${t('helper.optional')})`} {t('plat.com.name2')} - updateConfigObject({...conf, label: e.target.value})}/> + updateConfigObject({ ...conf, label: e.target.value })} /> {t('plat.com.source')} {!conf.custom && * {t('plat.com.source')} check System-{'>'}Streams tab} - updateConfigObject({...conf, stream: e.target.value})}/> + updateConfigObject({ ...conf, stream: e.target.value })} /> {conf.custom ? t('plat.com.server') : t('plat.com.server2')} {!conf.custom && * {t('plat.com.server3')} {conf?.locale?.link2}, {t('plat.com.server4')}} - updateConfigObject({...conf, server: e.target.value})}/> + updateConfigObject({ ...conf, server: e.target.value })} /> {t('plat.com.key')} {!conf.custom && * {t('plat.com.server3')} {conf?.locale?.link2}, {t('plat.com.key2')}} - updateConfigObject({...conf, secret: e.target.value})}/> + updateConfigObject({ ...conf, secret: e.target.value })} /> {conf?.allowCustom && ( - updateConfigObject({...conf, custom: !conf.custom})} /> + updateConfigObject({ ...conf, custom: !conf.custom })} /> @@ -265,7 +265,7 @@ function ScenarioForwardImpl({defaultActiveKey, defaultSecrets}) { disabled={submiting} onClick={(e) => { updateSecrets(e, 'update', conf.platform, conf.stream, conf.server, conf.secret, !conf.enabled, conf.custom, conf.label, () => { - updateConfigObject({...conf, enabled: !conf.enabled}); + updateConfigObject({ ...conf, enabled: !conf.enabled }); }); }} > @@ -284,36 +284,36 @@ function ScenarioForwardImpl({defaultActiveKey, defaultSecrets}) { forwards?.length ? ( - - - - - - - - - - + + + + + + + + + + - { - forwards?.map(file => { - return - - - - - - - - - ; - }) - } + { + forwards?.map(file => { + return + + + + + + + + + ; + }) + }
#{t('plat.com.platform')}{t('plat.com.status2')}StartReady{t('plat.com.update')}{t('plat.com.source')}{t('plat.com.log')}
#{t('plat.com.platform')}{t('plat.com.status2')}StartReady{t('plat.com.update')}{t('plat.com.source')}{t('plat.com.log')}
{file.i}{file.custom ? (file.label ? '' : t('plat.com.custom')) : file.name} {file.label} - - {file.enabled ? (file.frame ? t('plat.com.s0') : t('plat.com.s1')) : t('plat.com.s2')} - - {file.start && `${file.start?.format('YYYY-MM-DD HH:mm:ss')}`}{file.ready && `${file.ready?.format('YYYY-MM-DD HH:mm:ss')}`}{file.update && `${file.update?.format('YYYY-MM-DD HH:mm:ss')}`}{file.stream}{file.frame?.log}
{file.i}{file.custom ? (file.label ? '' : t('plat.com.custom')) : file.name} {file.label} + + {file.enabled ? (file.frame ? t('plat.com.s0') : t('plat.com.s1')) : t('plat.com.s2')} + + {file.start && `${file.start?.format('YYYY-MM-DD HH:mm:ss')}`}{file.ready && `${file.ready?.format('YYYY-MM-DD HH:mm:ss')}`}{file.update && `${file.update?.format('YYYY-MM-DD HH:mm:ss')}`}{file.stream}{file.frame?.log}
) : ''