Compare commits
11 Commits
option-ui
...
1800-UI-Us
Author | SHA1 | Date | |
---|---|---|---|
58fc25c27e | |||
65d96bbd81 | |||
8c3925ea1a | |||
3f41005d84 | |||
2fbf3895c5 | |||
d41abdbad9 | |||
db339eeada | |||
245314a887 | |||
72fdce471b | |||
780ecbee0f | |||
4db6bd1c66 |
@@ -5,13 +5,17 @@ plugins {
|
||||
}
|
||||
|
||||
javafx {
|
||||
version = "11"
|
||||
version = "11.0.2"
|
||||
modules(
|
||||
"javafx.controls",
|
||||
"javafx.fxml"
|
||||
)
|
||||
}
|
||||
|
||||
tasks.withType<JavaCompile> {
|
||||
options.encoding = "UTF-8"
|
||||
}
|
||||
|
||||
application {
|
||||
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));
|
||||
}
|
||||
|
||||
}
|
@@ -1,4 +1,4 @@
|
||||
package main;
|
||||
package events;
|
||||
|
||||
import com.jfoenix.controls.*;
|
||||
import helper.HttpRequestException;
|
||||
@@ -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,9 +1,8 @@
|
||||
package main;
|
||||
package events;
|
||||
|
||||
import customUI.Converter;
|
||||
import helper.HttpRequestException;
|
||||
import res.DataController;
|
||||
import res.Event;
|
||||
import container.DataController;
|
||||
import container.Event;
|
||||
|
||||
public class EditEventController extends CreateEventController{
|
||||
|
||||
@@ -16,7 +15,7 @@ public class EditEventController extends CreateEventController{
|
||||
public void setCurrentEvent(Event currentEvent) {
|
||||
this.currentEvent = currentEvent;
|
||||
|
||||
textName.setText(Converter.convertString(currentEvent.getName()));
|
||||
textName.setText(currentEvent.getName());
|
||||
datePickerDate.setValue(currentEvent.getDate().toLocalDate());
|
||||
ComboBoxPriotity.getSelectionModel().select(currentEvent.getPriority());
|
||||
|
@@ -2,15 +2,20 @@ package main;
|
||||
|
||||
import config.Config;
|
||||
import config.ConfigLoader;
|
||||
import helper.Tuple;
|
||||
import javafx.application.Application;
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.stage.Modality;
|
||||
import javafx.stage.Stage;
|
||||
import res.DataController;
|
||||
import res.HttpRequest;
|
||||
import container.DataController;
|
||||
import container.HttpRequest;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Objects;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class MainApplication extends Application {
|
||||
@Override
|
||||
@@ -70,4 +75,32 @@ public class MainApplication extends Application {
|
||||
public static void main(String[] args) {
|
||||
launch();
|
||||
}
|
||||
|
||||
public static void loadScene(
|
||||
String title,
|
||||
String fxml,
|
||||
String css,
|
||||
int width,
|
||||
int height,
|
||||
Consumer<FXMLLoader> method
|
||||
) {
|
||||
FXMLLoader fxmlLoader = new FXMLLoader(
|
||||
MainApplication.class.getResource(fxml));
|
||||
try {
|
||||
Scene scene = new Scene(fxmlLoader.load(), width, height);
|
||||
scene.getStylesheets().add(Objects.requireNonNull(
|
||||
MainApplication.class.getResource(css)).toExternalForm());
|
||||
Stage stage = new Stage();
|
||||
stage.setTitle(title);
|
||||
stage.setScene(scene);
|
||||
stage.initModality(Modality.APPLICATION_MODAL);
|
||||
stage.setResizable(false);
|
||||
|
||||
if(method != null)method.accept(fxmlLoader);
|
||||
|
||||
stage.showAndWait();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
@@ -2,27 +2,27 @@ package main;
|
||||
|
||||
import config.Config;
|
||||
import config.ConfigLoader;
|
||||
import customUI.Button;
|
||||
import customUI.Label;
|
||||
import helper.SvgBtnCreator;
|
||||
import events.EditEventController;
|
||||
import ui.DayPane;
|
||||
import ui.EventPane;
|
||||
import ui.SvgBtnCreator;
|
||||
import helper.HttpRequestException;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.Group;
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.control.ScrollPane;
|
||||
import javafx.scene.control.*;
|
||||
import javafx.scene.layout.GridPane;
|
||||
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;
|
||||
@@ -126,21 +126,14 @@ public class MainController {
|
||||
}
|
||||
|
||||
protected void onSettingBtnClick(){
|
||||
try{
|
||||
FXMLLoader fxmlLoader = new FXMLLoader(
|
||||
MainApplication.class.getResource("option-view.fxml"));
|
||||
Scene scene = new Scene(fxmlLoader.load(), 650, 650);
|
||||
scene.getStylesheets().add(Objects.requireNonNull(
|
||||
MainApplication.class.getResource("option-view.css")).toExternalForm());
|
||||
Stage stage = new Stage();
|
||||
stage.setTitle("Einstellungen");
|
||||
stage.setScene(scene);
|
||||
stage.initModality(Modality.APPLICATION_MODAL);
|
||||
stage.setResizable(false);
|
||||
stage.showAndWait();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
MainApplication.loadScene(
|
||||
"Einstellungen",
|
||||
"option-view.fxml",
|
||||
"option-view.css",
|
||||
650,
|
||||
600,
|
||||
null
|
||||
);
|
||||
}
|
||||
|
||||
protected void onLogoutBtnClick(ActionEvent event){
|
||||
@@ -153,128 +146,47 @@ public class MainController {
|
||||
|
||||
private void createWeek() {
|
||||
for (int i = 0; i < 7; i++) {
|
||||
Label label = new Label();
|
||||
label.setTextValue(dayNames[i]);
|
||||
label.setMaxHeight(Double.MAX_VALUE);
|
||||
label.setMaxWidth(Double.MAX_VALUE);
|
||||
label.getStyleClass().add("labelDays");
|
||||
dayLabel[i] = label;
|
||||
calendarGrid.add(label, i, 0);
|
||||
|
||||
ScrollPane scrollPane = new ScrollPane();
|
||||
|
||||
VBox vBox = new VBox();
|
||||
vBox.getStyleClass().add("vBoxDays");
|
||||
vBox.setSpacing(10);
|
||||
dayVBoxes[i] = vBox;
|
||||
scrollPane.setContent(vBox);
|
||||
|
||||
scrollPane.setFitToWidth(true);
|
||||
scrollPane.setFitToHeight(true);
|
||||
scrollPane.setHbarPolicy(ScrollPane.ScrollBarPolicy.AS_NEEDED);
|
||||
scrollPane.getStyleClass().add("scrollDays");
|
||||
|
||||
calendarGrid.add(scrollPane, i, 1);
|
||||
DayPane dayPane = new DayPane(dayNames[i]);
|
||||
this.dayLabel[i] = dayPane.getDayLabel();
|
||||
calendarGrid.add(dayPane.getDayLabel(), i, 0);
|
||||
dayVBoxes[i] = dayPane.getDayVBox();
|
||||
calendarGrid.add(dayPane.getScrollPane(), i, 1);
|
||||
}
|
||||
}
|
||||
|
||||
private void addEvent(Event event) {
|
||||
VBox vBox = new VBox();
|
||||
vBox.getStyleClass().add("event");
|
||||
vBox.setSpacing(5);
|
||||
EventPane eventPane = new EventPane(event);
|
||||
eventPane.getEditBtn().setOnAction(event1 -> MainApplication.loadScene(
|
||||
"edit-event.fxml",
|
||||
"create-event.css",
|
||||
"Termin bearbeiten",
|
||||
600,
|
||||
600,
|
||||
fxmlLoader -> {
|
||||
EditEventController editEventController = fxmlLoader.getController();
|
||||
editEventController.setCurrentEvent(event);
|
||||
}
|
||||
));
|
||||
|
||||
HBox btnHBox = new HBox();
|
||||
btnHBox.setAlignment(Pos.BOTTOM_RIGHT);
|
||||
|
||||
Group svgDel = new Group(
|
||||
SvgBtnCreator.createPath("M0 0h24v24H0z", "transparent", "transparent"),
|
||||
SvgBtnCreator.createPath("M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z",
|
||||
"white", "gray")
|
||||
);
|
||||
Button deleteBtn = SvgBtnCreator.createBtn(svgDel, 24, "", "Löschen des Termins");
|
||||
|
||||
deleteBtn.getStyleClass().add("deleteEventBtn");
|
||||
deleteBtn.setOnAction(e -> {
|
||||
eventPane.getDeleteBtn().setOnAction(e -> {
|
||||
DataController dataController = new DataController();
|
||||
try {
|
||||
dataController.deleteEvent(event.getOwnerId(), event.getId(), event.getDate());
|
||||
} catch (HttpRequestException ex) {
|
||||
ex.printStackTrace();
|
||||
new Alert(Alert.AlertType.ERROR, ex.getMessage()).showAndWait();
|
||||
}
|
||||
updateEvents();
|
||||
});
|
||||
|
||||
Group svgEdit = new Group(
|
||||
SvgBtnCreator.createPath("M0 0h24v24H0z", "transparent", "transparent"),
|
||||
SvgBtnCreator.createPath("M3 17.25V21h3.75L17.81 9.94l-3.75-3.75L3 17.25zM20.71 7.04c.39-.39.39-1.02 0-1.41l-2.34-2.34c-.39-.39-1.02-.39-1.41 0l-1.83 1.83 3.75 3.75 1.83-1.83z",
|
||||
"white", "gray")
|
||||
);
|
||||
Button editBtn = SvgBtnCreator.createBtn(svgEdit, 24, "", "Bearbeiten des Termins");
|
||||
editBtn.getStyleClass().add("editEventBtn");
|
||||
editBtn.setOnAction(event1 -> {
|
||||
try {
|
||||
FXMLLoader fxmlLoader = new FXMLLoader(
|
||||
MainApplication.class.getResource("edit-event.fxml"));
|
||||
Scene scene = new Scene(fxmlLoader.load(), 650, 650);
|
||||
scene.getStylesheets().add(Objects.requireNonNull(
|
||||
MainApplication.class.getResource("create-event.css")).toExternalForm());
|
||||
Stage stage = new Stage();
|
||||
stage.setTitle("Termin bearbeiten");
|
||||
stage.setScene(scene);
|
||||
stage.initModality(Modality.APPLICATION_MODAL);
|
||||
stage.setResizable(false);
|
||||
EditEventController editEventController = fxmlLoader.getController();
|
||||
editEventController.setCurrentEvent(event);
|
||||
stage.showAndWait();
|
||||
updateEvents();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
btnHBox.getChildren().add(editBtn);
|
||||
btnHBox.getChildren().add(deleteBtn);
|
||||
vBox.getChildren().add(btnHBox);
|
||||
|
||||
Label nameLabel = new Label(event.getName());
|
||||
vBox.getChildren().add(nameLabel);
|
||||
|
||||
if (event.getStart() != null || event.getEnd() != null) {
|
||||
String timeStr = (event.getStart() != null ? formatTime(event.getStart()) : "")
|
||||
+ (event.getEnd() != null ? " - " + formatTime(event.getEnd()) : "");
|
||||
Label timeLabel = new Label(timeStr);
|
||||
vBox.getChildren().add(timeLabel);
|
||||
}
|
||||
|
||||
Label typeLabel = new Label("Wer: " + event.getOwnerName());
|
||||
vBox.getChildren().add(typeLabel);
|
||||
|
||||
Label prioLabel = new Label("Priorit\u00e4t: " + event.getPriority());
|
||||
vBox.getChildren().add(prioLabel);
|
||||
|
||||
if (event.isFullDay()) {
|
||||
Label fullDayLabel = new Label("Dieser Termin bockiert den ganzen Tag!");
|
||||
vBox.getChildren().add(fullDayLabel);
|
||||
}
|
||||
|
||||
|
||||
LocalDateTime eventDate = event.getDate();
|
||||
|
||||
int day = (int) Duration.between(
|
||||
weekStartDateTime.toLocalDate().atStartOfDay(), eventDate.toLocalDate().atStartOfDay()).toDays();
|
||||
|
||||
if (day >= 0 && day < 7) {
|
||||
dayVBoxes[day].getChildren().add(vBox);
|
||||
dayVBoxes[day].getChildren().add(eventPane);
|
||||
}
|
||||
}
|
||||
|
||||
private String formatTime(String time) {
|
||||
String[] timeArr = time.split(":");
|
||||
if (timeArr.length > 2) {
|
||||
return timeArr[0] + ":" + timeArr[1];
|
||||
}
|
||||
return time;
|
||||
}
|
||||
|
||||
private void setDates() {
|
||||
DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("LLLL yyyy");
|
||||
DateTimeFormatter dayFormatter = DateTimeFormatter.ofPattern("E dd.MM");
|
||||
@@ -286,7 +198,7 @@ public class MainController {
|
||||
weekStartDateTime = now.plusDays(weekOffset * 7L - dayOfWeek + 1);
|
||||
|
||||
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));
|
||||
|
@@ -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;
|
||||
@@ -8,18 +11,18 @@ import javafx.event.ActionEvent;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.control.Alert;
|
||||
import javafx.scene.control.ButtonType;
|
||||
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 users.EditUserController;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
|
||||
public class OptionController {
|
||||
|
||||
@@ -36,10 +39,14 @@ public class OptionController {
|
||||
@FXML
|
||||
public GridPane mainGrid;
|
||||
|
||||
private JFXComboBox<String> comboBox;
|
||||
private DataController dataController;
|
||||
private List<User> users;
|
||||
private Config config;
|
||||
|
||||
@FXML
|
||||
public void initialize(){
|
||||
DataController dataController = new DataController();
|
||||
List<User> users;
|
||||
dataController = new DataController();
|
||||
try{
|
||||
users = dataController.getAllUser();
|
||||
} catch (HttpRequestException e){
|
||||
@@ -50,10 +57,15 @@ public class OptionController {
|
||||
for (User user: users) {
|
||||
observableUserList.add(user.getLogin());
|
||||
}
|
||||
JFXComboBox<String> comboBox = new JFXComboBox<>(observableUserList);
|
||||
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) {
|
||||
@@ -62,28 +74,66 @@ public class OptionController {
|
||||
}
|
||||
|
||||
public void onCreateBtnClick(ActionEvent actionEvent) {
|
||||
try{
|
||||
FXMLLoader fxmlLoader = new FXMLLoader(
|
||||
MainApplication.class.getResource("../users/create-user.fxml"));
|
||||
Scene scene = new Scene(fxmlLoader.load(), 800, 650);
|
||||
scene.getStylesheets().add(Objects.requireNonNull(
|
||||
MainApplication.class.getResource("../users/create-user.css")).toExternalForm());
|
||||
Stage stage = new Stage();
|
||||
stage.setTitle("User erstellen");
|
||||
stage.setScene(scene);
|
||||
stage.initModality(Modality.APPLICATION_MODAL);
|
||||
stage.setResizable(false);
|
||||
stage.showAndWait();
|
||||
Stage stageOld = (Stage) ((Node) actionEvent.getSource()).getScene().getWindow();
|
||||
stageOld.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
MainApplication.loadScene(
|
||||
"User erstellen",
|
||||
"../users/create-user.fxml",
|
||||
"../users/create-user.css",
|
||||
800,
|
||||
650,
|
||||
null
|
||||
);
|
||||
}
|
||||
|
||||
public void onUpdateBtnClick(ActionEvent actionEvent) {
|
||||
int editIndex = comboBox.getSelectionModel().getSelectedIndex();
|
||||
|
||||
if(editIndex < 0 || editIndex >= users.size()) return;
|
||||
|
||||
MainApplication.loadScene(
|
||||
"User bearbeiten",
|
||||
"../users/edit-user.fxml",
|
||||
"../users/create-user.css",
|
||||
800,
|
||||
650,
|
||||
fxmlLoader -> {
|
||||
EditUserController editUserController = fxmlLoader.getController();
|
||||
editUserController.setCurrentUser(users.get(editIndex));
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
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 {
|
||||
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 void setUserAtController(FXMLLoader fxmlLoader){
|
||||
int editIndex = comboBox.getSelectionModel().getSelectedIndex();
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
44
client/app/src/main/java/ui/DayPane.java
Normal file
44
client/app/src/main/java/ui/DayPane.java
Normal file
@@ -0,0 +1,44 @@
|
||||
package ui;
|
||||
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.control.ScrollPane;
|
||||
import javafx.scene.layout.VBox;
|
||||
|
||||
public class DayPane {
|
||||
|
||||
private Label dayLabel;
|
||||
private VBox dayVBox;
|
||||
private ScrollPane scrollPane;
|
||||
|
||||
public DayPane(String name) {
|
||||
dayLabel = new Label();
|
||||
dayLabel.setText(name);
|
||||
dayLabel.setMaxHeight(Double.MAX_VALUE);
|
||||
dayLabel.setMaxWidth(Double.MAX_VALUE);
|
||||
dayLabel.getStyleClass().add("labelDays");
|
||||
|
||||
scrollPane = new ScrollPane();
|
||||
|
||||
dayVBox = new VBox();
|
||||
dayVBox.getStyleClass().add("vBoxDays");
|
||||
dayVBox.setSpacing(10);
|
||||
scrollPane.setContent(dayVBox);
|
||||
|
||||
scrollPane.setFitToWidth(true);
|
||||
scrollPane.setFitToHeight(true);
|
||||
scrollPane.setHbarPolicy(ScrollPane.ScrollBarPolicy.AS_NEEDED);
|
||||
scrollPane.getStyleClass().add("scrollDays");
|
||||
}
|
||||
|
||||
public Label getDayLabel() {
|
||||
return dayLabel;
|
||||
}
|
||||
|
||||
public VBox getDayVBox() {
|
||||
return dayVBox;
|
||||
}
|
||||
|
||||
public ScrollPane getScrollPane() {
|
||||
return scrollPane;
|
||||
}
|
||||
}
|
97
client/app/src/main/java/ui/EventPane.java
Normal file
97
client/app/src/main/java/ui/EventPane.java
Normal file
@@ -0,0 +1,97 @@
|
||||
package ui;
|
||||
|
||||
import container.DataController;
|
||||
import container.Event;
|
||||
import events.EditEventController;
|
||||
import helper.HttpRequestException;
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.Group;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.control.Alert;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.layout.HBox;
|
||||
import javafx.scene.layout.VBox;
|
||||
import javafx.stage.Modality;
|
||||
import javafx.stage.Stage;
|
||||
import main.MainApplication;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.time.Duration;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Objects;
|
||||
|
||||
public class EventPane extends VBox {
|
||||
|
||||
private Button deleteBtn;
|
||||
private Button editBtn;
|
||||
|
||||
public EventPane(Event event) {
|
||||
this.getStyleClass().add("event");
|
||||
this.setSpacing(5);
|
||||
|
||||
HBox btnHBox = new HBox();
|
||||
btnHBox.setAlignment(Pos.BOTTOM_RIGHT);
|
||||
|
||||
Group svgDel = new Group(
|
||||
SvgBtnCreator.createPath("M0 0h24v24H0z", "transparent", "transparent"),
|
||||
SvgBtnCreator.createPath("M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z",
|
||||
"white", "gray")
|
||||
);
|
||||
deleteBtn = SvgBtnCreator.createBtn(svgDel, 24, "", "Löschen des Termins");
|
||||
deleteBtn.getStyleClass().add("deleteEventBtn");
|
||||
|
||||
Group svgEdit = new Group(
|
||||
SvgBtnCreator.createPath("M0 0h24v24H0z", "transparent", "transparent"),
|
||||
SvgBtnCreator.createPath("M3 17.25V21h3.75L17.81 9.94l-3.75-3.75L3 17.25zM20.71 7.04c.39-.39.39-1.02 0-1.41l-2.34-2.34c-.39-.39-1.02-.39-1.41 0l-1.83 1.83 3.75 3.75 1.83-1.83z",
|
||||
"white", "gray")
|
||||
);
|
||||
editBtn = SvgBtnCreator.createBtn(svgEdit, 24, "", "Bearbeiten des Termins");
|
||||
editBtn.getStyleClass().add("editEventBtn");
|
||||
|
||||
btnHBox.getChildren().add(editBtn);
|
||||
btnHBox.getChildren().add(deleteBtn);
|
||||
this.getChildren().add(btnHBox);
|
||||
|
||||
Label nameLabel = new Label(event.getName());
|
||||
nameLabel.setWrapText(true);
|
||||
this.getChildren().add(nameLabel);
|
||||
|
||||
if (event.getStart() != null || event.getEnd() != null) {
|
||||
String timeStr = (event.getStart() != null ? formatTime(event.getStart()) : "")
|
||||
+ (event.getEnd() != null ? " - " + formatTime(event.getEnd()) : "");
|
||||
Label timeLabel = new Label(timeStr);
|
||||
this.getChildren().add(timeLabel);
|
||||
}
|
||||
|
||||
Label typeLabel = new Label("Wer: " + event.getOwnerName());
|
||||
this.getChildren().add(typeLabel);
|
||||
|
||||
Label prioLabel = new Label("Priorität: " + event.getPriority());
|
||||
this.getChildren().add(prioLabel);
|
||||
|
||||
if (event.isFullDay()) {
|
||||
Label fullDayLabel = new Label("Dieser Termin bockiert den ganzen Tag!");
|
||||
fullDayLabel.setWrapText(true);
|
||||
this.getChildren().add(fullDayLabel);
|
||||
}
|
||||
}
|
||||
|
||||
public Button getDeleteBtn() {
|
||||
return deleteBtn;
|
||||
}
|
||||
|
||||
public Button getEditBtn() {
|
||||
return editBtn;
|
||||
}
|
||||
|
||||
|
||||
private String formatTime(String time) {
|
||||
String[] timeArr = time.split(":");
|
||||
if (timeArr.length > 2) {
|
||||
return timeArr[0] + ":" + timeArr[1];
|
||||
}
|
||||
return time;
|
||||
}
|
||||
}
|
@@ -1,10 +1,8 @@
|
||||
package helper;
|
||||
package ui;
|
||||
|
||||
import javafx.geometry.Bounds;
|
||||
import javafx.scene.Group;
|
||||
import customUI.Button;
|
||||
import javafx.scene.control.ContentDisplay;
|
||||
import customUI.Tooltip;
|
||||
import javafx.scene.control.*;
|
||||
import javafx.scene.shape.SVGPath;
|
||||
|
||||
public class SvgBtnCreator {
|
@@ -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,38 @@ 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());
|
||||
user.setAdmin(checkButtonIsAdmin.isSelected());
|
||||
|
||||
try {
|
||||
sendHttpRequest(user);
|
||||
} catch (HttpRequestException e) {
|
||||
labelError.setText(e.getMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
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();
|
||||
|
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.control.Label;
|
||||
import javafx.stage.Stage;
|
||||
import res.DataController;
|
||||
import container.DataController;
|
||||
|
||||
public class LoginController {
|
||||
@FXML
|
||||
|
@@ -8,7 +8,7 @@
|
||||
<?import com.jfoenix.controls.*?>
|
||||
|
||||
<GridPane fx:id="mainGrid" xmlns="http://javafx.com/javafx" xmlns:fx="http://javafx.com/fxml/1"
|
||||
fx:controller="main.CreateEventController">
|
||||
fx:controller="events.CreateEventController">
|
||||
|
||||
<columnConstraints>
|
||||
<ColumnConstraints/>
|
||||
|
@@ -8,7 +8,7 @@
|
||||
<?import com.jfoenix.controls.*?>
|
||||
|
||||
<GridPane fx:id="mainGrid" xmlns="http://javafx.com/javafx" xmlns:fx="http://javafx.com/fxml/1"
|
||||
fx:controller="main.EditEventController">
|
||||
fx:controller="events.EditEventController">
|
||||
|
||||
<columnConstraints>
|
||||
<ColumnConstraints/>
|
||||
|
@@ -43,7 +43,7 @@ fx:id="mainGrid">
|
||||
|
||||
<Label styleClass="loginLbl" GridPane.columnIndex="1" GridPane.rowIndex="8"
|
||||
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"/>
|
||||
<JFXButton GridPane.columnIndex="4" GridPane.rowIndex="9" onAction="#onBackBtnClick">Zurück</JFXButton>
|
||||
|
@@ -43,6 +43,7 @@ Label{
|
||||
.errorMessage{
|
||||
-fx-max-width: 400px;
|
||||
-fx-min-width: 400px;
|
||||
-fx-text-fill: red;
|
||||
}
|
||||
|
||||
Button{
|
||||
|
@@ -3,11 +3,12 @@
|
||||
<?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.CreateUserController">
|
||||
<columnConstraints>
|
||||
<ColumnConstraints minWidth="100"/>
|
||||
<ColumnConstraints minWidth="50"/>
|
||||
<ColumnConstraints minWidth="100"/>
|
||||
<ColumnConstraints minWidth="100"/>
|
||||
</columnConstraints>
|
||||
@@ -40,16 +41,16 @@
|
||||
<PasswordField fx:id="textPassword" styleClass="textField" GridPane.columnIndex="2" GridPane.rowIndex="4" />
|
||||
<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.margin>
|
||||
<Insets right="100" left="100"/>
|
||||
</HBox.margin>
|
||||
<Button onAction="#abortBtnClick">Abbrechen</Button>
|
||||
<Button onAction="#createUser" styleClass="btnLogin" >Anmelden</Button>
|
||||
<Button onAction="#createUser" styleClass="btnLogin" >Anlegen</Button>
|
||||
|
||||
</HBox>
|
||||
</GridPane>
|
||||
|
59
client/app/src/main/resources/users/edit-user.css
Normal file
59
client/app/src/main/resources/users/edit-user.css
Normal file
@@ -0,0 +1,59 @@
|
||||
* {
|
||||
-fx-base-background-color: #2B2D42;
|
||||
-fx-base1-background-color: #525E74;
|
||||
|
||||
-fx-main-border-color: #B0B0B0;
|
||||
-fx-main-text-color: #ffffff;
|
||||
}
|
||||
|
||||
|
||||
GridPane{
|
||||
-fx-background-color: #3E415F;
|
||||
-fx-padding: 20px;
|
||||
-fx-font-size: 20px;
|
||||
-fx-font-family: Segoe UI;
|
||||
|
||||
-fx-border-insets: 1;
|
||||
-fx-border-color: #B0B0B0;
|
||||
-fx-border-style: solid;
|
||||
-fx-border-width: 2;
|
||||
-fx-effect: dropshadow(three-pass-box, rgba(100, 100, 100, 1), 24, 0.5, 0, 0);
|
||||
}
|
||||
|
||||
.mainLabel{
|
||||
-fx-padding: 10px;
|
||||
-fx-max-width: 400px;
|
||||
-fx-min-width: 400px;
|
||||
-fx-font-weight: bold;
|
||||
-fx-alignment: top-center;
|
||||
}
|
||||
|
||||
|
||||
Label{
|
||||
-fx-text-fill: white;
|
||||
-fx-max-width: 150px;
|
||||
-fx-min-width: 150px;
|
||||
}
|
||||
|
||||
.textField{
|
||||
-fx-max-width: 400px;
|
||||
-fx-min-width: 400px;
|
||||
}
|
||||
|
||||
.errorMessage{
|
||||
-fx-font-weight: bold;
|
||||
-fx-max-width: 200px;
|
||||
-fx-text-fill: #ff5555;
|
||||
-fx-font-size: 16px;
|
||||
-fx-max-width: 400px;
|
||||
-fx-min-width: 400px;
|
||||
}
|
||||
|
||||
Button{
|
||||
-fx-max-width: 150px;
|
||||
-fx-min-width: 150px;
|
||||
}
|
||||
|
||||
.btnLogin{
|
||||
-fx-font-weight: bold;
|
||||
}
|
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
|
||||
}
|
||||
|
||||
tasks.withType<JavaCompile> {
|
||||
options.encoding = "UTF-8"
|
||||
}
|
||||
|
||||
dependencies {
|
||||
val jacksonVersion = "2.13.0"
|
||||
implementation("com.fasterxml.jackson.core:jackson-databind:$jacksonVersion")
|
||||
|
@@ -17,8 +17,10 @@ public class ConfigLoader {
|
||||
return objectMapper.readValue(jsonString, Config.class);
|
||||
} catch (IOException e) {
|
||||
System.out.println("config.json missing");
|
||||
Config config = new Config(false, -1, "");
|
||||
save(config);
|
||||
return config;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
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.type.TypeReference;
|
||||
@@ -125,7 +125,8 @@ public class DataController {
|
||||
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
objectMapper.findAndRegisterModules();
|
||||
return (ArrayList<Event>) objectMapper.readValue(jsonResponse, new TypeReference<List<Event>>() {});
|
||||
return (ArrayList<Event>) objectMapper.readValue(jsonResponse, new TypeReference<List<Event>>() {
|
||||
});
|
||||
|
||||
} catch (HttpRequestException e) {
|
||||
throw e;
|
||||
@@ -148,7 +149,13 @@ public class DataController {
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
objectMapper.findAndRegisterModules();
|
||||
try {
|
||||
return (List<User>)objectMapper.readValue(userJSON, new TypeReference<List<User>>() {});
|
||||
List<User> list = objectMapper.readValue(userJSON, new TypeReference<>() {
|
||||
});
|
||||
|
||||
for(User u : list){
|
||||
System.out.println(u);
|
||||
}
|
||||
return list;
|
||||
} catch (JsonProcessingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@@ -175,10 +182,18 @@ public class DataController {
|
||||
);
|
||||
}
|
||||
|
||||
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(
|
||||
EDIT_USER_ENDPOINT,
|
||||
"",
|
||||
urlParam,
|
||||
true
|
||||
);
|
||||
}
|
@@ -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.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.regex.PatternSyntaxException;
|
||||
|
||||
public class Event {
|
||||
|
||||
@@ -44,15 +36,15 @@ public class Event {
|
||||
|
||||
System.out.println("Create Event");
|
||||
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);
|
||||
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) {
|
||||
throw new IllegalArgumentException("Bitte eine Priorit\u00e4t w\u00e4hlen.");
|
||||
throw new IllegalArgumentException("Bitte eine Priorität wählen.");
|
||||
}
|
||||
LocalDateTime today = LocalDateTime.now().toLocalDate().atStartOfDay();
|
||||
if (Duration.between(today, date).isNegative()) {
|
||||
@@ -82,9 +74,7 @@ public class Event {
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
System.out.println(name);
|
||||
this.name = name;
|
||||
System.out.println(this.name);
|
||||
}
|
||||
|
||||
public int getPriority() {
|
@@ -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 = "";
|
||||
@@ -61,9 +60,9 @@ public class HttpRequest {
|
||||
BufferedReader in;
|
||||
|
||||
if (status == 200) {
|
||||
in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
|
||||
in = new BufferedReader(new InputStreamReader(connection.getInputStream(), StandardCharsets.UTF_8));
|
||||
} else {
|
||||
in = new BufferedReader(new InputStreamReader(connection.getErrorStream()));
|
||||
in = new BufferedReader(new InputStreamReader(connection.getErrorStream(), StandardCharsets.UTF_8));
|
||||
}
|
||||
|
||||
while ((inputLine = in.readLine()) != null) {
|
@@ -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;
|
||||
}
|
||||
@@ -58,4 +60,16 @@ public class User {
|
||||
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 +
|
||||
'}';
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user