|
@@ -3,13 +3,32 @@ import { Injectable, inject } from '@angular/core';
|
|
|
import { Observable, map, shareReplay } from 'rxjs';
|
|
import { Observable, map, shareReplay } from 'rxjs';
|
|
|
import { DomesticDataset, DomesticProduct, DomesticReview } from '../models/domestic.models';
|
|
import { DomesticDataset, DomesticProduct, DomesticReview } from '../models/domestic.models';
|
|
|
import { ProductInfo } from '../../../modules/shared/interfaces/voc-insight-interfaces';
|
|
import { ProductInfo } from '../../../modules/shared/interfaces/voc-insight-interfaces';
|
|
|
|
|
+import { RUNTIME_CONFIG, SaasVocRuntimeConfig } from '../config/runtime-config';
|
|
|
|
|
+
|
|
|
|
|
+export function buildDomesticDatasetUrl(
|
|
|
|
|
+ config: Pick<
|
|
|
|
|
+ SaasVocRuntimeConfig,
|
|
|
|
|
+ 'apiBaseUrl' | 'domesticDatasetMode' | 'domesticVocPath' | 'domesticWorkspaceId' | 'domesticPlatform'
|
|
|
|
|
+ >,
|
|
|
|
|
+): string {
|
|
|
|
|
+ if (config.domesticDatasetMode === 'case') return 'assets/data/demashi-summary.json';
|
|
|
|
|
+
|
|
|
|
|
+ const baseUrl = config.apiBaseUrl.replace(/\/+$/, '');
|
|
|
|
|
+ const path = `/${config.domesticVocPath.replace(/^\/+|\/+$/g, '')}`;
|
|
|
|
|
+ const query = new URLSearchParams({
|
|
|
|
|
+ workspaceId: config.domesticWorkspaceId,
|
|
|
|
|
+ platform: config.domesticPlatform,
|
|
|
|
|
+ });
|
|
|
|
|
+ return `${baseUrl}${path}/snapshot?${query.toString()}`;
|
|
|
|
|
+}
|
|
|
|
|
|
|
|
@Injectable({ providedIn: 'root' })
|
|
@Injectable({ providedIn: 'root' })
|
|
|
export class DomesticDatasetService {
|
|
export class DomesticDatasetService {
|
|
|
private readonly http = inject(HttpClient);
|
|
private readonly http = inject(HttpClient);
|
|
|
|
|
+ private readonly datasetUrl = buildDomesticDatasetUrl(RUNTIME_CONFIG);
|
|
|
|
|
|
|
|
readonly dataset$: Observable<DomesticDataset> = this.http
|
|
readonly dataset$: Observable<DomesticDataset> = this.http
|
|
|
- .get<DomesticDataset>('assets/data/demashi-summary.json')
|
|
|
|
|
|
|
+ .get<DomesticDataset>(this.datasetUrl)
|
|
|
.pipe(shareReplay({ bufferSize: 1, refCount: false }));
|
|
.pipe(shareReplay({ bufferSize: 1, refCount: false }));
|
|
|
|
|
|
|
|
readonly products$: Observable<ProductInfo[]> = this.dataset$.pipe(
|
|
readonly products$: Observable<ProductInfo[]> = this.dataset$.pipe(
|