Compare commits
No commits in common. "d41abdbad9535104ab1bc435cd76600da527dc65" and "4aafae98963ea51f3e6233718f874f9bfcbe5a8e" have entirely different histories.
d41abdbad9
...
4aafae9896
@ -5,17 +5,13 @@ plugins {
|
||||
}
|
||||
|
||||
javafx {
|
||||
version = "11.0.2"
|
||||
version = "11"
|
||||
modules(
|
||||
"javafx.controls",
|
||||
"javafx.fxml"
|
||||
)
|
||||
}
|
||||
|
||||
tasks.withType<JavaCompile> {
|
||||
options.encoding = "UTF-8"
|
||||
}
|
||||
|
||||
application {
|
||||
mainClassName = "main.MainApplication"
|
||||
}
|
||||
|
8
client/app/src/main/java/customUI/Button.java
Normal file
8
client/app/src/main/java/customUI/Button.java
Normal file
@ -0,0 +1,8 @@
|
||||
package customUI;
|
||||
|
||||
public class Button extends javafx.scene.control.Button {
|
||||
|
||||
public void setTextValue(String text){
|
||||
super.setText(Converter.convertString(text));
|
||||
}
|
||||
}
|
21
client/app/src/main/java/customUI/Converter.java
Normal file
21
client/app/src/main/java/customUI/Converter.java
Normal file
@ -0,0 +1,21 @@
|
||||
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");
|
||||
}
|
||||
}
|
15
client/app/src/main/java/customUI/Label.java
Normal file
15
client/app/src/main/java/customUI/Label.java
Normal file
@ -0,0 +1,15 @@
|
||||
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));
|
||||
}
|
||||
}
|
9
client/app/src/main/java/customUI/Tooltip.java
Normal file
9
client/app/src/main/java/customUI/Tooltip.java
Normal file
@ -0,0 +1,9 @@
|
||||
package customUI;
|
||||
|
||||
public class Tooltip extends javafx.scene.control.Tooltip {
|
||||
|
||||
public Tooltip(String tollTipText){
|
||||
super(Converter.convertString(tollTipText));
|
||||
}
|
||||
|
||||
}
|
@ -2,7 +2,9 @@ package helper;
|
||||
|
||||
import javafx.geometry.Bounds;
|
||||
import javafx.scene.Group;
|
||||
import javafx.scene.control.*;
|
||||
import customUI.Button;
|
||||
import javafx.scene.control.ContentDisplay;
|
||||
import customUI.Tooltip;
|
||||
import javafx.scene.shape.SVGPath;
|
||||
|
||||
public class SvgBtnCreator {
|
||||
|
@ -10,8 +10,8 @@ import javafx.scene.layout.GridPane;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.util.StringConverter;
|
||||
import javafx.util.converter.LocalTimeStringConverter;
|
||||
import container.DataController;
|
||||
import container.Event;
|
||||
import res.DataController;
|
||||
import res.Event;
|
||||
|
||||
import java.time.LocalTime;
|
||||
import java.time.format.FormatStyle;
|
||||
@ -44,6 +44,7 @@ public class CreateEventController {
|
||||
|
||||
@FXML
|
||||
public void initialize() {
|
||||
|
||||
StringConverter<LocalTime> defaultConverter = new LocalTimeStringConverter(FormatStyle.SHORT, Locale.GERMANY);
|
||||
timeStart.set24HourView(true);
|
||||
timeStart.setConverter(defaultConverter);
|
||||
|
@ -1,8 +1,16 @@
|
||||
package main;
|
||||
|
||||
import customUI.Converter;
|
||||
import helper.HttpRequestException;
|
||||
import container.DataController;
|
||||
import container.Event;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.util.StringConverter;
|
||||
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{
|
||||
|
||||
@ -15,7 +23,7 @@ public class EditEventController extends CreateEventController{
|
||||
public void setCurrentEvent(Event currentEvent) {
|
||||
this.currentEvent = currentEvent;
|
||||
|
||||
textName.setText(currentEvent.getName());
|
||||
textName.setText(Converter.convertString(currentEvent.getName()));
|
||||
datePickerDate.setValue(currentEvent.getDate().toLocalDate());
|
||||
ComboBoxPriotity.getSelectionModel().select(currentEvent.getPriority());
|
||||
|
||||
|
@ -6,8 +6,8 @@ import javafx.application.Application;
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.stage.Stage;
|
||||
import container.DataController;
|
||||
import container.HttpRequest;
|
||||
import res.DataController;
|
||||
import res.HttpRequest;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Objects;
|
||||
|
@ -2,6 +2,8 @@ package main;
|
||||
|
||||
import config.Config;
|
||||
import config.ConfigLoader;
|
||||
import customUI.Button;
|
||||
import customUI.Label;
|
||||
import helper.SvgBtnCreator;
|
||||
import helper.HttpRequestException;
|
||||
import javafx.fxml.FXML;
|
||||
@ -10,17 +12,17 @@ import javafx.geometry.Pos;
|
||||
import javafx.scene.Group;
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.control.*;
|
||||
import javafx.scene.control.ScrollPane;
|
||||
import javafx.scene.layout.GridPane;
|
||||
import javafx.scene.layout.HBox;
|
||||
import javafx.scene.layout.VBox;
|
||||
import javafx.stage.Modality;
|
||||
import javafx.stage.Stage;
|
||||
import container.DataController;
|
||||
import container.Event;
|
||||
import res.DataController;
|
||||
import res.Event;
|
||||
|
||||
import javafx.event.ActionEvent;
|
||||
import container.HttpRequest;
|
||||
import res.HttpRequest;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.time.Duration;
|
||||
@ -152,7 +154,7 @@ public class MainController {
|
||||
private void createWeek() {
|
||||
for (int i = 0; i < 7; i++) {
|
||||
Label label = new Label();
|
||||
label.setText(dayNames[i]);
|
||||
label.setTextValue(dayNames[i]);
|
||||
label.setMaxHeight(Double.MAX_VALUE);
|
||||
label.setMaxWidth(Double.MAX_VALUE);
|
||||
label.getStyleClass().add("labelDays");
|
||||
@ -234,7 +236,6 @@ public class MainController {
|
||||
vBox.getChildren().add(btnHBox);
|
||||
|
||||
Label nameLabel = new Label(event.getName());
|
||||
nameLabel.setWrapText(true);
|
||||
vBox.getChildren().add(nameLabel);
|
||||
|
||||
if (event.getStart() != null || event.getEnd() != null) {
|
||||
@ -247,12 +248,11 @@ public class MainController {
|
||||
Label typeLabel = new Label("Wer: " + event.getOwnerName());
|
||||
vBox.getChildren().add(typeLabel);
|
||||
|
||||
Label prioLabel = new Label("Priorität: " + event.getPriority());
|
||||
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!");
|
||||
fullDayLabel.setWrapText(true);
|
||||
vBox.getChildren().add(fullDayLabel);
|
||||
}
|
||||
|
||||
@ -286,7 +286,7 @@ public class MainController {
|
||||
weekStartDateTime = now.plusDays(weekOffset * 7L - dayOfWeek + 1);
|
||||
|
||||
for (int i = 0; i < 7; i++) {
|
||||
dayLabel[i].setText(dayFormatter.format(weekStartDateTime.plusDays(i)));
|
||||
dayLabel[i].setTextValue(dayFormatter.format(weekStartDateTime.plusDays(i)));
|
||||
}
|
||||
|
||||
LabelMonth.setText(dateFormatter.format(weekStartDateTime));
|
||||
|
@ -1,10 +1,6 @@
|
||||
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;
|
||||
import javafx.event.ActionEvent;
|
||||
@ -12,23 +8,12 @@ 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 container.DataController;
|
||||
import container.User;
|
||||
import users.EditUserController;
|
||||
|
||||
import java.awt.*;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class OptionController {
|
||||
|
||||
@ -43,35 +28,11 @@ public class OptionController {
|
||||
@FXML
|
||||
public Label labelError;
|
||||
@FXML
|
||||
public GridPane mainGrid;
|
||||
|
||||
private JFXComboBox<String> comboBox;
|
||||
private DataController dataController;
|
||||
private List<User> users;
|
||||
private Config config;
|
||||
public JFXComboBox<String> userCmb;
|
||||
|
||||
@FXML
|
||||
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) {
|
||||
@ -80,79 +41,28 @@ public class OptionController {
|
||||
}
|
||||
|
||||
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{
|
||||
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(
|
||||
MainApplication.class.getResource(fxml));
|
||||
try {
|
||||
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(title);
|
||||
stage.setTitle("User erstellen");
|
||||
stage.setScene(scene);
|
||||
stage.initModality(Modality.APPLICATION_MODAL);
|
||||
stage.setResizable(false);
|
||||
|
||||
if(method != null)method.accept(fxmlLoader);
|
||||
|
||||
stage.showAndWait();
|
||||
Stage stageOld = (Stage) ((Node) actionEvent.getSource()).getScene().getWindow();
|
||||
stageOld.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
e.printStackTrace();
|
||||
}
|
||||
return fxmlLoader;
|
||||
}
|
||||
|
||||
private void setUserAtController(FXMLLoader fxmlLoader){
|
||||
int editIndex = comboBox.getSelectionModel().getSelectedIndex();
|
||||
EditUserController editUserController = fxmlLoader.getController();
|
||||
editUserController.setCurrentUser(users.get(editIndex));
|
||||
public void onUpdateBtnClick(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);
|
||||
public void onDeleteBtnClick(ActionEvent actionEvent) {
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
package users;
|
||||
|
||||
import helper.HttpRequestException;
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.Node;
|
||||
@ -9,8 +8,6 @@ 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;
|
||||
|
||||
@ -42,38 +39,15 @@ 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();
|
||||
|
@ -1,92 +0,0 @@
|
||||
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 container.DataController;
|
||||
import res.DataController;
|
||||
|
||||
public class LoginController {
|
||||
@FXML
|
||||
|
@ -3,12 +3,12 @@
|
||||
<?import javafx.scene.control.*?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
<?import com.jfoenix.controls.*?>
|
||||
<?import javafx.collections.FXCollections?>
|
||||
|
||||
<GridPane xmlns="http://javafx.com/javafx"
|
||||
xmlns:fx="http://javafx.com/fxml"
|
||||
fx:controller="main.OptionController"
|
||||
prefHeight="400.0" prefWidth="600.0"
|
||||
fx:id="mainGrid">
|
||||
prefHeight="400.0" prefWidth="600.0">
|
||||
|
||||
<columnConstraints>
|
||||
<ColumnConstraints minWidth="100"/>
|
||||
@ -33,6 +33,13 @@ fx:id="mainGrid">
|
||||
<Label styleClass="mainLabel" GridPane.columnIndex="2" GridPane.halignment="CENTER" >Einstellungen</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"
|
||||
GridPane.rowIndex="4" GridPane.halignment="CENTER" onAction="#onUpdateBtnClick">User bearbeiten</JFXButton>
|
||||
@ -43,7 +50,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" onAction="#toggledBtn"/>
|
||||
<JFXToggleButton fx:id="saveLoginTBtn" GridPane.columnIndex="3" GridPane.rowIndex="8"/>
|
||||
|
||||
<Label fx:id="labelError" styleClass="errorMessage" GridPane.columnIndex="1" GridPane.rowIndex="9"/>
|
||||
<JFXButton GridPane.columnIndex="4" GridPane.rowIndex="9" onAction="#onBackBtnClick">Zurück</JFXButton>
|
||||
|
@ -3,7 +3,6 @@
|
||||
<?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">
|
||||
@ -41,16 +40,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" />
|
||||
|
||||
<JFXToggleButton fx:id="checkButtonIsAdmin" GridPane.columnIndex="2" GridPane.rowIndex="6"/>
|
||||
<ToggleButton fx:id="checkButtonIsAdmin" GridPane.columnIndex="2" GridPane.rowIndex="6"/>
|
||||
|
||||
<Label fx:id="labelError" wrapText="true" styleClass="errorMessage" GridPane.columnIndex="2" GridPane.rowIndex="7"/>
|
||||
<Label fx:id="labelError" 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" >Anlegen</Button>
|
||||
<Button onAction="#createUser" styleClass="btnLogin" >Anmelden</Button>
|
||||
|
||||
</HBox>
|
||||
</GridPane>
|
||||
|
@ -1,57 +0,0 @@
|
||||
<?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,10 +2,6 @@ plugins {
|
||||
java
|
||||
}
|
||||
|
||||
tasks.withType<JavaCompile> {
|
||||
options.encoding = "UTF-8"
|
||||
}
|
||||
|
||||
dependencies {
|
||||
val jacksonVersion = "2.13.0"
|
||||
implementation("com.fasterxml.jackson.core:jackson-databind:$jacksonVersion")
|
||||
|
@ -1,6 +1,7 @@
|
||||
package config;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import res.DataController;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
@ -17,10 +18,8 @@ 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,75 +0,0 @@
|
||||
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,4 +1,4 @@
|
||||
package container;
|
||||
package res;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
@ -6,6 +6,13 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import helper.HttpRequestException;
|
||||
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.util.*;
|
||||
|
||||
@ -111,6 +118,7 @@ public class DataController {
|
||||
}
|
||||
|
||||
public ArrayList<Event> getAllVisibleEvents(LocalDateTime startDate, LocalDateTime endDate) throws HttpRequestException {
|
||||
ArrayList<Event> eventList = new ArrayList<>();
|
||||
try {
|
||||
Tuple<Integer, String> response = httpRequest.sendPostRequest(
|
||||
ALL_EVENTS_ENDPOINT,
|
||||
@ -125,51 +133,28 @@ public class DataController {
|
||||
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
objectMapper.findAndRegisterModules();
|
||||
return (ArrayList<Event>) objectMapper.readValue(jsonResponse, new TypeReference<List<Event>>() {
|
||||
eventList = (ArrayList<Event>) objectMapper.readValue(jsonResponse, new TypeReference<List<Event>>() {
|
||||
});
|
||||
|
||||
|
||||
} catch (HttpRequestException e) {
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
throw new HttpRequestException("Es konnte keine Verbindung mit dem Server hergestellt werden.", 600);
|
||||
}
|
||||
|
||||
return eventList;
|
||||
}
|
||||
|
||||
/********
|
||||
* 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 {
|
||||
sendBasicHttpRequest(
|
||||
ADD_USER_ENDPOINT,
|
||||
"name=" + user.getName() +
|
||||
"&forename=" + user.getForename() +
|
||||
"&login=" + user.getLogin() +
|
||||
"&password=" + user.getPassword() +
|
||||
"&isAdmin=" + user.isAdmin(),
|
||||
user.getAsUrlParam(),
|
||||
true
|
||||
);
|
||||
}
|
||||
@ -177,28 +162,21 @@ public class DataController {
|
||||
public void deleteUser(User user) throws HttpRequestException {
|
||||
sendBasicHttpRequest(
|
||||
DELETE_USER_ENDPOINT,
|
||||
"userId=" + user.getUserId(),
|
||||
user.getAsUrlParam(),
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
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);
|
||||
public void editUser(User oldUser, User user) throws HttpRequestException {
|
||||
sendBasicHttpRequest(
|
||||
EDIT_USER_ENDPOINT,
|
||||
urlParam,
|
||||
user.getAsUrlParam(),
|
||||
true
|
||||
);
|
||||
}
|
||||
*/
|
||||
|
||||
private String sendBasicHttpRequest(String urlString, String urlParameters, boolean sendAuth) throws HttpRequestException {
|
||||
private void sendBasicHttpRequest(String urlString, String urlParameters, boolean sendAuth) throws HttpRequestException {
|
||||
try {
|
||||
Tuple<Integer, String> response = httpRequest.sendPostRequest(
|
||||
urlString,
|
||||
@ -208,8 +186,6 @@ public class DataController {
|
||||
if (response.getKey() != 200) {
|
||||
throw new HttpRequestException(response);
|
||||
}
|
||||
|
||||
return response.getValue();
|
||||
} catch (HttpRequestException e) {
|
||||
throw e;
|
||||
} catch (Exception e) {
|
@ -1,11 +1,19 @@
|
||||
package container;
|
||||
package res;
|
||||
|
||||
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 {
|
||||
|
||||
@ -36,15 +44,15 @@ public class Event {
|
||||
|
||||
System.out.println("Create Event");
|
||||
if (name.length() < 3) {
|
||||
throw new IllegalArgumentException("Der Name muss eine Länge von 3 haben.");
|
||||
throw new IllegalArgumentException("Der Name muss eine L\u00e4nge von 3 haben.");
|
||||
}
|
||||
Pattern pattern = Pattern.compile("[A-Za-zäöüÄÖÜß0-9 =!?+*/$.:,;_<>()-]*");
|
||||
Pattern pattern = Pattern.compile("[A-Za-z\u00e4\u00f6\u00fc\u00c4\u00d6\u00dc\u00df0-9 =!?+*/$.:,;_<>()-]*");
|
||||
Matcher matcher = pattern.matcher(name);
|
||||
if (!matcher.matches()) {
|
||||
throw new IllegalArgumentException("Der Name darf nur aus Zahlen, Buchstaben und folgenden Sonderzeichen bestehen: äöü ÄÖÜ ß =!?+*/$.:,;_ <>()-");
|
||||
throw new IllegalArgumentException("Der Name darf nur aus Zahlen, Buchstaben und folgenden Sonderzeichen bestehen: \u00e4\u00f6\u00fc \u00c4\u00d6\u00dc \u00df =!?+*/$.:,;_ <>()-");
|
||||
}
|
||||
if (priority < 0) {
|
||||
throw new IllegalArgumentException("Bitte eine Priorität wählen.");
|
||||
throw new IllegalArgumentException("Bitte eine Priorit\u00e4t w\u00e4hlen.");
|
||||
}
|
||||
LocalDateTime today = LocalDateTime.now().toLocalDate().atStartOfDay();
|
||||
if (Duration.between(today, date).isNegative()) {
|
||||
@ -74,7 +82,9 @@ 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 container;
|
||||
package res;
|
||||
|
||||
import helper.Tuple;
|
||||
|
||||
@ -9,6 +9,7 @@ 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 = "";
|
||||
@ -60,9 +61,9 @@ public class HttpRequest {
|
||||
BufferedReader in;
|
||||
|
||||
if (status == 200) {
|
||||
in = new BufferedReader(new InputStreamReader(connection.getInputStream(), StandardCharsets.UTF_8));
|
||||
in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
|
||||
} else {
|
||||
in = new BufferedReader(new InputStreamReader(connection.getErrorStream(), StandardCharsets.UTF_8));
|
||||
in = new BufferedReader(new InputStreamReader(connection.getErrorStream()));
|
||||
}
|
||||
|
||||
while ((inputLine = in.readLine()) != null) {
|
44
client/data/src/main/java/res/User.java
Normal file
44
client/data/src/main/java/res/User.java
Normal file
@ -0,0 +1,44 @@
|
||||
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