summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--localwebsite/config.php3
-rw-r--r--localwebsite/handlers/MiscHandler.php20
-rw-r--r--localwebsite/htdocs/index.php13
-rw-r--r--localwebsite/templates-web/cams.twig4
-rw-r--r--localwebsite/templates-web/index.twig8
5 files changed, 37 insertions, 11 deletions
diff --git a/localwebsite/config.php b/localwebsite/config.php
index 57ff739..b1e7553 100644
--- a/localwebsite/config.php
+++ b/localwebsite/config.php
@@ -66,6 +66,9 @@ return [
'high' => [
// fill me with names
],
+ 'labels' => [
+ // assoc array
+ ],
],
'vk_sms_checker' => [
diff --git a/localwebsite/handlers/MiscHandler.php b/localwebsite/handlers/MiscHandler.php
index 10817e1..2c2eb76 100644
--- a/localwebsite/handlers/MiscHandler.php
+++ b/localwebsite/handlers/MiscHandler.php
@@ -9,6 +9,7 @@ class MiscHandler extends RequestHandler
$this->tpl->set([
'grafana_sensors_url' => $config['grafana_sensors_url'],
'grafana_inverter_url' => $config['grafana_inverter_url'],
+ 'cameras' => $config['cam_list']['labels']
]);
$this->tpl->render_page('index.twig');
}
@@ -52,7 +53,17 @@ class MiscHandler extends RequestHandler
public function GET_cams() {
global $config;
- list($hls_debug, $video_events, $high) = $this->input('b:hls_debug, b:video_events, b:high');
+ list($hls_debug, $video_events, $high, $camera_ids) = $this->input('b:hls_debug, b:video_events, b:high, id');
+ if ($camera_ids != '') {
+ $camera_param = $camera_ids;
+ $camera_ids = explode(',', $camera_ids);
+ $camera_ids = array_filter($camera_ids);
+ $camera_ids = array_map('trim', $camera_ids);
+ $camera_ids = array_map('intval', $camera_ids);
+ } else {
+ $camera_ids = array_keys($config['cam_list']['labels']);
+ $camera_param = '';
+ }
$tab = $high ? 'high' : 'low';
@@ -78,13 +89,18 @@ class MiscHandler extends RequestHandler
if ($hls_key)
setcookie_safe('hls_key', $hls_key);
+ $cam_filter = function($id) use ($config, $camera_ids) {
+ return in_array($id, $camera_ids);
+ };
+
$this->tpl->set([
'hls_host' => $hls_host,
'hls_proto' => $hls_proto,
'hls_opts' => $hls_opts,
'hls_access_key' => $config['cam_hls_access_key'],
- 'cams' => $config['cam_list'][$tab],
+ 'camera_param' => $camera_param,
+ 'cams' => array_values(array_filter($config['cam_list'][$tab], $cam_filter)),
'tab' => $tab,
'video_events' => $video_events
]);
diff --git a/localwebsite/htdocs/index.php b/localwebsite/htdocs/index.php
index d1fc0fd..e249fc6 100644
--- a/localwebsite/htdocs/index.php
+++ b/localwebsite/htdocs/index.php
@@ -23,12 +23,13 @@ $router->add('inverter/set-osp/', 'Inverter set_osp');
$router->add('inverter/status.ajax', 'Inverter status_ajax');
// misc
-$router->add('/', 'Misc main');
-$router->add('sensors/', 'Misc sensors_page');
-$router->add('pump/', 'Misc pump_page');
-$router->add('phpinfo/', 'Misc phpinfo');
-$router->add('cams/', 'Misc cams');
-$router->add('debug/', 'Misc debug');
+$router->add('/', 'Misc main');
+$router->add('sensors/', 'Misc sensors_page');
+$router->add('pump/', 'Misc pump_page');
+$router->add('phpinfo/', 'Misc phpinfo');
+$router->add('cams/', 'Misc cams');
+$router->add('cams/([\d,]+)/', 'Misc cams id=$(1)');
+$router->add('debug/', 'Misc debug');
// auth
$router->add('auth/', 'Auth auth');
diff --git a/localwebsite/templates-web/cams.twig b/localwebsite/templates-web/cams.twig
index 9079a52..523e27c 100644
--- a/localwebsite/templates-web/cams.twig
+++ b/localwebsite/templates-web/cams.twig
@@ -6,8 +6,8 @@
<nav>
<div class="nav nav-tabs" id="nav-tab">
- <a href="/cams/" class="text-decoration-none"><button class="nav-link{% if tab == 'low' %} active{% endif %}" type="button">Low-res</button></a>
- <a href="/cams/?high=1" class="text-decoration-none"><button class="nav-link{% if tab == 'high' %} active{% endif %}" type="button">High-res</button></a>
+ <a href="/cams/{{ camera_param ? camera_param~"/" : "" }}" class="text-decoration-none"><button class="nav-link{% if tab == 'low' %} active{% endif %}" type="button">Low-res</button></a>
+ <a href="/cams/{{ camera_param ? camera_param~"/" : "" }}?high=1" class="text-decoration-none"><button class="nav-link{% if tab == 'high' %} active{% endif %}" type="button">High-res</button></a>
</div>
</nav>
diff --git a/localwebsite/templates-web/index.twig b/localwebsite/templates-web/index.twig
index 4527911..19cc367 100644
--- a/localwebsite/templates-web/index.twig
+++ b/localwebsite/templates-web/index.twig
@@ -23,6 +23,12 @@
<li class="list-group-item"><a href="/inverter/">Инвертор</a> (<a href="{{ grafana_inverter_url }}">Grafana</a>)</li>
<li class="list-group-item"><a href="/pump/">Насос</a></li>
<li class="list-group-item"><a href="/sensors/">Датчики</a> (<a href="{{ grafana_sensors_url }}">Grafana</a>)</li>
- <li class="list-group-item"><a href="/cams/">Камеры</a></li>
+ </ul>
+
+ <h6 class="mt-4"><a href="/cams/"><b>Все камеры</b></a> (<a href="/cams/?high=1">HQ</a>)</h6>
+ <ul class="list-group list-group-flush">
+ {% for id, name in cameras %}
+ <li class="list-group-item"><a href="/cams/{{ id }}/">{{ name }}</a> (<a href="/cams/{{ id }}/?high=1">HQ</a>)</li>
+ {% endfor %}
</ul>
</div> \ No newline at end of file