mirror of
https://github.com/bisq-network/bisq.git
synced 2025-02-24 15:10:44 +01:00
Add update notification to alert system
This commit is contained in:
parent
6b3df246a1
commit
a286e3e9b3
7 changed files with 116 additions and 16 deletions
|
@ -30,11 +30,13 @@ public final class Alert implements PubKeyProtectedExpirablePayload {
|
|||
private static final long TTL = TimeUnit.DAYS.toMillis(10);
|
||||
|
||||
public final String message;
|
||||
public final boolean isUpdateInfo;
|
||||
private String signatureAsBase64;
|
||||
private PublicKey storagePublicKey;
|
||||
|
||||
public Alert(String message) {
|
||||
public Alert(String message, boolean isUpdateInfo) {
|
||||
this.message = message;
|
||||
this.isUpdateInfo = isUpdateInfo;
|
||||
}
|
||||
|
||||
public void setSigAndStoragePubKey(String signatureAsBase64, PublicKey storagePublicKey) {
|
||||
|
|
|
@ -203,6 +203,44 @@ textfield */
|
|||
-fx-progress-color: dimgrey;
|
||||
}
|
||||
|
||||
.hyperlink {
|
||||
-fx-border-style: none;
|
||||
-fx-border-width: 0px;
|
||||
}
|
||||
|
||||
.hyperlink .text {
|
||||
-fx-fill: white;
|
||||
-fx-border-style: none;
|
||||
-fx-border-width: 0px;
|
||||
}
|
||||
|
||||
.hyperlink .text {
|
||||
-fx-fill: -fx-accent;
|
||||
-fx-border-style: none;
|
||||
-fx-border-width: 0px;
|
||||
}
|
||||
|
||||
.hyperlink .text:hover,
|
||||
.hyperlink .tooltip .text,
|
||||
.hyperlink .text:hover {
|
||||
-fx-fill: black;
|
||||
-fx-border-style: none;
|
||||
-fx-border-width: 0px;
|
||||
}
|
||||
|
||||
.hyperlink:hover,
|
||||
.hyperlink:visited,
|
||||
.hyperlink:hover:visited {
|
||||
-fx-underline: false;
|
||||
-fx-border-style: none;
|
||||
-fx-border-width: 0px;
|
||||
}
|
||||
|
||||
.hyperlink:focused {
|
||||
-fx-border-style: none;
|
||||
-fx-border-width: 0px;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* *
|
||||
* Table *
|
||||
|
@ -263,22 +301,30 @@ textfield */
|
|||
|
||||
.table-view .table-row-cell:selected .hyperlink .text {
|
||||
-fx-fill: white;
|
||||
-fx-border-style: none;
|
||||
-fx-border-width: 0px;
|
||||
}
|
||||
|
||||
.table-view .table-row-cell .hyperlink .text {
|
||||
-fx-fill: -fx-accent;
|
||||
-fx-border-style: none;
|
||||
-fx-border-width: 0px;
|
||||
}
|
||||
|
||||
.table-view .table-row-cell .hyperlink .text:hover,
|
||||
.table-view .table-row-cell:selected .hyperlink .tooltip .text,
|
||||
.table-view .table-row-cell:selected .hyperlink .text:hover {
|
||||
-fx-fill: black;
|
||||
-fx-border-style: none;
|
||||
-fx-border-width: 0px;
|
||||
}
|
||||
|
||||
.table-view .table-row-cell .hyperlink:hover,
|
||||
.table-view .table-row-cell .hyperlink:visited,
|
||||
.table-view .table-row-cell .hyperlink:hover:visited {
|
||||
-fx-underline: false;
|
||||
-fx-border-style: none;
|
||||
-fx-border-width: 0px;
|
||||
}
|
||||
|
||||
.table-view .table-row-cell .hyperlink:focused {
|
||||
|
|
|
@ -132,7 +132,14 @@ public class TransactionsListItem {
|
|||
}
|
||||
}
|
||||
} else {
|
||||
details = received ? "Funded to wallet" : "Withdrawn from wallet";
|
||||
/* Optional<AddressEntry> addressEntryOptional = walletService.getAddressEntryList().stream()
|
||||
.filter(e -> e.getAddressString() != null && e.getAddressString().equals(addressString))
|
||||
.findAny();
|
||||
if (addressEntryOptional.isPresent() &&
|
||||
addressEntryOptional.get().getContext() == AddressEntry.Context.ARBITRATOR)
|
||||
details = received ? "Received funds" : "Withdrawn from wallet";
|
||||
else*/
|
||||
details = received ? "Received funds" : "Withdrawn from wallet";
|
||||
}
|
||||
|
||||
date.set(formatter.formatDateTime(transaction.getUpdateTime()));
|
||||
|
|
|
@ -18,6 +18,8 @@
|
|||
package io.bitsquare.gui.popups;
|
||||
|
||||
import io.bitsquare.alert.Alert;
|
||||
import io.bitsquare.common.util.Utilities;
|
||||
import io.bitsquare.gui.components.HyperlinkWithIcon;
|
||||
import javafx.geometry.Insets;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.Label;
|
||||
|
@ -28,6 +30,7 @@ import org.slf4j.LoggerFactory;
|
|||
import java.util.Optional;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static io.bitsquare.gui.util.FormBuilder.addLabelHyperlinkWithIcon;
|
||||
import static io.bitsquare.gui.util.FormBuilder.addMultilineLabel;
|
||||
|
||||
public class DisplayAlertMessagePopup extends Popup {
|
||||
|
@ -44,17 +47,13 @@ public class DisplayAlertMessagePopup extends Popup {
|
|||
}
|
||||
|
||||
public DisplayAlertMessagePopup show() {
|
||||
if (headLine == null)
|
||||
headLine = "Global alert message!";
|
||||
|
||||
width = 700;
|
||||
// need to set headLine, otherwise the fields will not be created in addHeadLine
|
||||
headLine = "Important information!";
|
||||
createGridPane();
|
||||
addHeadLine();
|
||||
addContent();
|
||||
createPopup();
|
||||
|
||||
headLineLabel.setStyle("-fx-text-fill: -bs-error-red; -fx-font-weight: bold; -fx-font-size: 18;");
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -75,8 +74,17 @@ public class DisplayAlertMessagePopup extends Popup {
|
|||
private void addContent() {
|
||||
checkNotNull(alert, "alertMessage must not be null");
|
||||
msgLabel = addMultilineLabel(gridPane, ++rowIndex, alert.message, 10);
|
||||
msgLabel.setStyle("-fx-text-fill: -bs-error-red;");
|
||||
|
||||
if (alert.isUpdateInfo) {
|
||||
headLine = "Important update information!";
|
||||
headLineLabel.setStyle("-fx-text-fill: -fx-accent; -fx-font-weight: bold; -fx-font-size: 22;");
|
||||
String url = "https://github.com/bitsquare/bitsquare/releases";
|
||||
HyperlinkWithIcon download = addLabelHyperlinkWithIcon(gridPane, ++rowIndex, "Download:", url).second;
|
||||
download.setMaxWidth(350);
|
||||
download.setOnAction(e -> Utilities.openWebPage(url));
|
||||
} else {
|
||||
headLine = "Important information!";
|
||||
headLineLabel.setStyle("-fx-text-fill: -bs-error-red; -fx-font-weight: bold; -fx-font-size: 22;");
|
||||
}
|
||||
closeButton = new Button("Cancel");
|
||||
closeButton.setOnAction(e -> {
|
||||
hide();
|
||||
|
|
|
@ -22,6 +22,7 @@ import io.bitsquare.app.BitsquareApp;
|
|||
import io.bitsquare.gui.components.InputTextField;
|
||||
import javafx.geometry.Insets;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.CheckBox;
|
||||
import javafx.scene.layout.GridPane;
|
||||
import javafx.scene.layout.HBox;
|
||||
import org.slf4j.Logger;
|
||||
|
@ -29,6 +30,7 @@ import org.slf4j.LoggerFactory;
|
|||
|
||||
import java.util.Optional;
|
||||
|
||||
import static io.bitsquare.gui.util.FormBuilder.addLabelCheckBox;
|
||||
import static io.bitsquare.gui.util.FormBuilder.addLabelInputTextField;
|
||||
|
||||
public class SendAlertMessagePopup extends Popup {
|
||||
|
@ -59,9 +61,9 @@ public class SendAlertMessagePopup extends Popup {
|
|||
|
||||
public SendAlertMessagePopup show() {
|
||||
if (headLine == null)
|
||||
headLine = "Send alert message";
|
||||
headLine = "Send global notification";
|
||||
|
||||
width = 700;
|
||||
width = 600;
|
||||
createGridPane();
|
||||
addHeadLine();
|
||||
addContent();
|
||||
|
@ -91,23 +93,27 @@ public class SendAlertMessagePopup extends Popup {
|
|||
private void addContent() {
|
||||
InputTextField keyInputTextField = addLabelInputTextField(gridPane, ++rowIndex, "Alert private key:", 10).second;
|
||||
InputTextField alertMessageInputTextField = addLabelInputTextField(gridPane, ++rowIndex, "Alert message:").second;
|
||||
CheckBox isUpdateCheckBox = addLabelCheckBox(gridPane, ++rowIndex, "Is update notification:", "").second;
|
||||
isUpdateCheckBox.setSelected(true);
|
||||
|
||||
if (BitsquareApp.DEV_MODE) {
|
||||
keyInputTextField.setText("2e41038992f89eef2e4634ff3586e342c68ad9a5a7ffafee866781687f77a9b1");
|
||||
alertMessageInputTextField.setText("m1");
|
||||
}
|
||||
|
||||
openTicketButton = new Button("Send alert message");
|
||||
openTicketButton = new Button("Send notification");
|
||||
openTicketButton.setOnAction(e -> {
|
||||
if (alertMessageInputTextField.getText().length() > 0 && keyInputTextField.getText().length() > 0) {
|
||||
if (sendAlertMessageHandler.handle(new Alert(alertMessageInputTextField.getText()), keyInputTextField.getText()))
|
||||
if (sendAlertMessageHandler.handle(
|
||||
new Alert(alertMessageInputTextField.getText(), isUpdateCheckBox.isSelected()),
|
||||
keyInputTextField.getText()))
|
||||
hide();
|
||||
else
|
||||
new Popup().warning("The key you entered was not correct.").width(300).onClose(() -> blurAgain()).show();
|
||||
}
|
||||
});
|
||||
|
||||
Button removeAlertMessageButton = new Button("Remove alert message");
|
||||
Button removeAlertMessageButton = new Button("Remove notification");
|
||||
removeAlertMessageButton.setOnAction(e -> {
|
||||
if (keyInputTextField.getText().length() > 0) {
|
||||
if (removeAlertMessageHandler.handle(keyInputTextField.getText()))
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
package io.bitsquare.gui.util;
|
||||
|
||||
import de.jensd.fx.fontawesome.AwesomeIcon;
|
||||
import io.bitsquare.common.util.Tuple2;
|
||||
import io.bitsquare.common.util.Tuple3;
|
||||
import io.bitsquare.gui.components.*;
|
||||
|
@ -154,6 +155,32 @@ public class FormBuilder {
|
|||
|
||||
return new Tuple2<>(label, textField);
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Label + HyperlinkWithIcon
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public static Tuple2<Label, HyperlinkWithIcon> addLabelHyperlinkWithIcon(GridPane gridPane, int rowIndex, String title) {
|
||||
return addLabelHyperlinkWithIcon(gridPane, rowIndex, title, "", 0);
|
||||
}
|
||||
|
||||
public static Tuple2<Label, HyperlinkWithIcon> addLabelHyperlinkWithIcon(GridPane gridPane, int rowIndex, String title, String value) {
|
||||
return addLabelHyperlinkWithIcon(gridPane, rowIndex, title, value, 0);
|
||||
}
|
||||
|
||||
public static Tuple2<Label, HyperlinkWithIcon> addLabelHyperlinkWithIcon(GridPane gridPane, int rowIndex, String title, String value, double top) {
|
||||
Label label = addLabel(gridPane, rowIndex, title, top);
|
||||
|
||||
HyperlinkWithIcon textField = new HyperlinkWithIcon(value, AwesomeIcon.EXTERNAL_LINK);
|
||||
GridPane.setRowIndex(textField, rowIndex);
|
||||
GridPane.setColumnIndex(textField, 1);
|
||||
GridPane.setMargin(textField, new Insets(top, 0, 0, 0));
|
||||
gridPane.getChildren().add(textField);
|
||||
|
||||
return new Tuple2<>(label, textField);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Label + TextArea
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -357,6 +384,10 @@ public class FormBuilder {
|
|||
// Label + CheckBox
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public static Tuple2<Label, CheckBox> addLabelCheckBox(GridPane gridPane, int rowIndex, String title) {
|
||||
return addLabelCheckBox(gridPane, rowIndex, title, "", 0);
|
||||
}
|
||||
|
||||
public static Tuple2<Label, CheckBox> addLabelCheckBox(GridPane gridPane, int rowIndex, String title, String checkBoxTitle) {
|
||||
return addLabelCheckBox(gridPane, rowIndex, title, checkBoxTitle, 0);
|
||||
}
|
||||
|
|
|
@ -68,7 +68,7 @@ public class PeerManager implements ConnectionListener, MessageListener {
|
|||
this.seedNodeAddresses = new HashSet<>(seedNodeAddresses);
|
||||
networkNode.addConnectionListener(this);
|
||||
dbStorage = new Storage<>(storageDir);
|
||||
HashSet<ReportedPeer> persistedPeers = dbStorage.initAndGetPersisted("persistedPeers");
|
||||
HashSet<ReportedPeer> persistedPeers = dbStorage.initAndGetPersisted("PersistedPeers");
|
||||
if (persistedPeers != null) {
|
||||
log.info("We have persisted reported peers. persistedPeers.size()=" + persistedPeers.size());
|
||||
this.persistedPeers.addAll(persistedPeers);
|
||||
|
|
Loading…
Add table
Reference in a new issue