mirror of
https://github.com/bisq-network/bisq.git
synced 2025-02-24 15:10:44 +01:00
Add bonding dashboard
This commit is contained in:
parent
60e58f7bcb
commit
90297201f2
7 changed files with 134 additions and 8 deletions
|
@ -28,7 +28,9 @@ import bisq.desktop.components.MenuItem;
|
||||||
import bisq.desktop.main.MainView;
|
import bisq.desktop.main.MainView;
|
||||||
import bisq.desktop.main.dao.DaoView;
|
import bisq.desktop.main.dao.DaoView;
|
||||||
import bisq.desktop.main.dao.bonding.Lock.LockupBSQView;
|
import bisq.desktop.main.dao.bonding.Lock.LockupBSQView;
|
||||||
|
import bisq.desktop.main.dao.bonding.dashboard.BondingDashboardView;
|
||||||
import bisq.desktop.main.dao.bonding.unlock.UnlockBSQView;
|
import bisq.desktop.main.dao.bonding.unlock.UnlockBSQView;
|
||||||
|
import bisq.desktop.main.dao.voting.dashboard.VotingDashboardView;
|
||||||
|
|
||||||
import bisq.core.locale.Res;
|
import bisq.core.locale.Res;
|
||||||
|
|
||||||
|
@ -51,8 +53,7 @@ public class BondingView extends ActivatableViewAndModel {
|
||||||
private final ViewLoader viewLoader;
|
private final ViewLoader viewLoader;
|
||||||
private final Navigation navigation;
|
private final Navigation navigation;
|
||||||
|
|
||||||
private MenuItem lockupBSQ;
|
private MenuItem dashboard, lockupBSQ, unlockBSQ;
|
||||||
private MenuItem unlockBSQ;
|
|
||||||
private Navigation.Listener listener;
|
private Navigation.Listener listener;
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
|
@ -80,15 +81,18 @@ public class BondingView extends ActivatableViewAndModel {
|
||||||
|
|
||||||
ToggleGroup toggleGroup = new ToggleGroup();
|
ToggleGroup toggleGroup = new ToggleGroup();
|
||||||
final List<Class<? extends View>> baseNavPath = Arrays.asList(MainView.class, DaoView.class, bisq.desktop.main.dao.bonding.BondingView.class);
|
final List<Class<? extends View>> baseNavPath = Arrays.asList(MainView.class, DaoView.class, bisq.desktop.main.dao.bonding.BondingView.class);
|
||||||
|
dashboard = new MenuItem(navigation, toggleGroup, Res.get("shared.dashboard"),
|
||||||
|
BondingDashboardView.class, AwesomeIcon.DASHBOARD, baseNavPath);
|
||||||
lockupBSQ = new MenuItem(navigation, toggleGroup, Res.get("dao.bonding.menuItem.lockupBSQ"),
|
lockupBSQ = new MenuItem(navigation, toggleGroup, Res.get("dao.bonding.menuItem.lockupBSQ"),
|
||||||
LockupBSQView.class, AwesomeIcon.LIST_UL, baseNavPath);
|
LockupBSQView.class, AwesomeIcon.LIST_UL, baseNavPath);
|
||||||
unlockBSQ = new MenuItem(navigation, toggleGroup, Res.get("dao.bonding.menuItem.unlockBSQ"),
|
unlockBSQ = new MenuItem(navigation, toggleGroup, Res.get("dao.bonding.menuItem.unlockBSQ"),
|
||||||
UnlockBSQView.class, AwesomeIcon.LIST_UL, baseNavPath);
|
UnlockBSQView.class, AwesomeIcon.LIST_UL, baseNavPath);
|
||||||
leftVBox.getChildren().addAll(lockupBSQ, unlockBSQ);
|
leftVBox.getChildren().addAll(dashboard, lockupBSQ, unlockBSQ);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void activate() {
|
protected void activate() {
|
||||||
|
dashboard.activate();
|
||||||
lockupBSQ.activate();
|
lockupBSQ.activate();
|
||||||
unlockBSQ.activate();
|
unlockBSQ.activate();
|
||||||
|
|
||||||
|
@ -111,6 +115,7 @@ public class BondingView extends ActivatableViewAndModel {
|
||||||
protected void deactivate() {
|
protected void deactivate() {
|
||||||
navigation.removeListener(listener);
|
navigation.removeListener(listener);
|
||||||
|
|
||||||
|
dashboard.deactivate();
|
||||||
lockupBSQ.deactivate();
|
lockupBSQ.deactivate();
|
||||||
unlockBSQ.deactivate();
|
unlockBSQ.deactivate();
|
||||||
}
|
}
|
||||||
|
@ -119,7 +124,8 @@ public class BondingView extends ActivatableViewAndModel {
|
||||||
View view = viewLoader.load(viewClass);
|
View view = viewLoader.load(viewClass);
|
||||||
content.getChildren().setAll(view.getRoot());
|
content.getChildren().setAll(view.getRoot());
|
||||||
|
|
||||||
if (view instanceof LockupBSQView) lockupBSQ.setSelected(true);
|
if (view instanceof BondingDashboardView) dashboard.setSelected(true);
|
||||||
|
else if (view instanceof LockupBSQView) lockupBSQ.setSelected(true);
|
||||||
else if (view instanceof UnlockBSQView) unlockBSQ.setSelected(true);
|
else if (view instanceof UnlockBSQView) unlockBSQ.setSelected(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,8 +22,9 @@
|
||||||
<?import javafx.scene.layout.ColumnConstraints?>
|
<?import javafx.scene.layout.ColumnConstraints?>
|
||||||
<?import javafx.scene.layout.GridPane?>
|
<?import javafx.scene.layout.GridPane?>
|
||||||
<GridPane fx:id="root" fx:controller="bisq.desktop.main.dao.bonding.Lock.LockupBSQView"
|
<GridPane fx:id="root" fx:controller="bisq.desktop.main.dao.bonding.Lock.LockupBSQView"
|
||||||
|
hgap="5.0" vgap="5.0"
|
||||||
AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0"
|
AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0"
|
||||||
AnchorPane.rightAnchor="0" AnchorPane.topAnchor="0.0"
|
AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="-10.0"
|
||||||
xmlns:fx="http://javafx.com/fxml">
|
xmlns:fx="http://javafx.com/fxml">
|
||||||
|
|
||||||
<columnConstraints>
|
<columnConstraints>
|
||||||
|
|
|
@ -0,0 +1,33 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
~ This file is part of Bisq.
|
||||||
|
~
|
||||||
|
~ Bisq is free software: you can redistribute it and/or modify it
|
||||||
|
~ under the terms of the GNU Affero General Public License as published by
|
||||||
|
~ the Free Software Foundation, either version 3 of the License, or (at
|
||||||
|
~ your option) any later version.
|
||||||
|
~
|
||||||
|
~ Bisq is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
~ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
~ FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
|
||||||
|
~ License for more details.
|
||||||
|
~
|
||||||
|
~ You should have received a copy of the GNU Affero General Public License
|
||||||
|
~ along with Bisq. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<?import javafx.scene.layout.AnchorPane?>
|
||||||
|
<?import javafx.scene.layout.GridPane?>
|
||||||
|
<?import javafx.scene.layout.ColumnConstraints?>
|
||||||
|
<GridPane fx:id="root" fx:controller="bisq.desktop.main.dao.bonding.dashboard.BondingDashboardView"
|
||||||
|
hgap="5.0" vgap="5.0"
|
||||||
|
AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0"
|
||||||
|
AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="-10.0"
|
||||||
|
xmlns:fx="http://javafx.com/fxml">
|
||||||
|
|
||||||
|
<columnConstraints>
|
||||||
|
<ColumnConstraints hgrow="SOMETIMES" halignment="RIGHT" minWidth="160.0"/>
|
||||||
|
<ColumnConstraints hgrow="ALWAYS" minWidth="300.0"/>
|
||||||
|
</columnConstraints>
|
||||||
|
</GridPane>
|
|
@ -0,0 +1,58 @@
|
||||||
|
/*
|
||||||
|
* This file is part of Bisq.
|
||||||
|
*
|
||||||
|
* Bisq is free software: you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU Affero General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or (at
|
||||||
|
* your option) any later version.
|
||||||
|
*
|
||||||
|
* Bisq is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
|
||||||
|
* License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with Bisq. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package bisq.desktop.main.dao.bonding.dashboard;
|
||||||
|
|
||||||
|
import bisq.desktop.common.view.ActivatableView;
|
||||||
|
import bisq.desktop.common.view.FxmlView;
|
||||||
|
import bisq.desktop.main.dao.wallet.BsqBalanceUtil;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
|
||||||
|
import javafx.scene.layout.GridPane;
|
||||||
|
|
||||||
|
@FxmlView
|
||||||
|
public class BondingDashboardView extends ActivatableView<GridPane, Void> {
|
||||||
|
private final BsqBalanceUtil bsqBalanceUtil;
|
||||||
|
|
||||||
|
private int gridRow = 0;
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Constructor, lifecycle
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private BondingDashboardView(BsqBalanceUtil bsqBalanceUtil) {
|
||||||
|
this.bsqBalanceUtil = bsqBalanceUtil;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void initialize() {
|
||||||
|
gridRow = bsqBalanceUtil.addGroup(root, gridRow);
|
||||||
|
gridRow = bsqBalanceUtil.addBondBalanceGroup(root, gridRow);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void activate() {
|
||||||
|
bsqBalanceUtil.activate();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void deactivate() {
|
||||||
|
bsqBalanceUtil.deactivate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -22,8 +22,9 @@
|
||||||
<?import javafx.scene.layout.ColumnConstraints?>
|
<?import javafx.scene.layout.ColumnConstraints?>
|
||||||
<?import javafx.scene.layout.GridPane?>
|
<?import javafx.scene.layout.GridPane?>
|
||||||
<GridPane fx:id="root" fx:controller="bisq.desktop.main.dao.bonding.unlock.UnlockBSQView"
|
<GridPane fx:id="root" fx:controller="bisq.desktop.main.dao.bonding.unlock.UnlockBSQView"
|
||||||
|
hgap="5.0" vgap="5.0"
|
||||||
AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0"
|
AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0"
|
||||||
AnchorPane.rightAnchor="0" AnchorPane.topAnchor="0.0"
|
AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="-10.0"
|
||||||
xmlns:fx="http://javafx.com/fxml">
|
xmlns:fx="http://javafx.com/fxml">
|
||||||
|
|
||||||
<columnConstraints>
|
<columnConstraints>
|
||||||
|
|
|
@ -436,8 +436,6 @@ public class UnlockBSQView extends ActivatableView<GridPane, Void> implements Bs
|
||||||
bsqBalanceUtil.deactivate();
|
bsqBalanceUtil.deactivate();
|
||||||
bsqWalletService.removeBsqBalanceListener(this);
|
bsqWalletService.removeBsqBalanceListener(this);
|
||||||
|
|
||||||
|
|
||||||
bsqBalanceUtil.deactivate();
|
|
||||||
lockedTxs.predicateProperty().unbind();
|
lockedTxs.predicateProperty().unbind();
|
||||||
bsqWalletService.getWalletTransactions().removeListener(walletBsqTransactionsListener);
|
bsqWalletService.getWalletTransactions().removeListener(walletBsqTransactionsListener);
|
||||||
bsqWalletService.removeBsqBalanceListener(this);
|
bsqWalletService.removeBsqBalanceListener(this);
|
||||||
|
|
|
@ -33,6 +33,7 @@ import javafx.scene.layout.GridPane;
|
||||||
|
|
||||||
import javafx.geometry.Pos;
|
import javafx.geometry.Pos;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
import static bisq.desktop.util.FormBuilder.addLabelTextField;
|
import static bisq.desktop.util.FormBuilder.addLabelTextField;
|
||||||
|
@ -42,9 +43,14 @@ import static bisq.desktop.util.FormBuilder.addTitledGroupBg;
|
||||||
public class BsqBalanceUtil implements BsqBalanceListener {
|
public class BsqBalanceUtil implements BsqBalanceListener {
|
||||||
private final BsqWalletService bsqWalletService;
|
private final BsqWalletService bsqWalletService;
|
||||||
private final BsqFormatter bsqFormatter;
|
private final BsqFormatter bsqFormatter;
|
||||||
|
|
||||||
|
// Displaying general BSQ info
|
||||||
private TextField confirmedBalanceTextField, pendingBalanceTextField, lockedForVoteBalanceTextField,
|
private TextField confirmedBalanceTextField, pendingBalanceTextField, lockedForVoteBalanceTextField,
|
||||||
lockedInBondsBalanceTextField, totalBalanceTextField;
|
lockedInBondsBalanceTextField, totalBalanceTextField;
|
||||||
|
|
||||||
|
// Displaying bond dashboard info
|
||||||
|
private TextField lockedAmountTextField, unlockingAmountTextField;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private BsqBalanceUtil(BsqWalletService bsqWalletService,
|
private BsqBalanceUtil(BsqWalletService bsqWalletService,
|
||||||
BsqFormatter bsqFormatter) {
|
BsqFormatter bsqFormatter) {
|
||||||
|
@ -87,6 +93,23 @@ public class BsqBalanceUtil implements BsqBalanceListener {
|
||||||
return gridRow;
|
return gridRow;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int addBondBalanceGroup(GridPane gridPane, int gridRow) {
|
||||||
|
addTitledGroupBg(gridPane, ++gridRow, 2, Res.get("dao.bonding.dashboard.lockedHeadline"), Layout.GROUP_DISTANCE);
|
||||||
|
|
||||||
|
lockedAmountTextField = addLabelTextField(gridPane, gridRow, Res.get("dao.bonding.dashboard.lockedAmount"),
|
||||||
|
Layout.FIRST_ROW_DISTANCE + Layout.GROUP_DISTANCE).second;
|
||||||
|
lockedAmountTextField.setMouseTransparent(false);
|
||||||
|
lockedAmountTextField.setMaxWidth(150);
|
||||||
|
lockedAmountTextField.setAlignment(Pos.CENTER_RIGHT);
|
||||||
|
|
||||||
|
unlockingAmountTextField = addLabelTextField(gridPane, ++gridRow, Res.get("dao.bonding.dashboard.unlockingAmount")).second;
|
||||||
|
unlockingAmountTextField.setMouseTransparent(false);
|
||||||
|
unlockingAmountTextField.setMaxWidth(150);
|
||||||
|
unlockingAmountTextField.setAlignment(Pos.CENTER_RIGHT);
|
||||||
|
|
||||||
|
return gridRow;
|
||||||
|
}
|
||||||
|
|
||||||
public void activate() {
|
public void activate() {
|
||||||
onUpdateBalances(bsqWalletService.getAvailableBalance(),
|
onUpdateBalances(bsqWalletService.getAvailableBalance(),
|
||||||
bsqWalletService.getPendingBalance(),
|
bsqWalletService.getPendingBalance(),
|
||||||
|
@ -112,6 +135,12 @@ public class BsqBalanceUtil implements BsqBalanceListener {
|
||||||
lockedForVoteBalanceTextField.setText(bsqFormatter.formatCoinWithCode(lockedForVotingBalance));
|
lockedForVoteBalanceTextField.setText(bsqFormatter.formatCoinWithCode(lockedForVotingBalance));
|
||||||
lockedInBondsBalanceTextField.setText(bsqFormatter.formatCoinWithCode(
|
lockedInBondsBalanceTextField.setText(bsqFormatter.formatCoinWithCode(
|
||||||
lockedInBondsBalance.add(unlockingBondsBalance)));
|
lockedInBondsBalance.add(unlockingBondsBalance)));
|
||||||
|
|
||||||
|
if (lockedAmountTextField != null && unlockingAmountTextField != null) {
|
||||||
|
lockedAmountTextField.setText(bsqFormatter.formatCoinWithCode(lockedInBondsBalance));
|
||||||
|
unlockingAmountTextField.setText(bsqFormatter.formatCoinWithCode(unlockingBondsBalance));
|
||||||
|
}
|
||||||
|
|
||||||
final Coin total = confirmedBalance
|
final Coin total = confirmedBalance
|
||||||
.add(pendingBalance)
|
.add(pendingBalance)
|
||||||
.add(lockedForVotingBalance)
|
.add(lockedForVotingBalance)
|
||||||
|
|
Loading…
Add table
Reference in a new issue