diff --git a/.idea/compiler.xml b/.idea/compiler.xml index 204b727a..5a5f5e62 100644 --- a/.idea/compiler.xml +++ b/.idea/compiler.xml @@ -7,7 +7,10 @@ + + + diff --git a/.idea/encodings.xml b/.idea/encodings.xml index 71e7e915..86aeea20 100644 --- a/.idea/encodings.xml +++ b/.idea/encodings.xml @@ -1,6 +1,9 @@ + + + \ No newline at end of file diff --git a/.idea/navEditor.xml b/.idea/navEditor.xml new file mode 100644 index 00000000..62d9592d --- /dev/null +++ b/.idea/navEditor.xml @@ -0,0 +1,43 @@ + + + + + + \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml index c56f99b5..b165017c 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -11,20 +11,18 @@ - - - - - - - + + + + + - + @@ -67,7 +65,10 @@ "RunOnceActivity.ShowReadmeOnStart": "true", "RunOnceActivity.cidr.known.project.marker": "true", "cidr.known.project.marker": "true", - "last_opened_file_path": "D:/fac/DSI32/Projet d'integration/Digital Market/DigitalMarket" + "last_opened_file_path": "D:/fac/DSI32/Projet d'integration/Digital Market/DigitalMarket", + "project.structure.last.edited": "Modules", + "project.structure.proportion": "0.0", + "project.structure.side.proportion": "0.0" } } diff --git a/AngularFront/package-lock.json b/AngularFront/package-lock.json index da92efa8..58210b13 100644 --- a/AngularFront/package-lock.json +++ b/AngularFront/package-lock.json @@ -35,6 +35,7 @@ "ngx-confetti": "^1.0.3", "p5": "^1.8.0", "rxjs": "~7.8.0", + "socket.io-client": "^4.7.2", "tslib": "^2.3.0", "zone.js": "~0.13.0" }, @@ -4166,8 +4167,7 @@ "node_modules/@socket.io/component-emitter": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/@socket.io/component-emitter/-/component-emitter-3.1.0.tgz", - "integrity": "sha512-+9jVqKhRSpsc591z5vX+X5Yyw+he/HCB4iQ/RYxw35CEPaY1gnsNE43nf9n9AaYjAQrTiI/mOwKUKdUs9vf7Xg==", - "dev": true + "integrity": "sha512-+9jVqKhRSpsc591z5vX+X5Yyw+he/HCB4iQ/RYxw35CEPaY1gnsNE43nf9n9AaYjAQrTiI/mOwKUKdUs9vf7Xg==" }, "node_modules/@tootallnate/once": { "version": "1.1.2", @@ -6414,7 +6414,6 @@ "version": "4.3.4", "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", - "dev": true, "dependencies": { "ms": "2.1.2" }, @@ -6722,11 +6721,42 @@ "node": ">=10.2.0" } }, + "node_modules/engine.io-client": { + "version": "6.5.3", + "resolved": "https://registry.npmjs.org/engine.io-client/-/engine.io-client-6.5.3.tgz", + "integrity": "sha512-9Z0qLB0NIisTRt1DZ/8U2k12RJn8yls/nXMZLn+/N8hANT3TcYjKFKcwbw5zFQiN4NTde3TSY9zb79e1ij6j9Q==", + "dependencies": { + "@socket.io/component-emitter": "~3.1.0", + "debug": "~4.3.1", + "engine.io-parser": "~5.2.1", + "ws": "~8.11.0", + "xmlhttprequest-ssl": "~2.0.0" + } + }, + "node_modules/engine.io-client/node_modules/ws": { + "version": "8.11.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.11.0.tgz", + "integrity": "sha512-HPG3wQd9sNQoT9xHyNCXoDUa+Xw/VevmY9FoHyQ+g+rrMn4j6FB4np7Z0OhdTgjx6MgQLK7jwSy1YecU1+4Asg==", + "engines": { + "node": ">=10.0.0" + }, + "peerDependencies": { + "bufferutil": "^4.0.1", + "utf-8-validate": "^5.0.2" + }, + "peerDependenciesMeta": { + "bufferutil": { + "optional": true + }, + "utf-8-validate": { + "optional": true + } + } + }, "node_modules/engine.io-parser": { "version": "5.2.1", "resolved": "https://registry.npmjs.org/engine.io-parser/-/engine.io-parser-5.2.1.tgz", "integrity": "sha512-9JktcM3u18nU9N2Lz3bWeBgxVgOKpw7yhRaoxQA3FUDZzzw+9WlA6p4G4u0RixNkg14fH7EfEc/RhpurtiROTQ==", - "dev": true, "engines": { "node": ">=10.0.0" } @@ -9829,8 +9859,7 @@ "node_modules/ms": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", - "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", - "dev": true + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" }, "node_modules/multicast-dns": { "version": "7.2.5", @@ -12086,11 +12115,24 @@ } } }, + "node_modules/socket.io-client": { + "version": "4.7.2", + "resolved": "https://registry.npmjs.org/socket.io-client/-/socket.io-client-4.7.2.tgz", + "integrity": "sha512-vtA0uD4ibrYD793SOIAwlo8cj6haOeMHrGvwPxJsxH7CeIksqJ+3Zc06RvWTIFgiSqx4A3sOnTXpfAEE2Zyz6w==", + "dependencies": { + "@socket.io/component-emitter": "~3.1.0", + "debug": "~4.3.2", + "engine.io-client": "~6.5.2", + "socket.io-parser": "~4.2.4" + }, + "engines": { + "node": ">=10.0.0" + } + }, "node_modules/socket.io-parser": { "version": "4.2.4", "resolved": "https://registry.npmjs.org/socket.io-parser/-/socket.io-parser-4.2.4.tgz", "integrity": "sha512-/GbIKmo8ioc+NIWIhwdecY0ge+qVBSMdgxGygevmdHj24bsfgtCmcUUcQ5ZzcylGFHsN3k4HB4Cgkl96KVnuew==", - "dev": true, "dependencies": { "@socket.io/component-emitter": "~3.1.0", "debug": "~4.3.1" @@ -13648,6 +13690,14 @@ "integrity": "sha512-JZnDKK8B0RCDw84FNdDAIpZK+JuJw+s7Lz8nksI7SIuU3UXJJslUthsi+uWBUYOwPFwW7W7PRLRfUKpxjtjFCw==", "dev": true }, + "node_modules/xmlhttprequest-ssl": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/xmlhttprequest-ssl/-/xmlhttprequest-ssl-2.0.0.tgz", + "integrity": "sha512-QKxVRxiRACQcVuQEYFsI1hhkrMlrXHPegbbd1yn9UHOmRxY+si12nQYzri3vbzt8VdTTRviqcKxcyllFas5z2A==", + "engines": { + "node": ">=0.4.0" + } + }, "node_modules/y18n": { "version": "5.0.8", "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", @@ -16694,8 +16744,7 @@ "@socket.io/component-emitter": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/@socket.io/component-emitter/-/component-emitter-3.1.0.tgz", - "integrity": "sha512-+9jVqKhRSpsc591z5vX+X5Yyw+he/HCB4iQ/RYxw35CEPaY1gnsNE43nf9n9AaYjAQrTiI/mOwKUKdUs9vf7Xg==", - "dev": true + "integrity": "sha512-+9jVqKhRSpsc591z5vX+X5Yyw+he/HCB4iQ/RYxw35CEPaY1gnsNE43nf9n9AaYjAQrTiI/mOwKUKdUs9vf7Xg==" }, "@tootallnate/once": { "version": "1.1.2", @@ -18453,7 +18502,6 @@ "version": "4.3.4", "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", - "dev": true, "requires": { "ms": "2.1.2" } @@ -18705,11 +18753,30 @@ } } }, + "engine.io-client": { + "version": "6.5.3", + "resolved": "https://registry.npmjs.org/engine.io-client/-/engine.io-client-6.5.3.tgz", + "integrity": "sha512-9Z0qLB0NIisTRt1DZ/8U2k12RJn8yls/nXMZLn+/N8hANT3TcYjKFKcwbw5zFQiN4NTde3TSY9zb79e1ij6j9Q==", + "requires": { + "@socket.io/component-emitter": "~3.1.0", + "debug": "~4.3.1", + "engine.io-parser": "~5.2.1", + "ws": "~8.11.0", + "xmlhttprequest-ssl": "~2.0.0" + }, + "dependencies": { + "ws": { + "version": "8.11.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.11.0.tgz", + "integrity": "sha512-HPG3wQd9sNQoT9xHyNCXoDUa+Xw/VevmY9FoHyQ+g+rrMn4j6FB4np7Z0OhdTgjx6MgQLK7jwSy1YecU1+4Asg==", + "requires": {} + } + } + }, "engine.io-parser": { "version": "5.2.1", "resolved": "https://registry.npmjs.org/engine.io-parser/-/engine.io-parser-5.2.1.tgz", - "integrity": "sha512-9JktcM3u18nU9N2Lz3bWeBgxVgOKpw7yhRaoxQA3FUDZzzw+9WlA6p4G4u0RixNkg14fH7EfEc/RhpurtiROTQ==", - "dev": true + "integrity": "sha512-9JktcM3u18nU9N2Lz3bWeBgxVgOKpw7yhRaoxQA3FUDZzzw+9WlA6p4G4u0RixNkg14fH7EfEc/RhpurtiROTQ==" }, "enhanced-resolve": { "version": "5.15.0", @@ -21062,8 +21129,7 @@ "ms": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", - "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", - "dev": true + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" }, "multicast-dns": { "version": "7.2.5", @@ -22717,11 +22783,21 @@ } } }, + "socket.io-client": { + "version": "4.7.2", + "resolved": "https://registry.npmjs.org/socket.io-client/-/socket.io-client-4.7.2.tgz", + "integrity": "sha512-vtA0uD4ibrYD793SOIAwlo8cj6haOeMHrGvwPxJsxH7CeIksqJ+3Zc06RvWTIFgiSqx4A3sOnTXpfAEE2Zyz6w==", + "requires": { + "@socket.io/component-emitter": "~3.1.0", + "debug": "~4.3.2", + "engine.io-client": "~6.5.2", + "socket.io-parser": "~4.2.4" + } + }, "socket.io-parser": { "version": "4.2.4", "resolved": "https://registry.npmjs.org/socket.io-parser/-/socket.io-parser-4.2.4.tgz", "integrity": "sha512-/GbIKmo8ioc+NIWIhwdecY0ge+qVBSMdgxGygevmdHj24bsfgtCmcUUcQ5ZzcylGFHsN3k4HB4Cgkl96KVnuew==", - "dev": true, "requires": { "@socket.io/component-emitter": "~3.1.0", "debug": "~4.3.1" @@ -23823,6 +23899,11 @@ "integrity": "sha512-JZnDKK8B0RCDw84FNdDAIpZK+JuJw+s7Lz8nksI7SIuU3UXJJslUthsi+uWBUYOwPFwW7W7PRLRfUKpxjtjFCw==", "dev": true }, + "xmlhttprequest-ssl": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/xmlhttprequest-ssl/-/xmlhttprequest-ssl-2.0.0.tgz", + "integrity": "sha512-QKxVRxiRACQcVuQEYFsI1hhkrMlrXHPegbbd1yn9UHOmRxY+si12nQYzri3vbzt8VdTTRviqcKxcyllFas5z2A==" + }, "y18n": { "version": "5.0.8", "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", diff --git a/AngularFront/package.json b/AngularFront/package.json index eb7b2f5e..4d532fce 100644 --- a/AngularFront/package.json +++ b/AngularFront/package.json @@ -37,6 +37,7 @@ "ngx-confetti": "^1.0.3", "p5": "^1.8.0", "rxjs": "~7.8.0", + "socket.io-client": "^4.7.2", "tslib": "^2.3.0", "zone.js": "~0.13.0" }, diff --git a/AngularFront/src/app/AccueilClient/favorite-list-client/favorite-list-client.component.html b/AngularFront/src/app/AccueilClient/favorite-list-client/favorite-list-client.component.html index e51fe2ab..d7aa4513 100644 --- a/AngularFront/src/app/AccueilClient/favorite-list-client/favorite-list-client.component.html +++ b/AngularFront/src/app/AccueilClient/favorite-list-client/favorite-list-client.component.html @@ -6,18 +6,17 @@

