Something went wrong on our end
-
Giuseppe Digilio authored
Merge remote-tracking branch 'remotes/origin/master' into submission # Conflicts: # package.json # src/app/+admin/admin-registries/metadata-schema/metadata-schema.component.spec.ts # src/app/+search-page/search-service/search.service.spec.ts # src/app/app.module.ts # src/app/core/auth/auth.interceptor.ts # src/app/core/cache/response-cache.service.spec.ts # src/app/core/data/browse-response-parsing.service.spec.ts # src/app/core/data/data.service.spec.ts # src/app/core/data/request.service.spec.ts # src/app/core/data/request.service.ts # src/app/core/dspace-rest-v2/dspace-rest-v2.service.ts # src/app/core/integration/integration.service.ts # src/app/core/metadata/metadata.service.spec.ts # src/app/core/registry/registry.service.spec.ts # src/app/core/shared/collection.model.ts # src/app/core/shared/item.model.ts # src/app/shared/form/builder/ds-dynamic-form-ui/models/dynamic-group/dynamic-group.component.spec.ts # src/app/shared/form/builder/ds-dynamic-form-ui/models/dynamic-group/dynamic-group.components.ts # src/app/shared/form/builder/ds-dynamic-form-ui/models/list/dynamic-list.component.ts # src/app/shared/form/builder/ds-dynamic-form-ui/models/lookup/dynamic-lookup.component.spec.ts # src/app/shared/form/builder/ds-dynamic-form-ui/models/lookup/dynamic-lookup.component.ts # src/app/shared/form/builder/ds-dynamic-form-ui/models/scrollable-dropdown/dynamic-scrollable-dropdown.component.ts # src/app/shared/form/builder/ds-dynamic-form-ui/models/tag/dynamic-tag.component.spec.ts # src/app/shared/form/builder/ds-dynamic-form-ui/models/tag/dynamic-tag.component.ts # src/app/shared/form/builder/ds-dynamic-form-ui/models/typeahead/dynamic-typeahead.component.ts # src/app/shared/form/builder/form-builder.service.spec.ts # src/app/shared/form/form.service.spec.ts # src/app/shared/notifications/notification/notification.component.spec.ts # src/app/shared/services/route.service.spec.ts # src/app/shared/services/route.service.ts # src/app/shared/shared.module.ts # yarn.lock
ff97a4cc
community-data.service.ts 2.28 KiB
import {mergeMap, filter, take} from 'rxjs/operators';
import { Injectable } from '@angular/core';
import { Store } from '@ngrx/store';
import { RemoteDataBuildService } from '../cache/builders/remote-data-build.service';
import { NormalizedCommunity } from '../cache/models/normalized-community.model';
import { ObjectCacheService } from '../cache/object-cache.service';
import { ResponseCacheService } from '../cache/response-cache.service';
import { CoreState } from '../core.reducers';
import { Community } from '../shared/community.model';
import { ComColDataService } from './comcol-data.service';
import { RequestService } from './request.service';
import { HALEndpointService } from '../shared/hal-endpoint.service';
import { FindAllOptions, FindAllRequest } from './request.models';
import { RemoteData } from './remote-data';
import { hasValue, isNotEmpty } from '../../shared/empty.util';
import { Observable } from 'rxjs';
import { PaginatedList } from './paginated-list';
@Injectable()
export class CommunityDataService extends ComColDataService<NormalizedCommunity, Community> {
protected linkPath = 'communities';
protected topLinkPath = 'communities/search/top';
protected cds = this;
protected forceBypassCache = false;
constructor(
protected responseCache: ResponseCacheService,
protected requestService: RequestService,
protected rdbService: RemoteDataBuildService,
protected store: Store<CoreState>,
protected objectCache: ObjectCacheService,
protected halService: HALEndpointService
) {
super();
}
getEndpoint() {
return this.halService.getEndpoint(this.linkPath);
}
findTop(options: FindAllOptions = {}): Observable<RemoteData<PaginatedList<Community>>> {
const hrefObs = this.halService.getEndpoint(this.topLinkPath).pipe(filter((href: string) => isNotEmpty(href)),
mergeMap((endpoint: string) => this.getFindAllHref(options)),);
hrefObs.pipe(
filter((href: string) => hasValue(href)),
take(1),)
.subscribe((href: string) => {
const request = new FindAllRequest(this.requestService.generateRequestId(), href, options);
this.requestService.configure(request);
});
return this.rdbService.buildList<NormalizedCommunity, Community>(hrefObs) as Observable<RemoteData<PaginatedList<Community>>>;
}
}