From 77fcc7cfb4306d54fc2d7e24deab226a42ae2f3b Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Wed, 16 Mar 2011 17:51:54 +0100 Subject: [PATCH] added extra column for costs --- htdocs/frontend/index.html | 3 ++- htdocs/frontend/javascripts/entity.js | 28 +++++++++++++++------------ 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/htdocs/frontend/index.html b/htdocs/frontend/index.html index 61fb065..43f4db9 100644 --- a/htdocs/frontend/index.html +++ b/htdocs/frontend/index.html @@ -77,8 +77,9 @@ Min. Max. ∅ + aktuell Verbrauch - akt. + Kosten Aktion diff --git a/htdocs/frontend/javascripts/entity.js b/htdocs/frontend/javascripts/entity.js index 0cd9ce0..f2d170a 100644 --- a/htdocs/frontend/javascripts/entity.js +++ b/htdocs/frontend/javascripts/entity.js @@ -155,8 +155,9 @@ Entity.prototype.getRow = function() { .append($('').addClass('min')) // min .append($('').addClass('max')) // max .append($('').addClass('average')) // avg + .append($('').addClass('last')) // last value .append($('').addClass('consumption')) // consumption - .append($('').addClass('last')) // last + .append($('').addClass('cost')) // costs .append($('') // operations .addClass('ops') .append($('') @@ -214,21 +215,23 @@ Entity.prototype.loadData = function() { // update details in table $('#entity-' + this.uuid + ' .min') - .text(vz.wui.formatNumber(this.data.min[1]) + this.definition.unit) - .attr('title', $.plot.formatDate(new Date(this.data.min[0]), '%d. %b %h:%M:%S', vz.options.plot.xaxis.monthNames)); + .text(vz.wui.formatNumber(this.data.min[1]) + ' ' + this.definition.unit) + .attr('title', $.plot.formatDate(new Date(this.data.min[0] + vz.options.timezoneOffset), '%d. %b %h:%M:%S', vz.options.plot.xaxis.monthNames)); $('#entity-' + this.uuid + ' .max') - .text(vz.wui.formatNumber(this.data.max[1]) + this.definition.unit) - .attr('title', $.plot.formatDate(new Date(this.data.max[0]), '%d. %b %h:%M:%S', vz.options.plot.xaxis.monthNames)); + .text(vz.wui.formatNumber(this.data.max[1]) + ' ' + this.definition.unit) + .attr('title', $.plot.formatDate(new Date(this.data.max[0] + vz.options.timezoneOffset), '%d. %b %h:%M:%S', vz.options.plot.xaxis.monthNames)); $('#entity-' + this.uuid + ' .average') - .text(vz.wui.formatNumber(this.data.average) + this.definition.unit); + .text(vz.wui.formatNumber(this.data.average) + ' ' + this.definition.unit); $('#entity-' + this.uuid + ' .last') - .text(vz.wui.formatNumber(this.data.tuples.last()[1]) + this.definition.unit); + .text(vz.wui.formatNumber(this.data.tuples.last()[1]) + ' ' + this.definition.unit); if (this.definition.interpreter == 'Volkszaehler\\Interpreter\\MeterInterpreter') { // sensors have no consumption - var consumption = vz.wui.formatNumber((this.data.consumption > 1000) ? this.data.consumption / 1000 : this.data.consumption); - var unit = ((this.data.consumption > 1000) ? ' k' : ' ') + this.definition.unit + 'h'; - var cost = (this.cost !== undefined) ? ' (' + vz.wui.formatNumber(this.cost * this.data.consumption) + ' €)' : ''; - - $('#entity-' + this.uuid + ' .consumption').text(consumption + unit + cost); + $('#entity-' + this.uuid + ' .consumption').text( + vz.wui.formatNumber((this.data.consumption > 1000) ? this.data.consumption / 1000 : this.data.consumption) + + ((this.data.consumption > 1000) ? ' k' : ' ') + this.definition.unit + 'h' + ); + } + if (this.cost !== undefined) { + $('#entity-' + this.uuid + ' .cost').text(vz.wui.formatNumber(this.cost * this.data.consumption) + ' €'); } } else { // no data available, clear table @@ -237,6 +240,7 @@ Entity.prototype.loadData = function() { $('#entity-' + this.uuid + ' .average').text(''); $('#entity-' + this.uuid + ' .last').text(''); $('#entity-' + this.uuid + ' .consumption').text(''); + $('#entity-' + this.uuid + ' .cost').text(''); } } });