From c7393f8b7e61fafef98320678b6d3286d455748b Mon Sep 17 00:00:00 2001 From: Daniel Date: Wed, 14 Feb 2024 14:38:40 +0100 Subject: [PATCH] partner detail wip --- matsen-tool/openapi.yaml | 50 +++++++++++++++++++ .../{api.helper.ts => api.converter.ts} | 6 +-- .../app/core/api/v1/.openapi-generator/FILES | 1 - .../app/core/api/v1/api/contact.service.ts | 20 ++++++-- .../src/app/core/api/v1/model/contact.ts | 1 + .../app/core/api/v1/model/contactJsonhal.ts | 1 + .../app/core/api/v1/model/contactJsonld.ts | 1 + .../src/app/core/api/v1/model/partner.ts | 1 + .../app/core/api/v1/model/partnerJsonhal.ts | 1 + .../app/core/api/v1/model/partnerJsonld.ts | 1 + .../partners-detail.component.html | 2 +- .../partners-detail.component.ts | 17 ++----- .../src/app/partners/partners.component.ts | 6 +-- 13 files changed, 82 insertions(+), 26 deletions(-) rename matsen-tool/src/app/_helpers/{api.helper.ts => api.converter.ts} (66%) diff --git a/matsen-tool/openapi.yaml b/matsen-tool/openapi.yaml index 0845ef6..3e9679d 100644 --- a/matsen-tool/openapi.yaml +++ b/matsen-tool/openapi.yaml @@ -64,6 +64,32 @@ paths: style: form explode: false allowReserved: false + - + name: partner + in: query + description: '' + required: false + deprecated: false + allowEmptyValue: true + schema: + type: string + style: form + explode: false + allowReserved: false + - + name: 'partner[]' + in: query + description: '' + required: false + deprecated: false + allowEmptyValue: true + schema: + type: array + items: + type: string + style: form + explode: true + allowReserved: false deprecated: false post: operationId: api_contacts_post @@ -1137,6 +1163,10 @@ components: - 'null' format: iri-reference example: 'https://example.com/' + imageUrl: + type: + - string + - 'null' position: type: - string @@ -1198,6 +1228,10 @@ components: - 'null' format: iri-reference example: 'https://example.com/' + imageUrl: + type: + - string + - 'null' position: type: - string @@ -1273,6 +1307,10 @@ components: - 'null' format: iri-reference example: 'https://example.com/' + imageUrl: + type: + - string + - 'null' position: type: - string @@ -1408,6 +1446,10 @@ components: - 'null' format: iri-reference example: 'https://example.com/' + logoUrl: + type: + - string + - 'null' createdAt: type: - string @@ -1475,6 +1517,10 @@ components: - 'null' format: iri-reference example: 'https://example.com/' + logoUrl: + type: + - string + - 'null' createdAt: type: - string @@ -1556,6 +1602,10 @@ components: - 'null' format: iri-reference example: 'https://example.com/' + logoUrl: + type: + - string + - 'null' createdAt: type: - string diff --git a/matsen-tool/src/app/_helpers/api.helper.ts b/matsen-tool/src/app/_helpers/api.converter.ts similarity index 66% rename from matsen-tool/src/app/_helpers/api.helper.ts rename to matsen-tool/src/app/_helpers/api.converter.ts index 3a7a31a..d5d1aab 100644 --- a/matsen-tool/src/app/_helpers/api.helper.ts +++ b/matsen-tool/src/app/_helpers/api.converter.ts @@ -1,6 +1,6 @@ -export class ApiHelper { +export class ApiConverter { - public static extractId(iri: string | undefined) { + public static extractId(iri: string | undefined): string { if (iri !== undefined) { const iriRegex = /\/(\d+)$/; const match = iri.match(iriRegex); @@ -8,6 +8,6 @@ export class ApiHelper { return match[1]; } } - return undefined; + return ""; } } \ No newline at end of file diff --git a/matsen-tool/src/app/core/api/v1/.openapi-generator/FILES b/matsen-tool/src/app/core/api/v1/.openapi-generator/FILES index 1c2dc22..812c87e 100644 --- a/matsen-tool/src/app/core/api/v1/.openapi-generator/FILES +++ b/matsen-tool/src/app/core/api/v1/.openapi-generator/FILES @@ -1,5 +1,4 @@ .gitignore -.openapi-generator-ignore README.md api.module.ts api/api.ts diff --git a/matsen-tool/src/app/core/api/v1/api/contact.service.ts b/matsen-tool/src/app/core/api/v1/api/contact.service.ts index 6d8e9f3..48acbd0 100644 --- a/matsen-tool/src/app/core/api/v1/api/contact.service.ts +++ b/matsen-tool/src/app/core/api/v1/api/contact.service.ts @@ -103,19 +103,31 @@ export class ContactService { * Retrieves the collection of Contact resources. * Retrieves the collection of Contact resources. * @param page The collection page number + * @param partner + * @param partner2 * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. * @param reportProgress flag to report request and response progress. */ - public contactsGetCollection(page?: number, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/ld+json' | 'application/json' | 'text/html' | 'application/hal+json', context?: HttpContext}): Observable; - public contactsGetCollection(page?: number, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/ld+json' | 'application/json' | 'text/html' | 'application/hal+json', context?: HttpContext}): Observable>; - public contactsGetCollection(page?: number, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/ld+json' | 'application/json' | 'text/html' | 'application/hal+json', context?: HttpContext}): Observable>; - public contactsGetCollection(page?: number, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/ld+json' | 'application/json' | 'text/html' | 'application/hal+json', context?: HttpContext}): Observable { + public contactsGetCollection(page?: number, partner?: string, partner2?: Array, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/ld+json' | 'application/json' | 'text/html' | 'application/hal+json', context?: HttpContext}): Observable; + public contactsGetCollection(page?: number, partner?: string, partner2?: Array, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/ld+json' | 'application/json' | 'text/html' | 'application/hal+json', context?: HttpContext}): Observable>; + public contactsGetCollection(page?: number, partner?: string, partner2?: Array, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/ld+json' | 'application/json' | 'text/html' | 'application/hal+json', context?: HttpContext}): Observable>; + public contactsGetCollection(page?: number, partner?: string, partner2?: Array, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/ld+json' | 'application/json' | 'text/html' | 'application/hal+json', context?: HttpContext}): Observable { let localVarQueryParameters = new HttpParams({encoder: this.encoder}); if (page !== undefined && page !== null) { localVarQueryParameters = this.addToHttpParams(localVarQueryParameters, page, 'page'); } + if (partner !== undefined && partner !== null) { + localVarQueryParameters = this.addToHttpParams(localVarQueryParameters, + partner, 'partner'); + } + if (partner2) { + partner2.forEach((element) => { + localVarQueryParameters = this.addToHttpParams(localVarQueryParameters, + element, 'partner[]'); + }) + } let localVarHeaders = this.defaultHeaders; diff --git a/matsen-tool/src/app/core/api/v1/model/contact.ts b/matsen-tool/src/app/core/api/v1/model/contact.ts index 90458c6..deec4b6 100644 --- a/matsen-tool/src/app/core/api/v1/model/contact.ts +++ b/matsen-tool/src/app/core/api/v1/model/contact.ts @@ -20,6 +20,7 @@ export interface Contact { partner?: string | null; birthday?: string | null; image?: string | null; + imageUrl?: string | null; position?: string | null; phone?: string | null; email?: string | null; diff --git a/matsen-tool/src/app/core/api/v1/model/contactJsonhal.ts b/matsen-tool/src/app/core/api/v1/model/contactJsonhal.ts index 39e21c8..8071286 100644 --- a/matsen-tool/src/app/core/api/v1/model/contactJsonhal.ts +++ b/matsen-tool/src/app/core/api/v1/model/contactJsonhal.ts @@ -22,6 +22,7 @@ export interface ContactJsonhal { partner?: string | null; birthday?: string | null; image?: string | null; + imageUrl?: string | null; position?: string | null; phone?: string | null; email?: string | null; diff --git a/matsen-tool/src/app/core/api/v1/model/contactJsonld.ts b/matsen-tool/src/app/core/api/v1/model/contactJsonld.ts index e261272..90be4b2 100644 --- a/matsen-tool/src/app/core/api/v1/model/contactJsonld.ts +++ b/matsen-tool/src/app/core/api/v1/model/contactJsonld.ts @@ -23,6 +23,7 @@ export interface ContactJsonld { partner?: string | null; birthday?: string | null; image?: string | null; + imageUrl?: string | null; position?: string | null; phone?: string | null; email?: string | null; diff --git a/matsen-tool/src/app/core/api/v1/model/partner.ts b/matsen-tool/src/app/core/api/v1/model/partner.ts index 84e85e6..7675daa 100644 --- a/matsen-tool/src/app/core/api/v1/model/partner.ts +++ b/matsen-tool/src/app/core/api/v1/model/partner.ts @@ -24,6 +24,7 @@ export interface Partner { country?: string | null; website?: string | null; logo?: string | null; + logoUrl?: string | null; createdAt?: string | null; contacts?: Array; } diff --git a/matsen-tool/src/app/core/api/v1/model/partnerJsonhal.ts b/matsen-tool/src/app/core/api/v1/model/partnerJsonhal.ts index 774ec25..f8723b2 100644 --- a/matsen-tool/src/app/core/api/v1/model/partnerJsonhal.ts +++ b/matsen-tool/src/app/core/api/v1/model/partnerJsonhal.ts @@ -26,6 +26,7 @@ export interface PartnerJsonhal { country?: string | null; website?: string | null; logo?: string | null; + logoUrl?: string | null; createdAt?: string | null; contacts?: Array; } diff --git a/matsen-tool/src/app/core/api/v1/model/partnerJsonld.ts b/matsen-tool/src/app/core/api/v1/model/partnerJsonld.ts index 3dffe02..8072da0 100644 --- a/matsen-tool/src/app/core/api/v1/model/partnerJsonld.ts +++ b/matsen-tool/src/app/core/api/v1/model/partnerJsonld.ts @@ -26,6 +26,7 @@ export interface PartnerJsonld { country?: string | null; website?: string | null; logo?: string | null; + logoUrl?: string | null; createdAt?: string | null; contacts?: Array; } diff --git a/matsen-tool/src/app/partners/partners-detail/partners-detail.component.html b/matsen-tool/src/app/partners/partners-detail/partners-detail.component.html index 9c84345..eef2731 100644 --- a/matsen-tool/src/app/partners/partners-detail/partners-detail.component.html +++ b/matsen-tool/src/app/partners/partners-detail/partners-detail.component.html @@ -25,7 +25,7 @@
- {{partner.name}}
diff --git a/matsen-tool/src/app/partners/partners-detail/partners-detail.component.ts b/matsen-tool/src/app/partners/partners-detail/partners-detail.component.ts index 40e0d5d..168aac8 100644 --- a/matsen-tool/src/app/partners/partners-detail/partners-detail.component.ts +++ b/matsen-tool/src/app/partners/partners-detail/partners-detail.component.ts @@ -6,6 +6,7 @@ import {ActivatedRoute} from "@angular/router"; import {ContactJsonld, ContactService, MediaObjectService, PartnerJsonld, PartnerService} from "@app/core/api/v1"; import {Subscription} from "rxjs"; import {environment} from "@environments/environment"; +import {ApiConverter} from "@app/_helpers/api.converter"; @Component({ selector: 'app-partners-detail', @@ -60,25 +61,13 @@ export class PartnersDetailComponent implements OnInit { getData() { this.partnerDetailSub = this.partnerService.partnersIdGet( - "1" + this.id ).subscribe( data => { - console.log(data); this.partner = data; - // TODO: logoUrl ist hier falsch, wir müssten nur die ID des logos haben... - let logoUrl: string = typeof data.logo === 'string' ? data.logo : ""; - this.partnerLogoSub = this.mediaObjectService.mediaObjectsIdGet( - // logoUrl - "4" - ).subscribe( - data => { - this.partnerLogo = data.contentUrl; - console.log(this.partnerLogo); - } - ); this.partnerContactsSub = this.contactService.contactsGetCollection( - // TODO: Alle contacts von diesem Partner (id) holen + 1, ApiConverter.extractId(this.partner.id) ).subscribe( data => { console.log(data); diff --git a/matsen-tool/src/app/partners/partners.component.ts b/matsen-tool/src/app/partners/partners.component.ts index 297e2fa..ae03966 100644 --- a/matsen-tool/src/app/partners/partners.component.ts +++ b/matsen-tool/src/app/partners/partners.component.ts @@ -6,7 +6,7 @@ import {Subscription} from "rxjs"; import {PartnerJsonld, PartnerService} from "@app/core/api/v1"; import {MatPaginator, MatPaginatorIntl, MatPaginatorModule, PageEvent} from "@angular/material/paginator"; import {OrderFilter} from "@app/_models/orderFilter"; -import {ApiHelper} from "@app/_helpers/api.helper"; +import {ApiConverter} from "@app/_helpers/api.converter"; @Component({ selector: 'app-partners', @@ -129,8 +129,8 @@ export class PartnersComponent implements OnInit, AfterViewInit { const partner: PartnerJsonld = element as PartnerJsonld; // this.partnerService.setPartnerData(partner); //console.log(partner['@id']); - console.log(ApiHelper.extractId(partner.id)); - this.router.navigate(['/customers', ApiHelper.extractId(partner.id)]); + console.log(ApiConverter.extractId(partner.id)); + this.router.navigate(['/customers', ApiConverter.extractId(partner.id)]); } protected readonly PartnerJsonld = PartnerJsonld;