diff --git a/backend/README.md b/backend/README.md index 35b76c1..d6c299f 100644 --- a/backend/README.md +++ b/backend/README.md @@ -44,4 +44,8 @@ cd Jucundus docker Compose up -d Dashboard Agendash -https://jucundus-api.saucisse.ninja/dash/ \ No newline at end of file +https://jucundus-api.saucisse.ninja/dash/ + +# Prod Update +git stash +git pull origin main \ No newline at end of file diff --git a/backend/controllers/favorite.js b/backend/controllers/favorite.js index 1ba96ba..002c464 100644 --- a/backend/controllers/favorite.js +++ b/backend/controllers/favorite.js @@ -6,10 +6,10 @@ exports.save = asyncHandler(async (req, res, next) => { try{ let result = await save(req.body); console.log(result); - res.status(204).send({message: "Favorite created"}); + res.status(204).json({message: "Favorite created"}); }catch(err){ console.log(err); - return res.status(500).send({error: err}); + return res.status(500).json({error: err}); } }); @@ -19,9 +19,9 @@ exports.getAll = asyncHandler(async (req, res, next) => { try{ let result = await getAll(); console.log(result); - res.status(200).send(result); + res.status(200).json(result); }catch(err){ console.log(err); - return res.status(500).send({error: err}); + return res.status(500).json({error: err}); } }); \ No newline at end of file diff --git a/backend/controllers/lot.js b/backend/controllers/lot.js index 0ffc145..7c231eb 100644 --- a/backend/controllers/lot.js +++ b/backend/controllers/lot.js @@ -33,7 +33,7 @@ exports.getInfos = asyncHandler(async (req, res, next) => { }) .catch(error => { console.error(error); - return res.status(500).send({error: error}); + return res.status(500).json({error: error}); }); }); @@ -64,7 +64,7 @@ exports.getPictures = asyncHandler(async (req, res, next) => { }) .catch(error => { console.error(error); - return res.status(500).send({error: error}); + return res.status(500).json({error: error}); }); }); @@ -75,7 +75,7 @@ exports.getLotsBySale = asyncHandler(async (req, res, next) => { const Sale = await saleDb.get(id); if(!Sale){ console.error("Sale not found"); - return res.status(404).send({error: "Sale not found"}); + return res.status(404).json({error: "Sale not found"}); } Lots = await lotDb.getBySaleId(Sale._id.toString(),Sale.platform); @@ -91,7 +91,7 @@ exports.NextItem = asyncHandler(async (req, res, next) => { Sale = await saleDb.getByIDPlatform(req.body.idSalePlatform, req.body.platform); if(!Sale){ console.error("Sale not found"); - return res.status(404).send({error: "Sale not found"}); + return res.status(404).json({error: "Sale not found"}); } let Lot = await lotDb.getByIDPlatform(req.body.idPlatform, req.body.platform); @@ -127,10 +127,10 @@ exports.NextItem = asyncHandler(async (req, res, next) => { await lotDb.put(Lot._id, Lot); } - res.status(204).send({message: "Lot updated"}); + res.status(204).json({message: "Lot updated"}); }catch(err){ console.log(err); - return res.status(500).send({error: err}); + return res.status(500).json({error: err}); } }); @@ -157,13 +157,13 @@ exports.Bid = asyncHandler(async (req, res, next) => { await lotDb.put(Lot._id, Lot); }else{ console.error("Lot not found"); - return res.status(404).send({error: "Lot not found"}); + return res.status(404).json({error: "Lot not found"}); } - res.status(204).send({message: "Lot updated"}); + res.status(204).json({message: "Lot updated"}); }catch(err){ console.log(err); - return res.status(500).send({error: err}); + return res.status(500).json({error: err}); } }); @@ -189,13 +189,13 @@ exports.AuctionedItem = asyncHandler(async (req, res, next) => { }else{ console.error("Lot not found"); - return res.status(404).send({error: "Lot not found"}); + return res.status(404).json({error: "Lot not found"}); } - res.status(204).send({message: "Lot updated"}); + res.status(204).json({message: "Lot updated"}); }catch(err){ console.log(err); - return res.status(500).send({error: err}); + return res.status(500).json({error: err}); } }); @@ -205,10 +205,10 @@ exports.get = asyncHandler(async (req, res, next) => { try{ const id = req.params.id; let result = await lotDb.get(id); - res.status(200).send(result); + res.status(200).json(result); }catch(err){ console.log(err); - return res.status(500).send({error: err}); + return res.status(500).json({error: err}); } }); @@ -219,15 +219,15 @@ exports.post = asyncHandler(async (req, res, next) => { // check if double let Lot = await lotDb.getByIDPlatform(req.body.idPlatform, req.body.platform); if(Sale){ - return res.status(500).send({ error: "Lot already exists"}); + return res.status(500).json({ error: "Lot already exists"}); } let createLot = await lotDb.post(req.body); - res.status(204).send({message: "Lot created"}); + res.status(204).json({message: "Lot created"}); }catch(err){ console.log(err); - return res.status(500).send({error: err}); + return res.status(500).json({error: err}); } }); @@ -241,10 +241,10 @@ exports.put = asyncHandler(async (req, res, next) => { console.log(updatedDocument); let result = await lotDb.put(id, updatedDocument); console.log(result); - res.status(200).send(result); + res.status(200).json(result); }catch(err){ console.log(err); - return res.status(500).send({error: err}); + return res.status(500).json({error: err}); } }); @@ -256,10 +256,10 @@ exports.delete = asyncHandler(async (req, res, next) => { // Remove the lot await lotDb.remove(id); - res.status(200).send({"message": "Lots deleted"}); + res.status(200).json({"message": "Lots deleted"}); }catch(err){ console.log(err); - return res.status(500).send({error: err}); + return res.status(500).json({error: err}); } }); \ No newline at end of file diff --git a/backend/controllers/sale.js b/backend/controllers/sale.js index bc1d592..fa53ed8 100644 --- a/backend/controllers/sale.js +++ b/backend/controllers/sale.js @@ -18,7 +18,7 @@ exports.getSaleInfos = asyncHandler(async (req, res, next) => { }) .catch(error => { console.error(error); - return res.status(500).send({error: error}); + return res.status(500).json({error: error}); }); }); @@ -33,11 +33,11 @@ exports.prepareSale = asyncHandler(async (req, res, next) => { }) .catch(error => { console.error(error); - return res.status(500).send({error: error}); + return res.status(500).json({error: error}); }); }catch(err){ console.error(err); - return res.status(500).send({error: err}); + return res.status(500).json({error: err}); } }); @@ -48,15 +48,15 @@ exports.followSale = asyncHandler(async (req, res, next) => { agent.followSale(id) .then(data => { - res.status(200).send(data); + res.status(200).json(data); }) .catch(error => { console.error(error); - return res.status(500).send({error: error}); + return res.status(500).json({error: error}); }); }catch(err){ console.error(err); - return res.status(500).send({error: err}); + return res.status(500).json({error: err}); } }); @@ -67,10 +67,10 @@ exports.get = asyncHandler(async (req, res, next) => { try{ const id = req.params.id; let result = await saleDb.get(id); - res.status(200).send(result); + res.status(200).json(result); }catch(err){ console.log(err); - return res.status(500).send({error: err}); + return res.status(500).json({error: err}); } }); @@ -81,7 +81,7 @@ exports.post = asyncHandler(async (req, res, next) => { // check if double let Sale = await saleDb.getByIDPlatform(req.body.idPlatform, req.body.platform); if(Sale){ - return res.status(500).send({error: "Sale already exists"}); + return res.status(500).json({error: "Sale already exists"}); } let createData = await saleDb.post(req.body); @@ -105,10 +105,10 @@ exports.post = asyncHandler(async (req, res, next) => { await jobFollow.save(); }else{ console.log("Sale is in the past, no Follow Job");} - res.status(204).send({"message": "Sale created"}); + res.status(204).json({"message": "Sale created"}); }catch(err){ console.log(err); - return res.status(500).send({error: err}); + return res.status(500).json({error: err}); } }); @@ -122,10 +122,10 @@ exports.put = asyncHandler(async (req, res, next) => { console.log(updatedDocument); let result = await saleDb.put(id, updatedDocument); //console.log(result); - res.status(200).send(result); + res.status(200).json(result); }catch(err){ console.log(err); - return res.status(500).send({error: err}); + return res.status(500).json({error: err}); } }); @@ -147,10 +147,10 @@ exports.delete = asyncHandler(async (req, res, next) => { await job.remove(); } - res.status(200).send({"message": "Sale and Lots deleted"}); + res.status(200).json({"message": "Sale and Lots deleted"}); }catch(err){ console.log(err); - return res.status(500).send({error: err}); + return res.status(500).json({error: err}); } }); @@ -160,10 +160,10 @@ exports.delete = asyncHandler(async (req, res, next) => { exports.getAll = asyncHandler(async (req, res, next) => { try{ let result = await saleDb.getAll(); - res.status(200).send(result); + res.status(200).json(result); }catch(err){ console.log(err); - return res.status(500).send({error: err}); + return res.status(500).json({error: err}); } }); @@ -174,10 +174,10 @@ exports.getByUrl = asyncHandler(async (req, res, next) => { let result = await saleDb.getByUrl(url); //console.log(result); - res.status(200).send(result); + res.status(200).json(result); }catch(err){ console.log(err); - return res.status(500).send({error: err}); + return res.status(500).json({error: err}); } }); @@ -185,10 +185,10 @@ exports.postProcessing = asyncHandler(async (req, res, next) => { try{ const id = req.params.id; await saleDb.processStats(id); - res.status(200).send({"message": "Post Processing done"}); + res.status(200).json({"message": "Post Processing done"}); }catch(err){ console.log(err); - return res.status(500).send({error: err}); + return res.status(500).json({error: err}); } }); @@ -200,7 +200,7 @@ exports.SaleStatXsl = asyncHandler(async (req, res, next) => { Sale = await saleDb.get(id); if(!Sale){ console.error("Sale not found"); - return res.status(404).send({error: "Sale not found"}); + return res.status(404).json({error: "Sale not found"}); } Lots = await lotDb.getBySaleId(Sale._id.toString(),Sale.platform); diff --git a/backend/controllers/user.js b/backend/controllers/user.js index a3cbd12..1decba6 100644 --- a/backend/controllers/user.js +++ b/backend/controllers/user.js @@ -28,13 +28,13 @@ exports.get = asyncHandler(async (req, res, next) => { const id = req.params.id; let result = await userDb.get(id); if (req.user.isAdmin){ - res.status(200).send(ClearUserDataForAdmin(result)); + res.status(200).json(ClearUserDataForAdmin(result)); }else{ - res.status(200).send(ClearUserData(result)); + res.status(200).json(ClearUserData(result)); } }catch(err){ console.log(err); - return res.status(500).send({error: err}); + return res.status(500).json({error: err}); } }); @@ -46,24 +46,24 @@ exports.post = asyncHandler(async (req, res, next) => { // check if double let User = await userDb.getByEmail(req.body.email); if(User){ - return res.status(500).send({error: "User already exists"}); + return res.status(500).json({error: "User already exists"}); } // check password if(!req.body.password){ - return res.status(500).send({error: "Password not set"}); + return res.status(500).json({error: "Password not set"}); } if(req.body.password != req.body.confirmPassword){ - return res.status(500).send({error: "Passwords do not match"}); + return res.status(500).json({error: "Passwords do not match"}); } if(req.body.password.length < 8){ - return res.status(500).send({error: "Password too short"}); + return res.status(500).json({error: "Password too short"}); } if(req.body.isAdmin){ if(req.user){ if(!req.user.isAdmin){ - return res.status(500).send({error: "You are not allowed to create an admin user"}); + return res.status(500).json({error: "You are not allowed to create an admin user"}); } }else{ req.body.isAdmin = false @@ -73,7 +73,7 @@ exports.post = asyncHandler(async (req, res, next) => { if(req.body.isAgent){ if(req.user){ if(!req.user.isAgent){ - return res.status(500).send({error: "You are not allowed to create an agent user"}); + return res.status(500).json({error: "You are not allowed to create an agent user"}); } }else{ req.body.isAgent = false @@ -92,10 +92,10 @@ exports.post = asyncHandler(async (req, res, next) => { let createData = await userDb.post(user); - res.status(204).send({message: "User created"}); + res.status(204).json({message: "User created"}); }catch(err){ console.log(err); - return res.status(500).send({error: err}); + return res.status(500).json({error: err}); } }); @@ -108,7 +108,7 @@ exports.put = asyncHandler(async (req, res, next) => { const User = await userDb.get(id); if(!User){ - return res.status(500).send({error:"User not found"}); + return res.status(500).json({error:"User not found"}); } // check password @@ -116,10 +116,10 @@ exports.put = asyncHandler(async (req, res, next) => { let salt = ""; if(req.body.password){ if(req.body.password != req.body.confirmPassword){ - return res.status(500).send({error:"Passwords do not match"}); + return res.status(500).json({error:"Passwords do not match"}); } if(req.body.password.length < 8){ - return res.status(500).send({error:"Password too short"}); + return res.status(500).json({error:"Password too short"}); } salt = crypto.randomBytes(16).toString('hex'); hashed_password = crypto.pbkdf2Sync(req.body.password, salt, 310000, 32, 'sha256').toString('hex'); @@ -130,12 +130,12 @@ exports.put = asyncHandler(async (req, res, next) => { if(req.body.isAdmin){ if(!req.user.isAdmin){ - return res.status(500).send({error:"You are not allowed to create an admin user"}); + return res.status(500).json({error:"You are not allowed to create an admin user"}); } } if(req.body.isAgent){ if(!req.user.isAdmin){ - return res.status(500).send({error:"You are not allowed to create an agent user"}); + return res.status(500).json({error:"You are not allowed to create an agent user"}); } } @@ -150,10 +150,10 @@ exports.put = asyncHandler(async (req, res, next) => { let result = await userDb.put(id, user); console.log(result); - res.status(200).send(result); + res.status(200).json(result); }catch(err){ console.log(err); - return res.status(500).send({error: err}); + return res.status(500).json({error: err}); } }); @@ -166,10 +166,10 @@ exports.delete = asyncHandler(async (req, res, next) => { // Remove the sale await userDb.remove(id); - res.status(200).send({"message": "User deleted"}); + res.status(200).json({"message": "User deleted"}); }catch(err){ console.log(err); - return res.status(500).send({error: err}); + return res.status(500).json({error: err}); } }); @@ -178,10 +178,10 @@ exports.delete = asyncHandler(async (req, res, next) => { exports.current = asyncHandler(async (req, res, next) => { try{ const user = ClearUserData(req.user); - res.status(200).send(user); + res.status(200).json(user); }catch(err){ console.log(err); - return res.status(500).send({error: err}); + return res.status(500).json({error: err}); } }); @@ -189,10 +189,10 @@ exports.current = asyncHandler(async (req, res, next) => { exports.agentConnected = asyncHandler(async (req, res, next) => { try{ - res.status(200).send({message: "Agent connected"}); + res.status(200).json({message: "Agent connected"}); }catch(err){ console.log(err); - return res.status(500).send({error: err}); + return res.status(500).json({error: err}); } }); @@ -201,10 +201,10 @@ exports.getAllUsers = asyncHandler(async (req, res, next) => { const userDb = await UserDb.init(); let result = await userDb.getAll(); result = result.map(user => ClearUserDataForAdmin(user)); - res.status(200).send(result); + res.status(200).json(result); }catch(err){ console.log(err); - return res.status(500).send({error: err}); + return res.status(500).json({error: err}); } }); \ No newline at end of file diff --git a/backend/services/agent.js b/backend/services/agent.js index c5f069b..f6b6905 100644 --- a/backend/services/agent.js +++ b/backend/services/agent.js @@ -15,6 +15,7 @@ const Agent = class } async request(url, method){ + return new Promise((resolve, reject) => { fetch(url,{ method: method, diff --git a/client/src/app/features/sales/sales-page/sale-detail-page/lot-detail-dialog/lot-detail-dialog.component.css b/client/src/app/features/sales/sales-page/sale-detail-page/lot-detail-dialog/lot-detail-dialog.component.css index a203e17..e63b685 100644 --- a/client/src/app/features/sales/sales-page/sale-detail-page/lot-detail-dialog/lot-detail-dialog.component.css +++ b/client/src/app/features/sales/sales-page/sale-detail-page/lot-detail-dialog/lot-detail-dialog.component.css @@ -1,4 +1,19 @@ -.example-card { - +.example-card { margin-bottom: 8px; - } \ No newline at end of file + } + .description-item { + height: auto !important; + min-height: 48px !important; + } + + .description-container { + max-height: 150px; + overflow-y: auto; + /* padding: 8px 0; */ + } + + .description-text { + white-space: pre-wrap !important; + word-wrap: break-word; + line-height: 1.5; + } diff --git a/client/src/app/features/sales/sales-page/sale-detail-page/lot-detail-dialog/lot-detail-dialog.component.html b/client/src/app/features/sales/sales-page/sale-detail-page/lot-detail-dialog/lot-detail-dialog.component.html index a77f63c..72edd3c 100644 --- a/client/src/app/features/sales/sales-page/sale-detail-page/lot-detail-dialog/lot-detail-dialog.component.html +++ b/client/src/app/features/sales/sales-page/sale-detail-page/lot-detail-dialog/lot-detail-dialog.component.html @@ -1,29 +1,31 @@ - Lot - Lot informations + Lot
- - - # - {{Lot.lotNumber}} - - - Title - {{Lot.title}} - - - Description - - - - Estimate - Low: {{Lot.EstimateLow}} | High: {{Lot.EstimateHigh}} - - +
+