My Favorite List

- - +

{{ item.productDetails?.name }}

- + {{ item.productDetails?.prix }} DT

- + {{ item.productDetails?.desc }}


-

Add to cart

+

Add to cart

diff --git a/AngularFront/src/app/AccueilClient/favorite-list-client/favorite-list-client.component.ts b/AngularFront/src/app/AccueilClient/favorite-list-client/favorite-list-client.component.ts index 5275b6fc..52cddd21 100644 --- a/AngularFront/src/app/AccueilClient/favorite-list-client/favorite-list-client.component.ts +++ b/AngularFront/src/app/AccueilClient/favorite-list-client/favorite-list-client.component.ts @@ -2,13 +2,15 @@ import { Component } from '@angular/core'; import { WishlistService } from 'src/app/Service/wishlist.service'; import { CommandeServiceService } from 'src/app/Service/commande-service.service'; import { MatSnackBar } from '@angular/material/snack-bar'; +import { Websocket } from 'src/app/Service/websocket.service'; +import { ProductsServiceLocalStorageService } from 'src/app/Service/products-service-local-storage.service'; @Component({ selector: 'app-favorite-list-client', templateUrl: './favorite-list-client.component.html', styleUrls: ['./favorite-list-client.component.scss'] }) export class FavoriteListClientComponent { - constructor(private wishlistService: WishlistService , private commandeService: CommandeServiceService,private snackBar: MatSnackBar) { } + constructor(private wishlistService: WishlistService , private commandeService: CommandeServiceService,private snackBar: MatSnackBar,public productServiceStorage:ProductsServiceLocalStorageService) { } isFavorite: boolean = false; wishlist: any[] = []; @@ -16,7 +18,7 @@ export class FavoriteListClientComponent { ngOnInit(): void { this.loadWishlist(); - this.getNotificationsByIdRecu(2); + } loadWishlist() { @@ -46,7 +48,7 @@ export class FavoriteListClientComponent { toggleFavorite(id: any): void { this.wishlistService .addToWishlist({ - idUser: 2, + idUser: 3, idProduct: id, }) .subscribe( @@ -74,26 +76,12 @@ export class FavoriteListClientComponent { } ); } - - notifications: string[] = []; - getNotificationsByIdRecu(idRecu: any) { - this.commandeService.getNotificationsByIdRecu(2).subscribe( - (res: any) => { - - this.notifications = res; - console.log(this.notifications); - }, - (error) => { - console.error(error); - } - ); - } - - showNotifications = false; - - - toggleNotifications() { - this.showNotifications = !this.showNotifications; + products:any + addProduct(product: any) { + this.productServiceStorage.addProduct(product); + this.snackBar.open("Product Added",'',{ + duration:2000, + }) } -} +} \ No newline at end of file diff --git a/AngularFront/src/app/AdminCompoenent/gerer-commande/gerer-commande.component.html b/AngularFront/src/app/AdminCompoenent/gerer-commande/gerer-commande.component.html index c63059bd..29c13f96 100644 --- a/AngularFront/src/app/AdminCompoenent/gerer-commande/gerer-commande.component.html +++ b/AngularFront/src/app/AdminCompoenent/gerer-commande/gerer-commande.component.html @@ -17,21 +17,6 @@

hello

- @@ -58,11 +43,11 @@

hello

{{commande.LigneCommandes.length}}
    -
  • +
  • Accept
  • -
  • +
  • Refuse
  • @@ -70,7 +55,7 @@

    hello

    Info -
  • +
  • Delete
  • @@ -131,7 +116,7 @@

    Num Commande : {{InfoCommande.in {{item.id}} {{item.name}} - + {{item.qte}} {{item.price}} TND diff --git a/AngularFront/src/app/AdminCompoenent/gerer-commande/gerer-commande.component.ts b/AngularFront/src/app/AdminCompoenent/gerer-commande/gerer-commande.component.ts index 3f5f6da9..3d3f4f6c 100644 --- a/AngularFront/src/app/AdminCompoenent/gerer-commande/gerer-commande.component.ts +++ b/AngularFront/src/app/AdminCompoenent/gerer-commande/gerer-commande.component.ts @@ -1,8 +1,9 @@ import { Component } from '@angular/core'; +import { MatDialog } from '@angular/material/dialog'; import { MatSnackBar } from '@angular/material/snack-bar'; import { Product } from 'src/app/Model/Product'; import { CommandeServiceService } from 'src/app/Service/commande-service.service'; - +import { ConfirmDialogComponentComponent } from 'src/app/superAdminComponents/Employers/confirm-dialog-component/confirm-dialog-component.component'; @Component({ selector: 'app-gerer-commande', templateUrl: './gerer-commande.component.html', @@ -10,7 +11,7 @@ import { CommandeServiceService } from 'src/app/Service/commande-service.service }) export class GererCommandeComponent { - constructor(private commandeService: CommandeServiceService,private MatSnackBar:MatSnackBar) { + constructor(private commandeService: CommandeServiceService,private MatSnackBar:MatSnackBar,private dialog: MatDialog) { this.pagination={ currentPage:1, total:0, @@ -88,16 +89,28 @@ selectedCommand!:any }[] } - AccepteCommade(num:number){ - this.commandeService.AcceptCommand(num,{ - "userid":2 - }).subscribe((res:any)=>{ - this.getCommande(); - this.MatSnackBar.open("Accept Commande",'close',{ - duration:3000 - }) - }) - } + AccepteCommade(selectedCommand: any) { + const clientId = selectedCommand.Client_id; + this.commandeService.AcceptCommand(selectedCommand.NumCommande, { + "userid": clientId + }).subscribe((res: any) => { + this.getCommande(); + this.MatSnackBar.open("Commande Accepted", 'close', { + duration: 3000 + }); + }); +} +RefusedCommand(selectedCommand:any){ + const clientId = selectedCommand.Client_id; + this.commandeService.RefusedCommand(selectedCommand.NumCommande, { + "userid": clientId + }).subscribe((res:any)=>{ + this.getCommande(); + this.MatSnackBar.open("Commande Refused",'close',{ + duration:3000 + }); + }); +} commandeType:string="Waiting" choseCommande(type:string){ @@ -105,16 +118,7 @@ selectedCommand!:any this.getCommande(); } - RefusedCommand(num:number){ - this.commandeService.RefusedCommand(num,{ - "userid":2 - }).subscribe((res:any)=>{ - this.getCommande(); - this.MatSnackBar.open("Commande Refused",'close',{ - duration:3000 - }) - }) -} + getCommande() { this.commandeService.getCommandes( @@ -125,8 +129,6 @@ getCommande() { ).subscribe( (res: any) => { const previousCommandCount = this.commandes.length; - - // Update the commandes array with the new data this.commandes = res.docs; this.pagination.currentPage = res.page; this.pagination.total = res.pages; @@ -150,7 +152,34 @@ getCommande() { this.InfoCommande.prixTotal=0; } - + deleteCommande(commandeId : any) + { + const dialogRef = this.dialog.open(ConfirmDialogComponentComponent, { + width : '300px', + data: { message: 'Are you sure you want to delete this commande ?' }, + panelClass: 'custom-dialog-panel', + }); + + dialogRef.afterClosed().subscribe(userConfirmed => { + if (userConfirmed) { + this.commandeService.deleteCommandeById(commandeId).subscribe( + (res: any) => { + this.MatSnackBar.open('Commande deleted', 'close', { + duration: 3000 + }); + this.getCommande(); + }, + (error) => { + console.error('Error deleting commande:', error); + } + ); + } else { + console.log('Deletion canceled by admin'); + } + }) + } + + showCommandeInfo(command: any) { this.isPopupOpen = true; this.clearInfo(); @@ -192,7 +221,6 @@ toggleDropdown(): void { } resetNotifications() { - // Reset notifications.length to 0 when the dropdown is opened this.notifications.length = 0; } diff --git a/AngularFront/src/app/Service/websocket.service.ts b/AngularFront/src/app/Service/websocket.service.ts new file mode 100644 index 00000000..6504cd83 --- /dev/null +++ b/AngularFront/src/app/Service/websocket.service.ts @@ -0,0 +1,28 @@ +import { Injectable } from '@angular/core'; +import { io, Socket } from 'socket.io-client'; +import { Observable } from 'rxjs'; +import { port } from 'src/env'; + +@Injectable({ + providedIn: 'root' +}) +export class Websocket { + + socket: Socket; + + constructor() { + this.socket = io(`${port}/GESTIONCOMMANDE-SERVICE/Commande/`); + } + + listen(eventname: string): Observable { + return new Observable((subscriber: any) => { + this.socket.on(eventname, (data: any) => { + subscriber.next(data); + }); + }); + } + + emit(eventname: string, data: any) { + this.socket.emit(eventname, data); + } +} diff --git a/AngularFront/src/app/home/navbar/navbar.component.html b/AngularFront/src/app/home/navbar/navbar.component.html index 4d8cbb0e..c8b4a94f 100644 --- a/AngularFront/src/app/home/navbar/navbar.component.html +++ b/AngularFront/src/app/home/navbar/navbar.component.html @@ -1,12 +1,12 @@
    -
    +
    -

    free palestine

    +

    free palestine

    @@ -16,57 +16,117 @@

    free palestine

    -
    diff --git a/AngularFront/src/app/home/navbar/navbar.component.scss b/AngularFront/src/app/home/navbar/navbar.component.scss index 7a16fca9..7065a086 100644 --- a/AngularFront/src/app/home/navbar/navbar.component.scss +++ b/AngularFront/src/app/home/navbar/navbar.component.scss @@ -223,9 +223,16 @@ cursor: pointer; position: absolute; } +.notification-list { + width: 250px; +} +.notification-item { + padding: 8px; +} - - +#notif { + padding-top: 5px; +} diff --git a/AngularFront/src/app/home/navbar/navbar.component.ts b/AngularFront/src/app/home/navbar/navbar.component.ts index 55d66188..81034c3e 100644 --- a/AngularFront/src/app/home/navbar/navbar.component.ts +++ b/AngularFront/src/app/home/navbar/navbar.component.ts @@ -3,6 +3,8 @@ import { ActivatedRoute, Router } from '@angular/router'; import { AuthServiceService } from 'src/app/Service/auth-service.service'; import { CategoryServiceService } from 'src/app/Service/category-service.service'; import { ProductsServiceLocalStorageService } from 'src/app/Service/products-service-local-storage.service'; +import { CommandeServiceService } from 'src/app/Service/commande-service.service'; +import { Websocket } from 'src/app/Service/websocket.service'; @Component({ @@ -17,7 +19,7 @@ export class NavbarComponent implements OnInit { nbrArticle:number=0 - constructor(public AuthServiceService:AuthServiceService, public categoriesService : CategoryServiceService){} + constructor(public AuthServiceService:AuthServiceService, public categoriesService : CategoryServiceService ,private commandeService: CommandeServiceService,private webSocketService: Websocket){} @@ -32,6 +34,7 @@ export class NavbarComponent implements OnInit { ngOnInit():void { + this.categoriesService.getAllCategories().subscribe( (res:any)=>{ this.categories=res; @@ -45,10 +48,57 @@ export class NavbarComponent implements OnInit { for(let i = 0; i < this.products?.length; i++){ this.nbrArticle = (this.products.length) } + this.webSocketService.listen('chat').subscribe((data) => this.updateMessage(data)); + this.getNotificationsByIdRecu(3); + } + + +//-------notification code-----------// + notifications: any[] = []; + notificationListOpened : boolean = false; + openNotificationMenu(event: MouseEvent): void { + event.stopPropagation(); + this.notificationListOpened = !this.notificationListOpened; + this.getNotificationsByIdRecu(3); } + getNotificationsByIdRecu(idRecu: any) { + this.commandeService.getNotificationsByIdRecu(idRecu).subscribe( + (res: any) => { + this.notifications = res; + console.log(this.notifications); + }, + (error) => { + console.error(error); + } + ); + } + + showNotifications = false; + + + toggleNotifications() { + this.showNotifications = !this.showNotifications; + } + + + messageTyping(): void { + this.webSocketService.emit('typing', "test"); + } + + sendMessage(): void { + this.webSocketService.emit('chat', { + message:"msg", + handle: "this.userName" + }); + } + + updateMessage(data:any) { + this.getNotificationsByIdRecu(3) + console.log(this.notifications); + } diff --git a/FeedBack/src/controller/NotificationController.ts b/FeedBack/src/controller/NotificationController.ts index b37c368d..d7655340 100644 --- a/FeedBack/src/controller/NotificationController.ts +++ b/FeedBack/src/controller/NotificationController.ts @@ -21,4 +21,5 @@ export const getNotificationsByIdRecu = async (req: Request, res: Response) => { console.error(error); res.status(500).json({ error: 'Internal Server Error' }); } -}; \ No newline at end of file +}; + diff --git a/GestionCommande/package-lock.json b/GestionCommande/package-lock.json index 30563e8b..055685b7 100644 --- a/GestionCommande/package-lock.json +++ b/GestionCommande/package-lock.json @@ -15,7 +15,8 @@ "eureka-js-client": "^4.5.0", "express": "^4.18.2", "mongoose": "^7.5.4", - "mongoose-paginate": "^5.0.3" + "mongoose-paginate": "^5.0.3", + "socket.io": "^4.7.2" }, "devDependencies": { "@types/eureka-js-client": "^4.5.7", @@ -1224,6 +1225,11 @@ "node": ">=14.0.0" } }, + "node_modules/@socket.io/component-emitter": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/@socket.io/component-emitter/-/component-emitter-3.1.0.tgz", + "integrity": "sha512-+9jVqKhRSpsc591z5vX+X5Yyw+he/HCB4iQ/RYxw35CEPaY1gnsNE43nf9n9AaYjAQrTiI/mOwKUKdUs9vf7Xg==" + }, "node_modules/@types/body-parser": { "version": "1.19.3", "resolved": "https://registry.npmjs.org/@types/body-parser/-/body-parser-1.19.3.tgz", @@ -1243,6 +1249,19 @@ "@types/node": "*" } }, + "node_modules/@types/cookie": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/@types/cookie/-/cookie-0.4.1.tgz", + "integrity": "sha512-XW/Aa8APYr6jSVVA1y/DEIZX0/GMKLEVekNG727R8cs56ahETkRAy/3DR7+fJyh7oUgGwNQaRfXCun0+KbWY7Q==" + }, + "node_modules/@types/cors": { + "version": "2.8.17", + "resolved": "https://registry.npmjs.org/@types/cors/-/cors-2.8.17.tgz", + "integrity": "sha512-8CGDvrBj1zgo2qE+oS3pOCyYNqCPryMWY2bGfwA0dcfopWGgxs+78df0Rs3rc9THP4JkOhLsAa+15VdpAqkcUA==", + "dependencies": { + "@types/node": "*" + } + }, "node_modules/@types/eureka-js-client": { "version": "4.5.7", "resolved": "https://registry.npmjs.org/@types/eureka-js-client/-/eureka-js-client-4.5.7.tgz", @@ -1616,6 +1635,14 @@ } ] }, + "node_modules/base64id": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/base64id/-/base64id-2.0.0.tgz", + "integrity": "sha512-lGe34o6EHj9y3Kts9R4ZYs/Gr+6N7MCaMlIFA3F1R2O5/m7K06AxfSeO5530PEERE6/WyEg3lsuyw4GHlPZHog==", + "engines": { + "node": "^4.5.0 || >= 5.9" + } + }, "node_modules/bcrypt-pbkdf": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz", @@ -2014,6 +2041,63 @@ "node": ">= 0.8" } }, + "node_modules/engine.io": { + "version": "6.5.4", + "resolved": "https://registry.npmjs.org/engine.io/-/engine.io-6.5.4.tgz", + "integrity": "sha512-KdVSDKhVKyOi+r5uEabrDLZw2qXStVvCsEB/LN3mw4WFi6Gx50jTyuxYVCwAAC0U46FdnzP/ScKRBTXb/NiEOg==", + "dependencies": { + "@types/cookie": "^0.4.1", + "@types/cors": "^2.8.12", + "@types/node": ">=10.0.0", + "accepts": "~1.3.4", + "base64id": "2.0.0", + "cookie": "~0.4.1", + "cors": "~2.8.5", + "debug": "~4.3.1", + "engine.io-parser": "~5.2.1", + "ws": "~8.11.0" + }, + "engines": { + "node": ">=10.2.0" + } + }, + "node_modules/engine.io-parser": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/engine.io-parser/-/engine.io-parser-5.2.1.tgz", + "integrity": "sha512-9JktcM3u18nU9N2Lz3bWeBgxVgOKpw7yhRaoxQA3FUDZzzw+9WlA6p4G4u0RixNkg14fH7EfEc/RhpurtiROTQ==", + "engines": { + "node": ">=10.0.0" + } + }, + "node_modules/engine.io/node_modules/cookie": { + "version": "0.4.2", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.2.tgz", + "integrity": "sha512-aSWTXFzaKWkvHO1Ny/s+ePFpvKsPnjc551iI41v3ny/ow6tBG5Vd+FuqGNhh1LxOmVzOlGUriIlOaokOvhaStA==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/engine.io/node_modules/debug": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "dependencies": { + "ms": "2.1.2" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/engine.io/node_modules/ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" + }, "node_modules/escalade": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz", @@ -3259,6 +3343,85 @@ "npm": ">= 3.0.0" } }, + "node_modules/socket.io": { + "version": "4.7.2", + "resolved": "https://registry.npmjs.org/socket.io/-/socket.io-4.7.2.tgz", + "integrity": "sha512-bvKVS29/I5fl2FGLNHuXlQaUH/BlzX1IN6S+NKLNZpBsPZIDH+90eQmCs2Railn4YUiww4SzUedJ6+uzwFnKLw==", + "dependencies": { + "accepts": "~1.3.4", + "base64id": "~2.0.0", + "cors": "~2.8.5", + "debug": "~4.3.2", + "engine.io": "~6.5.2", + "socket.io-adapter": "~2.5.2", + "socket.io-parser": "~4.2.4" + }, + "engines": { + "node": ">=10.2.0" + } + }, + "node_modules/socket.io-adapter": { + "version": "2.5.2", + "resolved": "https://registry.npmjs.org/socket.io-adapter/-/socket.io-adapter-2.5.2.tgz", + "integrity": "sha512-87C3LO/NOMc+eMcpcxUBebGjkpMDkNBS9tf7KJqcDsmL936EChtVva71Dw2q4tQcuVC+hAUy4an2NO/sYXmwRA==", + "dependencies": { + "ws": "~8.11.0" + } + }, + "node_modules/socket.io-parser": { + "version": "4.2.4", + "resolved": "https://registry.npmjs.org/socket.io-parser/-/socket.io-parser-4.2.4.tgz", + "integrity": "sha512-/GbIKmo8ioc+NIWIhwdecY0ge+qVBSMdgxGygevmdHj24bsfgtCmcUUcQ5ZzcylGFHsN3k4HB4Cgkl96KVnuew==", + "dependencies": { + "@socket.io/component-emitter": "~3.1.0", + "debug": "~4.3.1" + }, + "engines": { + "node": ">=10.0.0" + } + }, + "node_modules/socket.io-parser/node_modules/debug": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "dependencies": { + "ms": "2.1.2" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/socket.io-parser/node_modules/ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" + }, + "node_modules/socket.io/node_modules/debug": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "dependencies": { + "ms": "2.1.2" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/socket.io/node_modules/ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" + }, "node_modules/socks": { "version": "2.7.1", "resolved": "https://registry.npmjs.org/socks/-/socks-2.7.1.tgz", @@ -3584,6 +3747,26 @@ "url": "https://github.com/chalk/wrap-ansi?sponsor=1" } }, + "node_modules/ws": { + "version": "8.11.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.11.0.tgz", + "integrity": "sha512-HPG3wQd9sNQoT9xHyNCXoDUa+Xw/VevmY9FoHyQ+g+rrMn4j6FB4np7Z0OhdTgjx6MgQLK7jwSy1YecU1+4Asg==", + "engines": { + "node": ">=10.0.0" + }, + "peerDependencies": { + "bufferutil": "^4.0.1", + "utf-8-validate": "^5.0.2" + }, + "peerDependenciesMeta": { + "bufferutil": { + "optional": true + }, + "utf-8-validate": { + "optional": true + } + } + }, "node_modules/y18n": { "version": "5.0.8", "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", @@ -4655,6 +4838,11 @@ "tslib": "^2.5.0" } }, + "@socket.io/component-emitter": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/@socket.io/component-emitter/-/component-emitter-3.1.0.tgz", + "integrity": "sha512-+9jVqKhRSpsc591z5vX+X5Yyw+he/HCB4iQ/RYxw35CEPaY1gnsNE43nf9n9AaYjAQrTiI/mOwKUKdUs9vf7Xg==" + }, "@types/body-parser": { "version": "1.19.3", "resolved": "https://registry.npmjs.org/@types/body-parser/-/body-parser-1.19.3.tgz", @@ -4674,6 +4862,19 @@ "@types/node": "*" } }, + "@types/cookie": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/@types/cookie/-/cookie-0.4.1.tgz", + "integrity": "sha512-XW/Aa8APYr6jSVVA1y/DEIZX0/GMKLEVekNG727R8cs56ahETkRAy/3DR7+fJyh7oUgGwNQaRfXCun0+KbWY7Q==" + }, + "@types/cors": { + "version": "2.8.17", + "resolved": "https://registry.npmjs.org/@types/cors/-/cors-2.8.17.tgz", + "integrity": "sha512-8CGDvrBj1zgo2qE+oS3pOCyYNqCPryMWY2bGfwA0dcfopWGgxs+78df0Rs3rc9THP4JkOhLsAa+15VdpAqkcUA==", + "requires": { + "@types/node": "*" + } + }, "@types/eureka-js-client": { "version": "4.5.7", "resolved": "https://registry.npmjs.org/@types/eureka-js-client/-/eureka-js-client-4.5.7.tgz", @@ -4985,6 +5186,11 @@ "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==", "dev": true }, + "base64id": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/base64id/-/base64id-2.0.0.tgz", + "integrity": "sha512-lGe34o6EHj9y3Kts9R4ZYs/Gr+6N7MCaMlIFA3F1R2O5/m7K06AxfSeO5530PEERE6/WyEg3lsuyw4GHlPZHog==" + }, "bcrypt-pbkdf": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz", @@ -5278,6 +5484,48 @@ "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", "integrity": "sha512-TPJXq8JqFaVYm2CWmPvnP2Iyo4ZSM7/QKcSmuMLDObfpH5fi7RUGmd/rTDf+rut/saiDiQEeVTNgAmJEdAOx0w==" }, + "engine.io": { + "version": "6.5.4", + "resolved": "https://registry.npmjs.org/engine.io/-/engine.io-6.5.4.tgz", + "integrity": "sha512-KdVSDKhVKyOi+r5uEabrDLZw2qXStVvCsEB/LN3mw4WFi6Gx50jTyuxYVCwAAC0U46FdnzP/ScKRBTXb/NiEOg==", + "requires": { + "@types/cookie": "^0.4.1", + "@types/cors": "^2.8.12", + "@types/node": ">=10.0.0", + "accepts": "~1.3.4", + "base64id": "2.0.0", + "cookie": "~0.4.1", + "cors": "~2.8.5", + "debug": "~4.3.1", + "engine.io-parser": "~5.2.1", + "ws": "~8.11.0" + }, + "dependencies": { + "cookie": { + "version": "0.4.2", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.2.tgz", + "integrity": "sha512-aSWTXFzaKWkvHO1Ny/s+ePFpvKsPnjc551iI41v3ny/ow6tBG5Vd+FuqGNhh1LxOmVzOlGUriIlOaokOvhaStA==" + }, + "debug": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "requires": { + "ms": "2.1.2" + } + }, + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" + } + } + }, + "engine.io-parser": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/engine.io-parser/-/engine.io-parser-5.2.1.tgz", + "integrity": "sha512-9JktcM3u18nU9N2Lz3bWeBgxVgOKpw7yhRaoxQA3FUDZzzw+9WlA6p4G4u0RixNkg14fH7EfEc/RhpurtiROTQ==" + }, "escalade": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz", @@ -6169,6 +6417,67 @@ "resolved": "https://registry.npmjs.org/smart-buffer/-/smart-buffer-4.2.0.tgz", "integrity": "sha512-94hK0Hh8rPqQl2xXc3HsaBoOXKV20MToPkcXvwbISWLEs+64sBq5kFgn2kJDHb1Pry9yrP0dxrCI9RRci7RXKg==" }, + "socket.io": { + "version": "4.7.2", + "resolved": "https://registry.npmjs.org/socket.io/-/socket.io-4.7.2.tgz", + "integrity": "sha512-bvKVS29/I5fl2FGLNHuXlQaUH/BlzX1IN6S+NKLNZpBsPZIDH+90eQmCs2Railn4YUiww4SzUedJ6+uzwFnKLw==", + "requires": { + "accepts": "~1.3.4", + "base64id": "~2.0.0", + "cors": "~2.8.5", + "debug": "~4.3.2", + "engine.io": "~6.5.2", + "socket.io-adapter": "~2.5.2", + "socket.io-parser": "~4.2.4" + }, + "dependencies": { + "debug": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "requires": { + "ms": "2.1.2" + } + }, + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" + } + } + }, + "socket.io-adapter": { + "version": "2.5.2", + "resolved": "https://registry.npmjs.org/socket.io-adapter/-/socket.io-adapter-2.5.2.tgz", + "integrity": "sha512-87C3LO/NOMc+eMcpcxUBebGjkpMDkNBS9tf7KJqcDsmL936EChtVva71Dw2q4tQcuVC+hAUy4an2NO/sYXmwRA==", + "requires": { + "ws": "~8.11.0" + } + }, + "socket.io-parser": { + "version": "4.2.4", + "resolved": "https://registry.npmjs.org/socket.io-parser/-/socket.io-parser-4.2.4.tgz", + "integrity": "sha512-/GbIKmo8ioc+NIWIhwdecY0ge+qVBSMdgxGygevmdHj24bsfgtCmcUUcQ5ZzcylGFHsN3k4HB4Cgkl96KVnuew==", + "requires": { + "@socket.io/component-emitter": "~3.1.0", + "debug": "~4.3.1" + }, + "dependencies": { + "debug": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "requires": { + "ms": "2.1.2" + } + }, + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" + } + } + }, "socks": { "version": "2.7.1", "resolved": "https://registry.npmjs.org/socks/-/socks-2.7.1.tgz", @@ -6409,6 +6718,12 @@ "strip-ansi": "^6.0.0" } }, + "ws": { + "version": "8.11.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.11.0.tgz", + "integrity": "sha512-HPG3wQd9sNQoT9xHyNCXoDUa+Xw/VevmY9FoHyQ+g+rrMn4j6FB4np7Z0OhdTgjx6MgQLK7jwSy1YecU1+4Asg==", + "requires": {} + }, "y18n": { "version": "5.0.8", "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", diff --git a/GestionCommande/package.json b/GestionCommande/package.json index 4e24dd66..f626d1af 100644 --- a/GestionCommande/package.json +++ b/GestionCommande/package.json @@ -15,7 +15,8 @@ "eureka-js-client": "^4.5.0", "express": "^4.18.2", "mongoose": "^7.5.4", - "mongoose-paginate": "^5.0.3" + "mongoose-paginate": "^5.0.3", + "socket.io": "^4.7.2" }, "devDependencies": { "@types/eureka-js-client": "^4.5.7", diff --git a/GestionCommande/src/Controller/CommandeController.ts b/GestionCommande/src/Controller/CommandeController.ts index add6a260..f4ca1f10 100644 --- a/GestionCommande/src/Controller/CommandeController.ts +++ b/GestionCommande/src/Controller/CommandeController.ts @@ -2,7 +2,9 @@ import { Request, Response } from "express"; import Commande from "../Model/Commande"; import LigneCommande from "../Model/LigneCommande"; import Livraison from "../Model/Livraison"; -import { stat } from "fs"; +import io from ".."; + + export const addCommande = async (req: Request, res: Response) => { @@ -182,6 +184,7 @@ export const RefusedCommand=async (req:Request,res:Response)=>{ function notifyNotificationService(userid:any,message:String) { + const axios = require('axios'); axios.post('http://localhost:8888/FEEDBACK-SERVICE/FeedBack/AddNotif', { idEnvoi: "3", @@ -189,6 +192,8 @@ function notifyNotificationService(userid:any,message:String) { Message:message, etat:0 }); + + } //admin @@ -231,14 +236,14 @@ export const deleteCommande = async (req: Request, res: Response) => { try { const id = req.params.id; const deletedCommande = await Commande.findByIdAndDelete(id); - + if (deletedCommande) { - res.status(200).send(deletedCommande); + res.status(200).send("Commande deleted successfully"); } else { res.status(404).send({ error: 'Commande not found' }); } } catch (err: any) { - res.status(500).send({ error: err.message }); + res.status(500).send({ error: 'Failed to delete Commande' }); } }; diff --git a/GestionCommande/src/Routes/CommandeRoutes.ts b/GestionCommande/src/Routes/CommandeRoutes.ts index e9c7d138..a6294d27 100644 --- a/GestionCommande/src/Routes/CommandeRoutes.ts +++ b/GestionCommande/src/Routes/CommandeRoutes.ts @@ -6,7 +6,7 @@ import { addCommande,GetCommandeDispo,AddLivraison, GetCommandsWaiting, RefusedCommand, AcceptCommand, - deleteCommande, + deleteCommandeById} from "../Controller/CommandeController" @@ -17,7 +17,7 @@ module.exports=(router:any)=>{ router.put('/AcceptCommand/:num',AcceptCommand); router.put('/RefusedCommand/:num',RefusedCommand); router.get('/GetCommandsWaiting',GetCommandsWaiting); - router.delete('/DeleteCommande/:id', deleteCommande); + // router.delete('/DeleteCommande/:id', deleteCommande); router.get('/GetCommandeByIdUser/:Client_id',GetCommandeByIdUser); router.get('/GetLivraisonByNumCommande/:num',GetLivraisonByNumCommande); router.put('/ChangerLocationLivreur/:num',ChangerLocationLivreur); diff --git a/GestionCommande/src/index.ts b/GestionCommande/src/index.ts index a76d08d1..bf170467 100644 --- a/GestionCommande/src/index.ts +++ b/GestionCommande/src/index.ts @@ -5,13 +5,40 @@ const eurekaHelper = require('./Setup_Euruka'); const PORT = process.env.PORT || 3000; const uri:string='mongodb://127.0.0.1:27017/GestionCommande' const connect=new ConnectMongo(uri); +var socket = require('socket.io'); + +var io : any; connect.ConnectToBd().then(()=>{ app.use("/Commande",router); - connect.server(app,PORT); + // connect.server(app,PORT); + io = socket(connect.server(app,PORT), { + cors: { + origin: "http://localhost:4200", + methods: ["GET", "POST"] + } + }); + + io.on('connection', (socket:any) => { + + console.log(`New connection ${socket.id}`) + + + socket.on('chat', function(data:any){ + io.sockets.emit('chat', data); + }); + + + // socket.on('typing', function(data:any){ + // io.sockets.emit('typing', data); + // }); + +}); + eurekaHelper.registerWithEureka('GestionCommande-service', PORT);//enregistrer dans Eureka }).catch((error:any)=>{ console.log(error); }) +export default io; \ No newline at end of file diff --git a/ProductPhotos/20231201204548_pexels-anj-namoro-2850487.jpg b/ProductPhotos/20231201204548_pexels-anj-namoro-2850487.jpg new file mode 100644 index 00000000..03e2cd97 Binary files /dev/null and b/ProductPhotos/20231201204548_pexels-anj-namoro-2850487.jpg differ diff --git a/deliverymarket/assets/images/livreur.jpg b/deliverymarket/assets/images/livreur.jpg new file mode 100644 index 00000000..9ae6b053 Binary files /dev/null and b/deliverymarket/assets/images/livreur.jpg differ diff --git a/deliverymarket/lib/Screens/HomeCommande.dart b/deliverymarket/lib/Screens/HomeCommande.dart index e4cb4ce1..d2920767 100644 --- a/deliverymarket/lib/Screens/HomeCommande.dart +++ b/deliverymarket/lib/Screens/HomeCommande.dart @@ -1,10 +1,14 @@ +// ignore_for_file: prefer_const_literals_to_create_immutables, prefer_const_constructors + import 'package:deliverymarket/Screens/CommandeCureent.dart'; import 'package:deliverymarket/Screens/CommandeDispo.dart'; import 'package:deliverymarket/Screens/CommandeOld.dart'; +import 'package:deliverymarket/Screens/LivreurProfile.dart'; import 'package:flutter/material.dart'; import 'package:curved_navigation_bar/curved_navigation_bar.dart'; + class HomeCommande extends StatefulWidget { const HomeCommande({super.key}); @@ -27,9 +31,12 @@ class _HomeCommandeState extends State { }else if(index==1){ layout=CommandeCurrent(); Commande="Chargement"; - }else{ + }else if (index==2){ layout=CommandeOld(); Commande="Old"; + }else{ + layout = Profile(); + Commande="Profile"; } _selectIndex=index; }); @@ -37,22 +44,29 @@ class _HomeCommandeState extends State { @override Widget build(BuildContext context) { - return Scaffold( - appBar: AppBar( - title: Text("Commande $Commande"), - ), + String appBarTitle = "Commande $Commande"; + if (_selectIndex == 3) { + appBarTitle = "Livreur Profile"; + } + + return Scaffold( + appBar: AppBar( + title: Text(appBarTitle), + ), bottomNavigationBar: CurvedNavigationBar( color:Colors.blue, buttonBackgroundColor:Colors.blue, backgroundColor:Colors.white, animationCurve: Curves.easeInOut, - animationDuration:const Duration(milliseconds: 600), + animationDuration:const Duration(milliseconds: 500), onTap: (index){changeSelectedINdex(index);}, index: _selectIndex, + items: [ Icon(Icons.newspaper,color: Colors.white,), Icon(Icons.delivery_dining,color: Colors.white,), Icon(Icons.delete_forever,color: Colors.white,), + Icon(Icons.account_box_rounded ,color: Colors.white,), ], ), body: layout diff --git a/deliverymarket/lib/Screens/LivreurProfile.dart b/deliverymarket/lib/Screens/LivreurProfile.dart new file mode 100644 index 00000000..5877dd4f --- /dev/null +++ b/deliverymarket/lib/Screens/LivreurProfile.dart @@ -0,0 +1,70 @@ +import 'package:flutter/material.dart'; + + + +class Profile extends StatelessWidget { + const Profile({super.key}); + + @override +Widget build(BuildContext context) { + return Scaffold( + body: Padding( + padding: const EdgeInsets.all(20), + child: Column( + children: [ + const SizedBox(height: 30), + CircleAvatar( + radius: 50, + backgroundImage: AssetImage("assets/images/livreur.jpg"), + ), + + + const SizedBox(height: 40), + itemProfile('Name', 'Souissi Youssef', Icons.person), + const SizedBox(height: 10), + itemProfile('Phone', '123453546567', Icons.phone), + const SizedBox(height: 10), + itemProfile('Address', 'tunis', Icons.location_on), + const SizedBox(height: 10), + itemProfile('Email', 'souissiyoussef9@gmail.com', Icons.mail), + const SizedBox(height: 40,), + SizedBox( + width: double.infinity, + child: ElevatedButton( + onPressed: () {}, + style: ElevatedButton.styleFrom( + padding: const EdgeInsets.all(15), + backgroundColor: Colors.redAccent + ), + child: const Text('Logout',style: TextStyle(fontSize: 18),) + ), + ) + ], + ), + ), + ); + } + + itemProfile(String title, String subtitle, IconData iconData) { + return Container( + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(10), + boxShadow: [ + BoxShadow( + offset: Offset(0, 5), + color: const Color.fromARGB(255, 52, 52, 53).withOpacity(.2), + spreadRadius: 2, + blurRadius: 10 + ) + ] + ), + child: ListTile( + title: Text(title), + subtitle: Text(subtitle), + leading: Icon(iconData), + tileColor: Colors.white, + ), + ); + } +} \ No newline at end of file diff --git a/deliverymarket/pubspec.yaml b/deliverymarket/pubspec.yaml index a9c49b80..3d5bbdd5 100644 --- a/deliverymarket/pubspec.yaml +++ b/deliverymarket/pubspec.yaml @@ -63,10 +63,9 @@ flutter: uses-material-design: true # To add assets to your application, add an assets section, like this: - # assets: - # - images/a_dot_burr.jpeg - # - images/a_dot_ham.jpeg - + assets: + - assets/images/ + # An image asset can refer to one or more resolution-specific "variants", see # https://flutter.dev/assets-and-images/#resolution-aware diff --git a/mobile/.idea/deploymentTargetDropDown.xml b/mobile/.idea/deploymentTargetDropDown.xml index 3b634866..13621fb6 100644 --- a/mobile/.idea/deploymentTargetDropDown.xml +++ b/mobile/.idea/deploymentTargetDropDown.xml @@ -7,11 +7,11 @@ - + - + \ No newline at end of file diff --git a/mobile/app/src/main/AndroidManifest.xml b/mobile/app/src/main/AndroidManifest.xml index e89a39e2..4d73bfd3 100644 --- a/mobile/app/src/main/AndroidManifest.xml +++ b/mobile/app/src/main/AndroidManifest.xml @@ -3,6 +3,7 @@ xmlns:tools="http://schemas.android.com/tools"> + + tools:targetApi="34"> + + + + + - + + + + - - - - - - - - + + + + - + - + - + android:exported="true" /> @@ -55,6 +74,4 @@ android:resource="@array/preloaded_fonts" /> - - - + \ No newline at end of file diff --git a/mobile/app/src/main/java/com/example/digitalmarket/Client/CheckoutActivity.kt b/mobile/app/src/main/java/com/example/digitalmarket/Client/CheckoutActivity.kt new file mode 100644 index 00000000..e8f6d38f --- /dev/null +++ b/mobile/app/src/main/java/com/example/digitalmarket/Client/CheckoutActivity.kt @@ -0,0 +1,14 @@ +package com.example.digitalmarket.Client +import android.os.Bundle +import androidx.appcompat.app.AppCompatActivity +import com.example.digitalmarket.R + +class CheckoutActivity : AppCompatActivity() { + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.checkout_client) + + + } +} diff --git a/mobile/app/src/main/java/com/example/digitalmarket/FournisseurIntoScreen2.kt b/mobile/app/src/main/java/com/example/digitalmarket/FournisseurIntoScreen2.kt new file mode 100644 index 00000000..6af23e7e --- /dev/null +++ b/mobile/app/src/main/java/com/example/digitalmarket/FournisseurIntoScreen2.kt @@ -0,0 +1,27 @@ +package com.example.digitalmarket + +import android.content.Intent +import android.os.Bundle +import android.view.animation.AnimationUtils +import android.widget.Button +import androidx.appcompat.app.AppCompatActivity +import androidx.core.app.ActivityOptionsCompat + +class FournisseurIntoScreen2 : AppCompatActivity() { + lateinit var navBtn: Button + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.fournisseurintroscreen2) + navBtn = findViewById(R.id.introButton) + + navBtn.setOnClickListener() { + val intent = Intent(this, FournisseurIntroScreen3::class.java) + val slideLeftAnimation = AnimationUtils.loadAnimation(this, R.anim.slide_left) + navBtn.startAnimation(slideLeftAnimation) + + + startActivity(intent, ActivityOptionsCompat.makeCustomAnimation(this, R.anim.slide_in_right, R.anim.slide_out_left).toBundle()) + } + } +} \ No newline at end of file diff --git a/mobile/app/src/main/java/com/example/digitalmarket/FournisseurIntroScreen1.kt b/mobile/app/src/main/java/com/example/digitalmarket/FournisseurIntroScreen1.kt new file mode 100644 index 00000000..a86fd504 --- /dev/null +++ b/mobile/app/src/main/java/com/example/digitalmarket/FournisseurIntroScreen1.kt @@ -0,0 +1,27 @@ +package com.example.digitalmarket + +import android.content.Intent +import android.os.Bundle +import android.view.animation.AnimationUtils +import android.widget.Button +import androidx.appcompat.app.AppCompatActivity +import androidx.core.app.ActivityOptionsCompat + +class FournisseurIntroScreen1 : AppCompatActivity() { + lateinit var navBtn: Button + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.fournisseurintroscreen1) + navBtn = findViewById(R.id.introButton) + + navBtn.setOnClickListener() { + val intent = Intent(this, FournisseurIntoScreen2::class.java) + val slideLeftAnimation = AnimationUtils.loadAnimation(this, R.anim.slide_left) + navBtn.startAnimation(slideLeftAnimation) + + + startActivity(intent, ActivityOptionsCompat.makeCustomAnimation(this, R.anim.slide_in_right, R.anim.slide_out_left).toBundle()) + } + } +} diff --git a/mobile/app/src/main/java/com/example/digitalmarket/FournisseurIntroScreen3.kt b/mobile/app/src/main/java/com/example/digitalmarket/FournisseurIntroScreen3.kt new file mode 100644 index 00000000..1f272c35 --- /dev/null +++ b/mobile/app/src/main/java/com/example/digitalmarket/FournisseurIntroScreen3.kt @@ -0,0 +1,27 @@ +package com.example.digitalmarket + +import android.content.Intent +import android.os.Bundle +import android.view.animation.AnimationUtils +import android.widget.Button +import androidx.appcompat.app.AppCompatActivity +import androidx.core.app.ActivityOptionsCompat + +class FournisseurIntroScreen3 : AppCompatActivity() { + lateinit var navBtn: Button + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.fournisseurintroscreens3) + navBtn = findViewById(R.id.introButton) + + navBtn.setOnClickListener() { + val intent = Intent(this, FournisseurDashboard::class.java) + val slideLeftAnimation = AnimationUtils.loadAnimation(this, R.anim.slide_left) + navBtn.startAnimation(slideLeftAnimation) + + + startActivity(intent, ActivityOptionsCompat.makeCustomAnimation(this, R.anim.slide_in_right, R.anim.slide_out_left).toBundle()) + } + } +} \ No newline at end of file diff --git a/mobile/app/src/main/res/drawable/business.png b/mobile/app/src/main/res/drawable/business.png new file mode 100644 index 00000000..9b8880cb Binary files /dev/null and b/mobile/app/src/main/res/drawable/business.png differ diff --git a/mobile/app/src/main/res/drawable/fournisseur_delivery.png b/mobile/app/src/main/res/drawable/fournisseur_delivery.png new file mode 100644 index 00000000..08a535d7 Binary files /dev/null and b/mobile/app/src/main/res/drawable/fournisseur_delivery.png differ diff --git a/mobile/app/src/main/res/drawable/stats.png b/mobile/app/src/main/res/drawable/stats.png new file mode 100644 index 00000000..3303f5ad Binary files /dev/null and b/mobile/app/src/main/res/drawable/stats.png differ diff --git a/mobile/app/src/main/res/layout/checkout_client.xml b/mobile/app/src/main/res/layout/checkout_client.xml new file mode 100644 index 00000000..53967852 --- /dev/null +++ b/mobile/app/src/main/res/layout/checkout_client.xml @@ -0,0 +1,115 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +