remove vpn, node and wallet from settings

This commit is contained in:
/dev/fd0 2025-05-24 19:52:59 +05:30
parent 79a597cfa0
commit 3cc97d11f3
2 changed files with 1 additions and 143 deletions

View file

@ -11,65 +11,14 @@ import javafx.scene.control.PasswordField;
public class SettingsController extends JoinstrFormController {
@FXML
Label urlLabel;
@FXML
Label selectedWalletLabel;
@FXML
TextField usernameTextField;
@FXML
PasswordField passwordTextField;
@FXML
TextField nostrRelayTextField;
@FXML
TextField hostTextField;
@FXML
TextField locationTextField;
@FXML
TextField ipAddressTextField;
@FXML
TextField portTextField;
@FXML
TextField protocolTextField;
private VpnGateway vpnGateway;
@Override
public void initializeView() {
try {
// Node settings
urlLabel.setText(Config.get().getServer().getUrl());
selectedWalletLabel.setText(this.getJoinstrForm().getWallet().getName());
usernameTextField.setText(Config.get().getNodeUsername());
usernameTextField.textProperty().addListener(new ChangeListener<String>() {
@Override
public void changed(ObservableValue<? extends String> observable,
String oldValue, String newValue) {
Config.get().setNodeUsername(usernameTextField.getText());
}
});
passwordTextField.setText(Config.get().getNodePassword());
passwordTextField.textProperty().addListener(new ChangeListener<String>() {
@Override
public void changed(ObservableValue<? extends String> observable,
String oldValue, String newValue) {
Config.get().setNodePassword(passwordTextField.getText());
}
});
nostrRelayTextField.setText(Config.get().getNostrRelay());
nostrRelayTextField.textProperty().addListener(new ChangeListener<String>() {
@Override
@ -82,69 +31,8 @@ public class SettingsController extends JoinstrFormController {
}
});
// VPN Gateway settings
vpnGateway = Config.get().getVpnGateway();
if(vpnGateway == null)
vpnGateway = new VpnGateway();
hostTextField.setText(vpnGateway.getHost());
hostTextField.textProperty().addListener(new ChangeListener<String>() {
@Override
public void changed(ObservableValue<? extends String> observable,
String oldValue, String newValue) {
vpnGateway.setHost(hostTextField.getText());
Config.get().setVpnGateway(vpnGateway);
}
});
locationTextField.setText(vpnGateway.getLocation());
locationTextField.textProperty().addListener(new ChangeListener<String>() {
@Override
public void changed(ObservableValue<? extends String> observable,
String oldValue, String newValue) {
vpnGateway.setLocation(locationTextField.getText());
Config.get().setVpnGateway(vpnGateway);
}
});
ipAddressTextField.setText(vpnGateway.getIpAddress());
ipAddressTextField.textProperty().addListener(new ChangeListener<String>() {
@Override
public void changed(ObservableValue<? extends String> observable,
String oldValue, String newValue) {
vpnGateway.setIpAddress(ipAddressTextField.getText());
Config.get().setVpnGateway(vpnGateway);
}
});
portTextField.setText(String.valueOf(vpnGateway.getPort()));
portTextField.textProperty().addListener(new ChangeListener<String>() {
@Override
public void changed(ObservableValue<? extends String> observable,
String oldValue, String newValue) {
if (!newValue.matches("\\d{0,4}")) {
portTextField.setText(newValue.replaceAll("[^\\d]", ""));
}
if (newValue.length() > 4) {
portTextField.setText(newValue.substring(0, 4));
}
vpnGateway.setPort(Integer.getInteger(portTextField.getText()));
Config.get().setVpnGateway(vpnGateway);
}
});
protocolTextField.setText(vpnGateway.getProtocol());
protocolTextField.textProperty().addListener(new ChangeListener<String>() {
@Override
public void changed(ObservableValue<? extends String> observable,
String oldValue, String newValue) {
vpnGateway.setProtocol(protocolTextField.getText());
Config.get().setVpnGateway(vpnGateway);
}
});
} catch(Exception e) {
if(e != null) {}
e.printStackTrace();
}
}

View file

@ -21,39 +21,9 @@
</columnConstraints>
<children>
<Label GridPane.rowIndex="0" GridPane.columnIndex="0">Node URL:</Label>
<Label GridPane.rowIndex="0" GridPane.columnIndex="1" fx:id="urlLabel" />
<Label GridPane.rowIndex="1" GridPane.columnIndex="0">Selected Wallet:</Label>
<Label GridPane.rowIndex="1" GridPane.columnIndex="1" fx:id="selectedWalletLabel" />
<Label GridPane.rowIndex="2" GridPane.columnIndex="0">Username:</Label>
<TextField prefWidth="50" maxWidth="100" GridPane.rowIndex="2" GridPane.columnIndex="1" fx:id="usernameTextField" />
<Label GridPane.rowIndex="3" GridPane.columnIndex="0">Password:</Label>
<PasswordField prefWidth="50" maxWidth="100" GridPane.rowIndex="3" GridPane.columnIndex="1" fx:id="passwordTextField" />
<Label GridPane.rowIndex="4" GridPane.columnIndex="0">Nostr Relay:</Label>
<TextField prefWidth="100" maxWidth="150" GridPane.rowIndex="4" GridPane.columnIndex="1" fx:id="nostrRelayTextField">wss://nostr.fmt.wiz.biz</TextField>
<Label GridPane.rowIndex="6" GridPane.columnIndex="0" styleClass="sub-title">VPN Gateway</Label>
<Label GridPane.rowIndex="7" GridPane.columnIndex="0">Host:</Label>
<TextField prefWidth="100" maxWidth="150" GridPane.rowIndex="7" GridPane.columnIndex="1" fx:id="hostTextField" />
<Label GridPane.rowIndex="8" GridPane.columnIndex="0">Location:</Label>
<TextField prefWidth="100" maxWidth="150" GridPane.rowIndex="8" GridPane.columnIndex="1" fx:id="locationTextField" />
<Label GridPane.rowIndex="11" GridPane.columnIndex="0">Protocol:</Label>
<TextField prefWidth="100" maxWidth="150" GridPane.rowIndex="11" GridPane.columnIndex="1" fx:id="protocolTextField" />
<Label GridPane.rowIndex="9" GridPane.columnIndex="0">IP Address:</Label>
<TextField prefWidth="100" maxWidth="150" GridPane.rowIndex="9" GridPane.columnIndex="1" fx:id="ipAddressTextField" />
<Label GridPane.rowIndex="10" GridPane.columnIndex="0">Port:</Label>
<TextField prefWidth="25" maxWidth="50" GridPane.rowIndex="10" GridPane.columnIndex="1" fx:id="portTextField" />
</children>
</GridPane>
</VBox>