Merge remote-tracking branch 'origin/251221-webui-redisign' into beta
# Conflicts: # www/index.html # www/links.html # www/main.js
This commit is contained in:
+454
-36
@@ -4,53 +4,451 @@
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>go2rtc</title>
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link href="https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;700&family=Orbitron:wght@700;900&display=swap" rel="stylesheet">
|
||||
<link rel="stylesheet" href="styles.css">
|
||||
<style>
|
||||
/* Page-specific styles for index.html */
|
||||
.controls {
|
||||
background: var(--bg-card);
|
||||
border: 1px solid var(--border-color);
|
||||
border-radius: 8px;
|
||||
padding: 24px;
|
||||
margin-bottom: 32px;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 10px;
|
||||
gap: 20px;
|
||||
align-items: center;
|
||||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
|
||||
}
|
||||
|
||||
.info {
|
||||
color: #888;
|
||||
white-space: pre;
|
||||
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
|
||||
.btn-primary {
|
||||
background: linear-gradient(135deg, var(--accent-cyan), var(--accent-electric));
|
||||
color: var(--bg-primary);
|
||||
border: none;
|
||||
padding: 12px 28px;
|
||||
border-radius: 6px;
|
||||
font-family: 'JetBrains Mono', monospace;
|
||||
font-weight: 700;
|
||||
font-size: 13px;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 1px;
|
||||
cursor: pointer;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
box-shadow: var(--glow-cyan);
|
||||
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
}
|
||||
|
||||
.btn-primary::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
width: 0;
|
||||
height: 0;
|
||||
border-radius: 50%;
|
||||
background: rgba(255, 255, 255, 0.3);
|
||||
transform: translate(-50%, -50%);
|
||||
transition: width 0.6s, height 0.6s;
|
||||
}
|
||||
|
||||
.btn-primary:hover::before {
|
||||
width: 300px;
|
||||
height: 300px;
|
||||
}
|
||||
|
||||
.btn-primary:hover {
|
||||
transform: translateY(-2px);
|
||||
box-shadow: 0 0 30px rgba(0, 217, 255, 0.5);
|
||||
}
|
||||
|
||||
.btn-primary:active {
|
||||
transform: translateY(0);
|
||||
}
|
||||
|
||||
.mode-selector {
|
||||
display: flex;
|
||||
gap: 16px;
|
||||
align-items: center;
|
||||
padding: 12px 20px;
|
||||
background: var(--bg-secondary);
|
||||
border-radius: 6px;
|
||||
border: 1px solid var(--border-color);
|
||||
}
|
||||
|
||||
.mode-label {
|
||||
color: var(--text-muted);
|
||||
text-transform: uppercase;
|
||||
font-size: 11px;
|
||||
letter-spacing: 1px;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.checkbox-wrapper {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
cursor: pointer;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
.checkbox-wrapper input[type="checkbox"] {
|
||||
appearance: none;
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
border: 2px solid var(--border-color);
|
||||
border-radius: 3px;
|
||||
cursor: pointer;
|
||||
position: relative;
|
||||
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
}
|
||||
|
||||
.checkbox-wrapper input[type="checkbox"]:checked {
|
||||
background: var(--accent-cyan);
|
||||
border-color: var(--accent-cyan);
|
||||
box-shadow: var(--glow-cyan);
|
||||
}
|
||||
|
||||
.checkbox-wrapper input[type="checkbox"]:checked::after {
|
||||
content: '✓';
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
color: var(--bg-primary);
|
||||
font-size: 12px;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.checkbox-wrapper label {
|
||||
color: var(--text-secondary);
|
||||
font-size: 12px;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.5px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
/* Table */
|
||||
.streams-table {
|
||||
background: var(--bg-card);
|
||||
border: 1px solid var(--border-color);
|
||||
border-radius: 8px;
|
||||
overflow: hidden;
|
||||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
|
||||
}
|
||||
|
||||
table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
|
||||
thead {
|
||||
background: var(--bg-secondary);
|
||||
border-bottom: 2px solid var(--accent-cyan);
|
||||
}
|
||||
|
||||
th {
|
||||
text-align: left;
|
||||
padding: 16px 20px;
|
||||
font-weight: 700;
|
||||
text-transform: uppercase;
|
||||
font-size: 11px;
|
||||
letter-spacing: 1px;
|
||||
color: var(--accent-cyan);
|
||||
}
|
||||
|
||||
th label {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
td {
|
||||
padding: 16px 20px;
|
||||
border-bottom: 1px solid var(--border-color);
|
||||
}
|
||||
|
||||
tbody tr {
|
||||
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
}
|
||||
|
||||
tbody td:first-child {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
tbody td:first-child::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 0;
|
||||
width: 3px;
|
||||
height: 100%;
|
||||
background: var(--accent-cyan);
|
||||
transform: scaleY(0);
|
||||
transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
}
|
||||
|
||||
tbody tr:hover {
|
||||
background: rgba(0, 217, 255, 0.05);
|
||||
}
|
||||
|
||||
tbody tr:hover td:first-child::before {
|
||||
transform: scaleY(1);
|
||||
}
|
||||
|
||||
tbody tr:last-child td {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
/* Stream name with checkbox */
|
||||
.stream-name {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.stream-name label {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
cursor: pointer;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
/* Live indicator */
|
||||
.online-count {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.live-dot {
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
border-radius: 50%;
|
||||
background: var(--accent-green);
|
||||
box-shadow: var(--glow-green);
|
||||
animation: pulse 2s infinite;
|
||||
}
|
||||
|
||||
@keyframes pulse {
|
||||
0%, 100% { opacity: 1; transform: scale(1); }
|
||||
50% { opacity: 0.6; transform: scale(1.2); }
|
||||
}
|
||||
|
||||
.offline-dot {
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
border-radius: 50%;
|
||||
background: var(--text-muted);
|
||||
}
|
||||
|
||||
.delete-link {
|
||||
color: var(--accent-red);
|
||||
}
|
||||
|
||||
.delete-link:hover {
|
||||
color: #ff6b81;
|
||||
}
|
||||
|
||||
/* Info footer */
|
||||
.info {
|
||||
margin-top: 32px;
|
||||
padding: 20px 24px;
|
||||
background: var(--bg-secondary);
|
||||
border: 1px solid var(--border-color);
|
||||
border-radius: 8px;
|
||||
color: var(--text-muted);
|
||||
font-size: 12px;
|
||||
white-space: pre;
|
||||
font-family: ui-monospace, SFMono-Regular, 'JetBrains Mono', Menlo, Monaco, Consolas, monospace;
|
||||
}
|
||||
|
||||
.info-item {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.info-label {
|
||||
color: var(--accent-cyan);
|
||||
text-transform: uppercase;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
/* Responsive - page specific */
|
||||
@media (max-width: 768px) {
|
||||
.controls {
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
}
|
||||
|
||||
.mode-selector {
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
}
|
||||
|
||||
table, thead, tbody, th, td, tr {
|
||||
display: block;
|
||||
}
|
||||
|
||||
thead {
|
||||
display: none;
|
||||
}
|
||||
|
||||
tr {
|
||||
margin-bottom: 16px;
|
||||
border: 1px solid var(--border-color);
|
||||
border-radius: 8px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
td {
|
||||
position: relative;
|
||||
padding-left: 50%;
|
||||
border: none;
|
||||
border-bottom: 1px solid var(--border-color);
|
||||
}
|
||||
|
||||
td:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
td::before {
|
||||
content: attr(data-label);
|
||||
position: absolute;
|
||||
left: 16px;
|
||||
top: 16px;
|
||||
color: var(--accent-cyan);
|
||||
font-weight: 700;
|
||||
text-transform: uppercase;
|
||||
font-size: 11px;
|
||||
}
|
||||
}
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<script src="main.js"></script>
|
||||
<header>
|
||||
<div class="container">
|
||||
<nav>
|
||||
<span class="logo">GO2RTC</span>
|
||||
<div class="nav-links">
|
||||
<a href="index.html" class="nav-link active">Streams</a>
|
||||
<a href="add.html" class="nav-link">Add Stream</a>
|
||||
<a href="config.html" class="nav-link">Config</a>
|
||||
<a href="log.html" class="nav-link">Logs</a>
|
||||
<a href="net.html" class="nav-link">Network</a>
|
||||
</div>
|
||||
<a href="https://github.com/AlexxIT/go2rtc" target="_blank" class="nav-link docs-link">docs</a>
|
||||
<button class="theme-toggle" id="theme-toggle" aria-label="Toggle theme">
|
||||
<span class="theme-icon">🌙</span>
|
||||
</button>
|
||||
</nav>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<main>
|
||||
<div class="controls">
|
||||
<button>stream</button>
|
||||
modes
|
||||
<label><input type="checkbox" name="webrtc" checked>webrtc</label>
|
||||
<label><input type="checkbox" name="mse" checked>mse</label>
|
||||
<label><input type="checkbox" name="hls" checked>hls</label>
|
||||
<label><input type="checkbox" name="mjpeg" checked>mjpeg</label>
|
||||
<div class="container">
|
||||
<div class="controls">
|
||||
<button class="btn-primary">View Streams</button>
|
||||
<div class="mode-selector">
|
||||
<span class="mode-label">Modes:</span>
|
||||
<label class="checkbox-wrapper">
|
||||
<input type="checkbox" name="webrtc" checked>
|
||||
<span>WebRTC</span>
|
||||
</label>
|
||||
<label class="checkbox-wrapper">
|
||||
<input type="checkbox" name="mse" checked>
|
||||
<span>MSE</span>
|
||||
</label>
|
||||
<label class="checkbox-wrapper">
|
||||
<input type="checkbox" name="hls" checked>
|
||||
<span>HLS</span>
|
||||
</label>
|
||||
<label class="checkbox-wrapper">
|
||||
<input type="checkbox" name="mjpeg" checked>
|
||||
<span>MJPEG</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="streams-table">
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
<label>
|
||||
<input id="selectall" type="checkbox">
|
||||
Stream Name
|
||||
</label>
|
||||
</th>
|
||||
<th>Status</th>
|
||||
<th>Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="streams">
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div class="info"></div>
|
||||
</div>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th><label><input id="selectall" type="checkbox">name</label></th>
|
||||
<th>online</th>
|
||||
<th>commands</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="streams">
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="info"></div>
|
||||
</main>
|
||||
|
||||
<script>
|
||||
// Theme management
|
||||
function initTheme() {
|
||||
const savedTheme = localStorage.getItem('theme');
|
||||
const systemPrefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
|
||||
const theme = savedTheme || (systemPrefersDark ? 'dark' : 'light');
|
||||
|
||||
setTheme(theme);
|
||||
|
||||
// Listen for system theme changes
|
||||
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', (e) => {
|
||||
if (!localStorage.getItem('theme')) {
|
||||
setTheme(e.matches ? 'dark' : 'light');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function setTheme(theme) {
|
||||
const html = document.documentElement;
|
||||
const themeIcon = document.querySelector('.theme-icon');
|
||||
|
||||
if (theme === 'light') {
|
||||
html.setAttribute('data-theme', 'light');
|
||||
if (themeIcon) themeIcon.textContent = '☀️';
|
||||
} else {
|
||||
html.removeAttribute('data-theme');
|
||||
if (themeIcon) themeIcon.textContent = '🌙';
|
||||
}
|
||||
}
|
||||
|
||||
function toggleTheme() {
|
||||
const html = document.documentElement;
|
||||
const currentTheme = html.getAttribute('data-theme') === 'light' ? 'light' : 'dark';
|
||||
const newTheme = currentTheme === 'light' ? 'dark' : 'light';
|
||||
|
||||
setTheme(newTheme);
|
||||
localStorage.setItem('theme', newTheme);
|
||||
}
|
||||
|
||||
// Initialize theme before page loads
|
||||
initTheme();
|
||||
|
||||
// Theme toggle button handler
|
||||
document.getElementById('theme-toggle')?.addEventListener('click', toggleTheme);
|
||||
|
||||
let templates = [
|
||||
'<a href="stream.html?src={name}">stream</a>',
|
||||
'<a href="links.html?src={name}">links</a>',
|
||||
'<a href="#" data-name="{name}">delete</a>',
|
||||
'<a href="#" class="delete-link" data-name="{name}">delete</a>',
|
||||
];
|
||||
let readOnly = false;
|
||||
|
||||
@@ -60,18 +458,18 @@
|
||||
templates = templates.filter(link => link.indexOf('delete') < 0);
|
||||
};
|
||||
|
||||
document.querySelector('.controls > button')
|
||||
document.querySelector('.btn-primary')
|
||||
.addEventListener('click', () => {
|
||||
const url = new URL('stream.html', location.href);
|
||||
|
||||
const streams = document.querySelectorAll('#streams input');
|
||||
const streams = document.querySelectorAll('#streams input[type="checkbox"]');
|
||||
streams.forEach(i => {
|
||||
if (i.checked) url.searchParams.append('src', i.name);
|
||||
if (i.checked && i.name) url.searchParams.append('src', i.name);
|
||||
});
|
||||
|
||||
if (!url.searchParams.has('src')) return;
|
||||
|
||||
let mode = document.querySelectorAll('.controls input');
|
||||
let mode = document.querySelectorAll('.mode-selector input[type="checkbox"]');
|
||||
mode = Array.from(mode).filter(i => i.checked).map(i => i.name).join(',');
|
||||
|
||||
window.location.href = `${url}&mode=${mode}`;
|
||||
@@ -79,7 +477,7 @@
|
||||
|
||||
const tbody = document.getElementById('streams');
|
||||
tbody.addEventListener('click', async ev => {
|
||||
if (ev.target.innerText !== 'delete') return;
|
||||
if (!ev.target.classList.contains('delete-link')) return;
|
||||
|
||||
ev.preventDefault();
|
||||
|
||||
@@ -103,7 +501,7 @@
|
||||
});
|
||||
|
||||
document.getElementById('selectall').addEventListener('change', ev => {
|
||||
document.querySelectorAll('#streams input').forEach(el => {
|
||||
document.querySelectorAll('#streams input[type="checkbox"]').forEach(el => {
|
||||
el.checked = ev.target.checked;
|
||||
});
|
||||
});
|
||||
@@ -125,7 +523,7 @@
|
||||
let tr = tbody.querySelector(`tr[data-id="${name}"]`);
|
||||
const online = value && value.consumers ? value.consumers.length : 0;
|
||||
const src = encodeURIComponent(name);
|
||||
const links = templates.map(link => link.replace('{name}', src)).join(' ');
|
||||
const links = templates.map(link => link.replace('{name}', src)).join('<span class="link-separator">/</span>');
|
||||
|
||||
if (!tr) {
|
||||
tr = document.createElement('tr');
|
||||
@@ -134,10 +532,30 @@
|
||||
}
|
||||
|
||||
const isChecked = checkboxStates[name] ? 'checked' : '';
|
||||
const dotClass = online > 0 ? 'live-dot' : 'offline-dot';
|
||||
|
||||
tr.innerHTML =
|
||||
`<td><label><input type="checkbox" name="${name}" ${isChecked}>${name}</label></td>` +
|
||||
`<td><a href="api/streams?src=${src}">${online} / info</a> / <a href="api/streams?src=${src}&video=all&audio=allµphone">probe</a> / <a href="net.html?src=${src}">net</a></td>` +
|
||||
`<td>${links}</td>`;
|
||||
`<td data-label="Name">
|
||||
<div class="stream-name">
|
||||
<label>
|
||||
<input type="checkbox" name="${name}" ${isChecked}>
|
||||
<span>${name}</span>
|
||||
</label>
|
||||
</div>
|
||||
</td>` +
|
||||
`<td data-label="Status">
|
||||
<div class="online-count">
|
||||
<span class="${dotClass}"></span>
|
||||
${online > 0 ? `<span>${online} viewer${online !== 1 ? 's' : ''}</span>` : '<span>offline</span>'}
|
||||
</div>
|
||||
<span class="link-separator">/</span>
|
||||
<a href="info.html?src=${src}">info</a>
|
||||
<span class="link-separator">/</span>
|
||||
<a href="probe.html?src=${src}">probe</a>
|
||||
<span class="link-separator">/</span>
|
||||
<a href="net.html?src=${src}">network</a>
|
||||
</td>` +
|
||||
`<td data-label="Actions">${links}</td>`;
|
||||
}
|
||||
|
||||
// Remove old rows
|
||||
|
||||
Reference in New Issue
Block a user