mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +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)
|
# The absolute lowest year to display in the dropdown (only used when no lowest date can be found for all items)
|
||||||
defaultLowerLimit: 1900
|
defaultLowerLimit: 1900
|
||||||
|
|
||||||
browseCommunities:
|
communityList:
|
||||||
communityListPageSize: 20
|
# No. of communities to list per expansion (show more)
|
||||||
topLevelPageSize: 5
|
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 Config
|
||||||
item:
|
item:
|
||||||
@@ -268,10 +279,3 @@ mediaViewer:
|
|||||||
info:
|
info:
|
||||||
enableEndUserAgreement: true
|
enableEndUserAgreement: true
|
||||||
enablePrivacyStatement: 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 { PageInfo } from '../core/shared/page-info.model';
|
||||||
import { FlatNode } from './flat-node.model';
|
import { FlatNode } from './flat-node.model';
|
||||||
import { FindListOptions } from '../core/data/find-list-options.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', () => {
|
describe('CommunityListService', () => {
|
||||||
let store: StoreMock<AppState>;
|
let store: StoreMock<AppState>;
|
||||||
@@ -191,13 +193,14 @@ describe('CommunityListService', () => {
|
|||||||
};
|
};
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
providers: [CommunityListService,
|
providers: [CommunityListService,
|
||||||
|
{ provide: APP_CONFIG, useValue: environment },
|
||||||
{ provide: CollectionDataService, useValue: collectionDataServiceStub },
|
{ provide: CollectionDataService, useValue: collectionDataServiceStub },
|
||||||
{ provide: CommunityDataService, useValue: communityDataServiceStub },
|
{ provide: CommunityDataService, useValue: communityDataServiceStub },
|
||||||
{ provide: Store, useValue: StoreMock },
|
{ provide: Store, useValue: StoreMock },
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
store = TestBed.inject(Store as any);
|
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) => {
|
it('should create', inject([CommunityListService], (serviceIn: CommunityListService) => {
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/* eslint-disable max-classes-per-file */
|
/* eslint-disable max-classes-per-file */
|
||||||
import { Injectable } from '@angular/core';
|
import { Inject, Injectable } from '@angular/core';
|
||||||
import { createSelector, Store } from '@ngrx/store';
|
import { createSelector, Store } from '@ngrx/store';
|
||||||
|
|
||||||
import { combineLatest as observableCombineLatest, Observable, of as observableOf } from 'rxjs';
|
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 { FlatNode } from './flat-node.model';
|
||||||
import { ShowMoreFlatNode } from './show-more-flat-node.model';
|
import { ShowMoreFlatNode } from './show-more-flat-node.model';
|
||||||
import { FindListOptions } from '../core/data/find-list-options.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
|
// Helper method to combine an flatten an array of observables of flatNode arrays
|
||||||
export const combineAndFlatten = (obsList: Observable<FlatNode[]>[]): Observable<FlatNode[]> =>
|
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 expandedNodesSelector = createSelector(communityListStateSelector, (communityList: CommunityListState) => communityList.expandedNodes);
|
||||||
const loadingNodeSelector = createSelector(communityListStateSelector, (communityList: CommunityListState) => communityList.loadingNode);
|
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
|
* 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
|
* 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()
|
@Injectable()
|
||||||
export class CommunityListService {
|
export class CommunityListService {
|
||||||
|
|
||||||
constructor(private communityDataService: CommunityDataService, private collectionDataService: CollectionDataService,
|
private pageSize: number;
|
||||||
private store: Store<any>) {
|
|
||||||
|
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(), {
|
private configOnePage: FindListOptions = Object.assign(new FindListOptions(), {
|
||||||
@@ -146,7 +151,7 @@ export class CommunityListService {
|
|||||||
private getTopCommunities(options: FindListOptions): Observable<PaginatedList<Community>> {
|
private getTopCommunities(options: FindListOptions): Observable<PaginatedList<Community>> {
|
||||||
return this.communityDataService.findTop({
|
return this.communityDataService.findTop({
|
||||||
currentPage: options.currentPage,
|
currentPage: options.currentPage,
|
||||||
elementsPerPage: MAX_COMCOLS_PER_PAGE,
|
elementsPerPage: this.pageSize,
|
||||||
sort: {
|
sort: {
|
||||||
field: options.sort.field,
|
field: options.sort.field,
|
||||||
direction: options.sort.direction
|
direction: options.sort.direction
|
||||||
@@ -217,7 +222,7 @@ export class CommunityListService {
|
|||||||
let subcoms = [];
|
let subcoms = [];
|
||||||
for (let i = 1; i <= currentCommunityPage; i++) {
|
for (let i = 1; i <= currentCommunityPage; i++) {
|
||||||
const nextSetOfSubcommunitiesPage = this.communityDataService.findByParent(community.uuid, {
|
const nextSetOfSubcommunitiesPage = this.communityDataService.findByParent(community.uuid, {
|
||||||
elementsPerPage: MAX_COMCOLS_PER_PAGE,
|
elementsPerPage: this.pageSize,
|
||||||
currentPage: i
|
currentPage: i
|
||||||
},
|
},
|
||||||
followLink('subcommunities', { findListOptions: this.configOnePage }),
|
followLink('subcommunities', { findListOptions: this.configOnePage }),
|
||||||
@@ -242,7 +247,7 @@ export class CommunityListService {
|
|||||||
let collections = [];
|
let collections = [];
|
||||||
for (let i = 1; i <= currentCollectionPage; i++) {
|
for (let i = 1; i <= currentCollectionPage; i++) {
|
||||||
const nextSetOfCollectionsPage = this.collectionDataService.findByParent(community.uuid, {
|
const nextSetOfCollectionsPage = this.collectionDataService.findByParent(community.uuid, {
|
||||||
elementsPerPage: MAX_COMCOLS_PER_PAGE,
|
elementsPerPage: this.pageSize,
|
||||||
currentPage: i
|
currentPage: i
|
||||||
})
|
})
|
||||||
.pipe(
|
.pipe(
|
||||||
|
@@ -32,6 +32,8 @@ import { SearchConfigurationService } from '../../core/shared/search/search-conf
|
|||||||
import { ConfigurationProperty } from '../../core/shared/configuration-property.model';
|
import { ConfigurationProperty } from '../../core/shared/configuration-property.model';
|
||||||
import { createPaginatedList } from '../../shared/testing/utils.test';
|
import { createPaginatedList } from '../../shared/testing/utils.test';
|
||||||
import { SearchConfigurationServiceStub } from '../../shared/testing/search-configuration-service.stub';
|
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', () => {
|
describe('TopLevelCommunityList Component', () => {
|
||||||
let comp: TopLevelCommunityListComponent;
|
let comp: TopLevelCommunityListComponent;
|
||||||
@@ -151,6 +153,7 @@ describe('TopLevelCommunityList Component', () => {
|
|||||||
],
|
],
|
||||||
declarations: [TopLevelCommunityListComponent],
|
declarations: [TopLevelCommunityListComponent],
|
||||||
providers: [
|
providers: [
|
||||||
|
{ provide: APP_CONFIG, useValue: environment },
|
||||||
{ provide: CommunityDataService, useValue: communityDataServiceStub },
|
{ provide: CommunityDataService, useValue: communityDataServiceStub },
|
||||||
{ provide: HostWindowService, useValue: new HostWindowServiceStub(0) },
|
{ provide: HostWindowService, useValue: new HostWindowServiceStub(0) },
|
||||||
{ provide: PaginationService, useValue: paginationService },
|
{ 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';
|
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 { hasValue } from '../../shared/empty.util';
|
||||||
import { switchMap } from 'rxjs/operators';
|
import { switchMap } from 'rxjs/operators';
|
||||||
import { PaginationService } from '../../core/pagination/pagination.service';
|
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
|
* this component renders the Top-Level Community list
|
||||||
@@ -51,11 +51,14 @@ export class TopLevelCommunityListComponent implements OnInit, OnDestroy {
|
|||||||
*/
|
*/
|
||||||
currentPageSubscription: Subscription;
|
currentPageSubscription: Subscription;
|
||||||
|
|
||||||
constructor(private cds: CommunityDataService,
|
constructor(
|
||||||
private paginationService: PaginationService) {
|
@Inject(APP_CONFIG) protected appConfig: AppConfig,
|
||||||
|
private cds: CommunityDataService,
|
||||||
|
private paginationService: PaginationService
|
||||||
|
) {
|
||||||
this.config = new PaginationComponentOptions();
|
this.config = new PaginationComponentOptions();
|
||||||
this.config.id = this.pageId;
|
this.config.id = this.pageId;
|
||||||
this.config.pageSize = environment.browseCommunities.topLevelPageSize;
|
this.config.pageSize = appConfig.homePage.topLevelCommunityList.pageSize;
|
||||||
this.config.currentPage = 1;
|
this.config.currentPage = 1;
|
||||||
this.sortConfig = new SortOptions('dc.title', SortDirection.ASC);
|
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 { BundleConfig } from './bundle-config.interface';
|
||||||
import { ActuatorsConfig } from './actuators.config';
|
import { ActuatorsConfig } from './actuators.config';
|
||||||
import { InfoConfig } from './info-config.interface';
|
import { InfoConfig } from './info-config.interface';
|
||||||
|
import { CommunityListConfig } from './community-list-config.interface';
|
||||||
import { HomeConfig } from './homepage-config.interface';
|
import { HomeConfig } from './homepage-config.interface';
|
||||||
|
|
||||||
interface AppConfig extends Config {
|
interface AppConfig extends Config {
|
||||||
ui: UIServerConfig;
|
ui: UIServerConfig;
|
||||||
rest: ServerConfig;
|
rest: ServerConfig;
|
||||||
@@ -31,7 +33,8 @@ interface AppConfig extends Config {
|
|||||||
defaultLanguage: string;
|
defaultLanguage: string;
|
||||||
languages: LangConfig[];
|
languages: LangConfig[];
|
||||||
browseBy: BrowseByConfig;
|
browseBy: BrowseByConfig;
|
||||||
browseCommunities: BrowseCommunitiesConfig;
|
communityList: CommunityListConfig;
|
||||||
|
homePage: HomeConfig;
|
||||||
item: ItemConfig;
|
item: ItemConfig;
|
||||||
collection: CollectionPageConfig;
|
collection: CollectionPageConfig;
|
||||||
themes: ThemeConfig[];
|
themes: ThemeConfig[];
|
||||||
@@ -39,7 +42,6 @@ interface AppConfig extends Config {
|
|||||||
bundle: BundleConfig;
|
bundle: BundleConfig;
|
||||||
actuators: ActuatorsConfig
|
actuators: ActuatorsConfig
|
||||||
info: InfoConfig;
|
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 { BundleConfig } from './bundle-config.interface';
|
||||||
import { ActuatorsConfig } from './actuators.config';
|
import { ActuatorsConfig } from './actuators.config';
|
||||||
import { InfoConfig } from './info-config.interface';
|
import { InfoConfig } from './info-config.interface';
|
||||||
|
import { CommunityListConfig } from './community-list-config.interface';
|
||||||
import { HomeConfig } from './homepage-config.interface';
|
import { HomeConfig } from './homepage-config.interface';
|
||||||
|
|
||||||
export class DefaultAppConfig implements AppConfig {
|
export class DefaultAppConfig implements AppConfig {
|
||||||
production = false;
|
production = false;
|
||||||
|
|
||||||
@@ -210,10 +212,21 @@ export class DefaultAppConfig implements AppConfig {
|
|||||||
defaultLowerLimit: 1900
|
defaultLowerLimit: 1900
|
||||||
};
|
};
|
||||||
|
|
||||||
browseCommunities: BrowseCommunitiesConfig = {
|
communityList: CommunityListConfig = {
|
||||||
communityListPageSize: 20,
|
pageSize: 20
|
||||||
topLevelPageSize: 5
|
};
|
||||||
|
|
||||||
|
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 Config
|
||||||
item: ItemConfig = {
|
item: ItemConfig = {
|
||||||
@@ -345,13 +358,4 @@ export class DefaultAppConfig implements AppConfig {
|
|||||||
enableEndUserAgreement: true,
|
enableEndUserAgreement: true,
|
||||||
enablePrivacyStatement: 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;
|
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)
|
// The absolute lowest year to display in the dropdown (only used when no lowest date can be found for all items)
|
||||||
defaultLowerLimit: 1900,
|
defaultLowerLimit: 1900,
|
||||||
},
|
},
|
||||||
browseCommunities: {
|
communityList: {
|
||||||
communityListPageSize: 20,
|
pageSize: 20
|
||||||
topLevelPageSize: 5
|
},
|
||||||
|
homePage: {
|
||||||
|
recentSubmissions: {
|
||||||
|
pageSize: 5,
|
||||||
|
//sort record of recent submission
|
||||||
|
sortField: 'dc.date.accessioned',
|
||||||
|
},
|
||||||
|
topLevelCommunityList: {
|
||||||
|
pageSize: 5
|
||||||
|
}
|
||||||
},
|
},
|
||||||
item: {
|
item: {
|
||||||
edit: {
|
edit: {
|
||||||
@@ -256,12 +265,4 @@ export const environment: BuildConfig = {
|
|||||||
enableEndUserAgreement: true,
|
enableEndUserAgreement: true,
|
||||||
enablePrivacyStatement: 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