diff --git a/client/app/src/main/java/main/OptionController.java b/client/app/src/main/java/main/OptionController.java index 2e82e48..9d85042 100644 --- a/client/app/src/main/java/main/OptionController.java +++ b/client/app/src/main/java/main/OptionController.java @@ -1,6 +1,9 @@ package main; import com.jfoenix.controls.*; +import config.Config; +import config.ConfigLoader; +import container.HttpRequest; import helper.HttpRequestException; import javafx.collections.FXCollections; import javafx.collections.ObservableList; @@ -45,6 +48,7 @@ public class OptionController { private JFXComboBox comboBox; private DataController dataController; private List users; + private Config config; @FXML public void initialize(){ @@ -63,6 +67,11 @@ public class OptionController { comboBox.getStyleClass().add("comboBox"); mainGrid.add(comboBox, 2,2); + config = ConfigLoader.load(); + if(config == null){ + config = new Config(false, -1, ""); + } + saveLoginTBtn.setSelected(config.isSaveLogin()); } public void onBackBtnClick(ActionEvent actionEvent) { @@ -134,4 +143,16 @@ public class OptionController { EditUserController editUserController = fxmlLoader.getController(); editUserController.setCurrentUser(users.get(editIndex)); } + + public void toggledBtn(ActionEvent actionEvent) { + config.setSaveLogin(saveLoginTBtn.isSelected()); + if(config.isSaveLogin()){ + config.setId(DataController.USER_ID); + config.setToken(HttpRequest.TOKEN); + } else { + config.setId(-1); + config.setToken(""); + } + ConfigLoader.save(config); + } } diff --git a/client/app/src/main/resources/main/option-view.fxml b/client/app/src/main/resources/main/option-view.fxml index e54f1fc..13e2edd 100644 --- a/client/app/src/main/resources/main/option-view.fxml +++ b/client/app/src/main/resources/main/option-view.fxml @@ -43,7 +43,7 @@ fx:id="mainGrid"> - +