mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +00:00
Merge pull request #2897 from 4Science/DURACOM-247
Fixes for #2891 #2889
This commit is contained in:
@@ -37,9 +37,9 @@ class TestModel implements HALResource {
|
|||||||
successor?: TestModel;
|
successor?: TestModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
const mockDataServiceMap: any = {
|
const mockDataServiceMap: any = new Map([
|
||||||
[TEST_MODEL.value]: () => import('../../../shared/testing/test-data-service.mock').then(m => m.TestDataService),
|
[TEST_MODEL.value, () => import('../../../shared/testing/test-data-service.mock').then(m => m.TestDataService)],
|
||||||
};
|
]);
|
||||||
|
|
||||||
let testDataService: TestDataService;
|
let testDataService: TestDataService;
|
||||||
|
|
||||||
|
7
src/app/core/cache/builders/link.service.ts
vendored
7
src/app/core/cache/builders/link.service.ts
vendored
@@ -1,7 +1,6 @@
|
|||||||
import {
|
import {
|
||||||
Inject,
|
Inject,
|
||||||
Injectable,
|
Injectable,
|
||||||
InjectionToken,
|
|
||||||
Injector,
|
Injector,
|
||||||
} from '@angular/core';
|
} from '@angular/core';
|
||||||
import {
|
import {
|
||||||
@@ -25,7 +24,7 @@ import { FollowLinkConfig } from '../../../shared/utils/follow-link-config.model
|
|||||||
import { HALDataService } from '../../data/base/hal-data-service.interface';
|
import { HALDataService } from '../../data/base/hal-data-service.interface';
|
||||||
import { PaginatedList } from '../../data/paginated-list.model';
|
import { PaginatedList } from '../../data/paginated-list.model';
|
||||||
import { RemoteData } from '../../data/remote-data';
|
import { RemoteData } from '../../data/remote-data';
|
||||||
import { lazyService } from '../../lazy-service';
|
import { lazyDataService } from '../../lazy-data-service';
|
||||||
import { GenericConstructor } from '../../shared/generic-constructor';
|
import { GenericConstructor } from '../../shared/generic-constructor';
|
||||||
import { HALResource } from '../../shared/hal-resource.model';
|
import { HALResource } from '../../shared/hal-resource.model';
|
||||||
import {
|
import {
|
||||||
@@ -43,7 +42,7 @@ export class LinkService {
|
|||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
protected injector: Injector,
|
protected injector: Injector,
|
||||||
@Inject(APP_DATA_SERVICES_MAP) private map: InjectionToken<LazyDataServicesMap>,
|
@Inject(APP_DATA_SERVICES_MAP) private map: LazyDataServicesMap,
|
||||||
@Inject(LINK_DEFINITION_FACTORY) private getLinkDefinition: <T extends HALResource>(source: GenericConstructor<T>, linkName: keyof T['_links']) => LinkDefinition<T>,
|
@Inject(LINK_DEFINITION_FACTORY) private getLinkDefinition: <T extends HALResource>(source: GenericConstructor<T>, linkName: keyof T['_links']) => LinkDefinition<T>,
|
||||||
@Inject(LINK_DEFINITION_MAP_FACTORY) private getLinkDefinitions: <T extends HALResource>(source: GenericConstructor<T>) => Map<keyof T['_links'], LinkDefinition<T>>,
|
@Inject(LINK_DEFINITION_MAP_FACTORY) private getLinkDefinitions: <T extends HALResource>(source: GenericConstructor<T>) => Map<keyof T['_links'], LinkDefinition<T>>,
|
||||||
) {
|
) {
|
||||||
@@ -73,7 +72,7 @@ export class LinkService {
|
|||||||
public resolveLinkWithoutAttaching<T extends HALResource, U extends HALResource>(model, linkToFollow: FollowLinkConfig<T>): Observable<RemoteData<U | PaginatedList<U>>> {
|
public resolveLinkWithoutAttaching<T extends HALResource, U extends HALResource>(model, linkToFollow: FollowLinkConfig<T>): Observable<RemoteData<U | PaginatedList<U>>> {
|
||||||
const matchingLinkDef = this.getLinkDefinition(model.constructor, linkToFollow.name);
|
const matchingLinkDef = this.getLinkDefinition(model.constructor, linkToFollow.name);
|
||||||
if (hasValue(matchingLinkDef)) {
|
if (hasValue(matchingLinkDef)) {
|
||||||
const lazyProvider$: Observable<HALDataService<any>> = lazyService(this.map[matchingLinkDef.resourceType.value], this.injector);
|
const lazyProvider$: Observable<HALDataService<any>> = lazyDataService(this.map, matchingLinkDef.resourceType.value, this.injector);
|
||||||
return lazyProvider$.pipe(
|
return lazyProvider$.pipe(
|
||||||
switchMap((provider: HALDataService<any>) => {
|
switchMap((provider: HALDataService<any>) => {
|
||||||
const link = model._links[matchingLinkDef.linkName];
|
const link = model._links[matchingLinkDef.linkName];
|
||||||
|
@@ -69,73 +69,71 @@ import { CLAIMED_TASK } from './tasks/models/claimed-task-object.resource-type';
|
|||||||
import { POOL_TASK } from './tasks/models/pool-task-object.resource-type';
|
import { POOL_TASK } from './tasks/models/pool-task-object.resource-type';
|
||||||
import { WORKFLOW_ACTION } from './tasks/models/workflow-action-object.resource-type';
|
import { WORKFLOW_ACTION } from './tasks/models/workflow-action-object.resource-type';
|
||||||
|
|
||||||
export const LAZY_DATA_SERVICES: LazyDataServicesMap = {
|
export const LAZY_DATA_SERVICES: LazyDataServicesMap = new Map([
|
||||||
[AUTHORIZATION.value]: () => import('./data/feature-authorization/authorization-data.service').then(m => m.AuthorizationDataService),
|
[AUTHORIZATION.value, () => import('./data/feature-authorization/authorization-data.service').then(m => m.AuthorizationDataService)],
|
||||||
[BROWSE_DEFINITION.value]: () => import('./browse/browse-definition-data.service').then(m => m.BrowseDefinitionDataService),
|
[BROWSE_DEFINITION.value, () => import('./browse/browse-definition-data.service').then(m => m.BrowseDefinitionDataService)],
|
||||||
[BULK_ACCESS_CONDITION_OPTIONS.value]: () => import('./config/bulk-access-config-data.service').then(m => m.BulkAccessConfigDataService),
|
[BULK_ACCESS_CONDITION_OPTIONS.value, () => import('./config/bulk-access-config-data.service').then(m => m.BulkAccessConfigDataService)],
|
||||||
[METADATA_SCHEMA.value]: () => import('./data/metadata-schema-data.service').then(m => m.MetadataSchemaDataService),
|
[METADATA_SCHEMA.value, () => import('./data/metadata-schema-data.service').then(m => m.MetadataSchemaDataService)],
|
||||||
[SUBMISSION_UPLOADS_TYPE.value]: () => import('./config/submission-uploads-config-data.service').then(m => m.SubmissionUploadsConfigDataService),
|
[SUBMISSION_UPLOADS_TYPE.value, () => import('./config/submission-uploads-config-data.service').then(m => m.SubmissionUploadsConfigDataService)],
|
||||||
[BITSTREAM.value]: () => import('./data/bitstream-data.service').then(m => m.BitstreamDataService),
|
[BITSTREAM.value, () => import('./data/bitstream-data.service').then(m => m.BitstreamDataService)],
|
||||||
[SUBMISSION_ACCESSES_TYPE.value]: () => import('./config/submission-accesses-config-data.service').then(m => m.SubmissionAccessesConfigDataService),
|
[SUBMISSION_ACCESSES_TYPE.value, () => import('./config/submission-accesses-config-data.service').then(m => m.SubmissionAccessesConfigDataService)],
|
||||||
[SYSTEMWIDEALERT.value]: () => import('./data/system-wide-alert-data.service').then(m => m.SystemWideAlertDataService),
|
[SYSTEMWIDEALERT.value, () => import('./data/system-wide-alert-data.service').then(m => m.SystemWideAlertDataService)],
|
||||||
[USAGE_REPORT.value]: () => import('./statistics/usage-report-data.service').then(m => m.UsageReportDataService),
|
[USAGE_REPORT.value, () => import('./statistics/usage-report-data.service').then(m => m.UsageReportDataService)],
|
||||||
[ACCESS_STATUS.value]: () => import('./data/access-status-data.service').then(m => m.AccessStatusDataService),
|
[ACCESS_STATUS.value, () => import('./data/access-status-data.service').then(m => m.AccessStatusDataService)],
|
||||||
[COLLECTION.value]: () => import('./data/collection-data.service').then(m => m.CollectionDataService),
|
[COLLECTION.value, () => import('./data/collection-data.service').then(m => m.CollectionDataService)],
|
||||||
[CLAIMED_TASK.value]: () => import('./tasks/claimed-task-data.service').then(m => m.ClaimedTaskDataService),
|
[CLAIMED_TASK.value, () => import('./tasks/claimed-task-data.service').then(m => m.ClaimedTaskDataService)],
|
||||||
[VOCABULARY_ENTRY.value]: () => import('./data/href-only-data.service').then(m => m.HrefOnlyDataService),
|
[VOCABULARY_ENTRY.value, () => import('./data/href-only-data.service').then(m => m.HrefOnlyDataService)],
|
||||||
[ITEM_TYPE.value]: () => import('./data/href-only-data.service').then(m => m.HrefOnlyDataService),
|
[ITEM_TYPE.value, () => import('./data/href-only-data.service').then(m => m.HrefOnlyDataService)],
|
||||||
[LICENSE.value]: () => import('./data/href-only-data.service').then(m => m.HrefOnlyDataService),
|
[LICENSE.value, () => import('./data/href-only-data.service').then(m => m.HrefOnlyDataService)],
|
||||||
[SUBSCRIPTION.value]: () => import('../shared/subscriptions/subscriptions-data.service').then(m => m.SubscriptionsDataService),
|
[SUBSCRIPTION.value, () => import('../shared/subscriptions/subscriptions-data.service').then(m => m.SubscriptionsDataService)],
|
||||||
[COMMUNITY.value]: () => import('./data/community-data.service').then(m => m.CommunityDataService),
|
[COMMUNITY.value, () => import('./data/community-data.service').then(m => m.CommunityDataService)],
|
||||||
[VOCABULARY.value]: () => import('./submission/vocabularies/vocabulary.data.service').then(m => m.VocabularyDataService),
|
[VOCABULARY.value, () => import('./submission/vocabularies/vocabulary.data.service').then(m => m.VocabularyDataService)],
|
||||||
[BUNDLE.value]: () => import('./data/bundle-data.service').then(m => m.BundleDataService),
|
[BUNDLE.value, () => import('./data/bundle-data.service').then(m => m.BundleDataService)],
|
||||||
[CONFIG_PROPERTY.value]: () => import('./data/configuration-data.service').then(m => m.ConfigurationDataService),
|
[CONFIG_PROPERTY.value, () => import('./data/configuration-data.service').then(m => m.ConfigurationDataService)],
|
||||||
[POOL_TASK.value]: () => import('./tasks/pool-task-data.service').then(m => m.PoolTaskDataService),
|
[POOL_TASK.value, () => import('./tasks/pool-task-data.service').then(m => m.PoolTaskDataService)],
|
||||||
[CLAIMED_TASK.value]: () => import('./tasks/claimed-task-data.service').then(m => m.ClaimedTaskDataService),
|
[CLAIMED_TASK.value, () => import('./tasks/claimed-task-data.service').then(m => m.ClaimedTaskDataService)],
|
||||||
[SUPERVISION_ORDER.value]: () => import('./supervision-order/supervision-order-data.service').then(m => m.SupervisionOrderDataService),
|
[SUPERVISION_ORDER.value, () => import('./supervision-order/supervision-order-data.service').then(m => m.SupervisionOrderDataService)],
|
||||||
[WORKSPACEITEM.value]: () => import('./submission/workspaceitem-data.service').then(m => m.WorkspaceitemDataService),
|
[WORKSPACEITEM.value, () => import('./submission/workspaceitem-data.service').then(m => m.WorkspaceitemDataService)],
|
||||||
[WORKFLOWITEM.value]: () => import('./submission/workflowitem-data.service').then(m => m.WorkflowItemDataService),
|
[WORKFLOWITEM.value, () => import('./submission/workflowitem-data.service').then(m => m.WorkflowItemDataService)],
|
||||||
[VOCABULARY.value]: () => import('./submission/vocabularies/vocabulary.data.service').then(m => m.VocabularyDataService),
|
[VOCABULARY.value, () => import('./submission/vocabularies/vocabulary.data.service').then(m => m.VocabularyDataService)],
|
||||||
[VOCABULARY_ENTRY_DETAIL.value]: () => import('./submission/vocabularies/vocabulary-entry-details.data.service').then(m => m.VocabularyEntryDetailsDataService),
|
[VOCABULARY_ENTRY_DETAIL.value, () => import('./submission/vocabularies/vocabulary-entry-details.data.service').then(m => m.VocabularyEntryDetailsDataService)],
|
||||||
[SUBMISSION_CC_LICENSE_URL.value]: () => import('./submission/submission-cc-license-url-data.service').then(m => m.SubmissionCcLicenseUrlDataService),
|
[SUBMISSION_CC_LICENSE_URL.value, () => import('./submission/submission-cc-license-url-data.service').then(m => m.SubmissionCcLicenseUrlDataService)],
|
||||||
[SUBMISSION_CC_LICENSE.value]: () => import('./submission/submission-cc-license-data.service').then(m => m.SubmissionCcLicenseDataService),
|
[SUBMISSION_CC_LICENSE.value, () => import('./submission/submission-cc-license-data.service').then(m => m.SubmissionCcLicenseDataService)],
|
||||||
[USAGE_REPORT.value]: () => import('./statistics/usage-report-data.service').then(m => m.UsageReportDataService),
|
[USAGE_REPORT.value, () => import('./statistics/usage-report-data.service').then(m => m.UsageReportDataService)],
|
||||||
[RESOURCE_POLICY.value]: () => import('./resource-policy/resource-policy-data.service').then(m => m.ResourcePolicyDataService),
|
[RESOURCE_POLICY.value, () => import('./resource-policy/resource-policy-data.service').then(m => m.ResourcePolicyDataService)],
|
||||||
[RESEARCHER_PROFILE.value]: () => import('./profile/researcher-profile-data.service').then(m => m.ResearcherProfileDataService),
|
[RESEARCHER_PROFILE.value, () => import('./profile/researcher-profile-data.service').then(m => m.ResearcherProfileDataService)],
|
||||||
[ORCID_QUEUE.value]: () => import('./orcid/orcid-queue-data.service').then(m => m.OrcidQueueDataService),
|
[ORCID_QUEUE.value, () => import('./orcid/orcid-queue-data.service').then(m => m.OrcidQueueDataService)],
|
||||||
[ORCID_HISTORY.value]: () => import('./orcid/orcid-history-data.service').then(m => m.OrcidHistoryDataService),
|
[ORCID_HISTORY.value, () => import('./orcid/orcid-history-data.service').then(m => m.OrcidHistoryDataService)],
|
||||||
[FEEDBACK.value]: () => import('./feedback/feedback-data.service').then(m => m.FeedbackDataService),
|
[FEEDBACK.value, () => import('./feedback/feedback-data.service').then(m => m.FeedbackDataService)],
|
||||||
[GROUP.value]: () => import('./eperson/group-data.service').then(m => m.GroupDataService),
|
[GROUP.value, () => import('./eperson/group-data.service').then(m => m.GroupDataService)],
|
||||||
[EPERSON.value]: () => import('./eperson/eperson-data.service').then(m => m.EPersonDataService),
|
[EPERSON.value, () => import('./eperson/eperson-data.service').then(m => m.EPersonDataService)],
|
||||||
[WORKFLOW_ACTION.value]: () => import('./data/workflow-action-data.service').then(m => m.WorkflowActionDataService),
|
[WORKFLOW_ACTION.value, () => import('./data/workflow-action-data.service').then(m => m.WorkflowActionDataService)],
|
||||||
[VERSION_HISTORY.value]: () => import('./data/version-history-data.service').then(m => m.VersionHistoryDataService),
|
[VERSION_HISTORY.value, () => import('./data/version-history-data.service').then(m => m.VersionHistoryDataService)],
|
||||||
[SITE.value]: () => import('./data/site-data.service').then(m => m.SiteDataService),
|
[SITE.value, () => import('./data/site-data.service').then(m => m.SiteDataService)],
|
||||||
[ROOT.value]: () => import('./data/root-data.service').then(m => m.RootDataService),
|
[ROOT.value, () => import('./data/root-data.service').then(m => m.RootDataService)],
|
||||||
[RELATIONSHIP_TYPE.value]: () => import('./data/relationship-type-data.service').then(m => m.RelationshipTypeDataService),
|
[RELATIONSHIP_TYPE.value, () => import('./data/relationship-type-data.service').then(m => m.RelationshipTypeDataService)],
|
||||||
[RELATIONSHIP.value]: () => import('./data/relationship-data.service').then(m => m.RelationshipDataService),
|
[RELATIONSHIP.value, () => import('./data/relationship-data.service').then(m => m.RelationshipDataService)],
|
||||||
[SCRIPT.value]: () => import('./data/processes/script-data.service').then(m => m.ScriptDataService),
|
[SCRIPT.value, () => import('./data/processes/script-data.service').then(m => m.ScriptDataService)],
|
||||||
[PROCESS.value]: () => import('./data/processes/process-data.service').then(m => m.ProcessDataService),
|
[PROCESS.value, () => import('./data/processes/process-data.service').then(m => m.ProcessDataService)],
|
||||||
[METADATA_FIELD.value]: () => import('./data/metadata-field-data.service').then(m => m.MetadataFieldDataService),
|
[METADATA_FIELD.value, () => import('./data/metadata-field-data.service').then(m => m.MetadataFieldDataService)],
|
||||||
[ITEM.value]: () => import('./data/item-data.service').then(m => m.ItemDataService),
|
[ITEM.value, () => import('./data/item-data.service').then(m => m.ItemDataService)],
|
||||||
[VERSION.value]: () => import('./data/version-data.service').then(m => m.VersionDataService),
|
[VERSION.value, () => import('./data/version-data.service').then(m => m.VersionDataService)],
|
||||||
[IDENTIFIERS.value]: () => import('./data/identifier-data.service').then(m => m.IdentifierDataService),
|
[IDENTIFIERS.value, () => import('./data/identifier-data.service').then(m => m.IdentifierDataService)],
|
||||||
[FEATURE.value]: () => import('./data/feature-authorization/authorization-data.service').then(m => m.AuthorizationDataService),
|
[FEATURE.value, () => import('./data/feature-authorization/authorization-data.service').then(m => m.AuthorizationDataService)],
|
||||||
[DSPACE_OBJECT.value]: () => import('./data/dspace-object-data.service').then(m => m.DSpaceObjectDataService),
|
[DSPACE_OBJECT.value, () => import('./data/dspace-object-data.service').then(m => m.DSpaceObjectDataService)],
|
||||||
[BITSTREAM_FORMAT.value]: () => import('./data/bitstream-format-data.service').then(m => m.BitstreamFormatDataService),
|
[BITSTREAM_FORMAT.value, () => import('./data/bitstream-format-data.service').then(m => m.BitstreamFormatDataService)],
|
||||||
[SUBMISSION_COAR_NOTIFY_CONFIG.value]: () => import('../submission/sections/section-coar-notify/coar-notify-config-data.service').then(m => m.CoarNotifyConfigDataService),
|
[SUBMISSION_COAR_NOTIFY_CONFIG.value, () => import('../submission/sections/section-coar-notify/coar-notify-config-data.service').then(m => m.CoarNotifyConfigDataService)],
|
||||||
[LDN_SERVICE_CONSTRAINT_FILTERS.value]: () => import('../admin/admin-ldn-services/ldn-services-data/ldn-itemfilters-data.service').then(m => m.LdnItemfiltersService),
|
[LDN_SERVICE_CONSTRAINT_FILTERS.value, () => import('../admin/admin-ldn-services/ldn-services-data/ldn-itemfilters-data.service').then(m => m.LdnItemfiltersService)],
|
||||||
[LDN_SERVICE.value]: () => import('../admin/admin-ldn-services/ldn-services-data/ldn-services-data.service').then(m => m.LdnServicesService),
|
[LDN_SERVICE.value, () => import('../admin/admin-ldn-services/ldn-services-data/ldn-services-data.service').then(m => m.LdnServicesService)],
|
||||||
[ADMIN_NOTIFY_MESSAGE.value]: () => import('../admin/admin-notify-dashboard/services/admin-notify-messages.service').then(m => m.AdminNotifyMessagesService),
|
[ADMIN_NOTIFY_MESSAGE.value, () => import('../admin/admin-notify-dashboard/services/admin-notify-messages.service').then(m => m.AdminNotifyMessagesService)],
|
||||||
[SUBMISSION_FORMS_TYPE.value]: () => import('./config/submission-forms-config-data.service').then(m => m.SubmissionFormsConfigDataService),
|
[SUBMISSION_FORMS_TYPE.value, () => import('./config/submission-forms-config-data.service').then(m => m.SubmissionFormsConfigDataService)],
|
||||||
[NOTIFYREQUEST.value]: () => import('./data/notify-services-status-data.service').then(m => m.NotifyRequestsStatusDataService),
|
[NOTIFYREQUEST.value, () => import('./data/notify-services-status-data.service').then(m => m.NotifyRequestsStatusDataService)],
|
||||||
[QUALITY_ASSURANCE_EVENT_OBJECT.value]: () => import('./notifications/qa/events/quality-assurance-event-data.service').then(m => m.QualityAssuranceEventDataService),
|
[QUALITY_ASSURANCE_EVENT_OBJECT.value, () => import('./notifications/qa/events/quality-assurance-event-data.service').then(m => m.QualityAssuranceEventDataService)],
|
||||||
[QUALITY_ASSURANCE_SOURCE_OBJECT.value]: () => import('./notifications/qa/source/quality-assurance-source-data.service').then(m => m.QualityAssuranceSourceDataService),
|
[QUALITY_ASSURANCE_SOURCE_OBJECT.value, () => import('./notifications/qa/source/quality-assurance-source-data.service').then(m => m.QualityAssuranceSourceDataService)],
|
||||||
[QUALITY_ASSURANCE_TOPIC_OBJECT.value]: () => import('./notifications/qa/topics/quality-assurance-topic-data.service').then(m => m.QualityAssuranceTopicDataService),
|
[QUALITY_ASSURANCE_TOPIC_OBJECT.value, () => import('./notifications/qa/topics/quality-assurance-topic-data.service').then(m => m.QualityAssuranceTopicDataService)],
|
||||||
[SUGGESTION.value]: () => import('./notifications/suggestions-data.service').then(m => m.SuggestionsDataService),
|
[SUGGESTION.value, () => import('./notifications/suggestions-data.service').then(m => m.SuggestionsDataService)],
|
||||||
[SUGGESTION_SOURCE.value]: () => import('./notifications/source/suggestion-source-data.service').then(m => m.SuggestionSourceDataService),
|
[SUGGESTION_SOURCE.value, () => import('./notifications/source/suggestion-source-data.service').then(m => m.SuggestionSourceDataService)],
|
||||||
[SUGGESTION_TARGET.value]: () => import('./notifications/target/suggestion-target-data.service').then(m => m.SuggestionTargetDataService),
|
[SUGGESTION_TARGET.value, () => import('./notifications/target/suggestion-target-data.service').then(m => m.SuggestionTargetDataService)],
|
||||||
[DUPLICATE.value]: () => import('./submission/submission-duplicate-data.service').then(m => m.SubmissionDuplicateDataService),
|
[DUPLICATE.value, () => import('./submission/submission-duplicate-data.service').then(m => m.SubmissionDuplicateDataService)],
|
||||||
[CorrectionType.type.value]: () => import('./submission/correctiontype-data.service').then(m => m.CorrectionTypeDataService),
|
[CorrectionType.type.value, () => import('./submission/correctiontype-data.service').then(m => m.CorrectionTypeDataService)],
|
||||||
};
|
]);
|
||||||
|
|
||||||
|
|
||||||
|
@@ -13,6 +13,7 @@ import {
|
|||||||
map,
|
map,
|
||||||
mergeMap,
|
mergeMap,
|
||||||
take,
|
take,
|
||||||
|
withLatestFrom,
|
||||||
} from 'rxjs/operators';
|
} from 'rxjs/operators';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
@@ -25,6 +26,7 @@ import { ParsedResponse } from '../cache/response.models';
|
|||||||
import { DSpaceSerializer } from '../dspace-rest/dspace.serializer';
|
import { DSpaceSerializer } from '../dspace-rest/dspace.serializer';
|
||||||
import { DspaceRestService } from '../dspace-rest/dspace-rest.service';
|
import { DspaceRestService } from '../dspace-rest/dspace-rest.service';
|
||||||
import { RawRestResponse } from '../dspace-rest/raw-rest-response.model';
|
import { RawRestResponse } from '../dspace-rest/raw-rest-response.model';
|
||||||
|
import { XSRFService } from '../xsrf/xsrf.service';
|
||||||
import {
|
import {
|
||||||
RequestActionTypes,
|
RequestActionTypes,
|
||||||
RequestErrorAction,
|
RequestErrorAction,
|
||||||
@@ -35,6 +37,7 @@ import {
|
|||||||
import { RequestService } from './request.service';
|
import { RequestService } from './request.service';
|
||||||
import { RequestEntry } from './request-entry.model';
|
import { RequestEntry } from './request-entry.model';
|
||||||
import { RequestError } from './request-error.model';
|
import { RequestError } from './request-error.model';
|
||||||
|
import { RestRequestMethod } from './rest-request-method';
|
||||||
import { RestRequestWithResponseParser } from './rest-request-with-response-parser.model';
|
import { RestRequestWithResponseParser } from './rest-request-with-response-parser.model';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
@@ -48,7 +51,11 @@ export class RequestEffects {
|
|||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
filter((entry: RequestEntry) => hasValue(entry)),
|
filter((entry: RequestEntry) => hasValue(entry)),
|
||||||
map((entry: RequestEntry) => entry.request),
|
withLatestFrom(this.xsrfService.tokenInitialized$),
|
||||||
|
// If it's a GET request, or we have an XSRF token, dispatch it immediately
|
||||||
|
// Otherwise wait for the XSRF token first
|
||||||
|
filter(([entry, tokenInitialized]: [RequestEntry, boolean]) => entry.request.method === RestRequestMethod.GET || tokenInitialized === true),
|
||||||
|
map(([entry, tokenInitialized]: [RequestEntry, boolean]) => entry.request),
|
||||||
mergeMap((request: RestRequestWithResponseParser) => {
|
mergeMap((request: RestRequestWithResponseParser) => {
|
||||||
let body = request.body;
|
let body = request.body;
|
||||||
if (isNotEmpty(request.body) && !request.isMultipart) {
|
if (isNotEmpty(request.body) && !request.isMultipart) {
|
||||||
@@ -89,6 +96,7 @@ export class RequestEffects {
|
|||||||
private restApi: DspaceRestService,
|
private restApi: DspaceRestService,
|
||||||
private injector: Injector,
|
private injector: Injector,
|
||||||
protected requestService: RequestService,
|
protected requestService: RequestService,
|
||||||
|
protected xsrfService: XSRFService,
|
||||||
) { }
|
) { }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -17,7 +17,6 @@ import {
|
|||||||
getTestScheduler,
|
getTestScheduler,
|
||||||
} from 'jasmine-marbles';
|
} from 'jasmine-marbles';
|
||||||
import {
|
import {
|
||||||
BehaviorSubject,
|
|
||||||
EMPTY,
|
EMPTY,
|
||||||
Observable,
|
Observable,
|
||||||
of as observableOf,
|
of as observableOf,
|
||||||
@@ -34,7 +33,6 @@ import { ObjectCacheService } from '../cache/object-cache.service';
|
|||||||
import { coreReducers } from '../core.reducers';
|
import { coreReducers } from '../core.reducers';
|
||||||
import { CoreState } from '../core-state.model';
|
import { CoreState } from '../core-state.model';
|
||||||
import { UUIDService } from '../shared/uuid.service';
|
import { UUIDService } from '../shared/uuid.service';
|
||||||
import { XSRFService } from '../xsrf/xsrf.service';
|
|
||||||
import {
|
import {
|
||||||
RequestConfigureAction,
|
RequestConfigureAction,
|
||||||
RequestExecuteAction,
|
RequestExecuteAction,
|
||||||
@@ -62,7 +60,6 @@ describe('RequestService', () => {
|
|||||||
let uuidService: UUIDService;
|
let uuidService: UUIDService;
|
||||||
let store: Store<CoreState>;
|
let store: Store<CoreState>;
|
||||||
let mockStore: MockStore<CoreState>;
|
let mockStore: MockStore<CoreState>;
|
||||||
let xsrfService: XSRFService;
|
|
||||||
|
|
||||||
const testUUID = '5f2a0d2a-effa-4d54-bd54-5663b960f9eb';
|
const testUUID = '5f2a0d2a-effa-4d54-bd54-5663b960f9eb';
|
||||||
const testHref = 'https://rest.api/endpoint/selfLink';
|
const testHref = 'https://rest.api/endpoint/selfLink';
|
||||||
@@ -108,16 +105,11 @@ describe('RequestService', () => {
|
|||||||
store = TestBed.inject(Store);
|
store = TestBed.inject(Store);
|
||||||
mockStore = store as MockStore<CoreState>;
|
mockStore = store as MockStore<CoreState>;
|
||||||
mockStore.setState(initialState);
|
mockStore.setState(initialState);
|
||||||
xsrfService = {
|
|
||||||
tokenInitialized$: new BehaviorSubject(false),
|
|
||||||
} as XSRFService;
|
|
||||||
|
|
||||||
service = new RequestService(
|
service = new RequestService(
|
||||||
objectCache,
|
objectCache,
|
||||||
uuidService,
|
uuidService,
|
||||||
store,
|
store,
|
||||||
xsrfService,
|
|
||||||
undefined,
|
|
||||||
);
|
);
|
||||||
serviceAsAny = service as any;
|
serviceAsAny = service as any;
|
||||||
});
|
});
|
||||||
|
@@ -34,16 +34,12 @@ import { ObjectCacheService } from '../cache/object-cache.service';
|
|||||||
import { CommitSSBAction } from '../cache/server-sync-buffer.actions';
|
import { CommitSSBAction } from '../cache/server-sync-buffer.actions';
|
||||||
import { coreSelector } from '../core.selectors';
|
import { coreSelector } from '../core.selectors';
|
||||||
import { CoreState } from '../core-state.model';
|
import { CoreState } from '../core-state.model';
|
||||||
import {
|
import { IndexState } from '../index/index.reducer';
|
||||||
IndexState,
|
|
||||||
MetaIndexState,
|
|
||||||
} from '../index/index.reducer';
|
|
||||||
import {
|
import {
|
||||||
getUrlWithoutEmbedParams,
|
getUrlWithoutEmbedParams,
|
||||||
requestIndexSelector,
|
requestIndexSelector,
|
||||||
} from '../index/index.selectors';
|
} from '../index/index.selectors';
|
||||||
import { UUIDService } from '../shared/uuid.service';
|
import { UUIDService } from '../shared/uuid.service';
|
||||||
import { XSRFService } from '../xsrf/xsrf.service';
|
|
||||||
import {
|
import {
|
||||||
RequestConfigureAction,
|
RequestConfigureAction,
|
||||||
RequestExecuteAction,
|
RequestExecuteAction,
|
||||||
@@ -169,9 +165,7 @@ export class RequestService {
|
|||||||
|
|
||||||
constructor(private objectCache: ObjectCacheService,
|
constructor(private objectCache: ObjectCacheService,
|
||||||
private uuidService: UUIDService,
|
private uuidService: UUIDService,
|
||||||
private store: Store<CoreState>,
|
private store: Store<CoreState>) {
|
||||||
protected xsrfService: XSRFService,
|
|
||||||
private indexStore: Store<MetaIndexState>) {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
generateRequestId(): string {
|
generateRequestId(): string {
|
||||||
@@ -455,17 +449,7 @@ export class RequestService {
|
|||||||
private dispatchRequest(request: RestRequest) {
|
private dispatchRequest(request: RestRequest) {
|
||||||
asapScheduler.schedule(() => {
|
asapScheduler.schedule(() => {
|
||||||
this.store.dispatch(new RequestConfigureAction(request));
|
this.store.dispatch(new RequestConfigureAction(request));
|
||||||
// If it's a GET request, or we have an XSRF token, dispatch it immediately
|
|
||||||
if (request.method === RestRequestMethod.GET || this.xsrfService.tokenInitialized$.getValue() === true) {
|
|
||||||
this.store.dispatch(new RequestExecuteAction(request.uuid));
|
this.store.dispatch(new RequestExecuteAction(request.uuid));
|
||||||
} else {
|
|
||||||
// Otherwise wait for the XSRF token first
|
|
||||||
this.xsrfService.tokenInitialized$.pipe(
|
|
||||||
find((hasInitialized: boolean) => hasInitialized === true),
|
|
||||||
).subscribe(() => {
|
|
||||||
this.store.dispatch(new RequestExecuteAction(request.uuid));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
50
src/app/core/lazy-data-service.ts
Normal file
50
src/app/core/lazy-data-service.ts
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
import {
|
||||||
|
Injector,
|
||||||
|
Type,
|
||||||
|
} from '@angular/core';
|
||||||
|
import {
|
||||||
|
defer,
|
||||||
|
Observable,
|
||||||
|
} from 'rxjs';
|
||||||
|
|
||||||
|
import { LazyDataServicesMap } from '../../config/app-config.interface';
|
||||||
|
import { HALDataService } from './data/base/hal-data-service.interface';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loads a service lazily. The service is loaded when the observable is subscribed to.
|
||||||
|
*
|
||||||
|
* @param dataServicesMap A map of promises returning the data services to load
|
||||||
|
* @param key The key of the service
|
||||||
|
* @param injector The injector to use to load the service. If not provided, the current injector is used.
|
||||||
|
* @returns An observable of the service.
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* ```ts
|
||||||
|
* const dataService$ = lazyDataService({ 'data-service': () => import('./data-service').then((m) => m.MyService)}, 'data-service', this.injector);
|
||||||
|
* or
|
||||||
|
* const dataService$ = lazyDataService({'data-service': () => import('./data-service')}, 'data-service', this.injector);
|
||||||
|
* ```
|
||||||
|
*/
|
||||||
|
export function lazyDataService<T>(
|
||||||
|
dataServicesMap: LazyDataServicesMap,
|
||||||
|
key: string,
|
||||||
|
injector: Injector,
|
||||||
|
): Observable<T> {
|
||||||
|
return defer(() => {
|
||||||
|
if (dataServicesMap.has(key) && typeof dataServicesMap.get(key) === 'function') {
|
||||||
|
const loader: () => Promise<Type<HALDataService<any>> | { default: HALDataService<any> }> = dataServicesMap.get(key);
|
||||||
|
return loader()
|
||||||
|
.then((serviceOrDefault) => {
|
||||||
|
if ('default' in serviceOrDefault) {
|
||||||
|
return injector!.get(serviceOrDefault.default);
|
||||||
|
}
|
||||||
|
return injector!.get(serviceOrDefault);
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
throw error;
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
@@ -1,40 +0,0 @@
|
|||||||
import {
|
|
||||||
Injector,
|
|
||||||
Type,
|
|
||||||
} from '@angular/core';
|
|
||||||
import {
|
|
||||||
defer,
|
|
||||||
Observable,
|
|
||||||
} from 'rxjs';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Loads a service lazily. The service is loaded when the observable is subscribed to.
|
|
||||||
*
|
|
||||||
* @param loader A function that returns a promise of the service to load.
|
|
||||||
* @param injector The injector to use to load the service. If not provided, the current injector is used.
|
|
||||||
* @returns An observable of the service.
|
|
||||||
*
|
|
||||||
* @example
|
|
||||||
* ```ts
|
|
||||||
* const dataService$ = lazyService(() => import('./data-service').then((m) => m.MyService), this.injector);
|
|
||||||
* or
|
|
||||||
* const dataService$ = lazyService(() => import('./data-service'), this.injector);
|
|
||||||
* ```
|
|
||||||
*/
|
|
||||||
export function lazyService<T>(
|
|
||||||
loader: () => Promise<Type<T>> | Promise<{ default: Type<T> }>,
|
|
||||||
injector: Injector,
|
|
||||||
): Observable<T> {
|
|
||||||
return defer(() => {
|
|
||||||
return loader()
|
|
||||||
.then((serviceOrDefault) => {
|
|
||||||
if ('default' in serviceOrDefault) {
|
|
||||||
return injector!.get(serviceOrDefault.default);
|
|
||||||
}
|
|
||||||
return injector!.get(serviceOrDefault);
|
|
||||||
})
|
|
||||||
.catch((error) => {
|
|
||||||
throw error;
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
@@ -38,9 +38,9 @@ const REINSTATE_BTN = 'reinstate';
|
|||||||
const SAVE_BTN = 'save';
|
const SAVE_BTN = 'save';
|
||||||
const DISCARD_BTN = 'discard';
|
const DISCARD_BTN = 'discard';
|
||||||
|
|
||||||
const mockDataServiceMap: any = {
|
const mockDataServiceMap: any = new Map([
|
||||||
[ITEM.value]: () => import('../../shared/testing/test-data-service.mock').then(m => m.TestDataService),
|
[ITEM.value, () => import('../../shared/testing/test-data-service.mock').then(m => m.TestDataService)],
|
||||||
};
|
]);
|
||||||
|
|
||||||
describe('DsoEditMetadataComponent', () => {
|
describe('DsoEditMetadataComponent', () => {
|
||||||
let component: DsoEditMetadataComponent;
|
let component: DsoEditMetadataComponent;
|
||||||
|
@@ -7,7 +7,6 @@ import {
|
|||||||
ChangeDetectorRef,
|
ChangeDetectorRef,
|
||||||
Component,
|
Component,
|
||||||
Inject,
|
Inject,
|
||||||
InjectionToken,
|
|
||||||
Injector,
|
Injector,
|
||||||
Input,
|
Input,
|
||||||
OnDestroy,
|
OnDestroy,
|
||||||
@@ -42,7 +41,7 @@ import {
|
|||||||
import { ArrayMoveChangeAnalyzer } from '../../core/data/array-move-change-analyzer.service';
|
import { ArrayMoveChangeAnalyzer } from '../../core/data/array-move-change-analyzer.service';
|
||||||
import { RemoteData } from '../../core/data/remote-data';
|
import { RemoteData } from '../../core/data/remote-data';
|
||||||
import { UpdateDataService } from '../../core/data/update-data.service';
|
import { UpdateDataService } from '../../core/data/update-data.service';
|
||||||
import { lazyService } from '../../core/lazy-service';
|
import { lazyDataService } from '../../core/lazy-data-service';
|
||||||
import { DSpaceObject } from '../../core/shared/dspace-object.model';
|
import { DSpaceObject } from '../../core/shared/dspace-object.model';
|
||||||
import { getFirstCompletedRemoteData } from '../../core/shared/operators';
|
import { getFirstCompletedRemoteData } from '../../core/shared/operators';
|
||||||
import { ResourceType } from '../../core/shared/resource-type';
|
import { ResourceType } from '../../core/shared/resource-type';
|
||||||
@@ -152,7 +151,7 @@ export class DsoEditMetadataComponent implements OnInit, OnDestroy {
|
|||||||
protected parentInjector: Injector,
|
protected parentInjector: Injector,
|
||||||
protected arrayMoveChangeAnalyser: ArrayMoveChangeAnalyzer<number>,
|
protected arrayMoveChangeAnalyser: ArrayMoveChangeAnalyzer<number>,
|
||||||
protected cdr: ChangeDetectorRef,
|
protected cdr: ChangeDetectorRef,
|
||||||
@Inject(APP_DATA_SERVICES_MAP) private dataServiceMap: InjectionToken<LazyDataServicesMap>) {
|
@Inject(APP_DATA_SERVICES_MAP) private dataServiceMap: LazyDataServicesMap) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -186,7 +185,7 @@ export class DsoEditMetadataComponent implements OnInit, OnDestroy {
|
|||||||
*/
|
*/
|
||||||
retrieveDataService(): Observable<UpdateDataService<DSpaceObject>> {
|
retrieveDataService(): Observable<UpdateDataService<DSpaceObject>> {
|
||||||
if (hasNoValue(this.updateDataService)) {
|
if (hasNoValue(this.updateDataService)) {
|
||||||
const lazyProvider$: Observable<UpdateDataService<DSpaceObject>> = lazyService(this.dataServiceMap[this.dsoType], this.parentInjector);
|
const lazyProvider$: Observable<UpdateDataService<DSpaceObject>> = lazyDataService(this.dataServiceMap, this.dsoType, this.parentInjector);
|
||||||
return lazyProvider$;
|
return lazyProvider$;
|
||||||
} else {
|
} else {
|
||||||
return EMPTY;
|
return EMPTY;
|
||||||
|
@@ -17,7 +17,10 @@ import { cold } from 'jasmine-marbles';
|
|||||||
import uniqueId from 'lodash/uniqueId';
|
import uniqueId from 'lodash/uniqueId';
|
||||||
import { of as observableOf } from 'rxjs';
|
import { of as observableOf } from 'rxjs';
|
||||||
|
|
||||||
import { APP_DATA_SERVICES_MAP } from '../../../config/app-config.interface';
|
import {
|
||||||
|
APP_DATA_SERVICES_MAP,
|
||||||
|
LazyDataServicesMap,
|
||||||
|
} from '../../../config/app-config.interface';
|
||||||
import { DSONameService } from '../../core/breadcrumbs/dso-name.service';
|
import { DSONameService } from '../../core/breadcrumbs/dso-name.service';
|
||||||
import { buildPaginatedList } from '../../core/data/paginated-list.model';
|
import { buildPaginatedList } from '../../core/data/paginated-list.model';
|
||||||
import { RequestService } from '../../core/data/request.service';
|
import { RequestService } from '../../core/data/request.service';
|
||||||
@@ -41,10 +44,10 @@ import { SearchEvent } from './eperson-group-list-event-type';
|
|||||||
import { EpersonSearchBoxComponent } from './eperson-search-box/eperson-search-box.component';
|
import { EpersonSearchBoxComponent } from './eperson-search-box/eperson-search-box.component';
|
||||||
import { GroupSearchBoxComponent } from './group-search-box/group-search-box.component';
|
import { GroupSearchBoxComponent } from './group-search-box/group-search-box.component';
|
||||||
|
|
||||||
const mockDataServiceMap: any = {
|
const mockDataServiceMap: LazyDataServicesMap = new Map([
|
||||||
[EPERSON.value]: () => import('../../core/eperson/eperson-data.service').then(m => m.EPersonDataService),
|
[EPERSON.value, () => import('../../core/eperson/eperson-data.service').then(m => m.EPersonDataService)],
|
||||||
[GROUP.value]: () => import('../../core/eperson/group-data.service').then(m => m.GroupDataService),
|
[GROUP.value, () => import('../../core/eperson/group-data.service').then(m => m.GroupDataService)],
|
||||||
};
|
]);
|
||||||
|
|
||||||
describe('EpersonGroupListComponent test suite', () => {
|
describe('EpersonGroupListComponent test suite', () => {
|
||||||
let comp: EpersonGroupListComponent;
|
let comp: EpersonGroupListComponent;
|
||||||
|
@@ -7,7 +7,6 @@ import {
|
|||||||
Component,
|
Component,
|
||||||
EventEmitter,
|
EventEmitter,
|
||||||
Inject,
|
Inject,
|
||||||
InjectionToken,
|
|
||||||
Injector,
|
Injector,
|
||||||
Input,
|
Input,
|
||||||
OnDestroy,
|
OnDestroy,
|
||||||
@@ -35,7 +34,7 @@ import { EPersonDataService } from '../../core/eperson/eperson-data.service';
|
|||||||
import { GroupDataService } from '../../core/eperson/group-data.service';
|
import { GroupDataService } from '../../core/eperson/group-data.service';
|
||||||
import { EPERSON } from '../../core/eperson/models/eperson.resource-type';
|
import { EPERSON } from '../../core/eperson/models/eperson.resource-type';
|
||||||
import { GROUP } from '../../core/eperson/models/group.resource-type';
|
import { GROUP } from '../../core/eperson/models/group.resource-type';
|
||||||
import { lazyService } from '../../core/lazy-service';
|
import { lazyDataService } from '../../core/lazy-data-service';
|
||||||
import { PaginationService } from '../../core/pagination/pagination.service';
|
import { PaginationService } from '../../core/pagination/pagination.service';
|
||||||
import { DSpaceObject } from '../../core/shared/dspace-object.model';
|
import { DSpaceObject } from '../../core/shared/dspace-object.model';
|
||||||
import { getFirstCompletedRemoteData } from '../../core/shared/operators';
|
import { getFirstCompletedRemoteData } from '../../core/shared/operators';
|
||||||
@@ -133,7 +132,7 @@ export class EpersonGroupListComponent implements OnInit, OnDestroy {
|
|||||||
constructor(public dsoNameService: DSONameService,
|
constructor(public dsoNameService: DSONameService,
|
||||||
private parentInjector: Injector,
|
private parentInjector: Injector,
|
||||||
private paginationService: PaginationService,
|
private paginationService: PaginationService,
|
||||||
@Inject(APP_DATA_SERVICES_MAP) private dataServiceMap: InjectionToken<LazyDataServicesMap>) {
|
@Inject(APP_DATA_SERVICES_MAP) private dataServiceMap: LazyDataServicesMap) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -141,7 +140,7 @@ export class EpersonGroupListComponent implements OnInit, OnDestroy {
|
|||||||
*/
|
*/
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
const resourceType: ResourceType = (this.isListOfEPerson) ? EPERSON : GROUP;
|
const resourceType: ResourceType = (this.isListOfEPerson) ? EPERSON : GROUP;
|
||||||
const lazyProvider$: Observable<EPersonDataService | GroupDataService> = lazyService(this.dataServiceMap[resourceType.value], this.parentInjector);
|
const lazyProvider$: Observable<EPersonDataService | GroupDataService> = lazyDataService(this.dataServiceMap, resourceType.value, this.parentInjector);
|
||||||
lazyProvider$.subscribe((dataService: EPersonDataService | GroupDataService) => {
|
lazyProvider$.subscribe((dataService: EPersonDataService | GroupDataService) => {
|
||||||
this.dataService = dataService;
|
this.dataService = dataService;
|
||||||
console.log(dataService);
|
console.log(dataService);
|
||||||
|
@@ -1,6 +1,5 @@
|
|||||||
import {
|
import {
|
||||||
inject,
|
inject,
|
||||||
InjectionToken,
|
|
||||||
Injector,
|
Injector,
|
||||||
} from '@angular/core';
|
} from '@angular/core';
|
||||||
import {
|
import {
|
||||||
@@ -12,10 +11,13 @@ import {
|
|||||||
import { Observable } from 'rxjs';
|
import { Observable } from 'rxjs';
|
||||||
import { switchMap } from 'rxjs/operators';
|
import { switchMap } from 'rxjs/operators';
|
||||||
|
|
||||||
import { LazyDataServicesMap } from '../../../../config/app-config.interface';
|
import {
|
||||||
|
APP_DATA_SERVICES_MAP,
|
||||||
|
LazyDataServicesMap,
|
||||||
|
} from '../../../../config/app-config.interface';
|
||||||
import { IdentifiableDataService } from '../../../core/data/base/identifiable-data.service';
|
import { IdentifiableDataService } from '../../../core/data/base/identifiable-data.service';
|
||||||
import { RemoteData } from '../../../core/data/remote-data';
|
import { RemoteData } from '../../../core/data/remote-data';
|
||||||
import { lazyService } from '../../../core/lazy-service';
|
import { lazyDataService } from '../../../core/lazy-data-service';
|
||||||
import { DSpaceObject } from '../../../core/shared/dspace-object.model';
|
import { DSpaceObject } from '../../../core/shared/dspace-object.model';
|
||||||
import { getFirstCompletedRemoteData } from '../../../core/shared/operators';
|
import { getFirstCompletedRemoteData } from '../../../core/shared/operators';
|
||||||
import { ResourceType } from '../../../core/shared/resource-type';
|
import { ResourceType } from '../../../core/shared/resource-type';
|
||||||
@@ -34,7 +36,7 @@ import { isEmpty } from '../../empty.util';
|
|||||||
export const resourcePolicyTargetResolver: ResolveFn<RemoteData<DSpaceObject>> = (
|
export const resourcePolicyTargetResolver: ResolveFn<RemoteData<DSpaceObject>> = (
|
||||||
route: ActivatedRouteSnapshot,
|
route: ActivatedRouteSnapshot,
|
||||||
state: RouterStateSnapshot,
|
state: RouterStateSnapshot,
|
||||||
dataServiceMap: InjectionToken<LazyDataServicesMap> = inject(InjectionToken<LazyDataServicesMap>),
|
dataServiceMap: LazyDataServicesMap = inject(APP_DATA_SERVICES_MAP),
|
||||||
parentInjector: Injector = inject(Injector),
|
parentInjector: Injector = inject(Injector),
|
||||||
router: Router = inject(Router),
|
router: Router = inject(Router),
|
||||||
): Observable<RemoteData<DSpaceObject>> => {
|
): Observable<RemoteData<DSpaceObject>> => {
|
||||||
@@ -46,7 +48,7 @@ export const resourcePolicyTargetResolver: ResolveFn<RemoteData<DSpaceObject>> =
|
|||||||
}
|
}
|
||||||
|
|
||||||
const resourceType: ResourceType = new ResourceType(targetType);
|
const resourceType: ResourceType = new ResourceType(targetType);
|
||||||
const lazyProvider$: Observable<IdentifiableDataService<DSpaceObject>> = lazyService(dataServiceMap[resourceType.value], parentInjector);
|
const lazyProvider$: Observable<IdentifiableDataService<DSpaceObject>> = lazyDataService(dataServiceMap, resourceType.value, parentInjector);
|
||||||
|
|
||||||
return lazyProvider$.pipe(
|
return lazyProvider$.pipe(
|
||||||
switchMap((dataService: IdentifiableDataService<DSpaceObject>) => {
|
switchMap((dataService: IdentifiableDataService<DSpaceObject>) => {
|
||||||
|
@@ -73,9 +73,7 @@ const APP_CONFIG = new InjectionToken<AppConfig>('APP_CONFIG');
|
|||||||
|
|
||||||
const APP_CONFIG_STATE = makeStateKey<AppConfig>('APP_CONFIG_STATE');
|
const APP_CONFIG_STATE = makeStateKey<AppConfig>('APP_CONFIG_STATE');
|
||||||
|
|
||||||
export interface LazyDataServicesMap {
|
export type LazyDataServicesMap = Map<string, () => Promise<Type<HALDataService<any>> | { default: HALDataService<any> }>>;
|
||||||
[type: string]: () => Promise<Type<HALDataService<any>>>
|
|
||||||
}
|
|
||||||
|
|
||||||
export const APP_DATA_SERVICES_MAP: InjectionToken<LazyDataServicesMap> = new InjectionToken<LazyDataServicesMap>('APP_DATA_SERVICES_MAP');
|
export const APP_DATA_SERVICES_MAP: InjectionToken<LazyDataServicesMap> = new InjectionToken<LazyDataServicesMap>('APP_DATA_SERVICES_MAP');
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user