|
16 | 16 | </div>
|
17 | 17 | {% endif %}
|
18 | 18 |
|
19 |
| - <div class="row"> |
20 |
| - <div class="col-sm-8"> |
21 |
| - {% if notification_count > 0 %} |
22 |
| - <div class="panel header-panel"> |
23 |
| - <header class="panel-heading"> |
24 |
| - {% trans "Unread notifications" %} <span |
25 |
| - class="badge bg-blue">{{ notification_count }}</span> |
26 |
| - </header> |
27 |
| - <div class="panel-body"> |
28 |
| - <a class="btn btn-sm btn-primary" href="{% url 'frontend:notifications' %}"><i |
29 |
| - class="fas fa-external-link-alt"></i> {% trans "Go to notification overview" %}</a> |
30 |
| - </div> |
31 |
| - </div> |
32 |
| - {% endif %} |
| 19 | + {% if notification_count > 0 %} |
| 20 | + <div class="row"> |
| 21 | + <div class="col-sm-12"> |
| 22 | + <div class="panel header-panel"> |
| 23 | + <header class="panel-heading"> |
| 24 | + {% trans "Unread notifications" %} <span class="badge bg-blue">{{ notification_count }}</span> |
| 25 | + </header> |
| 26 | + <div class="panel-body"> |
| 27 | + <a class="btn btn-sm btn-primary" href="{% url 'frontend:notifications' %}"><i class="fas fa-external-link-alt"></i> {% trans "Go to notification overview" %}</a> |
| 28 | + </div> |
33 | 29 | </div>
|
34 |
| - |
35 |
| - {% include "dsmr_frontend/includes/xhr-consumption-header.html" %} |
| 30 | + </div> |
36 | 31 | </div>
|
| 32 | + {% endif %} |
37 | 33 |
|
38 | 34 | {% if capabilities.electricity or capabilities.electricity_returned or capabilities.gas %}
|
39 | 35 | <div class="row consumption-block">
|
|
44 | 40 |
|
45 | 41 | <div class="pull-right">
|
46 | 42 | <a class="btn btn-sm btn-primary" href="{% url 'frontend:live-graphs' %}"><i class="fas fa-chart-line"></i></a>
|
47 |
| - </div> |
48 | 43 | </header>
|
49 | 44 | <div class="panel-body">
|
50 | 45 | <table class="table table-hover">
|
| 46 | + <tr class="live-header"> |
| 47 | + <th class="col-sm-6"> |
| 48 | + <span id="latest_timestamp"><i class="fas fa-circle-notch fa-spin fa-fw"></i></span> <span class="unit" id="tariff_name"></span> |
| 49 | + </th> |
| 50 | + <th class="col-sm-2"> |
| 51 | + {% if capabilities.electricity %} |
| 52 | + <span class="badge bg-red" id="latest_electricity"><i class="fas fa-circle-notch fa-spin fa-fw"></i></span> <span class="unit">{% trans "W" %}</span> |
| 53 | + {% endif %} |
| 54 | + </th> |
| 55 | + <th class="col-sm-2"> |
| 56 | + {% if capabilities.electricity_returned %} |
| 57 | + <span class="badge bg-green" id="latest_electricity_returned"></span> <span class="unit">{% trans "W" %}</span> |
| 58 | + {% endif %} |
| 59 | + </th> |
| 60 | + <th class="col-sm-2"> |
| 61 | + {% if capabilities.electricity %} |
| 62 | + <span class="xhr-hidden badge bg-black" id="cost_per_hour"></span> <span class="unit">€{% trans '/hour' %}</span> |
| 63 | + {% endif %} |
| 64 | + </th> |
| 65 | + </tr> |
51 | 66 | <tr>
|
52 |
| - <th class="col-sm-6"></th> |
53 |
| - <th class="col-sm-2">{% if capabilities.electricity %}{% trans "Consumed" %}{% endif %}</th> |
54 |
| - <th class="col-sm-2">{% if capabilities.electricity_returned %}{% trans "Returned" %}{% endif %}</th> |
55 |
| - <th class="col-sm-2">{% trans "Costs" %} <span class="unit">€</span></th> |
| 67 | + <td></td> |
| 68 | + <td>{% if capabilities.electricity %}{% trans "Consumed" %}{% endif %}</td> |
| 69 | + <td>{% if capabilities.electricity_returned %}{% trans "Returned" %}{% endif %}</td> |
| 70 | + <td>{% trans "Costs" %} <span class="unit">€</span></td> |
56 | 71 | </tr>
|
57 | 72 | {% if frontend_settings.merge_electricity_tariffs %}<tr>
|
58 | 73 | <td>{% if capabilities.electricity %}{% trans "Electricity (single tariff)" %} <span class="unit">{% trans "kWh" noop %}</span>{% endif %}</td>
|
|
170 | 185 | {% block javascript %}
|
171 | 186 | {{ block.super }}
|
172 | 187 |
|
| 188 | + <script type="text/javascript" src="{% static 'dsmr_frontend/js/dsmr-reader/consumption-header.js' %}?r=v{{ dsmr_version }}"></script> |
173 | 189 | <script type="text/javascript">
|
| 190 | + var xhr_consumption_header_url = "{% url 'frontend:xhr-consumption-header' %}"; |
| 191 | + |
174 | 192 | $(document).ready(function(){
|
175 |
| - setInterval(function(){ update_header(); }, 1000); |
| 193 | + setInterval(function(){ update_consumption_header(); }, 1000); |
176 | 194 |
|
177 | 195 | /* Reload entire page after 5 minutes. */
|
178 | 196 | setInterval(function(){ location.reload(); }, 5 * 60 * 1000)
|
179 | 197 | });
|
180 |
| - |
181 |
| - function update_header() |
182 |
| - { |
183 |
| - $("#header-loader").show(); |
184 |
| - |
185 |
| - $.ajax({ |
186 |
| - dataType: "json", |
187 |
| - url: "{% url 'frontend:xhr-consumption-header' %}", |
188 |
| - }).done(function(response) { |
189 |
| - $("#header-loader").hide(); |
190 |
| - $("#latest_timestamp").html('(' + response.timestamp + ')'); |
191 |
| - $("#latest_electricity").html(response.currently_delivered); |
192 |
| - $("#latest_electricity_returned").html(response.currently_returned); |
193 |
| - $("#tariff_name").html(response.tariff_name); |
194 |
| - |
195 |
| - if (response.cost_per_hour) |
196 |
| - { |
197 |
| - $("#cost_per_hour").html(response.cost_per_hour + " €{% trans '/hour' %}").show(); |
198 |
| - } |
199 |
| - }); |
200 |
| - } |
201 | 198 | </script>
|
202 | 199 |
|
203 | 200 | {% endblock %}
|
0 commit comments