Compare commits
11 Commits
4aafae9896
...
d41abdbad9
Author | SHA1 | Date | |
---|---|---|---|
d41abdbad9 | |||
db339eeada | |||
245314a887 | |||
72fdce471b | |||
780ecbee0f | |||
4e07b01b6a | |||
2f70515407 | |||
a4ce8940ab | |||
91daf95990 | |||
596343fe47 | |||
f133257194 |
@ -5,13 +5,17 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
javafx {
|
javafx {
|
||||||
version = "11"
|
version = "11.0.2"
|
||||||
modules(
|
modules(
|
||||||
"javafx.controls",
|
"javafx.controls",
|
||||||
"javafx.fxml"
|
"javafx.fxml"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tasks.withType<JavaCompile> {
|
||||||
|
options.encoding = "UTF-8"
|
||||||
|
}
|
||||||
|
|
||||||
application {
|
application {
|
||||||
mainClassName = "main.MainApplication"
|
mainClassName = "main.MainApplication"
|
||||||
}
|
}
|
||||||
|
@ -1,8 +0,0 @@
|
|||||||
package customUI;
|
|
||||||
|
|
||||||
public class Button extends javafx.scene.control.Button {
|
|
||||||
|
|
||||||
public void setTextValue(String text){
|
|
||||||
super.setText(Converter.convertString(text));
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,21 +0,0 @@
|
|||||||
package customUI;
|
|
||||||
|
|
||||||
public class Converter {
|
|
||||||
/*
|
|
||||||
Ä, ä \u00c4, \u00e4
|
|
||||||
Ö, ö \u00d6, \u00f6
|
|
||||||
Ü, ü \u00dc, \u00fc
|
|
||||||
ß \u00df
|
|
||||||
*/
|
|
||||||
@SuppressWarnings("all")
|
|
||||||
public static String convertString(String str){
|
|
||||||
return str
|
|
||||||
.replace("ä", "\u00e4")
|
|
||||||
.replace("Ä", "\u00c4")
|
|
||||||
.replace("ö", "\u00f6")
|
|
||||||
.replace("Ö", "\u00d6")
|
|
||||||
.replace("ü", "\u00fc")
|
|
||||||
.replace("Ü", "\u00dc")
|
|
||||||
.replace("ß", "\u00df");
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,15 +0,0 @@
|
|||||||
package customUI;
|
|
||||||
|
|
||||||
public class Label extends javafx.scene.control.Label {
|
|
||||||
public Label(String content){
|
|
||||||
super(Converter.convertString(content));
|
|
||||||
}
|
|
||||||
|
|
||||||
public Label(){
|
|
||||||
super();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTextValue(String text){
|
|
||||||
super.setText(Converter.convertString(text));
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,9 +0,0 @@
|
|||||||
package customUI;
|
|
||||||
|
|
||||||
public class Tooltip extends javafx.scene.control.Tooltip {
|
|
||||||
|
|
||||||
public Tooltip(String tollTipText){
|
|
||||||
super(Converter.convertString(tollTipText));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -2,9 +2,7 @@ package helper;
|
|||||||
|
|
||||||
import javafx.geometry.Bounds;
|
import javafx.geometry.Bounds;
|
||||||
import javafx.scene.Group;
|
import javafx.scene.Group;
|
||||||
import customUI.Button;
|
import javafx.scene.control.*;
|
||||||
import javafx.scene.control.ContentDisplay;
|
|
||||||
import customUI.Tooltip;
|
|
||||||
import javafx.scene.shape.SVGPath;
|
import javafx.scene.shape.SVGPath;
|
||||||
|
|
||||||
public class SvgBtnCreator {
|
public class SvgBtnCreator {
|
||||||
|
@ -10,8 +10,8 @@ import javafx.scene.layout.GridPane;
|
|||||||
import javafx.stage.Stage;
|
import javafx.stage.Stage;
|
||||||
import javafx.util.StringConverter;
|
import javafx.util.StringConverter;
|
||||||
import javafx.util.converter.LocalTimeStringConverter;
|
import javafx.util.converter.LocalTimeStringConverter;
|
||||||
import res.DataController;
|
import container.DataController;
|
||||||
import res.Event;
|
import container.Event;
|
||||||
|
|
||||||
import java.time.LocalTime;
|
import java.time.LocalTime;
|
||||||
import java.time.format.FormatStyle;
|
import java.time.format.FormatStyle;
|
||||||
@ -44,7 +44,6 @@ public class CreateEventController {
|
|||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
public void initialize() {
|
public void initialize() {
|
||||||
|
|
||||||
StringConverter<LocalTime> defaultConverter = new LocalTimeStringConverter(FormatStyle.SHORT, Locale.GERMANY);
|
StringConverter<LocalTime> defaultConverter = new LocalTimeStringConverter(FormatStyle.SHORT, Locale.GERMANY);
|
||||||
timeStart.set24HourView(true);
|
timeStart.set24HourView(true);
|
||||||
timeStart.setConverter(defaultConverter);
|
timeStart.setConverter(defaultConverter);
|
||||||
|
@ -1,16 +1,8 @@
|
|||||||
package main;
|
package main;
|
||||||
|
|
||||||
import customUI.Converter;
|
|
||||||
import helper.HttpRequestException;
|
import helper.HttpRequestException;
|
||||||
import javafx.fxml.FXML;
|
import container.DataController;
|
||||||
import javafx.util.StringConverter;
|
import container.Event;
|
||||||
import javafx.util.converter.LocalTimeStringConverter;
|
|
||||||
import res.DataController;
|
|
||||||
import res.Event;
|
|
||||||
|
|
||||||
import java.time.LocalTime;
|
|
||||||
import java.time.format.FormatStyle;
|
|
||||||
import java.util.Locale;
|
|
||||||
|
|
||||||
public class EditEventController extends CreateEventController{
|
public class EditEventController extends CreateEventController{
|
||||||
|
|
||||||
@ -23,7 +15,7 @@ public class EditEventController extends CreateEventController{
|
|||||||
public void setCurrentEvent(Event currentEvent) {
|
public void setCurrentEvent(Event currentEvent) {
|
||||||
this.currentEvent = currentEvent;
|
this.currentEvent = currentEvent;
|
||||||
|
|
||||||
textName.setText(Converter.convertString(currentEvent.getName()));
|
textName.setText(currentEvent.getName());
|
||||||
datePickerDate.setValue(currentEvent.getDate().toLocalDate());
|
datePickerDate.setValue(currentEvent.getDate().toLocalDate());
|
||||||
ComboBoxPriotity.getSelectionModel().select(currentEvent.getPriority());
|
ComboBoxPriotity.getSelectionModel().select(currentEvent.getPriority());
|
||||||
|
|
||||||
|
@ -6,8 +6,8 @@ import javafx.application.Application;
|
|||||||
import javafx.fxml.FXMLLoader;
|
import javafx.fxml.FXMLLoader;
|
||||||
import javafx.scene.Scene;
|
import javafx.scene.Scene;
|
||||||
import javafx.stage.Stage;
|
import javafx.stage.Stage;
|
||||||
import res.DataController;
|
import container.DataController;
|
||||||
import res.HttpRequest;
|
import container.HttpRequest;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
@ -2,8 +2,6 @@ package main;
|
|||||||
|
|
||||||
import config.Config;
|
import config.Config;
|
||||||
import config.ConfigLoader;
|
import config.ConfigLoader;
|
||||||
import customUI.Button;
|
|
||||||
import customUI.Label;
|
|
||||||
import helper.SvgBtnCreator;
|
import helper.SvgBtnCreator;
|
||||||
import helper.HttpRequestException;
|
import helper.HttpRequestException;
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
@ -12,17 +10,17 @@ import javafx.geometry.Pos;
|
|||||||
import javafx.scene.Group;
|
import javafx.scene.Group;
|
||||||
import javafx.scene.Node;
|
import javafx.scene.Node;
|
||||||
import javafx.scene.Scene;
|
import javafx.scene.Scene;
|
||||||
import javafx.scene.control.ScrollPane;
|
import javafx.scene.control.*;
|
||||||
import javafx.scene.layout.GridPane;
|
import javafx.scene.layout.GridPane;
|
||||||
import javafx.scene.layout.HBox;
|
import javafx.scene.layout.HBox;
|
||||||
import javafx.scene.layout.VBox;
|
import javafx.scene.layout.VBox;
|
||||||
import javafx.stage.Modality;
|
import javafx.stage.Modality;
|
||||||
import javafx.stage.Stage;
|
import javafx.stage.Stage;
|
||||||
import res.DataController;
|
import container.DataController;
|
||||||
import res.Event;
|
import container.Event;
|
||||||
|
|
||||||
import javafx.event.ActionEvent;
|
import javafx.event.ActionEvent;
|
||||||
import res.HttpRequest;
|
import container.HttpRequest;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
@ -154,7 +152,7 @@ public class MainController {
|
|||||||
private void createWeek() {
|
private void createWeek() {
|
||||||
for (int i = 0; i < 7; i++) {
|
for (int i = 0; i < 7; i++) {
|
||||||
Label label = new Label();
|
Label label = new Label();
|
||||||
label.setTextValue(dayNames[i]);
|
label.setText(dayNames[i]);
|
||||||
label.setMaxHeight(Double.MAX_VALUE);
|
label.setMaxHeight(Double.MAX_VALUE);
|
||||||
label.setMaxWidth(Double.MAX_VALUE);
|
label.setMaxWidth(Double.MAX_VALUE);
|
||||||
label.getStyleClass().add("labelDays");
|
label.getStyleClass().add("labelDays");
|
||||||
@ -236,6 +234,7 @@ public class MainController {
|
|||||||
vBox.getChildren().add(btnHBox);
|
vBox.getChildren().add(btnHBox);
|
||||||
|
|
||||||
Label nameLabel = new Label(event.getName());
|
Label nameLabel = new Label(event.getName());
|
||||||
|
nameLabel.setWrapText(true);
|
||||||
vBox.getChildren().add(nameLabel);
|
vBox.getChildren().add(nameLabel);
|
||||||
|
|
||||||
if (event.getStart() != null || event.getEnd() != null) {
|
if (event.getStart() != null || event.getEnd() != null) {
|
||||||
@ -248,11 +247,12 @@ public class MainController {
|
|||||||
Label typeLabel = new Label("Wer: " + event.getOwnerName());
|
Label typeLabel = new Label("Wer: " + event.getOwnerName());
|
||||||
vBox.getChildren().add(typeLabel);
|
vBox.getChildren().add(typeLabel);
|
||||||
|
|
||||||
Label prioLabel = new Label("Priorit\u00e4t: " + event.getPriority());
|
Label prioLabel = new Label("Priorität: " + event.getPriority());
|
||||||
vBox.getChildren().add(prioLabel);
|
vBox.getChildren().add(prioLabel);
|
||||||
|
|
||||||
if (event.isFullDay()) {
|
if (event.isFullDay()) {
|
||||||
Label fullDayLabel = new Label("Dieser Termin bockiert den ganzen Tag!");
|
Label fullDayLabel = new Label("Dieser Termin bockiert den ganzen Tag!");
|
||||||
|
fullDayLabel.setWrapText(true);
|
||||||
vBox.getChildren().add(fullDayLabel);
|
vBox.getChildren().add(fullDayLabel);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -286,7 +286,7 @@ public class MainController {
|
|||||||
weekStartDateTime = now.plusDays(weekOffset * 7L - dayOfWeek + 1);
|
weekStartDateTime = now.plusDays(weekOffset * 7L - dayOfWeek + 1);
|
||||||
|
|
||||||
for (int i = 0; i < 7; i++) {
|
for (int i = 0; i < 7; i++) {
|
||||||
dayLabel[i].setTextValue(dayFormatter.format(weekStartDateTime.plusDays(i)));
|
dayLabel[i].setText(dayFormatter.format(weekStartDateTime.plusDays(i)));
|
||||||
}
|
}
|
||||||
|
|
||||||
LabelMonth.setText(dateFormatter.format(weekStartDateTime));
|
LabelMonth.setText(dateFormatter.format(weekStartDateTime));
|
||||||
|
@ -1,6 +1,10 @@
|
|||||||
package main;
|
package main;
|
||||||
|
|
||||||
import com.jfoenix.controls.*;
|
import com.jfoenix.controls.*;
|
||||||
|
import config.Config;
|
||||||
|
import config.ConfigLoader;
|
||||||
|
import container.HttpRequest;
|
||||||
|
import helper.HttpRequestException;
|
||||||
import javafx.collections.FXCollections;
|
import javafx.collections.FXCollections;
|
||||||
import javafx.collections.ObservableList;
|
import javafx.collections.ObservableList;
|
||||||
import javafx.event.ActionEvent;
|
import javafx.event.ActionEvent;
|
||||||
@ -8,12 +12,23 @@ import javafx.fxml.FXML;
|
|||||||
import javafx.fxml.FXMLLoader;
|
import javafx.fxml.FXMLLoader;
|
||||||
import javafx.scene.Node;
|
import javafx.scene.Node;
|
||||||
import javafx.scene.Scene;
|
import javafx.scene.Scene;
|
||||||
|
import javafx.scene.control.Alert;
|
||||||
|
import javafx.scene.control.ButtonType;
|
||||||
import javafx.scene.control.Label;
|
import javafx.scene.control.Label;
|
||||||
|
import javafx.scene.layout.GridPane;
|
||||||
import javafx.stage.Modality;
|
import javafx.stage.Modality;
|
||||||
import javafx.stage.Stage;
|
import javafx.stage.Stage;
|
||||||
|
import container.DataController;
|
||||||
|
import container.User;
|
||||||
|
import users.EditUserController;
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
public class OptionController {
|
public class OptionController {
|
||||||
|
|
||||||
@ -28,11 +43,35 @@ public class OptionController {
|
|||||||
@FXML
|
@FXML
|
||||||
public Label labelError;
|
public Label labelError;
|
||||||
@FXML
|
@FXML
|
||||||
public JFXComboBox<String> userCmb;
|
public GridPane mainGrid;
|
||||||
|
|
||||||
|
private JFXComboBox<String> comboBox;
|
||||||
|
private DataController dataController;
|
||||||
|
private List<User> users;
|
||||||
|
private Config config;
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
public void initialize(){
|
public void initialize(){
|
||||||
|
dataController = new DataController();
|
||||||
|
try{
|
||||||
|
users = dataController.getAllUser();
|
||||||
|
} catch (HttpRequestException e){
|
||||||
|
users = new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
ObservableList<String> observableUserList = FXCollections.observableArrayList();
|
||||||
|
for (User user: users) {
|
||||||
|
observableUserList.add(user.getLogin());
|
||||||
|
}
|
||||||
|
comboBox = new JFXComboBox<>(observableUserList);
|
||||||
|
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) {
|
public void onBackBtnClick(ActionEvent actionEvent) {
|
||||||
@ -41,28 +80,79 @@ public class OptionController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void onCreateBtnClick(ActionEvent actionEvent) {
|
public void onCreateBtnClick(ActionEvent actionEvent) {
|
||||||
|
loadUserScene(actionEvent, "User erstellen", "../users/create-user.fxml", null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onUpdateBtnClick(ActionEvent actionEvent) {
|
||||||
|
int editIndex = comboBox.getSelectionModel().getSelectedIndex();
|
||||||
|
|
||||||
|
if(editIndex < 0 || editIndex >= users.size()) return;
|
||||||
|
|
||||||
|
FXMLLoader fxmlLoader = loadUserScene(
|
||||||
|
actionEvent,
|
||||||
|
"User bearbeiten",
|
||||||
|
"../users/edit-user.fxml",
|
||||||
|
this::setUserAtController
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onDeleteBtnClick(ActionEvent actionEvent) {
|
||||||
|
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 {
|
try {
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private FXMLLoader loadUserScene(ActionEvent actionEvent, String title, String fxml, Consumer<FXMLLoader> method) {
|
||||||
FXMLLoader fxmlLoader = new FXMLLoader(
|
FXMLLoader fxmlLoader = new FXMLLoader(
|
||||||
MainApplication.class.getResource("../users/create-user.fxml"));
|
MainApplication.class.getResource(fxml));
|
||||||
|
try {
|
||||||
Scene scene = new Scene(fxmlLoader.load(), 800, 650);
|
Scene scene = new Scene(fxmlLoader.load(), 800, 650);
|
||||||
scene.getStylesheets().add(Objects.requireNonNull(
|
scene.getStylesheets().add(Objects.requireNonNull(
|
||||||
MainApplication.class.getResource("../users/create-user.css")).toExternalForm());
|
MainApplication.class.getResource("../users/create-user.css")).toExternalForm());
|
||||||
Stage stage = new Stage();
|
Stage stage = new Stage();
|
||||||
stage.setTitle("User erstellen");
|
stage.setTitle(title);
|
||||||
stage.setScene(scene);
|
stage.setScene(scene);
|
||||||
stage.initModality(Modality.APPLICATION_MODAL);
|
stage.initModality(Modality.APPLICATION_MODAL);
|
||||||
stage.setResizable(false);
|
stage.setResizable(false);
|
||||||
|
|
||||||
|
if(method != null)method.accept(fxmlLoader);
|
||||||
|
|
||||||
stage.showAndWait();
|
stage.showAndWait();
|
||||||
Stage stageOld = (Stage) ((Node) actionEvent.getSource()).getScene().getWindow();
|
Stage stageOld = (Stage) ((Node) actionEvent.getSource()).getScene().getWindow();
|
||||||
stageOld.close();
|
stageOld.close();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
return fxmlLoader;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onUpdateBtnClick(ActionEvent actionEvent) {
|
private void setUserAtController(FXMLLoader fxmlLoader){
|
||||||
|
int editIndex = comboBox.getSelectionModel().getSelectedIndex();
|
||||||
|
EditUserController editUserController = fxmlLoader.getController();
|
||||||
|
editUserController.setCurrentUser(users.get(editIndex));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onDeleteBtnClick(ActionEvent actionEvent) {
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package users;
|
package users;
|
||||||
|
|
||||||
|
import helper.HttpRequestException;
|
||||||
import javafx.event.ActionEvent;
|
import javafx.event.ActionEvent;
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
import javafx.scene.Node;
|
import javafx.scene.Node;
|
||||||
@ -8,6 +9,8 @@ import javafx.scene.control.PasswordField;
|
|||||||
import javafx.scene.control.TextField;
|
import javafx.scene.control.TextField;
|
||||||
import javafx.scene.control.ToggleButton;
|
import javafx.scene.control.ToggleButton;
|
||||||
import javafx.stage.Stage;
|
import javafx.stage.Stage;
|
||||||
|
import container.DataController;
|
||||||
|
import container.User;
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
@ -39,15 +42,38 @@ public class CreateUserController {
|
|||||||
labelError.setText("Bitte Passwort eingeben!");
|
labelError.setText("Bitte Passwort eingeben!");
|
||||||
return;
|
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())){
|
if (!Objects.equals(textPassword.getText(), textPasswordSecond.getText())){
|
||||||
labelError.setText("Passwörter stimmen nicht überein!");
|
labelError.setText("Passwörter stimmen nicht überein!");
|
||||||
return;
|
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());
|
||||||
|
user.setAdmin(checkButtonIsAdmin.isSelected());
|
||||||
|
|
||||||
|
try {
|
||||||
|
sendHttpRequest(user);
|
||||||
|
} catch (HttpRequestException e) {
|
||||||
|
labelError.setText(e.getMessage());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Stage stage = (Stage) ((Node) event.getSource()).getScene().getWindow();
|
Stage stage = (Stage) ((Node) event.getSource()).getScene().getWindow();
|
||||||
stage.close();
|
stage.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void sendHttpRequest(User user) throws HttpRequestException {
|
||||||
|
DataController dataController = new DataController();
|
||||||
|
dataController.createUser(user);
|
||||||
|
}
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
protected void abortBtnClick(ActionEvent event) {
|
protected void abortBtnClick(ActionEvent event) {
|
||||||
Stage stage = (Stage) ((Node) event.getSource()).getScene().getWindow();
|
Stage stage = (Stage) ((Node) event.getSource()).getScene().getWindow();
|
||||||
|
92
client/app/src/main/java/users/EditUserController.java
Normal file
92
client/app/src/main/java/users/EditUserController.java
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
package users;
|
||||||
|
|
||||||
|
import container.DataController;
|
||||||
|
import container.User;
|
||||||
|
import helper.HttpRequestException;
|
||||||
|
import javafx.event.ActionEvent;
|
||||||
|
import javafx.scene.Node;
|
||||||
|
import javafx.scene.control.Alert;
|
||||||
|
import javafx.stage.Stage;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
public class EditUserController extends CreateUserController{
|
||||||
|
private User currentUser;
|
||||||
|
|
||||||
|
public User getCurrentUser() {
|
||||||
|
return currentUser;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCurrentUser(User currentUser) {
|
||||||
|
this.currentUser = currentUser;
|
||||||
|
|
||||||
|
textForename.setText(currentUser.getForename());
|
||||||
|
textName.setText(currentUser.getName());
|
||||||
|
textLogin.setText(currentUser.getLogin());
|
||||||
|
checkButtonIsAdmin.setSelected(currentUser.isAdmin());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void createUser(ActionEvent event){
|
||||||
|
if (textLogin.getText().trim().isEmpty()){
|
||||||
|
labelError.setText("Bitte Login Namen angeben");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (textForename.getText().trim().isEmpty()) {
|
||||||
|
labelError.setText("Bitte Vornamen eingeben!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (textName.getText().trim().isEmpty()) {
|
||||||
|
labelError.setText("Bitte Nachnamen eingeben!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
User user = new User();
|
||||||
|
|
||||||
|
if(!textPassword.getText().trim().isEmpty() || !textPasswordSecond.getText().trim().isEmpty()){
|
||||||
|
if (textPassword.getText().trim().isEmpty()) {
|
||||||
|
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.setPassword(textPassword.getText().trim());
|
||||||
|
}
|
||||||
|
|
||||||
|
user.setUserId(currentUser.getUserId());
|
||||||
|
user.setLogin(textLogin.getText().trim());
|
||||||
|
user.setForename(textForename.getText().trim());
|
||||||
|
user.setName(textName.getText().trim());
|
||||||
|
user.setAdmin(checkButtonIsAdmin.isSelected());
|
||||||
|
|
||||||
|
try {
|
||||||
|
sendHttpRequest(user);
|
||||||
|
} catch (HttpRequestException e) {
|
||||||
|
labelError.setText(e.getMessage());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(currentUser.getUserId() == DataController.USER_ID){
|
||||||
|
Alert alert = new Alert(
|
||||||
|
Alert.AlertType.WARNING,
|
||||||
|
"Bitte starte das Programm neu um die Änderungen anzuwenden."
|
||||||
|
);
|
||||||
|
alert.showAndWait();
|
||||||
|
}
|
||||||
|
|
||||||
|
Stage stage = (Stage) ((Node) event.getSource()).getScene().getWindow();
|
||||||
|
stage.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void sendHttpRequest(User user) throws HttpRequestException {
|
||||||
|
DataController dataController = new DataController();
|
||||||
|
dataController.editUser(user);
|
||||||
|
}
|
||||||
|
}
|
@ -6,7 +6,7 @@ import javafx.fxml.FXML;
|
|||||||
import javafx.scene.Node;
|
import javafx.scene.Node;
|
||||||
import javafx.scene.control.Label;
|
import javafx.scene.control.Label;
|
||||||
import javafx.stage.Stage;
|
import javafx.stage.Stage;
|
||||||
import res.DataController;
|
import container.DataController;
|
||||||
|
|
||||||
public class LoginController {
|
public class LoginController {
|
||||||
@FXML
|
@FXML
|
||||||
|
@ -3,12 +3,12 @@
|
|||||||
<?import javafx.scene.control.*?>
|
<?import javafx.scene.control.*?>
|
||||||
<?import javafx.scene.layout.*?>
|
<?import javafx.scene.layout.*?>
|
||||||
<?import com.jfoenix.controls.*?>
|
<?import com.jfoenix.controls.*?>
|
||||||
<?import javafx.collections.FXCollections?>
|
|
||||||
|
|
||||||
<GridPane xmlns="http://javafx.com/javafx"
|
<GridPane xmlns="http://javafx.com/javafx"
|
||||||
xmlns:fx="http://javafx.com/fxml"
|
xmlns:fx="http://javafx.com/fxml"
|
||||||
fx:controller="main.OptionController"
|
fx:controller="main.OptionController"
|
||||||
prefHeight="400.0" prefWidth="600.0">
|
prefHeight="400.0" prefWidth="600.0"
|
||||||
|
fx:id="mainGrid">
|
||||||
|
|
||||||
<columnConstraints>
|
<columnConstraints>
|
||||||
<ColumnConstraints minWidth="100"/>
|
<ColumnConstraints minWidth="100"/>
|
||||||
@ -33,13 +33,6 @@
|
|||||||
<Label styleClass="mainLabel" GridPane.columnIndex="2" GridPane.halignment="CENTER" >Einstellungen</Label>
|
<Label styleClass="mainLabel" GridPane.columnIndex="2" GridPane.halignment="CENTER" >Einstellungen</Label>
|
||||||
|
|
||||||
<Label GridPane.columnIndex="1" GridPane.rowIndex="2" GridPane.halignment="CENTER">User:</Label>
|
<Label GridPane.columnIndex="1" GridPane.rowIndex="2" GridPane.halignment="CENTER">User:</Label>
|
||||||
<JFXComboBox styleClass="comboBox" fx:id="userCmb" GridPane.columnIndex="2" GridPane.rowIndex="2">
|
|
||||||
<items>
|
|
||||||
<FXCollections fx:factory="observableArrayList">
|
|
||||||
|
|
||||||
</FXCollections>
|
|
||||||
</items>
|
|
||||||
</JFXComboBox>
|
|
||||||
|
|
||||||
<JFXButton styleClass="userBtn" fx:id="updateUserBtn" GridPane.columnIndex="1" GridPane.columnSpan="3"
|
<JFXButton styleClass="userBtn" fx:id="updateUserBtn" GridPane.columnIndex="1" GridPane.columnSpan="3"
|
||||||
GridPane.rowIndex="4" GridPane.halignment="CENTER" onAction="#onUpdateBtnClick">User bearbeiten</JFXButton>
|
GridPane.rowIndex="4" GridPane.halignment="CENTER" onAction="#onUpdateBtnClick">User bearbeiten</JFXButton>
|
||||||
@ -50,7 +43,7 @@
|
|||||||
|
|
||||||
<Label styleClass="loginLbl" GridPane.columnIndex="1" GridPane.rowIndex="8"
|
<Label styleClass="loginLbl" GridPane.columnIndex="1" GridPane.rowIndex="8"
|
||||||
GridPane.halignment="CENTER">Angemeldet bleiben:</Label>
|
GridPane.halignment="CENTER">Angemeldet bleiben:</Label>
|
||||||
<JFXToggleButton fx:id="saveLoginTBtn" GridPane.columnIndex="3" GridPane.rowIndex="8"/>
|
<JFXToggleButton fx:id="saveLoginTBtn" GridPane.columnIndex="3" GridPane.rowIndex="8" onAction="#toggledBtn"/>
|
||||||
|
|
||||||
<Label fx:id="labelError" styleClass="errorMessage" GridPane.columnIndex="1" GridPane.rowIndex="9"/>
|
<Label fx:id="labelError" styleClass="errorMessage" GridPane.columnIndex="1" GridPane.rowIndex="9"/>
|
||||||
<JFXButton GridPane.columnIndex="4" GridPane.rowIndex="9" onAction="#onBackBtnClick">Zurück</JFXButton>
|
<JFXButton GridPane.columnIndex="4" GridPane.rowIndex="9" onAction="#onBackBtnClick">Zurück</JFXButton>
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
<?import javafx.scene.control.*?>
|
<?import javafx.scene.control.*?>
|
||||||
<?import javafx.scene.layout.*?>
|
<?import javafx.scene.layout.*?>
|
||||||
<?import javafx.geometry.Insets?>
|
<?import javafx.geometry.Insets?>
|
||||||
|
<?import com.jfoenix.controls.JFXToggleButton?>
|
||||||
<GridPane xmlns="http://javafx.com/javafx"
|
<GridPane xmlns="http://javafx.com/javafx"
|
||||||
xmlns:fx="http://javafx.com/fxml"
|
xmlns:fx="http://javafx.com/fxml"
|
||||||
fx:controller="users.CreateUserController">
|
fx:controller="users.CreateUserController">
|
||||||
@ -40,16 +41,16 @@
|
|||||||
<PasswordField fx:id="textPassword" styleClass="textField" GridPane.columnIndex="2" GridPane.rowIndex="4" />
|
<PasswordField fx:id="textPassword" styleClass="textField" GridPane.columnIndex="2" GridPane.rowIndex="4" />
|
||||||
<PasswordField fx:id="textPasswordSecond" styleClass="textField" GridPane.columnIndex="2" GridPane.rowIndex="5" />
|
<PasswordField fx:id="textPasswordSecond" styleClass="textField" GridPane.columnIndex="2" GridPane.rowIndex="5" />
|
||||||
|
|
||||||
<ToggleButton fx:id="checkButtonIsAdmin" GridPane.columnIndex="2" GridPane.rowIndex="6"/>
|
<JFXToggleButton fx:id="checkButtonIsAdmin" GridPane.columnIndex="2" GridPane.rowIndex="6"/>
|
||||||
|
|
||||||
<Label fx:id="labelError" styleClass="errorMessage" GridPane.columnIndex="2" GridPane.rowIndex="7"/>
|
<Label fx:id="labelError" wrapText="true" styleClass="errorMessage" GridPane.columnIndex="2" GridPane.rowIndex="7"/>
|
||||||
|
|
||||||
<HBox GridPane.columnIndex="2" GridPane.rowIndex="8" alignment="CENTER_RIGHT">
|
<HBox GridPane.columnIndex="2" GridPane.rowIndex="8" alignment="CENTER_RIGHT">
|
||||||
<HBox.margin>
|
<HBox.margin>
|
||||||
<Insets right="100" left="100"/>
|
<Insets right="100" left="100"/>
|
||||||
</HBox.margin>
|
</HBox.margin>
|
||||||
<Button onAction="#abortBtnClick">Abbrechen</Button>
|
<Button onAction="#abortBtnClick">Abbrechen</Button>
|
||||||
<Button onAction="#createUser" styleClass="btnLogin" >Anmelden</Button>
|
<Button onAction="#createUser" styleClass="btnLogin" >Anlegen</Button>
|
||||||
|
|
||||||
</HBox>
|
</HBox>
|
||||||
</GridPane>
|
</GridPane>
|
||||||
|
57
client/app/src/main/resources/users/edit-user.fxml
Normal file
57
client/app/src/main/resources/users/edit-user.fxml
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
|
<?import javafx.scene.control.*?>
|
||||||
|
<?import javafx.scene.layout.*?>
|
||||||
|
<?import javafx.geometry.Insets?>
|
||||||
|
<?import com.jfoenix.controls.JFXToggleButton?>
|
||||||
|
<GridPane xmlns="http://javafx.com/javafx"
|
||||||
|
xmlns:fx="http://javafx.com/fxml"
|
||||||
|
fx:controller="users.EditUserController">
|
||||||
|
<columnConstraints>
|
||||||
|
<ColumnConstraints minWidth="100"/>
|
||||||
|
<ColumnConstraints minWidth="100"/>
|
||||||
|
<ColumnConstraints minWidth="100"/>
|
||||||
|
</columnConstraints>
|
||||||
|
<rowConstraints>
|
||||||
|
<RowConstraints vgrow="ALWAYS" />
|
||||||
|
<RowConstraints vgrow="ALWAYS" />
|
||||||
|
<RowConstraints vgrow="ALWAYS" />
|
||||||
|
<RowConstraints vgrow="ALWAYS" />
|
||||||
|
<RowConstraints vgrow="ALWAYS" />
|
||||||
|
<RowConstraints vgrow="ALWAYS" />
|
||||||
|
<RowConstraints vgrow="ALWAYS" />
|
||||||
|
<RowConstraints vgrow="ALWAYS" />
|
||||||
|
<RowConstraints vgrow="ALWAYS" />
|
||||||
|
<RowConstraints vgrow="ALWAYS" />
|
||||||
|
</rowConstraints>
|
||||||
|
|
||||||
|
<Label styleClass="mainLabel" GridPane.columnIndex="2" >User bearbeiten</Label>
|
||||||
|
|
||||||
|
<Label styleClass="inputLabel" GridPane.rowIndex="1" GridPane.columnIndex="1">Login:</Label>
|
||||||
|
<Label styleClass="inputLabel" GridPane.rowIndex="2" GridPane.columnIndex="1">Vorname:</Label>
|
||||||
|
<Label styleClass="inputLabel" GridPane.rowIndex="3" GridPane.columnIndex="1">Nachname:</Label>
|
||||||
|
<Label styleClass="inputLabel" GridPane.rowIndex="4" GridPane.columnIndex="1">Passwort:</Label>
|
||||||
|
<Label styleClass="inputLabel" GridPane.rowIndex="5" GridPane.columnIndex="1">Passwort wiederholen:</Label>
|
||||||
|
|
||||||
|
<Label styleClass="inputLabelAdmin" GridPane.rowIndex="6" GridPane.columnIndex="1">Admin:</Label>
|
||||||
|
|
||||||
|
<TextField fx:id="textLogin" styleClass="textField" GridPane.columnIndex="2" GridPane.rowIndex="1" />
|
||||||
|
<TextField fx:id="textForename" styleClass="textField" GridPane.columnIndex="2" GridPane.rowIndex="2" />
|
||||||
|
<TextField fx:id="textName" styleClass="textField" GridPane.columnIndex="2" GridPane.rowIndex="3" />
|
||||||
|
<PasswordField fx:id="textPassword" styleClass="textField" GridPane.columnIndex="2" GridPane.rowIndex="4" />
|
||||||
|
<PasswordField fx:id="textPasswordSecond" styleClass="textField" GridPane.columnIndex="2" GridPane.rowIndex="5" />
|
||||||
|
|
||||||
|
<JFXToggleButton fx:id="checkButtonIsAdmin" GridPane.columnIndex="2" GridPane.rowIndex="6"/>
|
||||||
|
|
||||||
|
<Label fx:id="labelError" wrapText="true" styleClass="errorMessage" GridPane.columnIndex="2" GridPane.rowIndex="7"/>
|
||||||
|
|
||||||
|
<HBox GridPane.columnIndex="2" GridPane.rowIndex="8" alignment="CENTER_RIGHT">
|
||||||
|
<HBox.margin>
|
||||||
|
<Insets right="100" left="100"/>
|
||||||
|
</HBox.margin>
|
||||||
|
<Button onAction="#abortBtnClick">Abbrechen</Button>
|
||||||
|
<Button onAction="#createUser" styleClass="btnLogin" >Bearbeiten</Button>
|
||||||
|
|
||||||
|
</HBox>
|
||||||
|
</GridPane>
|
||||||
|
|
@ -2,6 +2,10 @@ plugins {
|
|||||||
java
|
java
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tasks.withType<JavaCompile> {
|
||||||
|
options.encoding = "UTF-8"
|
||||||
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
val jacksonVersion = "2.13.0"
|
val jacksonVersion = "2.13.0"
|
||||||
implementation("com.fasterxml.jackson.core:jackson-databind:$jacksonVersion")
|
implementation("com.fasterxml.jackson.core:jackson-databind:$jacksonVersion")
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package config;
|
package config;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import res.DataController;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
@ -18,8 +17,10 @@ public class ConfigLoader {
|
|||||||
return objectMapper.readValue(jsonString, Config.class);
|
return objectMapper.readValue(jsonString, Config.class);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
System.out.println("config.json missing");
|
System.out.println("config.json missing");
|
||||||
|
Config config = new Config(false, -1, "");
|
||||||
|
save(config);
|
||||||
|
return config;
|
||||||
}
|
}
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void save(Config config){
|
public static void save(Config config){
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package res;
|
package container;
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import com.fasterxml.jackson.core.type.TypeReference;
|
import com.fasterxml.jackson.core.type.TypeReference;
|
||||||
@ -6,13 +6,6 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
|||||||
import helper.HttpRequestException;
|
import helper.HttpRequestException;
|
||||||
import helper.Tuple;
|
import helper.Tuple;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
|
||||||
import java.io.DataOutputStream;
|
|
||||||
import java.io.InputStreamReader;
|
|
||||||
import java.io.OutputStream;
|
|
||||||
import java.net.HttpURLConnection;
|
|
||||||
import java.net.URL;
|
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
@ -118,7 +111,6 @@ public class DataController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList<Event> getAllVisibleEvents(LocalDateTime startDate, LocalDateTime endDate) throws HttpRequestException {
|
public ArrayList<Event> getAllVisibleEvents(LocalDateTime startDate, LocalDateTime endDate) throws HttpRequestException {
|
||||||
ArrayList<Event> eventList = new ArrayList<>();
|
|
||||||
try {
|
try {
|
||||||
Tuple<Integer, String> response = httpRequest.sendPostRequest(
|
Tuple<Integer, String> response = httpRequest.sendPostRequest(
|
||||||
ALL_EVENTS_ENDPOINT,
|
ALL_EVENTS_ENDPOINT,
|
||||||
@ -133,28 +125,51 @@ public class DataController {
|
|||||||
|
|
||||||
ObjectMapper objectMapper = new ObjectMapper();
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
objectMapper.findAndRegisterModules();
|
objectMapper.findAndRegisterModules();
|
||||||
eventList = (ArrayList<Event>) objectMapper.readValue(jsonResponse, new TypeReference<List<Event>>() {
|
return (ArrayList<Event>) objectMapper.readValue(jsonResponse, new TypeReference<List<Event>>() {
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
} catch (HttpRequestException e) {
|
} catch (HttpRequestException e) {
|
||||||
throw e;
|
throw e;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new HttpRequestException("Es konnte keine Verbindung mit dem Server hergestellt werden.", 600);
|
throw new HttpRequestException("Es konnte keine Verbindung mit dem Server hergestellt werden.", 600);
|
||||||
}
|
}
|
||||||
|
|
||||||
return eventList;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/********
|
/********
|
||||||
* User *
|
* User *
|
||||||
********/
|
********/
|
||||||
|
|
||||||
/*
|
public List<User> getAllUser() throws HttpRequestException {
|
||||||
|
String userJSON = sendBasicHttpRequest(
|
||||||
|
ALL_USER_ENDPOINT,
|
||||||
|
"",
|
||||||
|
true
|
||||||
|
);
|
||||||
|
|
||||||
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
|
objectMapper.findAndRegisterModules();
|
||||||
|
try {
|
||||||
|
List<User> list = objectMapper.readValue(userJSON, new TypeReference<>() {
|
||||||
|
});
|
||||||
|
|
||||||
|
for(User u : list){
|
||||||
|
System.out.println(u);
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
} catch (JsonProcessingException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
public void createUser(User user) throws HttpRequestException {
|
public void createUser(User user) throws HttpRequestException {
|
||||||
sendBasicHttpRequest(
|
sendBasicHttpRequest(
|
||||||
ADD_USER_ENDPOINT,
|
ADD_USER_ENDPOINT,
|
||||||
user.getAsUrlParam(),
|
"name=" + user.getName() +
|
||||||
|
"&forename=" + user.getForename() +
|
||||||
|
"&login=" + user.getLogin() +
|
||||||
|
"&password=" + user.getPassword() +
|
||||||
|
"&isAdmin=" + user.isAdmin(),
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -162,21 +177,28 @@ public class DataController {
|
|||||||
public void deleteUser(User user) throws HttpRequestException {
|
public void deleteUser(User user) throws HttpRequestException {
|
||||||
sendBasicHttpRequest(
|
sendBasicHttpRequest(
|
||||||
DELETE_USER_ENDPOINT,
|
DELETE_USER_ENDPOINT,
|
||||||
user.getAsUrlParam(),
|
"userId=" + user.getUserId(),
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void editUser(User oldUser, User user) throws HttpRequestException {
|
public void editUser(User user) throws HttpRequestException {
|
||||||
|
String urlParam = "userId=" + user.getUserId() +
|
||||||
|
"&name=" + user.getName() +
|
||||||
|
"&forename=" + user.getForename() +
|
||||||
|
"&login=" + user.getLogin() +
|
||||||
|
"&isAdmin=" + user.isAdmin() +
|
||||||
|
(user.getPassword() == null ? "" : "&password=" + user.getPassword());
|
||||||
|
|
||||||
|
System.out.println(urlParam);
|
||||||
sendBasicHttpRequest(
|
sendBasicHttpRequest(
|
||||||
EDIT_USER_ENDPOINT,
|
EDIT_USER_ENDPOINT,
|
||||||
user.getAsUrlParam(),
|
urlParam,
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
private void sendBasicHttpRequest(String urlString, String urlParameters, boolean sendAuth) throws HttpRequestException {
|
private String sendBasicHttpRequest(String urlString, String urlParameters, boolean sendAuth) throws HttpRequestException {
|
||||||
try {
|
try {
|
||||||
Tuple<Integer, String> response = httpRequest.sendPostRequest(
|
Tuple<Integer, String> response = httpRequest.sendPostRequest(
|
||||||
urlString,
|
urlString,
|
||||||
@ -186,6 +208,8 @@ public class DataController {
|
|||||||
if (response.getKey() != 200) {
|
if (response.getKey() != 200) {
|
||||||
throw new HttpRequestException(response);
|
throw new HttpRequestException(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return response.getValue();
|
||||||
} catch (HttpRequestException e) {
|
} catch (HttpRequestException e) {
|
||||||
throw e;
|
throw e;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
@ -1,19 +1,11 @@
|
|||||||
package res;
|
package container;
|
||||||
|
|
||||||
import com.sun.jdi.event.StepEvent;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
import java.sql.SQLOutput;
|
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
import java.time.LocalDate;
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.LocalTime;
|
import java.time.LocalTime;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
import java.util.regex.PatternSyntaxException;
|
|
||||||
|
|
||||||
public class Event {
|
public class Event {
|
||||||
|
|
||||||
@ -44,15 +36,15 @@ public class Event {
|
|||||||
|
|
||||||
System.out.println("Create Event");
|
System.out.println("Create Event");
|
||||||
if (name.length() < 3) {
|
if (name.length() < 3) {
|
||||||
throw new IllegalArgumentException("Der Name muss eine L\u00e4nge von 3 haben.");
|
throw new IllegalArgumentException("Der Name muss eine Länge von 3 haben.");
|
||||||
}
|
}
|
||||||
Pattern pattern = Pattern.compile("[A-Za-z\u00e4\u00f6\u00fc\u00c4\u00d6\u00dc\u00df0-9 =!?+*/$.:,;_<>()-]*");
|
Pattern pattern = Pattern.compile("[A-Za-zäöüÄÖÜß0-9 =!?+*/$.:,;_<>()-]*");
|
||||||
Matcher matcher = pattern.matcher(name);
|
Matcher matcher = pattern.matcher(name);
|
||||||
if (!matcher.matches()) {
|
if (!matcher.matches()) {
|
||||||
throw new IllegalArgumentException("Der Name darf nur aus Zahlen, Buchstaben und folgenden Sonderzeichen bestehen: \u00e4\u00f6\u00fc \u00c4\u00d6\u00dc \u00df =!?+*/$.:,;_ <>()-");
|
throw new IllegalArgumentException("Der Name darf nur aus Zahlen, Buchstaben und folgenden Sonderzeichen bestehen: äöü ÄÖÜ ß =!?+*/$.:,;_ <>()-");
|
||||||
}
|
}
|
||||||
if (priority < 0) {
|
if (priority < 0) {
|
||||||
throw new IllegalArgumentException("Bitte eine Priorit\u00e4t w\u00e4hlen.");
|
throw new IllegalArgumentException("Bitte eine Priorität wählen.");
|
||||||
}
|
}
|
||||||
LocalDateTime today = LocalDateTime.now().toLocalDate().atStartOfDay();
|
LocalDateTime today = LocalDateTime.now().toLocalDate().atStartOfDay();
|
||||||
if (Duration.between(today, date).isNegative()) {
|
if (Duration.between(today, date).isNegative()) {
|
||||||
@ -82,9 +74,7 @@ public class Event {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setName(String name) {
|
public void setName(String name) {
|
||||||
System.out.println(name);
|
|
||||||
this.name = name;
|
this.name = name;
|
||||||
System.out.println(this.name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getPriority() {
|
public int getPriority() {
|
@ -1,4 +1,4 @@
|
|||||||
package res;
|
package container;
|
||||||
|
|
||||||
import helper.Tuple;
|
import helper.Tuple;
|
||||||
|
|
||||||
@ -9,7 +9,6 @@ import java.io.InputStreamReader;
|
|||||||
import java.net.HttpURLConnection;
|
import java.net.HttpURLConnection;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.Arrays;
|
|
||||||
|
|
||||||
public class HttpRequest {
|
public class HttpRequest {
|
||||||
public static String TOKEN = "";
|
public static String TOKEN = "";
|
||||||
@ -61,9 +60,9 @@ public class HttpRequest {
|
|||||||
BufferedReader in;
|
BufferedReader in;
|
||||||
|
|
||||||
if (status == 200) {
|
if (status == 200) {
|
||||||
in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
|
in = new BufferedReader(new InputStreamReader(connection.getInputStream(), StandardCharsets.UTF_8));
|
||||||
} else {
|
} else {
|
||||||
in = new BufferedReader(new InputStreamReader(connection.getErrorStream()));
|
in = new BufferedReader(new InputStreamReader(connection.getErrorStream(), StandardCharsets.UTF_8));
|
||||||
}
|
}
|
||||||
|
|
||||||
while ((inputLine = in.readLine()) != null) {
|
while ((inputLine = in.readLine()) != null) {
|
75
client/data/src/main/java/container/User.java
Normal file
75
client/data/src/main/java/container/User.java
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
package container;
|
||||||
|
|
||||||
|
public class User {
|
||||||
|
|
||||||
|
private int userId;
|
||||||
|
private String login;
|
||||||
|
private String forename;
|
||||||
|
private String name;
|
||||||
|
private String password;
|
||||||
|
private boolean isAdmin;
|
||||||
|
|
||||||
|
public User(){}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public int getUserId() {
|
||||||
|
return userId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUserId(int userId) {
|
||||||
|
this.userId = userId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLogin() {
|
||||||
|
return login;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLogin(String login) {
|
||||||
|
this.login = login;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getForename() {
|
||||||
|
return forename;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setForename(String forename) {
|
||||||
|
this.forename = forename;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isAdmin() {
|
||||||
|
return isAdmin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAdmin(boolean admin) {
|
||||||
|
isAdmin = admin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPassword() {
|
||||||
|
return password;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPassword(String password) {
|
||||||
|
this.password = password;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "User{" +
|
||||||
|
"userId=" + userId +
|
||||||
|
", login='" + login + '\'' +
|
||||||
|
", forename='" + forename + '\'' +
|
||||||
|
", name='" + name + '\'' +
|
||||||
|
", password='" + password + '\'' +
|
||||||
|
", isAdmin=" + isAdmin +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
}
|
@ -1,44 +0,0 @@
|
|||||||
package res;
|
|
||||||
|
|
||||||
public class User {
|
|
||||||
|
|
||||||
private int id;
|
|
||||||
private String loginName;
|
|
||||||
private String forename;
|
|
||||||
private String name;
|
|
||||||
|
|
||||||
public User(){
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setId(int id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getLoginName() {
|
|
||||||
return loginName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLoginName(String loginName) {
|
|
||||||
this.loginName = loginName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getForename() {
|
|
||||||
return forename;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setForename(String forename) {
|
|
||||||
this.forename = forename;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setName(String name) {
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user