| @@ -2052,8 +2052,6 @@ components: | |||
| type: object | |||
| description: '' | |||
| deprecated: false | |||
| externalDocs: | |||
| url: 'https://schema.org/MediaObject' | |||
| properties: | |||
| '@context': | |||
| readOnly: true | |||
| @@ -2078,32 +2076,28 @@ components: | |||
| '@type': | |||
| readOnly: true | |||
| type: string | |||
| id: | |||
| dbId: | |||
| readOnly: true | |||
| type: integer | |||
| type: | |||
| - integer | |||
| - 'null' | |||
| contentUrl: | |||
| externalDocs: | |||
| url: 'https://schema.org/contentUrl' | |||
| type: | |||
| - string | |||
| - 'null' | |||
| file: | |||
| type: | |||
| - string | |||
| - 'null' | |||
| format: binary | |||
| filePath: | |||
| readOnly: true | |||
| type: | |||
| - string | |||
| - 'null' | |||
| createdBy: | |||
| $ref: '#/components/schemas/User.jsonld' | |||
| createdAt: | |||
| readOnly: true | |||
| type: string | |||
| type: | |||
| - string | |||
| - 'null' | |||
| format: date-time | |||
| required: | |||
| - file | |||
| ShippingCompany: | |||
| type: object | |||
| description: '' | |||
| @@ -2941,10 +2935,9 @@ components: | |||
| headers: { } | |||
| securitySchemes: | |||
| JWT: | |||
| type: apiKey | |||
| description: 'Value for the Authorization header parameter.' | |||
| name: Authorization | |||
| in: header | |||
| type: http | |||
| scheme: bearer | |||
| bearerFormat: JWT | |||
| security: | |||
| - | |||
| JWT: [] | |||
| @@ -17,11 +17,9 @@ export const locationJsonldForm = new FormGroup({ | |||
| }); | |||
| export const mediaObjectJsonldForm = new FormGroup({ | |||
| id: new FormControl(null, []), | |||
| dbId: new FormControl(null, []), | |||
| contentUrl: new FormControl(null, []), | |||
| file: new FormControl(null, [Validators.required]), | |||
| filePath: new FormControl(null, []), | |||
| createdBy: new FormControl(null, []), | |||
| createdAt: new FormControl(null, []) | |||
| }); | |||
| @@ -6,7 +6,8 @@ import { map } from 'rxjs/operators'; | |||
| import { environment } from '@environments/environment'; | |||
| import { User } from '@app/_models'; | |||
| import {LoginCheckService} from "@app/core/api/v1"; | |||
| import {AuthService} from "@app/core/api/v1"; | |||
| @Injectable({ providedIn: 'root' }) | |||
| export class AccountService { | |||
| @@ -17,7 +18,7 @@ export class AccountService { | |||
| constructor( | |||
| private router: Router, | |||
| private http: HttpClient, | |||
| private loginCheckService: LoginCheckService | |||
| private loginCheckService: AuthService | |||
| ) { | |||
| this.userSubject = new BehaviorSubject(JSON.parse(localStorage.getItem('user')!)); | |||
| this.user = this.userSubject.asObservable(); | |||
| @@ -28,13 +29,15 @@ export class AccountService { | |||
| } | |||
| login(email: string, password: string) { | |||
| return this.loginCheckService.checkPost( | |||
| return this.loginCheckService.postCredentialsItem( | |||
| { email, password } | |||
| ).pipe(map(user => { | |||
| ).pipe(map(authResponse => { | |||
| // store user details and jwt token in local storage to keep user logged in between page refreshes | |||
| localStorage.setItem('user', JSON.stringify(user)); | |||
| this.userSubject.next(user); | |||
| return user; | |||
| localStorage.setItem('user', JSON.stringify(authResponse.user)); | |||
| if (authResponse.user) { | |||
| this.userSubject.next(authResponse.user); | |||
| } | |||
| return authResponse.user; | |||
| })); | |||
| // | |||
| // return this.http.post<User>(`${environment.apiUrl}/auth`, { email, password }) | |||
| @@ -1,4 +1,5 @@ | |||
| .gitignore | |||
| .openapi-generator-ignore | |||
| README.md | |||
| api.module.ts | |||
| api/api.ts | |||
| @@ -139,7 +139,7 @@ export class LocationService { | |||
| // authentication (JWT) required | |||
| localVarCredential = this.configuration.lookupCredential('JWT'); | |||
| if (localVarCredential) { | |||
| localVarHeaders = localVarHeaders.set('Authorization', localVarCredential); | |||
| localVarHeaders = localVarHeaders.set('Authorization', 'Bearer ' + localVarCredential); | |||
| } | |||
| let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept; | |||
| @@ -212,7 +212,7 @@ export class LocationService { | |||
| // authentication (JWT) required | |||
| localVarCredential = this.configuration.lookupCredential('JWT'); | |||
| if (localVarCredential) { | |||
| localVarHeaders = localVarHeaders.set('Authorization', localVarCredential); | |||
| localVarHeaders = localVarHeaders.set('Authorization', 'Bearer ' + localVarCredential); | |||
| } | |||
| let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept; | |||
| @@ -283,7 +283,7 @@ export class LocationService { | |||
| // authentication (JWT) required | |||
| localVarCredential = this.configuration.lookupCredential('JWT'); | |||
| if (localVarCredential) { | |||
| localVarHeaders = localVarHeaders.set('Authorization', localVarCredential); | |||
| localVarHeaders = localVarHeaders.set('Authorization', 'Bearer ' + localVarCredential); | |||
| } | |||
| let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept; | |||
| @@ -359,7 +359,7 @@ export class LocationService { | |||
| // authentication (JWT) required | |||
| localVarCredential = this.configuration.lookupCredential('JWT'); | |||
| if (localVarCredential) { | |||
| localVarHeaders = localVarHeaders.set('Authorization', localVarCredential); | |||
| localVarHeaders = localVarHeaders.set('Authorization', 'Bearer ' + localVarCredential); | |||
| } | |||
| let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept; | |||
| @@ -441,7 +441,7 @@ export class LocationService { | |||
| // authentication (JWT) required | |||
| localVarCredential = this.configuration.lookupCredential('JWT'); | |||
| if (localVarCredential) { | |||
| localVarHeaders = localVarHeaders.set('Authorization', localVarCredential); | |||
| localVarHeaders = localVarHeaders.set('Authorization', 'Bearer ' + localVarCredential); | |||
| } | |||
| let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept; | |||
| @@ -1,178 +0,0 @@ | |||
| /** | |||
| * Imaq Platform | |||
| * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) | |||
| * | |||
| * The version of the OpenAPI document: 1.0.0 | |||
| * | |||
| * | |||
| * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). | |||
| * https://openapi-generator.tech | |||
| * Do not edit the class manually. | |||
| */ | |||
| /* tslint:disable:no-unused-variable member-ordering */ | |||
| import { Inject, Injectable, Optional } from '@angular/core'; | |||
| import { HttpClient, HttpHeaders, HttpParams, | |||
| HttpResponse, HttpEvent, HttpParameterCodec, HttpContext | |||
| } from '@angular/common/http'; | |||
| import { CustomHttpParameterCodec } from '../encoder'; | |||
| import { Observable } from 'rxjs'; | |||
| // @ts-ignore | |||
| import { LoginCheckPost200Response } from '../model/loginCheckPost200Response'; | |||
| // @ts-ignore | |||
| import { LoginCheckPostRequest } from '../model/loginCheckPostRequest'; | |||
| // @ts-ignore | |||
| import { BASE_PATH, COLLECTION_FORMATS } from '../variables'; | |||
| import { Configuration } from '../configuration'; | |||
| @Injectable({ | |||
| providedIn: 'root' | |||
| }) | |||
| export class LoginCheckService { | |||
| protected basePath = 'http://localhost'; | |||
| public defaultHeaders = new HttpHeaders(); | |||
| public configuration = new Configuration(); | |||
| public encoder: HttpParameterCodec; | |||
| constructor(protected httpClient: HttpClient, @Optional()@Inject(BASE_PATH) basePath: string|string[], @Optional() configuration: Configuration) { | |||
| if (configuration) { | |||
| this.configuration = configuration; | |||
| } | |||
| if (typeof this.configuration.basePath !== 'string') { | |||
| if (Array.isArray(basePath) && basePath.length > 0) { | |||
| basePath = basePath[0]; | |||
| } | |||
| if (typeof basePath !== 'string') { | |||
| basePath = this.basePath; | |||
| } | |||
| this.configuration.basePath = basePath; | |||
| } | |||
| this.encoder = this.configuration.encoder || new CustomHttpParameterCodec(); | |||
| } | |||
| // @ts-ignore | |||
| private addToHttpParams(httpParams: HttpParams, value: any, key?: string): HttpParams { | |||
| if (typeof value === "object" && value instanceof Date === false) { | |||
| httpParams = this.addToHttpParamsRecursive(httpParams, value); | |||
| } else { | |||
| httpParams = this.addToHttpParamsRecursive(httpParams, value, key); | |||
| } | |||
| return httpParams; | |||
| } | |||
| private addToHttpParamsRecursive(httpParams: HttpParams, value?: any, key?: string): HttpParams { | |||
| if (value == null) { | |||
| return httpParams; | |||
| } | |||
| if (typeof value === "object") { | |||
| if (Array.isArray(value)) { | |||
| (value as any[]).forEach( elem => httpParams = this.addToHttpParamsRecursive(httpParams, elem, key)); | |||
| } else if (value instanceof Date) { | |||
| if (key != null) { | |||
| httpParams = httpParams.append(key, (value as Date).toISOString().substring(0, 10)); | |||
| } else { | |||
| throw Error("key may not be null if value is Date"); | |||
| } | |||
| } else { | |||
| Object.keys(value).forEach( k => httpParams = this.addToHttpParamsRecursive( | |||
| httpParams, value[k], key != null ? `${key}.${k}` : k)); | |||
| } | |||
| } else if (key != null) { | |||
| httpParams = httpParams.append(key, value); | |||
| } else { | |||
| throw Error("key may not be null if value is not object or array"); | |||
| } | |||
| return httpParams; | |||
| } | |||
| /** | |||
| * Creates a user token. | |||
| * Creates a user token. | |||
| * @param loginCheckPostRequest The login data | |||
| * @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 checkPost(loginCheckPostRequest: LoginCheckPostRequest, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<LoginCheckPost200Response>; | |||
| public checkPost(loginCheckPostRequest: LoginCheckPostRequest, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpResponse<LoginCheckPost200Response>>; | |||
| public checkPost(loginCheckPostRequest: LoginCheckPostRequest, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpEvent<LoginCheckPost200Response>>; | |||
| public checkPost(loginCheckPostRequest: LoginCheckPostRequest, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<any> { | |||
| if (loginCheckPostRequest === null || loginCheckPostRequest === undefined) { | |||
| throw new Error('Required parameter loginCheckPostRequest was null or undefined when calling checkPost.'); | |||
| } | |||
| let localVarHeaders = this.defaultHeaders; | |||
| let localVarCredential: string | undefined; | |||
| // authentication (JWT) required | |||
| localVarCredential = this.configuration.lookupCredential('JWT'); | |||
| if (localVarCredential) { | |||
| localVarHeaders = localVarHeaders.set('Authorization', 'Bearer ' + localVarCredential); | |||
| } | |||
| let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept; | |||
| if (localVarHttpHeaderAcceptSelected === undefined) { | |||
| // to determine the Accept header | |||
| const httpHeaderAccepts: string[] = [ | |||
| 'application/json' | |||
| ]; | |||
| localVarHttpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts); | |||
| } | |||
| if (localVarHttpHeaderAcceptSelected !== undefined) { | |||
| localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected); | |||
| } | |||
| let localVarHttpContext: HttpContext | undefined = options && options.context; | |||
| if (localVarHttpContext === undefined) { | |||
| localVarHttpContext = new HttpContext(); | |||
| } | |||
| let localVarTransferCache: boolean | undefined = options && options.transferCache; | |||
| if (localVarTransferCache === undefined) { | |||
| localVarTransferCache = true; | |||
| } | |||
| // to determine the Content-Type header | |||
| const consumes: string[] = [ | |||
| 'application/json' | |||
| ]; | |||
| const httpContentTypeSelected: string | undefined = this.configuration.selectHeaderContentType(consumes); | |||
| if (httpContentTypeSelected !== undefined) { | |||
| localVarHeaders = localVarHeaders.set('Content-Type', httpContentTypeSelected); | |||
| } | |||
| let responseType_: 'text' | 'json' | 'blob' = 'json'; | |||
| if (localVarHttpHeaderAcceptSelected) { | |||
| if (localVarHttpHeaderAcceptSelected.startsWith('text')) { | |||
| responseType_ = 'text'; | |||
| } else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) { | |||
| responseType_ = 'json'; | |||
| } else { | |||
| responseType_ = 'blob'; | |||
| } | |||
| } | |||
| let localVarPath = `/api/auth`; | |||
| return this.httpClient.request<LoginCheckPost200Response>('post', `${this.configuration.basePath}${localVarPath}`, | |||
| { | |||
| context: localVarHttpContext, | |||
| body: loginCheckPostRequest, | |||
| responseType: <any>responseType_, | |||
| withCredentials: this.configuration.withCredentials, | |||
| headers: localVarHeaders, | |||
| observe: observe, | |||
| transferCache: localVarTransferCache, | |||
| reportProgress: reportProgress | |||
| } | |||
| ); | |||
| } | |||
| } | |||
| @@ -135,7 +135,7 @@ export class MediaObjectService { | |||
| // authentication (JWT) required | |||
| localVarCredential = this.configuration.lookupCredential('JWT'); | |||
| if (localVarCredential) { | |||
| localVarHeaders = localVarHeaders.set('Authorization', localVarCredential); | |||
| localVarHeaders = localVarHeaders.set('Authorization', 'Bearer ' + localVarCredential); | |||
| } | |||
| let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept; | |||
| @@ -208,7 +208,7 @@ export class MediaObjectService { | |||
| // authentication (JWT) required | |||
| localVarCredential = this.configuration.lookupCredential('JWT'); | |||
| if (localVarCredential) { | |||
| localVarHeaders = localVarHeaders.set('Authorization', localVarCredential); | |||
| localVarHeaders = localVarHeaders.set('Authorization', 'Bearer ' + localVarCredential); | |||
| } | |||
| let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept; | |||
| @@ -279,7 +279,7 @@ export class MediaObjectService { | |||
| // authentication (JWT) required | |||
| localVarCredential = this.configuration.lookupCredential('JWT'); | |||
| if (localVarCredential) { | |||
| localVarHeaders = localVarHeaders.set('Authorization', localVarCredential); | |||
| localVarHeaders = localVarHeaders.set('Authorization', 'Bearer ' + localVarCredential); | |||
| } | |||
| let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept; | |||
| @@ -348,7 +348,7 @@ export class MediaObjectService { | |||
| // authentication (JWT) required | |||
| localVarCredential = this.configuration.lookupCredential('JWT'); | |||
| if (localVarCredential) { | |||
| localVarHeaders = localVarHeaders.set('Authorization', localVarCredential); | |||
| localVarHeaders = localVarHeaders.set('Authorization', 'Bearer ' + localVarCredential); | |||
| } | |||
| let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept; | |||
| @@ -139,7 +139,7 @@ export class ShippingCompanyService { | |||
| // authentication (JWT) required | |||
| localVarCredential = this.configuration.lookupCredential('JWT'); | |||
| if (localVarCredential) { | |||
| localVarHeaders = localVarHeaders.set('Authorization', localVarCredential); | |||
| localVarHeaders = localVarHeaders.set('Authorization', 'Bearer ' + localVarCredential); | |||
| } | |||
| let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept; | |||
| @@ -212,7 +212,7 @@ export class ShippingCompanyService { | |||
| // authentication (JWT) required | |||
| localVarCredential = this.configuration.lookupCredential('JWT'); | |||
| if (localVarCredential) { | |||
| localVarHeaders = localVarHeaders.set('Authorization', localVarCredential); | |||
| localVarHeaders = localVarHeaders.set('Authorization', 'Bearer ' + localVarCredential); | |||
| } | |||
| let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept; | |||
| @@ -283,7 +283,7 @@ export class ShippingCompanyService { | |||
| // authentication (JWT) required | |||
| localVarCredential = this.configuration.lookupCredential('JWT'); | |||
| if (localVarCredential) { | |||
| localVarHeaders = localVarHeaders.set('Authorization', localVarCredential); | |||
| localVarHeaders = localVarHeaders.set('Authorization', 'Bearer ' + localVarCredential); | |||
| } | |||
| let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept; | |||
| @@ -359,7 +359,7 @@ export class ShippingCompanyService { | |||
| // authentication (JWT) required | |||
| localVarCredential = this.configuration.lookupCredential('JWT'); | |||
| if (localVarCredential) { | |||
| localVarHeaders = localVarHeaders.set('Authorization', localVarCredential); | |||
| localVarHeaders = localVarHeaders.set('Authorization', 'Bearer ' + localVarCredential); | |||
| } | |||
| let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept; | |||
| @@ -441,7 +441,7 @@ export class ShippingCompanyService { | |||
| // authentication (JWT) required | |||
| localVarCredential = this.configuration.lookupCredential('JWT'); | |||
| if (localVarCredential) { | |||
| localVarHeaders = localVarHeaders.set('Authorization', localVarCredential); | |||
| localVarHeaders = localVarHeaders.set('Authorization', 'Bearer ' + localVarCredential); | |||
| } | |||
| let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept; | |||
| @@ -124,7 +124,7 @@ export class TripService { | |||
| // authentication (JWT) required | |||
| localVarCredential = this.configuration.lookupCredential('JWT'); | |||
| if (localVarCredential) { | |||
| localVarHeaders = localVarHeaders.set('Authorization', localVarCredential); | |||
| localVarHeaders = localVarHeaders.set('Authorization', 'Bearer ' + localVarCredential); | |||
| } | |||
| let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept; | |||
| @@ -197,7 +197,7 @@ export class TripService { | |||
| // authentication (JWT) required | |||
| localVarCredential = this.configuration.lookupCredential('JWT'); | |||
| if (localVarCredential) { | |||
| localVarHeaders = localVarHeaders.set('Authorization', localVarCredential); | |||
| localVarHeaders = localVarHeaders.set('Authorization', 'Bearer ' + localVarCredential); | |||
| } | |||
| let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept; | |||
| @@ -273,7 +273,7 @@ export class TripService { | |||
| // authentication (JWT) required | |||
| localVarCredential = this.configuration.lookupCredential('JWT'); | |||
| if (localVarCredential) { | |||
| localVarHeaders = localVarHeaders.set('Authorization', localVarCredential); | |||
| localVarHeaders = localVarHeaders.set('Authorization', 'Bearer ' + localVarCredential); | |||
| } | |||
| let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept; | |||
| @@ -355,7 +355,7 @@ export class TripService { | |||
| // authentication (JWT) required | |||
| localVarCredential = this.configuration.lookupCredential('JWT'); | |||
| if (localVarCredential) { | |||
| localVarHeaders = localVarHeaders.set('Authorization', localVarCredential); | |||
| localVarHeaders = localVarHeaders.set('Authorization', 'Bearer ' + localVarCredential); | |||
| } | |||
| let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept; | |||
| @@ -124,7 +124,7 @@ export class TripLocationService { | |||
| // authentication (JWT) required | |||
| localVarCredential = this.configuration.lookupCredential('JWT'); | |||
| if (localVarCredential) { | |||
| localVarHeaders = localVarHeaders.set('Authorization', localVarCredential); | |||
| localVarHeaders = localVarHeaders.set('Authorization', 'Bearer ' + localVarCredential); | |||
| } | |||
| let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept; | |||
| @@ -197,7 +197,7 @@ export class TripLocationService { | |||
| // authentication (JWT) required | |||
| localVarCredential = this.configuration.lookupCredential('JWT'); | |||
| if (localVarCredential) { | |||
| localVarHeaders = localVarHeaders.set('Authorization', localVarCredential); | |||
| localVarHeaders = localVarHeaders.set('Authorization', 'Bearer ' + localVarCredential); | |||
| } | |||
| let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept; | |||
| @@ -273,7 +273,7 @@ export class TripLocationService { | |||
| // authentication (JWT) required | |||
| localVarCredential = this.configuration.lookupCredential('JWT'); | |||
| if (localVarCredential) { | |||
| localVarHeaders = localVarHeaders.set('Authorization', localVarCredential); | |||
| localVarHeaders = localVarHeaders.set('Authorization', 'Bearer ' + localVarCredential); | |||
| } | |||
| let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept; | |||
| @@ -355,7 +355,7 @@ export class TripLocationService { | |||
| // authentication (JWT) required | |||
| localVarCredential = this.configuration.lookupCredential('JWT'); | |||
| if (localVarCredential) { | |||
| localVarHeaders = localVarHeaders.set('Authorization', localVarCredential); | |||
| localVarHeaders = localVarHeaders.set('Authorization', 'Bearer ' + localVarCredential); | |||
| } | |||
| let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept; | |||
| @@ -144,7 +144,7 @@ export class UserService { | |||
| // authentication (JWT) required | |||
| localVarCredential = this.configuration.lookupCredential('JWT'); | |||
| if (localVarCredential) { | |||
| localVarHeaders = localVarHeaders.set('Authorization', localVarCredential); | |||
| localVarHeaders = localVarHeaders.set('Authorization', 'Bearer ' + localVarCredential); | |||
| } | |||
| let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept; | |||
| @@ -217,7 +217,7 @@ export class UserService { | |||
| // authentication (JWT) required | |||
| localVarCredential = this.configuration.lookupCredential('JWT'); | |||
| if (localVarCredential) { | |||
| localVarHeaders = localVarHeaders.set('Authorization', localVarCredential); | |||
| localVarHeaders = localVarHeaders.set('Authorization', 'Bearer ' + localVarCredential); | |||
| } | |||
| let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept; | |||
| @@ -288,7 +288,7 @@ export class UserService { | |||
| // authentication (JWT) required | |||
| localVarCredential = this.configuration.lookupCredential('JWT'); | |||
| if (localVarCredential) { | |||
| localVarHeaders = localVarHeaders.set('Authorization', localVarCredential); | |||
| localVarHeaders = localVarHeaders.set('Authorization', 'Bearer ' + localVarCredential); | |||
| } | |||
| let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept; | |||
| @@ -364,7 +364,7 @@ export class UserService { | |||
| // authentication (JWT) required | |||
| localVarCredential = this.configuration.lookupCredential('JWT'); | |||
| if (localVarCredential) { | |||
| localVarHeaders = localVarHeaders.set('Authorization', localVarCredential); | |||
| localVarHeaders = localVarHeaders.set('Authorization', 'Bearer ' + localVarCredential); | |||
| } | |||
| let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept; | |||
| @@ -446,7 +446,7 @@ export class UserService { | |||
| // authentication (JWT) required | |||
| localVarCredential = this.configuration.lookupCredential('JWT'); | |||
| if (localVarCredential) { | |||
| localVarHeaders = localVarHeaders.set('Authorization', localVarCredential); | |||
| localVarHeaders = localVarHeaders.set('Authorization', 'Bearer ' + localVarCredential); | |||
| } | |||
| let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept; | |||
| @@ -124,7 +124,7 @@ export class UserTripService { | |||
| // authentication (JWT) required | |||
| localVarCredential = this.configuration.lookupCredential('JWT'); | |||
| if (localVarCredential) { | |||
| localVarHeaders = localVarHeaders.set('Authorization', localVarCredential); | |||
| localVarHeaders = localVarHeaders.set('Authorization', 'Bearer ' + localVarCredential); | |||
| } | |||
| let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept; | |||
| @@ -197,7 +197,7 @@ export class UserTripService { | |||
| // authentication (JWT) required | |||
| localVarCredential = this.configuration.lookupCredential('JWT'); | |||
| if (localVarCredential) { | |||
| localVarHeaders = localVarHeaders.set('Authorization', localVarCredential); | |||
| localVarHeaders = localVarHeaders.set('Authorization', 'Bearer ' + localVarCredential); | |||
| } | |||
| let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept; | |||
| @@ -273,7 +273,7 @@ export class UserTripService { | |||
| // authentication (JWT) required | |||
| localVarCredential = this.configuration.lookupCredential('JWT'); | |||
| if (localVarCredential) { | |||
| localVarHeaders = localVarHeaders.set('Authorization', localVarCredential); | |||
| localVarHeaders = localVarHeaders.set('Authorization', 'Bearer ' + localVarCredential); | |||
| } | |||
| let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept; | |||
| @@ -355,7 +355,7 @@ export class UserTripService { | |||
| // authentication (JWT) required | |||
| localVarCredential = this.configuration.lookupCredential('JWT'); | |||
| if (localVarCredential) { | |||
| localVarHeaders = localVarHeaders.set('Authorization', localVarCredential); | |||
| localVarHeaders = localVarHeaders.set('Authorization', 'Bearer ' + localVarCredential); | |||
| } | |||
| let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept; | |||
| @@ -124,7 +124,7 @@ export class UserTripLocationService { | |||
| // authentication (JWT) required | |||
| localVarCredential = this.configuration.lookupCredential('JWT'); | |||
| if (localVarCredential) { | |||
| localVarHeaders = localVarHeaders.set('Authorization', localVarCredential); | |||
| localVarHeaders = localVarHeaders.set('Authorization', 'Bearer ' + localVarCredential); | |||
| } | |||
| let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept; | |||
| @@ -197,7 +197,7 @@ export class UserTripLocationService { | |||
| // authentication (JWT) required | |||
| localVarCredential = this.configuration.lookupCredential('JWT'); | |||
| if (localVarCredential) { | |||
| localVarHeaders = localVarHeaders.set('Authorization', localVarCredential); | |||
| localVarHeaders = localVarHeaders.set('Authorization', 'Bearer ' + localVarCredential); | |||
| } | |||
| let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept; | |||
| @@ -273,7 +273,7 @@ export class UserTripLocationService { | |||
| // authentication (JWT) required | |||
| localVarCredential = this.configuration.lookupCredential('JWT'); | |||
| if (localVarCredential) { | |||
| localVarHeaders = localVarHeaders.set('Authorization', localVarCredential); | |||
| localVarHeaders = localVarHeaders.set('Authorization', 'Bearer ' + localVarCredential); | |||
| } | |||
| let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept; | |||
| @@ -355,7 +355,7 @@ export class UserTripLocationService { | |||
| // authentication (JWT) required | |||
| localVarCredential = this.configuration.lookupCredential('JWT'); | |||
| if (localVarCredential) { | |||
| localVarHeaders = localVarHeaders.set('Authorization', localVarCredential); | |||
| localVarHeaders = localVarHeaders.set('Authorization', 'Bearer ' + localVarCredential); | |||
| } | |||
| let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept; | |||
| @@ -124,7 +124,7 @@ export class UserTripWorkLogService { | |||
| // authentication (JWT) required | |||
| localVarCredential = this.configuration.lookupCredential('JWT'); | |||
| if (localVarCredential) { | |||
| localVarHeaders = localVarHeaders.set('Authorization', localVarCredential); | |||
| localVarHeaders = localVarHeaders.set('Authorization', 'Bearer ' + localVarCredential); | |||
| } | |||
| let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept; | |||
| @@ -197,7 +197,7 @@ export class UserTripWorkLogService { | |||
| // authentication (JWT) required | |||
| localVarCredential = this.configuration.lookupCredential('JWT'); | |||
| if (localVarCredential) { | |||
| localVarHeaders = localVarHeaders.set('Authorization', localVarCredential); | |||
| localVarHeaders = localVarHeaders.set('Authorization', 'Bearer ' + localVarCredential); | |||
| } | |||
| let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept; | |||
| @@ -273,7 +273,7 @@ export class UserTripWorkLogService { | |||
| // authentication (JWT) required | |||
| localVarCredential = this.configuration.lookupCredential('JWT'); | |||
| if (localVarCredential) { | |||
| localVarHeaders = localVarHeaders.set('Authorization', localVarCredential); | |||
| localVarHeaders = localVarHeaders.set('Authorization', 'Bearer ' + localVarCredential); | |||
| } | |||
| let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept; | |||
| @@ -355,7 +355,7 @@ export class UserTripWorkLogService { | |||
| // authentication (JWT) required | |||
| localVarCredential = this.configuration.lookupCredential('JWT'); | |||
| if (localVarCredential) { | |||
| localVarHeaders = localVarHeaders.set('Authorization', localVarCredential); | |||
| localVarHeaders = localVarHeaders.set('Authorization', 'Bearer ' + localVarCredential); | |||
| } | |||
| let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept; | |||
| @@ -139,7 +139,7 @@ export class VesselService { | |||
| // authentication (JWT) required | |||
| localVarCredential = this.configuration.lookupCredential('JWT'); | |||
| if (localVarCredential) { | |||
| localVarHeaders = localVarHeaders.set('Authorization', localVarCredential); | |||
| localVarHeaders = localVarHeaders.set('Authorization', 'Bearer ' + localVarCredential); | |||
| } | |||
| let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept; | |||
| @@ -212,7 +212,7 @@ export class VesselService { | |||
| // authentication (JWT) required | |||
| localVarCredential = this.configuration.lookupCredential('JWT'); | |||
| if (localVarCredential) { | |||
| localVarHeaders = localVarHeaders.set('Authorization', localVarCredential); | |||
| localVarHeaders = localVarHeaders.set('Authorization', 'Bearer ' + localVarCredential); | |||
| } | |||
| let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept; | |||
| @@ -283,7 +283,7 @@ export class VesselService { | |||
| // authentication (JWT) required | |||
| localVarCredential = this.configuration.lookupCredential('JWT'); | |||
| if (localVarCredential) { | |||
| localVarHeaders = localVarHeaders.set('Authorization', localVarCredential); | |||
| localVarHeaders = localVarHeaders.set('Authorization', 'Bearer ' + localVarCredential); | |||
| } | |||
| let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept; | |||
| @@ -359,7 +359,7 @@ export class VesselService { | |||
| // authentication (JWT) required | |||
| localVarCredential = this.configuration.lookupCredential('JWT'); | |||
| if (localVarCredential) { | |||
| localVarHeaders = localVarHeaders.set('Authorization', localVarCredential); | |||
| localVarHeaders = localVarHeaders.set('Authorization', 'Bearer ' + localVarCredential); | |||
| } | |||
| let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept; | |||
| @@ -441,7 +441,7 @@ export class VesselService { | |||
| // authentication (JWT) required | |||
| localVarCredential = this.configuration.lookupCredential('JWT'); | |||
| if (localVarCredential) { | |||
| localVarHeaders = localVarHeaders.set('Authorization', localVarCredential); | |||
| localVarHeaders = localVarHeaders.set('Authorization', 'Bearer ' + localVarCredential); | |||
| } | |||
| let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept; | |||
| @@ -139,7 +139,7 @@ export class ZoneService { | |||
| // authentication (JWT) required | |||
| localVarCredential = this.configuration.lookupCredential('JWT'); | |||
| if (localVarCredential) { | |||
| localVarHeaders = localVarHeaders.set('Authorization', localVarCredential); | |||
| localVarHeaders = localVarHeaders.set('Authorization', 'Bearer ' + localVarCredential); | |||
| } | |||
| let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept; | |||
| @@ -212,7 +212,7 @@ export class ZoneService { | |||
| // authentication (JWT) required | |||
| localVarCredential = this.configuration.lookupCredential('JWT'); | |||
| if (localVarCredential) { | |||
| localVarHeaders = localVarHeaders.set('Authorization', localVarCredential); | |||
| localVarHeaders = localVarHeaders.set('Authorization', 'Bearer ' + localVarCredential); | |||
| } | |||
| let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept; | |||
| @@ -283,7 +283,7 @@ export class ZoneService { | |||
| // authentication (JWT) required | |||
| localVarCredential = this.configuration.lookupCredential('JWT'); | |||
| if (localVarCredential) { | |||
| localVarHeaders = localVarHeaders.set('Authorization', localVarCredential); | |||
| localVarHeaders = localVarHeaders.set('Authorization', 'Bearer ' + localVarCredential); | |||
| } | |||
| let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept; | |||
| @@ -359,7 +359,7 @@ export class ZoneService { | |||
| // authentication (JWT) required | |||
| localVarCredential = this.configuration.lookupCredential('JWT'); | |||
| if (localVarCredential) { | |||
| localVarHeaders = localVarHeaders.set('Authorization', localVarCredential); | |||
| localVarHeaders = localVarHeaders.set('Authorization', 'Bearer ' + localVarCredential); | |||
| } | |||
| let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept; | |||
| @@ -441,7 +441,7 @@ export class ZoneService { | |||
| // authentication (JWT) required | |||
| localVarCredential = this.configuration.lookupCredential('JWT'); | |||
| if (localVarCredential) { | |||
| localVarHeaders = localVarHeaders.set('Authorization', localVarCredential); | |||
| localVarHeaders = localVarHeaders.set('Authorization', 'Bearer ' + localVarCredential); | |||
| } | |||
| let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept; | |||
| @@ -90,11 +90,9 @@ export class Configuration { | |||
| // init default JWT credential | |||
| if (!this.credentials['JWT']) { | |||
| this.credentials['JWT'] = () => { | |||
| if (this.apiKeys === null || this.apiKeys === undefined) { | |||
| return undefined; | |||
| } else { | |||
| return this.apiKeys['JWT'] || this.apiKeys['Authorization']; | |||
| } | |||
| return typeof this.accessToken === 'function' | |||
| ? this.accessToken() | |||
| : this.accessToken; | |||
| }; | |||
| } | |||
| } | |||
| @@ -1,17 +0,0 @@ | |||
| /** | |||
| * Imaq Platform | |||
| * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) | |||
| * | |||
| * The version of the OpenAPI document: 1.0.0 | |||
| * | |||
| * | |||
| * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). | |||
| * https://openapi-generator.tech | |||
| * Do not edit the class manually. | |||
| */ | |||
| export interface LoginCheckPost200Response { | |||
| readonly token: string; | |||
| } | |||
| @@ -1,18 +0,0 @@ | |||
| /** | |||
| * Imaq Platform | |||
| * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) | |||
| * | |||
| * The version of the OpenAPI document: 1.0.0 | |||
| * | |||
| * | |||
| * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). | |||
| * https://openapi-generator.tech | |||
| * Do not edit the class manually. | |||
| */ | |||
| export interface LoginCheckPostRequest { | |||
| email: string; | |||
| password: string; | |||
| } | |||
| @@ -9,7 +9,6 @@ | |||
| * https://openapi-generator.tech | |||
| * Do not edit the class manually. | |||
| */ | |||
| import { UserJsonld } from './userJsonld'; | |||
| import { LocationJsonldContext } from './locationJsonldContext'; | |||
| @@ -20,11 +19,9 @@ export interface MediaObjectJsonld { | |||
| context?: LocationJsonldContext; | |||
| readonly id?: string; | |||
| readonly type?: string; | |||
| readonly id?: number; | |||
| readonly dbId?: number | null; | |||
| contentUrl?: string | null; | |||
| file: Blob | null; | |||
| filePath?: string | null; | |||
| createdBy?: UserJsonld; | |||
| readonly createdAt?: string; | |||
| readonly filePath?: string | null; | |||
| readonly createdAt?: string | null; | |||
| } | |||
| @@ -1,24 +0,0 @@ | |||
| /** | |||
| * Imaq Platform | |||
| * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) | |||
| * | |||
| * The version of the OpenAPI document: 1.0.0 | |||
| * | |||
| * | |||
| * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). | |||
| * https://openapi-generator.tech | |||
| * Do not edit the class manually. | |||
| */ | |||
| import { LocationJsonldContext } from './locationJsonldContext'; | |||
| /** | |||
| * | |||
| */ | |||
| export interface MediaObjectJsonldMediaObjectRead { | |||
| context?: LocationJsonldContext; | |||
| readonly id?: string; | |||
| readonly type?: string; | |||
| contentUrl?: string | null; | |||
| } | |||
| @@ -17,7 +17,6 @@ api_platform: | |||
| pagination_items_per_page: 50 | |||
| pagination_maximum_items_per_page: 100 | |||
| swagger: | |||
| api_keys: | |||
| JWT: | |||
| @@ -0,0 +1,68 @@ | |||
| <?php | |||
| namespace App\ApiResource; | |||
| use ApiPlatform\Metadata\ApiProperty; | |||
| use ApiPlatform\Metadata\ApiResource; | |||
| use ApiPlatform\Metadata\Delete; | |||
| use ApiPlatform\Metadata\Get; | |||
| use ApiPlatform\Metadata\GetCollection; | |||
| use ApiPlatform\Metadata\Post; | |||
| use ApiPlatform\OpenApi\Model; | |||
| use App\Controller\CreateMediaObjectAction; | |||
| use App\Entity\MediaObject; | |||
| use App\State\EntityClassDtoStateProcessor; | |||
| use App\State\EntityToDtoStateProvider; | |||
| use ApiPlatform\Doctrine\Orm\State\Options; | |||
| #[ApiResource( | |||
| shortName: 'MediaObject', | |||
| operations: [ | |||
| new Get(), | |||
| new GetCollection(), | |||
| new Post( | |||
| controller: CreateMediaObjectAction::class, | |||
| openapi: new Model\Operation( | |||
| requestBody: new Model\RequestBody( | |||
| content: new \ArrayObject([ | |||
| 'multipart/form-data' => [ | |||
| 'schema' => [ | |||
| 'type' => 'object', | |||
| 'properties' => [ | |||
| 'file' => [ | |||
| 'type' => 'string', | |||
| 'format' => 'binary' | |||
| ] | |||
| ] | |||
| ] | |||
| ] | |||
| ]) | |||
| ) | |||
| ), | |||
| deserialize: false | |||
| ), | |||
| new Delete(), | |||
| ], | |||
| security: 'is_granted("ROLE_USER")', | |||
| provider: EntityToDtoStateProvider::class, | |||
| processor: EntityClassDtoStateProcessor::class, | |||
| stateOptions: new Options(entityClass: MediaObject::class), | |||
| )] | |||
| class MediaObjectApi | |||
| { | |||
| #[ApiProperty(readable: false, writable: false, identifier: true)] | |||
| public ?int $id = null; | |||
| #[ApiProperty(writable: false)] | |||
| public ?int $dbId = null; | |||
| #[ApiProperty(types: ['https://schema.org/contentUrl'])] | |||
| public ?string $contentUrl = null; | |||
| // Optional: Wenn Sie das Filepath in der API sehen möchten | |||
| #[ApiProperty(writable: false)] | |||
| public ?string $filePath = null; | |||
| #[ApiProperty(writable: false)] | |||
| public ?\DateTimeImmutable $createdAt = null; | |||
| } | |||
| @@ -1,35 +1,47 @@ | |||
| <?php | |||
| /** | |||
| * @author Daniel Knudsen <d.knudsen@spawntree.de> | |||
| * @date 25.01.24 | |||
| */ | |||
| namespace App\Controller; | |||
| use App\ApiResource\MediaObjectApi; | |||
| use App\Entity\MediaObject; | |||
| use App\Entity\User; | |||
| use Doctrine\ORM\EntityManagerInterface; | |||
| use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; | |||
| use Symfony\Component\Finder\Exception\AccessDeniedException; | |||
| use Symfony\Component\HttpFoundation\JsonResponse; | |||
| use Symfony\Component\HttpFoundation\Request; | |||
| use Symfony\Component\HttpKernel\Attribute\AsController; | |||
| use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; | |||
| use Symfonycasts\MicroMapper\MicroMapperInterface; | |||
| #[AsController] | |||
| final class CreateMediaObjectAction extends AbstractController | |||
| { | |||
| public function __invoke(Request $request): MediaObject | |||
| public function __construct( | |||
| private MicroMapperInterface $microMapper, | |||
| private EntityManagerInterface $em | |||
| ) { | |||
| } | |||
| public function __invoke(Request $request): JsonResponse | |||
| { | |||
| $uploadedFile = $request->files->get('file'); | |||
| if (!$uploadedFile) { | |||
| throw new BadRequestHttpException('"file" is required'); | |||
| } | |||
| // Sicherstellen dass ein User vorhanden ist | |||
| $user = $this->getUser(); | |||
| assert($user instanceof User); | |||
| if (!$user instanceof User) { | |||
| throw new AccessDeniedException('User must be logged in'); | |||
| } | |||
| $mediaObject = new MediaObject($user); | |||
| $mediaObject->file = $uploadedFile; | |||
| $this->em->persist($mediaObject); | |||
| $this->em->flush(); | |||
| return $mediaObject; | |||
| $mediaObjectApi = $this->microMapper->map($mediaObject, MediaObjectApi::class); | |||
| return new JsonResponse($mediaObjectApi); | |||
| } | |||
| } | |||
| @@ -0,0 +1,44 @@ | |||
| <?php | |||
| namespace App\Mapper; | |||
| use App\ApiResource\MediaObjectApi; | |||
| use App\Entity\MediaObject; | |||
| use Symfonycasts\MicroMapper\AsMapper; | |||
| use Symfonycasts\MicroMapper\MapperInterface; | |||
| use Vich\UploaderBundle\Storage\StorageInterface; | |||
| #[AsMapper(from: MediaObject::class, to: MediaObjectApi::class)] | |||
| class MediaObjectEntityToApiMapper implements MapperInterface | |||
| { | |||
| public function __construct( | |||
| private StorageInterface $storage | |||
| ) { | |||
| } | |||
| public function load(object $from, string $toClass, array $context): object | |||
| { | |||
| $entity = $from; | |||
| assert($entity instanceof MediaObject); | |||
| $dto = new MediaObjectApi(); | |||
| $dto->id = $entity->getId(); | |||
| return $dto; | |||
| } | |||
| public function populate(object $from, object $to, array $context): object | |||
| { | |||
| $entity = $from; | |||
| $dto = $to; | |||
| assert($entity instanceof MediaObject); | |||
| assert($dto instanceof MediaObjectApi); | |||
| $dto->dbId = $entity->getId(); | |||
| $dto->filePath = $entity->getFilePath(); | |||
| $dto->contentUrl = $this->storage->resolveUri($entity, 'file'); | |||
| $dto->createdAt = $entity->getCreatedAt(); | |||
| return $dto; | |||
| } | |||
| } | |||
| @@ -0,0 +1,32 @@ | |||
| <?php | |||
| declare(strict_types=1); | |||
| namespace App\OpenApi; | |||
| use ApiPlatform\OpenApi\OpenApi; | |||
| use ApiPlatform\OpenApi\Factory\OpenApiFactoryInterface; | |||
| use Symfony\Component\DependencyInjection\Attribute\AsDecorator; | |||
| #[AsDecorator(decorates: 'api_platform.openapi.factory')] | |||
| class BearerTokenDecorator implements OpenApiFactoryInterface | |||
| { | |||
| public function __construct( | |||
| private readonly OpenApiFactoryInterface $decorated | |||
| ) {} | |||
| public function __invoke(array $context = []): OpenApi | |||
| { | |||
| $openApi = ($this->decorated)($context); | |||
| $schemas = $openApi->getComponents()->getSecuritySchemes(); | |||
| $schemas['JWT'] = new \ArrayObject([ | |||
| 'type' => 'http', | |||
| 'scheme' => 'bearer', | |||
| 'bearerFormat' => 'JWT' | |||
| ]); | |||
| return $openApi; | |||
| } | |||
| } | |||