From b4d6fbc390282a381e1f7cc340615c40f39e936a Mon Sep 17 00:00:00 2001 From: Luca Giamminonni Date: Mon, 2 May 2022 17:40:51 +0200 Subject: [PATCH] [CST-5249] Fixed compilation issues --- .../admin-sidebar/admin-sidebar.component.ts | 1 - .../openaire-suggestion-source.model.ts | 2 +- .../openaire-suggestion-target.model.ts | 2 +- .../models/openaire-suggestion.model.ts | 2 +- .../openaire-suggestions-data.service.ts | 4 +- .../submission/workspaceitem-data.service.ts | 31 ++++++++++++- src/app/openaire/openaire.effects.ts | 5 ++ src/app/openaire/openaire.module.ts | 2 + .../openaire/reciter-suggestions/selectors.ts | 6 +-- .../suggestion-list-element.component.html | 1 - .../suggestion-targets.component.html | 1 - .../suggestion-targets.effects.ts | 2 +- .../suggestions.service.ts | 12 ++--- .../suggestions-page.component.ts | 5 +- src/config/app-config.interface.ts | 2 + src/config/default-app-config.ts | 9 ++++ src/config/layout-config.interfaces.ts | 46 +++++++++++++++++++ 17 files changed, 112 insertions(+), 21 deletions(-) create mode 100644 src/app/openaire/openaire.effects.ts create mode 100644 src/config/layout-config.interfaces.ts diff --git a/src/app/admin/admin-sidebar/admin-sidebar.component.ts b/src/app/admin/admin-sidebar/admin-sidebar.component.ts index a8c5ef800c..b770e3d675 100644 --- a/src/app/admin/admin-sidebar/admin-sidebar.component.ts +++ b/src/app/admin/admin-sidebar/admin-sidebar.component.ts @@ -42,7 +42,6 @@ import { Router, ActivatedRoute } from '@angular/router'; import {NOTIFICATIONS_RECITER_SUGGESTION_PATH} from "../admin-notifications/admin-notifications-routing-paths"; import { MenuID } from '../../shared/menu/menu-id.model'; import { MenuItemType } from '../../shared/menu/menu-item-type.model'; -import { ActivatedRoute } from '@angular/router'; /** * Component representing the admin sidebar diff --git a/src/app/core/openaire/reciter-suggestions/models/openaire-suggestion-source.model.ts b/src/app/core/openaire/reciter-suggestions/models/openaire-suggestion-source.model.ts index 6da9fd47b9..d71b49b913 100644 --- a/src/app/core/openaire/reciter-suggestions/models/openaire-suggestion-source.model.ts +++ b/src/app/core/openaire/reciter-suggestions/models/openaire-suggestion-source.model.ts @@ -1,11 +1,11 @@ import { autoserialize, deserialize } from 'cerialize'; -import { CacheableObject } from '../../../cache/object-cache.reducer'; import { SUGGESTION_SOURCE } from './openaire-suggestion-objects.resource-type'; import { excludeFromEquals } from '../../../utilities/equals.decorators'; import { ResourceType } from '../../../shared/resource-type'; import { HALLink } from '../../../shared/hal-link.model'; import { typedObject } from '../../../cache/builders/build-decorators'; +import {CacheableObject} from "../../../cache/cacheable-object.model"; /** * The interface representing the Suggestion Source model diff --git a/src/app/core/openaire/reciter-suggestions/models/openaire-suggestion-target.model.ts b/src/app/core/openaire/reciter-suggestions/models/openaire-suggestion-target.model.ts index e35972bc79..06f85ea5b3 100644 --- a/src/app/core/openaire/reciter-suggestions/models/openaire-suggestion-target.model.ts +++ b/src/app/core/openaire/reciter-suggestions/models/openaire-suggestion-target.model.ts @@ -1,11 +1,11 @@ import { autoserialize, deserialize } from 'cerialize'; -import { CacheableObject } from '../../../cache/object-cache.reducer'; import { SUGGESTION_TARGET } from './openaire-suggestion-objects.resource-type'; import { excludeFromEquals } from '../../../utilities/equals.decorators'; import { ResourceType } from '../../../shared/resource-type'; import { HALLink } from '../../../shared/hal-link.model'; import { typedObject } from '../../../cache/builders/build-decorators'; +import {CacheableObject} from "../../../cache/cacheable-object.model"; /** * The interface representing the Suggestion Target model diff --git a/src/app/core/openaire/reciter-suggestions/models/openaire-suggestion.model.ts b/src/app/core/openaire/reciter-suggestions/models/openaire-suggestion.model.ts index 3ff5d7b630..2d28ccf9bc 100644 --- a/src/app/core/openaire/reciter-suggestions/models/openaire-suggestion.model.ts +++ b/src/app/core/openaire/reciter-suggestions/models/openaire-suggestion.model.ts @@ -1,12 +1,12 @@ import { autoserialize, autoserializeAs, deserialize } from 'cerialize'; -import { CacheableObject } from '../../../cache/object-cache.reducer'; import { SUGGESTION } from './openaire-suggestion-objects.resource-type'; import { excludeFromEquals } from '../../../utilities/equals.decorators'; import { ResourceType } from '../../../shared/resource-type'; import { HALLink } from '../../../shared/hal-link.model'; import { typedObject } from '../../../cache/builders/build-decorators'; import { MetadataMap, MetadataMapSerializer } from '../../../shared/metadata.models'; +import {CacheableObject} from "../../../cache/cacheable-object.model"; export interface SuggestionEvidences { [sectionId: string]: { diff --git a/src/app/core/openaire/reciter-suggestions/openaire-suggestions-data.service.ts b/src/app/core/openaire/reciter-suggestions/openaire-suggestions-data.service.ts index d961eaf9b5..7454caa1d9 100644 --- a/src/app/core/openaire/reciter-suggestions/openaire-suggestions-data.service.ts +++ b/src/app/core/openaire/reciter-suggestions/openaire-suggestions-data.service.ts @@ -4,14 +4,12 @@ import { Store } from '@ngrx/store'; import { Observable } from 'rxjs'; -import { CoreState } from '../../core.reducers'; import { HALEndpointService } from '../../shared/hal-endpoint.service'; import { NotificationsService } from '../../../shared/notifications/notifications.service'; import { RemoteDataBuildService } from '../../cache/builders/remote-data-build.service'; import { ObjectCacheService } from '../../cache/object-cache.service'; import { dataService } from '../../cache/builders/build-decorators'; import { RequestService } from '../../data/request.service'; -import { FindListOptions } from '../../data/request.models'; import { DataService } from '../../data/data.service'; import { ChangeAnalyzer } from '../../data/change-analyzer'; import { DefaultChangeAnalyzer } from '../../data/default-change-analyzer.service'; @@ -24,6 +22,8 @@ import { OpenaireSuggestionTarget } from './models/openaire-suggestion-target.mo import { OpenaireSuggestion } from './models/openaire-suggestion.model'; import { RequestParam } from '../../cache/models/request-param.model'; import { NoContent } from '../../shared/NoContent.model'; +import {CoreState} from "../../core-state.model"; +import {FindListOptions} from "../../data/find-list-options.model"; /* tslint:disable:max-classes-per-file */ diff --git a/src/app/core/submission/workspaceitem-data.service.ts b/src/app/core/submission/workspaceitem-data.service.ts index 1b9782834c..a4dbaab6ca 100644 --- a/src/app/core/submission/workspaceitem-data.service.ts +++ b/src/app/core/submission/workspaceitem-data.service.ts @@ -1,5 +1,5 @@ import { Injectable } from '@angular/core'; -import { HttpClient } from '@angular/common/http'; +import {HttpClient, HttpHeaders} from '@angular/common/http'; import { Store } from '@ngrx/store'; import { dataService } from '../cache/builders/build-decorators'; @@ -17,6 +17,10 @@ import { FollowLinkConfig } from '../../shared/utils/follow-link-config.model'; import { RequestParam } from '../cache/models/request-param.model'; import { CoreState } from '../core-state.model'; import { FindListOptions } from '../data/find-list-options.model'; +import {HttpOptions} from "../dspace-rest/dspace-rest.service"; +import {find, map} from "rxjs/operators"; +import {PostRequest} from "../data/request.models"; +import {hasValue} from "../../shared/empty.util"; /** * A service that provides methods to make REST requests with workspaceitems endpoint. @@ -57,4 +61,29 @@ export class WorkspaceitemDataService extends DataService { return this.findByHref(href$, useCachedVersionIfAvailable, reRequestOnStale, ...linksToFollow); } + /** + * Import an external source entry into a collection + * @param externalSourceEntryHref + * @param collectionId + */ + public importExternalSourceEntry(externalSourceEntryHref: string, collectionId: string): Observable> { + const options: HttpOptions = Object.create({}); + let headers = new HttpHeaders(); + headers = headers.append('Content-Type', 'text/uri-list'); + options.headers = headers; + + const requestId = this.requestService.generateRequestId(); + const href$ = this.halService.getEndpoint(this.linkPath).pipe(map((href) => `${href}?owningCollection=${collectionId}`)); + + href$.pipe( + find((href: string) => hasValue(href)), + map((href: string) => { + const request = new PostRequest(requestId, href, externalSourceEntryHref, options); + this.requestService.send(request); + }) + ).subscribe(); + + return this.rdbService.buildFromRequestUUID(requestId); + } + } diff --git a/src/app/openaire/openaire.effects.ts b/src/app/openaire/openaire.effects.ts new file mode 100644 index 0000000000..d771089f92 --- /dev/null +++ b/src/app/openaire/openaire.effects.ts @@ -0,0 +1,5 @@ +import { SuggestionTargetsEffects } from './reciter-suggestions/suggestion-targets/suggestion-targets.effects'; + +export const openaireEffects = [ + SuggestionTargetsEffects +]; diff --git a/src/app/openaire/openaire.module.ts b/src/app/openaire/openaire.module.ts index 22d04f3002..ace4622190 100644 --- a/src/app/openaire/openaire.module.ts +++ b/src/app/openaire/openaire.module.ts @@ -18,12 +18,14 @@ import { SuggestionsPopupComponent } from './reciter-suggestions/suggestions-pop import { SuggestionsNotificationComponent } from './reciter-suggestions/suggestions-notification/suggestions-notification.component'; import { TranslateModule } from '@ngx-translate/core'; import { SearchModule } from '../shared/search/search.module'; +import {openaireEffects} from "./openaire.effects"; const MODULES = [ CommonModule, SharedModule, CoreModule.forRoot(), StoreModule.forFeature('openaire', openaireReducers, storeModuleConfig as StoreConfig), + EffectsModule.forFeature(openaireEffects), TranslateModule ]; diff --git a/src/app/openaire/reciter-suggestions/selectors.ts b/src/app/openaire/reciter-suggestions/selectors.ts index e699b27dba..292e63472a 100644 --- a/src/app/openaire/reciter-suggestions/selectors.ts +++ b/src/app/openaire/reciter-suggestions/selectors.ts @@ -1,8 +1,8 @@ -import { createSelector, MemoizedSelector } from '@ngrx/store'; -import { subStateSelector } from '../../shared/selector.util'; +import {createFeatureSelector, createSelector, MemoizedSelector} from '@ngrx/store'; import { openaireSelector, OpenaireState } from '../openaire.reducer'; import { OpenaireSuggestionTarget } from '../../core/openaire/reciter-suggestions/models/openaire-suggestion-target.model'; import { SuggestionTargetState } from './suggestion-targets/suggestion-targets.reducer'; +import {subStateSelector} from "../../submission/selectors"; /** * Returns the Reciter Suggestion Target state. @@ -10,7 +10,7 @@ import { SuggestionTargetState } from './suggestion-targets/suggestion-targets.r * @param {AppState} state Top level state. * @return {OpenaireState} */ -const _getReciterSuggestionTargetState = (state: any) => state.openaire; +const _getReciterSuggestionTargetState = createFeatureSelector('openaire'); // Reciter Suggestion Targets // ---------------------------------------------------------------------------- diff --git a/src/app/openaire/reciter-suggestions/suggestion-list-element/suggestion-list-element.component.html b/src/app/openaire/reciter-suggestions/suggestion-list-element/suggestion-list-element.component.html index 05f9c0ac77..f37d595c45 100644 --- a/src/app/openaire/reciter-suggestions/suggestion-list-element/suggestion-list-element.component.html +++ b/src/app/openaire/reciter-suggestions/suggestion-list-element/suggestion-list-element.component.html @@ -21,7 +21,6 @@ [showLabel]="false" [object]="listableObject" [linkType]="0" - [hideMetrics]="true" > diff --git a/src/app/openaire/reciter-suggestions/suggestion-targets/suggestion-targets.effects.ts b/src/app/openaire/reciter-suggestions/suggestion-targets/suggestion-targets.effects.ts index 85e871403c..9a007fab21 100644 --- a/src/app/openaire/reciter-suggestions/suggestion-targets/suggestion-targets.effects.ts +++ b/src/app/openaire/reciter-suggestions/suggestion-targets/suggestion-targets.effects.ts @@ -81,7 +81,7 @@ export class SuggestionTargetsEffects { return this.store$.select((state: any) => state.core.auth.user) .pipe( switchMap((user: EPerson) => { - return this.suggestionsService.retrieveCurrentUserSuggestions(user) + return this.suggestionsService.retrieveCurrentUserSuggestions(user.uuid) .pipe( map((suggestionTargets: OpenaireSuggestionTarget[]) => new AddUserSuggestionsAction(suggestionTargets)), catchError((errors) => of(errors)) diff --git a/src/app/openaire/reciter-suggestions/suggestions.service.ts b/src/app/openaire/reciter-suggestions/suggestions.service.ts index de743d95e3..5908c8c6bf 100644 --- a/src/app/openaire/reciter-suggestions/suggestions.service.ts +++ b/src/app/openaire/reciter-suggestions/suggestions.service.ts @@ -5,7 +5,6 @@ import { catchError, map, mergeMap, take } from 'rxjs/operators'; import { OpenaireSuggestionsDataService } from '../../core/openaire/reciter-suggestions/openaire-suggestions-data.service'; import { SortDirection, SortOptions } from '../../core/cache/models/sort-options.model'; -import { FindListOptions } from '../../core/data/request.models'; import { RemoteData } from '../../core/data/remote-data'; import { PaginatedList } from '../../core/data/paginated-list.model'; import { OpenaireSuggestionTarget } from '../../core/openaire/reciter-suggestions/models/openaire-suggestion-target.model'; @@ -25,8 +24,9 @@ import { WorkspaceitemDataService } from '../../core/submission/workspaceitem-da import { TranslateService } from '@ngx-translate/core'; import { NoContent } from '../../core/shared/NoContent.model'; import { environment } from '../../../environments/environment'; -import { SuggestionConfig } from '../../../config/layout-config.interfaces'; import { WorkspaceItem } from '../../core/submission/models/workspaceitem.model'; +import {FindListOptions} from "../../core/data/find-list-options.model"; +import {SuggestionConfig} from "../../../config/layout-config.interfaces"; export interface SuggestionBulkResult { success: number; @@ -142,11 +142,11 @@ export class SuggestionsService { /** * Retrieve suggestion targets for the given user * - * @param user - * The EPerson object for which to retrieve suggestion targets + * @param userUuid + * The EPerson id for which to retrieve suggestion targets */ - public retrieveCurrentUserSuggestions(user: EPerson): Observable { - return this.researcherProfileService.findById(user.uuid).pipe( + public retrieveCurrentUserSuggestions(userUuid: string): Observable { + return this.researcherProfileService.findById(userUuid).pipe( mergeMap((profile: ResearcherProfile) => { if (isNotEmpty(profile)) { return this.researcherProfileService.findRelatedItemId(profile).pipe( diff --git a/src/app/suggestions-page/suggestions-page.component.ts b/src/app/suggestions-page/suggestions-page.component.ts index 911f6167de..850a30da22 100644 --- a/src/app/suggestions-page/suggestions-page.component.ts +++ b/src/app/suggestions-page/suggestions-page.component.ts @@ -8,7 +8,7 @@ import { TranslateService } from '@ngx-translate/core'; import { SortDirection, SortOptions, } from '../core/cache/models/sort-options.model'; import { PaginatedList } from '../core/data/paginated-list.model'; import { RemoteData } from '../core/data/remote-data'; -import { getFirstSucceededRemoteDataPayload, redirectOn4xx } from '../core/shared/operators'; +import { getFirstSucceededRemoteDataPayload } from '../core/shared/operators'; import { SuggestionBulkResult, SuggestionsService } from '../openaire/reciter-suggestions/suggestions.service'; import { PaginationComponentOptions } from '../shared/pagination/pagination-component-options.model'; import { OpenaireSuggestion } from '../core/openaire/reciter-suggestions/models/openaire-suggestion.model'; @@ -19,8 +19,9 @@ import { NotificationsService } from '../shared/notifications/notifications.serv import { SuggestionTargetsStateService } from '../openaire/reciter-suggestions/suggestion-targets/suggestion-targets.state.service'; import { WorkspaceitemDataService } from '../core/submission/workspaceitem-data.service'; import { PaginationService } from '../core/pagination/pagination.service'; -import { FindListOptions } from '../core/data/request.models'; import { WorkspaceItem } from '../core/submission/models/workspaceitem.model'; +import {FindListOptions} from "../core/data/find-list-options.model"; +import {redirectOn4xx} from "../core/shared/authorized.operators"; @Component({ selector: 'ds-suggestion-page', diff --git a/src/config/app-config.interface.ts b/src/config/app-config.interface.ts index 121e80cd74..6446e7f127 100644 --- a/src/config/app-config.interface.ts +++ b/src/config/app-config.interface.ts @@ -14,6 +14,7 @@ import { AuthConfig } from './auth-config.interfaces'; import { UIServerConfig } from './ui-server-config.interface'; import { MediaViewerConfig } from './media-viewer-config.interface'; import { BrowseByConfig } from './browse-by-config.interface'; +import {SuggestionConfig} from "./layout-config.interfaces"; interface AppConfig extends Config { ui: UIServerConfig; @@ -32,6 +33,7 @@ interface AppConfig extends Config { collection: CollectionPageConfig; themes: ThemeConfig[]; mediaViewer: MediaViewerConfig; + suggestion: SuggestionConfig[]; } const APP_CONFIG = new InjectionToken('APP_CONFIG'); diff --git a/src/config/default-app-config.ts b/src/config/default-app-config.ts index dc54c2fcb0..aea29fc819 100644 --- a/src/config/default-app-config.ts +++ b/src/config/default-app-config.ts @@ -14,6 +14,7 @@ import { ServerConfig } from './server-config.interface'; import { SubmissionConfig } from './submission-config.interface'; import { ThemeConfig } from './theme.model'; import { UIServerConfig } from './ui-server-config.interface'; +import {SuggestionConfig} from "./layout-config.interfaces"; export class DefaultAppConfig implements AppConfig { production = false; @@ -210,6 +211,14 @@ export class DefaultAppConfig implements AppConfig { } }; + suggestion: SuggestionConfig[] = [ + // { + // // Use this configuration to map a suggestion import to a specific collection based on the suggestion type. + // source: 'suggestionSource', + // collectionId: 'collectionUUID' + // } + ]; + // Theme Config themes: ThemeConfig[] = [ // Add additional themes here. In the case where multiple themes match a route, the first one diff --git a/src/config/layout-config.interfaces.ts b/src/config/layout-config.interfaces.ts new file mode 100644 index 0000000000..0b15a06aa9 --- /dev/null +++ b/src/config/layout-config.interfaces.ts @@ -0,0 +1,46 @@ +import { Config } from './config.interface'; + +export interface UrnConfig extends Config { + name: string; + baseUrl: string; +} + +export interface CrisRefConfig extends Config { + entityType: string; + icon: string; +} + +export interface CrisLayoutMetadataBoxConfig extends Config { + defaultMetadataLabelColStyle: string; + defaultMetadataValueColStyle: string; +} + +export interface CrisLayoutTypeConfig { + orientation: string; +} + +export interface NavbarConfig extends Config { + showCommunityCollection: boolean; +} + +export interface CrisItemPageConfig extends Config { + [entity: string]: CrisLayoutTypeConfig; + default: CrisLayoutTypeConfig; +} + + +export interface CrisLayoutConfig extends Config { + urn: UrnConfig[]; + crisRef: CrisRefConfig[]; + itemPage: CrisItemPageConfig; + metadataBox: CrisLayoutMetadataBoxConfig; +} + +export interface LayoutConfig extends Config { + navbar: NavbarConfig; +} + +export interface SuggestionConfig extends Config { + source: string; + collectionId: string; +}