Files
VideoCommander/index.html

74 lines
3.0 KiB
HTML

<!DOCTYPE html>
<html style="background-color: #ebe1c7;">
<head>
<title>Video Commander</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
</head>
<script>
async function onclick_processor(name, is_group) {
try {
if (is_group) {
window.location.href = window.location.origin + '/?group=' + encodeURIComponent(name)
} else {
const response = await fetch(
window.location.origin + "/stream",
{
method: "POST",
"headers": {
"Content-Type": "application/json"
},
body: JSON.stringify({ "name": name })
}
)
if (!response.ok) {
throw new Error(`Response status: ${response.status}`)
}
const json = await response.json()
console.log(json)
}
} catch (error) {
console.log(error.message)
}
}
</script>
<body style="background-color: #ebe1c7;">
<div class="container">
<h1 class="text-center">Video Commander Instance {{ instance_name }}</h1>
<hr>
{% if buttons | length != 0 %}
<h3 class="text-center">Current group ({{ current_group }}) streams</h3>
{% for index in range(buttons | length) %}
{% if index % 3 == 0 %}
<div class="row">
{% endif %}
{% set current_name = buttons[index][0] %}
<button class="col-sm-4 btn-default p-3 my-1" onclick="onclick_processor('{{ current_name }}', false)">{{ current_name }}</button>
{% if index + 1 == buttons | length or (index + 1) % 3 == 0 %}
</div>
{% endif %}
{% endfor %}
{% else %}
<p>There are no stream buttons in this group</p>
{% endif %}
{% if groups | length != 0 %}
<h3 class="text-center">Current group ({{ current_group }}) sub-groups</h3>
{% for index in range(groups | length) %}
{% if index % 3 == 0 %}
<div class="row">
{% endif %}
{% set current_name = groups[index][0] %}
<button class="col-sm-4 btn-default p-3 my-1" onclick="onclick_processor('{{ current_name }}', true)">{{ current_name }}</button>
{% if index + 1 == groups | length or (index + 1) % 3 == 0 %}
</div>
{% endif %}
{% endfor %}
{% endif %}
<hr>
</div>
</body>
</html>