mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-10 19:14:16 +00:00
improve live control panel
This commit is contained in:
parent
300577706a
commit
80379b54d0
147
packages/app/src/pages/live_control/index.jsx
Normal file
147
packages/app/src/pages/live_control/index.jsx
Normal file
@ -0,0 +1,147 @@
|
|||||||
|
import React from "react"
|
||||||
|
import * as antd from "antd"
|
||||||
|
import { Icons } from "components/Icons"
|
||||||
|
|
||||||
|
import "./index.less"
|
||||||
|
|
||||||
|
const StreamingKeyView = (props) => {
|
||||||
|
const [streamingKeyVisibility, setStreamingKeyVisibility] = React.useState(false)
|
||||||
|
|
||||||
|
const toogleVisibility = (to) => {
|
||||||
|
setStreamingKeyVisibility(to ?? !streamingKeyVisibility)
|
||||||
|
}
|
||||||
|
|
||||||
|
return <div className="streamingKeyString">
|
||||||
|
{streamingKeyVisibility ?
|
||||||
|
<>
|
||||||
|
<Icons.EyeOff onClick={() => toogleVisibility()} />
|
||||||
|
<code>
|
||||||
|
{props.streamingKey ?? "No streaming key available"}
|
||||||
|
</code>
|
||||||
|
</> :
|
||||||
|
<div
|
||||||
|
onClick={() => toogleVisibility()}
|
||||||
|
>
|
||||||
|
<Icons.Eye />
|
||||||
|
Click to show key
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
|
||||||
|
export default (props) => {
|
||||||
|
const [streamInfo, setStreamInfo] = React.useState(null)
|
||||||
|
|
||||||
|
const [isConnected, setIsConnected] = React.useState(false)
|
||||||
|
const [targetServer, setTargetServer] = React.useState("No available server")
|
||||||
|
|
||||||
|
const [streamingKey, setStreamingKey] = React.useState(null)
|
||||||
|
|
||||||
|
const checkStreamingKey = async () => {
|
||||||
|
const result = await app.api.withEndpoints("main").get.streamingKey().catch((error) => {
|
||||||
|
console.error(error)
|
||||||
|
antd.message.error(error.message)
|
||||||
|
|
||||||
|
return null
|
||||||
|
})
|
||||||
|
|
||||||
|
if (result) {
|
||||||
|
setStreamingKey(result.key)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const regenerateStreamingKey = async () => {
|
||||||
|
antd.Modal.confirm({
|
||||||
|
title: "Regenerate streaming key",
|
||||||
|
content: "Are you sure you want to regenerate the streaming key? After this, all other generated keys will be deleted.",
|
||||||
|
onOk: async () => {
|
||||||
|
const result = await app.api.withEndpoints("main").post.regenerateStreamingKey().catch((error) => {
|
||||||
|
console.error(error)
|
||||||
|
antd.message.error(error.message)
|
||||||
|
|
||||||
|
return null
|
||||||
|
})
|
||||||
|
|
||||||
|
if (result) {
|
||||||
|
setStreamingKey(result.key)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
React.useEffect(() => {
|
||||||
|
checkStreamingKey()
|
||||||
|
}, [])
|
||||||
|
|
||||||
|
return <div className="streamingControlPanel">
|
||||||
|
<div className="header">
|
||||||
|
<div className="preview">
|
||||||
|
<img src="/assets/new_file.png" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="details">
|
||||||
|
<div className="status">
|
||||||
|
<antd.Tag
|
||||||
|
color={isConnected ? "Blue" : "Red"}
|
||||||
|
icon={isConnected ? <Icons.MdOutlineVideocam /> : <Icons.MdOutlineVideocamOff />}
|
||||||
|
>
|
||||||
|
{isConnected ? "Connected" : "Disconnected"}
|
||||||
|
</antd.Tag>
|
||||||
|
</div>
|
||||||
|
<div className="title">
|
||||||
|
<span>
|
||||||
|
Title
|
||||||
|
</span>
|
||||||
|
<h2>
|
||||||
|
{streamInfo?.title ?? "No title"}
|
||||||
|
</h2>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="category">
|
||||||
|
<span>
|
||||||
|
Category
|
||||||
|
</span>
|
||||||
|
<h4>
|
||||||
|
{streamInfo?.category ?? "No category"}
|
||||||
|
</h4>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="config">
|
||||||
|
<div className="panel">
|
||||||
|
<h2><Icons.MdSettingsInputAntenna /> Emission</h2>
|
||||||
|
|
||||||
|
<div className="content">
|
||||||
|
<span>Ingestion URL</span>
|
||||||
|
|
||||||
|
<code>
|
||||||
|
{targetServer}
|
||||||
|
</code>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="content">
|
||||||
|
<div className="title">
|
||||||
|
<div>
|
||||||
|
<span>Streaming key </span>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<antd.Button onClick={() => regenerateStreamingKey()}>
|
||||||
|
<Icons.RefreshCw />
|
||||||
|
Regenerate
|
||||||
|
</antd.Button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="value">
|
||||||
|
<StreamingKeyView streamingKey={streamingKey} />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="panel">
|
||||||
|
<h2>Additional options</h2>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
}
|
121
packages/app/src/pages/live_control/index.less
Normal file
121
packages/app/src/pages/live_control/index.less
Normal file
@ -0,0 +1,121 @@
|
|||||||
|
.streamingControlPanel {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
|
||||||
|
transition: all 0.3s ease-in-out;
|
||||||
|
|
||||||
|
.header {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
|
||||||
|
height: 20vh;
|
||||||
|
|
||||||
|
padding: 15px;
|
||||||
|
|
||||||
|
border: 1px solid var(--border-color);
|
||||||
|
border-radius: 12px;
|
||||||
|
|
||||||
|
margin-bottom: 20px;
|
||||||
|
|
||||||
|
transition: all 0.3s ease-in-out;
|
||||||
|
|
||||||
|
.preview {
|
||||||
|
height: 100%;
|
||||||
|
max-width: 400px;
|
||||||
|
|
||||||
|
img {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
|
||||||
|
border-radius: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
margin-right: 40px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.details {
|
||||||
|
display: inline-flex;
|
||||||
|
flex-direction: column;
|
||||||
|
|
||||||
|
padding: 20px 0;
|
||||||
|
|
||||||
|
.status {
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.config {
|
||||||
|
display: flex;
|
||||||
|
|
||||||
|
padding: 0 40px;
|
||||||
|
|
||||||
|
transition: all 0.3s ease-in-out;
|
||||||
|
|
||||||
|
code {
|
||||||
|
padding: 5px 8px;
|
||||||
|
font-size: 1rem;
|
||||||
|
|
||||||
|
background-color: var(--background-color-accent);
|
||||||
|
color: var(--text-color);
|
||||||
|
|
||||||
|
border-radius: 8px;
|
||||||
|
|
||||||
|
font-family: "DM Mono", monospace;
|
||||||
|
|
||||||
|
user-select: all;
|
||||||
|
}
|
||||||
|
|
||||||
|
.panel {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
|
||||||
|
margin-right: 50px;
|
||||||
|
|
||||||
|
.content {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
|
||||||
|
margin: 20px 20px 20px 0;
|
||||||
|
|
||||||
|
width: 100%;
|
||||||
|
|
||||||
|
.title {
|
||||||
|
display: inline-flex;
|
||||||
|
flex-direction: row;
|
||||||
|
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
|
||||||
|
width: 100%;
|
||||||
|
margin-bottom: 8px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
.streamingKeyString {
|
||||||
|
display: inline-flex;
|
||||||
|
flex-direction: row;
|
||||||
|
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
|
||||||
|
color: var(--text-color);
|
||||||
|
|
||||||
|
svg {
|
||||||
|
font-size: 1.5rem;
|
||||||
|
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
div {
|
||||||
|
display: inline-flex;
|
||||||
|
flex-direction: row;
|
||||||
|
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
}
|
@ -1,176 +0,0 @@
|
|||||||
import React from "react"
|
|
||||||
import * as antd from "antd"
|
|
||||||
import { Icons } from "components/Icons"
|
|
||||||
|
|
||||||
import "./index.less"
|
|
||||||
|
|
||||||
const StreamingKeyView = (props) => {
|
|
||||||
const [streamingKeyVisibility, setStreamingKeyVisibility] = React.useState(false)
|
|
||||||
|
|
||||||
const toogleVisibility = (to) => {
|
|
||||||
setStreamingKeyVisibility(to ?? !streamingKeyVisibility)
|
|
||||||
}
|
|
||||||
|
|
||||||
return <div className="streamingKeyString">
|
|
||||||
{streamingKeyVisibility ?
|
|
||||||
<>
|
|
||||||
<Icons.EyeOff onClick={() => toogleVisibility()} />
|
|
||||||
<h4>
|
|
||||||
{props.streamingKey ?? "No streaming key available"}
|
|
||||||
</h4>
|
|
||||||
</> :
|
|
||||||
<>
|
|
||||||
<Icons.Eye onClick={() => toogleVisibility()} />
|
|
||||||
Show key
|
|
||||||
</>
|
|
||||||
}
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
|
|
||||||
export default (props) => {
|
|
||||||
const [isConnected, setIsConnected] = React.useState(false)
|
|
||||||
const [targetServer, setTargetServer] = React.useState("No available server")
|
|
||||||
|
|
||||||
const [streamingKey, setStreamingKey] = React.useState(null)
|
|
||||||
const [serverTier, setServerTier] = React.useState(null)
|
|
||||||
|
|
||||||
const checkStreamingKey = async () => {
|
|
||||||
const result = await app.api.withEndpoints("main").get.streamingKey().catch((error) => {
|
|
||||||
console.error(error)
|
|
||||||
antd.message.error(error.message)
|
|
||||||
|
|
||||||
return null
|
|
||||||
})
|
|
||||||
|
|
||||||
if (result) {
|
|
||||||
setStreamingKey(result.key)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const checkTagetServer = async () => {
|
|
||||||
const result = await app.api.withEndpoints("main").get.targetStreamingServer()
|
|
||||||
|
|
||||||
if (result) {
|
|
||||||
const targetServer = `${result.protocol}://${result.address}:${result.port}/${result.space}`
|
|
||||||
setTargetServer(targetServer)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const regenerateStreamingKey = async () => {
|
|
||||||
antd.Modal.confirm({
|
|
||||||
title: "Regenerate streaming key",
|
|
||||||
content: "Are you sure you want to regenerate the streaming key? After this, all other generated keys will be deleted.",
|
|
||||||
onOk: async () => {
|
|
||||||
const result = await app.api.withEndpoints("main").post.regenerateStreamingKey().catch((error) => {
|
|
||||||
console.error(error)
|
|
||||||
antd.message.error(error.message)
|
|
||||||
|
|
||||||
return null
|
|
||||||
})
|
|
||||||
|
|
||||||
if (result) {
|
|
||||||
setStreamingKey(result.key)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
React.useEffect(() => {
|
|
||||||
checkStreamingKey()
|
|
||||||
checkTagetServer()
|
|
||||||
// TODO: Use UserTier controller to check streaming service tier
|
|
||||||
// by now, we just use a fixed value
|
|
||||||
setServerTier("basic")
|
|
||||||
}, [])
|
|
||||||
|
|
||||||
return <div className="streamingControlPanel">
|
|
||||||
<div>
|
|
||||||
<h2><Icons.MdSettingsInputAntenna /> Connection Status</h2>
|
|
||||||
|
|
||||||
<div>
|
|
||||||
<antd.Tag
|
|
||||||
color={isConnected ? "Blue" : "Red"}
|
|
||||||
icon={isConnected ? <Icons.MdOutlineVideocam /> : <Icons.MdOutlineVideocamOff />}
|
|
||||||
>
|
|
||||||
{isConnected ? "Connected" : "Disconnected"}
|
|
||||||
</antd.Tag>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div>
|
|
||||||
<h2><Icons.MdInfoOutline /> Stream information</h2>
|
|
||||||
|
|
||||||
<div className="info">
|
|
||||||
<div className="label">
|
|
||||||
<Icons.Tag />
|
|
||||||
Title
|
|
||||||
</div>
|
|
||||||
<div className="value">
|
|
||||||
<antd.Input
|
|
||||||
placeholder="Stream Title"
|
|
||||||
disabled
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="info">
|
|
||||||
<div className="label">
|
|
||||||
<Icons.Grid />
|
|
||||||
Category
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="value">
|
|
||||||
<antd.Select
|
|
||||||
disabled
|
|
||||||
>
|
|
||||||
|
|
||||||
</antd.Select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div>
|
|
||||||
<h2><Icons.Info /> Server info</h2>
|
|
||||||
|
|
||||||
<div className="info">
|
|
||||||
<div className="label">
|
|
||||||
<Icons.Server />
|
|
||||||
Server Address
|
|
||||||
</div>
|
|
||||||
<div className="value">
|
|
||||||
<h4>
|
|
||||||
{targetServer}
|
|
||||||
</h4>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="info">
|
|
||||||
<div className="label">
|
|
||||||
<Icons.Key />
|
|
||||||
Streaming Key
|
|
||||||
</div>
|
|
||||||
<div className="value">
|
|
||||||
<StreamingKeyView streamingKey={streamingKey} />
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<antd.Button onClick={() => regenerateStreamingKey()}>
|
|
||||||
<Icons.RefreshCw />
|
|
||||||
Regenerate
|
|
||||||
</antd.Button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="info">
|
|
||||||
<div className="label">
|
|
||||||
<Icons.MdSettingsInputSvideo />
|
|
||||||
Usage Tier
|
|
||||||
</div>
|
|
||||||
<div className="value">
|
|
||||||
<antd.Tag>
|
|
||||||
{serverTier}
|
|
||||||
</antd.Tag>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
}
|
|
@ -1,36 +0,0 @@
|
|||||||
.streamingControlPanel {
|
|
||||||
display: inline-flex;
|
|
||||||
flex-direction: column;
|
|
||||||
|
|
||||||
.info {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
|
|
||||||
margin-bottom: 10px;
|
|
||||||
|
|
||||||
.label {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
.value {
|
|
||||||
margin-left: 10px;
|
|
||||||
font-family: "DM Mono", monospace;
|
|
||||||
|
|
||||||
h4 {
|
|
||||||
// select all text
|
|
||||||
user-select: all;
|
|
||||||
margin: 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
> div {
|
|
||||||
margin-bottom: 20px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.streamingKeyString {
|
|
||||||
display: inline-flex;
|
|
||||||
flex-direction: row;
|
|
||||||
align-items: center;
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user