mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 01:54:15 +00:00
Resolve feedback
Inject environment rather than importing it Redo the configuration for better consistency across pages
This commit is contained in:
@@ -175,9 +175,20 @@ browseBy:
|
||||
# The absolute lowest year to display in the dropdown (only used when no lowest date can be found for all items)
|
||||
defaultLowerLimit: 1900
|
||||
|
||||
browseCommunities:
|
||||
communityListPageSize: 20
|
||||
topLevelPageSize: 5
|
||||
communityList:
|
||||
# No. of communities to list per expansion (show more)
|
||||
pageSize: 20
|
||||
|
||||
homePage:
|
||||
recentSubmissions:
|
||||
# The number of item showing in recent submission components
|
||||
pageSize: 5
|
||||
# Sort record of recent submission
|
||||
sortField: 'dc.date.accessioned'
|
||||
topLevelCommunityList:
|
||||
# No. of communities to list per page on the home page
|
||||
# This will always round to the nearest number from the list of page sizes. e.g. if you set it to 7 it'll use 10
|
||||
pageSize: 5
|
||||
|
||||
# Item Config
|
||||
item:
|
||||
@@ -268,10 +279,3 @@ mediaViewer:
|
||||
info:
|
||||
enableEndUserAgreement: true
|
||||
enablePrivacyStatement: true
|
||||
# Home Page
|
||||
homePage:
|
||||
recentSubmissions:
|
||||
# The number of item showing in recent submission components
|
||||
pageSize: 5
|
||||
# Sort record of recent submission
|
||||
sortField: 'dc.date.accessioned'
|
||||
|
@@ -15,6 +15,8 @@ import { Collection } from '../core/shared/collection.model';
|
||||
import { PageInfo } from '../core/shared/page-info.model';
|
||||
import { FlatNode } from './flat-node.model';
|
||||
import { FindListOptions } from '../core/data/find-list-options.model';
|
||||
import { APP_CONFIG } from 'src/config/app-config.interface';
|
||||
import { environment } from 'src/environments/environment.test';
|
||||
|
||||
describe('CommunityListService', () => {
|
||||
let store: StoreMock<AppState>;
|
||||
@@ -191,13 +193,14 @@ describe('CommunityListService', () => {
|
||||
};
|
||||
TestBed.configureTestingModule({
|
||||
providers: [CommunityListService,
|
||||
{ provide: APP_CONFIG, useValue: environment },
|
||||
{ provide: CollectionDataService, useValue: collectionDataServiceStub },
|
||||
{ provide: CommunityDataService, useValue: communityDataServiceStub },
|
||||
{ provide: Store, useValue: StoreMock },
|
||||
],
|
||||
});
|
||||
store = TestBed.inject(Store as any);
|
||||
service = new CommunityListService(communityDataServiceStub, collectionDataServiceStub, store);
|
||||
service = new CommunityListService(environment, communityDataServiceStub, collectionDataServiceStub, store);
|
||||
});
|
||||
|
||||
it('should create', inject([CommunityListService], (serviceIn: CommunityListService) => {
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/* eslint-disable max-classes-per-file */
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Inject, Injectable } from '@angular/core';
|
||||
import { createSelector, Store } from '@ngrx/store';
|
||||
|
||||
import { combineLatest as observableCombineLatest, Observable, of as observableOf } from 'rxjs';
|
||||
@@ -23,7 +23,7 @@ import { followLink } from '../shared/utils/follow-link-config.model';
|
||||
import { FlatNode } from './flat-node.model';
|
||||
import { ShowMoreFlatNode } from './show-more-flat-node.model';
|
||||
import { FindListOptions } from '../core/data/find-list-options.model';
|
||||
import { environment } from 'src/environments/environment';
|
||||
import { AppConfig, APP_CONFIG } from 'src/config/app-config.interface';
|
||||
|
||||
// Helper method to combine an flatten an array of observables of flatNode arrays
|
||||
export const combineAndFlatten = (obsList: Observable<FlatNode[]>[]): Observable<FlatNode[]> =>
|
||||
@@ -81,8 +81,6 @@ const communityListStateSelector = (state: AppState) => state.communityList;
|
||||
const expandedNodesSelector = createSelector(communityListStateSelector, (communityList: CommunityListState) => communityList.expandedNodes);
|
||||
const loadingNodeSelector = createSelector(communityListStateSelector, (communityList: CommunityListState) => communityList.loadingNode);
|
||||
|
||||
export const MAX_COMCOLS_PER_PAGE = environment.browseCommunities.communityListPageSize;
|
||||
|
||||
/**
|
||||
* Service class for the community list, responsible for the creating of the flat list used by communityList dataSource
|
||||
* and connection to the store to retrieve and save the state of the community list
|
||||
@@ -90,8 +88,15 @@ export const MAX_COMCOLS_PER_PAGE = environment.browseCommunities.communityListP
|
||||
@Injectable()
|
||||
export class CommunityListService {
|
||||
|
||||
constructor(private communityDataService: CommunityDataService, private collectionDataService: CollectionDataService,
|
||||
private store: Store<any>) {
|
||||
private pageSize: number;
|
||||
|
||||
constructor(
|
||||
@Inject(APP_CONFIG) protected appConfig: AppConfig,
|
||||
private communityDataService: CommunityDataService,
|
||||
private collectionDataService: CollectionDataService,
|
||||
private store: Store<any>
|
||||
) {
|
||||
this.pageSize = appConfig.communityList.pageSize;
|
||||
}
|
||||
|
||||
private configOnePage: FindListOptions = Object.assign(new FindListOptions(), {
|
||||
@@ -146,7 +151,7 @@ export class CommunityListService {
|
||||
private getTopCommunities(options: FindListOptions): Observable<PaginatedList<Community>> {
|
||||
return this.communityDataService.findTop({
|
||||
currentPage: options.currentPage,
|
||||
elementsPerPage: MAX_COMCOLS_PER_PAGE,
|
||||
elementsPerPage: this.pageSize,
|
||||
sort: {
|
||||
field: options.sort.field,
|
||||
direction: options.sort.direction
|
||||
@@ -217,7 +222,7 @@ export class CommunityListService {
|
||||
let subcoms = [];
|
||||
for (let i = 1; i <= currentCommunityPage; i++) {
|
||||
const nextSetOfSubcommunitiesPage = this.communityDataService.findByParent(community.uuid, {
|
||||
elementsPerPage: MAX_COMCOLS_PER_PAGE,
|
||||
elementsPerPage: this.pageSize,
|
||||
currentPage: i
|
||||
},
|
||||
followLink('subcommunities', { findListOptions: this.configOnePage }),
|
||||
@@ -242,7 +247,7 @@ export class CommunityListService {
|
||||
let collections = [];
|
||||
for (let i = 1; i <= currentCollectionPage; i++) {
|
||||
const nextSetOfCollectionsPage = this.collectionDataService.findByParent(community.uuid, {
|
||||
elementsPerPage: MAX_COMCOLS_PER_PAGE,
|
||||
elementsPerPage: this.pageSize,
|
||||
currentPage: i
|
||||
})
|
||||
.pipe(
|
||||
|
@@ -32,6 +32,8 @@ import { SearchConfigurationService } from '../../core/shared/search/search-conf
|
||||
import { ConfigurationProperty } from '../../core/shared/configuration-property.model';
|
||||
import { createPaginatedList } from '../../shared/testing/utils.test';
|
||||
import { SearchConfigurationServiceStub } from '../../shared/testing/search-configuration-service.stub';
|
||||
import { APP_CONFIG } from 'src/config/app-config.interface';
|
||||
import { environment } from 'src/environments/environment.test';
|
||||
|
||||
describe('TopLevelCommunityList Component', () => {
|
||||
let comp: TopLevelCommunityListComponent;
|
||||
@@ -151,6 +153,7 @@ describe('TopLevelCommunityList Component', () => {
|
||||
],
|
||||
declarations: [TopLevelCommunityListComponent],
|
||||
providers: [
|
||||
{ provide: APP_CONFIG, useValue: environment },
|
||||
{ provide: CommunityDataService, useValue: communityDataServiceStub },
|
||||
{ provide: HostWindowService, useValue: new HostWindowServiceStub(0) },
|
||||
{ provide: PaginationService, useValue: paginationService },
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import { ChangeDetectionStrategy, Component, OnInit, OnDestroy } from '@angular/core';
|
||||
import { ChangeDetectionStrategy, Component, OnInit, OnDestroy, Inject } from '@angular/core';
|
||||
|
||||
import { BehaviorSubject, combineLatest as observableCombineLatest, Subscription } from 'rxjs';
|
||||
|
||||
@@ -12,7 +12,7 @@ import { PaginationComponentOptions } from '../../shared/pagination/pagination-c
|
||||
import { hasValue } from '../../shared/empty.util';
|
||||
import { switchMap } from 'rxjs/operators';
|
||||
import { PaginationService } from '../../core/pagination/pagination.service';
|
||||
import { environment } from 'src/environments/environment';
|
||||
import { AppConfig, APP_CONFIG } from 'src/config/app-config.interface';
|
||||
|
||||
/**
|
||||
* this component renders the Top-Level Community list
|
||||
@@ -51,11 +51,14 @@ export class TopLevelCommunityListComponent implements OnInit, OnDestroy {
|
||||
*/
|
||||
currentPageSubscription: Subscription;
|
||||
|
||||
constructor(private cds: CommunityDataService,
|
||||
private paginationService: PaginationService) {
|
||||
constructor(
|
||||
@Inject(APP_CONFIG) protected appConfig: AppConfig,
|
||||
private cds: CommunityDataService,
|
||||
private paginationService: PaginationService
|
||||
) {
|
||||
this.config = new PaginationComponentOptions();
|
||||
this.config.id = this.pageId;
|
||||
this.config.pageSize = environment.browseCommunities.topLevelPageSize;
|
||||
this.config.pageSize = appConfig.homePage.topLevelCommunityList.pageSize;
|
||||
this.config.currentPage = 1;
|
||||
this.sortConfig = new SortOptions('dc.title', SortDirection.ASC);
|
||||
}
|
||||
|
@@ -17,7 +17,9 @@ import { BrowseByConfig } from './browse-by-config.interface';
|
||||
import { BundleConfig } from './bundle-config.interface';
|
||||
import { ActuatorsConfig } from './actuators.config';
|
||||
import { InfoConfig } from './info-config.interface';
|
||||
import { CommunityListConfig } from './community-list-config.interface';
|
||||
import { HomeConfig } from './homepage-config.interface';
|
||||
|
||||
interface AppConfig extends Config {
|
||||
ui: UIServerConfig;
|
||||
rest: ServerConfig;
|
||||
@@ -31,7 +33,8 @@ interface AppConfig extends Config {
|
||||
defaultLanguage: string;
|
||||
languages: LangConfig[];
|
||||
browseBy: BrowseByConfig;
|
||||
browseCommunities: BrowseCommunitiesConfig;
|
||||
communityList: CommunityListConfig;
|
||||
homePage: HomeConfig;
|
||||
item: ItemConfig;
|
||||
collection: CollectionPageConfig;
|
||||
themes: ThemeConfig[];
|
||||
@@ -39,7 +42,6 @@ interface AppConfig extends Config {
|
||||
bundle: BundleConfig;
|
||||
actuators: ActuatorsConfig
|
||||
info: InfoConfig;
|
||||
homePage: HomeConfig;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -1,12 +0,0 @@
|
||||
import { Config } from './config.interface';
|
||||
|
||||
export interface BrowseCommunitiesConfig extends Config {
|
||||
/**
|
||||
* Number of entries in the expandable community list (per show more).
|
||||
*/
|
||||
communityListPageSize: number;
|
||||
/**
|
||||
* Number of entries in the paginated (home page) top level community list.
|
||||
*/
|
||||
topLevelPageSize: number;
|
||||
}
|
5
src/config/community-list-config.interface.ts
Normal file
5
src/config/community-list-config.interface.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
import { Config } from './config.interface';
|
||||
|
||||
export interface CommunityListConfig extends Config {
|
||||
pageSize: number;
|
||||
}
|
@@ -17,7 +17,9 @@ import { UIServerConfig } from './ui-server-config.interface';
|
||||
import { BundleConfig } from './bundle-config.interface';
|
||||
import { ActuatorsConfig } from './actuators.config';
|
||||
import { InfoConfig } from './info-config.interface';
|
||||
import { CommunityListConfig } from './community-list-config.interface';
|
||||
import { HomeConfig } from './homepage-config.interface';
|
||||
|
||||
export class DefaultAppConfig implements AppConfig {
|
||||
production = false;
|
||||
|
||||
@@ -210,10 +212,21 @@ export class DefaultAppConfig implements AppConfig {
|
||||
defaultLowerLimit: 1900
|
||||
};
|
||||
|
||||
browseCommunities: BrowseCommunitiesConfig = {
|
||||
communityListPageSize: 20,
|
||||
topLevelPageSize: 5
|
||||
}
|
||||
communityList: CommunityListConfig = {
|
||||
pageSize: 20
|
||||
};
|
||||
|
||||
homePage: HomeConfig = {
|
||||
recentSubmissions: {
|
||||
//The number of item showing in recent submission components
|
||||
pageSize: 5,
|
||||
//sort record of recent submission
|
||||
sortField: 'dc.date.accessioned',
|
||||
},
|
||||
topLevelCommunityList: {
|
||||
pageSize: 5
|
||||
}
|
||||
};
|
||||
|
||||
// Item Config
|
||||
item: ItemConfig = {
|
||||
@@ -345,13 +358,4 @@ export class DefaultAppConfig implements AppConfig {
|
||||
enableEndUserAgreement: true,
|
||||
enablePrivacyStatement: true
|
||||
};
|
||||
// Home Pages
|
||||
homePage: HomeConfig = {
|
||||
recentSubmissions: {
|
||||
//The number of item showing in recent submission components
|
||||
pageSize: 5,
|
||||
//sort record of recent submission
|
||||
sortField: 'dc.date.accessioned',
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@@ -16,5 +16,7 @@ export interface HomeConfig extends Config {
|
||||
sortField: string;
|
||||
}
|
||||
|
||||
|
||||
topLevelCommunityList: {
|
||||
pageSize: number;
|
||||
};
|
||||
}
|
||||
|
@@ -204,9 +204,18 @@ export const environment: BuildConfig = {
|
||||
// The absolute lowest year to display in the dropdown (only used when no lowest date can be found for all items)
|
||||
defaultLowerLimit: 1900,
|
||||
},
|
||||
browseCommunities: {
|
||||
communityListPageSize: 20,
|
||||
topLevelPageSize: 5
|
||||
communityList: {
|
||||
pageSize: 20
|
||||
},
|
||||
homePage: {
|
||||
recentSubmissions: {
|
||||
pageSize: 5,
|
||||
//sort record of recent submission
|
||||
sortField: 'dc.date.accessioned',
|
||||
},
|
||||
topLevelCommunityList: {
|
||||
pageSize: 5
|
||||
}
|
||||
},
|
||||
item: {
|
||||
edit: {
|
||||
@@ -256,12 +265,4 @@ export const environment: BuildConfig = {
|
||||
enableEndUserAgreement: true,
|
||||
enablePrivacyStatement: true,
|
||||
},
|
||||
//Home Page
|
||||
homePage: {
|
||||
recentSubmissions: {
|
||||
pageSize: 5,
|
||||
//sort record of recent submission
|
||||
sortField: 'dc.date.accessioned',
|
||||
}
|
||||
}
|
||||
};
|
||||
|
Reference in New Issue
Block a user