Skip to content

Commit 306ae6a

Browse files
Merge pull request #321 from aiondemand/staging
Update main with Staging
2 parents 61c7bf7 + 23d18c3 commit 306ae6a

File tree

6 files changed

+395
-92
lines changed

6 files changed

+395
-92
lines changed

src/app/modules/marketplace/components/asset-detail/asset-detail.component.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ export class AssetDetailComponent implements OnInit, OnDestroy {
5959
this.breadcrumbService.set('@assetName', this.asset.name);
6060
this.isLoading = false;
6161
this.prepareGenericData();
62+
63+
if (!this.authService.isAuthActiveUser()) return;
64+
6265
// After asset is loaded, check if it's bookmarked
6366
const bookmarkSub = this.bookmarkService.getBookmarksList().subscribe({
6467
next: (bookmarks: AssetsPurchase[] | any) => {
@@ -107,7 +110,7 @@ export class AssetDetailComponent implements OnInit, OnDestroy {
107110
}
108111

109112
protected onClickBookmark(): void {
110-
if (!this.isAuthenticated()) return;
113+
if (!this.authService.isAuthActiveUser()) return;
111114

112115
if (!this.isBookmarked) {
113116
this.addBookmark();
@@ -119,6 +122,11 @@ export class AssetDetailComponent implements OnInit, OnDestroy {
119122
protected onClickReport(): void {
120123
const dialogRef = this.dialog.open(ReportDialogComponent, {
121124
width: '50rem',
125+
maxWidth: '90vw',
126+
maxHeight: '90vh',
127+
hasBackdrop: true,
128+
disableClose: false,
129+
panelClass: 'report-dialog-panel',
122130
data: {
123131
assetName: this.asset.name,
124132
assetId: this.asset.identifier,
@@ -143,11 +151,11 @@ export class AssetDetailComponent implements OnInit, OnDestroy {
143151
}
144152

145153
isAuthenticated(): boolean {
146-
return this.userProfile && Object.keys(this.userProfile).length > 0;
154+
return this.authService.isAuthActiveUser();
147155
}
148156

149157
private addBookmark() {
150-
if (this.userProfile) {
158+
if (this.authService.isAuthActiveUser()) {
151159
const bookmarkedAsset = this.getBookmarkedAsset();
152160

153161
this.bookmarkService.addBookmark(bookmarkedAsset.identifier).subscribe({
@@ -160,7 +168,7 @@ export class AssetDetailComponent implements OnInit, OnDestroy {
160168
}
161169

162170
private deleteBookmark() {
163-
if (this.userProfile) {
171+
if (this.authService.isAuthActiveUser()) {
164172
this.bookmarkService
165173
.deleteBookmark(this.asset.identifier.toString())
166174
.subscribe({

src/app/modules/marketplace/components/assets-list/assets-list.component.ts

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ import {
3232
import { MatTooltip } from '@angular/material/tooltip';
3333
import { HttpClient } from '@angular/common/http';
3434
import { FiltersStateService } from '@app/shared/services/sidenav/filters-state.service';
35-
import { PageEvent } from '@angular/material/paginator';
3635
import { ParamsReqSearchAsset } from '@app/shared/interfaces/search-service.interface';
3736
import { GeneralAssetService } from '../../services/assets-services/general-asset.service';
3837
import { ElasticSearchService } from '../../services/elastic-search/elastic-search.service';
@@ -348,7 +347,7 @@ export class AssetsListComponent implements OnInit, OnDestroy {
348347
const params: ParamsReqSearchAsset = {
349348
searchQuery: query,
350349
limit: this.pageSize,
351-
page: this.currentPage,
350+
offset: this.currentPage * this.pageSize,
352351
platforms: platformsSelected,
353352
sort_field: this.sortField,
354353
sort_order: this.sortOrder,
@@ -658,17 +657,6 @@ export class AssetsListComponent implements OnInit, OnDestroy {
658657
this.subscriptions.add(subscribe);
659658
}
660659

661-
public handlePageEvent(e: PageEvent) {
662-
this.offset = e.pageIndex * e.pageSize;
663-
this.pageSize = e.pageSize;
664-
this.currentPage = e.pageIndex;
665-
if (!this.isEnhancedSearch) {
666-
this.getAssets();
667-
} else if (this.searchQueryValue) {
668-
this.enhancedSearch(this.searchQueryValue);
669-
}
670-
}
671-
672660
// Custom paginator methods
673661
public currentPageSize = 15;
674662

@@ -679,22 +667,24 @@ export class AssetsListComponent implements OnInit, OnDestroy {
679667
this.currentPage = 0;
680668
this.offset = 0;
681669

682-
if (!this.isEnhancedSearch) {
683-
this.getAssets();
684-
} else if (this.searchQueryValue) {
685-
this.enhancedSearch(this.searchQueryValue);
686-
}
670+
this.performSearch();
687671
}
688672

689673
public goToPage(pageIndex: number) {
674+
if (pageIndex < 0 || pageIndex >= this.getTotalPages()) {
675+
return;
676+
}
690677
this.currentPage = pageIndex;
691678
this.offset = pageIndex * this.pageSize;
692679

693-
if (!this.isEnhancedSearch) {
694-
this.getAssets();
695-
} else if (this.searchQueryValue) {
696-
this.enhancedSearch(this.searchQueryValue);
697-
}
680+
this.performSearch();
681+
}
682+
683+
private isKeywordSearchActive(): boolean {
684+
return !!(
685+
this.searchQueryValue?.trim() ||
686+
this.filtersStateService.searchQuery?.trim()
687+
);
698688
}
699689

700690
public getTotalPages(): number {
@@ -949,4 +939,14 @@ export class AssetsListComponent implements OnInit, OnDestroy {
949939
this.infoTooltipVisible = false;
950940
}
951941
};
942+
943+
private performSearch() {
944+
if (!this.isEnhancedSearch && this.isKeywordSearchActive()) {
945+
this.basicSearch();
946+
} else if (!this.isEnhancedSearch) {
947+
this.getAssets();
948+
} else if (this.searchQueryValue) {
949+
this.enhancedSearch(this.searchQueryValue);
950+
}
951+
}
952952
}

src/app/modules/marketplace/services/elastic-search/elastic-search.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export class ElasticSearchService {
1717

1818
private buildParamsSearch(paramsSearch: ParamsReqSearchAsset): HttpParams {
1919
let params = new HttpParams()
20-
.set('page', paramsSearch.page)
20+
.set('offset', paramsSearch.offset)
2121
.set('limit', paramsSearch.limit)
2222
.set('search_query', paramsSearch.searchQuery);
2323

Lines changed: 67 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,72 @@
1-
<h1 mat-dialog-title class="dialog-title">{{ 'SHARED.REPORT_DIALOG.TITLE' | translate }}</h1>
2-
<div mat-dialog-content>
3-
<ng-container *ngIf="isAssetReportAvailable; else emailInfo">
4-
<p class="dialog-intro">{{ 'SHARED.REPORT_DIALOG.INTRO' | translate }}</p>
5-
<form [formGroup]="reportForm" (ngSubmit)="submitReport()">
6-
<mat-form-field appearance="outline" class="full-width name-field">
7-
<mat-label>{{ 'SHARED.REPORT_DIALOG.NAME' | translate }}</mat-label>
8-
<input matInput formControlName="name" required>
9-
<mat-error *ngIf="reportForm.get('name')?.hasError('required')">
10-
{{ 'SHARED.REPORT_DIALOG.NAME_REQUIRED' | translate }}
11-
</mat-error>
12-
</mat-form-field>
1+
<div class="modal-overlay" (click)="closeDialog()">
2+
<div class="modal-wrapper" (click)="$event.stopPropagation()">
3+
<div class="dialog-container">
4+
<h1 class="dialog-title">{{ 'SHARED.REPORT_DIALOG.TITLE' | translate }}</h1>
5+
<div class="dialog-content">
6+
<ng-container *ngIf="isAssetReportAvailable; else emailInfo">
7+
<p class="dialog-intro">{{ 'SHARED.REPORT_DIALOG.INTRO' | translate }}</p>
8+
<form [formGroup]="reportForm" (ngSubmit)="submitReport()">
9+
<div class="form-field full-width name-field">
10+
<label class="form-label">{{ 'SHARED.REPORT_DIALOG.NAME' | translate }}</label>
11+
<input type="text" class="form-input" formControlName="name" required>
12+
<div class="form-error" *ngIf="reportForm.get('name')?.hasError('required') && reportForm.get('name')?.touched">
13+
{{ 'SHARED.REPORT_DIALOG.NAME_REQUIRED' | translate }}
14+
</div>
15+
</div>
1316

14-
<mat-form-field appearance="outline" class="full-width">
15-
<mat-label>{{ 'SHARED.REPORT_DIALOG.EMAIL' | translate }}</mat-label>
16-
<input matInput formControlName="email" type="email">
17-
<mat-error *ngIf="reportForm.get('email')?.hasError('email')">
18-
{{ 'SHARED.REPORT_DIALOG.EMAIL_INVALID' | translate }}
19-
</mat-error>
20-
</mat-form-field>
17+
<div class="form-field full-width">
18+
<label class="form-label">{{ 'SHARED.REPORT_DIALOG.EMAIL' | translate }}</label>
19+
<input type="email" class="form-input" formControlName="email">
20+
<div class="form-error" *ngIf="reportForm.get('email')?.hasError('email') && reportForm.get('email')?.touched">
21+
{{ 'SHARED.REPORT_DIALOG.EMAIL_INVALID' | translate }}
22+
</div>
23+
</div>
2124

22-
<mat-form-field appearance="outline" class="full-width">
23-
<mat-label>{{ 'SHARED.REPORT_DIALOG.SUBJECT' | translate }}</mat-label>
24-
<input matInput formControlName="subject" required>
25-
<mat-error *ngIf="reportForm.get('subject')?.hasError('required')">
26-
{{ 'SHARED.REPORT_DIALOG.SUBJECT_REQUIRED' | translate }}
27-
</mat-error>
28-
</mat-form-field>
25+
<div class="form-field full-width">
26+
<label class="form-label">{{ 'SHARED.REPORT_DIALOG.SUBJECT' | translate }}</label>
27+
<input type="text" class="form-input" formControlName="subject" required>
28+
<div class="form-error" *ngIf="reportForm.get('subject')?.hasError('required') && reportForm.get('subject')?.touched">
29+
{{ 'SHARED.REPORT_DIALOG.SUBJECT_REQUIRED' | translate }}
30+
</div>
31+
</div>
2932

30-
<mat-form-field appearance="outline" class="full-width">
31-
<mat-label>{{ 'SHARED.REPORT_DIALOG.REPORT' | translate }}</mat-label>
32-
<textarea matInput formControlName="report" rows="4" required placeholder="{{ 'SHARED.REPORT_DIALOG.PLACEHOLDER' | translate }}"></textarea>
33-
<mat-error *ngIf="reportForm.get('report')?.hasError('required')">
34-
{{ 'SHARED.REPORT_DIALOG.REPORT_REQUIRED' | translate }}
35-
</mat-error>
36-
</mat-form-field>
37-
<div class="privacy-acceptance" style="margin-top:8px;">
38-
<mat-checkbox formControlName="privacyAccepted" aria-label="Accept privacy policy">
39-
{{ 'SHARED.REPORT_DIALOG.READ_ACCEPT' | translate }}
40-
<a [href]="EXTERNAL_LINKS.PRIVACY_POLICY" target="_blank" rel="noopener" style="color:#1976d2;">
41-
{{ 'SHARED.REPORT_DIALOG.PRIVACY_POLICY' | translate }}
42-
</a>.
43-
</mat-checkbox>
44-
<mat-error *ngIf="reportForm.get('privacyAccepted')?.hasError('required') && (reportForm.get('privacyAccepted')?.touched || reportForm.touched)">
45-
{{ 'SHARED.REPORT_DIALOG.PRIVACY_ACCEPTANCE_REQUIRED' | translate }}
46-
</mat-error>
47-
</div>
48-
</form>
49-
</ng-container>
33+
<div class="form-field full-width">
34+
<label class="form-label">{{ 'SHARED.REPORT_DIALOG.REPORT' | translate }}</label>
35+
<textarea class="form-textarea" formControlName="report" rows="4" required placeholder="{{ 'SHARED.REPORT_DIALOG.PLACEHOLDER' | translate }}"></textarea>
36+
<div class="form-error" *ngIf="reportForm.get('report')?.hasError('required') && reportForm.get('report')?.touched">
37+
{{ 'SHARED.REPORT_DIALOG.REPORT_REQUIRED' | translate }}
38+
</div>
39+
</div>
40+
41+
<div class="privacy-acceptance">
42+
<label class="checkbox-container">
43+
<input type="checkbox" formControlName="privacyAccepted" aria-label="Accept privacy policy">
44+
<span class="checkbox-label">
45+
{{ 'SHARED.REPORT_DIALOG.READ_ACCEPT' | translate }}&nbsp;
46+
<a [href]="EXTERNAL_LINKS.PRIVACY_POLICY" target="_blank" rel="noopener" class="privacy-link">
47+
{{ 'SHARED.REPORT_DIALOG.PRIVACY_POLICY' | translate }}
48+
</a>.
49+
</span>
50+
</label>
51+
<div class="form-error" *ngIf="reportForm.get('privacyAccepted')?.hasError('required') && (reportForm.get('privacyAccepted')?.touched || reportForm.touched)">
52+
{{ 'SHARED.REPORT_DIALOG.PRIVACY_ACCEPTANCE_REQUIRED' | translate }}
53+
</div>
54+
</div>
55+
</form>
56+
</ng-container>
5057

51-
<ng-template #emailInfo>
52-
<p [innerHTML]="'SHARED.REPORT_DIALOG.EMAIL_INSTRUCTIONS' | translate:{ assetName: this.data.assetName, assetId: this.data.assetId }"></p>
53-
</ng-template>
54-
</div>
55-
<div mat-dialog-actions align="end">
56-
<button mat-button (click)="closeDialog()">
57-
{{ 'SHARED.REPORT_DIALOG.CANCEL' | translate }}
58-
</button>
59-
<button *ngIf="isAssetReportAvailable" mat-raised-button color="warn" (click)="submitReport()" [disabled]="!reportForm.valid">
60-
{{ 'SHARED.REPORT_DIALOG.SUBMIT_REPORT' | translate }}
61-
</button>
58+
<ng-template #emailInfo>
59+
<p [innerHTML]="'SHARED.REPORT_DIALOG.EMAIL_INSTRUCTIONS' | translate:{ assetName: this.data.assetName, assetId: this.data.assetId }"></p>
60+
</ng-template>
61+
</div>
62+
<div class="dialog-actions">
63+
<button class="btn btn-secondary" (click)="closeDialog()">
64+
{{ 'SHARED.REPORT_DIALOG.CANCEL' | translate }}
65+
</button>
66+
<button *ngIf="isAssetReportAvailable" class="btn btn-primary" (click)="submitReport()" [disabled]="!reportForm.valid">
67+
{{ 'SHARED.REPORT_DIALOG.SUBMIT_REPORT' | translate }}
68+
</button>
69+
</div>
70+
</div>
71+
</div>
6272
</div>

0 commit comments

Comments
 (0)