diff --git a/.vscode/launch.json b/.vscode/launch.json index 4aa77b4..6f48257 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -1,16 +1,13 @@ { - // Use IntelliSense to learn about possible attributes. - // Hover to view descriptions of existing attributes. - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ - { - "type": "jdk", + "type": "java", "request": "launch", - "name": "Launch Java App", - "mainClass": "com.example.bricklog.Main", // Replace with your main class path - "vmArgs": "--module-path C:/javafx-sdk-21.0.5/lib --add-modules javafx.controls,javafx.fxml" + "name": "Launch BrickLog Client", + "mainClass": "com.example.bricklog.BrickLogClient", + "projectName": "bricklog-client", + "vmArgs": "--module-path C:/javafx-sdk-21.0.5 --add-modules javafx.controls,javafx.fxml" } ] -} \ No newline at end of file +} diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..7b016a8 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "java.compile.nullAnalysis.mode": "automatic" +} \ No newline at end of file diff --git a/BrickLog-Client/pom.xml b/BrickLog-Client/pom.xml new file mode 100644 index 0000000..cded788 --- /dev/null +++ b/BrickLog-Client/pom.xml @@ -0,0 +1,59 @@ + + 4.0.0 + + com.example + bricklog-client + 0.1-SNAPSHOT + jar + + + 21 + 23.0.1 + + + + + + org.openjfx + javafx-controls + ${javafx.version} + + + org.openjfx + javafx-fxml + ${javafx.version} + + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.8.1 + + ${java.version} + ${java.version} + + + + org.openjfx + javafx-maven-plugin + 0.0.5 + + + + run + + + + + com.example.bricklog.BrickLogClientApplication + + + + + diff --git a/BrickLog-Client/src/main/java/com/example/bricklog/BrickLogClientApplication.java b/BrickLog-Client/src/main/java/com/example/bricklog/BrickLogClientApplication.java new file mode 100644 index 0000000..dad934f --- /dev/null +++ b/BrickLog-Client/src/main/java/com/example/bricklog/BrickLogClientApplication.java @@ -0,0 +1,54 @@ +package com.example.bricklog; + +import javafx.application.Application; +import javafx.scene.Scene; +import javafx.scene.control.Button; +import javafx.scene.control.TextField; +import javafx.scene.layout.VBox; +import javafx.stage.Stage; + +public class BrickLogClientApplication extends Application { + + @Override + public void start(Stage primaryStage) { + primaryStage.setTitle("Brick Log"); + + // Create layout + VBox layout = new VBox(10); // Vertical box with spacing of 10 pixels + + // Search Box + TextField searchBox = new TextField(); + searchBox.setPromptText("Search for builds..."); + + // Add Button + Button addButton = new Button("+"); + addButton.setStyle("-fx-background-color: lightblue; -fx-font-size: 18px; -fx-padding: 10px; -fx-font-weight: bold;"); + addButton.setPrefSize(50, 50); + + // Animation Effect on Click + addButton.setOnMouseClicked(e -> { + addButton.setScaleX(1.2); + addButton.setScaleY(1.2); + // You may want to add logic for adding a new build here + // For example, opening a new window to add a build + }); + + // Reset size after animation + addButton.setOnMouseReleased(e -> { + addButton.setScaleX(1.0); + addButton.setScaleY(1.0); + }); + + // Add components to layout + layout.getChildren().addAll(searchBox, addButton); + + // Create a scene and set it to the stage + Scene scene = new Scene(layout, 400, 300); // Set the width and height as per your need + primaryStage.setScene(scene); + primaryStage.show(); + } + + public static void main(String[] args) { + launch(args); + } +} diff --git a/BrickLog-Client/src/main/java/com/example/bricklog/BrickLogClient.java b/BrickLog-Client/src/main/java/com/example/bricklog/controller/SettingsController.java similarity index 100% rename from BrickLog-Client/src/main/java/com/example/bricklog/BrickLogClient.java rename to BrickLog-Client/src/main/java/com/example/bricklog/controller/SettingsController.java diff --git a/BrickLog-Client/src/main/java/com/example/bricklog/view/SettingsWindow.java b/BrickLog-Client/src/main/java/com/example/bricklog/view/SettingsWindow.java new file mode 100644 index 0000000..3ea967b --- /dev/null +++ b/BrickLog-Client/src/main/java/com/example/bricklog/view/SettingsWindow.java @@ -0,0 +1,101 @@ +package com.example.bricklog.view; + +import javafx.application.Application; +import javafx.geometry.Insets; +import javafx.scene.Scene; +import javafx.scene.control.Label; +import javafx.scene.control.PasswordField; +import javafx.scene.control.RadioButton; +import javafx.scene.control.Slider; +import javafx.scene.control.Tab; +import javafx.scene.control.TabPane; +import javafx.scene.control.TextField; +import javafx.scene.control.ToggleGroup; +import javafx.scene.layout.GridPane; +import javafx.scene.layout.VBox; +import javafx.stage.Stage; + +public class SettingsWindow extends Application { + + @Override + public void start(Stage primaryStage) { + primaryStage.setTitle("Settings"); + + // Create a TabPane for organizing settings + TabPane tabPane = new TabPane(); + + // Tab 1: Display Settings + Tab displayTab = new Tab("Display Settings"); + displayTab.setContent(createDisplaySettingsContent()); + displayTab.setClosable(false); + + // Tab 2: Server Settings + Tab serverTab = new Tab("Server Settings"); + serverTab.setContent(createServerSettingsContent()); + serverTab.setClosable(false); + + tabPane.getTabs().addAll(displayTab, serverTab); + + // Set up the scene + VBox vbox = new VBox(tabPane); + Scene scene = new Scene(vbox, 400, 300); + primaryStage.setScene(scene); + primaryStage.show(); + } + + private GridPane createDisplaySettingsContent() { + GridPane grid = new GridPane(); + grid.setPadding(new Insets(10)); + grid.setVgap(10); + grid.setHgap(10); + + // Font Size Adjuster + Label fontSizeLabel = new Label("Font Size:"); + Slider fontSizeSlider = new Slider(10, 30, 14); + fontSizeSlider.setShowTickLabels(true); + fontSizeSlider.setShowTickMarks(true); + + // Dark/Light Mode Toggle + Label themeLabel = new Label("Theme:"); + ToggleGroup themeGroup = new ToggleGroup(); + RadioButton lightMode = new RadioButton("Light"); + RadioButton darkMode = new RadioButton("Dark"); + lightMode.setToggleGroup(themeGroup); + darkMode.setToggleGroup(themeGroup); + lightMode.setSelected(true); + + grid.add(fontSizeLabel, 0, 0); + grid.add(fontSizeSlider, 1, 0); + grid.add(themeLabel, 0, 1); + grid.add(lightMode, 1, 1); + grid.add(darkMode, 2, 1); + + return grid; + } + + private GridPane createServerSettingsContent() { + GridPane grid = new GridPane(); + grid.setPadding(new Insets(10)); + grid.setVgap(10); + grid.setHgap(10); + + // Server IP + Label ipLabel = new Label("Server IP:"); + TextField ipField = new TextField(); + + // Authentication Token + Label authLabel = new Label("Auth Token:"); + PasswordField authField = new PasswordField(); + + grid.add(ipLabel, 0, 0); + grid.add(ipField, 1, 0); + grid.add(authLabel, 0, 1); + grid.add(authField, 1, 1); + + return grid; + } + + public static void main(String[] args) { + launch(args); + } +} diff --git a/BrickLog-Client/src/main/java/css/config/application.properties b/BrickLog-Client/src/main/java/css/config/application.properties new file mode 100644 index 0000000..e69de29 diff --git a/BrickLog-Client/src/main/java/css/dark-theme.css b/BrickLog-Client/src/main/java/css/dark-theme.css new file mode 100644 index 0000000..e69de29 diff --git a/BrickLog-Client/src/main/java/css/light-theme.css b/BrickLog-Client/src/main/java/css/light-theme.css new file mode 100644 index 0000000..e69de29 diff --git a/BrickLog-Client/target/bricklog-client-0.1-SNAPSHOT.jar b/BrickLog-Client/target/bricklog-client-0.1-SNAPSHOT.jar new file mode 100644 index 0000000..71c4090 Binary files /dev/null and b/BrickLog-Client/target/bricklog-client-0.1-SNAPSHOT.jar differ diff --git a/BrickLog-Client/target/classes/com/example/bricklog/BrickLogClientApplication.class b/BrickLog-Client/target/classes/com/example/bricklog/BrickLogClientApplication.class new file mode 100644 index 0000000..9c5fc98 Binary files /dev/null and b/BrickLog-Client/target/classes/com/example/bricklog/BrickLogClientApplication.class differ diff --git a/BrickLog-Client/target/classes/com/example/bricklog/view/SettingsWindow.class b/BrickLog-Client/target/classes/com/example/bricklog/view/SettingsWindow.class new file mode 100644 index 0000000..56ac588 Binary files /dev/null and b/BrickLog-Client/target/classes/com/example/bricklog/view/SettingsWindow.class differ diff --git a/BrickLog-Client/target/classes/css/config/application.properties b/BrickLog-Client/target/classes/css/config/application.properties new file mode 100644 index 0000000..e69de29 diff --git a/BrickLog-Client/target/classes/css/dark-theme.css b/BrickLog-Client/target/classes/css/dark-theme.css new file mode 100644 index 0000000..e69de29 diff --git a/BrickLog-Client/target/classes/css/light-theme.css b/BrickLog-Client/target/classes/css/light-theme.css new file mode 100644 index 0000000..e69de29 diff --git a/BrickLog-Client/target/maven-archiver/pom.properties b/BrickLog-Client/target/maven-archiver/pom.properties new file mode 100644 index 0000000..3fa1b91 --- /dev/null +++ b/BrickLog-Client/target/maven-archiver/pom.properties @@ -0,0 +1,3 @@ +artifactId=bricklog-client +groupId=com.example +version=0.1-SNAPSHOT diff --git a/BrickLog-Client/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/BrickLog-Client/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst new file mode 100644 index 0000000..bfe2cb7 --- /dev/null +++ b/BrickLog-Client/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst @@ -0,0 +1,2 @@ +com\example\bricklog\BrickLogClientApplication.class +com\example\bricklog\view\SettingsWindow.class diff --git a/BrickLog-Client/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/BrickLog-Client/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst new file mode 100644 index 0000000..9d2b4dc --- /dev/null +++ b/BrickLog-Client/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst @@ -0,0 +1,3 @@ +C:\Users\bryce\Documents\Git\BrickLog\BrickLog-Client\src\main\java\com\example\bricklog\BrickLogClientApplication.java +C:\Users\bryce\Documents\Git\BrickLog\BrickLog-Client\src\main\java\com\example\bricklog\controller\SettingsController.java +C:\Users\bryce\Documents\Git\BrickLog\BrickLog-Client\src\main\java\com\example\bricklog\view\SettingsWindow.java diff --git a/BrickLog-Client/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst b/BrickLog-Client/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst new file mode 100644 index 0000000..e69de29 diff --git a/BrickLog-Client/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst b/BrickLog-Client/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst new file mode 100644 index 0000000..f723d7e --- /dev/null +++ b/BrickLog-Client/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst @@ -0,0 +1 @@ +C:\Users\bryce\Documents\Git\BrickLog\BrickLog-Client\src\test\java\com\example\bricklog\BrickLogClient.java diff --git a/BrickLog-Server/src/main/java/com/example/bricklog/BrickLogApplication.java b/BrickLog-Server/src/main/java/com/example/bricklog/BrickLogApplication.java index 2c8a9ee..e4f3ca8 100644 --- a/BrickLog-Server/src/main/java/com/example/bricklog/BrickLogApplication.java +++ b/BrickLog-Server/src/main/java/com/example/bricklog/BrickLogApplication.java @@ -1,9 +1,14 @@ package com.example.bricklog; +import org.springframework.boot.CommandLineRunner; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; import org.springframework.data.jpa.repository.config.EnableJpaRepositories; +import com.example.bricklog.model.LegoBuild; +import com.example.bricklog.repository.LegoBuildRepository; + @SpringBootApplication @EnableJpaRepositories(basePackages = "com.example.bricklog.repository") // Adjust if needed public class BrickLogApplication { @@ -12,4 +17,14 @@ public class BrickLogApplication { SpringApplication.run(BrickLogApplication.class, args); System.out.println("BrickLog Server is running..."); } + + // Example CommandLineRunner to load initial data into the database + @Bean + public CommandLineRunner initDatabase(LegoBuildRepository repository) { + return args -> { + repository.save(new LegoBuild("Castle", "John Doe", true, "A magnificent medieval castle")); + repository.save(new LegoBuild("Spaceship", "Jane Smith", false, "A futuristic spacecraft model")); + System.out.println("Database initialized with sample data."); + }; + } } diff --git a/BrickLog-Server/src/main/java/com/example/bricklog/controller/LegoBuildController.java b/BrickLog-Server/src/main/java/com/example/bricklog/controller/LegoBuildController.java new file mode 100644 index 0000000..48f555a --- /dev/null +++ b/BrickLog-Server/src/main/java/com/example/bricklog/controller/LegoBuildController.java @@ -0,0 +1,63 @@ +package com.example.bricklog.controller; + +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.multipart.MultipartFile; + +import com.example.bricklog.model.LegoBuild; +import com.example.bricklog.repository.LegoBuildRepository; + +@RestController +@RequestMapping("/api/builds") +public class LegoBuildController { + + private static final String IMAGE_DIRECTORY = "uploads/images/"; + + @Autowired + private LegoBuildRepository legoBuildRepository; + + @PostMapping("/add") + public ResponseEntity addLegoBuild( + @RequestParam("name") String name, + @RequestParam("builder") String builder, + @RequestParam("isKitset") boolean isKitset, + @RequestParam("description") String description, + @RequestParam("image") MultipartFile image) { + + // Save the image file + String filePath = saveImageFile(image); + + // Save the LegoBuild with image path + LegoBuild legoBuild = new LegoBuild(name, builder, isKitset, description); + legoBuild.setImagePath(filePath); + legoBuildRepository.save(legoBuild); + + return new ResponseEntity<>("Build added successfully with image.", HttpStatus.OK); + } + + private String saveImageFile(MultipartFile image) { + try { + Path directoryPath = Paths.get(IMAGE_DIRECTORY); + if (!Files.exists(directoryPath)) { + Files.createDirectories(directoryPath); // Create directory if it doesn’t exist + } + String filePath = IMAGE_DIRECTORY + image.getOriginalFilename(); + File file = new File(filePath); + image.transferTo(file); // Save the image + return filePath; + } catch (IOException e) { + throw new RuntimeException("Failed to store image file", e); + } + } +} diff --git a/BrickLog-Server/src/main/java/com/example/bricklog/model/LegoBuild.java b/BrickLog-Server/src/main/java/com/example/bricklog/model/LegoBuild.java index 0792eba..2ac4a9e 100644 --- a/BrickLog-Server/src/main/java/com/example/bricklog/model/LegoBuild.java +++ b/BrickLog-Server/src/main/java/com/example/bricklog/model/LegoBuild.java @@ -16,6 +16,7 @@ public class LegoBuild { private String builder; private boolean isKitset; // true for Kitset, false for MoC private String description; + private String imagePath; public LegoBuild() {} @@ -67,4 +68,12 @@ public class LegoBuild { public void setDescription(String description) { this.description = description; } + + public String getImagePath() { + return imagePath; + } + + public void setImagePath(String imagePath) { + this.imagePath = imagePath; + } } diff --git a/BrickLog-Server/target/classes/com/example/bricklog/BrickLogApplication.class b/BrickLog-Server/target/classes/com/example/bricklog/BrickLogApplication.class index df8026a..68455e2 100644 Binary files a/BrickLog-Server/target/classes/com/example/bricklog/BrickLogApplication.class and b/BrickLog-Server/target/classes/com/example/bricklog/BrickLogApplication.class differ diff --git a/BrickLog-Server/target/classes/com/example/bricklog/controller/LegoBuildController.class b/BrickLog-Server/target/classes/com/example/bricklog/controller/LegoBuildController.class new file mode 100644 index 0000000..92f2732 Binary files /dev/null and b/BrickLog-Server/target/classes/com/example/bricklog/controller/LegoBuildController.class differ diff --git a/BrickLog-Server/target/classes/com/example/bricklog/model/LegoBuild.class b/BrickLog-Server/target/classes/com/example/bricklog/model/LegoBuild.class new file mode 100644 index 0000000..2fcf428 Binary files /dev/null and b/BrickLog-Server/target/classes/com/example/bricklog/model/LegoBuild.class differ diff --git a/BrickLog-Server/target/classes/com/example/bricklog/repository/LegoBuildRepository.class b/BrickLog-Server/target/classes/com/example/bricklog/repository/LegoBuildRepository.class new file mode 100644 index 0000000..0125d94 Binary files /dev/null and b/BrickLog-Server/target/classes/com/example/bricklog/repository/LegoBuildRepository.class differ diff --git a/BrickLog-Server/target/classes/resources/application.properties b/BrickLog-Server/target/classes/resources/application.properties new file mode 100644 index 0000000..a1ade11 --- /dev/null +++ b/BrickLog-Server/target/classes/resources/application.properties @@ -0,0 +1,9 @@ +# MariaDB Configuration +spring.datasource.url=jdbc:mariadb://localhost:3306/bricklog_db +spring.datasource.username=your_db_username +spring.datasource.password=your_db_password + +# JPA settings +spring.jpa.hibernate.ddl-auto=update # Creates tables automatically; set to 'none' in production if not needed +spring.jpa.show-sql=true # Shows SQL queries in the console, useful for debugging +spring.jpa.database-platform=org.hibernate.dialect.MariaDBDialect