From 5acaeca2120faf92be3ca1e89725239baed81db9 Mon Sep 17 00:00:00 2001 From: FazCodeFR <30906528+FazCodeFR@users.noreply.github.com> Date: Wed, 5 Jun 2024 12:33:42 +0200 Subject: [PATCH 1/2] Add bug report in footer --- src/app/components/footer/footer.component.html | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/app/components/footer/footer.component.html b/src/app/components/footer/footer.component.html index 1dab8b0..c642d90 100644 --- a/src/app/components/footer/footer.component.html +++ b/src/app/components/footer/footer.component.html @@ -15,6 +15,8 @@ routerLink="/contact">Nous contacter Mentions légales + Signaler un bug From 2bf349940057befbc4a453f51b0ba08c08949713 Mon Sep 17 00:00:00 2001 From: marion-sgr Date: Wed, 5 Jun 2024 14:38:38 +0200 Subject: [PATCH 2/2] Create association detail page --- package-lock.json | 53 +++---- package.json | 1 + src/app/app-routing.module.ts | 5 + src/app/app.module.ts | 4 +- .../associations-details.component.html | 146 ++++++++++++++++++ .../associations-details.component.scss | 0 .../associations-details.component.spec.ts | 21 +++ .../associations-details.component.ts | 89 +++++++++++ src/app/interfaces/interfaces.ts | 10 +- src/app/services/app.service.ts | 26 +++- src/index.html | 1 + 11 files changed, 322 insertions(+), 34 deletions(-) create mode 100644 src/app/components/associations/associations-details/associations-details.component.html create mode 100644 src/app/components/associations/associations-details/associations-details.component.scss create mode 100644 src/app/components/associations/associations-details/associations-details.component.spec.ts create mode 100644 src/app/components/associations/associations-details/associations-details.component.ts diff --git a/package-lock.json b/package-lock.json index 0d9a9a8..9de457c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -25,6 +25,7 @@ "@fortawesome/free-solid-svg-icons": "^6.4.0", "@tinymce/tinymce-angular": "^7.0.0", "ngx-toastr": "^18.0.0", + "primeicons": "^7.0.0", "primeng": "^16.9.1", "rxjs": "~7.8.0", "socket.io-client": "^4.7.5", @@ -11292,6 +11293,11 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/primeicons": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/primeicons/-/primeicons-7.0.0.tgz", + "integrity": "sha512-jK3Et9UzwzTsd6tzl2RmwrVY/b8raJ3QZLzoDACj+oTJ0oX7L9Hy+XnVwgo4QVKlKpnP/Ur13SXV/pVh4LzaDw==" + }, "node_modules/primeng": { "version": "16.9.1", "resolved": "https://registry.npmjs.org/primeng/-/primeng-16.9.1.tgz", @@ -15189,8 +15195,7 @@ "version": "7.21.0-placeholder-for-preset-env.2", "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-private-property-in-object/-/plugin-proposal-private-property-in-object-7.21.0-placeholder-for-preset-env.2.tgz", "integrity": "sha512-SOSkfJDddaM7mak6cPEpswyTRnuRltl429hMraQEglW+OkovnCzsiszTmsrlY//qLFjCpQDFRvjdm2wA5pPm9w==", - "dev": true, - "requires": {} + "dev": true }, "@babel/plugin-proposal-unicode-property-regex": { "version": "7.18.6", @@ -17166,8 +17171,7 @@ "version": "16.2.12", "resolved": "https://registry.npmjs.org/@ngtools/webpack/-/webpack-16.2.12.tgz", "integrity": "sha512-f9R9Qsk8v+ffDxryl6PQ7Wnf2JCNd4dDXOH+d/AuF06VFiwcwGDRDZpmqkAXbFxQfcWTbT1FFvfoJ+SFcJgXLA==", - "dev": true, - "requires": {} + "dev": true }, "@nodelib/fs.scandir": { "version": "2.1.5", @@ -17717,8 +17721,7 @@ "version": "1.0.1", "resolved": "https://registry.npmjs.org/@vitejs/plugin-basic-ssl/-/plugin-basic-ssl-1.0.1.tgz", "integrity": "sha512-pcub+YbFtFhaGRTo1832FQHQSHvMrlb43974e2eS8EKleR3p1cDdkJFPci1UhwkEf1J9Bz+wKBSzqpKp7nNj2A==", - "dev": true, - "requires": {} + "dev": true }, "@webassemblyjs/ast": { "version": "1.11.6", @@ -17997,8 +18000,7 @@ "version": "1.9.0", "resolved": "https://registry.npmjs.org/acorn-import-assertions/-/acorn-import-assertions-1.9.0.tgz", "integrity": "sha512-cmMwop9x+8KFhxvKrKfPYmN6/pKTYYHBqLa0DfvVZcKMJWNyWLnaqND7dx/qn66R7ewM1UX5XMaDVP5wlVTaVA==", - "dev": true, - "requires": {} + "dev": true }, "acorn-walk": { "version": "7.2.0", @@ -19347,8 +19349,7 @@ "version": "8.11.0", "resolved": "https://registry.npmjs.org/ws/-/ws-8.11.0.tgz", "integrity": "sha512-HPG3wQd9sNQoT9xHyNCXoDUa+Xw/VevmY9FoHyQ+g+rrMn4j6FB4np7Z0OhdTgjx6MgQLK7jwSy1YecU1+4Asg==", - "dev": true, - "requires": {} + "dev": true } } }, @@ -19367,8 +19368,7 @@ "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": {} + "integrity": "sha512-HPG3wQd9sNQoT9xHyNCXoDUa+Xw/VevmY9FoHyQ+g+rrMn4j6FB4np7Z0OhdTgjx6MgQLK7jwSy1YecU1+4Asg==" } } }, @@ -20348,8 +20348,7 @@ "version": "5.1.0", "resolved": "https://registry.npmjs.org/icss-utils/-/icss-utils-5.1.0.tgz", "integrity": "sha512-soFhflCVWLfRNOPU3iv5Z9VUdT44xFRbzjLsEzSr5AQmgqPMTHdU3PMT1Cf1ssx8fLNJDA1juftYl+PUcv3MqA==", - "dev": true, - "requires": {} + "dev": true }, "ieee754": { "version": "1.2.1", @@ -21063,8 +21062,7 @@ "version": "2.1.0", "resolved": "https://registry.npmjs.org/karma-jasmine-html-reporter/-/karma-jasmine-html-reporter-2.1.0.tgz", "integrity": "sha512-sPQE1+nlsn6Hwb5t+HHwyy0A1FNCVKuL1192b+XNauMYWThz2kweiBVW1DqloRpVvZIJkIoHVB7XRpK78n1xbQ==", - "dev": true, - "requires": {} + "dev": true }, "karma-source-map-support": { "version": "1.4.0", @@ -22665,8 +22663,7 @@ "version": "3.0.0", "resolved": "https://registry.npmjs.org/postcss-modules-extract-imports/-/postcss-modules-extract-imports-3.0.0.tgz", "integrity": "sha512-bdHleFnP3kZ4NYDhuGlVK+CMrQ/pqUm8bx/oGL93K6gVwiclvX5x0n76fYMKuIGKzlABOy13zsvqjb0f92TEXw==", - "dev": true, - "requires": {} + "dev": true }, "postcss-modules-local-by-default": { "version": "4.0.4", @@ -22728,6 +22725,11 @@ "integrity": "sha512-FFw039TmrBqFK8ma/7OL3sDz/VytdtJr044/QUJtH0wK9lb9jLq9tJyIxUwtQJHwar2BqtiA4iCWSwo9JLkzFg==", "dev": true }, + "primeicons": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/primeicons/-/primeicons-7.0.0.tgz", + "integrity": "sha512-jK3Et9UzwzTsd6tzl2RmwrVY/b8raJ3QZLzoDACj+oTJ0oX7L9Hy+XnVwgo4QVKlKpnP/Ur13SXV/pVh4LzaDw==" + }, "primeng": { "version": "16.9.1", "resolved": "https://registry.npmjs.org/primeng/-/primeng-16.9.1.tgz", @@ -23605,8 +23607,7 @@ "version": "8.11.0", "resolved": "https://registry.npmjs.org/ws/-/ws-8.11.0.tgz", "integrity": "sha512-HPG3wQd9sNQoT9xHyNCXoDUa+Xw/VevmY9FoHyQ+g+rrMn4j6FB4np7Z0OhdTgjx6MgQLK7jwSy1YecU1+4Asg==", - "dev": true, - "requires": {} + "dev": true } } }, @@ -24087,8 +24088,7 @@ "version": "3.5.2", "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-3.5.2.tgz", "integrity": "sha512-5p6WTN0DdTGVQk6VjcEju19IgaHudalcfabD7yhDGeA6bcQnmL+CpveLJq/3hvfwd1aof6L386Ougkx6RfyMIQ==", - "dev": true, - "requires": {} + "dev": true }, "commander": { "version": "2.20.3", @@ -24622,8 +24622,7 @@ "version": "3.5.2", "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-3.5.2.tgz", "integrity": "sha512-5p6WTN0DdTGVQk6VjcEju19IgaHudalcfabD7yhDGeA6bcQnmL+CpveLJq/3hvfwd1aof6L386Ougkx6RfyMIQ==", - "dev": true, - "requires": {} + "dev": true }, "json-schema-traverse": { "version": "0.4.1", @@ -24712,8 +24711,7 @@ "version": "8.16.0", "resolved": "https://registry.npmjs.org/ws/-/ws-8.16.0.tgz", "integrity": "sha512-HS0c//TP7Ina87TfiPUz1rQzMhHrl/SG2guqRcTOIUYD2q8uhUdNHZYJUaQ8aTGPzCh+c6oawMKW35nFl1dxyQ==", - "dev": true, - "requires": {} + "dev": true } } }, @@ -24893,8 +24891,7 @@ "version": "7.5.9", "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.9.tgz", "integrity": "sha512-F+P9Jil7UiSKSkppIiD94dN07AwvFixvLIj1Og1Rl9GGMuNipJnV9JzjD6XuqmAeiswGvUmNLjr5cFuXwNS77Q==", - "dev": true, - "requires": {} + "dev": true }, "xml-name-validator": { "version": "3.0.0", diff --git a/package.json b/package.json index 217b674..d75c2c5 100644 --- a/package.json +++ b/package.json @@ -28,6 +28,7 @@ "@fortawesome/free-solid-svg-icons": "^6.4.0", "@tinymce/tinymce-angular": "^7.0.0", "ngx-toastr": "^18.0.0", + "primeicons": "^7.0.0", "primeng": "^16.9.1", "rxjs": "~7.8.0", "socket.io-client": "^4.7.5", diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index d8ac8ba..c00c76d 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -15,6 +15,7 @@ import { CguComponent } from './components/cgu/cgu.component'; import { ErreurComponent } from './components/erreur/erreur.component'; import { AuthGuard } from '@auth0/auth0-angular'; import { TchatComponent } from './components/tchat/tchat.component'; +import { AssociationsDetailsComponent } from './components/associations/associations-details/associations-details.component'; const routes: Routes = [ { @@ -53,6 +54,10 @@ const routes: Routes = [ component: DonsComponent, data: { state: 'dons' }, }, + { + path: 'associations/:id', + component: AssociationsDetailsComponent, + }, { path: 'associations', component: AssociationsListComponent, diff --git a/src/app/app.module.ts b/src/app/app.module.ts index d0febcf..65a4332 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -42,9 +42,10 @@ import { TchatMessageComponent } from './components/tchat/tchat-message/tchat-me import { FileUploadModule } from 'primeng/fileupload'; import { AccordionModule } from 'primeng/accordion'; - import { ToastModule } from 'primeng/toast'; +import { AssociationsDetailsComponent } from './components/associations/associations-details/associations-details.component'; + @NgModule({ declarations: [ AppComponent, @@ -67,6 +68,7 @@ import { ToastModule } from 'primeng/toast'; TchatComponent, TchatIconComponent, TchatMessageComponent, + AssociationsDetailsComponent, ], imports: [ BrowserModule, diff --git a/src/app/components/associations/associations-details/associations-details.component.html b/src/app/components/associations/associations-details/associations-details.component.html new file mode 100644 index 0000000..676b5f4 --- /dev/null +++ b/src/app/components/associations/associations-details/associations-details.component.html @@ -0,0 +1,146 @@ +
+
+
+

