Nearly done rework of the whole application to add groups
This commit is contained in:
65
index.html
65
index.html
@@ -1,5 +1,5 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<html style="background-color: #ebe1c7;">
|
||||
<head>
|
||||
<title>Video Commander</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
@@ -7,45 +7,68 @@
|
||||
<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) {
|
||||
async function onclick_processor(name, is_group) {
|
||||
try {
|
||||
const response = await fetch(
|
||||
window.location.origin + "/stream",
|
||||
{
|
||||
method: "POST",
|
||||
"headers": {
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
body: JSON.stringify({ "name": name })
|
||||
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}`)
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`Response status: ${response.status}`)
|
||||
const json = await response.json()
|
||||
console.log(json)
|
||||
}
|
||||
|
||||
const json = await response.json()
|
||||
console.log(json)
|
||||
} catch (error) {
|
||||
console.log(error.message)
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<body>
|
||||
<body style="background-color: #ebe1c7;">
|
||||
<div class="container">
|
||||
<h1 class="text-center">Video Commander Instance {{ instance_name }}</h1>
|
||||
<h3 class="text-center">Which video stream do you want to show?</h3>
|
||||
<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]["name"] %}
|
||||
<button class="col-sm-4 btn-default p-3 my-1" onclick="onclick_processor('{{ current_name }}')">{{ current_name }}</button>
|
||||
{% 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>
|
||||
Reference in New Issue
Block a user