Skip to content

Commit

Permalink
Feat: UI Upgrade to match to new balancing concept. Allows to navigat…
Browse files Browse the repository at this point in the history
…e through balances from near history.
  • Loading branch information
zoernert committed Jan 19, 2024
1 parent c6ade19 commit 422b6df
Show file tree
Hide file tree
Showing 11 changed files with 163 additions and 263 deletions.
349 changes: 117 additions & 232 deletions framework/public/devUI/assets/js/uc_balancing.js

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion framework/public/devUI/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
<li class="nav-item"><a class="nav-link" href="uc_tariff.html">Tarif</a></li>
<li class="nav-item"><a class="nav-link" href="uc_settlement.html">Settlement</a></li>
<li class="nav-item"><a class="nav-link" href="uc_assets.html">Kennungen</a></li>
<li class="nav-item"><a class="nav-link" href="uc_balancing.html">Bilanzierung</a></li>
<li class="nav-item col-6" style="padding-left: 15px;">
<form class="ms-auto" action="./uc_assets.html" method="get">
<div class="input-group"><input class="form-control" type="search" id="searchMeter" name="meterId" required="" minlength="2" autocomplete="on" autofocus=""><button class="btn btn-dark" type="submit"><i class="fa fa-search"></i></button></div>
Expand Down
1 change: 0 additions & 1 deletion framework/public/devUI/uc_assets.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
<li class="nav-item"><a class="nav-link" href="uc_tariff.html">Tarif</a></li>
<li class="nav-item"><a class="nav-link" href="uc_settlement.html">Settlement</a></li>
<li class="nav-item"><a class="nav-link" href="uc_assets.html">Kennungen</a></li>
<li class="nav-item"><a class="nav-link" href="uc_balancing.html">Bilanzierung</a></li>
<li class="nav-item col-6" style="padding-left: 15px;">
<form class="ms-auto" action="./uc_assets.html" method="get">
<div class="input-group"><input class="form-control" type="search" id="searchMeter" name="meterId" required="" minlength="2" autocomplete="on" autofocus=""><button class="btn btn-dark" type="submit"><i class="fa fa-search"></i></button></div>
Expand Down
17 changes: 8 additions & 9 deletions framework/public/devUI/uc_balancing.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
<li class="nav-item"><a class="nav-link" href="uc_tariff.html">Tarif</a></li>
<li class="nav-item"><a class="nav-link" href="uc_settlement.html">Settlement</a></li>
<li class="nav-item"><a class="nav-link" href="uc_assets.html">Kennungen</a></li>
<li class="nav-item"><a class="nav-link" href="uc_balancing.html">Bilanzierung</a></li>
<li class="nav-item col-6" style="padding-left: 15px;">
<form class="ms-auto" action="./uc_assets.html" method="get">
<div class="input-group"><input class="form-control" type="search" id="searchMeter" name="meterId" required="" minlength="2" autocomplete="on" autofocus=""><button class="btn btn-dark" type="submit"><i class="fa fa-search"></i></button></div>
Expand All @@ -37,20 +36,20 @@
<h3>
<div class="btn-group float-end" role="group"><button class="btn btn-dark" id="backBtn" type="button"><i class="fa fa-backward"></i></button><button class="btn btn-dark" id="fwdBtn" type="button"><i class="fa fa-forward"></i></button></div>Energie Bilanz:&nbsp;<span class="assetLabel">-</span>
</h3>
<div id="epochbalance"></div>
<div id="balances"></div>
</div>
</div>
<form id="balancerule">
<div class="card" style="margin-bottom: 25px;">
<div class="card-body">
<h3>Bilanzierungsregel:&nbsp;<span class="assetLabel">-</span>&nbsp;</h3>
<h3>Ausgleich:&nbsp;<span class="assetLabel">-</span>&nbsp;</h3>
<div class="row" style="margin-bottom: 15px;">
<div class="col">
<div class="form-check"><input class="form-check-input" type="radio" id="direction-from" name="direction" checked="" value="in"><label class="form-check-label" for="direction-from">Bezug von</label></div>
<div class="form-check"><input class="form-check-input" type="radio" id="direction-to" name="direction" value="out"><label class="form-check-label" for="direction-to">Einspeisung für</label></div>
</div>
<div class="col-8">
<div class="input-group"><span class="input-group-text">Allokation</span><input class="form-control" type="text" id="allocation" required="" minlength="2" name="allocation" value="eaf_general"></div>
<div class="input-group"><span class="input-group-text">Allokation</span><input class="form-control" type="text" id="allocation" required="" minlength="2" name="allocation" value="eaf_generic_balancegroup"></div>
</div>
</div><button class="btn btn-dark float-end" id="btnRule" type="submit"><i class="fa fa-floppy-o" style="margin-right: 5px;"></i>speichern</button>
</div>
Expand Down Expand Up @@ -85,14 +84,14 @@ <h4 class="modal-title" id="helpTitle">Modal Title</h4><button class="btn-close"
</div>
</footer>
</div>
<div class="modal fade" role="dialog" tabindex="-1" id="modalStatement">
<div class="modal fade" role="dialog" tabindex="-1" id="modalTransactions">
<div class="modal-dialog modal-xl modal-dialog-scrollable" role="document">
<div class="modal-content">
<div class="modal-header">
<div id="balanceModal"></div><button class="btn btn-warning float-end" id="sealBtn" type="button"><i class="fa fa-unlock-alt"></i></button><button class="btn-close" type="button" aria-label="Close" data-bs-dismiss="modal"></button>
<div class="modal-header"><button class="btn btn-warning" id="sealBtn" type="button" style="margin-right: 5px;"><i class="fa fa-unlock-alt"></i></button>
<h3 id="balanceHeader">-</h3><button class="btn-close" type="button" aria-label="Close" data-bs-dismiss="modal"></button>
</div>
<div class="modal-body">
<h4 class="modal-title">Transaktionen<button class="btn btn-danger btn-sm float-end" id="deactivatedFilter" type="button" style="margin-left: 15px;"><i class="fa fa-filter"></i>&nbsp; </button><button class="btn btn-success btn-sm float-end" id="activeFilter" type="button" style="margin-left: 15px;"><i class="fa fa-filter"></i>&nbsp; <span class="filterAsset">-</span></button></h4>
<h4 class="modal-title">Transaktionen</h4>
<div id="txTable"></div>
</div>
</div>
Expand All @@ -102,7 +101,7 @@ <h4 class="modal-title">Transaktionen<button class="btn btn-danger btn-sm float-
<script src="assets/bootstrap/js/bootstrap.min.js?h=e55bde7d6e36ebf17ba0b8c1e80e4065"></script>
<script src="assets/js/utils.js?h=b6a1e690b2a987d9af7e9692dff15273"></script>
<script src="assets/js/3party/marked.min.js?h=26085551a49dd1635b48b42f08c3d583"></script>
<script src="assets/js/uc_balancing.js?h=37c127e533314626b4b8d922059c65bb"></script>
<script src="assets/js/uc_balancing.js?h=ca77b222a15a00074d687eaaf376c896"></script>
</body>

