Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions core-web/apps/dotcdn/src/app/dotcdn.component.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { inject, Injectable } from '@angular/core';

import { SelectItem } from 'primeng/api';

import { mergeMap, pluck, switchMapTo, tap } from 'rxjs/operators';
import { map, mergeMap, switchMapTo, tap } from 'rxjs/operators';

import {
ChartData,
Expand Down Expand Up @@ -189,7 +189,10 @@ export class DotCDNStore extends ComponentStore<DotCDNState> {
);

$loading
.pipe(switchMapTo(this.dotCdnService.purgeCacheAll()), pluck('bodyJsonObject'))
.pipe(
switchMapTo(this.dotCdnService.purgeCacheAll()),
map((x: any) => x?.bodyJsonObject)
)
.subscribe(() => {
this.dispatchLoading({
loadingState: LoadingState.LOADED,
Expand Down
14 changes: 7 additions & 7 deletions core-web/apps/dotcdn/src/app/dotcdn.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Observable } from 'rxjs';

import { inject, Injectable } from '@angular/core';

import { mergeMap, pluck } from 'rxjs/operators';
import { map, mergeMap } from 'rxjs/operators';

import { CoreWebService, ResponseView, SiteService } from '@dotcms/dotcms-js';

Expand All @@ -25,7 +25,7 @@ export class DotCDNService {
*/
requestStats(period: string): Observable<DotCDNStats> {
return this.siteService.getCurrentSite().pipe(
pluck('identifier'),
map((x) => x?.identifier),
mergeMap((hostId: string) => {
const dateTo = format(new Date(), 'yyyy-MM-dd');
const dateFrom = format(subDays(new Date(), parseInt(period, 10)), 'yyyy-MM-dd');
Expand All @@ -34,7 +34,7 @@ export class DotCDNService {
url: `/api/v1/dotcdn/stats?hostId=${hostId}&dateFrom=${dateFrom}&dateTo=${dateTo}`
});
}),
pluck('entity')
map((x) => x?.entity)
);
}

Expand All @@ -47,11 +47,11 @@ export class DotCDNService {
*/
purgeCache(urls?: string[]): Observable<PurgeReturnData> {
return this.siteService.getCurrentSite().pipe(
pluck('identifier'),
map((x) => x?.identifier),
mergeMap((hostId: string) => {
return this.purgeUrlRequest({ hostId, invalidateAll: false, urls });
}),
pluck('bodyJsonObject')
map((x) => x?.bodyJsonObject)
);
}

Expand All @@ -63,9 +63,9 @@ export class DotCDNService {
*/
purgeCacheAll(): Observable<PurgeReturnData> {
return this.siteService.getCurrentSite().pipe(
pluck('identifier'),
map((x) => x?.identifier),
mergeMap((hostId: string) => this.purgeUrlRequest({ hostId, invalidateAll: true })),
pluck('bodyJsonObject')
map((x) => x?.bodyJsonObject)
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Observable, of } from 'rxjs';
import { HttpErrorResponse } from '@angular/common/http';
import { Injectable, inject } from '@angular/core';

import { catchError, map, pluck, take } from 'rxjs/operators';
import { catchError, map, take } from 'rxjs/operators';

import { DotHttpErrorManagerService } from '@dotcms/data-access';
import { CoreWebService } from '@dotcms/dotcms-js';
Expand Down Expand Up @@ -61,7 +61,7 @@ export class DotAddToMenuService {
url: `${addToMenuUrl}/custom`
})
.pipe(
pluck('entity'),
map((x) => x?.entity),
catchError((error: HttpErrorResponse) => {
if (error.status === 400) {
return of(null);
Expand Down Expand Up @@ -91,7 +91,7 @@ export class DotAddToMenuService {
url: `${addToMenuUrl}/custom/c_${portletId}/_addtolayout/${params.layoutId}`
})
.pipe(
pluck('entity'),
map((x) => x?.entity),
catchError((error: HttpErrorResponse) => {
return this.httpErrorManagerService.handle(error).pipe(
take(1),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Observable } from 'rxjs';
import { HttpErrorResponse } from '@angular/common/http';
import { Injectable, inject } from '@angular/core';

import { catchError, map, pluck, take } from 'rxjs/operators';
import { catchError, map, take } from 'rxjs/operators';

import { DotHttpErrorManagerService } from '@dotcms/data-access';
import { CoreWebService, ResponseView } from '@dotcms/dotcms-js';
Expand Down Expand Up @@ -42,7 +42,7 @@ export class DotAccountService {
})
.pipe(
take(1),
pluck('entity'),
map((x) => x?.entity),
catchError((error: HttpErrorResponse) => {
return this.httpErrorManagerService.handle(error).pipe(
take(1),
Expand All @@ -66,7 +66,7 @@ export class DotAccountService {
})
.pipe(
take(1),
pluck('entity'),
map((x) => x?.entity),
catchError((error: HttpErrorResponse) => {
return this.httpErrorManagerService.handle(error).pipe(
take(1),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Observable } from 'rxjs';
import { HttpErrorResponse } from '@angular/common/http';
import { Injectable, inject } from '@angular/core';

import { catchError, map, pluck, take } from 'rxjs/operators';
import { catchError, map, take } from 'rxjs/operators';

import { DotHttpErrorManagerService } from '@dotcms/data-access';
import { CoreWebService } from '@dotcms/dotcms-js';
Expand Down Expand Up @@ -41,7 +41,7 @@ export class DotAppsService {
url
})
.pipe(
pluck('entity'),
map((x) => x?.entity),
catchError((error: HttpErrorResponse) => {
return this.httpErrorManagerService.handle(error).pipe(
take(1),
Expand All @@ -63,7 +63,7 @@ export class DotAppsService {
url: `${appsUrl}/${appKey}`
})
.pipe(
pluck('entity'),
map((x) => x?.entity),
catchError((error: HttpErrorResponse) => {
return this.httpErrorManagerService.handle(error).pipe(
take(1),
Expand All @@ -86,7 +86,7 @@ export class DotAppsService {
url: `${appsUrl}/${appKey}/${id}`
})
.pipe(
pluck('entity'),
map((x) => x?.entity),
catchError((error: HttpErrorResponse) => {
return this.httpErrorManagerService.handle(error).pipe(
take(1),
Expand Down Expand Up @@ -118,7 +118,7 @@ export class DotAppsService {
url: `${appsUrl}/${appKey}/${id}`
})
.pipe(
pluck('entity'),
map((x) => x?.entity),
catchError((error: HttpErrorResponse) => {
return this.httpErrorManagerService.handle(error).pipe(
take(1),
Expand Down Expand Up @@ -187,7 +187,7 @@ export class DotAppsService {
method: 'POST'
})
.pipe(
pluck('entity'),
map((x) => x?.entity),
catchError((error: HttpErrorResponse) => {
return this.httpErrorManagerService.handle(error).pipe(
take(1),
Expand All @@ -211,7 +211,7 @@ export class DotAppsService {
url: `${appsUrl}/${appKey}/${hostId}`
})
.pipe(
pluck('entity'),
map((x) => x?.entity),
catchError((error: HttpErrorResponse) => {
return this.httpErrorManagerService.handle(error).pipe(
take(1),
Expand All @@ -234,7 +234,7 @@ export class DotAppsService {
url: `${appsUrl}/${appKey}`
})
.pipe(
pluck('entity'),
map((x) => x?.entity),
catchError((error: HttpErrorResponse) => {
return this.httpErrorManagerService.handle(error).pipe(
take(1),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Observable } from 'rxjs';
import { HttpErrorResponse } from '@angular/common/http';
import { Injectable, inject } from '@angular/core';

import { catchError, map, pluck, take } from 'rxjs/operators';
import { catchError, map, take } from 'rxjs/operators';

import { DotHttpErrorManagerService } from '@dotcms/data-access';
import { CoreWebService, DotRequestOptionsArgs } from '@dotcms/dotcms-js';
Expand Down Expand Up @@ -211,7 +211,7 @@ export class DotContainersService {
const response$ = this.coreWebService.requestView<T>(options);

return response$.pipe(
pluck('entity'),
map((x) => x?.entity),
catchError((error: HttpErrorResponse) => {
return this.httpErrorManagerService.handle(error).pipe(
take(1),
Expand Down
21 changes: 7 additions & 14 deletions core-web/apps/dotcms-ui/src/app/api/services/dot-menu.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,7 @@ import { Observable } from 'rxjs';
import { HttpClient } from '@angular/common/http';
import { Injectable, inject } from '@angular/core';

import {
defaultIfEmpty,
filter,
find,
map,
mergeMap,
pluck,
publishLast,
refCount
} from 'rxjs/operators';
import { defaultIfEmpty, filter, find, map, mergeMap, publishLast, refCount } from 'rxjs/operators';

import { DotCMSResponse } from '@dotcms/dotcms-js';
import { DotMenu, DotMenuItem } from '@dotcms/dotcms-models';
Expand All @@ -34,7 +25,7 @@ export class DotMenuService {
getUrlById(id: string): Observable<string> {
return this.getMenuItems().pipe(
filter((res: DotMenuItem) => !res.angular && res.id === id),
pluck('url'),
map((x) => x?.url),
defaultIfEmpty('')
);
}
Expand Down Expand Up @@ -70,9 +61,11 @@ export class DotMenuService {
*/
loadMenu(force = false): Observable<DotMenu[]> {
if (!this.menu$ || force) {
this.menu$ = this.http
.get<DotCMSResponse<DotMenu>>(this.urlMenus)
.pipe(publishLast(), refCount(), pluck('entity'));
this.menu$ = this.http.get<DotCMSResponse<DotMenu>>(this.urlMenus).pipe(
publishLast(),
refCount(),
map((x) => x?.entity)
);
}

return this.menu$;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Observable } from 'rxjs';
import { HttpClient, HttpErrorResponse } from '@angular/common/http';
import { Injectable, inject } from '@angular/core';

import { catchError, map, pluck, take } from 'rxjs/operators';
import { catchError, map, take } from 'rxjs/operators';

import { DotHttpErrorManagerService } from '@dotcms/data-access';
import { CoreWebService, DotRequestOptionsArgs } from '@dotcms/dotcms-js';
Expand Down Expand Up @@ -101,7 +101,7 @@ export class DotTemplatesService {
.put<DotTemplate>(`${TEMPLATE_API_URL}_savepublish`, {
...values
})
.pipe(pluck('entity'));
.pipe(map((x) => x?.entity));
}

/**
Expand Down Expand Up @@ -198,7 +198,7 @@ export class DotTemplatesService {
const response$ = this.coreWebService.requestView<T>(options);

return response$.pipe(
pluck('entity'),
map((x) => x?.entity),
catchError((error: HttpErrorResponse) => {
return this.httpErrorManagerService.handle(error).pipe(
take(1),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Observable } from 'rxjs';

import { Injectable, inject } from '@angular/core';

import { pluck } from 'rxjs/operators';
import { map } from 'rxjs/operators';

import { CoreWebService, DotCMSResponse } from '@dotcms/dotcms-js';

Expand Down Expand Up @@ -35,15 +35,15 @@ export class NotificationsService {
.requestView({
url: this.urls.getLastNotificationsUrl
})
.pipe(pluck('bodyJsonObject'));
.pipe(map((x) => x?.bodyJsonObject));
}

getAllNotifications(): Observable<DotCMSResponse<DotNotificationResponse>> {
return this.coreWebService
.requestView({
url: this.urls.getNotificationsUrl
})
.pipe(pluck('bodyJsonObject'));
.pipe(map((x) => x?.bodyJsonObject));
}

dismissNotifications(
Expand All @@ -55,7 +55,7 @@ export class NotificationsService {
method: 'PUT',
url: this.urls.dismissNotificationsUrl
})
.pipe(pluck('bodyJsonObject'));
.pipe(map((x) => x?.bodyJsonObject));
}

markAllAsRead(): Observable<DotCMSResponse<DotNotificationResponse>> {
Expand All @@ -64,6 +64,6 @@ export class NotificationsService {
method: 'PUT',
url: this.urls.markAsReadNotificationsUrl
})
.pipe(pluck('bodyJsonObject'));
.pipe(map((x) => x?.bodyJsonObject));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { ActivatedRoute } from '@angular/router';

import { ButtonModule } from 'primeng/button';

import { pluck, take } from 'rxjs/operators';
import { map, take } from 'rxjs/operators';

import { DotRouterService } from '@dotcms/data-access';
import { DotApp, DotAppsSaveData, DotAppsSecret } from '@dotcms/dotcms-models';
Expand Down Expand Up @@ -40,13 +40,18 @@ export class DotAppsConfigurationDetailComponent implements OnInit {
formValid = false;

ngOnInit() {
this.route.data.pipe(pluck('data'), take(1)).subscribe((app: DotApp) => {
this.apps = app;
this.formFields = this.getSecrets(app.sites[0].secrets);
this.dynamicVariables = this.transformSecretsToKeyValue(
this.getSecrets(app.sites[0].secrets, true)
);
});
this.route.data
.pipe(
map((x: any) => x?.data),
take(1)
)
.subscribe((app: DotApp) => {
this.apps = app;
this.formFields = this.getSecrets(app.sites[0].secrets);
this.dynamicVariables = this.transformSecretsToKeyValue(
this.getSecrets(app.sites[0].secrets, true)
);
});
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { LazyLoadEvent } from 'primeng/api';
import { ButtonModule } from 'primeng/button';
import { InputTextModule } from 'primeng/inputtext';

import { debounceTime, pluck, take, takeUntil } from 'rxjs/operators';
import { debounceTime, map, take, takeUntil } from 'rxjs/operators';

import {
DotAlertConfirmService,
Expand Down Expand Up @@ -59,10 +59,15 @@ export class DotAppsConfigurationComponent implements OnInit, OnDestroy {
private destroy$: Subject<boolean> = new Subject<boolean>();

ngOnInit() {
this.route.data.pipe(pluck('data'), take(1)).subscribe((app: DotApp) => {
this.apps = app;
this.apps.sites = [];
});
this.route.data
.pipe(
map((x: any) => x?.data),
take(1)
)
.subscribe((app: DotApp) => {
this.apps = app;
this.apps.sites = [];
});

observableFromEvent(this.searchInput.nativeElement, 'keyup')
.pipe(debounceTime(500), takeUntil(this.destroy$))
Expand Down
Loading
Loading