Skip to content

Commit

Permalink
final push
Browse files Browse the repository at this point in the history
  • Loading branch information
nedaei79 committed Jul 24, 2020
1 parent 37580e7 commit b9f6d45
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 29 deletions.
10 changes: 1 addition & 9 deletions src/main/java/client/controller/ProductController.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,6 @@ public void deleteItemById(String Id) {

// used in cart managing menu

public void setActiveProductById(int productId) {
try {
MethodStringer.sampleMethod(getClass(),
"setActiveProductById", productId);
} catch (Throwable throwable) {
throwable.printStackTrace();
}
}

public void setActiveProductById(String productId) {
try {
MethodStringer.sampleMethod(getClass(),
Expand All @@ -104,6 +95,7 @@ public void setActiveProductById(String productId) {
}
}


// used in products managing menu

public void setActiveProductSellInfo(String sellInfoId) {
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/client/network/ClientSocket.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
public class ClientSocket extends Thread {

// server info
// public static final int PORT = 15154;
// public static final String IP = "0.tcp.ngrok.io";
public static final int PORT = 13092;
public static final String IP = "0.tcp.ngrok.io";

// in pc
public static final int PORT = 6666;
public static final String IP = "127.0.0.1";
// public static final int PORT = 6666;
// public static final String IP = "127.0.0.1";
private int messageCounter;

private final P2PSocket p2pSocket = new P2PSocket();
Expand Down
20 changes: 10 additions & 10 deletions src/main/java/client/newViewBagheri/ProductMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -171,15 +171,15 @@ private VBox createProductInfoVBox(HashMap<String, String> productInfo) {
int sizePrefWidth = 195;
productInfoVBox.setPrefWidth(sizePrefWidth);
productInfoVBox.setPrefHeight(350.0);
ImageView productImageView = new ImageView(new Image(productInfo.get("imageAddress")));
productImageView.setOnMouseClicked(e -> goToProduct(productInfo.get("id")));
productImageView.setPreserveRatio(true);
productImageView.setFitWidth(190.0);
productImageView.setFitHeight(250.0);
BorderPane imagePane = new BorderPane(productImageView);
BorderPane.setAlignment(productImageView, Pos.CENTER);
imagePane.setPrefWidth(sizePrefWidth);
imagePane.setPrefHeight(250.0);
// ImageView productImageView = new ImageView(new Image(productInfo.get("imageAddress")));
// productImageView.setOnMouseClicked(e -> goToProduct(productInfo.get("id")));
// productImageView.setPreserveRatio(true);
// productImageView.setFitWidth(190.0);
// productImageView.setFitHeight(250.0);
// BorderPane imagePane = new BorderPane(productImageView);
// BorderPane.setAlignment(productImageView, Pos.CENTER);
// imagePane.setPrefWidth(sizePrefWidth);
// imagePane.setPrefHeight(250.0);
// TODO: productImageView.setFitWidth();
// TODO: add pane and centering image
int labelSize = 30;
Expand All @@ -196,7 +196,7 @@ private VBox createProductInfoVBox(HashMap<String, String> productInfo) {
} else {
productPriceLabel.setText("price: " + productPrice);
}
productInfoVBox.getChildren().addAll(imagePane, productName, productScore, productPriceLabel);
productInfoVBox.getChildren().addAll(productName, productScore, productPriceLabel);
return productInfoVBox;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import client.controller.ProductController;
import client.controller.userControllers.BuyerController;
import client.controller.userControllers.UserController;
import com.google.gson.internal.LinkedTreeMap;
import javafx.fxml.FXML;
import javafx.geometry.Pos;
import javafx.scene.control.Button;
Expand All @@ -24,7 +25,7 @@
public class CartManagingMenu {
public Label price;
public GridPane grid;
private final ArrayList<HashMap<String, String>> cart;
private final ArrayList cart;

public CartManagingMenu() {
cart = BuyerController.getInstance().getCart();
Expand All @@ -37,8 +38,8 @@ public static String getFxmlFilePath() {
@FXML
public void initialize() {
int i = 0;
for (HashMap<String, String> product : cart) {
Pane pane = createProductDisplay(product);
for (Object product : cart) {
Pane pane = createProductDisplay(new HashMap<String, String>((LinkedTreeMap)product));
grid.add(pane, i%5, i/5);
i++;
}
Expand Down Expand Up @@ -104,7 +105,7 @@ private Pane createProductDisplay(HashMap<String, String> product) {
view.setPrefHeight(50);
view.setTranslateX(120);
view.setTranslateY(120);
ProductController.getInstance().setActiveProductById(Integer.parseInt(product.get("id")));
ProductController.getInstance().setActiveProductById(product.get("id"));
view.setOnMouseClicked(event -> MenuController.getInstance().goToMenu(ProductMenu.getFxmlFilePath()));

pane.getChildren().add(nameAndAmount);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public void initialize() {
}

public void goNext() {
if (!BuyerController.getInstance().isDiscountCodeValid(code.getText())) {
if (!code.getText().equals("") && !BuyerController.getInstance().isDiscountCodeValid(code.getText())) {
error.setText("invalid discount code");
return;
} if (walletOrAccount.getValue().equals("account") && !BuyerController.getInstance().canPurchaseByAccount()) {
Expand Down
1 change: 1 addition & 0 deletions src/main/java/server/controller/ProductController.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package server.controller;

import client.network.MethodStringer;
import server.controller.managers.Deleter;
import server.controller.userControllers.BuyerController;
import server.controller.userControllers.UserController;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/server/databaserecovery.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"allUsers":{"buyer3":{"purchasedProducts":"{}","personalInfo":"{\"username\":\"b\",\"firstName\":\"b\",\"lastName\":\"b\",\"emailAddress\":\"[email protected]\",\"phoneNumber\":\"09123456789\",\"password\":\"b\"}","balance":"100","listOfCodedDiscounts":"[]","listOfBuyLogs":"[]"},"admin1":{"personalInfo":"{\"username\":\"a\",\"firstName\":\"a\",\"lastName\":\"a\",\"emailAddress\":\"[email protected]\",\"phoneNumber\":\"09123456789\",\"password\":\"a\"}"},"seller2":{"personalInfo":"{\"username\":\"s\",\"firstName\":\"s\",\"lastName\":\"s\",\"emailAddress\":\"[email protected]\",\"phoneNumber\":\"09123456789\",\"password\":\"s\"}","listOfOffs":"[\"1\"]","balance":"0","listOfSellLogs":"[]","availableProducts":"{\"1\":\"1\",\"2\":\"2\"}","company":"c"},"seller4":{"personalInfo":"{\"username\":\"ss\",\"firstName\":\"s\",\"lastName\":\"s\",\"emailAddress\":\"[email protected]\",\"phoneNumber\":\"09123456789\",\"password\":\"c\"}","listOfOffs":"[]","balance":"0","listOfSellLogs":"[]","availableProducts":"{\"1\":\"4\",\"3\":\"5\",\"4\":\"6\"}","company":"c"}},"requestedSellers":{},"allCodedDiscounts":{},"allCategories":{"FinalCategory4":{"specialFeatures":"[\"\"]","productsList":"[\"2\"]","name":"cc"},"FinalCategory2":{"specialFeatures":"[\"\"]","productsList":"[\"1\",\"3\",\"4\"]","name":"c"}},"allProducts":{"1":{"allComments":"[]","rates":"[]","description":"fghjkl","seen":"4","categoryFeatures":"{}","averageScore":"0.0","productionDate":"\"Jun 26, 2020 3:36:10 PM\"","defaultSellInfo":"1","name":"p","sellersList":"[\"1\",\"4\"]","sellCount":"0","imageAddress":"/photos/12.jpg","company":"c","minimumPrice":"5","category":"FinalCategory2"},"2":{"allComments":"[]","rates":"[]","description":"bnm","seen":"0","categoryFeatures":"{}","averageScore":"0.0","productionDate":"\"Jun 26, 2020 3:36:36 PM\"","defaultSellInfo":"2","name":"p1","sellersList":"[\"2\"]","sellCount":"0","imageAddress":"/photos/14.jpg","company":"c","minimumPrice":"20","category":"FinalCategory4"},"3":{"allComments":"[]","rates":"[]","description":"dfghjkl","seen":"0","categoryFeatures":"{}","averageScore":"0.0","productionDate":"\"Jun 26, 2020 4:34:21 PM\"","defaultSellInfo":"5","name":"p4","sellersList":"[\"5\"]","sellCount":"0","imageAddress":"/poker.png","company":"c","minimumPrice":"123","category":"FinalCategory2"},"4":{"allComments":"[]","rates":"[]","description":"ghjk","seen":"0","categoryFeatures":"{}","averageScore":"0.0","productionDate":"\"Jun 26, 2020 4:35:02 PM\"","defaultSellInfo":"6","name":"p6","sellersList":"[\"6\"]","sellCount":"0","imageAddress":"/poker.png","company":"c","minimumPrice":"54","category":"FinalCategory2"}},"allLogs":{},"allOffs":{"1":{"productsList":"[\"1\"]","offStatus":"null","discountAmount":"50","startTime":"\"Jun 26, 2020 12:00:00 AM\"","endTime":"\"Jun 27, 2020 12:00:00 AM\""}},"allRequests":{},"allProductSellInfos":{"1":{"seller":"seller2","product":"1","price":"10","allBuyers":"{}","stock":"10","off":"1"},"2":{"seller":"seller2","product":"2","price":"20","allBuyers":"{}","stock":"10"},"3":{"seller":"seller4","product":"1","price":"30","allBuyers":"{}","stock":"100"},"4":{"seller":"seller4","product":"1","price":"30","allBuyers":"{}","stock":"20"},"5":{"seller":"seller4","product":"3","price":"123","allBuyers":"{}","stock":"321"},"6":{"seller":"seller4","product":"4","price":"54","allBuyers":"{}","stock":"45"}},"allRates":{},"allCompanies":[{"name":"c","otherInformation":"zxcvbnm"},{"name":"c","otherInformation":"ghjkl;"}],"idKeeper":{"usersNewId":4,"codedDiscountsNewId":0,"categoriesNewId":5,"productsNewId":4,"logsNewId":0,"offsNewId":1,"requestsNewId":9,"productSellInfosNewId":6,"ratesNewId":0}}
{"allUsers":{"seller9":{"personalInfo":"{\"username\":\"s4\",\"firstName\":\"s\",\"lastName\":\"s\",\"emailAddress\":\"[email protected]\",\"phoneNumber\":\"09123456789\",\"password\":\"s\"}","listOfOffs":"[]","balance":"0","listOfSellLogs":"[]","availableProducts":"{\"3\":\"3\",\"4\":\"4\"}","company":"sth","accountNumber":"34693","accountToken":"b8f0c9bf10ee4cfc9cbacfc232b26531"},"buyer10":{"purchasedProducts":"{}","personalInfo":"{\"username\":\"b5\",\"firstName\":\"b\",\"lastName\":\"b\",\"emailAddress\":\"[email protected]\",\"phoneNumber\":\"09123456789\",\"password\":\"b\"}","balance":"0","listOfCodedDiscounts":"[]","listOfBuyLogs":"[]","accountNumber":"47039","accountToken":"450ca00689f34ac4822a86bc71029f26"},"buyer11":{"purchasedProducts":"{}","personalInfo":"{\"username\":\"bm\",\"firstName\":\"b\",\"lastName\":\"b\",\"emailAddress\":\"[email protected]\",\"phoneNumber\":\"09123456789\",\"password\":\"b\"}","balance":"0","listOfCodedDiscounts":"[]","listOfBuyLogs":"[]","accountNumber":"59385","accountToken":"4dcb7d925632425c8fe787b71ac002b9"},"seller7":{"personalInfo":"{\"username\":\"ss\",\"firstName\":\"s\",\"lastName\":\"s\",\"emailAddress\":\"[email protected]\",\"phoneNumber\":\"09123456789\",\"password\":\"s\"}","listOfOffs":"[]","balance":"0","listOfSellLogs":"[]","availableProducts":"{\"1\":\"1\",\"2\":\"2\"}","company":"sth","accountNumber":"108769"},"buyer5":{"purchasedProducts":"{}","personalInfo":"{\"username\":\"bb\",\"firstName\":\"b\",\"lastName\":\"b\",\"emailAddress\":\"[email protected]\",\"phoneNumber\":\"09123456789\",\"password\":\"b\"}","balance":"0","listOfCodedDiscounts":"[]","listOfBuyLogs":"[]","accountNumber":"84077","accountToken":"2129ec00ee3345b3bce6e3376a9622ff"},"buyer12":{"purchasedProducts":"{}","personalInfo":"{\"username\":\"b6\",\"firstName\":\"b\",\"lastName\":\"b\",\"emailAddress\":\"[email protected]\",\"phoneNumber\":\"09123456789\",\"password\":\"b\"}","balance":"0","listOfCodedDiscounts":"[]","listOfBuyLogs":"[]","accountNumber":"71731","accountToken":"fe82bea96aff442fab387928899f0c2e"},"buyer6":{"purchasedProducts":"{}","personalInfo":"{\"username\":\"b1\",\"firstName\":\"b\",\"lastName\":\"b\",\"emailAddress\":\"[email protected]\",\"phoneNumber\":\"09123456789\",\"password\":\"b\"}","balance":"100","listOfCodedDiscounts":"[]","listOfBuyLogs":"[]","accountNumber":"96423","accountToken":"16b143a042f44abdaa0e4c5091ddb188"},"buyer13":{"purchasedProducts":"{}","personalInfo":"{\"username\":\"b7\",\"firstName\":\"b\",\"lastName\":\"b\",\"emailAddress\":\"[email protected]\",\"phoneNumber\":\"09123456789\",\"password\":\"b\"}","balance":"0","listOfCodedDiscounts":"[]","listOfBuyLogs":"[]","accountNumber":"84077","accountToken":"7dd3a896012745dea260a9be53844459"},"admin1":{"personalInfo":"{\"username\":\"a\",\"firstName\":\"a\",\"lastName\":\"a\",\"emailAddress\":\"[email protected]\",\"phoneNumber\":\"09123456789\",\"password\":\"a\"}"}},"requestedSellers":{},"allCodedDiscounts":{},"allCategories":{"FinalCategory2":{"specialFeatures":"[\"\"]","productsList":"[\"1\",\"2\",\"3\",\"4\"]","name":"c"}},"allProducts":{"1":{"allComments":"[]","rates":"[]","description":"sth","videoAddress":"sth","seen":"0","categoryFeatures":"{}","averageScore":"0.0","productionDate":"\"Jul 24, 2020 6:35:40 PM\"","defaultSellInfo":"1","name":"p1","sellersList":"[\"1\"]","sellCount":"0","imageAddress":"/photos/sth","company":"sth","minimumPrice":"10","category":"FinalCategory2"},"2":{"allComments":"[]","rates":"[]","description":"sth","videoAddress":"sth","seen":"0","categoryFeatures":"{}","averageScore":"0.0","productionDate":"\"Jul 24, 2020 7:24:27 PM\"","defaultSellInfo":"2","name":"p2","sellersList":"[\"2\"]","sellCount":"0","imageAddress":"/photos/sth","company":"sth","minimumPrice":"10","category":"FinalCategory2"},"3":{"allComments":"[]","rates":"[]","description":"sth","videoAddress":"sth","seen":"2","categoryFeatures":"{}","averageScore":"0.0","productionDate":"\"Jul 24, 2020 9:35:28 PM\"","defaultSellInfo":"3","name":"p5","sellersList":"[\"3\"]","sellCount":"0","imageAddress":"/photos/sth","company":"sth","minimumPrice":"0","category":"FinalCategory2"},"4":{"allComments":"[]","rates":"[]","description":"sth","videoAddress":"sth","seen":"2","categoryFeatures":"{}","averageScore":"0.0","productionDate":"\"Jul 24, 2020 10:23:10 PM\"","defaultSellInfo":"4","name":"p6","sellersList":"[\"4\"]","sellCount":"0","imageAddress":"/photos/sth","company":"sth","minimumPrice":"10","category":"FinalCategory2"}},"allLogs":{},"allOffs":{},"allRequests":{},"allProductSellInfos":{"1":{"seller":"seller7","product":"1","price":"10","allBuyers":"{}","stock":"10"},"2":{"seller":"seller7","product":"2","price":"10","allBuyers":"{}","stock":"10"},"3":{"seller":"seller9","product":"3","price":"10","allBuyers":"{}","stock":"10"},"4":{"seller":"seller9","product":"4","price":"10","allBuyers":"{}","stock":"10"}},"allRates":{},"allCompanies":[{"name":"sth","otherInformation":"sth"},{"name":"sth","otherInformation":"sth"}],"idKeeper":{"usersNewId":13,"codedDiscountsNewId":0,"categoriesNewId":2,"productsNewId":4,"logsNewId":0,"offsNewId":0,"requestsNewId":6,"productSellInfosNewId":4,"ratesNewId":0,"auctionNewId":6}}

0 comments on commit b9f6d45

Please sign in to comment.