Skip to content

Commit

Permalink
Increment: Adding switch between cost and revenue in PWA (customer in…
Browse files Browse the repository at this point in the history
…terface).
  • Loading branch information
zoernert committed Jan 28, 2024
1 parent e68058a commit 46f41d6
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
9 changes: 9 additions & 0 deletions framework/public_pwa/assets/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,16 @@ const app = async function(token) {
});

$.getJSON("/api/debit/open?meterId="+window.meterId+"&token="+token, function(data) {
let totalConsumption = 0;

// Handling "Abrechnung Übersicht in Zeile"
for (let [key, value] of Object.entries(data)) {
if(key.indexOf('cost') == 0) {
$('.'+key).html(value.toFixed(2).replace('.',','));
}
if(key.indexOf('consumption') == 0) {
$('.'+key).html((value/1000).toFixed(3).replace('.',','));
totalConsumption += value * 1;
}
}
$('.consumption').html((data.consumption/1000).toFixed(3).replace('.',','));
Expand Down Expand Up @@ -347,6 +350,12 @@ const app = async function(token) {
})

$.getJSON("/api/access/getAssetMeta?meterId="+window.meterId+"&token="+token, function(data) {
if(typeof data.balancerule !== 'undefined') {
if(typeof data.balancerule.to !== 'undefined') {
$('.kosten').html("Einnahmen");
$('.verbrauch').html("Einspeisung");
}
}
let customName = window.meterId;
if(typeof data.operationMeta !== 'undefined') {
if(typeof data.operationMeta.meterPointName !== 'undefined') {
Expand Down
6 changes: 3 additions & 3 deletions framework/public_pwa/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,10 @@ <h5 class="text-center card-title"><span class="consumption">-</span>kWh /&nbsp;
</div>
<div class="row" style="margin-bottom: 35px;">
<div class="col-sm-12 col-md-12 col-lg-6 col-xl-6 col-xxl-6 text-center">
<h5 class="text-center card-title">Verbrauch</h5><canvas id="consumptionChart"></canvas>
<h5 class="text-center card-title verbrauch">Verbrauch</h5><canvas id="consumptionChart"></canvas>
</div>
<div class="col-sm-12 col-md-12 col-lg-6 col-xl-6 col-xxl-6 text-center">
<h5 class="text-center card-title">Kosten</h5><canvas id="costChart"></canvas>
<h5 class="text-center card-title kosten">Kosten</h5><canvas id="costChart"></canvas>
</div>
</div>
<div class="row" style="margin-bottom: 35px;">
Expand Down Expand Up @@ -175,7 +175,7 @@ <h4 class="modal-title">Anmeldung</h4><button class="btn-close" type="button" ar
<script src="/assets/js/3party/zoom.js?h=a2c095af13b21a0342de04621079a5db"></script>
<script src="/assets/js/3party/datalabels.js?h=4babdfc4369820b10f76762bfbc021c4"></script>
<script src="/assets/js/3party/editable.js?h=1d014573023a54df6bf1660cc3431371"></script>
<script src="/assets/js/index.js?h=87b89d896b8d074ec0c1f85979052363"></script>
<script src="/assets/js/index.js?h=01effd45a0d5838d6565593fb75793f2"></script>
</body>

</html>
2 changes: 1 addition & 1 deletion framework/services/access.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ module.exports = {
verifyOptions.expiresIn = process.env.JWT_EXPIRE_METERING;
const token = jwt.verify(ctx.params.token,process.env.JWT_PUBLICKEY, verifyOptions);
delete ctx.params.token;
const result = await ctx.call("asset.get",{assetId:token.meterId,type:'meter'});
const result = await ctx.call("asset.get",{assetId:token.meterId}); // Removes ,type:'meter'
return result;
}
}
Expand Down

0 comments on commit 46f41d6

Please sign in to comment.