Skip to content

Commit d6900a6

Browse files
Layout verbeteren #912
1 parent 9264789 commit d6900a6

File tree

7 files changed

+103
-99
lines changed

7 files changed

+103
-99
lines changed

dsmr_frontend/static/dsmr_frontend/css/dsmr-reader/global.css

+9
Original file line numberDiff line numberDiff line change
@@ -78,4 +78,13 @@ div.search_help {
7878
clear: left;
7979
color: gray;
8080
font-size: xx-small;
81+
}
82+
83+
tr > th {
84+
/* Remove weird duplicate border on top. */
85+
border-top: none !important;
86+
}
87+
88+
tr.live-header > th {
89+
padding-bottom: 30px !important;
8190
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
function update_consumption_header()
2+
{
3+
$("#header-loader").show();
4+
5+
$.ajax({
6+
dataType: "json",
7+
url: xhr_consumption_header_url,
8+
}).done(function(response) {
9+
$("#header-loader").hide();
10+
$("#latest_timestamp").html(response.timestamp);
11+
$("#latest_electricity").html(response.currently_delivered);
12+
$("#latest_electricity_returned").html(response.currently_returned);
13+
$("#tariff_name").html(response.tariff_name);
14+
15+
if (response.cost_per_hour)
16+
{
17+
$("#cost_per_hour").html(response.cost_per_hour).show();
18+
}
19+
});
20+
}

dsmr_frontend/static/dsmr_frontend/js/dsmr-reader/global.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ $('a').click(function (event) {
44
event.preventDefault();
55
location.href = $(this).attr('href');
66
}
7-
});
7+
});

dsmr_frontend/templates/dsmr_frontend/dashboard.html

+40-43
Original file line numberDiff line numberDiff line change
@@ -16,24 +16,20 @@
1616
</div>
1717
{% endif %}
1818

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" %} &nbsp; <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" %} &nbsp; <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>
3329
</div>
34-
35-
{% include "dsmr_frontend/includes/xhr-consumption-header.html" %}
30+
</div>
3631
</div>
32+
{% endif %}
3733

3834
{% if capabilities.electricity or capabilities.electricity_returned or capabilities.gas %}
3935
<div class="row consumption-block">
@@ -44,15 +40,34 @@
4440
&nbsp;&nbsp;&nbsp;
4541
<div class="pull-right">
4642
<a class="btn btn-sm btn-primary" href="{% url 'frontend:live-graphs' %}"><i class="fas fa-chart-line"></i></a>
47-
</div>
4843
</header>
4944
<div class="panel-body">
5045
<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">&euro;{% trans '/hour' %}</span>
63+
{% endif %}
64+
</th>
65+
</tr>
5166
<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">&euro;</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">&euro;</span></td>
5671
</tr>
5772
{% if frontend_settings.merge_electricity_tariffs %}<tr>
5873
<td>{% if capabilities.electricity %}{% trans "Electricity (single tariff)" %} <span class="unit">{% trans "kWh" noop %}</span>{% endif %}</td>
@@ -170,34 +185,16 @@
170185
{% block javascript %}
171186
{{ block.super }}
172187

188+
<script type="text/javascript" src="{% static 'dsmr_frontend/js/dsmr-reader/consumption-header.js' %}?r=v{{ dsmr_version }}"></script>
173189
<script type="text/javascript">
190+
var xhr_consumption_header_url = "{% url 'frontend:xhr-consumption-header' %}";
191+
174192
$(document).ready(function(){
175-
setInterval(function(){ update_header(); }, 1000);
193+
setInterval(function(){ update_consumption_header(); }, 1000);
176194

177195
/* Reload entire page after 5 minutes. */
178196
setInterval(function(){ location.reload(); }, 5 * 60 * 1000)
179197
});
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 + " &euro;{% trans '/hour' %}").show();
198-
}
199-
});
200-
}
201198
</script>
202199

203200
{% endblock %}

dsmr_frontend/templates/dsmr_frontend/includes/xhr-consumption-header.html

-22
This file was deleted.

dsmr_frontend/templates/dsmr_frontend/live-graphs.html

+27-27
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,6 @@
1616
</div>
1717
{% endif %}
1818

