Initial commit: LiveStream Platform
Backend: FastAPI + SQLAlchemy + SQLite Frontend: React + Vite + Ant Design (serif Anthropic theme) Media server: MediaMTX with edge node support Load balancing: round-robin / weighted / least-conn Multicast detection with automatic fallback Transcoding support via FFmpeg (configurable quality) hls.js player with line & quality switching Admin panel with password auth Windows compatible scripts
This commit is contained in:
commit
2e4594fa77
43 files changed
+2196
No files matched your search
@@ -0,0 +1,84 @@
|
||||
import { useState, useEffect } from 'react'
|
||||
import {
|
||||
Card, Select, Switch, Typography, message, Space, Descriptions, Button,
|
||||
} from 'antd'
|
||||
import api from '../../api/client'
|
||||
|
||||
const { Title } = Typography
|
||||
|
||||
const strategies = [
|
||||
{ value: 'round-robin', label: 'Round Robin' },
|
||||
{ value: 'weighted', label: 'Weighted' },
|
||||
{ value: 'least-conn', label: 'Least Connections' },
|
||||
]
|
||||
|
||||
export default function SettingsPage() {
|
||||
const [strategy, setStrategy] = useState('weighted')
|
||||
const [multicastEnabled, setMulticastEnabled] = useState(true)
|
||||
const [multicastAvailable, setMulticastAvailable] = useState(false)
|
||||
const [saving, setSaving] = useState(false)
|
||||
|
||||
useEffect(() => {
|
||||
loadSettings()
|
||||
}, [])
|
||||
|
||||
async function loadSettings() {
|
||||
try {
|
||||
const { data } = await api.get('/nodes/strategy')
|
||||
setStrategy(data.strategy)
|
||||
setMulticastEnabled(data.multicast_enabled)
|
||||
setMulticastAvailable(data.multicast_available)
|
||||
} catch { /* ignore */ }
|
||||
}
|
||||
|
||||
async function saveStrategy(val: string) {
|
||||
setSaving(true)
|
||||
try {
|
||||
await api.put(`/nodes/strategy?strategy=${val}&multicast_enabled=${multicastEnabled}`)
|
||||
setStrategy(val)
|
||||
message.success('Strategy updated')
|
||||
} catch { message.error('Failed') }
|
||||
setSaving(false)
|
||||
}
|
||||
|
||||
async function toggleMulticast(val: boolean) {
|
||||
setMulticastEnabled(val)
|
||||
try {
|
||||
await api.put(`/nodes/strategy?strategy=${strategy}&multicast_enabled=${val}`)
|
||||
message.success('Multicast setting updated')
|
||||
} catch { message.error('Failed') }
|
||||
}
|
||||
|
||||
return (
|
||||
<div style={{ maxWidth: 720 }}>
|
||||
<Title level={3} style={{ marginBottom: 24 }}>Settings</Title>
|
||||
|
||||
<Card title="Load Balancing" style={{ marginBottom: 24 }}>
|
||||
<Descriptions column={1} labelStyle={{ width: 180 }}>
|
||||
<Descriptions.Item label="Strategy">
|
||||
<Select
|
||||
value={strategy}
|
||||
onChange={saveStrategy}
|
||||
options={strategies}
|
||||
loading={saving}
|
||||
style={{ width: 240 }}
|
||||
/>
|
||||
</Descriptions.Item>
|
||||
</Descriptions>
|
||||
</Card>
|
||||
|
||||
<Card title="Multicast">
|
||||
<Descriptions column={1} labelStyle={{ width: 180 }}>
|
||||
<Descriptions.Item label="Enable Multicast">
|
||||
<Switch checked={multicastEnabled} onChange={toggleMulticast} />
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="Network Status">
|
||||
<span style={{ color: multicastAvailable ? '#52c41a' : '#999' }}>
|
||||
{multicastAvailable ? 'Available' : 'Unavailable (fallback to unicast)'}
|
||||
</span>
|
||||
</Descriptions.Item>
|
||||
</Descriptions>
|
||||
</Card>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
Reference in new issue
Block a user