Renamed package;
Implemented create user
This commit is contained in:
parent
72fdce471b
commit
245314a887
@ -10,8 +10,8 @@ import javafx.scene.layout.GridPane;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.util.StringConverter;
|
||||
import javafx.util.converter.LocalTimeStringConverter;
|
||||
import res.DataController;
|
||||
import res.Event;
|
||||
import container.DataController;
|
||||
import container.Event;
|
||||
|
||||
import java.time.LocalTime;
|
||||
import java.time.format.FormatStyle;
|
||||
|
@ -1,8 +1,8 @@
|
||||
package main;
|
||||
|
||||
import helper.HttpRequestException;
|
||||
import res.DataController;
|
||||
import res.Event;
|
||||
import container.DataController;
|
||||
import container.Event;
|
||||
|
||||
public class EditEventController extends CreateEventController{
|
||||
|
||||
|
@ -6,8 +6,8 @@ import javafx.application.Application;
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.stage.Stage;
|
||||
import res.DataController;
|
||||
import res.HttpRequest;
|
||||
import container.DataController;
|
||||
import container.HttpRequest;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Objects;
|
||||
|
@ -16,11 +16,11 @@ import javafx.scene.layout.HBox;
|
||||
import javafx.scene.layout.VBox;
|
||||
import javafx.stage.Modality;
|
||||
import javafx.stage.Stage;
|
||||
import res.DataController;
|
||||
import res.Event;
|
||||
import container.DataController;
|
||||
import container.Event;
|
||||
|
||||
import javafx.event.ActionEvent;
|
||||
import res.HttpRequest;
|
||||
import container.HttpRequest;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.time.Duration;
|
||||
|
@ -15,8 +15,8 @@ import javafx.scene.control.Label;
|
||||
import javafx.scene.layout.GridPane;
|
||||
import javafx.stage.Modality;
|
||||
import javafx.stage.Stage;
|
||||
import res.DataController;
|
||||
import res.User;
|
||||
import container.DataController;
|
||||
import container.User;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
@ -79,12 +79,16 @@ public class OptionController {
|
||||
Alert alert = new Alert(Alert.AlertType.CONFIRMATION, "Wirklich löschen?");
|
||||
Optional<ButtonType> result = alert.showAndWait();
|
||||
if(result.isPresent() && result.get() == ButtonType.OK){
|
||||
int removeIndex = comboBox.getSelectionModel().getSelectedIndex();
|
||||
try {
|
||||
dataController.deleteUser(users.get(comboBox.getSelectionModel().getSelectedIndex()));
|
||||
dataController.deleteUser(users.get(removeIndex));
|
||||
} catch (HttpRequestException e) {
|
||||
Alert alert1 = new Alert(Alert.AlertType.ERROR, e.getMessage());
|
||||
alert1.showAndWait();
|
||||
return;
|
||||
}
|
||||
comboBox.getItems().remove(removeIndex);
|
||||
users.remove(removeIndex);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
package users;
|
||||
|
||||
import helper.HttpRequestException;
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.Node;
|
||||
@ -8,6 +9,8 @@ import javafx.scene.control.PasswordField;
|
||||
import javafx.scene.control.TextField;
|
||||
import javafx.scene.control.ToggleButton;
|
||||
import javafx.stage.Stage;
|
||||
import container.DataController;
|
||||
import container.User;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
@ -39,15 +42,36 @@ public class CreateUserController {
|
||||
labelError.setText("Bitte Passwort eingeben!");
|
||||
return;
|
||||
}
|
||||
if (textPassword.getText().trim().length() < 8) {
|
||||
labelError.setText("Das Passwort muss mindestens 8 Zeichen lang sein!");
|
||||
return;
|
||||
}
|
||||
if (!Objects.equals(textPassword.getText(), textPasswordSecond.getText())){
|
||||
labelError.setText("Passwörter stimmen nicht überein!");
|
||||
return;
|
||||
}
|
||||
|
||||
User user = new User();
|
||||
user.setLogin(textLogin.getText().trim());
|
||||
user.setForename(textForename.getText().trim());
|
||||
user.setName(textName.getText().trim());
|
||||
user.setPassword(textPassword.getText().trim());
|
||||
|
||||
try {
|
||||
sendHttpRequest(user);
|
||||
} catch (HttpRequestException e) {
|
||||
labelError.setText(e.getMessage());
|
||||
}
|
||||
|
||||
Stage stage = (Stage) ((Node) event.getSource()).getScene().getWindow();
|
||||
stage.close();
|
||||
}
|
||||
|
||||
protected void sendHttpRequest(User user) throws HttpRequestException {
|
||||
DataController dataController = new DataController();
|
||||
dataController.createUser(user);
|
||||
}
|
||||
|
||||
@FXML
|
||||
protected void abortBtnClick(ActionEvent event) {
|
||||
Stage stage = (Stage) ((Node) event.getSource()).getScene().getWindow();
|
||||
|
@ -1,6 +1,6 @@
|
||||
package users;
|
||||
|
||||
import res.User;
|
||||
import container.User;
|
||||
|
||||
public class EditUserController extends CreateUserController{
|
||||
private User currentUser;
|
||||
|
@ -6,7 +6,7 @@ import javafx.fxml.FXML;
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.stage.Stage;
|
||||
import res.DataController;
|
||||
import container.DataController;
|
||||
|
||||
public class LoginController {
|
||||
@FXML
|
||||
|
@ -1,4 +1,4 @@
|
||||
package res;
|
||||
package container;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
@ -148,7 +148,7 @@ public class DataController {
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
objectMapper.findAndRegisterModules();
|
||||
try {
|
||||
return (List<User>)objectMapper.readValue(userJSON, new TypeReference<List<User>>() {});
|
||||
return objectMapper.readValue(userJSON, new TypeReference<>() {});
|
||||
} catch (JsonProcessingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package res;
|
||||
package container;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.time.LocalDateTime;
|
@ -1,4 +1,4 @@
|
||||
package res;
|
||||
package container;
|
||||
|
||||
import helper.Tuple;
|
||||
|
||||
@ -9,7 +9,6 @@ import java.io.InputStreamReader;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class HttpRequest {
|
||||
public static String TOKEN = "";
|
@ -1,4 +1,4 @@
|
||||
package res;
|
||||
package container;
|
||||
|
||||
public class User {
|
||||
|
||||
@ -11,6 +11,8 @@ public class User {
|
||||
|
||||
public User(){}
|
||||
|
||||
|
||||
|
||||
public int getUserId() {
|
||||
return userId;
|
||||
}
|
Loading…
Reference in New Issue
Block a user