Skip to content

Commit

Permalink
Merge branch 'dspace-cris-7' into DSC-763
Browse files Browse the repository at this point in the history
  • Loading branch information
corrado lombardi committed Dec 29, 2022
2 parents 8c1d7f2 + 5fc0085 commit bbc7e55
Show file tree
Hide file tree
Showing 20 changed files with 213 additions and 99 deletions.
49 changes: 49 additions & 0 deletions src/app/core/data/bitstream-data.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -331,4 +331,53 @@ export class BitstreamDataService extends IdentifiableDataService<Bitstream> imp
...linksToFollow
);
}

/**
* Returns an observable of {@link RemoteData} of a {@link Bitstream} that is not marked
* hidden (that hasn't got the metadata `bitstream.hide` or its value is not true/yes).
* resolve {@link HALLink}s of the object
*
* @param uuid The item UUID to retrieve bitstreams from
* @param bundlename Bundle type of the bitstreams
* @param metadataFilters Array of object we want to filter by
* @param options The {@link FindListOptions} for the request
* @param useCachedVersionIfAvailable If this is true, the request will only be sent if there's
* no valid cached version. Defaults to true
* @param reRequestOnStale Whether or not the request should automatically be re-
* requested after the response becomes stale
* @param linksToFollow List of {@link FollowLinkConfig} that indicate which
* {@link HALLink}s should be automatically resolved
*/
findShowableBitstreamsByItem(
uuid: string,
bundlename: string,
metadataFilters: MetadataFilter[],
options: FindListOptions,
useCachedVersionIfAvailable = true,
reRequestOnStale = true,
...linksToFollow: FollowLinkConfig<Bitstream>[]
): Observable<RemoteData<PaginatedList<Bitstream>>> {
const searchParams = [];
searchParams.push(new RequestParam('uuid', uuid));
searchParams.push(new RequestParam('name', bundlename));

metadataFilters.forEach((entry: MetadataFilter) => {
searchParams.push(new RequestParam('filterMetadata', entry.metadataName));
searchParams.push(new RequestParam('filterMetadataValue', entry.metadataValue));
});

const hrefObs = this.getSearchByHref(
'showableByItem',
{ searchParams },
...linksToFollow
);

return this.findListByHref(
hrefObs,
options,
useCachedVersionIfAvailable,
reRequestOnStale,
...linksToFollow
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export class QualityAssuranceSuggestionDataService extends IdentifiableDataServi
protected halService: HALEndpointService,
protected notificationsService: NotificationsService
) {
super('suggestiontargets', requestService, rdbService, objectCache, halService);
super('suggestions', requestService, rdbService, objectCache, halService);
this.deleteData = new DeleteDataImpl(this.linkPath, requestService, rdbService, objectCache, halService, notificationsService, this.responseMsToLive, this.constructIdEndpoint);
this.findAllData = new FindAllDataImpl(this.linkPath, requestService, rdbService, objectCache, halService, this.responseMsToLive);
this.searchData = new SearchDataImpl(this.linkPath, requestService, rdbService, objectCache, halService, this.responseMsToLive);
Expand Down
4 changes: 2 additions & 2 deletions src/app/core/services/link-head.service.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Injectable, RendererFactory2, ViewEncapsulation, Inject } from '@angular/core';
import { Inject, Injectable, RendererFactory2, ViewEncapsulation } from '@angular/core';
import { DOCUMENT } from '@angular/common';

/**
Expand Down Expand Up @@ -68,7 +68,7 @@ export class LinkHeadService {
renderer.removeChild(head, link);
}
} catch (e) {
console.log('Error while removing tag ' + e.message);
console.error('Error while removing tag ' + e.message);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/core/services/server-hard-redirect.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export class ServerHardRedirectService extends HardRedirectService {
status = 302;
}

console.log(`Redirecting from ${this.req.url} to ${url} with ${status}`);
console.info(`Redirecting from ${this.req.url} to ${url} with ${status}`);
this.res.redirect(status, url);
this.res.end();
// I haven't found a way to correctly stop Angular rendering.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import { BehaviorSubject } from 'rxjs';
import { map, take } from 'rxjs/operators';

import { FieldRenderingType, MetadataBoxFieldRendering } from '../metadata-box.decorator';
import { BitstreamRenderingModelComponent } from '../bitstream-rendering-model';
import { BitstreamDataService } from '../../../../../../../core/data/bitstream-data.service';
import { Bitstream } from '../../../../../../../core/shared/bitstream.model';
import { Item } from '../../../../../../../core/shared/item.model';
import { LayoutField } from '../../../../../../../core/layout/models/box.model';
import { environment } from '../../../../../../../../environments/environment';
import { FindListOptions } from '../../../../../../../core/data/find-list-options.model';
import { PaginatedList } from '../../../../../../../core/data/paginated-list.model';
import { BitstreamAttachmentRenderingModelComponent } from './bitstream-attachment-rendering.model';

@Component({
selector: 'ds-attachment',
Expand All @@ -23,7 +23,7 @@ import { PaginatedList } from '../../../../../../../core/data/paginated-list.mod
/**
* The component for displaying a thumbnail rendered metadata box
*/
export class AttachmentComponent extends BitstreamRenderingModelComponent implements OnInit {
export class AttachmentComponent extends BitstreamAttachmentRenderingModelComponent implements OnInit {

/**
* List of bitstreams to show
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { FindListOptions } from '../../../../../../../core/data/find-list-options.model';
import { Observable } from 'rxjs';
import { buildPaginatedList, PaginatedList } from '../../../../../../../core/data/paginated-list.model';
import { Bitstream } from '../../../../../../../core/shared/bitstream.model';
import { followLink } from '../../../../../../../shared/utils/follow-link-config.model';
import { getFirstCompletedRemoteData } from '../../../../../../../core/shared/operators';
import { map } from 'rxjs/operators';
import { RemoteData } from '../../../../../../../core/data/remote-data';
import { Component, Inject } from '@angular/core';
import { LayoutField } from '../../../../../../../core/layout/models/box.model';
import { Item } from '../../../../../../../core/shared/item.model';
import { BitstreamDataService } from '../../../../../../../core/data/bitstream-data.service';
import { TranslateService } from '@ngx-translate/core';
import { BitstreamRenderingModelComponent } from '../bitstream-rendering-model';

/**
* This class defines the basic model to extends for create a new
* bitstream-attachment field render component.
* This will render all bitstreams that aren't marked hidden.
*/
@Component({
template: ''
})
export abstract class BitstreamAttachmentRenderingModelComponent extends BitstreamRenderingModelComponent {
constructor(
@Inject('fieldProvider') fieldProvider: LayoutField,
@Inject('itemProvider') itemProvider: Item,
@Inject('renderingSubTypeProvider') renderingSubTypeProvider: string,
bitstreamDataService: BitstreamDataService,
translateService: TranslateService
) {
super(fieldProvider, itemProvider, renderingSubTypeProvider, bitstreamDataService, translateService);
}

getBitstreamsByItem(options?: FindListOptions): Observable<PaginatedList<Bitstream>> {
return this.bitstreamDataService
.findShowableBitstreamsByItem(this.item.uuid, this.field.bitstream.bundle, this.getMetadataFilters(), options, false, false, followLink('thumbnail'))
.pipe(
getFirstCompletedRemoteData(),
map((response: RemoteData<PaginatedList<Bitstream>>) => {
return response.hasSucceeded ? response.payload : buildPaginatedList(null, []);
})
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -124,16 +124,8 @@ export abstract class BitstreamRenderingModelComponent extends RenderingTypeStru
* @param options The {@link FindListOptions} for the request
*/
getBitstreamsByItem(options?: FindListOptions): Observable<PaginatedList<Bitstream>> {
let filters: MetadataFilter[] = [];
if (isNotEmpty(this.field.bitstream.metadataValue)) {
filters.push({
metadataName: this.field.bitstream.metadataField,
metadataValue: this.field.bitstream.metadataValue
});
}

return this.bitstreamDataService
.findByItem(this.item.uuid, this.field.bitstream.bundle, filters, options, false, false, followLink('thumbnail'))
.findByItem(this.item.uuid, this.field.bitstream.bundle, this.getMetadataFilters(), options, false, false, followLink('thumbnail'))
.pipe(
getFirstCompletedRemoteData(),
map((response: RemoteData<PaginatedList<Bitstream>>) => {
Expand All @@ -142,5 +134,22 @@ export abstract class BitstreamRenderingModelComponent extends RenderingTypeStru
);
}

/**
* Composes the {@link MetadataFilter} array used as filter
* while retrieving bitstream from remote services.
*
* @protected
*/
protected getMetadataFilters(): MetadataFilter[] {
let filters: MetadataFilter[] = [];
if (isNotEmpty(this.field.bitstream.metadataValue)) {
filters.push({
metadataName: this.field.bitstream.metadataField,
metadataValue: this.field.bitstream.metadataValue
});
}
return filters;
}


}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Injectable } from '@angular/core';

import { Store } from '@ngrx/store';
import { Actions, Effect, ofType } from '@ngrx/effects';
import { Actions, createEffect, ofType } from '@ngrx/effects';
import { TranslateService } from '@ngx-translate/core';
import { catchError, map, switchMap, tap } from 'rxjs/operators';
import { of } from 'rxjs';
Expand All @@ -18,7 +18,9 @@ import { PaginatedList } from '../../../core/data/paginated-list.model';
import { SuggestionsService } from '../suggestions.service';
import { NotificationsService } from '../../../shared/notifications/notifications.service';
import { AuthActionTypes, RetrieveAuthenticatedEpersonSuccessAction } from '../../../core/auth/auth.actions';
import { OpenaireSuggestionTarget } from '../../../core/openaire/reciter-suggestions/models/openaire-suggestion-target.model';
import {
OpenaireSuggestionTarget
} from '../../../core/openaire/reciter-suggestions/models/openaire-suggestion-target.model';
import { EPerson } from '../../../core/eperson/models/eperson.model';

/**
Expand All @@ -30,7 +32,7 @@ export class SuggestionTargetsEffects {
/**
* Retrieve all Suggestion Targets managing pagination and errors.
*/
@Effect() retrieveTargetsBySource$ = this.actions$.pipe(
retrieveTargetsBySource$ = createEffect(() => this.actions$.pipe(
ofType(SuggestionTargetActionTypes.RETRIEVE_TARGETS_BY_SOURCE),
switchMap((action: RetrieveTargetsBySourceAction) => {
return this.suggestionsService.getTargets(
Expand All @@ -49,33 +51,33 @@ export class SuggestionTargetsEffects {
})
);
})
);
));

/**
* Show a notification on error.
*/
@Effect({ dispatch: false }) retrieveAllTargetsErrorAction$ = this.actions$.pipe(
retrieveAllTargetsErrorAction$ = createEffect(() => this.actions$.pipe(
ofType(SuggestionTargetActionTypes.RETRIEVE_TARGETS_BY_SOURCE_ERROR),
tap(() => {
this.notificationsService.error(null, this.translate.get('reciter.suggestion.target.error.service.retrieve'));
})
);
), { dispatch: false });

/**
* Show a notification on error.
*/
@Effect() retrieveUserTargets$ = this.actions$.pipe(
retrieveUserTargets$ = createEffect(() => this.actions$.pipe(
ofType(AuthActionTypes.RETRIEVE_AUTHENTICATED_EPERSON_SUCCESS),
switchMap((action: RetrieveAuthenticatedEpersonSuccessAction) => {
return this.suggestionsService.retrieveCurrentUserSuggestions(action.payload).pipe(
map((suggestionTargets: OpenaireSuggestionTarget[]) => new AddUserSuggestionsAction(suggestionTargets))
);
}));
})));

/**
* Fetch the current user suggestion
*/
@Effect() refreshUserTargets$ = this.actions$.pipe(
refreshUserTargets$ = createEffect(() => this.actions$.pipe(
ofType(SuggestionTargetActionTypes.REFRESH_USER_SUGGESTIONS),
switchMap((action: RefreshUserSuggestionsAction) => {
return this.store$.select((state: any) => state.core.auth.user)
Expand All @@ -89,7 +91,7 @@ export class SuggestionTargetsEffects {
}),
catchError((errors) => of(errors))
);
}));
})));

/**
* Initialize the effect class variables.
Expand Down
11 changes: 4 additions & 7 deletions src/app/openaire/reciter-suggestions/suggestions.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import { AuthService } from '../../core/auth/auth.service';
import { EPerson } from '../../core/eperson/models/eperson.model';
import { hasValue, isNotEmpty } from '../../shared/empty.util';
import {
getAllSucceededRemoteDataPayload,
getFinishedRemoteData,
getFirstSucceededRemoteDataPayload,
getFirstSucceededRemoteListPayload
Expand Down Expand Up @@ -131,7 +130,7 @@ export class SuggestionsService {
* @return Observable<RemoteData<PaginatedList<OpenaireSuggestion>>>
* The list of Suggestion.
*/
public getSuggestions(targetId: string, elementsPerPage, currentPage, sortOptions: SortOptions): Observable<PaginatedList<OpenaireSuggestion>> {
public getSuggestions(targetId: string, elementsPerPage, currentPage, sortOptions: SortOptions): Observable<RemoteData<PaginatedList<OpenaireSuggestion>>> {
const [source, target] = targetId.split(':');

const findListOptions: FindListOptions = {
Expand All @@ -140,9 +139,7 @@ export class SuggestionsService {
sort: sortOptions
};

return this.suggestionsDataService.getSuggestionsByTargetAndSource(target, source, findListOptions).pipe(
getAllSucceededRemoteDataPayload()
);
return this.suggestionsDataService.getSuggestionsByTargetAndSource(target, source, findListOptions);
}

/**
Expand Down Expand Up @@ -176,12 +173,12 @@ export class SuggestionsService {
* The EPerson object for which to retrieve suggestion targets
*/
public retrieveCurrentUserSuggestions(user: EPerson): Observable<OpenaireSuggestionTarget[]> {
return this.researcherProfileService.findById(user.id, false, true, followLink('item')).pipe(
return this.researcherProfileService.findById(user.id, true, true, followLink('item')).pipe(
getFirstSucceededRemoteDataPayload(),
mergeMap((researcherProfile) => this.researcherProfileService.findRelatedItemId(researcherProfile).pipe(
mergeMap((itemId: string) => {
if (isNotEmpty(itemId)) {
return this.suggestionTargetsDataService.getTargetsByUser(itemId).pipe(
return this.suggestionTargetsDataService.getTargetsByUser(itemId, {}, false).pipe(
getFirstSucceededRemoteListPayload()
);
} else {
Expand Down
1 change: 0 additions & 1 deletion src/app/process-page/detail/process-detail.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ export class ProcessDetailComponent implements OnInit {
* Sets the outputLogs when retrieved and sets the showOutputLogs boolean to show them and hide the button.
*/
showProcessOutputLogs() {
console.log('showProcessOutputLogs');
this.retrievingOutputLogs$.next(true);
this.zone.runOutsideAngular(() => {
const processOutputRD$: Observable<RemoteData<Bitstream>> = this.processRD$.pipe(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,7 @@ export class ProfilePageAccessTokenComponent implements OnInit {
}

ngOnInit(): void {
console.log(this.user);
this.tokenAlreadyExists.next(this.user.machineTokenGenerated);
console.log(this.tokenAlreadyExists.value);
}

/**
Expand Down Expand Up @@ -108,7 +106,6 @@ export class ProfilePageAccessTokenComponent implements OnInit {
if (response.hasSucceeded) {
this.generatedToken.next(response.payload.value);
this.tokenAlreadyExists.next(true);
console.log(response, response.hasSucceeded);
} else {
this.notificationService.error(null, this.translate.instant('profile.card.access-token.create.error'));
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/shared/cookies/browser-klaro.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export class BrowserKlaroService extends KlaroService {
if (hideRegistrationVerification) {
servicesToHideArray.push(CAPTCHA_NAME);
}
console.log(servicesToHideArray);

return servicesToHideArray;
})
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export abstract class BaseEmbeddedMetricComponent extends BaseMetricComponent im
notifier.next(null);
notifier.complete();
} catch (error) {
console.log('Error applying script for ' + this.metric.metricType + '. Retry');
console.error('Error applying script for ' + this.metric.metricType + '. Retry');
}
}

Expand Down
Loading

0 comments on commit bbc7e55

Please sign in to comment.