</html>
1 change: 0 additions & 1 deletion framework/public/devUI/uc_clearing.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
<li class="nav-item"><a class="nav-link" href="uc_tariff.html">Tarif</a></li>
<li class="nav-item"><a class="nav-link" href="uc_settlement.html">Settlement</a></li>
<li class="nav-item"><a class="nav-link" href="uc_assets.html">Kennungen</a></li>
<li class="nav-item"><a class="nav-link" href="uc_balancing.html">Bilanzierung</a></li>
<li class="nav-item col-6" style="padding-left: 15px;">
<form class="ms-auto" action="./uc_assets.html" method="get">
<div class="input-group"><input class="form-control" type="search" id="searchMeter" name="meterId" required="" minlength="2" autocomplete="on" autofocus=""><button class="btn btn-dark" type="submit"><i class="fa fa-search"></i></button></div>
Expand Down
1 change: 0 additions & 1 deletion framework/public/devUI/uc_concentrator.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
<li class="nav-item"><a class="nav-link" href="uc_tariff.html">Tarif</a></li>
<li class="nav-item"><a class="nav-link" href="uc_settlement.html">Settlement</a></li>
<li class="nav-item"><a class="nav-link" href="uc_assets.html">Kennungen</a></li>
<li class="nav-item"><a class="nav-link" href="uc_balancing.html">Bilanzierung</a></li>
<li class="nav-item col-6" style="padding-left: 15px;">
<form class="ms-auto" action="./uc_assets.html" method="get">
<div class="input-group"><input class="form-control" type="search" id="searchMeter" name="meterId" required="" minlength="2" autocomplete="on" autofocus=""><button class="btn btn-dark" type="submit"><i class="fa fa-search"></i></button></div>
Expand Down
1 change: 0 additions & 1 deletion framework/public/devUI/uc_energyprofile.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
<li class="nav-item"><a class="nav-link" href="uc_tariff.html">Tarif</a></li>
<li class="nav-item"><a class="nav-link" href="uc_settlement.html">Settlement</a></li>
<li class="nav-item"><a class="nav-link" href="uc_assets.html">Kennungen</a></li>
<li class="nav-item"><a class="nav-link" href="uc_balancing.html">Bilanzierung</a></li>
<li class="nav-item col-6" style="padding-left: 15px;">
<form class="ms-auto" action="./uc_assets.html" method="get">
<div class="input-group"><input class="form-control" type="search" id="searchMeter" name="meterId" required="" minlength="2" autocomplete="on" autofocus=""><button class="btn btn-dark" type="submit"><i class="fa fa-search"></i></button></div>
Expand Down
1 change: 0 additions & 1 deletion framework/public/devUI/uc_meterreading.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
<li class="nav-item"><a class="nav-link" href="uc_tariff.html">Tarif</a></li>
<li class="nav-item"><a class="nav-link" href="uc_settlement.html">Settlement</a></li>
<li class="nav-item"><a class="nav-link" href="uc_assets.html">Kennungen</a></li>
<li class="nav-item"><a class="nav-link" href="uc_balancing.html">Bilanzierung</a></li>
<li class="nav-item col-6" style="padding-left: 15px;">
<form class="ms-auto" action="./uc_assets.html" method="get">
<div class="input-group"><input class="form-control" type="search" id="searchMeter" name="meterId" required="" minlength="2" autocomplete="on" autofocus=""><button class="btn btn-dark" type="submit"><i class="fa fa-search"></i></button></div>
Expand Down
1 change: 0 additions & 1 deletion framework/public/devUI/uc_settlement.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
<li class="nav-item"><a class="nav-link" href="uc_tariff.html">Tarif</a></li>
<li class="nav-item"><a class="nav-link" href="uc_settlement.html">Settlement</a></li>
<li class="nav-item"><a class="nav-link" href="uc_assets.html">Kennungen</a></li>
<li class="nav-item"><a class="nav-link" href="uc_balancing.html">Bilanzierung</a></li>
<li class="nav-item col-6" style="padding-left: 15px;">
<form class="ms-auto" action="./uc_assets.html" method="get">
<div class="input-group"><input class="form-control" type="search" id="searchMeter" name="meterId" required="" minlength="2" autocomplete="on" autofocus=""><button class="btn btn-dark" type="submit"><i class="fa fa-search"></i></button></div>
Expand Down
1 change: 0 additions & 1 deletion framework/public/devUI/uc_tariff.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
<li class="nav-item"><a class="nav-link" href="uc_tariff.html">Tarif</a></li>
<li class="nav-item"><a class="nav-link" href="uc_settlement.html">Settlement</a></li>
<li class="nav-item"><a class="nav-link" href="uc_assets.html">Kennungen</a></li>
<li class="nav-item"><a class="nav-link" href="uc_balancing.html">Bilanzierung</a></li>
<li class="nav-item col-6" style="padding-left: 15px;">
<form class="ms-auto" action="./uc_assets.html" method="get">
<div class="input-group"><input class="form-control" type="search" id="searchMeter" name="meterId" required="" minlength="2" autocomplete="on" autofocus=""><button class="btn btn-dark" type="submit"><i class="fa fa-search"></i></button></div>
Expand Down
52 changes: 38 additions & 14 deletions framework/services/balancing.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,36 @@ module.exports = {
* @return {Promise<Array>} A promise that resolves to an array of the top n balances sealed models.
*/
async handler(ctx) {
if(typeof ctx.params.n == 'undefined') ctx.params.n = 1;

const top = await ctx.call("balances_sealed_model.find", {
query: {
assetId: ctx.params.assetId
},
sort: '-epoch',
limit: ctx.params.n * 1
if(typeof ctx.params.n == 'undefined') ctx.params.n = 1; else ctx.params.n *= 1;
let top = [];
let query = {
"$or": [ { "from": ctx.params.assetId }, { "to": ctx.params.assetId}],
};
if((typeof ctx.params.before !== 'undefined') && (!isNaN(ctx.params.before))) {
query.epoch = { $lt: ctx.params.before *1 };
}
const settlements = await ctx.call("balance_settlements_active_model.find", {
query,
limit: 1,
sort: "-epoch"
});
if(settlements.length == 0) {
return top;
}
const top_epoch = settlements[0].epoch;
for(let e = top_epoch;(e > top_epoch - (ctx.params.n));e--) {
const epoch_balance = await ctx.call("balancing.balance", {
assetId: ctx.params.assetId,
epoch:e
});
top.push(epoch_balance);
}

for(let i=0;i<top.length;i++) {
if(typeof top[i].time == 'undefined') {
top[i].time = top[i].epoch * process.env.EPOCH_DURATION;
}
}

return top;
}
Expand Down Expand Up @@ -307,9 +328,15 @@ module.exports = {
}
});
if(res.length == 0) {
return await ctx.call("balancing.unsealedBalance",ctx.params);
} else {
res = await ctx.call("balancing.unsealedBalance",ctx.params);
if(res.clearing.energy !== 0) {
res.energy = (-1) * res.clearing.energy;
}
res.energy *= -1;

return res;
} else {
return res[0];
}
}
},
Expand Down Expand Up @@ -372,10 +399,7 @@ module.exports = {
epoch: ctx.params.epoch * 1
},
});
console.log("Query",{
"$or": [ { "from": ctx.params.assetId }, { "to": ctx.params.assetId}],
epoch: ctx.params.epoch * 1
});

balance.upstream = await ctx.call("balancing.getUpstream", {assetId: ctx.params.assetId});

for(let i=0;i<settlements.length;i++) {
Expand Down

0 comments on commit 422b6df

Please sign in to comment.