mirror of
https://github.com/aljazceru/lnd-manageJ.git
synced 2026-01-20 14:34:24 +01:00
switch to balance model in ui
This commit is contained in:
committed by
Carsten Otto
parent
2b2feb798b
commit
286bfcc538
@@ -29,4 +29,12 @@ public record BalanceInformationModel(
|
||||
long routableCapacity = outbound + remoteBalanceSat();
|
||||
return (1.0 * outbound / routableCapacity) * 100;
|
||||
}
|
||||
|
||||
public long getRoutableCapacity() {
|
||||
return remoteBalanceSat() + localBalanceSat();
|
||||
}
|
||||
|
||||
public double getInboundPercentage() {
|
||||
return 100 - getOutboundPercentage();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,17 +28,4 @@ public record ChannelDetailsDto(
|
||||
Set<String> warnings
|
||||
) {
|
||||
|
||||
public long getRoutableCapacity() {
|
||||
return balanceInformation.remoteBalanceSat() + balanceInformation.localBalanceSat();
|
||||
}
|
||||
|
||||
public double getInboundPercentage() {
|
||||
return 100 - getOutboundPercentage();
|
||||
}
|
||||
|
||||
public double getOutboundPercentage() {
|
||||
long outbound = balanceInformation.localBalanceSat();
|
||||
return (1.0 * outbound / getRoutableCapacity()) * 100;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
<div th:replace="~{fragments/tiles :: channel-details(${channel})}"/>
|
||||
<div th:replace="~{fragments/tiles :: fee-policy(${channel.channelStatus}, ${channel.policies})}"/>
|
||||
<div th:replace="~{fragments/tiles :: balance(${channel.balanceInformation}, ${channel.getInboundPercentage}, ${channel.getOutboundPercentage}, ${channel.routableCapacity == 0})}"/>
|
||||
<div th:replace="~{fragments/tiles :: balance(${channel.balanceInformation})}"/>
|
||||
|
||||
<div th:replace="~{fragments/tiles :: on-chain-costs(${channel.onChainCosts})}"/>
|
||||
<div th:replace="~{fragments/tiles :: rebalance-report(${channel.rebalanceReport})}"/>
|
||||
|
||||
@@ -149,9 +149,8 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div th:fragment="balance (balanceInformation, inboundPercent, outboundPercent, disabled)" class="tile col-sm-4"
|
||||
th:if="!${disabled}">
|
||||
<div th:fragment="balance (balanceInformation)" class="tile col-sm-4"
|
||||
th:if="${balanceInformation.routableCapacity > 0}">
|
||||
<div class="card border-secondary">
|
||||
<div class="card-header">
|
||||
<div class="fs-4 mb-0">
|
||||
@@ -162,12 +161,15 @@
|
||||
<div class="card-body">
|
||||
<div class="container" style="padding-left: 0; padding-right: 0;">
|
||||
<div class="progress" style="margin-bottom: 16px">
|
||||
<div th:text="${#numbers.formatDecimal(outboundPercent,1,0)} + '%'"
|
||||
<div th:text="${#numbers.formatDecimal(balanceInformation.getOutboundPercentage,1,0)} + '%'"
|
||||
class="progress-bar outbound-green" role="progressbar"
|
||||
th:style="'width: ' + ${outboundPercent} + '%'" aria-valuenow="30" aria-valuemin="0"
|
||||
th:style="'width: ' + ${balanceInformation.getOutboundPercentage} + '%'" aria-valuenow="30"
|
||||
aria-valuemin="0"
|
||||
aria-valuemax="100"></div>
|
||||
<div th:text="${#numbers.formatDecimal(inboundPercent,1,0)} + '%'" class="progress-bar inbound-red"
|
||||
role="progressbar" th:style="'width: ' + ${inboundPercent} + '%'" aria-valuenow="15"
|
||||
<div th:text="${#numbers.formatDecimal(balanceInformation.getInboundPercentage,1,0)} + '%'"
|
||||
class="progress-bar inbound-red"
|
||||
role="progressbar" th:style="'width: ' + ${balanceInformation.getInboundPercentage} + '%'"
|
||||
aria-valuenow="15"
|
||||
aria-valuemin="0" aria-valuemax="100"></div>
|
||||
</div>
|
||||
<div class="row align-items-start">
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
<div th:replace="~{fragments/tiles :: channel-tile(${node})}"/>
|
||||
|
||||
<div th:replace="~{fragments/tiles :: balance(${node.balance}, 0, 0, false)}"/>
|
||||
<div th:replace="~{fragments/tiles :: balance(${node.balance})}"/>
|
||||
<div th:replace="~{fragments/tiles :: rebalance-report(${node.rebalanceReport})}"/>
|
||||
<div th:replace="~{fragments/tiles :: on-chain-costs(${node.onChainCosts})}"/>
|
||||
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
package de.cotto.lndmanagej.ui.dto;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static de.cotto.lndmanagej.ui.dto.BalanceInformationModelFixture.BALANCE_INFORMATION_MODEL;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
class BalanceInformationModelTest {
|
||||
|
||||
@Test
|
||||
void routableCapacity() {
|
||||
assertThat(BALANCE_INFORMATION_MODEL.getRoutableCapacity()).isEqualTo(1123L);
|
||||
}
|
||||
|
||||
@Test
|
||||
void inboundPercentage() {
|
||||
assertThat(BALANCE_INFORMATION_MODEL.getInboundPercentage()).isEqualTo(10.952_804_986_642_917);
|
||||
}
|
||||
|
||||
@Test
|
||||
void outboundPercentage() {
|
||||
assertThat(BALANCE_INFORMATION_MODEL.getOutboundPercentage()).isEqualTo(100 - 10.952_804_986_642_917);
|
||||
}
|
||||
}
|
||||
@@ -48,21 +48,6 @@ class ChannelDetailsDtoTest {
|
||||
.isEqualTo(BalanceInformationModel.createFromModel(BALANCE_INFORMATION));
|
||||
}
|
||||
|
||||
@Test
|
||||
void routableCapacity() {
|
||||
assertThat(CHANNEL_DETAILS_DTO.getRoutableCapacity()).isEqualTo(1123L);
|
||||
}
|
||||
|
||||
@Test
|
||||
void inboundPercentage() {
|
||||
assertThat(CHANNEL_DETAILS_DTO.getInboundPercentage()).isEqualTo(10.952_804_986_642_917);
|
||||
}
|
||||
|
||||
@Test
|
||||
void outboundPercentage() {
|
||||
assertThat(CHANNEL_DETAILS_DTO.getOutboundPercentage()).isEqualTo(100 - 10.952_804_986_642_917);
|
||||
}
|
||||
|
||||
@Test
|
||||
void capacitySat() {
|
||||
assertThat(CHANNEL_DETAILS_DTO.capacitySat()).isEqualTo(21_000_000);
|
||||
|
||||
Reference in New Issue
Block a user