mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 18:14:17 +00:00
Merge branch 'main' into collection-thumbnail-embed
This commit is contained in:
@@ -156,9 +156,15 @@ languages:
|
|||||||
- code: tr
|
- code: tr
|
||||||
label: Türkçe
|
label: Türkçe
|
||||||
active: true
|
active: true
|
||||||
|
- code: kk
|
||||||
|
label: Қазақ
|
||||||
|
active: true
|
||||||
- code: bn
|
- code: bn
|
||||||
label: বাংলা
|
label: বাংলা
|
||||||
active: true
|
active: true
|
||||||
|
- code: el
|
||||||
|
label: Ελληνικά
|
||||||
|
active: true
|
||||||
|
|
||||||
# Browse-By Pages
|
# Browse-By Pages
|
||||||
browseBy:
|
browseBy:
|
||||||
@@ -171,6 +177,21 @@ browseBy:
|
|||||||
# If true, thumbnail images for items will be added to BOTH search and browse result lists.
|
# If true, thumbnail images for items will be added to BOTH search and browse result lists.
|
||||||
showThumbnails: true
|
showThumbnails: true
|
||||||
|
|
||||||
|
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 Config
|
||||||
item:
|
item:
|
||||||
edit:
|
edit:
|
||||||
@@ -260,10 +281,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'
|
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "dspace-angular",
|
"name": "dspace-angular",
|
||||||
"version": "0.0.0",
|
"version": "7.4.0-next",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"ng": "ng",
|
"ng": "ng",
|
||||||
"config:watch": "nodemon",
|
"config:watch": "nodemon",
|
||||||
@@ -10,7 +10,7 @@
|
|||||||
"start:prod": "yarn run build:prod && cross-env NODE_ENV=production yarn run serve:ssr",
|
"start:prod": "yarn run build:prod && cross-env NODE_ENV=production yarn run serve:ssr",
|
||||||
"start:mirador:prod": "yarn run build:mirador && yarn run start:prod",
|
"start:mirador:prod": "yarn run build:mirador && yarn run start:prod",
|
||||||
"preserve": "yarn base-href",
|
"preserve": "yarn base-href",
|
||||||
"serve": "ng serve --configuration development",
|
"serve": "ts-node --project ./tsconfig.ts-node.json scripts/serve.ts",
|
||||||
"serve:ssr": "node dist/server/main",
|
"serve:ssr": "node dist/server/main",
|
||||||
"analyze": "webpack-bundle-analyzer dist/browser/stats.json",
|
"analyze": "webpack-bundle-analyzer dist/browser/stats.json",
|
||||||
"build": "ng build --configuration development",
|
"build": "ng build --configuration development",
|
||||||
|
@@ -10,6 +10,6 @@ const appConfig: AppConfig = buildAppConfig();
|
|||||||
* Any CLI arguments given to this script are patched through to `ng serve` as well.
|
* Any CLI arguments given to this script are patched through to `ng serve` as well.
|
||||||
*/
|
*/
|
||||||
child.spawn(
|
child.spawn(
|
||||||
`ng serve --host ${appConfig.ui.host} --port ${appConfig.ui.port} --serve-path ${appConfig.ui.nameSpace} --ssl ${appConfig.ui.ssl} ${process.argv.slice(2).join(' ')}`,
|
`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`,
|
||||||
{ stdio: 'inherit', shell: true }
|
{ stdio: 'inherit', shell: true }
|
||||||
);
|
);
|
||||||
|
@@ -48,6 +48,7 @@ import { ServerAppModule } from './src/main.server';
|
|||||||
import { buildAppConfig } from './src/config/config.server';
|
import { buildAppConfig } from './src/config/config.server';
|
||||||
import { APP_CONFIG, AppConfig } from './src/config/app-config.interface';
|
import { APP_CONFIG, AppConfig } from './src/config/app-config.interface';
|
||||||
import { extendEnvironmentWithAppConfig } from './src/config/config.util';
|
import { extendEnvironmentWithAppConfig } from './src/config/config.util';
|
||||||
|
import { logStartupMessage } from './startup-message';
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Set path for the browser application's dist folder
|
* Set path for the browser application's dist folder
|
||||||
@@ -281,6 +282,8 @@ function run() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function start() {
|
function start() {
|
||||||
|
logStartupMessage(environment);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If SSL is enabled
|
* If SSL is enabled
|
||||||
* - Read credentials from configuration files
|
* - Read credentials from configuration files
|
||||||
|
@@ -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,6 +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 { 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[]> =>
|
||||||
@@ -80,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 = 20;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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
|
||||||
@@ -89,8 +88,15 @@ export const MAX_COMCOLS_PER_PAGE = 20;
|
|||||||
@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(), {
|
||||||
@@ -145,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
|
||||||
@@ -216,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 }),
|
||||||
@@ -241,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(
|
||||||
|
@@ -120,6 +120,17 @@ describe('PaginationService', () => {
|
|||||||
|
|
||||||
expect(router.navigate).toHaveBeenCalledWith([], {queryParams: navigateParams, queryParamsHandling: 'merge'});
|
expect(router.navigate).toHaveBeenCalledWith([], {queryParams: navigateParams, queryParamsHandling: 'merge'});
|
||||||
});
|
});
|
||||||
|
it('should pass on navigationExtras to router.navigate', () => {
|
||||||
|
service.updateRoute('test', {page: 2}, undefined, undefined, { queryParamsHandling: 'preserve', replaceUrl: true, preserveFragment: true });
|
||||||
|
|
||||||
|
const navigateParams = {};
|
||||||
|
navigateParams[`test.page`] = `2`;
|
||||||
|
navigateParams[`test.rpp`] = `10`;
|
||||||
|
navigateParams[`test.sf`] = `score`;
|
||||||
|
navigateParams[`test.sd`] = `ASC`;
|
||||||
|
|
||||||
|
expect(router.navigate).toHaveBeenCalledWith([], {queryParams: navigateParams, queryParamsHandling: 'preserve', replaceUrl: true, preserveFragment: true });
|
||||||
|
});
|
||||||
});
|
});
|
||||||
describe('updateRouteWithUrl', () => {
|
describe('updateRouteWithUrl', () => {
|
||||||
it('should update the route with the provided page params and url', () => {
|
it('should update the route with the provided page params and url', () => {
|
||||||
@@ -144,7 +155,17 @@ describe('PaginationService', () => {
|
|||||||
|
|
||||||
expect(router.navigate).toHaveBeenCalledWith(['someUrl'], {queryParams: navigateParams, queryParamsHandling: 'merge'});
|
expect(router.navigate).toHaveBeenCalledWith(['someUrl'], {queryParams: navigateParams, queryParamsHandling: 'merge'});
|
||||||
});
|
});
|
||||||
|
it('should pass on navigationExtras to router.navigate', () => {
|
||||||
|
service.updateRouteWithUrl('test',['someUrl'], {page: 2}, undefined, undefined, { queryParamsHandling: 'preserve', replaceUrl: true, preserveFragment: true });
|
||||||
|
|
||||||
|
const navigateParams = {};
|
||||||
|
navigateParams[`test.page`] = `2`;
|
||||||
|
navigateParams[`test.rpp`] = `10`;
|
||||||
|
navigateParams[`test.sf`] = `score`;
|
||||||
|
navigateParams[`test.sd`] = `ASC`;
|
||||||
|
|
||||||
|
expect(router.navigate).toHaveBeenCalledWith(['someUrl'], {queryParams: navigateParams, queryParamsHandling: 'preserve', replaceUrl: true, preserveFragment: true });
|
||||||
|
});
|
||||||
});
|
});
|
||||||
describe('clearPagination', () => {
|
describe('clearPagination', () => {
|
||||||
it('should clear the pagination next time the updateRoute/updateRouteWithUrl method is called', () => {
|
it('should clear the pagination next time the updateRoute/updateRouteWithUrl method is called', () => {
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { Router } from '@angular/router';
|
import { NavigationExtras, Router } from '@angular/router';
|
||||||
import { RouteService } from '../services/route.service';
|
import { RouteService } from '../services/route.service';
|
||||||
import { PaginationComponentOptions } from '../../shared/pagination/pagination-component-options.model';
|
import { PaginationComponentOptions } from '../../shared/pagination/pagination-component-options.model';
|
||||||
import { combineLatest as observableCombineLatest, Observable } from 'rxjs';
|
import { combineLatest as observableCombineLatest, Observable } from 'rxjs';
|
||||||
@@ -117,15 +117,22 @@ export class PaginationService {
|
|||||||
* @param params - The page related params to update in the route
|
* @param params - The page related params to update in the route
|
||||||
* @param extraParams - Addition params unrelated to the pagination that need to be added to the route
|
* @param extraParams - Addition params unrelated to the pagination that need to be added to the route
|
||||||
* @param retainScrollPosition - Scroll to the pagination component after updating the route instead of the top of the page
|
* @param retainScrollPosition - Scroll to the pagination component after updating the route instead of the top of the page
|
||||||
|
* @param navigationExtras - Extra parameters to pass on to `router.navigate`. Can be used to override values set by this service.
|
||||||
*/
|
*/
|
||||||
updateRoute(paginationId: string, params: {
|
updateRoute(
|
||||||
page?: number
|
paginationId: string,
|
||||||
pageSize?: number
|
params: {
|
||||||
sortField?: string
|
page?: number
|
||||||
sortDirection?: SortDirection
|
pageSize?: number
|
||||||
}, extraParams?, retainScrollPosition?: boolean) {
|
sortField?: string
|
||||||
|
sortDirection?: SortDirection
|
||||||
|
},
|
||||||
|
extraParams?,
|
||||||
|
retainScrollPosition?: boolean,
|
||||||
|
navigationExtras?: NavigationExtras,
|
||||||
|
) {
|
||||||
|
|
||||||
this.updateRouteWithUrl(paginationId, [], params, extraParams, retainScrollPosition);
|
this.updateRouteWithUrl(paginationId, [], params, extraParams, retainScrollPosition, navigationExtras);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -135,13 +142,21 @@ export class PaginationService {
|
|||||||
* @param params - The page related params to update in the route
|
* @param params - The page related params to update in the route
|
||||||
* @param extraParams - Addition params unrelated to the pagination that need to be added to the route
|
* @param extraParams - Addition params unrelated to the pagination that need to be added to the route
|
||||||
* @param retainScrollPosition - Scroll to the pagination component after updating the route instead of the top of the page
|
* @param retainScrollPosition - Scroll to the pagination component after updating the route instead of the top of the page
|
||||||
|
* @param navigationExtras - Extra parameters to pass on to `router.navigate`. Can be used to override values set by this service.
|
||||||
*/
|
*/
|
||||||
updateRouteWithUrl(paginationId: string, url: string[], params: {
|
updateRouteWithUrl(
|
||||||
page?: number
|
paginationId: string,
|
||||||
pageSize?: number
|
url: string[],
|
||||||
sortField?: string
|
params: {
|
||||||
sortDirection?: SortDirection
|
page?: number
|
||||||
}, extraParams?, retainScrollPosition?: boolean) {
|
pageSize?: number
|
||||||
|
sortField?: string
|
||||||
|
sortDirection?: SortDirection
|
||||||
|
},
|
||||||
|
extraParams?,
|
||||||
|
retainScrollPosition?: boolean,
|
||||||
|
navigationExtras?: NavigationExtras,
|
||||||
|
) {
|
||||||
this.getCurrentRouting(paginationId).subscribe((currentFindListOptions) => {
|
this.getCurrentRouting(paginationId).subscribe((currentFindListOptions) => {
|
||||||
const currentParametersWithIdName = this.getParametersWithIdName(paginationId, currentFindListOptions);
|
const currentParametersWithIdName = this.getParametersWithIdName(paginationId, currentFindListOptions);
|
||||||
const parametersWithIdName = this.getParametersWithIdName(paginationId, params);
|
const parametersWithIdName = this.getParametersWithIdName(paginationId, params);
|
||||||
@@ -152,12 +167,14 @@ export class PaginationService {
|
|||||||
this.router.navigate(url, {
|
this.router.navigate(url, {
|
||||||
queryParams: queryParams,
|
queryParams: queryParams,
|
||||||
queryParamsHandling: 'merge',
|
queryParamsHandling: 'merge',
|
||||||
fragment: `p-${paginationId}`
|
fragment: `p-${paginationId}`,
|
||||||
|
...navigationExtras,
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
this.router.navigate(url, {
|
this.router.navigate(url, {
|
||||||
queryParams: queryParams,
|
queryParams: queryParams,
|
||||||
queryParamsHandling: 'merge'
|
queryParamsHandling: 'merge',
|
||||||
|
...navigationExtras,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
this.clearParams = {};
|
this.clearParams = {};
|
||||||
|
@@ -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,6 +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 { 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
|
||||||
@@ -50,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 = 5;
|
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);
|
||||||
}
|
}
|
||||||
|
@@ -143,10 +143,6 @@ export abstract class InitService {
|
|||||||
if (environment.debug) {
|
if (environment.debug) {
|
||||||
console.info(environment);
|
console.info(environment);
|
||||||
}
|
}
|
||||||
|
|
||||||
const env: string = environment.production ? 'Production' : 'Development';
|
|
||||||
const color: string = environment.production ? 'red' : 'green';
|
|
||||||
console.info(`Environment: %c${env}`, `color: ${color}; font-weight: bold;`);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -10,9 +10,15 @@ import { AuthService } from '../../core/auth/auth.service';
|
|||||||
import { CookieService } from '../../core/services/cookie.service';
|
import { CookieService } from '../../core/services/cookie.service';
|
||||||
import { getTestScheduler } from 'jasmine-marbles';
|
import { getTestScheduler } from 'jasmine-marbles';
|
||||||
import { MetadataValue } from '../../core/shared/metadata.models';
|
import { MetadataValue } from '../../core/shared/metadata.models';
|
||||||
import { cloneDeep } from 'lodash';
|
import {clone, cloneDeep} from 'lodash';
|
||||||
|
import { ConfigurationDataService } from '../../core/data/configuration-data.service';
|
||||||
|
import {createFailedRemoteDataObject$, createSuccessfulRemoteDataObject$} from '../remote-data.utils';
|
||||||
|
import { ConfigurationProperty } from '../../core/shared/configuration-property.model';
|
||||||
|
|
||||||
describe('BrowserKlaroService', () => {
|
describe('BrowserKlaroService', () => {
|
||||||
|
const trackingIdProp = 'google.analytics.key';
|
||||||
|
const trackingIdTestValue = 'mock-tracking-id';
|
||||||
|
const googleAnalytics = 'google-analytics';
|
||||||
let translateService;
|
let translateService;
|
||||||
let ePersonService;
|
let ePersonService;
|
||||||
let authService;
|
let authService;
|
||||||
@@ -20,11 +26,20 @@ describe('BrowserKlaroService', () => {
|
|||||||
|
|
||||||
let user;
|
let user;
|
||||||
let service: BrowserKlaroService;
|
let service: BrowserKlaroService;
|
||||||
|
let configurationDataService: ConfigurationDataService;
|
||||||
|
const createConfigSuccessSpy = (...values: string[]) => jasmine.createSpyObj('configurationDataService', {
|
||||||
|
findByPropertyName: createSuccessfulRemoteDataObject$({
|
||||||
|
... new ConfigurationProperty(),
|
||||||
|
name: trackingIdProp,
|
||||||
|
values: values,
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
|
||||||
let mockConfig;
|
let mockConfig;
|
||||||
let appName;
|
let appName;
|
||||||
let purpose;
|
let purpose;
|
||||||
let testKey;
|
let testKey;
|
||||||
|
let findByPropertyName;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
user = new EPerson();
|
user = new EPerson();
|
||||||
@@ -38,6 +53,8 @@ describe('BrowserKlaroService', () => {
|
|||||||
isAuthenticated: observableOf(true),
|
isAuthenticated: observableOf(true),
|
||||||
getAuthenticatedUserFromStore: observableOf(user)
|
getAuthenticatedUserFromStore: observableOf(user)
|
||||||
});
|
});
|
||||||
|
configurationDataService = createConfigSuccessSpy(trackingIdTestValue);
|
||||||
|
findByPropertyName = configurationDataService.findByPropertyName;
|
||||||
cookieService = jasmine.createSpyObj('cookieService', {
|
cookieService = jasmine.createSpyObj('cookieService', {
|
||||||
get: '{%22token_item%22:true%2C%22impersonation%22:true%2C%22redirect%22:true%2C%22language%22:true%2C%22klaro%22:true%2C%22has_agreed_end_user%22:true%2C%22google-analytics%22:true}',
|
get: '{%22token_item%22:true%2C%22impersonation%22:true%2C%22redirect%22:true%2C%22language%22:true%2C%22klaro%22:true%2C%22has_agreed_end_user%22:true%2C%22google-analytics%22:true}',
|
||||||
set: () => {
|
set: () => {
|
||||||
@@ -63,6 +80,10 @@ describe('BrowserKlaroService', () => {
|
|||||||
{
|
{
|
||||||
provide: CookieService,
|
provide: CookieService,
|
||||||
useValue: cookieService
|
useValue: cookieService
|
||||||
|
},
|
||||||
|
{
|
||||||
|
provide: ConfigurationDataService,
|
||||||
|
useValue: configurationDataService
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
@@ -83,6 +104,9 @@ describe('BrowserKlaroService', () => {
|
|||||||
services: [{
|
services: [{
|
||||||
name: appName,
|
name: appName,
|
||||||
purposes: [purpose]
|
purposes: [purpose]
|
||||||
|
},{
|
||||||
|
name: googleAnalytics,
|
||||||
|
purposes: [purpose]
|
||||||
}],
|
}],
|
||||||
|
|
||||||
};
|
};
|
||||||
@@ -233,4 +257,54 @@ describe('BrowserKlaroService', () => {
|
|||||||
expect(ePersonService.patch).not.toHaveBeenCalled();
|
expect(ePersonService.patch).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('initialize google analytics configuration', () => {
|
||||||
|
let GOOGLE_ANALYTICS_KEY;
|
||||||
|
beforeEach(() => {
|
||||||
|
GOOGLE_ANALYTICS_KEY = clone((service as any).GOOGLE_ANALYTICS_KEY);
|
||||||
|
configurationDataService.findByPropertyName = findByPropertyName;
|
||||||
|
spyOn((service as any), 'getUser$').and.returnValue(observableOf(user));
|
||||||
|
translateService.get.and.returnValue(observableOf('loading...'));
|
||||||
|
spyOn(service, 'addAppMessages');
|
||||||
|
spyOn((service as any), 'initializeUser');
|
||||||
|
spyOn(service, 'translateConfiguration');
|
||||||
|
});
|
||||||
|
it('should not filter googleAnalytics when servicesToHide are empty', () => {
|
||||||
|
const filteredConfig = (service as any).filterConfigServices([]);
|
||||||
|
expect(filteredConfig).toContain(jasmine.objectContaining({name: googleAnalytics}));
|
||||||
|
});
|
||||||
|
it('should filter services using names passed as servicesToHide', () => {
|
||||||
|
const filteredConfig = (service as any).filterConfigServices([googleAnalytics]);
|
||||||
|
expect(filteredConfig).not.toContain(jasmine.objectContaining({name: googleAnalytics}));
|
||||||
|
});
|
||||||
|
it('should have been initialized with googleAnalytics', () => {
|
||||||
|
service.initialize();
|
||||||
|
expect(service.klaroConfig.services).toContain(jasmine.objectContaining({name: googleAnalytics}));
|
||||||
|
});
|
||||||
|
it('should filter googleAnalytics when empty configuration is retrieved', () => {
|
||||||
|
configurationDataService.findByPropertyName = jasmine.createSpy().withArgs(GOOGLE_ANALYTICS_KEY).and.returnValue(
|
||||||
|
createSuccessfulRemoteDataObject$({
|
||||||
|
... new ConfigurationProperty(),
|
||||||
|
name: googleAnalytics,
|
||||||
|
values: [],
|
||||||
|
}));
|
||||||
|
|
||||||
|
service.initialize();
|
||||||
|
expect(service.klaroConfig.services).not.toContain(jasmine.objectContaining({name: googleAnalytics}));
|
||||||
|
});
|
||||||
|
it('should filter googleAnalytics when an error occurs', () => {
|
||||||
|
configurationDataService.findByPropertyName = jasmine.createSpy().withArgs(GOOGLE_ANALYTICS_KEY).and.returnValue(
|
||||||
|
createFailedRemoteDataObject$('Erro while loading GA')
|
||||||
|
);
|
||||||
|
service.initialize();
|
||||||
|
expect(service.klaroConfig.services).not.toContain(jasmine.objectContaining({name: googleAnalytics}));
|
||||||
|
});
|
||||||
|
it('should filter googleAnalytics when an invalid payload is retrieved', () => {
|
||||||
|
configurationDataService.findByPropertyName = jasmine.createSpy().withArgs(GOOGLE_ANALYTICS_KEY).and.returnValue(
|
||||||
|
createSuccessfulRemoteDataObject$(null)
|
||||||
|
);
|
||||||
|
service.initialize();
|
||||||
|
expect(service.klaroConfig.services).not.toContain(jasmine.objectContaining({name: googleAnalytics}));
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@@ -4,15 +4,17 @@ import { combineLatest as observableCombineLatest, Observable, of as observableO
|
|||||||
import { AuthService } from '../../core/auth/auth.service';
|
import { AuthService } from '../../core/auth/auth.service';
|
||||||
import { TranslateService } from '@ngx-translate/core';
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
import { environment } from '../../../environments/environment';
|
import { environment } from '../../../environments/environment';
|
||||||
import { switchMap, take } from 'rxjs/operators';
|
import { map, switchMap, take } from 'rxjs/operators';
|
||||||
import { EPerson } from '../../core/eperson/models/eperson.model';
|
import { EPerson } from '../../core/eperson/models/eperson.model';
|
||||||
import { KlaroService } from './klaro.service';
|
import { KlaroService } from './klaro.service';
|
||||||
import { hasValue, isNotEmpty } from '../empty.util';
|
import { hasValue, isEmpty, isNotEmpty } from '../empty.util';
|
||||||
import { CookieService } from '../../core/services/cookie.service';
|
import { CookieService } from '../../core/services/cookie.service';
|
||||||
import { EPersonDataService } from '../../core/eperson/eperson-data.service';
|
import { EPersonDataService } from '../../core/eperson/eperson-data.service';
|
||||||
import { cloneDeep, debounce } from 'lodash';
|
import { cloneDeep, debounce } from 'lodash';
|
||||||
import { ANONYMOUS_STORAGE_NAME_KLARO, klaroConfiguration } from './klaro-configuration';
|
import { ANONYMOUS_STORAGE_NAME_KLARO, klaroConfiguration } from './klaro-configuration';
|
||||||
import { Operation } from 'fast-json-patch';
|
import { Operation } from 'fast-json-patch';
|
||||||
|
import { getFirstCompletedRemoteData} from '../../core/shared/operators';
|
||||||
|
import { ConfigurationDataService } from '../../core/data/configuration-data.service';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Metadata field to store a user's cookie consent preferences in
|
* Metadata field to store a user's cookie consent preferences in
|
||||||
@@ -38,23 +40,31 @@ const cookiePurposeMessagePrefix = 'cookies.consent.purpose.';
|
|||||||
* Update request debounce in ms
|
* Update request debounce in ms
|
||||||
*/
|
*/
|
||||||
const updateDebounce = 300;
|
const updateDebounce = 300;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Browser implementation for the KlaroService, representing a service for handling Klaro consent preferences and UI
|
* Browser implementation for the KlaroService, representing a service for handling Klaro consent preferences and UI
|
||||||
*/
|
*/
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class BrowserKlaroService extends KlaroService {
|
export class BrowserKlaroService extends KlaroService {
|
||||||
|
|
||||||
|
private readonly GOOGLE_ANALYTICS_KEY = 'google.analytics.key';
|
||||||
|
|
||||||
|
private readonly GOOGLE_ANALYTICS_SERVICE_NAME = 'google-analytics';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initial Klaro configuration
|
* Initial Klaro configuration
|
||||||
*/
|
*/
|
||||||
klaroConfig = klaroConfiguration;
|
klaroConfig = cloneDeep(klaroConfiguration);
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private translateService: TranslateService,
|
private translateService: TranslateService,
|
||||||
private authService: AuthService,
|
private authService: AuthService,
|
||||||
private ePersonService: EPersonDataService,
|
private ePersonService: EPersonDataService,
|
||||||
|
private configService: ConfigurationDataService,
|
||||||
private cookieService: CookieService) {
|
private cookieService: CookieService) {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes the service:
|
* Initializes the service:
|
||||||
* - Retrieves the current authenticated user
|
* - Retrieves the current authenticated user
|
||||||
@@ -68,14 +78,25 @@ export class BrowserKlaroService extends KlaroService {
|
|||||||
this.klaroConfig.translations.en.consentNotice.description = 'cookies.consent.content-notice.description.no-privacy';
|
this.klaroConfig.translations.en.consentNotice.description = 'cookies.consent.content-notice.description.no-privacy';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const servicesToHide$: Observable<string[]> = this.configService.findByPropertyName(this.GOOGLE_ANALYTICS_KEY).pipe(
|
||||||
|
getFirstCompletedRemoteData(),
|
||||||
|
map(remoteData => {
|
||||||
|
if (!remoteData.hasSucceeded || !remoteData.payload || isEmpty(remoteData.payload.values)) {
|
||||||
|
return [this.GOOGLE_ANALYTICS_SERVICE_NAME];
|
||||||
|
} else {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
this.translateService.setDefaultLang(environment.defaultLanguage);
|
this.translateService.setDefaultLang(environment.defaultLanguage);
|
||||||
|
|
||||||
const user$: Observable<EPerson> = this.getUser$();
|
const user$: Observable<EPerson> = this.getUser$();
|
||||||
|
|
||||||
const translationServiceReady$ = this.translateService.get('loading.default').pipe(take(1));
|
const translationServiceReady$ = this.translateService.get('loading.default').pipe(take(1));
|
||||||
|
|
||||||
observableCombineLatest([user$, translationServiceReady$])
|
observableCombineLatest([user$, servicesToHide$, translationServiceReady$])
|
||||||
.subscribe(([user, translation]: [EPerson, string]) => {
|
.subscribe(([user, servicesToHide, _]: [EPerson, string[], string]) => {
|
||||||
user = cloneDeep(user);
|
user = cloneDeep(user);
|
||||||
|
|
||||||
if (hasValue(user)) {
|
if (hasValue(user)) {
|
||||||
@@ -93,6 +114,9 @@ export class BrowserKlaroService extends KlaroService {
|
|||||||
* Show the configuration if the configuration has not been confirmed
|
* Show the configuration if the configuration has not been confirmed
|
||||||
*/
|
*/
|
||||||
this.translateConfiguration();
|
this.translateConfiguration();
|
||||||
|
|
||||||
|
this.klaroConfig.services = this.filterConfigServices(servicesToHide);
|
||||||
|
|
||||||
Klaro.setup(this.klaroConfig);
|
Klaro.setup(this.klaroConfig);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -168,7 +192,10 @@ export class BrowserKlaroService extends KlaroService {
|
|||||||
*/
|
*/
|
||||||
addAppMessages() {
|
addAppMessages() {
|
||||||
this.klaroConfig.services.forEach((app) => {
|
this.klaroConfig.services.forEach((app) => {
|
||||||
this.klaroConfig.translations.en[app.name] = { title: this.getTitleTranslation(app.name), description: this.getDescriptionTranslation(app.name) };
|
this.klaroConfig.translations.en[app.name] = {
|
||||||
|
title: this.getTitleTranslation(app.name),
|
||||||
|
description: this.getDescriptionTranslation(app.name)
|
||||||
|
};
|
||||||
app.purposes.forEach((purpose) => {
|
app.purposes.forEach((purpose) => {
|
||||||
this.klaroConfig.translations.en.purposes[purpose] = this.getPurposeTranslation(purpose);
|
this.klaroConfig.translations.en.purposes[purpose] = this.getPurposeTranslation(purpose);
|
||||||
});
|
});
|
||||||
@@ -257,4 +284,11 @@ export class BrowserKlaroService extends KlaroService {
|
|||||||
getStorageName(identifier: string) {
|
getStorageName(identifier: string) {
|
||||||
return 'klaro-' + identifier;
|
return 'klaro-' + identifier;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* remove the google analytics from the services
|
||||||
|
*/
|
||||||
|
private filterConfigServices(servicesToHide: string[]): Pick<typeof klaroConfiguration, 'services'>[] {
|
||||||
|
return this.klaroConfig.services.filter(service => !servicesToHide.some(name => name === service.name));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
2242
src/assets/i18n/el.json5
Normal file
2242
src/assets/i18n/el.json5
Normal file
File diff suppressed because it is too large
Load Diff
7745
src/assets/i18n/kk.json5
Normal file
7745
src/assets/i18n/kk.json5
Normal file
File diff suppressed because it is too large
Load Diff
@@ -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,6 +33,8 @@ interface AppConfig extends Config {
|
|||||||
defaultLanguage: string;
|
defaultLanguage: string;
|
||||||
languages: LangConfig[];
|
languages: LangConfig[];
|
||||||
browseBy: BrowseByConfig;
|
browseBy: BrowseByConfig;
|
||||||
|
communityList: CommunityListConfig;
|
||||||
|
homePage: HomeConfig;
|
||||||
item: ItemConfig;
|
item: ItemConfig;
|
||||||
collection: CollectionPageConfig;
|
collection: CollectionPageConfig;
|
||||||
themes: ThemeConfig[];
|
themes: ThemeConfig[];
|
||||||
@@ -38,7 +42,6 @@ interface AppConfig extends Config {
|
|||||||
bundle: BundleConfig;
|
bundle: BundleConfig;
|
||||||
actuators: ActuatorsConfig
|
actuators: ActuatorsConfig
|
||||||
info: InfoConfig;
|
info: InfoConfig;
|
||||||
homePage: HomeConfig;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
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;
|
||||||
|
}
|
@@ -54,14 +54,28 @@ const getEnvironment = (): Environment => {
|
|||||||
return environment;
|
return environment;
|
||||||
};
|
};
|
||||||
|
|
||||||
const getLocalConfigPath = (env: Environment) => {
|
/**
|
||||||
// default to config/config.yml
|
* Get the path of the default config file.
|
||||||
let localConfigPath = join(CONFIG_PATH, 'config.yml');
|
*/
|
||||||
|
const getDefaultConfigPath = () => {
|
||||||
|
|
||||||
if (!fs.existsSync(localConfigPath)) {
|
// default to config/config.yml
|
||||||
localConfigPath = join(CONFIG_PATH, 'config.yaml');
|
let defaultConfigPath = join(CONFIG_PATH, 'config.yml');
|
||||||
|
|
||||||
|
if (!fs.existsSync(defaultConfigPath)) {
|
||||||
|
defaultConfigPath = join(CONFIG_PATH, 'config.yaml');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return defaultConfigPath;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the path of an environment-specific config file.
|
||||||
|
*
|
||||||
|
* @param env the environment to get the config file for
|
||||||
|
*/
|
||||||
|
const getEnvConfigFilePath = (env: Environment) => {
|
||||||
|
|
||||||
// determine app config filename variations
|
// determine app config filename variations
|
||||||
let envVariations;
|
let envVariations;
|
||||||
switch (env) {
|
switch (env) {
|
||||||
@@ -76,22 +90,21 @@ const getLocalConfigPath = (env: Environment) => {
|
|||||||
envVariations = ['dev', 'development'];
|
envVariations = ['dev', 'development'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let envLocalConfigPath;
|
||||||
|
|
||||||
// check if any environment variations of app config exist
|
// check if any environment variations of app config exist
|
||||||
for (const envVariation of envVariations) {
|
for (const envVariation of envVariations) {
|
||||||
let envLocalConfigPath = join(CONFIG_PATH, `config.${envVariation}.yml`);
|
envLocalConfigPath = join(CONFIG_PATH, `config.${envVariation}.yml`);
|
||||||
|
if (fs.existsSync(envLocalConfigPath)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
envLocalConfigPath = join(CONFIG_PATH, `config.${envVariation}.yaml`);
|
||||||
if (fs.existsSync(envLocalConfigPath)) {
|
if (fs.existsSync(envLocalConfigPath)) {
|
||||||
localConfigPath = envLocalConfigPath;
|
|
||||||
break;
|
break;
|
||||||
} else {
|
|
||||||
envLocalConfigPath = join(CONFIG_PATH, `config.${envVariation}.yaml`);
|
|
||||||
if (fs.existsSync(envLocalConfigPath)) {
|
|
||||||
localConfigPath = envLocalConfigPath;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return localConfigPath;
|
return envLocalConfigPath;
|
||||||
};
|
};
|
||||||
|
|
||||||
const overrideWithConfig = (config: Config, pathToConfig: string) => {
|
const overrideWithConfig = (config: Config, pathToConfig: string) => {
|
||||||
@@ -174,12 +187,20 @@ export const buildAppConfig = (destConfigPath?: string): AppConfig => {
|
|||||||
console.log(`Building ${colors.green.bold(`development`)} app config`);
|
console.log(`Building ${colors.green.bold(`development`)} app config`);
|
||||||
}
|
}
|
||||||
|
|
||||||
// override with dist config
|
// override with default config
|
||||||
const localConfigPath = getLocalConfigPath(env);
|
const defaultConfigPath = getDefaultConfigPath();
|
||||||
|
if (fs.existsSync(defaultConfigPath)) {
|
||||||
|
overrideWithConfig(appConfig, defaultConfigPath);
|
||||||
|
} else {
|
||||||
|
console.warn(`Unable to find default config file at ${defaultConfigPath}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
// override with env config
|
||||||
|
const localConfigPath = getEnvConfigFilePath(env);
|
||||||
if (fs.existsSync(localConfigPath)) {
|
if (fs.existsSync(localConfigPath)) {
|
||||||
overrideWithConfig(appConfig, localConfigPath);
|
overrideWithConfig(appConfig, localConfigPath);
|
||||||
} else {
|
} else {
|
||||||
console.warn(`Unable to find dist config file at ${localConfigPath}`);
|
console.warn(`Unable to find env config file at ${localConfigPath}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
// override with external config if specified by environment variable `DSPACE_APP_CONFIG_PATH`
|
// override with external config if specified by environment variable `DSPACE_APP_CONFIG_PATH`
|
||||||
|
@@ -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;
|
||||||
|
|
||||||
@@ -195,7 +197,9 @@ export class DefaultAppConfig implements AppConfig {
|
|||||||
{ code: 'fi', label: 'Suomi', active: true },
|
{ code: 'fi', label: 'Suomi', active: true },
|
||||||
{ code: 'sv', label: 'Svenska', active: true },
|
{ code: 'sv', label: 'Svenska', active: true },
|
||||||
{ code: 'tr', label: 'Türkçe', active: true },
|
{ code: 'tr', label: 'Türkçe', active: true },
|
||||||
{ code: 'bn', label: 'বাংলা', active: true }
|
{ code: 'kk', label: 'Қазақ', active: true },
|
||||||
|
{ code: 'bn', label: 'বাংলা', active: true },
|
||||||
|
{ code: 'el', label: 'Ελληνικά', active: true }
|
||||||
];
|
];
|
||||||
|
|
||||||
// Browse-By Pages
|
// Browse-By Pages
|
||||||
@@ -210,6 +214,22 @@ export class DefaultAppConfig implements AppConfig {
|
|||||||
showThumbnails: true
|
showThumbnails: true
|
||||||
};
|
};
|
||||||
|
|
||||||
|
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 Config
|
||||||
item: ItemConfig = {
|
item: ItemConfig = {
|
||||||
edit: {
|
edit: {
|
||||||
@@ -340,13 +360,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;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
@@ -189,6 +189,10 @@ export const environment: BuildConfig = {
|
|||||||
code: 'bn',
|
code: 'bn',
|
||||||
label: 'বাংলা',
|
label: 'বাংলা',
|
||||||
active: true,
|
active: true,
|
||||||
|
}, {
|
||||||
|
code: 'el',
|
||||||
|
label: 'Ελληνικά',
|
||||||
|
active: true,
|
||||||
}],
|
}],
|
||||||
|
|
||||||
// Browse-By Pages
|
// Browse-By Pages
|
||||||
@@ -202,7 +206,19 @@ export const environment: BuildConfig = {
|
|||||||
// Whether to add item thumbnail images to BOTH browse and search result lists.
|
// Whether to add item thumbnail images to BOTH browse and search result lists.
|
||||||
showThumbnails: true
|
showThumbnails: true
|
||||||
},
|
},
|
||||||
|
communityList: {
|
||||||
|
pageSize: 20
|
||||||
|
},
|
||||||
|
homePage: {
|
||||||
|
recentSubmissions: {
|
||||||
|
pageSize: 5,
|
||||||
|
//sort record of recent submission
|
||||||
|
sortField: 'dc.date.accessioned',
|
||||||
|
},
|
||||||
|
topLevelCommunityList: {
|
||||||
|
pageSize: 5
|
||||||
|
}
|
||||||
|
},
|
||||||
item: {
|
item: {
|
||||||
edit: {
|
edit: {
|
||||||
undoTimeout: 10000 // 10 seconds
|
undoTimeout: 10000 // 10 seconds
|
||||||
@@ -251,12 +267,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',
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
@@ -28,6 +28,7 @@ import { StoreAction, StoreActionTypes } from '../../app/store.actions';
|
|||||||
import { coreSelector } from '../../app/core/core.selectors';
|
import { coreSelector } from '../../app/core/core.selectors';
|
||||||
import { find, map } from 'rxjs/operators';
|
import { find, map } from 'rxjs/operators';
|
||||||
import { isNotEmpty } from '../../app/shared/empty.util';
|
import { isNotEmpty } from '../../app/shared/empty.util';
|
||||||
|
import { logStartupMessage } from '../../../startup-message';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Performs client-side initialization.
|
* Performs client-side initialization.
|
||||||
@@ -79,6 +80,7 @@ export class BrowserInitService extends InitService {
|
|||||||
this.initCorrelationId();
|
this.initCorrelationId();
|
||||||
|
|
||||||
this.checkEnvironment();
|
this.checkEnvironment();
|
||||||
|
logStartupMessage(environment);
|
||||||
|
|
||||||
this.initI18n();
|
this.initI18n();
|
||||||
this.initAngulartics();
|
this.initAngulartics();
|
||||||
|
19
startup-message.ts
Normal file
19
startup-message.ts
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
import PACKAGE_JSON from './package.json';
|
||||||
|
import { BuildConfig } from './src/config/build-config.interface';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Log a message at the start of the application containing the version number and the environment.
|
||||||
|
*
|
||||||
|
* @param environment the environment configuration
|
||||||
|
*/
|
||||||
|
export const logStartupMessage = (environment: Partial<BuildConfig>) => {
|
||||||
|
const env: string = environment.production ? 'Production' : 'Development';
|
||||||
|
const color: string = environment.production ? 'red' : 'green';
|
||||||
|
|
||||||
|
console.info('');
|
||||||
|
console.info(`%cdspace-angular`, `font-weight: bold;`);
|
||||||
|
console.info(`Version: %c${PACKAGE_JSON.version}`, `font-weight: bold;`);
|
||||||
|
console.info(`Environment: %c${env}`, `color: ${color}; font-weight: bold;`);
|
||||||
|
console.info('');
|
||||||
|
|
||||||
|
}
|
Reference in New Issue
Block a user