Merge remote-tracking branch 'origin/develop' into Real-Time-update
# Conflicts: # src/main/java/org/to/telegramfinalproject/Client/ActionHandler.java # src/main/java/org/to/telegramfinalproject/UI/LoginForm.java # src/main/java/org/to/telegramfinalproject/UI/RegisterForm.java
This commit is contained in:
@@ -118,8 +118,4 @@ public class User {
|
||||
|
||||
public List<ChatEntry> getChatList(){return this.chatList;}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -35,7 +35,7 @@ public class LoginController {
|
||||
visiblePasswordField.textProperty().bindBidirectional(passwordField.textProperty());
|
||||
|
||||
try {
|
||||
connection = new ClientConnection("localhost", 12345);
|
||||
connection = new ClientConnection("localhost", 8000);
|
||||
} catch (Exception e) {
|
||||
System.out.println("Could not connect to server: " + e.getMessage());
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ public class RegisterController {
|
||||
visibleConfirmPasswordField.textProperty().bindBidirectional(confirmPasswordField.textProperty());
|
||||
|
||||
try {
|
||||
connection = new ClientConnection("localhost", 12345);
|
||||
connection = new ClientConnection("localhost", 8000);
|
||||
} catch (Exception e) {
|
||||
System.out.println("Could not connect to server: " + e.getMessage());
|
||||
}
|
||||
@@ -81,7 +81,7 @@ public class RegisterController {
|
||||
String passwordRegex = "\\b(?=[^\\s]*[A-Z])(?=[^\\s]*[a-z])(?=[^\\s]*\\d)(?=[^\\s]*[!@#$%^&*])[^\\s]{8,}\\b";
|
||||
|
||||
// 1. Empty fields
|
||||
if (username.isEmpty() || profileName.isEmpty() || password.isEmpty() || confirmPass.isEmpty()) {
|
||||
if (userID.isEmpty() || username.isEmpty() || profileName.isEmpty() || password.isEmpty() || confirmPass.isEmpty()) {
|
||||
showError("Please fill in all required fields.");
|
||||
return;
|
||||
}
|
||||
@@ -92,8 +92,8 @@ public class RegisterController {
|
||||
return;
|
||||
}
|
||||
|
||||
// 3. User ID exists (if entered)
|
||||
if (!userID.isEmpty() && userDb.existsByUserId(userID)) {
|
||||
// 3. User ID exists
|
||||
if (userDb.existsByUserId(userID)) {
|
||||
showError("This user ID is already taken.");
|
||||
return;
|
||||
}
|
||||
@@ -114,12 +114,13 @@ public class RegisterController {
|
||||
try {
|
||||
JSONObject request = new JSONObject();
|
||||
request.put("action", "register");
|
||||
request.put("user_id", userID.isEmpty() ? JSONObject.NULL : userID);
|
||||
request.put("user_id", userID);
|
||||
request.put("username", username);
|
||||
request.put("password", password);
|
||||
request.put("profile_name", profileName);
|
||||
connection.send(request.toString());
|
||||
|
||||
// Simulate successful registration (since main.fxml isn’t ready)
|
||||
Alert alert = new Alert(Alert.AlertType.INFORMATION, "Registration successful!");
|
||||
alert.show();
|
||||
|
||||
@@ -137,7 +138,7 @@ public class RegisterController {
|
||||
try {
|
||||
FXMLLoader loader = new FXMLLoader(getClass().getResource("/org/to/telegramfinalproject/" + fxmlFile));
|
||||
Parent root = loader.load();
|
||||
Stage stage = (Stage) usernameField.getScene().getWindow(); // Or any node from your current scene
|
||||
Stage stage = (Stage) usernameField.getScene().getWindow();
|
||||
stage.setScene(new Scene(root, 500, 700));
|
||||
stage.show();
|
||||
} catch (IOException e) {
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
package org.to.telegramfinalproject.UI;
|
||||
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import javafx.scene.Parent;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.stage.Stage;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class login_view {
|
||||
|
||||
@FXML
|
||||
private Button loginButton;
|
||||
|
||||
@FXML
|
||||
private Button registerButton;
|
||||
|
||||
@FXML
|
||||
public void initialize() {
|
||||
|
||||
loginButton.setOnAction(e -> {
|
||||
switchScene("LoginForm.fxml");
|
||||
});
|
||||
|
||||
registerButton.setOnAction(e -> {
|
||||
switchScene("register_view.fxml");
|
||||
});
|
||||
}
|
||||
|
||||
private void switchScene(String fxmlFile) {
|
||||
try {
|
||||
|
||||
FXMLLoader loader = new FXMLLoader(getClass().getResource("/org/to/telegramfinalproject/" + fxmlFile));
|
||||
Parent root = loader.load();
|
||||
|
||||
|
||||
Stage stage = (Stage) loginButton.getScene().getWindow();
|
||||
stage.setScene(new Scene(root));
|
||||
stage.show();
|
||||
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
CREATE TABLE IF NOT EXISTS users(
|
||||
user_id VARCHAR(70) UNIQUE,
|
||||
user_id VARCHAR(70) UNIQUE NOT NULL,
|
||||
internal_uuid UUID PRIMARY KEY,
|
||||
username VARCHAR(50) UNIQUE NOT NULL,
|
||||
password TEXT NOT NULL,
|
||||
@@ -109,3 +109,13 @@ CREATE TABLE IF NOT EXISTS message_receipts (
|
||||
PRIMARY KEY (message_id, user_id)
|
||||
);
|
||||
|
||||
--(Bouns)
|
||||
CREATE TABLE archived_chats (
|
||||
user_id UUID NOT NULL REFERENCES users(internal_uuid) ON DELETE CASCADE,
|
||||
chat_id UUID NOT NULL,
|
||||
chat_type TEXT NOT NULL CHECK (chat_type IN ('private', 'group', 'channel')),
|
||||
archived_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (user_id, chat_id)
|
||||
);
|
||||
|
||||
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.scene.image.Image?>
|
||||
<?import javafx.scene.image.ImageView?>
|
||||
<?import javafx.scene.control.Label?>
|
||||
<?import javafx.scene.layout.HBox?>
|
||||
<?import javafx.scene.layout.VBox?>
|
||||
|
||||
<HBox xmlns="http://javafx.com/javafx"
|
||||
xmlns:fx="http://javafx.com/fxml"
|
||||
fx:controller="org.to.telegramfinalproject.ContactCell"
|
||||
spacing="10.0" alignment="CENTER_LEFT"
|
||||
prefHeight="60.0" style="-fx-padding: 10;">
|
||||
|
||||
<ImageView fx:id="profileImage" fitHeight="40.0" fitWidth="40.0" preserveRatio="true">
|
||||
<image>
|
||||
<Image url="@/Icons/default_user.png" />
|
||||
</image>
|
||||
</ImageView>
|
||||
|
||||
<VBox spacing="4.0">
|
||||
<Label fx:id="nameLabel" text="profile_name"
|
||||
style="-fx-font-size: 14px; -fx-font-weight: bold;" />
|
||||
<Label fx:id="statusLabel" text="● Online"
|
||||
style="-fx-font-size: 12px; -fx-text-fill: green;" />
|
||||
</VBox>
|
||||
</HBox>
|
||||
@@ -1,40 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.scene.text.*?>
|
||||
<?import java.lang.*?>
|
||||
<?import java.util.*?>
|
||||
<?import javafx.scene.*?>
|
||||
<?import javafx.scene.control.*?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
|
||||
<AnchorPane prefHeight="709.0" prefWidth="600.0" style="-fx-background-color: linear-gradient(to right, #B39DDB, #81D4FA); -fx-background-radius: 12;" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="org.to.telegramfinalproject.UI.LoginForm">
|
||||
<children>
|
||||
<TextField fx:id="usernameField" layoutX="289.0" layoutY="189.0" />
|
||||
<PasswordField fx:id="passwordField" layoutX="289.0" layoutY="297.0" />
|
||||
<Label layoutX="258.0" layoutY="69.0" text="Login" textAlignment="CENTER" textFill="WHITE">
|
||||
<font>
|
||||
<Font name="System Bold" size="40.0" />
|
||||
</font>
|
||||
</Label>
|
||||
<Label layoutX="89.0" layoutY="182.0" text="Username :" textAlignment="CENTER" textFill="WHITE">
|
||||
<font>
|
||||
<Font name="System Italic" size="36.0" />
|
||||
</font>
|
||||
</Label>
|
||||
<Label layoutX="88.0" layoutY="290.0" text="Password :" textFill="WHITE">
|
||||
<font>
|
||||
<Font name="System Italic" size="36.0" />
|
||||
</font>
|
||||
</Label>
|
||||
<Button fx:id="loginButton" layoutX="225.0" layoutY="449.0" mnemonicParsing="false" prefHeight="39.0" prefWidth="176.0" style="-fx-background-color: #f8bbd0; -fx-border-radius: 12; -fx-border-color: #6a1b9a; -fx-background-radius: 12;" text="Login" textFill="#79195c">
|
||||
<font>
|
||||
<Font name="System Bold" size="18.0" />
|
||||
</font>
|
||||
</Button>
|
||||
<Button fx:id="backButton" layoutX="227.0" layoutY="532.0" mnemonicParsing="false" prefHeight="39.0" prefWidth="176.0" style="-fx-background-color: #f8bbd0; -fx-background-radius: 12; -fx-border-color: #6a1b9a; -fx-border-radius: 12;" text="Back" textFill="#79195c">
|
||||
<font>
|
||||
<Font name="System Bold" size="18.0" />
|
||||
</font>
|
||||
</Button>
|
||||
</children>
|
||||
</AnchorPane>
|
||||
@@ -1,52 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.scene.image.*?>
|
||||
<?import javafx.scene.text.*?>
|
||||
<?import java.lang.*?>
|
||||
<?import java.util.*?>
|
||||
<?import javafx.scene.*?>
|
||||
<?import javafx.scene.control.*?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
|
||||
<ScrollPane prefHeight="983.0" prefWidth="859.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="org.to.telegramfinalproject.MainPage">
|
||||
<content>
|
||||
<AnchorPane prefHeight="977.0" prefWidth="845.0">
|
||||
<children>
|
||||
<AnchorPane layoutX="7.0" layoutY="-8.0" prefHeight="977.0" prefWidth="845.0">
|
||||
<children>
|
||||
<Label layoutX="-7.0" layoutY="-6.0" prefHeight="78.0" prefWidth="859.0" style="-fx-background-color: #1882da;" text=" Telegram" textFill="WHITE">
|
||||
<font>
|
||||
<Font name="Arial Bold" size="36.0" />
|
||||
</font>
|
||||
</Label>
|
||||
<Button contentDisplay="GRAPHIC_ONLY" layoutX="6.0" layoutY="10.0" mnemonicParsing="false" style="-fx-background-color: #1882da;">
|
||||
<graphic>
|
||||
<ImageView fitHeight="39.0" fitWidth="63.0" pickOnBounds="true" preserveRatio="true">
|
||||
<image>
|
||||
<Image url="@../../../Icons/menu.png" />
|
||||
</image>
|
||||
</ImageView>
|
||||
</graphic>
|
||||
</Button>
|
||||
<Button contentDisplay="GRAPHIC_ONLY" layoutX="703.0" layoutY="9.0" mnemonicParsing="false" prefHeight="54.0" prefWidth="135.0" style="-fx-background-color: #1882da;" text="" textFill="#d6d6d6">
|
||||
<graphic>
|
||||
<ImageView fitHeight="47.0" fitWidth="54.0" pickOnBounds="true" preserveRatio="true">
|
||||
<image>
|
||||
<Image url="@../../../Icons/search.png" />
|
||||
</image>
|
||||
</ImageView>
|
||||
</graphic>
|
||||
</Button>
|
||||
<Button contentDisplay="GRAPHIC_ONLY" layoutX="547.0" mnemonicParsing="false" prefHeight="66.0" prefWidth="114.0" style="-fx-background-color: #1882da;" text="" />
|
||||
<ImageView fitHeight="50.0" fitWidth="110.0" layoutX="586.0" layoutY="14.0" pickOnBounds="true" preserveRatio="true">
|
||||
<image>
|
||||
<Image url="@../../../Icons/time.png" />
|
||||
</image>
|
||||
</ImageView>
|
||||
<ListView fx:id="contactListView" layoutX="1.0" layoutY="73.0" prefHeight="907.0" prefWidth="851.0" />
|
||||
</children>
|
||||
</AnchorPane>
|
||||
</children>
|
||||
</AnchorPane>
|
||||
</content>
|
||||
</ScrollPane>
|
||||
@@ -1,68 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.geometry.Insets?>
|
||||
<?import javafx.scene.control.*?>
|
||||
<?import javafx.scene.image.*?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
<?import javafx.scene.text.Font?>
|
||||
|
||||
<AnchorPane prefHeight="800.0" prefWidth="802.0"
|
||||
xmlns="http://javafx.com/javafx/8"
|
||||
xmlns:fx="http://javafx.com/fxml/1"
|
||||
fx:controller="org.to.telegramfinalproject.SearchingView">
|
||||
|
||||
<children>
|
||||
|
||||
<StackPane alignment="CENTER_LEFT" layoutX="0" layoutY="0" prefHeight="90.0" prefWidth="802.0">
|
||||
<children>
|
||||
|
||||
<Label prefHeight="90.0" prefWidth="802.0"
|
||||
style="-fx-background-color: #1882da;"
|
||||
text=" Search" textFill="#c9c9c9">
|
||||
<font>
|
||||
<Font name="System Bold" size="24.0" />
|
||||
</font>
|
||||
</Label>
|
||||
|
||||
<HBox spacing="5.0" alignment="CENTER_LEFT">
|
||||
<StackPane.margin>
|
||||
<Insets left="100.0" />
|
||||
</StackPane.margin>
|
||||
|
||||
<TextField fx:id="searchField"
|
||||
promptText="Search..."
|
||||
prefHeight="40.0" prefWidth="250.0"
|
||||
style="-fx-background-color: #ffffff; -fx-background-radius: 20; -fx-border-radius: 20; -fx-border-color: transparent; -fx-font-size: 14;" />
|
||||
|
||||
<Button fx:id="searchButton"
|
||||
contentDisplay="GRAPHIC_ONLY"
|
||||
prefWidth="32.0" prefHeight="32.0"
|
||||
style="-fx-background-color: #ffffff; -fx-background-radius: 50; -fx-border-color: transparent;">
|
||||
<graphic>
|
||||
<ImageView fitHeight="16.0" fitWidth="16.0" preserveRatio="true">
|
||||
<image>
|
||||
<Image url="@/Icons/search.png" />
|
||||
</image>
|
||||
</ImageView>
|
||||
</graphic>
|
||||
</Button>
|
||||
|
||||
<Button fx:id="exitButton"
|
||||
contentDisplay="GRAPHIC_ONLY"
|
||||
prefWidth="32.0" prefHeight="32.0"
|
||||
style="-fx-background-color: #ffffff; -fx-background-radius: 50; -fx-border-color: transparent;">
|
||||
<graphic>
|
||||
<ImageView fitHeight="16.0" fitWidth="16.0" preserveRatio="true">
|
||||
<image>
|
||||
<Image url="@/Icons/remove.png" />
|
||||
</image>
|
||||
</ImageView>
|
||||
</graphic>
|
||||
</Button>
|
||||
</HBox>
|
||||
|
||||
</children>
|
||||
</StackPane>
|
||||
|
||||
</children>
|
||||
</AnchorPane>
|
||||
@@ -16,7 +16,7 @@
|
||||
style="-fx-font-size: 24px; -fx-font-weight: bold;" />
|
||||
|
||||
<TextField fx:id="userIdField"
|
||||
promptText="User ID (optional)"
|
||||
promptText="User ID"
|
||||
prefWidth="320" prefHeight="30"
|
||||
maxWidth="320"/>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user