mirror of
https://dev.azure.com/hugendubel/ISA/_git/ISA-Frontend
synced 2025-12-31 09:37:15 +01:00
Merged HIMA-38 into development
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { Injectable, Inject } from '@angular/core';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { Observable } from 'rxjs';
|
||||
import { Observable, isObservable } from 'rxjs';
|
||||
import { ItemDTO } from './dtos/data';
|
||||
import { PagedApiResponse, ApiResponse } from './response';
|
||||
import { CAT_SERVICE_ENDPOINT } from './tokens';
|
||||
@@ -14,10 +14,18 @@ export class CatSearchService {
|
||||
|
||||
settingsCache$: Observable<ApiResponse<UISettingsDTO>>;
|
||||
|
||||
endpoint = '';
|
||||
|
||||
constructor(
|
||||
private http: HttpClient,
|
||||
@Inject(CAT_SERVICE_ENDPOINT) private endpoint: string
|
||||
) { }
|
||||
@Inject(CAT_SERVICE_ENDPOINT) endpoint: string | Observable<string>
|
||||
) {
|
||||
if (isObservable(endpoint)) {
|
||||
endpoint.subscribe(e => this.endpoint = e);
|
||||
} else {
|
||||
this.endpoint = endpoint;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* TOP-Search
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { InjectionToken } from '@angular/core';
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
export const CAT_SERVICE_ENDPOINT = new InjectionToken<string>('cat:service:endpoint');
|
||||
export const CAT_SERVICE_ENDPOINT = new InjectionToken<string | Observable<string>>('cat:service:endpoint');
|
||||
|
||||
@@ -2,14 +2,26 @@ import { Injectable, Inject } from '@angular/core';
|
||||
import { FEED_SERVICE_ENDPOINT } from './tokens';
|
||||
import { PagedApiResponse } from './response';
|
||||
import { FeedDTO } from './dtos/feed.dto';
|
||||
import { Observable } from 'rxjs';
|
||||
import { Observable, isObservable } from 'rxjs';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { StringDictionary } from './models';
|
||||
import { isNumber } from 'util';
|
||||
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class FeedService {
|
||||
constructor(@Inject(FEED_SERVICE_ENDPOINT) private endpoint: string, private http: HttpClient) { }
|
||||
|
||||
endpoint = '';
|
||||
|
||||
constructor(
|
||||
private http: HttpClient,
|
||||
@Inject(FEED_SERVICE_ENDPOINT) endpoint: string | Observable<string>
|
||||
) {
|
||||
if (isObservable(endpoint)) {
|
||||
endpoint.subscribe(e => this.endpoint = e);
|
||||
} else {
|
||||
this.endpoint = endpoint;
|
||||
}
|
||||
}
|
||||
|
||||
info(options?: { skip?: number; take?: number; }): Observable<PagedApiResponse<FeedDTO>> {
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { InjectionToken } from '@angular/core';
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
export const FEED_SERVICE_ENDPOINT = new InjectionToken<string>('feed:service:endpoint');
|
||||
export const FEED_SERVICE_ENDPOINT = new InjectionToken<string | Observable<string>>('feed:service:endpoint');
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { Component } from '@angular/core';
|
||||
import { FeedService } from 'feed-service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-root',
|
||||
|
||||
@@ -7,11 +7,11 @@ import { ComponentsModule } from './modules/components.module';
|
||||
import { HttpClientModule, HTTP_INTERCEPTORS } from '@angular/common/http';
|
||||
import { BasicAuthorizationInterceptor, BasicAuthorizationOptions } from './core/interceptors';
|
||||
import { SearchResultsComponent } from './components/search-results/search-results.component';
|
||||
import { CatServiceModule } from 'cat-service';
|
||||
import { CatServiceModule, CAT_SERVICE_ENDPOINT } from 'cat-service';
|
||||
import { ProductCardComponent } from './components/product-card/product-card.component';
|
||||
import { ConfigService } from './core/services/config.service';
|
||||
import { ProductDetailsComponent } from './components/product-details/product-details.component';
|
||||
import { FeedServiceModule, FeedService, FeedMockService } from 'feed-service';
|
||||
import { FeedServiceModule, FEED_SERVICE_ENDPOINT, FeedService, FeedMockService } from 'feed-service';
|
||||
import { NgxsModule } from '@ngxs/store';
|
||||
import { NgxsReduxDevtoolsPluginModule } from '@ngxs/devtools-plugin';
|
||||
import { NgxsLoggerPluginModule } from '@ngxs/logger-plugin';
|
||||
@@ -44,6 +44,14 @@ export function _basicAuthorizationInterceptorFactory(conf: ConfigService) {
|
||||
return new BasicAuthorizationInterceptor(conf.select<BasicAuthorizationOptions>('basicAuthorization'));
|
||||
}
|
||||
|
||||
export function _catServiceEndpointProviderFactory(conf: ConfigService) {
|
||||
return conf.select<string>('catService', 'endpoint');
|
||||
}
|
||||
|
||||
export function _feedServiceEndpointProviderFactory(conf: ConfigService) {
|
||||
return conf.select<string>('feedService', 'endpoint');
|
||||
}
|
||||
|
||||
@NgModule({
|
||||
declarations: [
|
||||
AppComponent,
|
||||
@@ -70,6 +78,8 @@ export function _basicAuthorizationInterceptorFactory(conf: ConfigService) {
|
||||
providers: [
|
||||
{ provide: APP_INITIALIZER, useFactory: _configInitializer, multi: true, deps: [ ConfigService ] },
|
||||
{ provide: HTTP_INTERCEPTORS, useFactory: _basicAuthorizationInterceptorFactory, deps: [ConfigService], multi: true },
|
||||
{ provide: CAT_SERVICE_ENDPOINT, useFactory: _catServiceEndpointProviderFactory, deps: [ConfigService] },
|
||||
{ provide: FEED_SERVICE_ENDPOINT, useFactory: _feedServiceEndpointProviderFactory, deps: [ConfigService] },
|
||||
// { provide: CatSearchService, useClass: CatSearchMockService } // Uncomment if u want to use the CatSearchMockService
|
||||
{ provide: FeedService, useClass: FeedMockService } // Uncomment if u want to use the FeedMockService
|
||||
],
|
||||
|
||||
@@ -3,15 +3,6 @@ import { isNullOrUndefined } from 'util';
|
||||
import { AvailabilityDTO, PriceDTO, ItemDTO, AvailabilityType } from 'cat-service';
|
||||
import { Injectable } from '@angular/core';
|
||||
|
||||
|
||||
const itemFormatMap = {
|
||||
'CD': 'Hörbuch',
|
||||
'GEB': 'Buch',
|
||||
'KT': 'Taschenbuch',
|
||||
'SPL': 'Spiel'
|
||||
};
|
||||
|
||||
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class ProductMapping {
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ import { tap, map, distinctUntilChanged } from 'rxjs/operators';
|
||||
import { isNullOrUndefined } from 'util';
|
||||
import { ReplaySubject } from 'rxjs';
|
||||
import { SKIP_BASIC_AUTHORIZATION_INTERCEPTOR } from '../interceptors';
|
||||
import { environment } from '../../../environments/environment';
|
||||
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class ConfigService {
|
||||
@@ -13,7 +14,7 @@ export class ConfigService {
|
||||
constructor(private httpClient: HttpClient) { }
|
||||
|
||||
load(): Promise<Object> {
|
||||
return this.httpClient.get('/assets/config.json', { headers: { SKIP_BASIC_AUTHORIZATION_INTERCEPTOR } })
|
||||
return this.httpClient.get(environment.config, { headers: { SKIP_BASIC_AUTHORIZATION_INTERCEPTOR } })
|
||||
.pipe(tap(result => this.configSub.next(result)))
|
||||
.toPromise();
|
||||
}
|
||||
|
||||
@@ -5,5 +5,11 @@
|
||||
"endpoints": [
|
||||
"https://catsearch.paragon-data.de"
|
||||
]
|
||||
},
|
||||
"catService": {
|
||||
"endpoint": "https://catsearch.paragon-data.de"
|
||||
},
|
||||
"feedService": {
|
||||
"endpoint": "https://isa.paragon-data.de"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
export const environment = {
|
||||
production: true
|
||||
production: true,
|
||||
config: '/assets/config.json'
|
||||
};
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
// The list of file replacements can be found in `angular.json`.
|
||||
|
||||
export const environment = {
|
||||
production: false
|
||||
production: false,
|
||||
config: '/assets/config.json'
|
||||
};
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user