+ Catégorie : Association +

+
+ + + + +
+

+ + +

+
+
+ +
+ +
+
+ +
+ + +
+
+
+ +
+ + +
+
+ +
+ +
+
+ +
+
+ + + + + +
+ +
+ +

+ {{asso.tel}} +

+
+ +
+ + + {{asso.url}} + +
+
+
+ + +
+ +

+

+ + +
+ + + + + + + + +
\ No newline at end of file diff --git a/src/app/components/associations/associations-details/associations-details.component.scss b/src/app/components/associations/associations-details/associations-details.component.scss new file mode 100644 index 0000000..e69de29 diff --git a/src/app/components/associations/associations-details/associations-details.component.spec.ts b/src/app/components/associations/associations-details/associations-details.component.spec.ts new file mode 100644 index 0000000..578807f --- /dev/null +++ b/src/app/components/associations/associations-details/associations-details.component.spec.ts @@ -0,0 +1,21 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { AssociationsDetailsComponent } from './associations-details.component'; + +describe('AssociationsDetailsComponent', () => { + let component: AssociationsDetailsComponent; + let fixture: ComponentFixture; + + beforeEach(() => { + TestBed.configureTestingModule({ + declarations: [AssociationsDetailsComponent] + }); + fixture = TestBed.createComponent(AssociationsDetailsComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/components/associations/associations-details/associations-details.component.ts b/src/app/components/associations/associations-details/associations-details.component.ts new file mode 100644 index 0000000..19d037a --- /dev/null +++ b/src/app/components/associations/associations-details/associations-details.component.ts @@ -0,0 +1,89 @@ +import { DOCUMENT, DatePipe } from '@angular/common'; +import { Component, Inject } from '@angular/core'; +import { Association, Chat, Sexe } from '../../../interfaces/interfaces'; +import { AppService } from '../../../services/app.service'; +import { ActivatedRoute } from '@angular/router'; +import { faTrash, faUpload } from '@fortawesome/free-solid-svg-icons'; +import { DomSanitizer, SafeHtml } from '@angular/platform-browser'; +import { ToastrService } from 'ngx-toastr'; +import { AuthService } from '@auth0/auth0-angular'; +import { UserService } from '../../../services/user.service'; +import { Subscription, firstValueFrom } from 'rxjs'; + +@Component({ + selector: 'app-associations-details', + templateUrl: './associations-details.component.html', + styleUrls: ['./associations-details.component.scss'] +}) +export class AssociationsDetailsComponent { + asso: Association | undefined; + faTrash = faTrash; + faUpload = faUpload; + dataModel: any; + description: string = '

L\'association est ....

'; + isEditMode: boolean = false; + isAuthenticated: boolean = false; + private subscriptions = new Subscription(); + + constructor( + private route: ActivatedRoute, + private appService: AppService, + private sanitizer: DomSanitizer, + private toastr: ToastrService, + public auth: AuthService, + @Inject(DOCUMENT) private doc: Document, + public userService: UserService, + ) {} + + async ngOnInit() { + this.isAuthenticated = await firstValueFrom(this.auth.isAuthenticated$); + this.getAsso(); + } + + sanitizeUrl(url: string): SafeHtml { + return this.sanitizer.bypassSecurityTrustUrl(url); + } + sanitizeHtml(html: string): SafeHtml { + return this.sanitizer.bypassSecurityTrustHtml(html); + } + + toggleEditMode() { + this.isEditMode = !this.isEditMode; + } + + getAsso() { + this.route.params.subscribe((params) => { + if (params['id']) { + this.appService.getByIdAsso(params['id']).subscribe((asso) => { + this.asso = asso; + console.log('asso:', asso); + }); + } + }); + } + + updateAsso() { + this.appService.updateAsso(this.asso!).subscribe({ + error: (error) => { + console.error('error:', error); + if (error?.error?.message) { + this.toastr.error( + error.error.message, + 'Erreur de mise à jour de l\'association' + ); + } else { + this.toastr.error('Erreur de mise à jour de l\'association'); + } + }, + complete: () => { + this.toastr.success('Association mis à jour avec succès'); + this.isEditMode = false; + }, + }); + } + + ngOnDestroy() { + this.subscriptions.unsubscribe(); + } + +} diff --git a/src/app/interfaces/interfaces.ts b/src/app/interfaces/interfaces.ts index 75ef3a2..9403e57 100644 --- a/src/app/interfaces/interfaces.ts +++ b/src/app/interfaces/interfaces.ts @@ -37,8 +37,10 @@ export interface Photo { id: number; createdAt: string; url: string; - chatId: number; - chat: Chat; + chatId?: number; + chat?: Chat; + associationId?: number; + association?: Association; } export interface Video { @@ -69,13 +71,13 @@ export interface Utilisateur { export interface Association { id: number; nom: string; - url?: string; + url: string; ville: string; - urlImage?: string; description?: string; tel?: string; chats: Chat[]; utilisateurs: Utilisateur[]; + photos: Photo[]; } export interface Favori { diff --git a/src/app/services/app.service.ts b/src/app/services/app.service.ts index 474c1c9..2028fe3 100644 --- a/src/app/services/app.service.ts +++ b/src/app/services/app.service.ts @@ -1,7 +1,7 @@ import { Inject, Injectable } from '@angular/core'; import { HttpClient } from '@angular/common/http'; import { Observable, map, share, take } from 'rxjs'; -import { Chat, Favori } from '../interfaces/interfaces'; +import { Association, Chat, Favori } from '../interfaces/interfaces'; import { environment } from 'src/environments/environment'; import { DOCUMENT } from '@angular/common'; @@ -58,6 +58,30 @@ export class AppService { ); } + getAllAsso(): Observable { + return this.http.get(this.api + '/associations').pipe( + map((res: any) => res), + share(), + take(1) + ); + } + + getByIdAsso(id: number): Observable { + return this.http.get(this.api + '/associations/' + id).pipe( + map((res: any) => res), + share(), + take(1) + ); + } + + updateAsso(asso: Association): Observable { + return this.http.put(this.api + '/associations/' + asso.id, asso).pipe( + map((res: any) => res), + share(), + take(1) + ); + } + createFavori(favori: Favori): Observable { return this.http.post(this.api + '/favoris', favori).pipe( map((res: any) => res), diff --git a/src/index.html b/src/index.html index b61d311..2533b5a 100644 --- a/src/index.html +++ b/src/index.html @@ -11,6 +11,7 @@ +