Skip to content

Commit

Permalink
Add voteResult view
Browse files Browse the repository at this point in the history
  • Loading branch information
ManfredKarrer committed Jul 15, 2018
1 parent dfcda39 commit 9f01e9e
Show file tree
Hide file tree
Showing 20 changed files with 1,192 additions and 688 deletions.
8 changes: 8 additions & 0 deletions src/main/java/bisq/desktop/bisq.css
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,14 @@ bg color of non edit textFields: fafafa
-fx-text-fill: -bs-green;
}

.dao-accepted-icon {
-fx-text-fill: -bs-green;
}

.dao-rejected-icon {
-fx-text-fill: -bs-error-red;
}

.version {
-fx-text-fill: black;
-fx-underline: false;
Expand Down
3 changes: 0 additions & 3 deletions src/main/java/bisq/desktop/main/dao/DaoView.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,10 @@
~ along with Bisq. If not, see <http://www.gnu.org/licenses/>.
-->

<?import javafx.scene.control.Tab?>
<?import javafx.scene.control.TabPane?>
<?import javafx.scene.layout.AnchorPane?>
<TabPane fx:id="root" fx:controller="bisq.desktop.main.dao.DaoView"
AnchorPane.bottomAnchor="0" AnchorPane.leftAnchor="0"
AnchorPane.rightAnchor="0" AnchorPane.topAnchor="0"
xmlns:fx="http://javafx.com/fxml">

<Tab fx:id="bsqWalletTab" closable="false"/>
</TabPane>
22 changes: 18 additions & 4 deletions src/main/java/bisq/desktop/main/dao/DaoView.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import bisq.desktop.common.view.ViewLoader;
import bisq.desktop.main.MainView;
import bisq.desktop.main.dao.bonding.BondingView;
import bisq.desktop.main.dao.cycles.CyclesView;
import bisq.desktop.main.dao.proposal.ProposalView;
import bisq.desktop.main.dao.voting.VotingView;
import bisq.desktop.main.dao.wallet.BsqWalletView;
Expand All @@ -49,7 +50,7 @@
public class DaoView extends ActivatableViewAndModel<TabPane, Activatable> {

@FXML
Tab bsqWalletTab, proposalsTab, votingTab, bondingTab;
Tab bsqWalletTab, proposalsTab, votingTab, resultsTab, bondingTab;

private Navigation.Listener navigationListener;
private ChangeListener<Tab> tabChangeListener;
Expand All @@ -68,22 +69,27 @@ private DaoView(CachingViewLoader viewLoader, Navigation navigation) {

@Override
public void initialize() {
bsqWalletTab = new Tab(Res.get("dao.tab.bsqWallet"));
proposalsTab = new Tab(Res.get("dao.tab.proposals"));
votingTab = new Tab(Res.get("dao.tab.voting"));
resultsTab = new Tab(Res.get("dao.tab.results"));
bondingTab = new Tab(Res.get("dao.tab.bonding"));

bsqWalletTab.setClosable(false);
proposalsTab.setClosable(false);
votingTab.setClosable(false);
resultsTab.setClosable(false);
bondingTab.setClosable(false);
root.getTabs().addAll(proposalsTab, votingTab, bondingTab);

root.getTabs().addAll(bsqWalletTab, proposalsTab, votingTab, resultsTab, bondingTab);

if (!BisqEnvironment.isDAOActivatedAndBaseCurrencySupportingBsq() || !DevEnv.isDaoPhase2Activated()) {
votingTab.setDisable(true);
bondingTab.setDisable(true);
resultsTab.setDisable(true);
proposalsTab.setDisable(true);
}

bsqWalletTab.setText(Res.get("dao.tab.bsqWallet"));

navigationListener = viewPath -> {
if (viewPath.size() == 3 && viewPath.indexOf(DaoView.class) == 1) {
if (proposalsTab == null && viewPath.get(2).equals(BsqWalletView.class))
Expand All @@ -109,6 +115,9 @@ public void initialize() {
} else if (newValue == votingTab) {
//noinspection unchecked
navigation.navigateTo(MainView.class, DaoView.class, VotingView.class);
} else if (newValue == resultsTab) {
//noinspection unchecked
navigation.navigateTo(MainView.class, DaoView.class, CyclesView.class);
} else if (newValue == bondingTab) {
//noinspection unchecked
navigation.navigateTo(MainView.class, DaoView.class, BondingView.class);
Expand All @@ -132,6 +141,9 @@ else if (selectedItem == proposalsTab)
else if (selectedItem == votingTab)
//noinspection unchecked
navigation.navigateTo(MainView.class, DaoView.class, VotingView.class);
else if (selectedItem == resultsTab)
//noinspection unchecked
navigation.navigateTo(MainView.class, DaoView.class, CyclesView.class);
else if (selectedItem == bondingTab)
//noinspection unchecked
navigation.navigateTo(MainView.class, DaoView.class, BondingView.class);
Expand All @@ -153,6 +165,8 @@ private void loadView(Class<? extends View> viewClass) {
selectedTab = proposalsTab;
} else if (view instanceof VotingView) {
selectedTab = votingTab;
} else if (view instanceof CyclesView) {
selectedTab = resultsTab;
} else if (view instanceof BondingView) {
selectedTab = bondingTab;
}
Expand Down
73 changes: 73 additions & 0 deletions src/main/java/bisq/desktop/main/dao/cycles/CyclesListItem.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/*
* 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.cycles;

import bisq.desktop.main.dao.cycles.model.CycleResult;

import bisq.core.dao.voting.proposal.compensation.CompensationProposal;
import bisq.core.locale.Res;
import bisq.core.util.BsqFormatter;

import org.bitcoinj.core.Coin;

import java.util.Date;

import lombok.Getter;

public class CyclesListItem {
private BsqFormatter bsqFormatter;
@Getter
private CycleResult cycleResult;

public CyclesListItem(CycleResult cycleResult,
BsqFormatter bsqFormatter) {
this.cycleResult = cycleResult;
this.bsqFormatter = bsqFormatter;
}

public String getCycle() {
int displayIndex = cycleResult.getCycleIndex() + 1;
String dateTime = bsqFormatter.formatDateTime(new Date(cycleResult.getCycleStartTime()));
return Res.get("dao.results.results.table.item.cycle", displayIndex, dateTime);
}

public String getNumProposals() {
return String.valueOf(cycleResult.getEvaluatedProposals().size());
}

public String getNumVotesAsString() {
return String.valueOf(cycleResult.getNumVotes());
}

public String getStake() {
return bsqFormatter.formatCoinWithCode(Coin.valueOf(cycleResult.getTotalStake()));
}

public String getIssuance() {
long totalIssuance = cycleResult.getEvaluatedProposals().stream()
.filter(e -> e.getProposal() instanceof CompensationProposal)
.map(e -> (CompensationProposal) e.getProposal())
.mapToLong(e -> e.getRequestedBsq().value)
.sum();
return bsqFormatter.formatCoinWithCode(Coin.valueOf(totalIssuance));
}

public Long getCycleStartTime() {
return cycleResult.getCycleStartTime();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,21 @@
~ along with Bisq. If not, see <http://www.gnu.org/licenses/>.
-->


<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.ColumnConstraints?>
<?import javafx.scene.layout.GridPane?>
<GridPane fx:id="root" fx:controller="bisq.desktop.main.dao.proposal.myvotes.MyVotesView"
<?import javafx.geometry.Insets?>
<GridPane fx:id="root" fx:controller="bisq.desktop.main.dao.cycles.CyclesView"
hgap="5.0" vgap="5.0"
AnchorPane.bottomAnchor="20.0" AnchorPane.leftAnchor="20.0"
AnchorPane.rightAnchor="25.0" AnchorPane.topAnchor="20.0"
AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0"
AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0"
xmlns:fx="http://javafx.com/fxml">
<padding>
<Insets bottom="10.0" left="25.0" top="15.0" right="25"/>
</padding>

<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" halignment="RIGHT" minWidth="160.0"/>
<ColumnConstraints hgrow="SOMETIMES" halignment="RIGHT" minWidth="140.0"/>
<ColumnConstraints hgrow="ALWAYS" minWidth="300.0"/>
</columnConstraints>
</GridPane>
Loading

0 comments on commit 9f01e9e

Please sign in to comment.