Skip to content

Commit 76416ff

Browse files
committed
Merge branch 'main' into collection-thumbnail-embed
2 parents d2d6554 + 0f1b9bb commit 76416ff

23 files changed

Lines changed: 10320 additions & 87 deletions

config/config.example.yml

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,15 @@ languages:
156156
- code: tr
157157
label: Türkçe
158158
active: true
159+
- code: kk
160+
label: Қазақ
161+
active: true
159162
- code: bn
160163
label: বাংলা
161164
active: true
165+
- code: el
166+
label: Ελληνικά
167+
active: true
162168

163169
# Browse-By Pages
164170
browseBy:
@@ -171,6 +177,21 @@ browseBy:
171177
# If true, thumbnail images for items will be added to BOTH search and browse result lists.
172178
showThumbnails: true
173179

180+
communityList:
181+
# No. of communities to list per expansion (show more)
182+
pageSize: 20
183+
184+
homePage:
185+
recentSubmissions:
186+
# The number of item showing in recent submission components
187+
pageSize: 5
188+
# Sort record of recent submission
189+
sortField: 'dc.date.accessioned'
190+
topLevelCommunityList:
191+
# No. of communities to list per page on the home page
192+
# 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
193+
pageSize: 5
194+
174195
# Item Config
175196
item:
176197
edit:
@@ -260,10 +281,3 @@ mediaViewer:
260281
info:
261282
enableEndUserAgreement: true
262283
enablePrivacyStatement: true
263-
# Home Page
264-
homePage:
265-
recentSubmissions:
266-
# The number of item showing in recent submission components
267-
pageSize: 5
268-
# Sort record of recent submission
269-
sortField: 'dc.date.accessioned'

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "dspace-angular",
3-
"version": "0.0.0",
3+
"version": "7.4.0-next",
44
"scripts": {
55
"ng": "ng",
66
"config:watch": "nodemon",
@@ -10,7 +10,7 @@
1010
"start:prod": "yarn run build:prod && cross-env NODE_ENV=production yarn run serve:ssr",
1111
"start:mirador:prod": "yarn run build:mirador && yarn run start:prod",
1212
"preserve": "yarn base-href",
13-
"serve": "ng serve --configuration development",
13+
"serve": "ts-node --project ./tsconfig.ts-node.json scripts/serve.ts",
1414
"serve:ssr": "node dist/server/main",
1515
"analyze": "webpack-bundle-analyzer dist/browser/stats.json",
1616
"build": "ng build --configuration development",

scripts/serve.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ const appConfig: AppConfig = buildAppConfig();
1010
* Any CLI arguments given to this script are patched through to `ng serve` as well.
1111
*/
1212
child.spawn(
13-
`ng serve --host ${appConfig.ui.host} --port ${appConfig.ui.port} --serve-path ${appConfig.ui.nameSpace} --ssl ${appConfig.ui.ssl} ${process.argv.slice(2).join(' ')}`,
13+
`ng serve --host ${appConfig.ui.host} --port ${appConfig.ui.port} --serve-path ${appConfig.ui.nameSpace} --ssl ${appConfig.ui.ssl} ${process.argv.slice(2).join(' ')} --configuration development`,
1414
{ stdio: 'inherit', shell: true }
1515
);

server.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ import { ServerAppModule } from './src/main.server';
4848
import { buildAppConfig } from './src/config/config.server';
4949
import { APP_CONFIG, AppConfig } from './src/config/app-config.interface';
5050
import { extendEnvironmentWithAppConfig } from './src/config/config.util';
51+
import { logStartupMessage } from './startup-message';
5152

5253
/*
5354
* Set path for the browser application's dist folder
@@ -281,6 +282,8 @@ function run() {
281282
}
282283

283284
function start() {
285+
logStartupMessage(environment);
286+
284287
/*
285288
* If SSL is enabled
286289
* - Read credentials from configuration files

src/app/community-list-page/community-list-service.spec.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ import { Collection } from '../core/shared/collection.model';
1515
import { PageInfo } from '../core/shared/page-info.model';
1616
import { FlatNode } from './flat-node.model';
1717
import { FindListOptions } from '../core/data/find-list-options.model';
18+
import { APP_CONFIG } from 'src/config/app-config.interface';
19+
import { environment } from 'src/environments/environment.test';
1820

1921
describe('CommunityListService', () => {
2022
let store: StoreMock<AppState>;
@@ -191,13 +193,14 @@ describe('CommunityListService', () => {
191193
};
192194
TestBed.configureTestingModule({
193195
providers: [CommunityListService,
196+
{ provide: APP_CONFIG, useValue: environment },
194197
{ provide: CollectionDataService, useValue: collectionDataServiceStub },
195198
{ provide: CommunityDataService, useValue: communityDataServiceStub },
196199
{ provide: Store, useValue: StoreMock },
197200
],
198201
});
199202
store = TestBed.inject(Store as any);
200-
service = new CommunityListService(communityDataServiceStub, collectionDataServiceStub, store);
203+
service = new CommunityListService(environment, communityDataServiceStub, collectionDataServiceStub, store);
201204
});
202205

203206
it('should create', inject([CommunityListService], (serviceIn: CommunityListService) => {

src/app/community-list-page/community-list-service.ts

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* eslint-disable max-classes-per-file */
2-
import { Injectable } from '@angular/core';
2+
import { Inject, Injectable } from '@angular/core';
33
import { createSelector, Store } from '@ngrx/store';
44

55
import { combineLatest as observableCombineLatest, Observable, of as observableOf } from 'rxjs';
@@ -23,6 +23,7 @@ import { followLink } from '../shared/utils/follow-link-config.model';
2323
import { FlatNode } from './flat-node.model';
2424
import { ShowMoreFlatNode } from './show-more-flat-node.model';
2525
import { FindListOptions } from '../core/data/find-list-options.model';
26+
import { AppConfig, APP_CONFIG } from 'src/config/app-config.interface';
2627

2728
// Helper method to combine an flatten an array of observables of flatNode arrays
2829
export const combineAndFlatten = (obsList: Observable<FlatNode[]>[]): Observable<FlatNode[]> =>
@@ -80,17 +81,22 @@ const communityListStateSelector = (state: AppState) => state.communityList;
8081
const expandedNodesSelector = createSelector(communityListStateSelector, (communityList: CommunityListState) => communityList.expandedNodes);
8182
const loadingNodeSelector = createSelector(communityListStateSelector, (communityList: CommunityListState) => communityList.loadingNode);
8283

83-
export const MAX_COMCOLS_PER_PAGE = 20;
84-
8584
/**
8685
* Service class for the community list, responsible for the creating of the flat list used by communityList dataSource
8786
* and connection to the store to retrieve and save the state of the community list
8887
*/
8988
@Injectable()
9089
export class CommunityListService {
9190

92-
constructor(private communityDataService: CommunityDataService, private collectionDataService: CollectionDataService,
93-
private store: Store<any>) {
91+
private pageSize: number;
92+
93+
constructor(
94+
@Inject(APP_CONFIG) protected appConfig: AppConfig,
95+
private communityDataService: CommunityDataService,
96+
private collectionDataService: CollectionDataService,
97+
private store: Store<any>
98+
) {
99+
this.pageSize = appConfig.communityList.pageSize;
94100
}
95101

96102
private configOnePage: FindListOptions = Object.assign(new FindListOptions(), {
@@ -145,7 +151,7 @@ export class CommunityListService {
145151
private getTopCommunities(options: FindListOptions): Observable<PaginatedList<Community>> {
146152
return this.communityDataService.findTop({
147153
currentPage: options.currentPage,
148-
elementsPerPage: MAX_COMCOLS_PER_PAGE,
154+
elementsPerPage: this.pageSize,
149155
sort: {
150156
field: options.sort.field,
151157
direction: options.sort.direction
@@ -216,7 +222,7 @@ export class CommunityListService {
216222
let subcoms = [];
217223
for (let i = 1; i <= currentCommunityPage; i++) {
218224
const nextSetOfSubcommunitiesPage = this.communityDataService.findByParent(community.uuid, {
219-
elementsPerPage: MAX_COMCOLS_PER_PAGE,
225+
elementsPerPage: this.pageSize,
220226
currentPage: i
221227
},
222228
followLink('subcommunities', { findListOptions: this.configOnePage }),
@@ -241,7 +247,7 @@ export class CommunityListService {
241247
let collections = [];
242248
for (let i = 1; i <= currentCollectionPage; i++) {
243249
const nextSetOfCollectionsPage = this.collectionDataService.findByParent(community.uuid, {
244-
elementsPerPage: MAX_COMCOLS_PER_PAGE,
250+
elementsPerPage: this.pageSize,
245251
currentPage: i
246252
})
247253
.pipe(

src/app/core/pagination/pagination.service.spec.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,17 @@ describe('PaginationService', () => {
120120

121121
expect(router.navigate).toHaveBeenCalledWith([], {queryParams: navigateParams, queryParamsHandling: 'merge'});
122122
});
123+
it('should pass on navigationExtras to router.navigate', () => {
124+
service.updateRoute('test', {page: 2}, undefined, undefined, { queryParamsHandling: 'preserve', replaceUrl: true, preserveFragment: true });
125+
126+
const navigateParams = {};
127+
navigateParams[`test.page`] = `2`;
128+
navigateParams[`test.rpp`] = `10`;
129+
navigateParams[`test.sf`] = `score`;
130+
navigateParams[`test.sd`] = `ASC`;
131+
132+
expect(router.navigate).toHaveBeenCalledWith([], {queryParams: navigateParams, queryParamsHandling: 'preserve', replaceUrl: true, preserveFragment: true });
133+
});
123134
});
124135
describe('updateRouteWithUrl', () => {
125136
it('should update the route with the provided page params and url', () => {
@@ -144,7 +155,17 @@ describe('PaginationService', () => {
144155

145156
expect(router.navigate).toHaveBeenCalledWith(['someUrl'], {queryParams: navigateParams, queryParamsHandling: 'merge'});
146157
});
158+
it('should pass on navigationExtras to router.navigate', () => {
159+
service.updateRouteWithUrl('test',['someUrl'], {page: 2}, undefined, undefined, { queryParamsHandling: 'preserve', replaceUrl: true, preserveFragment: true });
147160

161+
const navigateParams = {};
162+
navigateParams[`test.page`] = `2`;
163+
navigateParams[`test.rpp`] = `10`;
164+
navigateParams[`test.sf`] = `score`;
165+
navigateParams[`test.sd`] = `ASC`;
166+
167+
expect(router.navigate).toHaveBeenCalledWith(['someUrl'], {queryParams: navigateParams, queryParamsHandling: 'preserve', replaceUrl: true, preserveFragment: true });
168+
});
148169
});
149170
describe('clearPagination', () => {
150171
it('should clear the pagination next time the updateRoute/updateRouteWithUrl method is called', () => {

src/app/core/pagination/pagination.service.ts

Lines changed: 33 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Injectable } from '@angular/core';
2-
import { Router } from '@angular/router';
2+
import { NavigationExtras, Router } from '@angular/router';
33
import { RouteService } from '../services/route.service';
44
import { PaginationComponentOptions } from '../../shared/pagination/pagination-component-options.model';
55
import { combineLatest as observableCombineLatest, Observable } from 'rxjs';
@@ -117,15 +117,22 @@ export class PaginationService {
117117
* @param params - The page related params to update in the route
118118
* @param extraParams - Addition params unrelated to the pagination that need to be added to the route
119119
* @param retainScrollPosition - Scroll to the pagination component after updating the route instead of the top of the page
120+
* @param navigationExtras - Extra parameters to pass on to `router.navigate`. Can be used to override values set by this service.
120121
*/
121-
updateRoute(paginationId: string, params: {
122-
page?: number
123-
pageSize?: number
124-
sortField?: string
125-
sortDirection?: SortDirection
126-
}, extraParams?, retainScrollPosition?: boolean) {
122+
updateRoute(
123+
paginationId: string,
124+
params: {
125+
page?: number
126+
pageSize?: number
127+
sortField?: string
128+
sortDirection?: SortDirection
129+
},
130+
extraParams?,
131+
retainScrollPosition?: boolean,
132+
navigationExtras?: NavigationExtras,
133+
) {
127134

128-
this.updateRouteWithUrl(paginationId, [], params, extraParams, retainScrollPosition);
135+
this.updateRouteWithUrl(paginationId, [], params, extraParams, retainScrollPosition, navigationExtras);
129136
}
130137

131138
/**
@@ -135,13 +142,21 @@ export class PaginationService {
135142
* @param params - The page related params to update in the route
136143
* @param extraParams - Addition params unrelated to the pagination that need to be added to the route
137144
* @param retainScrollPosition - Scroll to the pagination component after updating the route instead of the top of the page
145+
* @param navigationExtras - Extra parameters to pass on to `router.navigate`. Can be used to override values set by this service.
138146
*/
139-
updateRouteWithUrl(paginationId: string, url: string[], params: {
140-
page?: number
141-
pageSize?: number
142-
sortField?: string
143-
sortDirection?: SortDirection
144-
}, extraParams?, retainScrollPosition?: boolean) {
147+
updateRouteWithUrl(
148+
paginationId: string,
149+
url: string[],
150+
params: {
151+
page?: number
152+
pageSize?: number
153+
sortField?: string
154+
sortDirection?: SortDirection
155+
},
156+
extraParams?,
157+
retainScrollPosition?: boolean,
158+
navigationExtras?: NavigationExtras,
159+
) {
145160
this.getCurrentRouting(paginationId).subscribe((currentFindListOptions) => {
146161
const currentParametersWithIdName = this.getParametersWithIdName(paginationId, currentFindListOptions);
147162
const parametersWithIdName = this.getParametersWithIdName(paginationId, params);
@@ -152,12 +167,14 @@ export class PaginationService {
152167
this.router.navigate(url, {
153168
queryParams: queryParams,
154169
queryParamsHandling: 'merge',
155-
fragment: `p-${paginationId}`
170+
fragment: `p-${paginationId}`,
171+
...navigationExtras,
156172
});
157173
} else {
158174
this.router.navigate(url, {
159175
queryParams: queryParams,
160-
queryParamsHandling: 'merge'
176+
queryParamsHandling: 'merge',
177+
...navigationExtras,
161178
});
162179
}
163180
this.clearParams = {};

src/app/home-page/top-level-community-list/top-level-community-list.component.spec.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ import { SearchConfigurationService } from '../../core/shared/search/search-conf
3232
import { ConfigurationProperty } from '../../core/shared/configuration-property.model';
3333
import { createPaginatedList } from '../../shared/testing/utils.test';
3434
import { SearchConfigurationServiceStub } from '../../shared/testing/search-configuration-service.stub';
35+
import { APP_CONFIG } from 'src/config/app-config.interface';
36+
import { environment } from 'src/environments/environment.test';
3537

3638
describe('TopLevelCommunityList Component', () => {
3739
let comp: TopLevelCommunityListComponent;
@@ -151,6 +153,7 @@ describe('TopLevelCommunityList Component', () => {
151153
],
152154
declarations: [TopLevelCommunityListComponent],
153155
providers: [
156+
{ provide: APP_CONFIG, useValue: environment },
154157
{ provide: CommunityDataService, useValue: communityDataServiceStub },
155158
{ provide: HostWindowService, useValue: new HostWindowServiceStub(0) },
156159
{ provide: PaginationService, useValue: paginationService },

src/app/home-page/top-level-community-list/top-level-community-list.component.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ChangeDetectionStrategy, Component, OnInit, OnDestroy } from '@angular/core';
1+
import { ChangeDetectionStrategy, Component, OnInit, OnDestroy, Inject } from '@angular/core';
22

33
import { BehaviorSubject, combineLatest as observableCombineLatest, Subscription } from 'rxjs';
44

@@ -12,6 +12,7 @@ import { PaginationComponentOptions } from '../../shared/pagination/pagination-c
1212
import { hasValue } from '../../shared/empty.util';
1313
import { switchMap } from 'rxjs/operators';
1414
import { PaginationService } from '../../core/pagination/pagination.service';
15+
import { AppConfig, APP_CONFIG } from 'src/config/app-config.interface';
1516

1617
/**
1718
* this component renders the Top-Level Community list
@@ -50,11 +51,14 @@ export class TopLevelCommunityListComponent implements OnInit, OnDestroy {
5051
*/
5152
currentPageSubscription: Subscription;
5253

53-
constructor(private cds: CommunityDataService,
54-
private paginationService: PaginationService) {
54+
constructor(
55+
@Inject(APP_CONFIG) protected appConfig: AppConfig,
56+
private cds: CommunityDataService,
57+
private paginationService: PaginationService
58+
) {
5559
this.config = new PaginationComponentOptions();
5660
this.config.id = this.pageId;
57-
this.config.pageSize = 5;
61+
this.config.pageSize = appConfig.homePage.topLevelCommunityList.pageSize;
5862
this.config.currentPage = 1;
5963
this.sortConfig = new SortOptions('dc.title', SortDirection.ASC);
6064
}

0 commit comments

Comments
 (0)