Skip to content
Snippets Groups Projects
Commit e540256a authored by Robert Goldmann's avatar Robert Goldmann
Browse files

Fixed #89 - disable all tabs if settings are not working

parent 2a6cccb6
No related branches found
No related tags found
1 merge request!104merge v_1_2_0 into master
......@@ -144,6 +144,7 @@ public class Controller
{
Platform.runLater(() -> {
AlertGenerator.showAlert(AlertType.WARNING, "Warnung", "", "Bitte gibt zuerst deine Serverdaten ein!", icon, stage, null, false);
toggleAllTabsExceptSettings(true);
tabPane.getSelectionModel().select(tabSettings);
});
}
......@@ -233,6 +234,9 @@ public class Controller
if(!alertIsShowing)
{
Platform.runLater(() -> {
toggleAllTabsExceptSettings(true);
tabPane.getSelectionModel().select(tabSettings);
alertIsShowing = true;
Alert alert = new Alert(AlertType.ERROR);
alert.setTitle("Fehler");
......@@ -289,6 +293,14 @@ public class Controller
this.filterSettings = filterSettings;
}
public void toggleAllTabsExceptSettings(boolean disable)
{
tabHome.setDisable(disable);
tabPayments.setDisable(disable);
tabCategories.setDisable(disable);
tabCharts.setDisable(disable);
}
public void about()
{
AlertGenerator.showAboutAlert(bundle.getString("app.name"), bundle.getString("version.name"), bundle.getString("version.code"), bundle.getString("version.date"), bundle.getString("author"), icon, stage, null, false);
......@@ -315,6 +327,8 @@ public class Controller
categoryBudgets = connection.getCategoryBudgets(currentDate.getYear(), currentDate.getMonthOfYear());
paymentHandler.filter(newFilterSettings);
toggleAllTabsExceptSettings(false);
}
catch(Exception e)
{
......
......@@ -108,12 +108,24 @@ public class SettingsController
String url = textFieldURL.getText().trim();
String secret = textFieldSecret.getText().trim();
String currency = textFieldCurrency.getText().trim();
if(url != null && !url.equals(""))
if(url == null || url.equals(""))
{
if(secret != null && !secret.equals(""))
AlertGenerator.showAlert(AlertType.WARNING, "Warnung", "", "Das Feld für die Server URL darf nicht leer sein!", controller.getIcon(), controller.getStage(), null, false);
return;
}
if(secret == null || secret.equals(""))
{
if(currency != null && !currency.equals(""))
AlertGenerator.showAlert(AlertType.WARNING, "Warnung", "", "Das Server Passwortfeld darf nicht leer sein!", controller.getIcon(), controller.getStage(), null, false);
return;
}
if(currency == null || currency.equals(""))
{
AlertGenerator.showAlert(AlertType.WARNING, "Warnung", "", "Bitte gib deine gewünschte Währung ein!", controller.getIcon(), controller.getStage(), null, false);
return;
}
ArrayList<String> trustedHosts = new ArrayList<>();
String trustedHostText = textAreaTrustedHosts.getText();
String[] trustedHostsArray = trustedHostText.split("\n");
......@@ -129,8 +141,11 @@ public class SettingsController
if(controller.getSettings() != null)
{
controller.getSettings().setUrl(url);
if(!secret.equals("******"))
{
controller.getSettings().setSecret(HashUtils.hash(secret, Helpers.SALT));
}
controller.getSettings().setUrl(url);
controller.getSettings().setCurrency(currency);
controller.getSettings().setRestActivated(radioButtonRestActivated.isSelected());
controller.getSettings().setTrustedHosts(trustedHosts);
......@@ -161,21 +176,6 @@ public class SettingsController
controller.refresh(controller.getFilterSettings());
controller.showNotification("Erfolgreich gespeichert");
}
else
{
AlertGenerator.showAlert(AlertType.WARNING, "Warnung", "", "Bitte gib deine gewünschte Währung ein!", controller.getIcon(), controller.getStage(), null, false);
}
}
else
{
AlertGenerator.showAlert(AlertType.WARNING, "Warnung", "", "Das Server Passwortfeld darf nicht leer sein!", controller.getIcon(), controller.getStage(), null, false);
}
}
else
{
AlertGenerator.showAlert(AlertType.WARNING, "Warnung", "", "Das Feld für die Server URL darf nicht leer sein!", controller.getIcon(), controller.getStage(), null, false);
}
}
public void backupDB()
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment