| @@ -1119,11 +1119,12 @@ components: | |||||
| - string | - string | ||||
| - 'null' | - 'null' | ||||
| partner: | partner: | ||||
| anyOf: | |||||
| - | |||||
| $ref: '#/components/schemas/Partner' | |||||
| - | |||||
| type: 'null' | |||||
| 'owl:maxCardinality': 1 | |||||
| type: | |||||
| - string | |||||
| - 'null' | |||||
| format: iri-reference | |||||
| example: 'https://example.com/' | |||||
| birthday: | birthday: | ||||
| type: | type: | ||||
| - string | - string | ||||
| @@ -1179,11 +1180,12 @@ components: | |||||
| - string | - string | ||||
| - 'null' | - 'null' | ||||
| partner: | partner: | ||||
| anyOf: | |||||
| - | |||||
| $ref: '#/components/schemas/Partner.jsonhal' | |||||
| - | |||||
| type: 'null' | |||||
| 'owl:maxCardinality': 1 | |||||
| type: | |||||
| - string | |||||
| - 'null' | |||||
| format: iri-reference | |||||
| example: 'https://example.com/' | |||||
| birthday: | birthday: | ||||
| type: | type: | ||||
| - string | - string | ||||
| @@ -1253,11 +1255,12 @@ components: | |||||
| - string | - string | ||||
| - 'null' | - 'null' | ||||
| partner: | partner: | ||||
| anyOf: | |||||
| - | |||||
| $ref: '#/components/schemas/Partner.jsonld' | |||||
| - | |||||
| type: 'null' | |||||
| 'owl:maxCardinality': 1 | |||||
| type: | |||||
| - string | |||||
| - 'null' | |||||
| format: iri-reference | |||||
| example: 'https://example.com/' | |||||
| birthday: | birthday: | ||||
| type: | type: | ||||
| - string | - string | ||||
| @@ -1362,10 +1365,10 @@ components: | |||||
| type: object | type: object | ||||
| description: '' | description: '' | ||||
| deprecated: false | deprecated: false | ||||
| required: | |||||
| - name | |||||
| - type | |||||
| properties: | properties: | ||||
| id: | |||||
| readOnly: true | |||||
| type: integer | |||||
| name: | name: | ||||
| type: string | type: string | ||||
| type: | type: | ||||
| @@ -1398,13 +1401,6 @@ components: | |||||
| type: | type: | ||||
| - string | - string | ||||
| - 'null' | - 'null' | ||||
| createdAt: | |||||
| type: string | |||||
| format: date-time | |||||
| contacts: | |||||
| type: array | |||||
| items: | |||||
| $ref: '#/components/schemas/Contact' | |||||
| logo: | logo: | ||||
| 'owl:maxCardinality': 1 | 'owl:maxCardinality': 1 | ||||
| type: | type: | ||||
| @@ -1412,10 +1408,24 @@ components: | |||||
| - 'null' | - 'null' | ||||
| format: iri-reference | format: iri-reference | ||||
| example: 'https://example.com/' | 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: | Partner.jsonhal: | ||||
| type: object | type: object | ||||
| description: '' | description: '' | ||||
| deprecated: false | deprecated: false | ||||
| required: | |||||
| - name | |||||
| - type | |||||
| properties: | properties: | ||||
| _links: | _links: | ||||
| type: object | type: object | ||||
| @@ -1426,9 +1436,6 @@ components: | |||||
| href: | href: | ||||
| type: string | type: string | ||||
| format: iri-reference | format: iri-reference | ||||
| id: | |||||
| readOnly: true | |||||
| type: integer | |||||
| name: | name: | ||||
| type: string | type: string | ||||
| type: | type: | ||||
| @@ -1461,13 +1468,6 @@ components: | |||||
| type: | type: | ||||
| - string | - string | ||||
| - 'null' | - 'null' | ||||
| createdAt: | |||||
| type: string | |||||
| format: date-time | |||||
| contacts: | |||||
| type: array | |||||
| items: | |||||
| $ref: '#/components/schemas/Contact.jsonhal' | |||||
| logo: | logo: | ||||
| 'owl:maxCardinality': 1 | 'owl:maxCardinality': 1 | ||||
| type: | type: | ||||
| @@ -1475,10 +1475,24 @@ components: | |||||
| - 'null' | - 'null' | ||||
| format: iri-reference | format: iri-reference | ||||
| example: 'https://example.com/' | 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: | Partner.jsonld: | ||||
| type: object | type: object | ||||
| description: '' | description: '' | ||||
| deprecated: false | deprecated: false | ||||
| required: | |||||
| - name | |||||
| - type | |||||
| properties: | properties: | ||||
| '@context': | '@context': | ||||
| readOnly: true | readOnly: true | ||||
| @@ -1503,9 +1517,6 @@ components: | |||||
| '@type': | '@type': | ||||
| readOnly: true | readOnly: true | ||||
| type: string | type: string | ||||
| id: | |||||
| readOnly: true | |||||
| type: integer | |||||
| name: | name: | ||||
| type: string | type: string | ||||
| type: | type: | ||||
| @@ -1538,13 +1549,6 @@ components: | |||||
| type: | type: | ||||
| - string | - string | ||||
| - 'null' | - 'null' | ||||
| createdAt: | |||||
| type: string | |||||
| format: date-time | |||||
| contacts: | |||||
| type: array | |||||
| items: | |||||
| $ref: '#/components/schemas/Contact.jsonld' | |||||
| logo: | logo: | ||||
| 'owl:maxCardinality': 1 | 'owl:maxCardinality': 1 | ||||
| type: | type: | ||||
| @@ -1552,6 +1556,17 @@ components: | |||||
| - 'null' | - 'null' | ||||
| format: iri-reference | format: iri-reference | ||||
| example: 'https://example.com/' | 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: | Post: | ||||
| type: object | type: object | ||||
| description: '' | 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 { DocumentsComponent } from './documents/documents.component'; | ||||
| import { NewContactComponent } from './partners/new-contact/new-contact.component'; | import { NewContactComponent } from './partners/new-contact/new-contact.component'; | ||||
| import { ModalComponent } from './_components/modal/modal.component'; | import { ModalComponent } from './_components/modal/modal.component'; | ||||
| import {PropertyInterceptor} from "@app/_helpers/property.interceptor"; | |||||
| export function apiConfigFactory(): Configuration { | export function apiConfigFactory(): Configuration { | ||||
| const params: ConfigurationParameters = { | const params: ConfigurationParameters = { | ||||
| @@ -74,6 +75,7 @@ export function HttpLoaderFactory(http: HttpClient) { | |||||
| providers: [ | providers: [ | ||||
| {provide: HTTP_INTERCEPTORS, useClass: JwtInterceptor, multi: true}, | {provide: HTTP_INTERCEPTORS, useClass: JwtInterceptor, multi: true}, | ||||
| {provide: HTTP_INTERCEPTORS, useClass: ErrorInterceptor, multi: true}, | {provide: HTTP_INTERCEPTORS, useClass: ErrorInterceptor, multi: true}, | ||||
| {provide: HTTP_INTERCEPTORS, useClass: PropertyInterceptor, multi: true}, | |||||
| ], | ], | ||||
| bootstrap: [AppComponent] | bootstrap: [AppComponent] | ||||
| @@ -9,7 +9,6 @@ | |||||
| * https://openapi-generator.tech | * https://openapi-generator.tech | ||||
| * Do not edit the class manually. | * Do not edit the class manually. | ||||
| */ | */ | ||||
| import { Partner } from './partner'; | |||||
| /** | /** | ||||
| @@ -18,7 +17,7 @@ import { Partner } from './partner'; | |||||
| export interface Contact { | export interface Contact { | ||||
| firstName: string | null; | firstName: string | null; | ||||
| lastName: string | null; | lastName: string | null; | ||||
| partner?: Partner | null; | |||||
| partner?: string | null; | |||||
| birthday?: string | null; | birthday?: string | null; | ||||
| image?: string | null; | image?: string | null; | ||||
| position?: string | null; | position?: string | null; | ||||
| @@ -10,7 +10,6 @@ | |||||
| * Do not edit the class manually. | * Do not edit the class manually. | ||||
| */ | */ | ||||
| import { ContactJsonhalLinks } from './contactJsonhalLinks'; | import { ContactJsonhalLinks } from './contactJsonhalLinks'; | ||||
| import { PartnerJsonhal } from './partnerJsonhal'; | |||||
| /** | /** | ||||
| @@ -20,7 +19,7 @@ export interface ContactJsonhal { | |||||
| _links?: ContactJsonhalLinks; | _links?: ContactJsonhalLinks; | ||||
| firstName: string | null; | firstName: string | null; | ||||
| lastName: string | null; | lastName: string | null; | ||||
| partner?: PartnerJsonhal | null; | |||||
| partner?: string | null; | |||||
| birthday?: string | null; | birthday?: string | null; | ||||
| image?: string | null; | image?: string | null; | ||||
| position?: string | null; | position?: string | null; | ||||
| @@ -9,7 +9,6 @@ | |||||
| * https://openapi-generator.tech | * https://openapi-generator.tech | ||||
| * Do not edit the class manually. | * Do not edit the class manually. | ||||
| */ | */ | ||||
| import { PartnerJsonld } from './partnerJsonld'; | |||||
| /** | /** | ||||
| @@ -21,7 +20,7 @@ export interface ContactJsonld { | |||||
| readonly type?: string; | readonly type?: string; | ||||
| firstName: string | null; | firstName: string | null; | ||||
| lastName: string | null; | lastName: string | null; | ||||
| partner?: PartnerJsonld | null; | |||||
| partner?: string | null; | |||||
| birthday?: string | null; | birthday?: string | null; | ||||
| image?: string | null; | image?: string | null; | ||||
| position?: string | null; | position?: string | null; | ||||
| @@ -9,25 +9,23 @@ | |||||
| * https://openapi-generator.tech | * https://openapi-generator.tech | ||||
| * Do not edit the class manually. | * Do not edit the class manually. | ||||
| */ | */ | ||||
| import { Contact } from './contact'; | |||||
| /** | /** | ||||
| * | * | ||||
| */ | */ | ||||
| export interface Partner { | export interface Partner { | ||||
| readonly id?: number; | |||||
| name?: string; | |||||
| type?: Partner.TypeEnum; | |||||
| name: string; | |||||
| type: Partner.TypeEnum; | |||||
| street?: string | null; | street?: string | null; | ||||
| streetNo?: string | null; | streetNo?: string | null; | ||||
| zip?: string | null; | zip?: string | null; | ||||
| city?: string | null; | city?: string | null; | ||||
| country?: string | null; | country?: string | null; | ||||
| website?: string | null; | website?: string | null; | ||||
| createdAt?: string; | |||||
| contacts?: Array<Contact>; | |||||
| logo?: string | null; | logo?: string | null; | ||||
| createdAt?: string | null; | |||||
| contacts?: Array<string>; | |||||
| } | } | ||||
| export namespace Partner { | export namespace Partner { | ||||
| export type TypeEnum = 'customer' | 'supplier' | 'service'; | export type TypeEnum = 'customer' | 'supplier' | 'service'; | ||||
| @@ -10,7 +10,6 @@ | |||||
| * Do not edit the class manually. | * Do not edit the class manually. | ||||
| */ | */ | ||||
| import { ContactJsonhalLinks } from './contactJsonhalLinks'; | import { ContactJsonhalLinks } from './contactJsonhalLinks'; | ||||
| import { ContactJsonhal } from './contactJsonhal'; | |||||
| /** | /** | ||||
| @@ -18,18 +17,17 @@ import { ContactJsonhal } from './contactJsonhal'; | |||||
| */ | */ | ||||
| export interface PartnerJsonhal { | export interface PartnerJsonhal { | ||||
| _links?: ContactJsonhalLinks; | _links?: ContactJsonhalLinks; | ||||
| readonly id?: number; | |||||
| name?: string; | |||||
| type?: PartnerJsonhal.TypeEnum; | |||||
| name: string; | |||||
| type: PartnerJsonhal.TypeEnum; | |||||
| street?: string | null; | street?: string | null; | ||||
| streetNo?: string | null; | streetNo?: string | null; | ||||
| zip?: string | null; | zip?: string | null; | ||||
| city?: string | null; | city?: string | null; | ||||
| country?: string | null; | country?: string | null; | ||||
| website?: string | null; | website?: string | null; | ||||
| createdAt?: string; | |||||
| contacts?: Array<ContactJsonhal>; | |||||
| logo?: string | null; | logo?: string | null; | ||||
| createdAt?: string | null; | |||||
| contacts?: Array<string>; | |||||
| } | } | ||||
| export namespace PartnerJsonhal { | export namespace PartnerJsonhal { | ||||
| export type TypeEnum = 'customer' | 'supplier' | 'service'; | export type TypeEnum = 'customer' | 'supplier' | 'service'; | ||||
| @@ -9,7 +9,6 @@ | |||||
| * https://openapi-generator.tech | * https://openapi-generator.tech | ||||
| * Do not edit the class manually. | * Do not edit the class manually. | ||||
| */ | */ | ||||
| import { ContactJsonld } from './contactJsonld'; | |||||
| /** | /** | ||||
| @@ -17,18 +16,18 @@ import { ContactJsonld } from './contactJsonld'; | |||||
| */ | */ | ||||
| export interface PartnerJsonld { | export interface PartnerJsonld { | ||||
| context?: string | null; | context?: string | null; | ||||
| readonly id?: number; | |||||
| name?: string; | |||||
| type?: PartnerJsonld.TypeEnum; | |||||
| readonly id?: string; | |||||
| name: string; | |||||
| type: PartnerJsonld.TypeEnum; | |||||
| street?: string | null; | street?: string | null; | ||||
| streetNo?: string | null; | streetNo?: string | null; | ||||
| zip?: string | null; | zip?: string | null; | ||||
| city?: string | null; | city?: string | null; | ||||
| country?: string | null; | country?: string | null; | ||||
| website?: string | null; | website?: string | null; | ||||
| createdAt?: string; | |||||
| contacts?: Array<ContactJsonld>; | |||||
| logo?: string | null; | logo?: string | null; | ||||
| createdAt?: string | null; | |||||
| contacts?: Array<string>; | |||||
| } | } | ||||
| export namespace PartnerJsonld { | export namespace PartnerJsonld { | ||||
| export type TypeEnum = 'customer' | 'supplier' | 'service'; | export type TypeEnum = 'customer' | 'supplier' | 'service'; | ||||
| @@ -36,7 +36,7 @@ export class PartnersDetailComponent implements OnInit { | |||||
| ) { | ) { | ||||
| this.id = ""; | this.id = ""; | ||||
| this.partnerDetailSub = new Subscription(); | this.partnerDetailSub = new Subscription(); | ||||
| this.partner = {}; | |||||
| this.partner = {} as PartnerJsonld; | |||||
| this.partnerLogoSub = new Subscription(); | this.partnerLogoSub = new Subscription(); | ||||
| this.partnerLogo = ""; | this.partnerLogo = ""; | ||||
| this.partnerContactsSub = new Subscription(); | this.partnerContactsSub = new Subscription(); | ||||
| @@ -6,6 +6,7 @@ import {Subscription} from "rxjs"; | |||||
| import {PartnerJsonld, PartnerService} from "@app/core/api/v1"; | import {PartnerJsonld, PartnerService} from "@app/core/api/v1"; | ||||
| import {MatPaginator, MatPaginatorIntl, MatPaginatorModule, PageEvent} from "@angular/material/paginator"; | import {MatPaginator, MatPaginatorIntl, MatPaginatorModule, PageEvent} from "@angular/material/paginator"; | ||||
| import {OrderFilter} from "@app/_models/orderFilter"; | import {OrderFilter} from "@app/_models/orderFilter"; | ||||
| import {ApiHelper} from "@app/_helpers/api.helper"; | |||||
| @Component({ | @Component({ | ||||
| selector: 'app-partners', | selector: 'app-partners', | ||||
| @@ -124,8 +125,13 @@ export class PartnersComponent implements OnInit, AfterViewInit { | |||||
| this.getData(); | this.getData(); | ||||
| } | } | ||||
| navigateToDetails(partner: any) { | |||||
| navigateToDetails(element: any) { | |||||
| const partner: PartnerJsonld = element as PartnerJsonld; | |||||
| // this.partnerService.setPartnerData(partner); | // 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; | |||||
| } | } | ||||