# {{Lot.lotNumber}}

+
+
+

Title {{Lot.title}}

+
+
+
+
+

Estimate [{{Lot.EstimateLow}} - {{Lot.EstimateHigh}}]

+
+
+
+ + + Description +
+ +
+
+
diff --git a/client/src/app/features/sales/sales-page/sale-detail-page/sale-detail-page.component.ts b/client/src/app/features/sales/sales-page/sale-detail-page/sale-detail-page.component.ts index 6f11c6d..aa1cee5 100644 --- a/client/src/app/features/sales/sales-page/sale-detail-page/sale-detail-page.component.ts +++ b/client/src/app/features/sales/sales-page/sale-detail-page/sale-detail-page.component.ts @@ -78,24 +78,23 @@ export class SaleDetailPageComponent implements OnInit, AfterViewInit { this.route.paramMap.subscribe(params => { this.id = params.get('id'); - this.getSale(); - this.getLotList(); + this.refresh(); }); } ngAfterViewInit(): void { } + refresh(): void { + this.getSale(); + this.getLotList(); + } getSale(){ this.apiSaleService.getSale(this.id).subscribe((sale: Sale) => { this.Sale = sale; }); - } - - refresh(): void { - this.getLotList(); - } + } getLotList(){ this.apiLotService.getLotsBySale(this.id).subscribe((lotList: Lot[]) => { diff --git a/config.js b/config.js index 99e1d0c..c7084a3 100644 --- a/config.js +++ b/config.js @@ -21,7 +21,7 @@ const config = { audience: "yoursite", }, agent :{ - ApiAgentURL: 'jucundus-agent1.saucisse.ninja/api', + ApiAgentURL: 'https://jucundus-agent1.saucisse.ninja/api', token: '861v48gr4YTHJTUre0reg40g8e6r8r64eggv1r4e6g4r81PKREVJ8g6reg46r8eg416reST6ger84g14er86e', } };