Skip to content

Commit

Permalink
feat: migrate current swing componenet
Browse files Browse the repository at this point in the history
  • Loading branch information
lcaohoanq committed Aug 29, 2024
1 parent d9b1f1d commit 16d3bc4
Show file tree
Hide file tree
Showing 27 changed files with 3,592 additions and 67 deletions.
37 changes: 37 additions & 0 deletions logs/app.log
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,40 @@
2024-08-27 09:00:45 WARN org.hibernate.orm.deprecation - HHH90000025: MySQLDialect does not need to be specified explicitly using 'hibernate.dialect' (remove the property setting and it will be selected by default)
2024-08-27 09:00:46 INFO o.h.e.t.j.p.i.JtaPlatformInitiator - HHH000489: No JTA platform available (set 'hibernate.transaction.jta.platform' to enable JTA platform integration)
2024-08-27 09:00:46 INFO o.hibernate.orm.connections.access - HHH10001501: Connection obtained from JdbcConnectionAccess [org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator$ConnectionProviderJdbcConnectionAccess@3df2199] for (non-JTA) DDL execution was not in auto-commit mode; the Connection 'local transaction' will be committed and the Connection will be set into auto-commit mode.
2024-08-29 17:09:39 INFO o.h.jpa.internal.util.LogHelper - HHH000204: Processing PersistenceUnitInfo [name: JFXSGPU]
2024-08-29 17:09:39 INFO org.hibernate.Version - HHH000412: Hibernate ORM core version [WORKING]
2024-08-29 17:09:39 INFO o.h.c.i.RegionFactoryInitiator - HHH000026: Second-level cache disabled
2024-08-29 17:09:39 WARN o.hibernate.orm.connections.pooling - HHH10001002: Using built-in connection pool (not intended for production use)
2024-08-29 17:09:39 INFO o.hibernate.orm.connections.pooling - HHH10001005: Loaded JDBC driver class: com.mysql.cj.jdbc.Driver
2024-08-29 17:09:39 INFO o.hibernate.orm.connections.pooling - HHH10001012: Connecting with JDBC URL [jdbc:mysql://localhost:3307/snake_game_app]
2024-08-29 17:09:39 INFO o.hibernate.orm.connections.pooling - HHH10001001: Connection properties: {password=****, user=lcaohoanq}
2024-08-29 17:09:39 INFO o.hibernate.orm.connections.pooling - HHH10001003: Autocommit mode: false
2024-08-29 17:09:39 INFO o.hibernate.orm.connections.pooling - HHH10001115: Connection pool size: 20 (min=1)
2024-08-29 17:09:39 WARN org.hibernate.orm.deprecation - HHH90000025: MySQLDialect does not need to be specified explicitly using 'hibernate.dialect' (remove the property setting and it will be selected by default)
2024-08-29 17:09:40 INFO o.h.e.t.j.p.i.JtaPlatformInitiator - HHH000489: No JTA platform available (set 'hibernate.transaction.jta.platform' to enable JTA platform integration)
2024-08-29 17:09:40 INFO o.hibernate.orm.connections.access - HHH10001501: Connection obtained from JdbcConnectionAccess [org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator$ConnectionProviderJdbcConnectionAccess@23b863ff] for (non-JTA) DDL execution was not in auto-commit mode; the Connection 'local transaction' will be committed and the Connection will be set into auto-commit mode.
2024-08-29 17:10:07 INFO c.l.f.c.SwingLoginController - Admin login successful
2024-08-29 17:17:32 INFO o.h.jpa.internal.util.LogHelper - HHH000204: Processing PersistenceUnitInfo [name: JFXSGPU]
2024-08-29 17:17:32 INFO org.hibernate.Version - HHH000412: Hibernate ORM core version [WORKING]
2024-08-29 17:17:32 INFO o.h.c.i.RegionFactoryInitiator - HHH000026: Second-level cache disabled
2024-08-29 17:17:33 WARN o.hibernate.orm.connections.pooling - HHH10001002: Using built-in connection pool (not intended for production use)
2024-08-29 17:17:33 INFO o.hibernate.orm.connections.pooling - HHH10001005: Loaded JDBC driver class: com.mysql.cj.jdbc.Driver
2024-08-29 17:17:33 INFO o.hibernate.orm.connections.pooling - HHH10001012: Connecting with JDBC URL [jdbc:mysql://localhost:3307/snake_game_app]
2024-08-29 17:17:33 INFO o.hibernate.orm.connections.pooling - HHH10001001: Connection properties: {password=****, user=lcaohoanq}
2024-08-29 17:17:33 INFO o.hibernate.orm.connections.pooling - HHH10001003: Autocommit mode: false
2024-08-29 17:17:33 INFO o.hibernate.orm.connections.pooling - HHH10001115: Connection pool size: 20 (min=1)
2024-08-29 17:17:33 WARN org.hibernate.orm.deprecation - HHH90000025: MySQLDialect does not need to be specified explicitly using 'hibernate.dialect' (remove the property setting and it will be selected by default)
2024-08-29 17:17:34 INFO o.h.e.t.j.p.i.JtaPlatformInitiator - HHH000489: No JTA platform available (set 'hibernate.transaction.jta.platform' to enable JTA platform integration)
2024-08-29 17:17:34 INFO o.hibernate.orm.connections.access - HHH10001501: Connection obtained from JdbcConnectionAccess [org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator$ConnectionProviderJdbcConnectionAccess@3dfe5ca] for (non-JTA) DDL execution was not in auto-commit mode; the Connection 'local transaction' will be committed and the Connection will be set into auto-commit mode.
2024-08-29 17:19:43 INFO o.h.jpa.internal.util.LogHelper - HHH000204: Processing PersistenceUnitInfo [name: JFXSGPU]
2024-08-29 17:19:43 INFO org.hibernate.Version - HHH000412: Hibernate ORM core version [WORKING]
2024-08-29 17:19:43 INFO o.h.c.i.RegionFactoryInitiator - HHH000026: Second-level cache disabled
2024-08-29 17:19:43 WARN o.hibernate.orm.connections.pooling - HHH10001002: Using built-in connection pool (not intended for production use)
2024-08-29 17:19:43 INFO o.hibernate.orm.connections.pooling - HHH10001005: Loaded JDBC driver class: com.mysql.cj.jdbc.Driver
2024-08-29 17:19:43 INFO o.hibernate.orm.connections.pooling - HHH10001012: Connecting with JDBC URL [jdbc:mysql://localhost:3307/snake_game_app]
2024-08-29 17:19:43 INFO o.hibernate.orm.connections.pooling - HHH10001001: Connection properties: {password=****, user=lcaohoanq}
2024-08-29 17:19:43 INFO o.hibernate.orm.connections.pooling - HHH10001003: Autocommit mode: false
2024-08-29 17:19:43 INFO o.hibernate.orm.connections.pooling - HHH10001115: Connection pool size: 20 (min=1)
2024-08-29 17:19:43 WARN org.hibernate.orm.deprecation - HHH90000025: MySQLDialect does not need to be specified explicitly using 'hibernate.dialect' (remove the property setting and it will be selected by default)
2024-08-29 17:19:44 INFO o.h.e.t.j.p.i.JtaPlatformInitiator - HHH000489: No JTA platform available (set 'hibernate.transaction.jta.platform' to enable JTA platform integration)
2024-08-29 17:19:44 INFO o.hibernate.orm.connections.access - HHH10001501: Connection obtained from JdbcConnectionAccess [org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator$ConnectionProviderJdbcConnectionAccess@1d91bfa] for (non-JTA) DDL execution was not in auto-commit mode; the Connection 'local transaction' will be committed and the Connection will be set into auto-commit mode.
3 changes: 3 additions & 0 deletions src/main/java/com/lcaohoanq/formhandling/Main.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package com.lcaohoanq.formhandling;

import com.lcaohoanq.formhandling.utils.LogsUtils;
import com.lcaohoanq.formhandling.views.OTPVerificationView;
import com.lcaohoanq.formhandling.views.SwingLoginView;
import java.awt.EventQueue;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.lcaohoanq.formhandling.constants;

public class APIConstants {
public static final String API_PREFIX = "/api/v1";
public static final String BASE_URL = "http://localhost:8081" + API_PREFIX;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.lcaohoanq.formhandling.controllers;

import java.awt.Desktop;
import java.awt.event.ActionListener;
import java.net.URI;
import lombok.extern.slf4j.Slf4j;
import com.lcaohoanq.formhandling.views.SwingLoginView;
import com.lcaohoanq.formhandling.views.OTPVerificationView;

@Slf4j
public class ForgotPasswordController implements ActionListener {

private final SwingLoginView loginView;

@Deprecated
private OTPVerificationView otpVerificationView;

public ForgotPasswordController(SwingLoginView loginView, OTPVerificationView otpVerificationView) {
this.loginView = loginView;
this.otpVerificationView = otpVerificationView;
}

@Override
public void actionPerformed(java.awt.event.ActionEvent e) {
String api = "http://localhost:3000/forgot-password";
try {
// Specify the URL of the website
URI uri = new URI("http://localhost:3000/forgot-password");
// Open the website in the default browser
if (Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(Desktop.Action.BROWSE)) {
Desktop.getDesktop().browse(uri);
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
package com.lcaohoanq.formhandling.controllers;

import com.lcaohoanq.formhandling.constants.APIConstants;
import com.lcaohoanq.formhandling.utils.ApiUtils;
import com.lcaohoanq.formhandling.utils.EnvUtils;
import com.lcaohoanq.formhandling.views.MenuView;
import com.lcaohoanq.formhandling.views.UIPrompts;
import com.lcaohoanq.formhandling.views.base.BaseResources;
import java.awt.EventQueue;
import java.awt.event.ActionListener;
import java.net.http.HttpResponse;
import java.util.Map;
import javafx.application.Platform;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.control.PasswordField;
import javafx.scene.control.TextField;
import javafx.scene.input.KeyCode;
import javafx.event.ActionEvent;
import javafx.stage.Stage;
import javax.swing.JOptionPane;
import lombok.AllArgsConstructor;
import lombok.Getter;
Expand Down Expand Up @@ -76,7 +83,7 @@ private void login(String email_phone, String password) {
new Thread(() -> {
try {
// Replace with your API URL
String apiUrl = "http://localhost:8081/users/login";
String apiUrl = APIConstants.BASE_URL + "/users/login";
// Create the payload as a map and convert it to JSON
Map<String, String> payload = Map.of(
"email_phone", email_phone, // Replace with actual value
Expand All @@ -90,6 +97,13 @@ private void login(String email_phone, String password) {
switch (response.statusCode()) {
case 200:
UIPrompts.IS_LOGIN_SUCCESS();

Platform.runLater(() -> {
new MenuView().setVisible(true);
Stage stage = (Stage) loginButton.getScene().getWindow();
stage.close();
});

break;
case 400:
JOptionPane.showMessageDialog(null,
Expand All @@ -107,22 +121,33 @@ private void login(String email_phone, String password) {
}

@FXML
// Custom method for login via Google action
private void loginViaGoogleAction() {
UIPrompts.IS_NOT_SUPPORT();
Platform.runLater(() -> {
String googleAuthUrl = EnvUtils.get("GOOGLE_AUTH_URL");
try {
URI uri = new URI(googleAuthUrl);
if (Desktop.isDesktopSupported() && Desktop.getDesktop()
.isSupported(Desktop.Action.BROWSE)) {
Desktop.getDesktop().browse(uri);
}
} catch (Exception ex) {
ex.printStackTrace();
}
});
}

@FXML
private void loginViaFacebookAction() {
UIPrompts.IS_NOT_SUPPORT();
Platform.runLater(() -> UIPrompts.IS_NOT_SUPPORT());
}

public void signupHereAction(ActionEvent actionEvent) {
try {
// Specify the URL of the website
URI uri = new URI("http://localhost:3000/users/register");
// Open the website in the default browser
if (Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(Desktop.Action.BROWSE)) {
if (Desktop.isDesktopSupported() && Desktop.getDesktop()
.isSupported(Desktop.Action.BROWSE)) {
Desktop.getDesktop().browse(uri);
}
} catch (Exception ex) {
Expand Down
Loading

0 comments on commit 16d3bc4

Please sign in to comment.