1717package de .doubleslash .keeptime .view ;
1818
1919import java .io .File ;
20- import java .io .FileInputStream ;
2120import java .io .FileOutputStream ;
2221import java .io .IOException ;
2322import java .io .InputStream ;
@@ -167,7 +166,7 @@ public class SettingsController {
167166 private TextField authName ;
168167
169168 @ FXML
170- private PasswordField authPassword ;
169+ private PasswordField authPassword1 ;
171170
172171 private ToggleGroup toggleGroup ;
173172
@@ -186,15 +185,6 @@ public class SettingsController {
186185 @ FXML
187186 private TextField authPort ;
188187
189- @ FXML
190- private Label labelPassword ;
191-
192- @ FXML
193- private Label labelPort ;
194-
195- @ FXML
196- private Label labelUsername ;
197-
198188 private String propertiesFilePath = "application.properties" ;
199189
200190 private static final String GITHUB_PAGE = "https://www.github.com/doubleSlashde/KeepTime" ;
@@ -256,41 +246,8 @@ private void initialize() {
256246 radioApiOff .setToggleGroup (toggleGroup );
257247 radioApiOn .setToggleGroup (toggleGroup );
258248
259- Properties properties = new Properties ();
260- User user ;
261- try (FileInputStream input = new FileInputStream (propertiesFilePath )) {
262- properties .load (input );
263- String apistatus = properties .getProperty ("api" );
264- System .err .println (apistatus );
265-
266- if (apistatus .equals ("ON" )) {
267- radioApiOn .setSelected (true );
268- radioApiOff .setSelected (false );
269- authPort .setText (properties .getProperty ("server.port" ));
270- authName .setText (properties .getProperty ("authUsername" ));
271- // labelPort.setDisable(false);
272- // labelUsername.setDisable(false);
273- // labelPassword.setDisable(false);
274- // authPort.setDisable(false);
275- // authName.setDisable(false);
276- // authPassword.setDisable(false);
277- System .err .println ("--------" );
278- } else if (apistatus .equals ("OFF" )) {
279- radioApiOn .setSelected (false );
280- radioApiOff .setSelected (true );
281- // labelPort.setDisable(true);
282- // labelUsername.setDisable(true);
283- // labelPassword.setDisable(true);
284- // authPort.setDisable(true);
285- // authName.setDisable(true);
286- // authPassword.setDisable(true);
287- System .err .println ("+++++++++" );
288- }
289- } catch (IOException e ) {
290- e .printStackTrace ();
291- }
292-
293249 LOG .debug ("saveButton.setOnAction" );
250+
294251 saveButton .setOnAction (ae -> {
295252 LOG .info ("Save clicked" );
296253
@@ -629,24 +586,18 @@ private void showLicense(final Licenses license) {
629586 }
630587
631588 private void handleApiOff () {
632- Map <String , String > propertiesToUpdate = new HashMap <>();
633589 setWebApplicationType ("none" );
634- propertiesToUpdate .put ("api" , "OFF" );
635- propertyWrite (propertiesToUpdate );
636-
637590 }
638591
639592 private void handleApiOn () {
640593 username = authName .getText ();
641- password = authPassword .getText ();
594+ password = authPassword1 .getText ();
642595
643596 createAndSaveUser (username , password );
644597
645598 Map <String , String > propertiesToUpdate = new HashMap <>();
646599 propertiesToUpdate .put ("spring.main.web-application-type" , "" );
647600 propertiesToUpdate .put ("server.port" , authPort .getText ());
648- propertiesToUpdate .put ("api" , "ON" );
649- propertiesToUpdate .put ("authUsername" , username );
650601
651602 propertyWrite (propertiesToUpdate );
652603 }
0 commit comments