19-
<div class="row">
20-
<div class="col-sm-8"></div>
21-
{% include "dsmr_frontend/includes/xhr-consumption-header.html" %}
22-
</div>
23-
2419
{% if capabilities.electricity %}
2520
<div class="row">
2621
<div class="col-sm-12">
@@ -29,6 +24,29 @@
2924
{% trans "Recent electricity consumption" %}
3025
</header>
3126
<div class="panel-body">
27+
<table class="table table-hover">
28+
<tr class="live-header">
29+
<th class="col-sm-6">
30+
<span id="latest_timestamp"><i class="fas fa-circle-notch fa-spin fa-fw"></i></span> <span class="unit" id="tariff_name"></span>
31+
</th>
32+
<th class="col-sm-2">
33+
{% if capabilities.electricity %}
34+
<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>
35+
{% endif %}
36+
</th>
37+
<th class="col-sm-2">
38+
{% if capabilities.electricity_returned %}
39+
<span class="badge bg-green" id="latest_electricity_returned"></span> <span class="unit">{% trans "W" %}</span>
40+
{% endif %}
41+
</th>
42+
<th class="col-sm-2">
43+
{% if capabilities.electricity %}
44+
<span class="xhr-hidden badge bg-black" id="cost_per_hour"></span> <span class="unit">&euro;{% trans '/hour' %}</span>
45+
{% endif %}
46+
</th>
47+
</tr>
48+
</table>
49+
3250
<div id="echarts-electricity-graph" style="width: 100%; height: 300px;"></div>
3351
<div class="graph_controls_help">{% blocktrans %}Scroll or pinch the graph to zoom in and out. To change the current point in time, drag the graph sideways, or use the scrollbar/control below the graph.{% endblocktrans %}</div>
3452
</div>
@@ -208,34 +226,16 @@
208226
<script type="text/javascript" src="{% static 'dsmr_frontend/js/dsmr-reader/live/temperature.js' %}?r=v{{ dsmr_version }}"></script>
209227
{% endif %}
210228

229+
<script type="text/javascript" src="{% static 'dsmr_frontend/js/dsmr-reader/consumption-header.js' %}?r=v{{ dsmr_version }}"></script>
211230
<script type="text/javascript">
231+
var xhr_consumption_header_url = "{% url 'frontend:xhr-consumption-header' %}";
232+
212233
$(document).ready(function(){
213-
setInterval(function(){ update_header(); }, 1000);
234+
setInterval(function(){ update_consumption_header(); }, 1000);
214235

215236
/* Reload entire page after 15 minutes. */
216237
setInterval(function(){ location.reload(); }, 15 * 60 * 1000)
217238
});
218-
219-
function update_header()
220-
{
221-
$("#header-loader").show();
222-
223-
$.ajax({
224-
dataType: "json",
225-
url: "{% url 'frontend:xhr-consumption-header' %}",
226-
}).done(function(response) {
227-
$("#header-loader").hide();
228-
$("#latest_timestamp").html('(' + response.timestamp + ')');
229-
$("#latest_electricity").html(response.currently_delivered);
230-
$("#latest_electricity_returned").html(response.currently_returned);
231-
$("#tariff_name").html(response.tariff_name);
232-
233-
if (response.cost_per_hour)
234-
{
235-
$("#cost_per_hour").html(response.cost_per_hour + " &euro;{% trans '/hour' %}").show();
236-
}
237-
});
238-
}
239239
</script>
240240

241241
{% endblock %}

dsmrreader/locales/nl/LC_MESSAGES/django.po

+6-6
Original file line numberDiff line numberDiff line change
@@ -1165,6 +1165,12 @@ msgstr "Ongelezen notificaties"
11651165
msgid "Go to notification overview"
11661166
msgstr "Ga naar notificatieoverzicht"
11671167

1168+
msgid "W"
1169+
msgstr "W"
1170+
1171+
msgid "/hour"
1172+
msgstr "/uur"
1173+
11681174
msgid "Consumed"
11691175
msgstr "Verbruikt"
11701176

@@ -1192,9 +1198,6 @@ msgstr "tot en met gisteren"
11921198
msgid "The totals for the current month are currently not (yet) available. Check again tomorrow."
11931199
msgstr "De totalen voor de huidige maand zijn momenteel (nog) niet beschikbaar. Probeer het morgen nogmaals."
11941200

1195-
msgid "/hour"
1196-
msgstr "/uur"
1197-
11981201
msgid "Please note that the data displayed here only includes the energy price and is likely to differ from the bill of your energy supplier."
11991202
msgstr "N.B.: De gegevens die hier getoond worden zijn alleen gebaseerd op de energieprijzen en verschillen zeer waarschijnlijk van je energierekening."
12001203

@@ -1276,9 +1279,6 @@ msgstr "Gem"
12761279
msgid "Difference"
12771280
msgstr "Verschil"
12781281

1279-
msgid "W"
1280-
msgstr "W"
1281-
12821282
msgid "Recent electricity consumption"
12831283
msgstr "Recent elektriciteitsverbruik"
12841284

0 commit comments

Comments
 (0)