Skip to content

Commit

Permalink
finalize service
Browse files Browse the repository at this point in the history
  • Loading branch information
ntqdinh-axonivy committed Dec 16, 2024
1 parent 305a97a commit 04c6628
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ export class ProductFeedbackService {

fetchFeedbacks(): void {
this.getInitFeedbacksObservable().subscribe(response => {
this.setInitFeedbacksObservable(response);
this.handleFeedbackApiResponse(response);
});
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<div class="container-fluid min-vh-100">
<div>

<app-loading-spinner
containerClasses="d-flex justify-content-center position-absolute align-items-center w-100 h-100 start-0 rounded overlay-background"
[key]="LoadingComponentId.DETAIL_PAGE" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ export class ProductDetailComponent {
}

ngOnInit(): void {
this.loadingService.showLoading(LoadingComponentId.DETAIL_PAGE);
this.router.navigate([], {
relativeTo: this.route,
queryParamsHandling: 'merge',
Expand All @@ -161,30 +162,26 @@ export class ProductDetailComponent {
productDetail: this.getProductDetailObservable(productId),
productFeedBack: this.productFeedbackService.getInitFeedbacksObservable(),
rating: this.productStarRatingService.getRatingObservable(productId),

userFeedback: this.productFeedbackService.findProductFeedbackOfUser()
}).subscribe(res => {
this.handleProductDetail(res.productDetail);
this.productFeedbackService.handleFeedbackApiResponse(res.productFeedBack);
res.rating;
this.updateDropdownSelection();
this.checkMediaSize();
this.route.queryParams.subscribe(params => {
this.showPopup = params['showPopup'] === 'true';
if (this.showPopup && this.authService.getToken()) {
this.appModalService
.openAddFeedbackDialog()
.then(() => this.removeQueryParam())
.catch(() => this.removeQueryParam());
}
});
this.loadingService.hideLoading(LoadingComponentId.DETAIL_PAGE);
});
this.getUserFeedBack();
}
}

getUserFeedBack() {
this.productFeedbackService.findProductFeedbackOfUser().subscribe(() => {
this.route.queryParams.subscribe(params => {
this.showPopup = params['showPopup'] === 'true';
if (this.showPopup && this.authService.getToken()) {
this.appModalService
.openAddFeedbackDialog()
.then(() => this.removeQueryParam())
.catch(() => this.removeQueryParam());
}
});
});
}
}

getProductDetailObservable(productId: string): Observable<ProductDetail> {
Expand Down
31 changes: 4 additions & 27 deletions marketplace-ui/src/app/modules/product/product.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,7 @@ export class ProductService {
version: string
): Observable<ProductDetail> {
return this.httpClient.get<ProductDetail>(
`${API_URI.PRODUCT_DETAILS}/${productId}/${version}`,
{
context: new HttpContext().set(
LoadingComponent,
LoadingComponentId.PRODUCT_DETAIL_INFORMATION
)
}
`${API_URI.PRODUCT_DETAILS}/${productId}/${version}`
);
}

Expand All @@ -68,13 +62,7 @@ export class ProductService {
version: string
): Observable<ProductDetail> {
return this.httpClient.get<ProductDetail>(
`${API_URI.PRODUCT_DETAILS}/${productId}/${version}/bestmatch`,
{
context: new HttpContext().set(
LoadingComponent,
LoadingComponentId.DETAIL_PAGE
)
}
`${API_URI.PRODUCT_DETAILS}/${productId}/${version}/bestmatch`
);
}

Expand All @@ -84,13 +72,7 @@ export class ProductService {
): Observable<ProductDetail> {
return this.httpClient
.get<ProductDetail>(
`${API_URI.PRODUCT_DETAILS}/${productId}?isShowDevVersion=${isShowDevVersion}`,
{
context: new HttpContext().set(
LoadingComponent,
LoadingComponentId.DETAIL_PAGE
)
}
`${API_URI.PRODUCT_DETAILS}/${productId}?isShowDevVersion=${isShowDevVersion}`
)
.pipe(delay(5000));
}
Expand All @@ -104,12 +86,7 @@ export class ProductService {
const params = new HttpParams()
.append('designerVersion', designerVersion)
.append('isShowDevVersion', showDevVersion);
return this.httpClient.get<VersionData[]>(url, {
params,
context: new HttpContext()
.set(SkipLoading, true)
.set(LoadingComponent, LoadingComponentId.PRODUCT_DETAIL_INFORMATION)
});
return this.httpClient.get<VersionData[]>(url, { params });
}

sendRequestToUpdateInstallationCount(
Expand Down

0 comments on commit 04c6628

Please sign in to comment.