init commit
This commit is contained in:
450
templates/create_room.html
Normal file
450
templates/create_room.html
Normal file
@@ -0,0 +1,450 @@
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Create Room - Video Streaming Server</title>
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
||||
<style>
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
:root {
|
||||
--primary: #667eea;
|
||||
--secondary: #764ba2;
|
||||
--success: #10b981;
|
||||
--danger: #ef4444;
|
||||
--warning: #f59e0b;
|
||||
--info: #3b82f6;
|
||||
--dark: #1f2937;
|
||||
--light: #f9fafb;
|
||||
--gray: #6b7280;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
||||
background: #f3f4f6;
|
||||
color: var(--dark);
|
||||
}
|
||||
|
||||
/* Sidebar */
|
||||
.sidebar {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
height: 100vh;
|
||||
width: 250px;
|
||||
background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
|
||||
color: white;
|
||||
padding: 20px 0;
|
||||
box-shadow: 0 0 20px rgba(0,0,0,0.1);
|
||||
z-index: 1000;
|
||||
}
|
||||
|
||||
.logo {
|
||||
padding: 0 20px 30px;
|
||||
border-bottom: 1px solid rgba(255,255,255,0.1);
|
||||
margin-bottom: 30px;
|
||||
}
|
||||
|
||||
.logo h1 {
|
||||
font-size: 24px;
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
|
||||
.logo p {
|
||||
font-size: 12px;
|
||||
opacity: 0.8;
|
||||
}
|
||||
|
||||
.nav-links {
|
||||
list-style: none;
|
||||
padding: 0 20px;
|
||||
}
|
||||
|
||||
.nav-links li {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.nav-links a {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 12px 15px;
|
||||
color: white;
|
||||
text-decoration: none;
|
||||
border-radius: 5px;
|
||||
transition: background 0.3s;
|
||||
}
|
||||
|
||||
.nav-links a:hover {
|
||||
background: rgba(255,255,255,0.1);
|
||||
}
|
||||
|
||||
.nav-links a.active {
|
||||
background: rgba(255,255,255,0.2);
|
||||
}
|
||||
|
||||
.nav-links i {
|
||||
margin-right: 10px;
|
||||
width: 20px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.back-btn {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 12px 15px;
|
||||
color: white;
|
||||
text-decoration: none;
|
||||
border-radius: 5px;
|
||||
transition: background 0.3s;
|
||||
background: rgba(255,255,255,0.1);
|
||||
margin: 20px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.back-btn:hover {
|
||||
background: rgba(255,255,255,0.2);
|
||||
}
|
||||
|
||||
.back-btn i {
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
/* Main Content */
|
||||
.main-content {
|
||||
margin-left: 250px;
|
||||
padding: 30px;
|
||||
}
|
||||
|
||||
.header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 30px;
|
||||
}
|
||||
|
||||
.header h2 {
|
||||
font-size: 28px;
|
||||
color: var(--dark);
|
||||
}
|
||||
|
||||
/* Form */
|
||||
.form-container {
|
||||
background: white;
|
||||
border-radius: 10px;
|
||||
padding: 30px;
|
||||
box-shadow: 0 5px 15px rgba(0,0,0,0.05);
|
||||
max-width: 600px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.form-group {
|
||||
margin-bottom: 25px;
|
||||
}
|
||||
|
||||
.form-group label {
|
||||
display: block;
|
||||
margin-bottom: 8px;
|
||||
color: var(--gray);
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.form-group input,
|
||||
.form-group select {
|
||||
width: 100%;
|
||||
padding: 12px;
|
||||
border: 1px solid #ddd;
|
||||
border-radius: 5px;
|
||||
font-size: 16px;
|
||||
transition: border-color 0.3s;
|
||||
}
|
||||
|
||||
.form-group input:focus,
|
||||
.form-group select:focus {
|
||||
outline: none;
|
||||
border-color: var(--primary);
|
||||
}
|
||||
|
||||
.form-group .help-text {
|
||||
font-size: 12px;
|
||||
color: var(--gray);
|
||||
margin-top: 5px;
|
||||
}
|
||||
|
||||
.btn {
|
||||
padding: 12px 24px;
|
||||
border: none;
|
||||
border-radius: 5px;
|
||||
cursor: pointer;
|
||||
font-weight: 600;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
transition: all 0.3s;
|
||||
text-decoration: none;
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
.btn-primary {
|
||||
background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
|
||||
color: white;
|
||||
}
|
||||
|
||||
.btn-secondary {
|
||||
background: var(--gray);
|
||||
color: white;
|
||||
}
|
||||
|
||||
.btn:hover {
|
||||
transform: translateY(-2px);
|
||||
box-shadow: 0 5px 15px rgba(0,0,0,0.1);
|
||||
}
|
||||
|
||||
.form-actions {
|
||||
display: flex;
|
||||
gap: 15px;
|
||||
margin-top: 30px;
|
||||
}
|
||||
|
||||
/* Alert */
|
||||
.alert {
|
||||
padding: 15px;
|
||||
border-radius: 5px;
|
||||
margin-bottom: 20px;
|
||||
display: none;
|
||||
}
|
||||
|
||||
.alert-success {
|
||||
background: #d1fae5;
|
||||
color: var(--success);
|
||||
border: 1px solid #a7f3d0;
|
||||
}
|
||||
|
||||
.alert-error {
|
||||
background: #fee2e2;
|
||||
color: var(--danger);
|
||||
border: 1px solid #fecaca;
|
||||
}
|
||||
|
||||
/* Room Preview */
|
||||
.room-preview {
|
||||
background: var(--light);
|
||||
border-radius: 5px;
|
||||
padding: 20px;
|
||||
margin-top: 30px;
|
||||
display: none;
|
||||
}
|
||||
|
||||
.room-preview h4 {
|
||||
margin-bottom: 15px;
|
||||
color: var(--dark);
|
||||
}
|
||||
|
||||
.preview-item {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.preview-item label {
|
||||
display: inline-block;
|
||||
width: 120px;
|
||||
color: var(--gray);
|
||||
}
|
||||
|
||||
/* Responsive */
|
||||
@media (max-width: 768px) {
|
||||
.sidebar {
|
||||
width: 70px;
|
||||
}
|
||||
|
||||
.sidebar .logo h1,
|
||||
.sidebar .logo p,
|
||||
.sidebar .nav-links span,
|
||||
.sidebar .back-btn span {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.sidebar .nav-links a {
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.sidebar .nav-links i {
|
||||
margin-right: 0;
|
||||
font-size: 20px;
|
||||
}
|
||||
|
||||
.sidebar .back-btn {
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.main-content {
|
||||
margin-left: 70px;
|
||||
}
|
||||
|
||||
.form-container {
|
||||
padding: 20px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<!-- Sidebar -->
|
||||
<div class="sidebar">
|
||||
<div class="logo">
|
||||
<h1>🎥 VSS</h1>
|
||||
<p>Video Streaming Server</p>
|
||||
</div>
|
||||
|
||||
<ul class="nav-links">
|
||||
<li>
|
||||
<a href="/dashboard">
|
||||
<i class="fas fa-tachometer-alt"></i>
|
||||
<span>Dashboard</span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="/create-room" class="active">
|
||||
<i class="fas fa-plus-circle"></i>
|
||||
<span>Create Room</span>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<a href="/dashboard" class="back-btn">
|
||||
<i class="fas fa-arrow-left"></i>
|
||||
<span>Back to Dashboard</span>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<!-- Main Content -->
|
||||
<div class="main-content">
|
||||
<!-- Header -->
|
||||
<div class="header">
|
||||
<h2>Create New Room</h2>
|
||||
</div>
|
||||
|
||||
<!-- Alert Messages -->
|
||||
<div id="alert" class="alert"></div>
|
||||
|
||||
<!-- Form -->
|
||||
<div class="form-container">
|
||||
<form id="createRoomForm" method="POST" action="/api/create-room">
|
||||
<div class="form-group">
|
||||
<label for="name">Room Name *</label>
|
||||
<input type="text" id="name" name="name" required
|
||||
placeholder="e.g., Conference Room, Surveillance Camera">
|
||||
<div class="help-text">A descriptive name for the room</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="password">Room Password *</label>
|
||||
<input type="text" id="password" name="password" required
|
||||
placeholder="Enter a secure password">
|
||||
<div class="help-text">Clients will need this password to connect</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="max_connections">Max Connections *</label>
|
||||
<select id="max_connections" name="max_connections" required>
|
||||
<option value="1">1 client</option>
|
||||
<option value="5" selected>5 clients</option>
|
||||
<option value="10">10 clients</option>
|
||||
<option value="20">20 clients</option>
|
||||
<option value="50">50 clients</option>
|
||||
</select>
|
||||
<div class="help-text">Maximum number of clients that can connect simultaneously</div>
|
||||
</div>
|
||||
|
||||
<div class="form-actions">
|
||||
<button type="submit" class="btn btn-primary">
|
||||
<i class="fas fa-plus-circle"></i> Create Room
|
||||
</button>
|
||||
<a href="/dashboard" class="btn btn-secondary">
|
||||
<i class="fas fa-times"></i> Cancel
|
||||
</a>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<!-- Room Preview -->
|
||||
<div id="roomPreview" class="room-preview">
|
||||
<h4>Room Information</h4>
|
||||
<div class="preview-item">
|
||||
<label>Room ID:</label>
|
||||
<span id="previewId">Generating...</span>
|
||||
</div>
|
||||
<div class="preview-item">
|
||||
<label>WebSocket URL:</label>
|
||||
<code id="previewWsUrl">ws://{{ server_host }}:{{ server_port }}/ws/client/...</code>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
document.getElementById('createRoomForm').addEventListener('submit', async function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
const formData = new FormData(this);
|
||||
const alertDiv = document.getElementById('alert');
|
||||
const previewDiv = document.getElementById('roomPreview');
|
||||
|
||||
// Show loading
|
||||
alertDiv.className = 'alert alert-success';
|
||||
alertDiv.style.display = 'block';
|
||||
alertDiv.textContent = 'Creating room...';
|
||||
|
||||
try {
|
||||
const response = await fetch('/api/create-room', {
|
||||
method: 'POST',
|
||||
body: formData
|
||||
});
|
||||
|
||||
const result = await response.json();
|
||||
|
||||
if (result.success) {
|
||||
alertDiv.className = 'alert alert-success';
|
||||
alertDiv.textContent = 'Room created successfully!';
|
||||
|
||||
// Show room preview
|
||||
previewDiv.style.display = 'block';
|
||||
document.getElementById('previewId').textContent = result.room.id;
|
||||
document.getElementById('previewWsUrl').textContent =
|
||||
`ws://${window.location.hostname}:{{ server_port }}/ws/client/${result.room.id}/${result.room.password}`;
|
||||
|
||||
// Clear form
|
||||
this.reset();
|
||||
|
||||
// Redirect to room page after 3 seconds
|
||||
setTimeout(() => {
|
||||
window.location.href = `/room/${result.room.id}`;
|
||||
}, 3000);
|
||||
} else {
|
||||
alertDiv.className = 'alert alert-error';
|
||||
alertDiv.textContent = 'Error: ' + (result.error || 'Failed to create room');
|
||||
}
|
||||
} catch (error) {
|
||||
alertDiv.className = 'alert alert-error';
|
||||
alertDiv.textContent = 'Error: ' + error.message;
|
||||
}
|
||||
});
|
||||
|
||||
// Generate a random password suggestion
|
||||
function generatePassword() {
|
||||
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
||||
let password = '';
|
||||
for (let i = 0; i < 8; i++) {
|
||||
password += chars.charAt(Math.floor(Math.random() * chars.length));
|
||||
}
|
||||
document.getElementById('password').value = password;
|
||||
}
|
||||
|
||||
// Auto-generate password on page load
|
||||
window.addEventListener('load', generatePassword);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user