| @@ -1119,11 +1119,12 @@ components: | |||
| - string | |||
| - 'null' | |||
| partner: | |||
| anyOf: | |||
| - | |||
| $ref: '#/components/schemas/Partner' | |||
| - | |||
| type: 'null' | |||
| 'owl:maxCardinality': 1 | |||
| type: | |||
| - string | |||
| - 'null' | |||
| format: iri-reference | |||
| example: 'https://example.com/' | |||
| birthday: | |||
| type: | |||
| - string | |||
| @@ -1179,11 +1180,12 @@ components: | |||
| - string | |||
| - 'null' | |||
| partner: | |||
| anyOf: | |||
| - | |||
| $ref: '#/components/schemas/Partner.jsonhal' | |||
| - | |||
| type: 'null' | |||
| 'owl:maxCardinality': 1 | |||
| type: | |||
| - string | |||
| - 'null' | |||
| format: iri-reference | |||
| example: 'https://example.com/' | |||
| birthday: | |||
| type: | |||
| - string | |||
| @@ -1253,11 +1255,12 @@ components: | |||
| - string | |||
| - 'null' | |||
| partner: | |||
| anyOf: | |||
| - | |||
| $ref: '#/components/schemas/Partner.jsonld' | |||
| - | |||
| type: 'null' | |||
| 'owl:maxCardinality': 1 | |||
| type: | |||
| - string | |||
| - 'null' | |||
| format: iri-reference | |||
| example: 'https://example.com/' | |||
| birthday: | |||
| type: | |||
| - string | |||
| @@ -1362,10 +1365,10 @@ components: | |||
| type: object | |||
| description: '' | |||
| deprecated: false | |||
| required: | |||
| - name | |||
| - type | |||
| properties: | |||
| id: | |||
| readOnly: true | |||
| type: integer | |||
| name: | |||
| type: string | |||
| type: | |||
| @@ -1398,13 +1401,6 @@ components: | |||
| type: | |||
| - string | |||
| - 'null' | |||
| createdAt: | |||
| type: string | |||
| format: date-time | |||
| contacts: | |||
| type: array | |||
| items: | |||
| $ref: '#/components/schemas/Contact' | |||
| logo: | |||
| 'owl:maxCardinality': 1 | |||
| type: | |||
| @@ -1412,10 +1408,24 @@ components: | |||
| - 'null' | |||
| format: iri-reference | |||
| example: 'https://example.com/' | |||
| createdAt: | |||
| type: | |||
| - string | |||
| - 'null' | |||
| format: date-time | |||
| contacts: | |||
| type: array | |||
| items: | |||
| type: string | |||
| format: iri-reference | |||
| example: 'https://example.com/' | |||
| Partner.jsonhal: | |||
| type: object | |||
| description: '' | |||
| deprecated: false | |||
| required: | |||
| - name | |||
| - type | |||
| properties: | |||
| _links: | |||
| type: object | |||
| @@ -1426,9 +1436,6 @@ components: | |||
| href: | |||
| type: string | |||
| format: iri-reference | |||
| id: | |||
| readOnly: true | |||
| type: integer | |||
| name: | |||
| type: string | |||
| type: | |||
| @@ -1461,13 +1468,6 @@ components: | |||
| type: | |||
| - string | |||
| - 'null' | |||
| createdAt: | |||
| type: string | |||
| format: date-time | |||
| contacts: | |||
| type: array | |||
| items: | |||
| $ref: '#/components/schemas/Contact.jsonhal' | |||
| logo: | |||
| 'owl:maxCardinality': 1 | |||
| type: | |||
| @@ -1475,10 +1475,24 @@ components: | |||
| - 'null' | |||
| format: iri-reference | |||
| example: 'https://example.com/' | |||
| createdAt: | |||
| type: | |||
| - string | |||
| - 'null' | |||
| format: date-time | |||
| contacts: | |||
| type: array | |||
| items: | |||
| type: string | |||
| format: iri-reference | |||
| example: 'https://example.com/' | |||
| Partner.jsonld: | |||
| type: object | |||
| description: '' | |||
| deprecated: false | |||
| required: | |||
| - name | |||
| - type | |||
| properties: | |||
| '@context': | |||
| readOnly: true | |||
| @@ -1503,9 +1517,6 @@ components: | |||
| '@type': | |||
| readOnly: true | |||
| type: string | |||
| id: | |||
| readOnly: true | |||
| type: integer | |||
| name: | |||
| type: string | |||
| type: | |||
| @@ -1538,13 +1549,6 @@ components: | |||
| type: | |||
| - string | |||
| - 'null' | |||
| createdAt: | |||
| type: string | |||
| format: date-time | |||
| contacts: | |||
| type: array | |||
| items: | |||
| $ref: '#/components/schemas/Contact.jsonld' | |||
| logo: | |||
| 'owl:maxCardinality': 1 | |||
| type: | |||
| @@ -1552,6 +1556,17 @@ components: | |||
| - 'null' | |||
| format: iri-reference | |||
| example: 'https://example.com/' | |||
| createdAt: | |||
| type: | |||
| - string | |||
| - 'null' | |||
| format: date-time | |||
| contacts: | |||
| type: array | |||
| items: | |||
| type: string | |||
| format: iri-reference | |||
| example: 'https://example.com/' | |||
| Post: | |||
| type: object | |||
| description: '' | |||
| @@ -0,0 +1,13 @@ | |||
| export class ApiHelper { | |||
| public static extractId(iri: string | undefined) { | |||
| if (iri !== undefined) { | |||
| const iriRegex = /\/(\d+)$/; | |||
| const match = iri.match(iriRegex); | |||
| if (match && match[1]) { | |||
| return match[1]; | |||
| } | |||
| } | |||
| return undefined; | |||
| } | |||
| } | |||
| @@ -0,0 +1,59 @@ | |||
| // property.interceptor.ts | |||
| import { Injectable } from '@angular/core'; | |||
| import { | |||
| HttpInterceptor, | |||
| HttpRequest, | |||
| HttpHandler, | |||
| HttpEvent, HttpResponse, | |||
| } from '@angular/common/http'; | |||
| import { Observable } from 'rxjs'; | |||
| import { map } from 'rxjs/operators'; | |||
| @Injectable() | |||
| export class PropertyInterceptor implements HttpInterceptor { | |||
| intercept( | |||
| request: HttpRequest<any>, | |||
| next: HttpHandler | |||
| ): Observable<HttpEvent<any>> { | |||
| return next.handle(request).pipe( | |||
| map((event) => { | |||
| if (event instanceof HttpResponse && event.body) { | |||
| let modifiedBody; | |||
| if (event.body['hydra:member']) { | |||
| modifiedBody = { | |||
| ...event.body, | |||
| 'hydra:member': this.mapDataItems( | |||
| event.body['hydra:member'] | |||
| ), | |||
| }; | |||
| } else { | |||
| // Wenn keine 'hydra:member' vorhanden ist, betrachte das gesamte Objekt | |||
| modifiedBody = this.mapDataItem(event.body); | |||
| } | |||
| return event.clone({ | |||
| body: modifiedBody, | |||
| }); | |||
| } | |||
| return event; | |||
| }) | |||
| ); | |||
| } | |||
| private mapDataItems(items: any[]): any[] { | |||
| return items.map((item) => this.mapDataItem(item)); | |||
| } | |||
| private mapDataItem(item: any): any { | |||
| if (item && item['@id']) { | |||
| return { | |||
| ...item, | |||
| id: item['@id'], | |||
| }; | |||
| } | |||
| return item; | |||
| } | |||
| } | |||
| @@ -24,6 +24,7 @@ import { ProductsDetailComponent } from './products/products-detail/products-det | |||
| import { DocumentsComponent } from './documents/documents.component'; | |||
| import { NewContactComponent } from './partners/new-contact/new-contact.component'; | |||
| import { ModalComponent } from './_components/modal/modal.component'; | |||
| import {PropertyInterceptor} from "@app/_helpers/property.interceptor"; | |||
| export function apiConfigFactory(): Configuration { | |||
| const params: ConfigurationParameters = { | |||
| @@ -74,6 +75,7 @@ export function HttpLoaderFactory(http: HttpClient) { | |||
| providers: [ | |||
| {provide: HTTP_INTERCEPTORS, useClass: JwtInterceptor, multi: true}, | |||
| {provide: HTTP_INTERCEPTORS, useClass: ErrorInterceptor, multi: true}, | |||
| {provide: HTTP_INTERCEPTORS, useClass: PropertyInterceptor, multi: true}, | |||
| ], | |||
| bootstrap: [AppComponent] | |||
| @@ -9,7 +9,6 @@ | |||
| * https://openapi-generator.tech | |||
| * Do not edit the class manually. | |||
| */ | |||
| import { Partner } from './partner'; | |||
| /** | |||
| @@ -18,7 +17,7 @@ import { Partner } from './partner'; | |||
| export interface Contact { | |||
| firstName: string | null; | |||
| lastName: string | null; | |||
| partner?: Partner | null; | |||
| partner?: string | null; | |||
| birthday?: string | null; | |||
| image?: string | null; | |||
| position?: string | null; | |||
| @@ -10,7 +10,6 @@ | |||
| * Do not edit the class manually. | |||
| */ | |||
| import { ContactJsonhalLinks } from './contactJsonhalLinks'; | |||
| import { PartnerJsonhal } from './partnerJsonhal'; | |||
| /** | |||
| @@ -20,7 +19,7 @@ export interface ContactJsonhal { | |||
| _links?: ContactJsonhalLinks; | |||
| firstName: string | null; | |||
| lastName: string | null; | |||
| partner?: PartnerJsonhal | null; | |||
| partner?: string | null; | |||
| birthday?: string | null; | |||
| image?: string | null; | |||
| position?: string | null; | |||
| @@ -9,7 +9,6 @@ | |||
| * https://openapi-generator.tech | |||
| * Do not edit the class manually. | |||
| */ | |||
| import { PartnerJsonld } from './partnerJsonld'; | |||
| /** | |||
| @@ -21,7 +20,7 @@ export interface ContactJsonld { | |||
| readonly type?: string; | |||
| firstName: string | null; | |||
| lastName: string | null; | |||
| partner?: PartnerJsonld | null; | |||
| partner?: string | null; | |||
| birthday?: string | null; | |||
| image?: string | null; | |||
| position?: string | null; | |||
| @@ -9,25 +9,23 @@ | |||
| * https://openapi-generator.tech | |||
| * Do not edit the class manually. | |||
| */ | |||
| import { Contact } from './contact'; | |||
| /** | |||
| * | |||
| */ | |||
| export interface Partner { | |||
| readonly id?: number; | |||
| name?: string; | |||
| type?: Partner.TypeEnum; | |||
| name: string; | |||
| type: Partner.TypeEnum; | |||
| street?: string | null; | |||
| streetNo?: string | null; | |||
| zip?: string | null; | |||
| city?: string | null; | |||
| country?: string | null; | |||
| website?: string | null; | |||
| createdAt?: string; | |||
| contacts?: Array<Contact>; | |||
| logo?: string | null; | |||
| createdAt?: string | null; | |||
| contacts?: Array<string>; | |||
| } | |||
| export namespace Partner { | |||
| export type TypeEnum = 'customer' | 'supplier' | 'service'; | |||
| @@ -10,7 +10,6 @@ | |||
| * Do not edit the class manually. | |||
| */ | |||
| import { ContactJsonhalLinks } from './contactJsonhalLinks'; | |||
| import { ContactJsonhal } from './contactJsonhal'; | |||
| /** | |||
| @@ -18,18 +17,17 @@ import { ContactJsonhal } from './contactJsonhal'; | |||
| */ | |||
| export interface PartnerJsonhal { | |||
| _links?: ContactJsonhalLinks; | |||
| readonly id?: number; | |||
| name?: string; | |||
| type?: PartnerJsonhal.TypeEnum; | |||
| name: string; | |||
| type: PartnerJsonhal.TypeEnum; | |||
| street?: string | null; | |||
| streetNo?: string | null; | |||
| zip?: string | null; | |||
| city?: string | null; | |||
| country?: string | null; | |||
| website?: string | null; | |||
| createdAt?: string; | |||
| contacts?: Array<ContactJsonhal>; | |||
| logo?: string | null; | |||
| createdAt?: string | null; | |||
| contacts?: Array<string>; | |||
| } | |||
| export namespace PartnerJsonhal { | |||
| export type TypeEnum = 'customer' | 'supplier' | 'service'; | |||
| @@ -9,7 +9,6 @@ | |||
| * https://openapi-generator.tech | |||
| * Do not edit the class manually. | |||
| */ | |||
| import { ContactJsonld } from './contactJsonld'; | |||
| /** | |||
| @@ -17,18 +16,18 @@ import { ContactJsonld } from './contactJsonld'; | |||
| */ | |||
| export interface PartnerJsonld { | |||
| context?: string | null; | |||
| readonly id?: number; | |||
| name?: string; | |||
| type?: PartnerJsonld.TypeEnum; | |||
| readonly id?: string; | |||
| name: string; | |||
| type: PartnerJsonld.TypeEnum; | |||
| street?: string | null; | |||
| streetNo?: string | null; | |||
| zip?: string | null; | |||
| city?: string | null; | |||
| country?: string | null; | |||
| website?: string | null; | |||
| createdAt?: string; | |||
| contacts?: Array<ContactJsonld>; | |||
| logo?: string | null; | |||
| createdAt?: string | null; | |||
| contacts?: Array<string>; | |||
| } | |||
| export namespace PartnerJsonld { | |||
| export type TypeEnum = 'customer' | 'supplier' | 'service'; | |||
| @@ -36,7 +36,7 @@ export class PartnersDetailComponent implements OnInit { | |||
| ) { | |||
| this.id = ""; | |||
| this.partnerDetailSub = new Subscription(); | |||
| this.partner = {}; | |||
| this.partner = {} as PartnerJsonld; | |||
| this.partnerLogoSub = new Subscription(); | |||
| this.partnerLogo = ""; | |||
| this.partnerContactsSub = new Subscription(); | |||
| @@ -6,6 +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"; | |||
| @Component({ | |||
| selector: 'app-partners', | |||
| @@ -124,8 +125,13 @@ export class PartnersComponent implements OnInit, AfterViewInit { | |||
| this.getData(); | |||
| } | |||
| navigateToDetails(partner: any) { | |||
| navigateToDetails(element: any) { | |||
| const partner: PartnerJsonld = element as PartnerJsonld; | |||
| // this.partnerService.setPartnerData(partner); | |||
| this.router.navigate(['/customers', partner.name]); | |||
| //console.log(partner['@id']); | |||
| console.log(ApiHelper.extractId(partner.id)); | |||
| this.router.navigate(['/customers', ApiHelper.extractId(partner.id)]); | |||
| } | |||
| protected readonly PartnerJsonld = PartnerJsonld; | |||
| } | |||