summaryrefslogtreecommitdiff
path: root/web/kbn_templates
diff options
context:
space:
mode:
authorEvgeny Zinoviev <me@ch1p.io>2024-02-17 02:48:57 +0300
committerEvgeny Zinoviev <me@ch1p.io>2024-02-17 02:48:57 +0300
commitb7f1d55c9b4de4d21b11e5615a5dc8be0d4e883c (patch)
treedf3cba57518e21590d579b014867611002d92de5 /web/kbn_templates
parentc4ace358182d1f58724336714490e3caac6b60df (diff)
parent05c85757b8e2340441057d9ddfde2e9649ae8676 (diff)
Merge branch 'website-python-rewrite'
Diffstat (limited to 'web/kbn_templates')
-rw-r--r--web/kbn_templates/base.j244
-rw-r--r--web/kbn_templates/index.j239
-rw-r--r--web/kbn_templates/inverter.j220
-rw-r--r--web/kbn_templates/loading.j214
-rw-r--r--web/kbn_templates/modem_data.j213
-rw-r--r--web/kbn_templates/modem_verbose.j218
-rw-r--r--web/kbn_templates/modems.j216
-rw-r--r--web/kbn_templates/pump.j217
-rw-r--r--web/kbn_templates/signal_level.j25
-rw-r--r--web/kbn_templates/sms.j263
10 files changed, 249 insertions, 0 deletions
diff --git a/web/kbn_templates/base.j2 b/web/kbn_templates/base.j2
new file mode 100644
index 0000000..e2e29e3
--- /dev/null
+++ b/web/kbn_templates/base.j2
@@ -0,0 +1,44 @@
+{% macro breadcrumbs(history) %}
+ <nav aria-label="breadcrumb">
+ <ol class="breadcrumb">
+ <li class="breadcrumb-item"><a href="main.cgi">Главная</a></li>
+ {% for item in history %}
+ <li class="breadcrumb-item"{% if loop.last %} aria-current="page"{% endif %}>
+ {% if item.link %}<a href="{{ item.link }}">{% endif %}
+ {% if item.html %}
+ {% raw %}{{ item.html }}{% endraw %}
+ {% else %}
+ {{ item.text }}
+ {% endif %}
+ {% if item.link %}</a>{% endif %}
+ </li>
+ {% endfor %}
+ </ol>
+ </nav>
+{% endmacro %}
+
+<!doctype html>
+<html>
+<head>
+ <title>{{ title }}</title>
+ <meta http-equiv="content-type" content="text/html; charset=utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
+ <script>
+ window.onerror = function(error) {
+ window.console && console.error(error);
+ }
+ </script>
+ {{ head_static | safe }}
+</head>
+<body>
+<div class="container py-3">
+
+{% block content %}{% endblock %}
+
+<script>
+{% block js %}{% endblock %}
+</script>
+
+</div>
+</body>
+</html>
diff --git a/web/kbn_templates/index.j2 b/web/kbn_templates/index.j2
new file mode 100644
index 0000000..c356326
--- /dev/null
+++ b/web/kbn_templates/index.j2
@@ -0,0 +1,39 @@
+{% extends "base.j2" %}
+
+{% block content %}
+<div class="container py-4">
+ <nav aria-label="breadcrumb">
+ <ol class="breadcrumb">
+ <li class="breadcrumb-item active" aria-current="page">Главная</li>
+ </ol>
+ </nav>
+
+<!-- {% if auth_user %}-->
+<!-- <div class="mb-4 alert alert-secondary">-->
+<!-- Вы авторизованы как <b>{{ auth_user.username }}</b>. <a href="/deauth/">Выйти</a>-->
+<!-- </div>-->
+<!-- {% endif %}-->
+
+ <h6>Интернет</h6>
+ <ul class="list-group list-group-flush">
+ <li class="list-group-item"><a href="/modems.cgi">Модемы</a></li>
+ <li class="list-group-item"><a href="/routing.cgi">Маршрутизация</a></li>
+ <li class="list-group-item"><a href="/sms.cgi">SMS-сообщения</a></li>
+ </ul>
+
+ <h6 class="mt-4">Другое</h6>
+ <ul class="list-group list-group-flush">
+ <li class="list-group-item"><a href="/inverter.cgi">Инвертор</a> (<a href="{{ inverter_grafana_url }}">Grafana</a>)</li>
+ <li class="list-group-item"><a href="/pump.cgi">Насос</a></li>
+ <li class="list-group-item"><a href="/sensors.cgi">Датчики</a> (<a href="{{ sensors_grafana_url }}">Grafana</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 %}
+ <li class="list-group-item"><a href="/cams/stat/">Статистика</a></li>
+ </ul>
+</div>
+{% endblock %} \ No newline at end of file
diff --git a/web/kbn_templates/inverter.j2 b/web/kbn_templates/inverter.j2
new file mode 100644
index 0000000..26491f3
--- /dev/null
+++ b/web/kbn_templates/inverter.j2
@@ -0,0 +1,20 @@
+{% extends "base.j2" %}
+
+{% block content %}
+{{ breadcrumbs([{'text': 'Инвертор'}]) }}
+
+<h6 class="text-primary">Статус</h6>
+<div id="inverter_status">
+ {{ html|safe }}
+</div>
+
+<div class="pt-3">
+ <a href="/inverter.cgi?do=set-osp&amp;value={{ 'sub' if rated.output_source_priority == 'Solar-Battery-Utility' else 'sbu' }}">
+ <button type="button" class="btn btn-primary">Переключить на <b>{{ 'Solar-Utility-Battery' if rated.output_source_priority == 'Solar-Battery-Utility' else 'Solar-Battery-Utility' }}</b></button>
+ </a>
+</div>
+{% endblock %}
+
+{% block js %}
+Inverter.poll();
+{% endblock %} \ No newline at end of file
diff --git a/web/kbn_templates/loading.j2 b/web/kbn_templates/loading.j2
new file mode 100644
index 0000000..d064a48
--- /dev/null
+++ b/web/kbn_templates/loading.j2
@@ -0,0 +1,14 @@
+<div class="sk-fading-circle">
+ <div class="sk-circle1 sk-circle"></div>
+ <div class="sk-circle2 sk-circle"></div>
+ <div class="sk-circle3 sk-circle"></div>
+ <div class="sk-circle4 sk-circle"></div>
+ <div class="sk-circle5 sk-circle"></div>
+ <div class="sk-circle6 sk-circle"></div>
+ <div class="sk-circle7 sk-circle"></div>
+ <div class="sk-circle8 sk-circle"></div>
+ <div class="sk-circle9 sk-circle"></div>
+ <div class="sk-circle10 sk-circle"></div>
+ <div class="sk-circle11 sk-circle"></div>
+ <div class="sk-circle12 sk-circle"></div>
+</div> \ No newline at end of file
diff --git a/web/kbn_templates/modem_data.j2 b/web/kbn_templates/modem_data.j2
new file mode 100644
index 0000000..7f97b77
--- /dev/null
+++ b/web/kbn_templates/modem_data.j2
@@ -0,0 +1,13 @@
+{% with level=modem_data.level %}
+ <span class="text-secondary">Сигнал:</span> {% include 'signal_level.j2' %}<br>
+{% endwith %}
+
+<span class="text-secondary">Тип сети:</span> <b>{{ modem_data.type }}</b><br>
+<span class="text-secondary">RSSI:</span> {{ modem_data.rssi }}<br/>
+{% if modem_data.sinr %}
+<span class="text-secondary">SINR:</span> {{ modem_data.sinr }}<br/>
+{% endif %}
+<span class="text-secondary">Время соединения:</span> {{ modem_data.connected_time }}<br>
+<span class="text-secondary">Принято/передано:</span> {{ modem_data.downloaded }} / {{ modem_data.uploaded }}
+<br>
+<a href="/modems/verbose.cgi?id={{ modem }}">Подробная информация</a>
diff --git a/web/kbn_templates/modem_verbose.j2 b/web/kbn_templates/modem_verbose.j2
new file mode 100644
index 0000000..7c6c930
--- /dev/null
+++ b/web/kbn_templates/modem_verbose.j2
@@ -0,0 +1,18 @@
+{% extends "base.j2" %}
+
+{% block content %}
+{{ breadcrumbs([
+ {'link': '/modems.cgi', 'text': "Модемы"},
+ {'text': modem_name}
+]) }}
+
+{% for item in data %}
+ {% set item_name = item[0] %}
+ {% set item_data = item[1] %}
+ <h6 class="text-primary mt-4">{{ item_name }}</h6>
+ {% for k, v in item_data.items() %}
+ {{ k }} = {{ v }}<br>
+ {% endfor %}
+{% endfor %}
+
+{% endblock %} \ No newline at end of file
diff --git a/web/kbn_templates/modems.j2 b/web/kbn_templates/modems.j2
new file mode 100644
index 0000000..06339f8
--- /dev/null
+++ b/web/kbn_templates/modems.j2
@@ -0,0 +1,16 @@
+{% extends "base.j2" %}
+
+{% block content %}
+{{ breadcrumbs([{'text': 'Модемы'}]) }}
+
+{% for modem in modems %}
+<h6 class="text-primary{% if not loop.first %} mt-4{% endif %}">{{ modems.getfullname(modem) }}</h6>
+<div id="modem_data_{{ modem }}">
+ {% include "loading.j2" %}
+</div>
+{% endfor %}
+{% endblock %}
+
+{% block js %}
+ModemStatus.init({{ modems.getkeys()|tojson }});
+{% endblock %}
diff --git a/web/kbn_templates/pump.j2 b/web/kbn_templates/pump.j2
new file mode 100644
index 0000000..28d5c9d
--- /dev/null
+++ b/web/kbn_templates/pump.j2
@@ -0,0 +1,17 @@
+{% extends "base.j2" %}
+
+{% block content %}
+{{ breadcrumbs([{'text': 'Насос'}]) }}
+
+<form action="/pump.cgi" method="get">
+ <input type="hidden" name="set" value="{{ 'off' if status == 'on' else 'on' }}" />
+ Сейчас насос
+ {% if status == 'on' %}
+ <span class="text-success"><b>включен</b></span>.<br><br>
+ <button type="submit" class="btn btn-primary">Выключить</button>
+ {% else %}
+ <span class="text-danger"><b>выключен</b></span>.<br><br>
+ <button type="submit" class="btn btn-primary">Включить</button>
+ {% endif %}
+</form>
+{% endblock %}
diff --git a/web/kbn_templates/signal_level.j2 b/web/kbn_templates/signal_level.j2
new file mode 100644
index 0000000..93c9abf
--- /dev/null
+++ b/web/kbn_templates/signal_level.j2
@@ -0,0 +1,5 @@
+<div class="signal_level">
+ {% for i in range(5) %}
+ <div{% if i < level %} class="yes"{% endif %}></div>
+ {% endfor %}
+</div> \ No newline at end of file
diff --git a/web/kbn_templates/sms.j2 b/web/kbn_templates/sms.j2
new file mode 100644
index 0000000..6de9d42
--- /dev/null
+++ b/web/kbn_templates/sms.j2
@@ -0,0 +1,63 @@
+{% extends "base.j2" %}
+
+{% block content %}
+{{ breadcrumbs([{'text': 'SMS-сообщения'}]) }}
+
+<nav>
+ <div class="nav nav-tabs" id="nav-tab">
+ {% for modem in modems.keys() %}
+ {% if selected_modem != modem %}<a href="/sms.cgi?id={{ modem }}" class="text-decoration-none">{% endif %}
+ <button class="nav-link{% if modem == selected_modem %} active{% endif %}" type="button">{{ modems.getshortname(modem) }}</button>
+ {% if selected_modem != modem %}</a>{% endif %}
+ {% endfor %}
+ </div>
+</nav>
+
+<h6 class="text-primary mt-4">Отправить SMS</h6>
+
+{% if is_sent %}
+ <div class="alert alert-success" role="alert">
+ Сообщение отправлено.
+ </div>
+{% elif error %}
+ <div class="alert alert-danger" role="alert">
+ {{ error }}
+ </div>
+{% endif %}
+
+<div>
+ <form method="post" action="/sms.cgi">
+ <input type="hidden" name="modem" value="{{ selected_modem }}">
+ <div class="form-floating mb-3">
+ <input type="text" name="phone" class="form-control" id="inputPhone" placeholder="+7911xxxyyzz">
+ <label for="inputPhone">Телефон</label>
+ </div>
+ <div class="form-floating">
+ <textarea class="form-control" id="inputTA" name="text" placeholder="Hello world" style="height: 100px"></textarea>
+ <label for="inputTA">Текст сообщения</label>
+ </div>
+ <div class="mt-3">
+ <button type="submit" class="btn btn-primary">Отправить</button>
+ </div>
+ </form>
+</div>
+
+<h6 class="text-primary mt-4">
+ Последние
+ {% if not is_outbox %}
+ <b>входящие</b> <span class="text-black-50">|</span> <a href="/sms.cgi?id={{ selected_modem }}&amp;outbox=1">исходящие</a>
+ {% else %}
+ <a href="/sms.cgi?id={{ selected_modem }}">входящие</a> <span class="text-black-50">|</span> <b>исходящие</b>
+ {% endif %}
+</h6>
+
+{% for m in messages %}
+ <div class="mt-3">
+ <b>{{ m.Phone }}</b> <span class="text-secondary">({{ m.Date }})</span><br/>
+ {{ m.Content }}
+ </div>
+{% else %}
+ <span class="text-secondary">Сообщений нет.</span>
+{% endfor %}
+
+{% endblock %} \ No newline at end of file