diff --git a/framework/public/devUI/assets/js/uc_balancing.js b/framework/public/devUI/assets/js/uc_balancing.js index 0d25413..9691e87 100644 --- a/framework/public/devUI/assets/js/uc_balancing.js +++ b/framework/public/devUI/assets/js/uc_balancing.js @@ -1,265 +1,150 @@ $(document).ready(function() { let customLabels = {}; - const balanceRetrieve = (assetId,epoch) => { - window.assetId = assetId; - window.highlightEpoch = 1 * epoch; - - $('.assetLabel').html(window.assetId); - - let epochQuery = ""; - if(epoch) { - epochQuery = "&epoch="+epoch; - } - $.getJSON("/api/balancing/balance?assetId="+assetId+epochQuery,balanceRender); - $.getJSON("/api/asset/get?assetId="+assetId+"&type=balance", function(data) { - if(typeof data.balancerule !== 'undefined') { - if(typeof data.balancerule.from !== 'undefined') { - $('#allocation').val(data.balancerule.from); - $('#direction-from').attr('checked','checked'); - } - if(typeof data.balancerule.to !== 'undefined') { - $('#allocation').val(data.balancerule.to); - $('#direction-to').attr('checked','checked'); - } - } - }); + if($.urlParam('meterId')) { + window.assetId = $.urlParam('meterId'); } + if($.urlParam('assetId')) { + window.assetId = $.urlParam('assetId'); + } + + $.getJSON("/api/tariff/customLabels", function(data) { + customLabels = data; + retrieveBalances(window.assetId); + }) - const showLedger = function() { - const updateTXs = function(assetId,epoch,label) { - $.getJSON("/api/balancing/statements?assetId="+assetId+"&epoch="+epoch+"&label="+label,function(data) { - let openSaldo = 0; - let closeSaldo = 0; - let html = '
'; - html += ' | Von | '; - html += 'An | '; - html += 'Energie | '; - html += ''; - } - let btnclass = 'btn-light'; - if(data[i].from == window.assetId) { - - mult = 1; - } - html_row += ' | '; - - btnclass = 'btn-light'; - - html_row += ' | '; - html_row += ' | ' + (data[i].energy/1000).toFixed(3).replace('.',',') + 'kWh | '; - html_row += ''; - - if(data[i].label == '.clearing') { - closing_rows += html_row; - } else { - opening_rows += html_row; - } - } - html += ''; - html += 'Abschlussbuchungen | '; - html += ''; - html += ''; - html += closing_rows; - html += ''; - html += '
---|---|---|---|---|
Verlauf | '; - html += ''; - html += ''; - html += opening_rows; - html += ''; - - html += '
Von | Nach | Energie | '; + + html += ' | '; + html += ' | '+(data.transactions[i].energy/1000).toFixed(3).replace('.',',')+'kWh | '; + html += ''; } - - $('.filterAsset').html(window.assetId); - $('#txTable').html('...'); - $('#balanceModal').html('...'); - if( ($(this).data('sealed')) && ($(this).data('sealed').length > 0)) { + html += '
---|
Allokation | '; - html += 'Stromprodukt | '; - html += 'Bezug | '; - html += 'Lieferung | '; - html += 'Verlauf | '; - html += ''; - html += ' |
---|---|---|---|---|---|
'+window.assetId+' | '; - html += ''+new Date($(this).attr('data-time')* 1).toLocaleString()+' | '; - html += ''+($(this).attr('data-in')/1000).toFixed(3).replace('.',',')+'kWh | '; - html += ''+($(this).attr('data-out')/1000).toFixed(3).replace('.',',')+'kWh | '; - html += ''+(($(this).attr('data-out') - $(this).attr('data-in'))/1000).toFixed(3).replace('.',',')+'kWh | '; - html += ''; - html += ' |
'; html += ' | Stromprodukt | '; - html += 'Segment | '; - html += 'Bezug | '; - html += 'Einspeisung | '; - html += 'Saldo | '; + html += 'Zeitfenster | '; + html += 'Saldo | '; html += ''; - } else { - data[i].sealed = ""; - html += ' | '; - } - html += ' | '; - html += ' | ' + customLabels[data[i].label] + ' | '; - html += '' + (data[i].in/1000).toFixed(3).replace('.',',') + 'kWh | '; - html += '' + (data[i].out/1000).toFixed(3).replace('.',',') + 'kWh | '; - html += '' + ((data[i].out - data[i].in)/1000).toFixed(3).replace('.',',') + 'kWh | '; - html += ''; + data[i].energy *= -1; // clearerer to interpret. + html += '
---|---|---|---|---|---|---|---|
'; + } else { + html += ' | '; } + html += ' | '; + html += ' | '+new Date(data[i].time).toLocaleString()+' | '; + let color = 'text-danger'; + if(data[i].energy > 0) { + color = 'text-success'; + } + html += ''+(data[i].energy/1000).toFixed(3).replace('.',',')+'kWh | '; + html += '