diff options
author | Evgeny Zinoviev <me@ch1p.io> | 2024-02-19 01:44:02 +0300 |
---|---|---|
committer | Evgeny Zinoviev <me@ch1p.io> | 2024-02-19 01:44:11 +0300 |
commit | 3741f7cf78a288e967415ccb6736c888a21c211b (patch) | |
tree | a48d8331c9936d6c108de4d0f9179a089b1e56e6 /web/kbn_templates | |
parent | d79309e498cdc1358c81367ce2a93a5731e517d1 (diff) |
web_kbn: almost completely ported lws to python
Diffstat (limited to 'web/kbn_templates')
-rw-r--r-- | web/kbn_templates/base.j2 | 2 | ||||
-rw-r--r-- | web/kbn_templates/index.j2 | 6 | ||||
-rw-r--r-- | web/kbn_templates/routing_dhcp.j2 | 14 | ||||
-rw-r--r-- | web/kbn_templates/routing_header.j2 | 19 | ||||
-rw-r--r-- | web/kbn_templates/routing_main.j2 | 19 | ||||
-rw-r--r-- | web/kbn_templates/routing_rules.j2 | 30 |
6 files changed, 86 insertions, 4 deletions
diff --git a/web/kbn_templates/base.j2 b/web/kbn_templates/base.j2 index dc1fd58..53a2984 100644 --- a/web/kbn_templates/base.j2 +++ b/web/kbn_templates/base.j2 @@ -1,7 +1,7 @@ {% macro breadcrumbs(history) %} <nav aria-label="breadcrumb"> <ol class="breadcrumb"> - <li class="breadcrumb-item"><a href="main.cgi">{{ "main"|lang }}</a></li> + <li class="breadcrumb-item"><a href="/main.cgi">{{ "main"|lang }}</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 %} diff --git a/web/kbn_templates/index.j2 b/web/kbn_templates/index.j2 index e246dc5..cd40819 100644 --- a/web/kbn_templates/index.j2 +++ b/web/kbn_templates/index.j2 @@ -17,15 +17,15 @@ <h6>{{ "internet"|lang }}</h6> <ul class="list-group list-group-flush"> <li class="list-group-item"><a href="/modems.cgi">{{ "modems"|lang }}</a></li> - <li class="list-group-item"><a href="/routing.cgi">{{ "routing"|lang }}</a></li> + <li class="list-group-item"><a href="/routing/main.cgi">{{ "routing"|lang }}</a></li> <li class="list-group-item"><a href="/sms.cgi">{{ "sms"|lang }}</a></li> </ul> <h6 class="mt-4">{{ "misc"|lang }}</h6> <ul class="list-group list-group-flush"> <li class="list-group-item"><a href="/inverter.cgi">{{ "inverter"|lang }}</a> (<a href="{{ inverter_grafana_url }}">Grafana</a>)</li> - <li class="list-group-item"><a href="/pump.cgi">{{ "pump"|lang }}</a></li> - <li class="list-group-item"><a href="/sensors.cgi">{{ "sensors"|lang }}</a> (<a href="{{ sensors_grafana_url }}">Grafana</a>)</li> +{# <li class="list-group-item"><a href="/pump.cgi">{{ "pump"|lang }}</a></li>#} +{# <li class="list-group-item"><a href="/sensors.cgi">{{ "sensors"|lang }}</a> (<a href="{{ sensors_grafana_url }}">Grafana</a>)</li>#} </ul> <nav class="mt-4"> diff --git a/web/kbn_templates/routing_dhcp.j2 b/web/kbn_templates/routing_dhcp.j2 new file mode 100644 index 0000000..c8a3e8e --- /dev/null +++ b/web/kbn_templates/routing_dhcp.j2 @@ -0,0 +1,14 @@ +{% extends "base.j2" %} + +{% block content %} +{% include 'routing_header.j2' %} + +{% for lease in leases %} + <div class="mt-3"> + <b>{{ lease.hostname }}</b> <span class="text-secondary">(exp: {{ lease.time_s }})</span><br/> + {{ lease.ip }}<br> + <span class="text-secondary">{{ lease.mac }}</span> + </div> +{% endfor %} + +{% endblock %}
\ No newline at end of file diff --git a/web/kbn_templates/routing_header.j2 b/web/kbn_templates/routing_header.j2 new file mode 100644 index 0000000..527f154 --- /dev/null +++ b/web/kbn_templates/routing_header.j2 @@ -0,0 +1,19 @@ +{{ breadcrumbs([{'text': 'routing'|lang}]) }} + +{% set routing_tabs = [ + {'tab': 'main', 'url': '/routing/main.cgi', 'label': 'routing_main'|lang}, + {'tab': 'rules', 'url': '/routing/rules.cgi', 'label': 'routing_rules'|lang}, + {'tab': 'dhcp', 'url': '/routing/dhcp.cgi', 'label': 'DHCP'} +] %} + +<nav> + <div class="nav nav-tabs" id="nav-tab"> + {% for tab in routing_tabs %} + <a href="{{ tab.url }}" class="text-decoration-none"><button class="nav-link{% if tab.tab == selected_tab %} active{% endif %}" type="button">{{ tab.label }}</button></a> + {% endfor %} + </div> +</nav> + +{% if error %} + <div class="mt-4 alert alert-danger"><b>{{ "error"|lang }}:</b> {{ error }}</div> +{% endif %} diff --git a/web/kbn_templates/routing_main.j2 b/web/kbn_templates/routing_main.j2 new file mode 100644 index 0000000..856da78 --- /dev/null +++ b/web/kbn_templates/routing_main.j2 @@ -0,0 +1,19 @@ +{% extends "base.j2" %} + +{% block content %} +{% include 'routing_header.j2' %} + +<div class="mt-3 mb-3"> + {{ "routing_current_upstream"|lang }}: <b>{{ (upstream|lang('modems'))['full'] }}</b> +</div> + +{% for modem in modems %} + {% if modem != upstream %} + <div class="pt-1 pb-2"> + <a href="/routing/main.cgi?set-upstream-to={{ modem }}"> + <button type="button" class="btn btn-primary">{{ "routing_switch_to"|lang }} <b>{{ (modem|lang('modems'))['full'] }}</b></button> + </a> + </div> + {% endif %} +{% endfor %} +{% endblock %}
\ No newline at end of file diff --git a/web/kbn_templates/routing_rules.j2 b/web/kbn_templates/routing_rules.j2 new file mode 100644 index 0000000..61b68c9 --- /dev/null +++ b/web/kbn_templates/routing_rules.j2 @@ -0,0 +1,30 @@ +{% extends "base.j2" %} + +{% block content %} +{% include 'routing_header.j2' %} + +<div class="mt-2 text-secondary">{{ "routing_iptables_note"|lang }}</div> + +{% for set, ips in sets.items() %} + <h6 class="text-primary mt-4">{{ set }}</h6> + + {% if ips %} + {% for ip in ips %} + <div>{{ ip }} (<a href="/routing/rules.cgi?action=del&set={{ set }}&ip={{ ip }}" onclick="return confirm('{{ 'routing_deleting_confirmation'|lang|format(ip, set) }}')">{{ "routing_del"|lang }}</a>)</div> + {% endfor %} + {% else %} + <span class="text-secondary">{{ "routing_no_records"|lang }}</span> + {% endif %} + + <div style="max-width: 300px"> + <form method="get" action="/routing/rules.cgi"> + <input type="hidden" name="action" value="add"> + <input type="hidden" name="set" value="{{ set }}"> + <div class="input-group mt-2"> + <input type="text" name="ip" placeholder="x.x.x.x/y" class="form-control"> + <button type="submit" class="btn btn-outline-primary">{{ "routing_add"|lang }}</button> + </div> + </form> + </div> +{% endfor %} +{% endblock %}
\ No newline at end of file |