diff options
Diffstat (limited to 'web')
-rw-r--r-- | web/kbn_assets/app.js | 17 | ||||
-rw-r--r-- | web/kbn_assets/inverter.js | 15 | ||||
-rw-r--r-- | web/kbn_templates/inverter.j2 | 20 |
3 files changed, 37 insertions, 15 deletions
diff --git a/web/kbn_assets/app.js b/web/kbn_assets/app.js index eaac003..d575a5a 100644 --- a/web/kbn_assets/app.js +++ b/web/kbn_assets/app.js @@ -349,3 +349,20 @@ var ModemStatus = { } } }; + + +var Inverter = { + poll: function () { + setInterval(this._tick, 1000); + }, + + _tick: function() { + ajax.get('/inverter.ajx') + .then(({response}) => { + if (response) { + var el = document.getElementById('inverter_status'); + el.innerHTML = response.html; + } + }); + } +};
\ No newline at end of file diff --git a/web/kbn_assets/inverter.js b/web/kbn_assets/inverter.js deleted file mode 100644 index 72d985c..0000000 --- a/web/kbn_assets/inverter.js +++ /dev/null @@ -1,15 +0,0 @@ -var Inverter = { - poll: function () { - setInterval(this._tick, 1000); - }, - - _tick: function() { - ajax.get('/inverter/status.ajax') - .then(({response}) => { - if (response) { - var el = document.getElementById('inverter_status'); - el.innerHTML = response.html; - } - }); - } -};
\ 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&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 |