From 8212feaa6e05735eb54a681ec8aed55c60bd7b57 Mon Sep 17 00:00:00 2001 From: Evgeny Zinoviev Date: Sun, 25 Dec 2022 11:25:17 +0300 Subject: lws: update cam interface --- localwebsite/config.php | 3 +++ localwebsite/handlers/MiscHandler.php | 20 ++++++++++++++++++-- localwebsite/htdocs/index.php | 13 +++++++------ localwebsite/templates-web/cams.twig | 4 ++-- localwebsite/templates-web/index.twig | 8 +++++++- 5 files changed, 37 insertions(+), 11 deletions(-) (limited to 'localwebsite') 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 @@ 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 @@
  • Инвертор (Grafana)
  • Насос
  • Датчики (Grafana)
  • -
  • Камеры
  • + + +
    Все камеры (HQ)
    + \ No newline at end of file -- cgit v1.2.3