updated angular/rxjs to v6 successfully

This commit is contained in:
lotte
2018-08-31 15:40:39 +02:00
parent 777facf5cd
commit f11d486d14
78 changed files with 968 additions and 1361 deletions

View File

@@ -25,7 +25,7 @@
"prebuild:prod": "yarn run prebuild",
"build": "webpack --progress --mode development",
"build:aot": "webpack --env.aot --env.server --mode development && webpack --env.aot --env.client --mode development",
"build:prod": "webpack --env.aot --env.server --mode production && webpack --env.aot --env.client --mode production",
"build:prod": "webpack --env.aot --env.server --env.production && webpack --env.aot --env.client --env.production",
"postbuild:prod": "yarn run rollup",
"rollup": "rollup -c rollup.config.js",
"prestart": "yarn run build:prod",
@@ -120,6 +120,7 @@
"ts-md5": "^1.2.4",
"uuid": "^3.2.1",
"webfontloader": "1.6.28",
"webpack-cli": "^3.1.0",
"zone.js": "^0.8.26"
},
"devDependencies": {
@@ -131,37 +132,36 @@
"@types/cookie-parser": "1.4.1",
"@types/deep-freeze": "0.1.1",
"@types/express": "^4.11.1",
"@types/express-serve-static-core": "4.11.1",
"@types/express-serve-static-core": "4.16.0",
"@types/hammerjs": "2.0.35",
"@types/jasmine": "^2.8.6",
"@types/js-cookie": "2.1.0",
"@types/lodash": "^4.14.110",
"@types/memory-cache": "0.2.0",
"@types/mime": "2.0.0",
"@types/node": "^9.4.6",
"@types/serve-static": "1.13.1",
"@types/node": "^10.9.4",
"@types/serve-static": "1.13.2",
"@types/uuid": "^3.4.3",
"@types/webfontloader": "1.6.29",
"ajv": "^6.1.1",
"ajv-keywords": "^3.1.0",
"angular2-template-loader": "0.6.2",
"autoprefixer": "^8.0.0",
"awesome-typescript-loader": "3.4.1",
"autoprefixer": "^9.1.3",
"awesome-typescript-loader": "5.2.0",
"caniuse-lite": "^1.0.30000697",
"codelyzer": "^4.4.4",
"compression-webpack-plugin": "^1.1.6",
"copy-webpack-plugin": "^4.4.1",
"coveralls": "3.0.0",
"css-loader": "0.28.9",
"css-loader": "1.0.0",
"deep-freeze": "0.0.1",
"exports-loader": "^0.7.0",
"html-webpack-plugin": "^4.0.0-alpha",
"imports-loader": "0.7.1",
"imports-loader": "0.8.0",
"istanbul-instrumenter-loader": "3.0.1",
"jasmine-core": "^3.2.1",
"jasmine-marbles": "0.3.0",
"jasmine-spec-reporter": "4.2.1",
"json-loader": "0.5.7",
"karma": "2.0.0",
"karma-chrome-launcher": "2.2.0",
"karma-cli": "1.0.1",
@@ -191,25 +191,24 @@
"raw-loader": "0.5.1",
"resolve-url-loader": "^2.3.0",
"rimraf": "2.6.2",
"rollup": "^0.56.0",
"rollup-plugin-commonjs": "^8.3.0",
"rollup-plugin-node-globals": "1.1.0",
"rollup": "^0.65.0",
"rollup-plugin-commonjs": "^9.1.6",
"rollup-plugin-node-globals": "1.2.1",
"rollup-plugin-node-resolve": "^3.0.3",
"rollup-plugin-uglify": "3.0.0",
"rollup-plugin-terser": "^2.0.2",
"sass-loader": "6.0.6",
"script-ext-html-webpack-plugin": "2.0.1",
"source-map": "0.6.1",
"source-map-loader": "0.2.3",
"source-map": "0.7.3",
"source-map-loader": "0.2.4",
"string-replace-loader": "2.1.1",
"to-string-loader": "1.1.5",
"ts-helpers": "1.1.2",
"ts-node": "4.1.0",
"tslint": "5.9.1",
"tslint": "5.11.0",
"typedoc": "^0.9.0",
"typescript": "^2.9.1",
"webpack": "^4.17.1",
"webpack-bundle-analyzer": "^2.13.1",
"webpack-command": "^0.4.1",
"webpack-dev-middleware": "3.2.0",
"webpack-dev-server": "^3.1.5",
"webpack-merge": "4.1.4",

View File

@@ -1,6 +1,6 @@
import nodeResolve from 'rollup-plugin-node-resolve'
import commonjs from 'rollup-plugin-commonjs';
import uglify from 'rollup-plugin-uglify'
import terser from 'rollup-plugin-terser'
export default {
input: 'dist/client.js',
@@ -8,7 +8,6 @@ export default {
file: 'dist/client.js',
format: 'iife',
},
sourcemap: false,
plugins: [
nodeResolve({
jsnext: true,
@@ -17,6 +16,6 @@ export default {
commonjs({
include: 'node_modules/rxjs/**'
}),
uglify()
terser.terser()
]
}

View File

@@ -1,14 +1,13 @@
import { BitstreamFormatsComponent } from './bitstream-formats.component';
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { RegistryService } from '../../../core/registry/registry.service';
import { Observable } from 'rxjs';
import { of as observableOf } from 'rxjs';
import { RemoteData } from '../../../core/data/remote-data';
import { PaginatedList } from '../../../core/data/paginated-list';
import { CommonModule } from '@angular/common';
import { RouterTestingModule } from '@angular/router/testing';
import { TranslateModule } from '@ngx-translate/core';
import { By } from '@angular/platform-browser';
import { SharedModule } from '../../../shared/shared.module';
import { PaginationComponent } from '../../../shared/pagination/pagination.component';
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
import { EnumKeysPipe } from '../../../shared/utils/enum-keys-pipe';
@@ -53,7 +52,7 @@ describe('BitstreamFormatsComponent', () => {
extensions: null
}
];
const mockFormats = Observable.of(new RemoteData(false, false, true, undefined, new PaginatedList(null, mockFormatsList)));
const mockFormats = observableOf(new RemoteData(false, false, true, undefined, new PaginatedList(null, mockFormatsList)));
const registryServiceStub = {
getBitstreamFormats: () => mockFormats
};

View File

@@ -1,6 +1,6 @@
import { MetadataRegistryComponent } from './metadata-registry.component';
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { Observable } from 'rxjs';
import { of as observableOf } from 'rxjs';
import { RemoteData } from '../../../core/data/remote-data';
import { PaginatedList } from '../../../core/data/paginated-list';
import { TranslateModule } from '@ngx-translate/core';
@@ -8,13 +8,13 @@ import { By } from '@angular/platform-browser';
import { CommonModule } from '@angular/common';
import { RouterTestingModule } from '@angular/router/testing';
import { RegistryService } from '../../../core/registry/registry.service';
import { SharedModule } from '../../../shared/shared.module';
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
import { EnumKeysPipe } from '../../../shared/utils/enum-keys-pipe';
import { PaginationComponent } from '../../../shared/pagination/pagination.component';
import { HostWindowServiceStub } from '../../../shared/testing/host-window-service-stub';
import { HostWindowService } from '../../../shared/host-window.service';
describe('MetadataRegistryComponent', () => {
let comp: MetadataRegistryComponent;
let fixture: ComponentFixture<MetadataRegistryComponent>;
@@ -33,7 +33,7 @@ describe('MetadataRegistryComponent', () => {
namespace: 'http://dspace.org/mockschema'
}
];
const mockSchemas = Observable.of(new RemoteData(false, false, true, undefined, new PaginatedList(null, mockSchemasList)));
const mockSchemas = observableOf(new RemoteData(false, false, true, undefined, new PaginatedList(null, mockSchemasList)));
const registryServiceStub = {
getMetadataSchemas: () => mockSchemas
};

View File

@@ -1,16 +1,14 @@
import { MetadataSchemaComponent } from './metadata-schema.component';
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { Observable } from 'rxjs';
import { of as observableOf } from 'rxjs';
import { RemoteData } from '../../../core/data/remote-data';
import { PaginatedList } from '../../../core/data/paginated-list';
import { MetadataSchema } from '../../../core/metadata/metadataschema.model';
import { TranslateLoader, TranslateModule } from '@ngx-translate/core';
import { TranslateModule } from '@ngx-translate/core';
import { CommonModule } from '@angular/common';
import { ActivatedRoute, Router } from '@angular/router';
import { By } from '@angular/platform-browser';
import { MockTranslateLoader } from '../../../shared/testing/mock-translate-loader';
import { RegistryService } from '../../../core/registry/registry.service';
import { SharedModule } from '../../../shared/shared.module';
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
import { EnumKeysPipe } from '../../../shared/utils/enum-keys-pipe';
import { PaginationComponent } from '../../../shared/pagination/pagination.component';
@@ -68,15 +66,15 @@ describe('MetadataSchemaComponent', () => {
schema: mockSchemasList[1]
}
];
const mockSchemas = Observable.of(new RemoteData(false, false, true, undefined, new PaginatedList(null, mockSchemasList)));
const mockSchemas = observableOf(new RemoteData(false, false, true, undefined, new PaginatedList(null, mockSchemasList)));
const registryServiceStub = {
getMetadataSchemas: () => mockSchemas,
getMetadataFieldsBySchema: (schema: MetadataSchema) => Observable.of(new RemoteData(false, false, true, undefined, new PaginatedList(null, mockFieldsList.filter((value) => value.schema === schema)))),
getMetadataSchemaByName: (schemaName: string) => Observable.of(new RemoteData(false, false, true, undefined, mockSchemasList.filter((value) => value.prefix === schemaName)[0]))
getMetadataFieldsBySchema: (schema: MetadataSchema) => observableOf(new RemoteData(false, false, true, undefined, new PaginatedList(null, mockFieldsList.filter((value) => value.schema === schema)))),
getMetadataSchemaByName: (schemaName: string) => observableOf(new RemoteData(false, false, true, undefined, mockSchemasList.filter((value) => value.prefix === schemaName)[0]))
};
const schemaNameParam = 'mock';
const activatedRouteStub = Object.assign(new ActivatedRouteStub(), {
params: Observable.of({
params: observableOf({
schemaName: schemaNameParam
})
});

View File

@@ -6,7 +6,7 @@ import { Collection } from '../../../core/shared/collection.model';
import { RemoteDataBuildService } from '../../../core/cache/builders/remote-data-build.service';
import { getMockRemoteDataBuildService } from '../../../shared/mocks/mock-remote-data-build.service';
import { Item } from '../../../core/shared/item.model';
import { Observable } from 'rxjs';
import { of as observableOf } from 'rxjs';
import { RemoteData } from '../../../core/data/remote-data';
import { TranslateModule } from '@ngx-translate/core';
@@ -22,8 +22,8 @@ const mockCollection1: Collection = Object.assign(new Collection(), {
}]
});
const succeededMockItem: Item = Object.assign(new Item(), {owningCollection: Observable.of(new RemoteData(false, false, true, null, mockCollection1))});
const failedMockItem: Item = Object.assign(new Item(), {owningCollection: Observable.of(new RemoteData(false, false, false, null, mockCollection1))});
const succeededMockItem: Item = Object.assign(new Item(), {owningCollection: observableOf(new RemoteData(false, false, true, null, mockCollection1))});
const failedMockItem: Item = Object.assign(new Item(), {owningCollection: observableOf(new RemoteData(false, false, false, null, mockCollection1))});
describe('CollectionsComponent', () => {
beforeEach(async(() => {

View File

@@ -1,11 +1,10 @@
import {combineLatest as observableCombineLatest, Observable } from 'rxjs';
import { combineLatest as observableCombineLatest, Observable } from 'rxjs';
import { Component, Input, OnInit } from '@angular/core';
import { Bitstream } from '../../../../core/shared/bitstream.model';
import { Item } from '../../../../core/shared/item.model';
import { FileSectionComponent } from '../../../simple/field-components/file-section/file-section.component';
import { hasValue } from '../../../../shared/empty.util';
import { map } from 'rxjs/operators';
/**
* This component renders the file section of the item
@@ -34,7 +33,7 @@ export class FullFileSectionComponent extends FileSectionComponent implements On
initialize(): void {
const originals = this.item.getFiles();
const licenses = this.item.getBitstreamsByBundleName('LICENSE');
this.bitstreamsObs = observableCombineLatest(originals, licenses, (o, l) => [...o, ...l]);
this.bitstreamsObs = observableCombineLatest(originals, licenses).pipe(map(([o, l]) => [...o, ...l]));
this.bitstreamsObs.subscribe(
(files) =>
files.forEach(

View File

@@ -3,7 +3,7 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { Store } from '@ngrx/store';
import { TranslateModule } from '@ngx-translate/core';
import { Observable } from 'rxjs';
import { of as observableOf } from 'rxjs';
import 'rxjs/add/observable/of';
import { LoginPageComponent } from './login-page.component';
@@ -16,7 +16,7 @@ describe('LoginPageComponent', () => {
/* tslint:disable:no-empty */
dispatch: {},
/* tslint:enable:no-empty */
select: Observable.of(true)
select: observableOf(true)
});
beforeEach(async(() => {

View File

@@ -1,4 +1,3 @@
import 'rxjs/add/observable/of';
import { SortDirection, SortOptions } from '../core/cache/models/sort-options.model';
import { PaginationComponentOptions } from '../shared/pagination/pagination-component-options.model';
import { PaginatedSearchOptions } from './paginated-search-options.model';

View File

@@ -7,7 +7,7 @@ import { SearchFilterConfig } from '../../../search-service/search-filter-config
import { FilterType } from '../../../search-service/filter-type.model';
import { FacetValue } from '../../../search-service/facet-value.model';
import { FormsModule } from '@angular/forms';
import { Observable } from 'rxjs';
import { of as observableOf } from 'rxjs';
import { SearchService } from '../../../search-service/search.service';
import { SearchServiceStub } from '../../../../shared/testing/search-service-stub';
import { RemoteData } from '../../../../core/data/remote-data';
@@ -54,9 +54,9 @@ describe('SearchFacetFilterComponent', () => {
let filterService;
let searchService;
let router;
const page = Observable.of(0);
const page = observableOf(0);
const mockValues = Observable.of(new RemoteData(false, false, true, null, new PaginatedList(new PageInfo(), values)));
const mockValues = observableOf(new RemoteData(false, false, true, null, new PaginatedList(new PageInfo(), values)));
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [TranslateModule.forRoot(), NoopAnimationsModule, FormsModule],
@@ -65,11 +65,11 @@ describe('SearchFacetFilterComponent', () => {
{ provide: SearchService, useValue: new SearchServiceStub(searchLink) },
{ provide: Router, useValue: new RouterStub() },
{ provide: FILTER_CONFIG, useValue: new SearchFilterConfig() },
{ provide: RemoteDataBuildService, useValue: {aggregate: () => Observable.of({})} },
{ provide: SearchConfigurationService, useValue: {searchOptions: Observable.of({})} },
{ provide: RemoteDataBuildService, useValue: {aggregate: () => observableOf({})} },
{ provide: SearchConfigurationService, useValue: {searchOptions: observableOf({})} },
{
provide: SearchFilterService, useValue: {
getSelectedValuesForFilter: () => Observable.of(selectedValues),
getSelectedValuesForFilter: () => observableOf(selectedValues),
isFilterActiveWithValue: (paramName: string, filterValue: string) => true,
getPage: (paramName: string) => page,
/* tslint:disable:no-empty */

View File

@@ -1,5 +1,12 @@
import {combineLatest as observableCombineLatest, of as observableOf, BehaviorSubject , Observable , Subject , Subscription } from 'rxjs';
import {switchMap, distinctUntilChanged, first, map } from 'rxjs/operators';
import {
combineLatest as observableCombineLatest,
of as observableOf,
BehaviorSubject,
Observable,
Subject,
Subscription
} from 'rxjs';
import { switchMap, distinctUntilChanged, first, map } from 'rxjs/operators';
import { animate, state, style, transition, trigger } from '@angular/animations';
import { Component, Inject, OnDestroy, OnInit } from '@angular/core';
import { Router } from '@angular/router';
@@ -82,21 +89,24 @@ export class SearchFacetFilterComponent implements OnInit, OnDestroy {
this.selectedValues = this.filterService.getSelectedValuesForFilter(this.filterConfig);
const searchOptions = this.searchConfigService.searchOptions;
this.subs.push(this.searchConfigService.searchOptions.subscribe(() => this.updateFilterValueList()));
const facetValues = observableCombineLatest(searchOptions, this.currentPage, (options, page) => {
return { options, page }
}).pipe(switchMap(({ options, page }) => {
return this.searchService.getFacetValuesFor(this.filterConfig, page, options)
.pipe(
getSucceededRemoteData(),
map((results) => {
return {
values: observableOf(results),
page: page
};
}
const facetValues = observableCombineLatest(searchOptions, this.currentPage).pipe(
map(([options, page]) => {
return { options, page }
}),
switchMap(({ options, page }) => {
return this.searchService.getFacetValuesFor(this.filterConfig, page, options)
.pipe(
getSucceededRemoteData(),
map((results) => {
return {
values: observableOf(results),
page: page
};
}
)
)
)
}));
})
);
let filterValues = [];
this.subs.push(facetValues.subscribe((facetOutcome) => {
const newValues$ = facetOutcome.values;

View File

@@ -3,7 +3,7 @@ import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core';
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { RouterTestingModule } from '@angular/router/testing';
import { TranslateModule } from '@ngx-translate/core';
import { Observable } from 'rxjs';
import { Observable, of as observableOf } from 'rxjs';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { SearchFilterService } from './search-filter.service';
import { SearchService } from '../../search-service/search.service';
@@ -38,19 +38,19 @@ describe('SearchFilterComponent', () => {
initialExpand: (filter) => {
},
getSelectedValuesForFilter: (filter) => {
return Observable.of([filterName1, filterName2, filterName3])
return observableOf([filterName1, filterName2, filterName3])
},
isFilterActive: (filter) => {
return Observable.of([filterName1, filterName2, filterName3].indexOf(filter) >= 0);
return observableOf([filterName1, filterName2, filterName3].indexOf(filter) >= 0);
},
isCollapsed: (filter) => {
return Observable.of(true)
return observableOf(true)
}
/* tslint:enable:no-empty */
};
let filterService;
const mockResults = Observable.of(['test', 'data']);
const mockResults = observableOf(['test', 'data']);
const searchServiceStub = {
getFacetValuesFor: (filter) => mockResults
};
@@ -140,7 +140,7 @@ describe('SearchFilterComponent', () => {
describe('when isCollapsed is called and the filter is collapsed', () => {
let isActive: Observable<boolean>;
beforeEach(() => {
filterService.isCollapsed = () => Observable.of(true);
filterService.isCollapsed = () => observableOf(true);
isActive = comp.isCollapsed();
});
@@ -155,7 +155,7 @@ describe('SearchFilterComponent', () => {
describe('when isCollapsed is called and the filter is not collapsed', () => {
let isActive: Observable<boolean>;
beforeEach(() => {
filterService.isCollapsed = () => Observable.of(false);
filterService.isCollapsed = () => observableOf(false);
isActive = comp.isCollapsed();
});

View File

@@ -1,16 +1,20 @@
import { Observable } from 'rxjs';
import { SearchFilterService } from './search-filter.service';
import { Store } from '@ngrx/store';
import {
SearchFilterCollapseAction, SearchFilterDecrementPageAction, SearchFilterExpandAction,
SearchFilterCollapseAction,
SearchFilterDecrementPageAction,
SearchFilterExpandAction,
SearchFilterIncrementPageAction,
SearchFilterInitialCollapseAction, SearchFilterInitialExpandAction, SearchFilterResetPageAction,
SearchFilterInitialCollapseAction,
SearchFilterInitialExpandAction,
SearchFilterResetPageAction,
SearchFilterToggleAction
} from './search-filter.actions';
import { SearchFiltersState } from './search-filter.reducer';
import { SearchFilterConfig } from '../../search-service/search-filter-config.model';
import { FilterType } from '../../search-service/filter-type.model';
import { ActivatedRouteStub } from '../../../shared/testing/active-router-stub';
import { of as observableOf } from 'rxjs';
describe('SearchFilterService', () => {
let service: SearchFilterService;
@@ -28,7 +32,7 @@ describe('SearchFilterService', () => {
/* tslint:disable:no-empty */
dispatch: {},
/* tslint:enable:no-empty */
select: Observable.of(true)
select: observableOf(true)
});
const routeServiceStub: any = {
@@ -42,10 +46,10 @@ describe('SearchFilterService', () => {
addQueryParameterValue: (param: string, value: string) => {
},
getQueryParameterValues: (param: string) => {
return Observable.of({});
return observableOf({});
},
getQueryParamsWithPrefix: (param: string) => {
return Observable.of({});
return observableOf({});
}
/* tslint:enable:no-empty */
};

View File

@@ -1,6 +1,6 @@
import { combineLatest as observableCombineLatest, Observable } from 'rxjs';
import { Injectable, InjectionToken } from '@angular/core';
import { distinctUntilChanged, map } from 'rxjs/operators';
import { map } from 'rxjs/operators';
import { SearchFiltersState, SearchFilterState } from './search-filter.reducer';
import { createSelector, MemoizedSelector, select, Store } from '@ngrx/store';
import {
@@ -13,14 +13,10 @@ import {
SearchFilterResetPageAction,
SearchFilterToggleAction
} from './search-filter.actions';
import { hasValue, isEmpty, isNotEmpty, } from '../../../shared/empty.util';
import { hasValue, isNotEmpty, } from '../../../shared/empty.util';
import { SearchFilterConfig } from '../../search-service/search-filter-config.model';
import { RouteService } from '../../../shared/services/route.service';
import { SortDirection, SortOptions } from '../../../core/cache/models/sort-options.model';
import { PaginationComponentOptions } from '../../../shared/pagination/pagination-component-options.model';
import { SearchOptions } from '../../search-options.model';
import { PaginatedSearchOptions } from '../../paginated-search-options.model';
import { ActivatedRoute, Params } from '@angular/router';
import { Params } from '@angular/router';
const filterStateSelector = (state: SearchFiltersState) => state.searchFilter;
@@ -63,13 +59,19 @@ export class SearchFilterService {
*/
getSelectedValuesForFilter(filterConfig: SearchFilterConfig): Observable<string[]> {
const values$ = this.routeService.getQueryParameterValues(filterConfig.paramName);
const prefixValues$ = this.routeService.getQueryParamsWithPrefix(filterConfig.paramName + '.').pipe(map((params: Params) => [].concat(...Object.values(params))));
return observableCombineLatest(values$, prefixValues$, (values, prefixValues) => {
if (isNotEmpty(values)) {
return values;
}
return prefixValues;
})
const prefixValues$ = this.routeService.getQueryParamsWithPrefix(filterConfig.paramName + '.').pipe(
map((params: Params) => [].concat(...Object.values(params)))
);
return observableCombineLatest(values$, prefixValues$).pipe(
map(([values, prefixValues]) => {
if (isNotEmpty(values)) {
return values;
}
return prefixValues;
}
)
)
}
/**

View File

@@ -7,7 +7,7 @@ import { SearchFilterConfig } from '../../../search-service/search-filter-config
import { FilterType } from '../../../search-service/filter-type.model';
import { FacetValue } from '../../../search-service/facet-value.model';
import { FormsModule } from '@angular/forms';
import { Observable } from 'rxjs';
import { of as observableOf } from 'rxjs'
import { SearchService } from '../../../search-service/search.service';
import { SearchServiceStub } from '../../../../shared/testing/search-service-stub';
import { RemoteData } from '../../../../core/data/remote-data';
@@ -56,13 +56,13 @@ describe('SearchRangeFilterComponent', () => {
];
const searchLink = '/search';
const selectedValues = Observable.of([value1]);
const selectedValues = observableOf([value1]);
let filterService;
let searchService;
let router;
const page = Observable.of(0);
const page = observableOf(0);
const mockValues = Observable.of(new RemoteData(false, false, true, null, new PaginatedList(new PageInfo(), values)));
const mockValues = observableOf(new RemoteData(false, false, true, null, new PaginatedList(new PageInfo(), values)));
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [TranslateModule.forRoot(), NoopAnimationsModule, FormsModule],
@@ -71,10 +71,10 @@ describe('SearchRangeFilterComponent', () => {
{ provide: SearchService, useValue: new SearchServiceStub(searchLink) },
{ provide: Router, useValue: new RouterStub() },
{ provide: FILTER_CONFIG, useValue: mockFilterConfig },
{ provide: RemoteDataBuildService, useValue: {aggregate: () => Observable.of({})} },
{ provide: RouteService, useValue: {getQueryParameterValue: () => Observable.of({})} },
{ provide: RemoteDataBuildService, useValue: {aggregate: () => observableOf({})} },
{ provide: RouteService, useValue: {getQueryParameterValue: () => observableOf({})} },
{ provide: SearchConfigurationService, useValue: {
searchOptions: Observable.of({}) }
searchOptions: observableOf({}) }
},
{
provide: SearchFilterService, useValue: {

View File

@@ -1,5 +1,10 @@
import {of as observableOf, combineLatest as observableCombineLatest, Observable , Subscription } from 'rxjs';
import {startWith} from 'rxjs/operators';
import {
of as observableOf,
combineLatest as observableCombineLatest,
Observable,
Subscription
} from 'rxjs';
import { map, startWith } from 'rxjs/operators';
import { isPlatformBrowser } from '@angular/common';
import { Component, Inject, OnDestroy, OnInit, PLATFORM_ID } from '@angular/core';
import { RemoteDataBuildService } from '../../../../core/cache/builders/remote-data-build.service';
@@ -82,11 +87,13 @@ export class SearchRangeFilterComponent extends SearchFacetFilterComponent imple
this.max = moment(this.filterConfig.maxValue, dateFormats).year() || this.max;
const iniMin = this.route.getQueryParameterValue(this.filterConfig.paramName + minSuffix).pipe(startWith(undefined));
const iniMax = this.route.getQueryParameterValue(this.filterConfig.paramName + maxSuffix).pipe(startWith(undefined));
this.sub = observableCombineLatest(iniMin, iniMax, (min, max) => {
const minimum = hasValue(min) ? min : this.min;
const maximum = hasValue(max) ? max : this.max;
return [minimum, maximum]
}).subscribe((minmax) => this.range = minmax);
this.sub = observableCombineLatest(iniMin, iniMax).pipe(
map(([min, max]) => {
const minimum = hasValue(min) ? min : this.min;
const maximum = hasValue(max) ? max : this.max;
return [minimum, maximum]
})
).subscribe((minmax) => this.range = minmax);
}
/**

View File

@@ -7,8 +7,8 @@ import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { SearchFilterService } from './search-filter/search-filter.service';
import { SearchFiltersComponent } from './search-filters.component';
import { SearchService } from '../search-service/search.service';
import { Observable } from 'rxjs';
import { SearchConfigurationService } from '../search-service/search-configuration.service';
import { of as observableOf } from 'rxjs';
describe('SearchFiltersComponent', () => {
let comp: SearchFiltersComponent;
@@ -17,7 +17,7 @@ describe('SearchFiltersComponent', () => {
const searchServiceStub = {
/* tslint:disable:no-empty */
getConfig: () =>
Observable.of({ hasSucceeded: true, payload: [] }),
observableOf({ hasSucceeded: true, payload: [] }),
getClearFiltersQueryParams: () => {
},
getSearchLink: () => {
@@ -31,7 +31,7 @@ describe('SearchFiltersComponent', () => {
};
const searchConfigServiceStub = jasmine.createSpyObj('SearchConfigurationService', {
getCurrentFrontendFilters: Observable.of({})
getCurrentFrontendFilters: observableOf({})
});
beforeEach(async(() => {

View File

@@ -6,7 +6,7 @@ import { SearchService } from '../search-service/search.service';
import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { SearchServiceStub } from '../../shared/testing/search-service-stub';
import { Observable } from 'rxjs';
import { Observable, of as observableOf } from 'rxjs';
import { Params } from '@angular/router';
import { ObjectKeysPipe } from '../../shared/utils/object-keys-pipe';
import { SearchConfigurationService } from '../search-service/search-configuration.service';
@@ -35,7 +35,7 @@ describe('SearchLabelsComponent', () => {
declarations: [SearchLabelsComponent, ObjectKeysPipe],
providers: [
{ provide: SearchService, useValue: new SearchServiceStub(searchLink) },
{ provide: SearchConfigurationService, useValue: {getCurrentFrontendFilters : () => Observable.of({})} }
{ provide: SearchConfigurationService, useValue: {getCurrentFrontendFilters : () => observableOf({})} }
],
schemas: [NO_ERRORS_SCHEMA]
}).overrideComponent(SearchLabelsComponent, {
@@ -47,7 +47,7 @@ describe('SearchLabelsComponent', () => {
fixture = TestBed.createComponent(SearchLabelsComponent);
comp = fixture.componentInstance;
searchService = (comp as any).searchService;
(comp as any).appliedFilters = Observable.of(mockFilters);
(comp as any).appliedFilters = observableOf(mockFilters);
fixture.detectChanges();
});

View File

@@ -5,8 +5,7 @@ import { RouterTestingModule } from '@angular/router/testing';
import { Store } from '@ngrx/store';
import { TranslateModule } from '@ngx-translate/core';
import { cold, hot } from 'jasmine-marbles';
import { Observable } from 'rxjs';
import 'rxjs/add/observable/of';
import { of as observableOf } from 'rxjs';
import { SortDirection, SortOptions } from '../core/cache/models/sort-options.model';
import { CommunityDataService } from '../core/data/community-data.service';
import { HostWindowService } from '../shared/host-window.service';
@@ -30,18 +29,18 @@ describe('SearchPageComponent', () => {
/* tslint:disable:no-empty */
dispatch: {},
/* tslint:enable:no-empty */
select: Observable.of(true)
select: observableOf(true)
});
const pagination: PaginationComponentOptions = new PaginationComponentOptions();
pagination.id = 'search-results-pagination';
pagination.currentPage = 1;
pagination.pageSize = 10;
const sort: SortOptions = new SortOptions('score', SortDirection.DESC);
const mockResults = Observable.of(new RemoteData(false, false, true, null, ['test', 'data']));
const mockResults = observableOf(new RemoteData(false, false, true, null, ['test', 'data']));
const searchServiceStub = jasmine.createSpyObj('SearchService', {
search: mockResults,
getSearchLink: '/search',
getScopes: Observable.of(['test-scope'])
getScopes: observableOf(['test-scope'])
});
const queryParam = 'test query';
const scopeParam = '7669c72a-3f2a-451f-a3b9-9210e7a4c02f';
@@ -52,15 +51,15 @@ describe('SearchPageComponent', () => {
sort
};
const activatedRouteStub = {
queryParams: Observable.of({
queryParams: observableOf({
query: queryParam,
scope: scopeParam
})
};
const sidebarService = {
isCollapsed: Observable.of(true),
collapse: () => this.isCollapsed = Observable.of(true),
expand: () => this.isCollapsed = Observable.of(false)
isCollapsed: observableOf(true),
collapse: () => this.isCollapsed = observableOf(true),
expand: () => this.isCollapsed = observableOf(false)
};
beforeEach(async(() => {
@@ -80,9 +79,9 @@ describe('SearchPageComponent', () => {
{
provide: HostWindowService, useValue: jasmine.createSpyObj('hostWindowService',
{
isXs: Observable.of(true),
isSm: Observable.of(false),
isXsOrSm: Observable.of(true)
isXs: observableOf(true),
isSm: observableOf(false),
isXsOrSm: observableOf(true)
})
},
{
@@ -98,7 +97,7 @@ describe('SearchPageComponent', () => {
paginatedSearchOptions: hot('a', {
a: paginatedSearchOptions
}),
getCurrentScope: (a) => Observable.of('test-id')
getCurrentScope: (a) => observableOf('test-id')
}
},
],
@@ -154,7 +153,7 @@ describe('SearchPageComponent', () => {
beforeEach(() => {
menu = fixture.debugElement.query(By.css('#search-sidebar-sm')).nativeElement;
comp.isSidebarCollapsed = () => Observable.of(true);
comp.isSidebarCollapsed = () => observableOf(true);
fixture.detectChanges();
});
@@ -169,7 +168,7 @@ describe('SearchPageComponent', () => {
beforeEach(() => {
menu = fixture.debugElement.query(By.css('#search-sidebar-sm')).nativeElement;
comp.isSidebarCollapsed = () => Observable.of(false);
comp.isSidebarCollapsed = () => observableOf(false);
fixture.detectChanges();
});

View File

@@ -3,8 +3,8 @@ import { ActivatedRouteStub } from '../../shared/testing/active-router-stub';
import { PaginationComponentOptions } from '../../shared/pagination/pagination-component-options.model';
import { SortDirection, SortOptions } from '../../core/cache/models/sort-options.model';
import { PaginatedSearchOptions } from '../paginated-search-options.model';
import { Observable } from 'rxjs';
import { SearchFilter } from '../search-filter.model';
import { of as observableOf } from 'rxjs';
describe('SearchConfigurationService', () => {
let service: SearchConfigurationService;
@@ -24,8 +24,8 @@ describe('SearchConfigurationService', () => {
const backendFilters = [new SearchFilter('f.author', ['another value']), new SearchFilter('f.date', ['[2013 TO 2018]'])];
const spy = jasmine.createSpyObj('RouteService', {
getQueryParameterValue: Observable.of(value1),
getQueryParamsWithPrefix: Observable.of(prefixFilter)
getQueryParameterValue: observableOf(value1),
getQueryParamsWithPrefix: observableOf(prefixFilter)
});
const activatedRoute: any = new ActivatedRouteStub();

View File

@@ -1,5 +1,12 @@
import {of as observableOf, merge as observableMerge, combineLatest as observableCombineLatest, Observable , BehaviorSubject , Subscription } from 'rxjs';
import {filter, map} from 'rxjs/operators';
import {
BehaviorSubject,
combineLatest as observableCombineLatest,
merge as observableMerge,
Observable,
of as observableOf,
Subscription
} from 'rxjs';
import { filter, map } from 'rxjs/operators';
import { SortDirection, SortOptions } from '../../core/cache/models/sort-options.model';
import { PaginationComponentOptions } from '../../shared/pagination/pagination-component-options.model';
import { SearchOptions } from '../search-options.model';
@@ -7,7 +14,7 @@ import { ActivatedRoute, Params } from '@angular/router';
import { PaginatedSearchOptions } from '../paginated-search-options.model';
import { Injectable, OnDestroy } from '@angular/core';
import { RouteService } from '../../shared/services/route.service';
import { hasNoValue, hasValue, isEmpty, isNotEmpty } from '../../shared/empty.util';
import { hasNoValue, hasValue, isNotEmpty } from '../../shared/empty.util';
import { RemoteData } from '../../core/data/remote-data';
import { getSucceededRemoteData } from '../../core/shared/operators';
import { SearchFilter } from '../search-filter.model';
@@ -115,12 +122,13 @@ export class SearchConfigurationService implements OnDestroy {
getCurrentPagination(defaultPagination: PaginationComponentOptions): Observable<PaginationComponentOptions> {
const page$ = this.routeService.getQueryParameterValue('page');
const size$ = this.routeService.getQueryParameterValue('pageSize');
return observableCombineLatest(page$, size$, (page, size) => {
return Object.assign(new PaginationComponentOptions(), defaultPagination, {
currentPage: page || defaultPagination.currentPage,
pageSize: size || defaultPagination.pageSize
});
});
return observableCombineLatest(page$, size$).pipe(map(([page, size]) => {
return Object.assign(new PaginationComponentOptions(), defaultPagination, {
currentPage: page || defaultPagination.currentPage,
pageSize: size || defaultPagination.pageSize
});
})
);
}
/**
@@ -129,7 +137,7 @@ export class SearchConfigurationService implements OnDestroy {
getCurrentSort(defaultSort: SortOptions): Observable<SortOptions> {
const sortDirection$ = this.routeService.getQueryParameterValue('sortDirection');
const sortField$ = this.routeService.getQueryParameterValue('sortField');
return observableCombineLatest(sortDirection$, sortField$, (sortDirection, sortField) => {
return observableCombineLatest(sortDirection$, sortField$).pipe(map(([sortDirection, sortField]) => {
// Dirty fix because sometimes the observable value is null somehow
sortField = this.route.snapshot.queryParamMap.get('sortField');
@@ -137,7 +145,8 @@ export class SearchConfigurationService implements OnDestroy {
const direction = SortDirection[sortDirection] || defaultSort.direction;
return new SortOptions(field, direction)
}
)
)
);
}
/**

View File

@@ -12,7 +12,7 @@ import { ResponseCacheService } from '../../core/cache/response-cache.service';
import { ActivatedRouteStub } from '../../shared/testing/active-router-stub';
import { RouterStub } from '../../shared/testing/router-stub';
import { HALEndpointService } from '../../core/shared/hal-endpoint.service';
import { Observable } from 'rxjs';
import { Observable, combineLatest as observableCombineLatest } from 'rxjs';
import { PaginatedSearchOptions } from '../paginated-search-options.model';
import { RemoteData } from '../../core/data/remote-data';
import { ResponseCacheEntry } from '../../core/cache/response-cache.reducer';
@@ -28,6 +28,8 @@ import { SearchFilterConfig } from './search-filter-config.model';
import { CommunityDataService } from '../../core/data/community-data.service';
import { ViewMode } from '../../core/shared/view-mode.model';
import { DSpaceObjectDataService } from '../../core/data/dspace-object-data.service';
import { of as observableOf } from 'rxjs';
import { map } from 'rxjs/operators';
@Component({ template: '' })
class DummyComponent {
@@ -56,8 +58,8 @@ describe('SearchService', () => {
{ provide: RequestService, useValue: getMockRequestService() },
{ provide: RemoteDataBuildService, useValue: {} },
{ provide: HALEndpointService, useValue: {} },
{ provide: CommunityDataService, useValue: {}},
{ provide: DSpaceObjectDataService, useValue: {}},
{ provide: CommunityDataService, useValue: {} },
{ provide: DSpaceObjectDataService, useValue: {} },
SearchService
],
});
@@ -85,13 +87,15 @@ describe('SearchService', () => {
const remoteDataBuildService = {
toRemoteDataObservable: (requestEntryObs: Observable<RequestEntry>, responseCacheObs: Observable<ResponseCacheEntry>, payloadObs: Observable<any>) => {
return Observable.combineLatest(requestEntryObs,
responseCacheObs, payloadObs, (req, res, pay) => {
return observableCombineLatest(requestEntryObs,
responseCacheObs, payloadObs).pipe(
map(([req, res, pay]) => {
return { req, res, pay };
});
})
);
},
aggregate: (input: Array<Observable<RemoteData<any>>>): Observable<RemoteData<any[]>> => {
return Observable.of(new RemoteData(false, false, true, null, []));
return observableOf(new RemoteData(false, false, true, null, []));
}
};
@@ -113,8 +117,8 @@ describe('SearchService', () => {
{ provide: RequestService, useValue: getMockRequestService() },
{ provide: RemoteDataBuildService, useValue: remoteDataBuildService },
{ provide: HALEndpointService, useValue: halService },
{ provide: CommunityDataService, useValue: {}},
{ provide: DSpaceObjectDataService, useValue: {}},
{ provide: CommunityDataService, useValue: {} },
{ provide: DSpaceObjectDataService, useValue: {} },
SearchService
],
});
@@ -160,8 +164,8 @@ describe('SearchService', () => {
const response = new SearchSuccessResponse(queryResponse, '200');
const responseEntry = Object.assign(new ResponseCacheEntry(), { response: response });
beforeEach(() => {
spyOn((searchService as any).halService, 'getEndpoint').and.returnValue(Observable.of(endPoint));
(searchService as any).responseCache.get.and.returnValue(Observable.of(responseEntry));
spyOn((searchService as any).halService, 'getEndpoint').and.returnValue(observableOf(endPoint));
(searchService as any).responseCache.get.and.returnValue(observableOf(responseEntry));
/* tslint:disable:no-empty */
searchService.search(searchOptions).subscribe((t) => {
}); // subscribe to make sure all methods are called
@@ -190,8 +194,8 @@ describe('SearchService', () => {
const response = new FacetConfigSuccessResponse(filterConfig, '200');
const responseEntry = Object.assign(new ResponseCacheEntry(), { response: response });
beforeEach(() => {
spyOn((searchService as any).halService, 'getEndpoint').and.returnValue(Observable.of(endPoint));
(searchService as any).responseCache.get.and.returnValue(Observable.of(responseEntry));
spyOn((searchService as any).halService, 'getEndpoint').and.returnValue(observableOf(endPoint));
(searchService as any).responseCache.get.and.returnValue(observableOf(responseEntry));
/* tslint:disable:no-empty */
searchService.getConfig(null).subscribe((t) => {
}); // subscribe to make sure all methods are called
@@ -222,8 +226,8 @@ describe('SearchService', () => {
const response = new FacetConfigSuccessResponse(filterConfig, '200');
const responseEntry = Object.assign(new ResponseCacheEntry(), { response: response });
beforeEach(() => {
spyOn((searchService as any).halService, 'getEndpoint').and.returnValue(Observable.of(endPoint));
(searchService as any).responseCache.get.and.returnValue(Observable.of(responseEntry));
spyOn((searchService as any).halService, 'getEndpoint').and.returnValue(observableOf(endPoint));
(searchService as any).responseCache.get.and.returnValue(observableOf(responseEntry));
/* tslint:disable:no-empty */
searchService.getConfig(scope).subscribe((t) => {
}); // subscribe to make sure all methods are called

View File

@@ -1,4 +1,4 @@
import {of as observableOf, combineLatest as observableCombineLatest, Observable } from 'rxjs';
import { of as observableOf, combineLatest as observableCombineLatest, Observable } from 'rxjs';
import { Injectable, OnDestroy } from '@angular/core';
import {
ActivatedRoute,
@@ -122,30 +122,33 @@ export class SearchService implements OnDestroy {
);
// Create search results again with the correct dso objects linked to each result
const tDomainListObs = observableCombineLatest(sqrObs, dsoObs, (sqr: SearchQueryResponse, dsos: RemoteData<DSpaceObject[]>) => {
return sqr.objects.map((object: NormalizedSearchResult, index: number) => {
let co = DSpaceObject;
if (dsos.payload[index]) {
const constructor: GenericConstructor<ListableObject> = dsos.payload[index].constructor as GenericConstructor<ListableObject>;
co = getSearchResultFor(constructor);
return Object.assign(new co(), object, {
dspaceObject: dsos.payload[index]
});
} else {
return undefined;
}
});
});
const tDomainListObs = observableCombineLatest(sqrObs, dsoObs).pipe(
map(([sqr, dsos]) => {
return sqr.objects.map((object: NormalizedSearchResult, index: number) => {
let co = DSpaceObject;
if (dsos.payload[index]) {
const constructor: GenericConstructor<ListableObject> = dsos.payload[index].constructor as GenericConstructor<ListableObject>;
co = getSearchResultFor(constructor);
return Object.assign(new co(), object, {
dspaceObject: dsos.payload[index]
});
} else {
return undefined;
}
});
})
);
const pageInfoObs: Observable<PageInfo> = responseCacheObs.pipe(
map((entry: ResponseCacheEntry) => entry.response),
map((response: FacetValueSuccessResponse) => response.pageInfo)
);
const payloadObs = observableCombineLatest(tDomainListObs, pageInfoObs, (tDomainList, pageInfo) => {
return new PaginatedList(pageInfo, tDomainList);
});
const payloadObs = observableCombineLatest(tDomainListObs, pageInfoObs).pipe(
map(([tDomainList, pageInfo]) => {
return new PaginatedList(pageInfo, tDomainList);
})
);
return this.rdb.toRemoteDataObservable(requestEntryObs, responseCacheObs, payloadObs);
}
@@ -244,9 +247,11 @@ export class SearchService implements OnDestroy {
map((response: FacetValueSuccessResponse) => response.pageInfo)
);
const payloadObs = observableCombineLatest(facetValueObs, pageInfoObs, (facetValue, pageInfo) => {
return new PaginatedList(pageInfo, facetValue);
});
const payloadObs = observableCombineLatest(facetValueObs, pageInfoObs).pipe(
map(([facetValue, pageInfo]) => {
return new PaginatedList(pageInfo, facetValue);
})
);
return this.rdb.toRemoteDataObservable(requestEntryObs, responseCacheObs, payloadObs);
}
@@ -272,10 +277,12 @@ export class SearchService implements OnDestroy {
switchMap((dsoRD: RemoteData<DSpaceObject>) => {
if (dsoRD.payload.type === ResourceType.Community) {
const community: Community = dsoRD.payload as Community;
return observableCombineLatest(community.subcommunities, community.collections, (subCommunities, collections) => {
/*if this is a community, we also need to show the direct children*/
return [community, ...subCommunities.payload.page, ...collections.payload.page]
})
return observableCombineLatest(community.subcommunities, community.collections).pipe(
map(([subCommunities, collections]) => {
/*if this is a community, we also need to show the direct children*/
return [community, ...subCommunities.payload.page, ...collections.payload.page]
})
);
} else {
return observableOf([dsoRD.payload]);
}

View File

@@ -1,7 +1,7 @@
import { SearchService } from '../search-service/search.service';
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { SearchSettingsComponent } from './search-settings.component';
import { Observable } from 'rxjs';
import { of as observableOf } from 'rxjs';
import { PaginationComponentOptions } from '../../shared/pagination/pagination-component-options.model';
import { SortDirection, SortOptions } from '../../core/cache/models/sort-options.model';
import { TranslateModule } from '@ngx-translate/core';
@@ -15,6 +15,7 @@ import { SearchFilterService } from '../search-filters/search-filter/search-filt
import { hot } from 'jasmine-marbles';
import { VarDirective } from '../../shared/utils/var.directive';
import { SearchConfigurationService } from '../search-service/search-configuration.service';
import { first } from 'rxjs/operators';
describe('SearchSettingsComponent', () => {
@@ -43,16 +44,16 @@ describe('SearchSettingsComponent', () => {
};
const activatedRouteStub = {
queryParams: Observable.of({
queryParams: observableOf({
query: queryParam,
scope: scopeParam
})
};
const sidebarService = {
isCollapsed: Observable.of(true),
collapse: () => this.isCollapsed = Observable.of(true),
expand: () => this.isCollapsed = Observable.of(false)
isCollapsed: observableOf(true),
collapse: () => this.isCollapsed = observableOf(true),
expand: () => this.isCollapsed = observableOf(false)
};
beforeEach(async(() => {
@@ -101,7 +102,7 @@ describe('SearchSettingsComponent', () => {
});
it('it should show the order settings with the respective selectable options', () => {
(comp as any).searchOptions$.first().subscribe((options) => {
(comp as any).searchOptions$.pipe(first()).subscribe((options) => {
fixture.detectChanges();
const orderSetting = fixture.debugElement.query(By.css('div.result-order-settings'));
expect(orderSetting).toBeDefined();
@@ -111,7 +112,7 @@ describe('SearchSettingsComponent', () => {
});
it('it should show the size settings with the respective selectable options', () => {
(comp as any).searchOptions$.first().subscribe((options) => {
(comp as any).searchOptions$.pipe(first()).subscribe((options) => {
fixture.detectChanges();
const pageSizeSetting = fixture.debugElement.query(By.css('div.page-size-settings'));
expect(pageSizeSetting).toBeDefined();
@@ -122,7 +123,7 @@ describe('SearchSettingsComponent', () => {
});
it('should have the proper order value selected by default', () => {
(comp as any).searchOptions$.first().subscribe((options) => {
(comp as any).searchOptions$.pipe(first()).subscribe((options) => {
fixture.detectChanges();
const orderSetting = fixture.debugElement.query(By.css('div.result-order-settings'));
const childElementToBeSelected = orderSetting.query(By.css('.form-control option[value="0"][selected="selected"]'));
@@ -131,7 +132,7 @@ describe('SearchSettingsComponent', () => {
});
it('should have the proper rpp value selected by default', () => {
(comp as any).searchOptions$.first().subscribe((options) => {
(comp as any).searchOptions$.pipe(first()).subscribe((options) => {
fixture.detectChanges();
const pageSizeSetting = fixture.debugElement.query(By.css('div.page-size-settings'));
const childElementToBeSelected = pageSizeSetting.query(By.css('.form-control option[value="10"][selected="selected"]'));

View File

@@ -3,7 +3,6 @@ import { SearchService } from '../search-service/search.service';
import { SortDirection, SortOptions } from '../../core/cache/models/sort-options.model';
import { ActivatedRoute, NavigationExtras, Router } from '@angular/router';
import { PaginatedSearchOptions } from '../paginated-search-options.model';
import { SearchFilterService } from '../search-filters/search-filter/search-filter.service';
import { Observable } from 'rxjs';
import { SearchConfigurationService } from '../search-service/search-configuration.service';

View File

@@ -1,8 +1,8 @@
import { Store } from '@ngrx/store';
import { SearchSidebarService } from './search-sidebar.service';
import { AppState } from '../../app.reducer';
import { async, inject, TestBed } from '@angular/core/testing';
import { Observable } from 'rxjs';
import { async, TestBed } from '@angular/core/testing';
import { of as observableOf } from 'rxjs';
import 'rxjs/add/observable/of';
import { SearchSidebarCollapseAction, SearchSidebarExpandAction } from './search-sidebar.actions';
import { HostWindowService } from '../../shared/host-window.service';
@@ -13,13 +13,13 @@ describe('SearchSidebarService', () => {
/* tslint:disable:no-empty */
dispatch: {},
/* tslint:enable:no-empty */
select: Observable.of(true)
select: observableOf(true)
});
const windowService = jasmine.createSpyObj('hostWindowService',
{
isXs: Observable.of(true),
isSm: Observable.of(false),
isXsOrSm: Observable.of(true)
isXs: observableOf(true),
isSm: observableOf(false),
isXsOrSm: observableOf(true)
});
beforeEach(async(() => {
TestBed.configureTestingModule({

View File

@@ -5,6 +5,7 @@ import { createSelector, select, Store } from '@ngrx/store';
import { SearchSidebarCollapseAction, SearchSidebarExpandAction } from './search-sidebar.actions';
import { AppState } from '../../app.reducer';
import { HostWindowService } from '../../shared/host-window.service';
import { map } from 'rxjs/operators';
const sidebarStateSelector = (state: AppState) => state.searchSidebar;
const sidebarCollapsedSelector = createSelector(sidebarStateSelector, (sidebar: SearchSidebarState) => sidebar.sidebarCollapsed);
@@ -36,8 +37,10 @@ export class SearchSidebarService {
get isCollapsed(): Observable<boolean> {
return observableCombineLatest(
this.isXsOrSm$,
this.isCollapsedInStore,
(mobile, store) => mobile ? store : true);
this.isCollapsedInStore
).pipe(
map(([mobile, store]) => mobile ? store : true)
);
}
/**

View File

@@ -92,7 +92,7 @@ describe('App component', () => {
let store: Store<HostWindowState>;
beforeEach(() => {
store = fixture.debugElement.injector.get(Store);
store = fixture.debugElement.injector.get(Store) as Store<HostWindowState>;
spyOn(store, 'dispatch');
window.dispatchEvent(new Event('resize'));

View File

@@ -5,7 +5,7 @@ import { Store } from '@ngrx/store';
import { cold, hot } from 'jasmine-marbles';
import { Observable } from 'rxjs';
import 'rxjs/add/observable/of'
import { of as observableOf } from 'rxjs';
import { AuthEffects } from './auth.effects';
import {
@@ -36,7 +36,7 @@ describe('AuthEffects', () => {
/* tslint:disable:no-empty */
dispatch: {},
/* tslint:enable:no-empty */
select: Observable.of(true)
select: observableOf(true)
});
const token = authServiceStub.getToken();

View File

@@ -4,7 +4,7 @@ import { HTTP_INTERCEPTORS } from '@angular/common/http';
import { Router } from '@angular/router';
import { Store } from '@ngrx/store';
import { Observable } from 'rxjs';
import { of as observableOf } from 'rxjs';
import { AuthInterceptor } from './auth.interceptor';
import { AuthService } from './auth.service';
@@ -23,7 +23,7 @@ describe(`AuthInterceptor`, () => {
/* tslint:disable:no-empty */
dispatch: {},
/* tslint:enable:no-empty */
select: Observable.of(true)
select: observableOf(true)
});
beforeEach(() => {

View File

@@ -3,9 +3,9 @@ import { CommonModule } from '@angular/common';
import { ActivatedRoute, Router } from '@angular/router';
import { Store, StoreModule } from '@ngrx/store';
import { Observable } from 'rxjs';
import { REQUEST } from '@nguniversal/express-engine/tokens';
import 'rxjs/add/observable/of';
import { of as observableOf } from 'rxjs';
import { authReducer, AuthState } from './auth.reducer';
import { NativeWindowRef, NativeWindowService } from '../../shared/services/window.service';
@@ -27,7 +27,7 @@ describe('AuthService test', () => {
const mockStore: Store<AuthState> = jasmine.createSpyObj('store', {
dispatch: {},
select: Observable.of(true)
select: observableOf(true)
});
let authService: AuthService;
const authRequest = new AuthRequestServiceStub();

View File

@@ -1,5 +1,5 @@
import { cold, getTestScheduler, hot } from 'jasmine-marbles';
import { TestScheduler } from 'rxjs';
import { TestScheduler } from 'rxjs/testing';
import { getMockRemoteDataBuildService } from '../../shared/mocks/mock-remote-data-build.service';
import { getMockRequestService } from '../../shared/mocks/mock-request.service';
import { getMockResponseCacheService } from '../../shared/mocks/mock-response-cache.service';

View File

@@ -1,5 +1,9 @@
import {combineLatest as observableCombineLatest, of as observableOf, Observable, race as observableRace } from 'rxjs';
import {
combineLatest as observableCombineLatest,
of as observableOf,
Observable,
race as observableRace
} from 'rxjs';
import { Injectable } from '@angular/core';
import { distinctUntilChanged, flatMap, map, startWith } from 'rxjs/operators';
import { hasValue, hasValueOperator, isEmpty, isNotEmpty } from '../../../shared/empty.util';
@@ -66,15 +70,15 @@ export class RemoteDataBuildService {
}),
distinctUntilChanged(),
startWith(undefined)
),
(fromSelfLink, fromResponse) => {
)
).pipe(
map(([fromSelfLink, fromResponse]) => {
if (hasValue(fromSelfLink)) {
return fromSelfLink;
} else {
return fromResponse;
}
}
).pipe(
}),
hasValueOperator(),
map((normalized: TNormalized) => {
return this.build<TNormalized, TDomain>(normalized);
@@ -86,8 +90,8 @@ export class RemoteDataBuildService {
}
toRemoteDataObservable<T>(requestEntry$: Observable<RequestEntry>, responseCache$: Observable<ResponseCacheEntry>, payload$: Observable<T>) {
return observableCombineLatest(requestEntry$, responseCache$.pipe(startWith(undefined)), payload$,
(reqEntry: RequestEntry, resEntry: ResponseCacheEntry, payload: T) => {
return observableCombineLatest(requestEntry$, responseCache$.pipe(startWith(undefined)), payload$).pipe(
map(([reqEntry, resEntry, payload]) => {
const requestPending = hasValue(reqEntry.requestPending) ? reqEntry.requestPending : true;
const responsePending = hasValue(reqEntry.responsePending) ? reqEntry.responsePending : false;
let isSuccessful: boolean;
@@ -106,7 +110,8 @@ export class RemoteDataBuildService {
error,
payload
);
});
})
);
}
buildList<TNormalized extends NormalizedObject, TDomain>(href$: string | Observable<string>): Observable<RemoteData<PaginatedList<TDomain>>> {
@@ -143,11 +148,13 @@ export class RemoteDataBuildService {
}
}
})
);
);
const payload$ = observableCombineLatest(tDomainList$, pageInfo$, (tDomainList, pageInfo) => {
return new PaginatedList(pageInfo, tDomainList);
});
const payload$ = observableCombineLatest(tDomainList$, pageInfo$).pipe(
map(([tDomainList, pageInfo]) => {
return new PaginatedList(pageInfo, tDomainList);
})
);
return this.toRemoteDataObservable(requestEntry$, responseCache$, payload$);
}
@@ -208,9 +215,8 @@ export class RemoteDataBuildService {
return observableOf(new RemoteData(false, false, true, null, []));
}
return observableCombineLatest(
...input,
(...arr: Array<RemoteData<T>>) => {
return observableCombineLatest(...input).pipe(
map((arr) => {
const requestPending: boolean = arr
.map((d: RemoteData<T>) => d.isRequestPending)
.every((b: boolean) => b === true);
@@ -252,11 +258,11 @@ export class RemoteDataBuildService {
error,
payload
);
})
}))
}
aggregatePaginatedList<T>(input: Observable<RemoteData<T[]>>, pageInfo: PageInfo): Observable<RemoteData<PaginatedList<T>>> {
return input.pipe(map((rd) => Object.assign(rd, {payload: new PaginatedList(pageInfo, rd.payload)})));
return input.pipe(map((rd) => Object.assign(rd, { payload: new PaginatedList(pageInfo, rd.payload) })));
}
}

View File

@@ -1,11 +1,12 @@
import { Store } from '@ngrx/store';
import { Observable } from 'rxjs';
import { of as observableOf } from 'rxjs';
import { ObjectCacheService } from './object-cache.service';
import { AddToObjectCacheAction, RemoveFromObjectCacheAction } from './object-cache.actions';
import { CoreState } from '../core.reducers';
import { ResourceType } from '../shared/resource-type';
import { NormalizedItem } from './models/normalized-item.model';
import { first } from 'rxjs/operators';
describe('ObjectCacheService', () => {
let service: ObjectCacheService;
@@ -51,10 +52,10 @@ describe('ObjectCacheService', () => {
describe('getBySelfLink', () => {
it('should return an observable of the cached object with the specified self link and type', () => {
spyOn(store, 'select').and.returnValue(Observable.of(cacheEntry));
spyOn(store, 'select').and.returnValue(observableOf(cacheEntry));
// due to the implementation of spyOn above, this subscribe will be synchronous
service.getBySelfLink(selfLink).take(1).subscribe((o) => {
service.getBySelfLink(selfLink).pipe(first()).subscribe((o) => {
expect(o.self).toBe(selfLink);
// this only works if testObj is an instance of TestClass
expect(o instanceof NormalizedItem).toBeTruthy();
@@ -63,7 +64,7 @@ describe('ObjectCacheService', () => {
});
it('should not return a cached object that has exceeded its time to live', () => {
spyOn(store, 'select').and.returnValue(Observable.of(invalidCacheEntry));
spyOn(store, 'select').and.returnValue(observableOf(invalidCacheEntry));
let getObsHasFired = false;
const subscription = service.getBySelfLink(selfLink).subscribe((o) => getObsHasFired = true);
@@ -76,9 +77,9 @@ describe('ObjectCacheService', () => {
it('should return an observable of the array of cached objects with the specified self link and type', () => {
const item = new NormalizedItem();
item.self = selfLink;
spyOn(service, 'getBySelfLink').and.returnValue(Observable.of(item));
spyOn(service, 'getBySelfLink').and.returnValue(observableOf(item));
service.getList([selfLink, selfLink]).take(1).subscribe((arr) => {
service.getList([selfLink, selfLink]).pipe(first()).subscribe((arr) => {
expect(arr[0].self).toBe(selfLink);
expect(arr[0] instanceof NormalizedItem).toBeTruthy();
});
@@ -87,19 +88,19 @@ describe('ObjectCacheService', () => {
describe('has', () => {
it('should return true if the object with the supplied self link is cached and still valid', () => {
spyOn(store, 'select').and.returnValue(Observable.of(cacheEntry));
spyOn(store, 'select').and.returnValue(observableOf(cacheEntry));
expect(service.hasBySelfLink(selfLink)).toBe(true);
});
it("should return false if the object with the supplied self link isn't cached", () => {
spyOn(store, 'select').and.returnValue(Observable.of(undefined));
spyOn(store, 'select').and.returnValue(observableOf(undefined));
expect(service.hasBySelfLink(selfLink)).toBe(false);
});
it('should return false if the object with the supplied self link is cached but has exceeded its time to live', () => {
spyOn(store, 'select').and.returnValue(Observable.of(invalidCacheEntry));
spyOn(store, 'select').and.returnValue(observableOf(invalidCacheEntry));
expect(service.hasBySelfLink(selfLink)).toBe(false);
});

View File

@@ -1,10 +1,11 @@
import { Store } from '@ngrx/store';
import { ResponseCacheService } from './response-cache.service';
import { Observable } from 'rxjs';
import { of as observableOf } from 'rxjs';
import { CoreState } from '../core.reducers';
import { RestResponse } from './response-cache.models';
import { ResponseCacheEntry } from './response-cache.reducer';
import { first } from 'rxjs/operators';
describe('ResponseCacheService', () => {
let service: ResponseCacheService;
@@ -41,11 +42,11 @@ describe('ResponseCacheService', () => {
describe('get', () => {
it('should return an observable of the cached request with the specified key', () => {
spyOn(store, 'select').and.callFake((...args: any[]) => {
return Observable.of(validCacheEntry(keys[1]));
return observableOf(validCacheEntry(keys[1]));
});
let testObj: ResponseCacheEntry;
service.get(keys[1]).first().subscribe((entry) => {
service.get(keys[1]).pipe(first()).subscribe((entry) => {
testObj = entry;
});
expect(testObj.key).toEqual(keys[1]);
@@ -53,7 +54,7 @@ describe('ResponseCacheService', () => {
it('should not return a cached request that has exceeded its time to live', () => {
spyOn(store, 'select').and.callFake((...args: any[]) => {
return Observable.of(invalidCacheEntry(keys[1]));
return observableOf(invalidCacheEntry(keys[1]));
});
let getObsHasFired = false;
@@ -65,17 +66,17 @@ describe('ResponseCacheService', () => {
describe('has', () => {
it('should return true if the request with the supplied key is cached and still valid', () => {
spyOn(store, 'select').and.returnValue(Observable.of(validCacheEntry(keys[1])));
spyOn(store, 'select').and.returnValue(observableOf(validCacheEntry(keys[1])));
expect(service.has(keys[1])).toBe(true);
});
it('should return false if the request with the supplied key isn\'t cached', () => {
spyOn(store, 'select').and.returnValue(Observable.of(undefined));
spyOn(store, 'select').and.returnValue(observableOf(undefined));
expect(service.has(keys[1])).toBe(false);
});
it('should return false if the request with the supplied key is cached but has exceeded its time to live', () => {
spyOn(store, 'select').and.returnValue(Observable.of(invalidCacheEntry(keys[1])));
spyOn(store, 'select').and.returnValue(observableOf(invalidCacheEntry(keys[1])));
expect(service.has(keys[1])).toBe(false);
});
});

View File

@@ -1,5 +1,5 @@
import { cold, getTestScheduler, hot } from 'jasmine-marbles';
import { TestScheduler } from 'rxjs';
import { TestScheduler } from 'rxjs/testing';
import { getMockRequestService } from '../../shared/mocks/mock-request.service';
import { ResponseCacheService } from '../cache/response-cache.service';
import { ConfigService } from './config.service';

View File

@@ -1,10 +1,9 @@
import { Store } from '@ngrx/store';
import { cold, getTestScheduler, hot } from 'jasmine-marbles';
import { TestScheduler } from 'rxjs';
import { TestScheduler } from 'rxjs/testing';
import { GlobalConfig } from '../../../config';
import { getMockRequestService } from '../../shared/mocks/mock-request.service';
import { RemoteDataBuildService } from '../cache/builders/remote-data-build.service';
import { NormalizedCommunity } from '../cache/models/normalized-community.model';
import { ObjectCacheService } from '../cache/object-cache.service';
import { ResponseCacheService } from '../cache/response-cache.service';
import { CoreState } from '../core.reducers';

View File

@@ -1,5 +1,5 @@
import { cold, getTestScheduler } from 'jasmine-marbles';
import { TestScheduler } from '../../../../node_modules/rxjs';
import { TestScheduler } from 'rxjs/testing';
import { RemoteDataBuildService } from '../cache/builders/remote-data-build.service';
import { DSpaceObject } from '../shared/dspace-object.model';
import { HALEndpointService } from '../shared/hal-endpoint.service';

View File

@@ -1,6 +1,6 @@
import { Store } from '@ngrx/store';
import { cold, getTestScheduler } from 'jasmine-marbles';
import { TestScheduler } from 'rxjs';
import { TestScheduler } from 'rxjs/testing';
import { BrowseService } from '../browse/browse.service';
import { RemoteDataBuildService } from '../cache/builders/remote-data-build.service';
import { ResponseCacheService } from '../cache/response-cache.service';

View File

@@ -1,5 +1,5 @@
import { cold, getTestScheduler } from 'jasmine-marbles';
import { TestScheduler } from 'rxjs';
import { TestScheduler } from 'rxjs/testing';
import { getMockRequestService } from '../../shared/mocks/mock-request.service';
import { ResponseCacheService } from '../cache/response-cache.service';

View File

@@ -1,17 +1,15 @@
import { ComponentFixture, TestBed, async, fakeAsync, inject, tick } from '@angular/core/testing';
import { ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testing';
import { RouterTestingModule } from '@angular/router/testing';
import { Location, CommonModule } from '@angular/common';
import { CommonModule, Location } from '@angular/common';
import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { By, Meta, MetaDefinition, Title } from '@angular/platform-browser';
import { Meta, MetaDefinition, Title } from '@angular/platform-browser';
import { ActivatedRoute, Router } from '@angular/router';
import { TranslateModule, TranslateLoader } from '@ngx-translate/core';
import { TranslateLoader, TranslateModule } from '@ngx-translate/core';
import { Store, StoreModule } from '@ngrx/store';
import { Observable } from 'rxjs';
import { RemoteDataError } from '../data/remote-data-error';
import { Observable, of as observableOf } from 'rxjs';
import { UUIDService } from '../shared/uuid.service';
import { MetadataService } from './metadata.service';
@@ -182,7 +180,7 @@ describe('MetadataService', () => {
}));
const mockRemoteData = (mockItem: Item): Observable<RemoteData<Item>> => {
return Observable.of(new RemoteData<Item>(
return observableOf(new RemoteData<Item>(
false,
false,
true,

View File

@@ -1,4 +1,4 @@
import { async, TestBed } from '@angular/core/testing';
import { TestBed } from '@angular/core/testing';
import { RegistryService } from './registry.service';
import { CommonModule } from '@angular/common';
import { ResponseCacheService } from '../cache/response-cache.service';
@@ -6,26 +6,24 @@ import { RequestService } from '../data/request.service';
import { RemoteDataBuildService } from '../cache/builders/remote-data-build.service';
import { HALEndpointService } from '../shared/hal-endpoint.service';
import { PaginationComponentOptions } from '../../shared/pagination/pagination-component-options.model';
import { Observable } from 'rxjs';
import { Observable, of as observableOf, combineLatest as observableCombineLatest } from 'rxjs';
import { ResponseCacheEntry } from '../cache/response-cache.reducer';
import { RequestEntry } from '../data/request.reducer';
import { RemoteData } from '../data/remote-data';
import { PaginatedList } from '../data/paginated-list';
import { PageInfo } from '../shared/page-info.model';
import { GetRequest } from '../data/request.models';
import { URLCombiner } from '../url-combiner/url-combiner';
import { getMockRequestService } from '../../shared/mocks/mock-request.service';
import { getMockResponseCacheService } from '../../shared/mocks/mock-response-cache.service';
import {
RegistryBitstreamformatsSuccessResponse,
RegistryMetadatafieldsSuccessResponse, RegistryMetadataschemasSuccessResponse,
SearchSuccessResponse
RegistryMetadatafieldsSuccessResponse,
RegistryMetadataschemasSuccessResponse
} from '../cache/response-cache.models';
import { SearchQueryResponse } from '../../+search-page/search-service/search-query-response.model';
import { Component } from '@angular/core';
import { RegistryMetadataschemasResponse } from './registry-metadataschemas-response.model';
import { RegistryMetadatafieldsResponse } from './registry-metadatafields-response.model';
import { RegistryBitstreamformatsResponse } from './registry-bitstreamformats-response.model';
import { map } from 'rxjs/operators';
@Component({ template: '' })
class DummyComponent {
@@ -125,24 +123,25 @@ describe('RegistryService', () => {
const endpointWithParams = `${endpoint}?size=${pageInfo.elementsPerPage}&page=${pageInfo.currentPage - 1}`;
const halServiceStub = {
getEndpoint: (link: string) => Observable.of(endpoint)
getEndpoint: (link: string) => observableOf(endpoint)
};
const rdbStub = {
toRemoteDataObservable: (requestEntryObs: Observable<RequestEntry>, responseCacheObs: Observable<ResponseCacheEntry>, payloadObs: Observable<any>) => {
return Observable.combineLatest(requestEntryObs,
responseCacheObs, payloadObs, (req, res, pay) => {
return observableCombineLatest(requestEntryObs,
responseCacheObs, payloadObs).pipe(map(([req, res, pay]) => {
return { req, res, pay };
});
})
);
},
aggregate: (input: Array<Observable<RemoteData<any>>>): Observable<RemoteData<any[]>> => {
return Observable.of(new RemoteData(false, false, true, null, []));
return observableOf(new RemoteData(false, false, true, null, []));
}
};
beforeEach(() => {
TestBed.configureTestingModule({
imports: [ CommonModule ],
imports: [CommonModule],
declarations: [
DummyComponent
],
@@ -156,16 +155,19 @@ describe('RegistryService', () => {
});
registryService = TestBed.get(RegistryService);
spyOn((registryService as any).halService, 'getEndpoint').and.returnValue(Observable.of(endpoint));
spyOn((registryService as any).halService, 'getEndpoint').and.returnValue(observableOf(endpoint));
});
describe('when requesting metadataschemas', () => {
const queryResponse = Object.assign(new RegistryMetadataschemasResponse(), { metadataschemas: mockSchemasList, page: pageInfo });
const queryResponse = Object.assign(new RegistryMetadataschemasResponse(), {
metadataschemas: mockSchemasList,
page: pageInfo
});
const response = new RegistryMetadataschemasSuccessResponse(queryResponse, '200', pageInfo);
const responseEntry = Object.assign(new ResponseCacheEntry(), { response: response });
beforeEach(() => {
(registryService as any).responseCache.get.and.returnValue(Observable.of(responseEntry));
(registryService as any).responseCache.get.and.returnValue(observableOf(responseEntry));
/* tslint:disable:no-empty */
registryService.getMetadataSchemas(pagination).subscribe((value) => {
});
@@ -190,12 +192,15 @@ describe('RegistryService', () => {
});
describe('when requesting metadataschema by name', () => {
const queryResponse = Object.assign(new RegistryMetadataschemasResponse(), { metadataschemas: mockSchemasList, page: pageInfo });
const queryResponse = Object.assign(new RegistryMetadataschemasResponse(), {
metadataschemas: mockSchemasList,
page: pageInfo
});
const response = new RegistryMetadataschemasSuccessResponse(queryResponse, '200', pageInfo);
const responseEntry = Object.assign(new ResponseCacheEntry(), { response: response });
beforeEach(() => {
(registryService as any).responseCache.get.and.returnValue(Observable.of(responseEntry));
(registryService as any).responseCache.get.and.returnValue(observableOf(responseEntry));
/* tslint:disable:no-empty */
registryService.getMetadataSchemaByName(mockSchemasList[0].prefix).subscribe((value) => {
});
@@ -220,12 +225,15 @@ describe('RegistryService', () => {
});
describe('when requesting metadatafields', () => {
const queryResponse = Object.assign(new RegistryMetadatafieldsResponse(), { metadatafields: mockFieldsList, page: pageInfo });
const queryResponse = Object.assign(new RegistryMetadatafieldsResponse(), {
metadatafields: mockFieldsList,
page: pageInfo
});
const response = new RegistryMetadatafieldsSuccessResponse(queryResponse, '200', pageInfo);
const responseEntry = Object.assign(new ResponseCacheEntry(), { response: response });
beforeEach(() => {
(registryService as any).responseCache.get.and.returnValue(Observable.of(responseEntry));
(registryService as any).responseCache.get.and.returnValue(observableOf(responseEntry));
/* tslint:disable:no-empty */
registryService.getMetadataFieldsBySchema(mockSchemasList[0], pagination).subscribe((value) => {
});
@@ -250,12 +258,15 @@ describe('RegistryService', () => {
});
describe('when requesting bitstreamformats', () => {
const queryResponse = Object.assign(new RegistryBitstreamformatsResponse(), { bitstreamformats: mockFieldsList, page: pageInfo });
const queryResponse = Object.assign(new RegistryBitstreamformatsResponse(), {
bitstreamformats: mockFieldsList,
page: pageInfo
});
const response = new RegistryBitstreamformatsSuccessResponse(queryResponse, '200', pageInfo);
const responseEntry = Object.assign(new ResponseCacheEntry(), { response: response });
beforeEach(() => {
(registryService as any).responseCache.get.and.returnValue(Observable.of(responseEntry));
(registryService as any).responseCache.get.and.returnValue(observableOf(responseEntry));
/* tslint:disable:no-empty */
registryService.getBitstreamFormats(pagination).subscribe((value) => {
});

View File

@@ -1,5 +1,4 @@
import {combineLatest as observableCombineLatest, Observable } from 'rxjs';
import { combineLatest as observableCombineLatest, Observable } from 'rxjs';
import { Injectable } from '@angular/core';
import { RemoteData } from '../data/remote-data';
import { PaginatedList } from '../data/paginated-list';
@@ -18,7 +17,9 @@ import { ResponseCacheService } from '../cache/response-cache.service';
import { RegistryMetadataschemasResponse } from './registry-metadataschemas-response.model';
import { ResponseCacheEntry } from '../cache/response-cache.reducer';
import {
MetadataschemaSuccessResponse, RegistryBitstreamformatsSuccessResponse, RegistryMetadatafieldsSuccessResponse,
MetadataschemaSuccessResponse,
RegistryBitstreamformatsSuccessResponse,
RegistryMetadatafieldsSuccessResponse,
RegistryMetadataschemasSuccessResponse
} from '../cache/response-cache.models';
import { HALEndpointService } from '../shared/hal-endpoint.service';
@@ -71,9 +72,11 @@ export class RegistryService {
map((response: RegistryMetadataschemasSuccessResponse) => response.pageInfo)
);
const payloadObs = observableCombineLatest(metadataschemasObs, pageInfoObs, (metadataschemas, pageInfo) => {
return new PaginatedList(pageInfo, metadataschemas);
});
const payloadObs = observableCombineLatest(metadataschemasObs, pageInfoObs).pipe(
map(([metadataschemas, pageInfo]) => {
return new PaginatedList(pageInfo, metadataschemas);
})
);
return this.rdb.toRemoteDataObservable(requestEntryObs, responseCacheObs, payloadObs);
}
@@ -133,9 +136,11 @@ export class RegistryService {
map((response: RegistryMetadatafieldsSuccessResponse) => response.pageInfo)
);
const payloadObs = observableCombineLatest(metadatafieldsObs, pageInfoObs, (metadatafields, pageInfo) => {
return new PaginatedList(pageInfo, metadatafields);
});
const payloadObs = observableCombineLatest(metadatafieldsObs, pageInfoObs).pipe(
map(([metadatafields, pageInfo]) => {
return new PaginatedList(pageInfo, metadatafields);
})
);
return this.rdb.toRemoteDataObservable(requestEntryObs, responseCacheObs, payloadObs);
}
@@ -165,9 +170,11 @@ export class RegistryService {
map((response: RegistryBitstreamformatsSuccessResponse) => response.pageInfo)
);
const payloadObs = observableCombineLatest(bitstreamformatsObs, pageInfoObs, (bitstreamformats, pageInfo) => {
return new PaginatedList(pageInfo, bitstreamformats);
});
const payloadObs = observableCombineLatest(bitstreamformatsObs, pageInfoObs).pipe(
map(([bitstreamformats, pageInfo]) => {
return new PaginatedList(pageInfo, bitstreamformats);
})
);
return this.rdb.toRemoteDataObservable(requestEntryObs, responseCacheObs, payloadObs);
}

View File

@@ -1,10 +1,10 @@
import { Observable } from 'rxjs';
import { Observable, of as observableOf } from 'rxjs';
import { Item } from './item.model';
import { RemoteData } from '../data/remote-data';
import { Bitstream } from './bitstream.model';
import { isEmpty } from '../../shared/empty.util';
import { PageInfo } from './page-info.model';
import { first, map } from 'rxjs/operators';
describe('Item', () => {
@@ -56,30 +56,30 @@ describe('Item', () => {
it('should return the bitstreams related to this item with the specified bundle name', () => {
const bitObs: Observable<Bitstream[]> = item.getBitstreamsByBundleName(thumbnailBundleName);
bitObs.take(1).subscribe((bs) =>
bitObs.pipe(first()).subscribe((bs) =>
expect(bs.every((b) => b.name === thumbnailBundleName)).toBeTruthy());
});
it('should return an empty array when no bitstreams with this bundleName exist for this item', () => {
const bs: Observable<Bitstream[]> = item.getBitstreamsByBundleName(nonExistingBundleName);
bs.take(1).subscribe((b) => expect(isEmpty(b)).toBeTruthy());
bs.pipe(first()).subscribe((b) => expect(isEmpty(b)).toBeTruthy());
});
describe('get thumbnail', () => {
beforeEach(() => {
spyOn(item, 'getBitstreamsByBundleName').and.returnValue(Observable.of([remoteDataThumbnail]));
spyOn(item, 'getBitstreamsByBundleName').and.returnValue(observableOf([remoteDataThumbnail]));
});
it('should return the thumbnail of this item', () => {
const path: string = thumbnailPath;
const bitstream: Observable<Bitstream> = item.getThumbnail();
bitstream.map((b) => expect(b.content).toBe(path));
bitstream.pipe(map((b) => expect(b.content).toBe(path)));
});
});
describe('get files', () => {
beforeEach(() => {
spyOn(item, 'getBitstreamsByBundleName').and.returnValue(Observable.of(bitstreams));
spyOn(item, 'getBitstreamsByBundleName').and.returnValue(observableOf(bitstreams));
});
it("should return all bitstreams with 'ORIGINAL' as bundleName", () => {
@@ -87,7 +87,7 @@ describe('Item', () => {
const files: Observable<Bitstream[]> = item.getFiles();
let index = 0;
files.map((f) => expect(f.length).toBe(2));
files.pipe(map((f) => expect(f.length).toBe(2)));
files.subscribe(
(array) => array.forEach(
(file) => {
@@ -103,7 +103,7 @@ describe('Item', () => {
});
function createRemoteDataObject(object: any) {
return Observable.of(new RemoteData(
return observableOf(new RemoteData(
false,
false,
true,

View File

@@ -1,5 +1,5 @@
import { cold, getTestScheduler, hot } from 'jasmine-marbles';
import { TestScheduler } from '../../../../node_modules/rxjs';
import { TestScheduler } from 'rxjs/testing';
import { getMockRequestService } from '../../shared/mocks/mock-request.service';
import { getMockResponseCacheService } from '../../shared/mocks/mock-response-cache.service';
import { ResponseCacheEntry } from '../cache/response-cache.reducer';

View File

@@ -1,10 +1,10 @@
import { ComponentFixture, TestBed, async } from '@angular/core/testing';
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { By } from '@angular/platform-browser';
import { Store, StoreModule } from '@ngrx/store';
import { TranslateModule } from '@ngx-translate/core';
import { NgbCollapseModule } from '@ng-bootstrap/ng-bootstrap';
import { Observable } from 'rxjs';
import { of as observableOf } from 'rxjs';
import { HeaderComponent } from './header.component';
import { HeaderState } from './header.reducer';
@@ -50,7 +50,7 @@ describe('HeaderComponent', () => {
comp = fixture.componentInstance;
store = fixture.debugElement.injector.get(Store);
store = fixture.debugElement.injector.get(Store) as Store<HeaderState>;
spyOn(store, 'dispatch');
});
@@ -72,7 +72,7 @@ describe('HeaderComponent', () => {
beforeEach(() => {
menu = fixture.debugElement.query(By.css('#collapsingNav')).nativeElement;
spyOn(store, 'select').and.returnValue(Observable.of({ navCollapsed: true }));
spyOn(store, 'select').and.returnValue(observableOf({ navCollapsed: true }));
fixture.detectChanges();
});
@@ -87,7 +87,7 @@ describe('HeaderComponent', () => {
beforeEach(() => {
menu = fixture.debugElement.query(By.css('#collapsingNav')).nativeElement;
spyOn(store, 'select').and.returnValue(Observable.of(false));
spyOn(store, 'select').and.returnValue(observableOf(false));
fixture.detectChanges();
});

View File

@@ -149,7 +149,7 @@ describe('DsDynamicFormControlComponent test suite', () => {
expect(component.change).toBeDefined();
expect(component.focus).toBeDefined();
expect(component.onValueChange).toBeDefined();
expect(component.onChange).toBeDefined();
expect(component.onBlur).toBeDefined();
expect(component.onFocus).toBeDefined();
@@ -185,11 +185,11 @@ describe('DsDynamicFormControlComponent test suite', () => {
it('should listen to native change event', () => {
spyOn(component, 'onValueChange');
spyOn(component, 'onChange');
testElement.triggerEventHandler('change', null);
expect(component.onValueChange).toHaveBeenCalled();
expect(component.onChange).toHaveBeenCalled();
});
it('should update model value when control value changes', () => {

View File

@@ -1,6 +1,5 @@
import {
Component,
ComponentFactoryResolver,
Component, ComponentFactoryResolver,
ContentChildren,
EventEmitter,
Input,
@@ -21,7 +20,7 @@ import {
DYNAMIC_FORM_CONTROL_TYPE_SELECT,
DYNAMIC_FORM_CONTROL_TYPE_TEXTAREA,
DYNAMIC_FORM_CONTROL_TYPE_TIMEPICKER,
DynamicDatePickerModel, DynamicFormControl,
DynamicDatePickerModel, DynamicFormControl, DynamicFormControlComponent,
DynamicFormControlContainerComponent,
DynamicFormControlEvent,
DynamicFormControlModel,
@@ -38,6 +37,7 @@ import { DYNAMIC_FORM_CONTROL_TYPE_DSDATEPICKER } from './models/date-picker/dat
import { DYNAMIC_FORM_CONTROL_TYPE_LOOKUP } from './models/lookup/dynamic-lookup.model';
import { DynamicListCheckboxGroupModel } from './models/list/dynamic-list-checkbox-group.model';
import { DynamicListRadioGroupModel } from './models/list/dynamic-list-radio-group.model';
import { isNotEmpty } from '../../../empty.util';
import { DYNAMIC_FORM_CONTROL_TYPE_LOOKUP_NAME } from './models/lookup/dynamic-lookup-name.model';
export const enum NGBootstrapFormControlType {
@@ -89,9 +89,10 @@ export class DsDynamicFormControlComponent extends DynamicFormControlContainerCo
@Output('dfFocus') focus: EventEmitter<DynamicFormControlEvent> = new EventEmitter<DynamicFormControlEvent>();
/* tslint:enable:no-output-rename */
componentType: Type<DynamicFormControl> | null;
type: NGBootstrapFormControlType | null;
readonly componentType: Type<DynamicFormControl> | null;
static getFormControlType(model: DynamicFormControlModel): NGBootstrapFormControlType | null {
switch (model.type) {
@@ -162,7 +163,7 @@ export class DsDynamicFormControlComponent extends DynamicFormControlContainerCo
ngOnChanges(changes: SimpleChanges) {
if (changes) {
super.ngOnChanges(changes);
// super.ngOnChanges(changes);
}
if (changes.model) {
@@ -170,4 +171,9 @@ export class DsDynamicFormControlComponent extends DynamicFormControlContainerCo
}
}
onChangeLanguage(event) {
if (isNotEmpty((this.model as any).value)) {
this.onChange(event);
}
}
}

View File

@@ -6,13 +6,15 @@ import { FormControl, FormGroup, FormsModule, ReactiveFormsModule } from '@angul
import { DynamicFormValidationService } from '@ng-dynamic-forms/core';
import { Store } from '@ngrx/store';
import { TranslateModule } from '@ngx-translate/core';
import { Observable } from 'rxjs';
import 'rxjs/add/observable/of';
import { of as observableOf } from 'rxjs';
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
import { DsDynamicGroupComponent } from './dynamic-group.components';
import { DynamicGroupModel, DynamicGroupModelConfig } from './dynamic-group.model';
import { FormRowModel, SubmissionFormsModel } from '../../../../../../core/shared/config/config-submission-forms.model';
import {
FormRowModel,
SubmissionFormsModel
} from '../../../../../../core/shared/config/config-submission-forms.model';
import { FormFieldModel } from '../../../models/form-field.model';
import { FormBuilderService } from '../../../form-builder.service';
import { FormService } from '../../../../form.service';
@@ -97,7 +99,7 @@ describe('DsDynamicGroupComponent test suite', () => {
const store: Store<AppState> = jasmine.createSpyObj('store', {
dispatch: {},
select: Observable.of(true)
select: observableOf(true)
});
// async beforeEach
@@ -182,7 +184,7 @@ describe('DsDynamicGroupComponent test suite', () => {
const formModel = service.modelFromConfiguration(formConfig, groupComp.model.scopeUUID, {}, groupComp.model.submissionScope, groupComp.model.readOnly);
const chips = new Chips([], 'value', 'dc.contributor.author');
expect(groupComp.formCollapsed).toEqual(Observable.of(false));
expect(groupComp.formCollapsed).toEqual(observableOf(false));
expect(groupComp.formModel.length).toEqual(formModel.length);
expect(groupComp.chips.getChipsItems()).toEqual(chips.getChipsItems());
}));
@@ -203,7 +205,7 @@ describe('DsDynamicGroupComponent test suite', () => {
btnEl.click();
expect(groupComp.chips.getChipsItems()).toEqual(modelValue);
expect(groupComp.formCollapsed).toEqual(Observable.of(true));
expect(groupComp.formCollapsed).toEqual(observableOf(true));
});
it('should clear form inputs', () => {
@@ -220,7 +222,7 @@ describe('DsDynamicGroupComponent test suite', () => {
expect(control1.value).toBeNull();
expect(control2.value).toBeNull();
expect(groupComp.formCollapsed).toEqual(Observable.of(false));
expect(groupComp.formCollapsed).toEqual(observableOf(false));
});
});
@@ -252,7 +254,7 @@ describe('DsDynamicGroupComponent test suite', () => {
const formModel = service.modelFromConfiguration(formConfig, groupComp.model.scopeUUID, {}, groupComp.model.submissionScope, groupComp.model.readOnly);
const chips = new Chips(modelValue, 'value', 'dc.contributor.author');
expect(groupComp.formCollapsed).toEqual(Observable.of(true));
expect(groupComp.formCollapsed).toEqual(observableOf(true));
expect(groupComp.formModel.length).toEqual(formModel.length);
expect(groupComp.chips.getChipsItems()).toEqual(chips.getChipsItems());
}));
@@ -280,7 +282,7 @@ describe('DsDynamicGroupComponent test suite', () => {
groupFixture.detectChanges();
expect(groupComp.chips.getChipsItems()).toEqual(modelValue);
expect(groupComp.formCollapsed).toEqual(Observable.of(true));
expect(groupComp.formCollapsed).toEqual(observableOf(true));
}));
it('should delete existing chips item', () => {
@@ -292,7 +294,7 @@ describe('DsDynamicGroupComponent test suite', () => {
btnEl.click();
expect(groupComp.chips.getChipsItems()).toEqual([]);
expect(groupComp.formCollapsed).toEqual(Observable.of(false));
expect(groupComp.formCollapsed).toEqual(observableOf(false));
});
});
});

View File

@@ -73,7 +73,7 @@ export class DsDynamicGroupComponent implements OnDestroy, OnInit {
} else {
this.expandForm();
}
// this.formCollapsed = (isNotEmpty(value) && !(value.length === 1 && hasOnlyEmptyProperties(value[0]))) ? Observable.of(true) : Observable.of(false);
// this.formCollapsed = (isNotEmpty(value) && !(value.length === 1 && hasOnlyEmptyProperties(value[0]))) ? observableOf(true) : observableOf(false);
});
this.formId = this.formService.getUniqueId(this.model.id);

View File

@@ -2,12 +2,11 @@
import { ChangeDetectorRef, Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { FormControl, FormGroup, FormsModule, ReactiveFormsModule } from '@angular/forms';
import { async, ComponentFixture, fakeAsync, flush, inject, TestBed, } from '@angular/core/testing';
import { of as observableOf } from 'rxjs';
import { DynamicFormsCoreModule } from '@ng-dynamic-forms/core';
import { DynamicFormsNGBootstrapUIModule } from '@ng-dynamic-forms/ui-ng-bootstrap';
import { NgbModule, NgbTypeaheadSelectItemEvent } from '@ng-bootstrap/ng-bootstrap';
import { Observable } from 'rxjs';
import 'rxjs/add/observable/of'
import { AuthorityOptions } from '../../../../../../core/integration/models/authority-options.model';
import { AuthorityService } from '../../../../../../core/integration/authority.service';
@@ -140,7 +139,7 @@ describe('DsDynamicTagComponent test suite', () => {
it('should search when 3+ characters typed', fakeAsync(() => {
spyOn((tagComp as any).authorityService, 'getEntriesByName').and.callThrough();
tagComp.search(Observable.of('test')).subscribe(() => {
tagComp.search(observableOf('test')).subscribe(() => {
expect((tagComp as any).authorityService.getEntriesByName).toHaveBeenCalled();
});
}));

View File

@@ -3,8 +3,7 @@ import { ChangeDetectorRef, Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/c
import { FormControl, FormGroup, FormsModule, ReactiveFormsModule } from '@angular/forms';
import { async, ComponentFixture, fakeAsync, inject, TestBed, } from '@angular/core/testing';
import { By } from '@angular/platform-browser';
import { Observable } from 'rxjs';
import { of as observableOf } from 'rxjs';
import 'rxjs/add/observable/of';
import { AuthorityOptions } from '../../../../../../core/integration/models/authority-options.model';
@@ -123,7 +122,7 @@ describe('DsDynamicTypeaheadComponent test suite', () => {
it('should search when 3+ characters typed', fakeAsync(() => {
spyOn((typeaheadComp as any).authorityService, 'getEntriesByName').and.callThrough();
typeaheadComp.search(Observable.of('test')).subscribe(() => {
typeaheadComp.search(observableOf('test')).subscribe(() => {
expect((typeaheadComp as any).authorityService.getEntriesByName).toHaveBeenCalled();
});

View File

@@ -16,7 +16,7 @@ import {
DynamicFileUploadModel, DynamicFormArrayGroupModel,
DynamicFormArrayModel,
DynamicFormControlModel,
DynamicFormControlValue,
// DynamicFormControlValue,
DynamicFormGroupModel,
DynamicFormService,
DynamicFormValidationService,
@@ -761,8 +761,8 @@ describe('FormBuilderService test suite', () => {
(formArray.at(index) as FormGroup).controls.testFormArrayGroupInput.setValue('next test value 1');
(formArray.at(index + step) as FormGroup).controls.testFormArrayGroupInput.setValue('next test value 2');
(model.get(index).get(0) as DynamicFormValueControlModel<DynamicFormControlValue>).valueUpdates.next('next test value 1');
(model.get(index + step).get(0) as DynamicFormValueControlModel<DynamicFormControlValue>).valueUpdates.next('next test value 2');
(model.get(index).get(0) as DynamicFormValueControlModel<any>).valueUpdates.next('next test value 1');
(model.get(index + step).get(0) as DynamicFormValueControlModel<any>).valueUpdates.next('next test value 2');
service.moveFormArrayGroup(index, step, formArray, model);
@@ -771,8 +771,8 @@ describe('FormBuilderService test suite', () => {
expect((formArray.at(index) as FormGroup).controls.testFormArrayGroupInput.value).toEqual('next test value 2');
expect((formArray.at(index + step) as FormGroup).controls.testFormArrayGroupInput.value).toEqual('next test value 1');
expect((model.get(index).get(0) as DynamicFormValueControlModel<DynamicFormControlValue>).value).toEqual('next test value 2');
expect((model.get(index + step).get(0) as DynamicFormValueControlModel<DynamicFormControlValue>).value).toEqual('next test value 1');
expect((model.get(index).get(0) as DynamicFormValueControlModel<any>).value).toEqual('next test value 2');
expect((model.get(index + step).get(0) as DynamicFormValueControlModel<any>).value).toEqual('next test value 1');
});
it('should move down a form array group', () => {
@@ -785,8 +785,8 @@ describe('FormBuilderService test suite', () => {
(formArray.at(index) as FormGroup).controls.testFormArrayGroupInput.setValue('next test value 1');
(formArray.at(index + step) as FormGroup).controls.testFormArrayGroupInput.setValue('next test value 2');
(model.get(index).get(0) as DynamicFormValueControlModel<DynamicFormControlValue>).valueUpdates.next('next test value 1');
(model.get(index + step).get(0) as DynamicFormValueControlModel<DynamicFormControlValue>).valueUpdates.next('next test value 2');
(model.get(index).get(0) as DynamicFormValueControlModel<any>).valueUpdates.next('next test value 1');
(model.get(index + step).get(0) as DynamicFormValueControlModel<any>).valueUpdates.next('next test value 2');
service.moveFormArrayGroup(index, step, formArray, model);
@@ -795,8 +795,8 @@ describe('FormBuilderService test suite', () => {
expect((formArray.at(index) as FormGroup).controls.testFormArrayGroupInput.value).toEqual('next test value 2');
expect((formArray.at(index + step) as FormGroup).controls.testFormArrayGroupInput.value).toEqual('next test value 1');
expect((model.get(index).get(0) as DynamicFormValueControlModel<DynamicFormControlValue>).value).toEqual('next test value 2');
expect((model.get(index + step).get(0) as DynamicFormValueControlModel<DynamicFormControlValue>).value).toEqual('next test value 1');
expect((model.get(index).get(0) as DynamicFormValueControlModel<any>).value).toEqual('next test value 2');
expect((model.get(index + step).get(0) as DynamicFormValueControlModel<any>).value).toEqual('next test value 1');
});
it('should throw when form array group is to be moved out of bounds', () => {

View File

@@ -1,8 +1,7 @@
import { Store } from '@ngrx/store';
import { cold, hot } from 'jasmine-marbles';
import { Observable } from 'rxjs';
import { of as observableOf } from 'rxjs';
import { AppState } from '../app.reducer';
import { HostWindowState } from './host-window.reducer';
import { GridBreakpoint, HostWindowService, WidthCategory } from './host-window.service';
@@ -13,7 +12,7 @@ describe('HostWindowService', () => {
describe('', () => {
beforeEach(() => {
const _initialState = { hostWindow: { width: 1600, height: 770 } };
store = new Store<AppState>(Observable.of(_initialState), undefined, undefined);
store = new Store<AppState>(observableOf(_initialState), undefined, undefined);
service = new HostWindowService(store);
});
@@ -49,7 +48,7 @@ describe('HostWindowService', () => {
describe('', () => {
beforeEach(() => {
const _initialState = { hostWindow: { width: 1100, height: 770 } };
store = new Store<AppState>(Observable.of(_initialState), undefined, undefined);
store = new Store<AppState>(observableOf(_initialState), undefined, undefined);
service = new HostWindowService(store);
});
@@ -85,7 +84,7 @@ describe('HostWindowService', () => {
describe('', () => {
beforeEach(() => {
const _initialState = { hostWindow: { width: 800, height: 770 } };
store = new Store<AppState>(Observable.of(_initialState), undefined, undefined);
store = new Store<AppState>(observableOf(_initialState), undefined, undefined);
service = new HostWindowService(store);
});
@@ -121,7 +120,7 @@ describe('HostWindowService', () => {
describe('', () => {
beforeEach(() => {
const _initialState = { hostWindow: { width: 600, height: 770 } };
store = new Store<AppState>(Observable.of(_initialState), undefined, undefined);
store = new Store<AppState>(observableOf(_initialState), undefined, undefined);
service = new HostWindowService(store);
});
@@ -157,7 +156,7 @@ describe('HostWindowService', () => {
describe('', () => {
beforeEach(() => {
const _initialState = { hostWindow: { width: 400, height: 770 } };
store = new Store<AppState>(Observable.of(_initialState), undefined, undefined);
store = new Store<AppState>(observableOf(_initialState), undefined, undefined);
service = new HostWindowService(store);
});

View File

@@ -99,8 +99,10 @@ export class HostWindowService {
isXsOrSm(): Observable<boolean> {
return observableCombineLatest(
this.isXs(),
this.isSm(),
((isXs, isSm) => isXs || isSm)
).pipe(distinctUntilChanged());
this.isSm()
).pipe(
map(([isXs, isSm]) => isXs || isSm),
distinctUntilChanged()
);
}
}

View File

@@ -4,9 +4,13 @@ import { NotificationsBoardComponent } from './notifications-board/notifications
import { NotificationComponent } from './notification/notification.component';
import { Store, StoreModule } from '@ngrx/store';
import { notificationsReducer } from './notifications.reducers';
import { Observable } from 'rxjs';
import { of as observableOf } from 'rxjs';
import 'rxjs/add/observable/of';
import { NewNotificationAction, RemoveAllNotificationsAction, RemoveNotificationAction } from './notifications.actions';
import {
NewNotificationAction,
RemoveAllNotificationsAction,
RemoveNotificationAction
} from './notifications.actions';
import { Notification } from './models/notification.model';
import { NotificationType } from './models/notification-type';
import { GlobalConfig } from '../../../config/global-config.interface';
@@ -14,7 +18,7 @@ import { GlobalConfig } from '../../../config/global-config.interface';
describe('NotificationsService test', () => {
const store: Store<Notification> = jasmine.createSpyObj('store', {
dispatch: {},
select: Observable.of(true)
select: observableOf(true)
});
let service;
let envConfig: GlobalConfig;
@@ -43,25 +47,25 @@ describe('NotificationsService test', () => {
});
it('Success method should dispatch NewNotificationAction with proper parameter', () => {
const notification = service.success('Title', Observable.of('Content'));
const notification = service.success('Title', observableOf('Content'));
expect(notification.type).toBe(NotificationType.Success);
expect(store.dispatch).toHaveBeenCalledWith(new NewNotificationAction(notification));
});
it('Warning method should dispatch NewNotificationAction with proper parameter', () => {
const notification = service.warning('Title', Observable.of('Content'));
const notification = service.warning('Title', observableOf('Content'));
expect(notification.type).toBe(NotificationType.Warning);
expect(store.dispatch).toHaveBeenCalledWith(new NewNotificationAction(notification));
});
it('Info method should dispatch NewNotificationAction with proper parameter', () => {
const notification = service.info('Title', Observable.of('Content'));
const notification = service.info('Title', observableOf('Content'));
expect(notification.type).toBe(NotificationType.Info);
expect(store.dispatch).toHaveBeenCalledWith(new NewNotificationAction(notification));
});
it('Error method should dispatch NewNotificationAction with proper parameter', () => {
const notification = service.error('Title', Observable.of('Content'));
const notification = service.error('Title', observableOf('Content'));
expect(notification.type).toBe(NotificationType.Error);
expect(store.dispatch).toHaveBeenCalledWith(new NewNotificationAction(notification));
});

View File

@@ -3,7 +3,7 @@ import { By } from '@angular/platform-browser';
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { NO_ERRORS_SCHEMA } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { Observable } from 'rxjs';
import { of as observableOf } from 'rxjs';
import { RouterStub } from '../testing/router-stub';
import { ViewMode } from '../../core/shared/view-mode.model';
@@ -14,7 +14,7 @@ describe('ObjectCollectionComponent', () => {
const queryParam = 'test query';
const scopeParam = '7669c72a-3f2a-451f-a3b9-9210e7a4c02f';
const activatedRouteStub = {
queryParams: Observable.of({
queryParams: observableOf({
query: queryParam,
scope: scopeParam
})

View File

@@ -4,13 +4,13 @@ import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core';
import { By } from '@angular/platform-browser';
import { TruncatePipe } from '../../utils/truncate.pipe';
import { Item } from '../../../core/shared/item.model';
import { Observable } from 'rxjs';
import { of as observableOf } from 'rxjs';
let itemGridElementComponent: ItemGridElementComponent;
let fixture: ComponentFixture<ItemGridElementComponent>;
const mockItemWithAuthorAndDate: Item = Object.assign(new Item(), {
bitstreams: Observable.of({}),
bitstreams: observableOf({}),
metadata: [
{
key: 'dc.contributor.author',
@@ -24,7 +24,7 @@ const mockItemWithAuthorAndDate: Item = Object.assign(new Item(), {
}]
});
const mockItemWithoutAuthorAndDate: Item = Object.assign(new Item(), {
bitstreams: Observable.of({}),
bitstreams: observableOf({}),
metadata: [
{
key: 'dc.title',

View File

@@ -1,7 +1,6 @@
import { combineLatest as observableCombineLatest, BehaviorSubject, Observable } from 'rxjs';
import {combineLatest as observableCombineLatest, BehaviorSubject , Observable } from 'rxjs';
import {startWith, distinctUntilChanged, map } from 'rxjs/operators';
import { startWith, distinctUntilChanged, map } from 'rxjs/operators';
import {
ChangeDetectionStrategy,
Component,
@@ -26,7 +25,7 @@ import { PaginationComponentOptions } from '../pagination/pagination-component-o
changeDetection: ChangeDetectionStrategy.Default,
encapsulation: ViewEncapsulation.Emulated,
selector: 'ds-object-grid',
styleUrls: [ './object-grid.component.scss' ],
styleUrls: ['./object-grid.component.scss'],
templateUrl: './object-grid.component.html',
animations: [fadeIn]
})
@@ -38,9 +37,11 @@ export class ObjectGridComponent implements OnInit {
@Input() hideGear = false;
@Input() hidePagerWhenSinglePage = true;
private _objects$: BehaviorSubject<RemoteData<PaginatedList<ListableObject>>>;
@Input() set objects(objects: RemoteData<PaginatedList<ListableObject>>) {
this._objects$.next(objects);
}
get objects() {
return this._objects$.getValue();
}
@@ -111,26 +112,25 @@ export class ObjectGridComponent implements OnInit {
this.columns$ = observableCombineLatest(
nbColumns$,
this._objects$,
(nbColumns, objects) => {
if (hasValue(objects) && hasValue(objects.payload) && hasValue(objects.payload.page)) {
const page = objects.payload.page;
this._objects$).pipe(map(([nbColumns, objects]) => {
if (hasValue(objects) && hasValue(objects.payload) && hasValue(objects.payload.page)) {
const page = objects.payload.page;
const result = [];
const result = [];
page.forEach((obj: ListableObject, i: number) => {
const colNb = i % nbColumns;
let col = result[colNb];
if (hasNoValue(col)) {
col = [];
}
result[colNb] = [...col, obj];
});
return result;
} else {
return [];
}
});
page.forEach((obj: ListableObject, i: number) => {
const colNb = i % nbColumns;
let col = result[colNb];
if (hasNoValue(col)) {
col = [];
}
result[colNb] = [...col, obj];
});
return result;
} else {
return [];
}
}));
}
onPageChange(event) {

View File

@@ -1,6 +1,6 @@
import { CollectionSearchResultGridElementComponent } from './collection-search-result-grid-element.component';
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { Observable } from 'rxjs';
import { of as observableOf } from 'rxjs';
import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core';
import { By } from '@angular/platform-browser';
import { TruncatePipe } from '../../../utils/truncate.pipe';
@@ -12,7 +12,7 @@ let collectionSearchResultGridElementComponent: CollectionSearchResultGridElemen
let fixture: ComponentFixture<CollectionSearchResultGridElementComponent>;
const truncatableServiceStub: any = {
isCollapsed: (id: number) => Observable.of(true),
isCollapsed: (id: number) => observableOf(true),
};
const mockCollectionWithAbstract: CollectionSearchResult = new CollectionSearchResult();

View File

@@ -1,6 +1,6 @@
import { CommunitySearchResultGridElementComponent } from './community-search-result-grid-element.component';
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { Observable } from 'rxjs';
import { of as observableOf } from 'rxjs';
import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core';
import { By } from '@angular/platform-browser';
import { TruncatePipe } from '../../../utils/truncate.pipe';
@@ -12,7 +12,7 @@ let communitySearchResultGridElementComponent: CommunitySearchResultGridElementC
let fixture: ComponentFixture<CommunitySearchResultGridElementComponent>;
const truncatableServiceStub: any = {
isCollapsed: (id: number) => Observable.of(true),
isCollapsed: (id: number) => observableOf(true),
};
const mockCommunityWithAbstract: CommunitySearchResult = new CommunitySearchResult();

View File

@@ -1,7 +1,7 @@
import { ItemSearchResultGridElementComponent } from './item-search-result-grid-element.component';
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { Observable } from 'rxjs';
import { NO_ERRORS_SCHEMA, ChangeDetectionStrategy } from '@angular/core';
import { of as observableOf } from 'rxjs';
import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core';
import { By } from '@angular/platform-browser';
import { TruncatePipe } from '../../../utils/truncate.pipe';
import { Item } from '../../../../core/shared/item.model';
@@ -13,13 +13,13 @@ let itemSearchResultGridElementComponent: ItemSearchResultGridElementComponent;
let fixture: ComponentFixture<ItemSearchResultGridElementComponent>;
const truncatableServiceStub: any = {
isCollapsed: (id: number) => Observable.of(true),
isCollapsed: (id: number) => observableOf(true),
};
const mockItemWithAuthorAndDate: ItemSearchResult = new ItemSearchResult();
mockItemWithAuthorAndDate.hitHighlights = [];
mockItemWithAuthorAndDate.dspaceObject = Object.assign(new Item(), {
bitstreams: Observable.of({}),
bitstreams: observableOf({}),
metadata: [
{
key: 'dc.contributor.author',
@@ -36,7 +36,7 @@ mockItemWithAuthorAndDate.dspaceObject = Object.assign(new Item(), {
const mockItemWithoutAuthorAndDate: ItemSearchResult = new ItemSearchResult();
mockItemWithoutAuthorAndDate.hitHighlights = [];
mockItemWithoutAuthorAndDate.dspaceObject = Object.assign(new Item(), {
bitstreams: Observable.of({}),
bitstreams: observableOf({}),
metadata: [
{
key: 'dc.title',

View File

@@ -1,6 +1,6 @@
import { WrapperGridElementComponent } from './wrapper-grid-element.component';
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { Observable } from 'rxjs';
import { of as observableOf } from 'rxjs';
import { ActivatedRoute, Router } from '@angular/router';
import { RouterStub } from '../../testing/router-stub';
import { NO_ERRORS_SCHEMA } from '@angular/core';
@@ -11,7 +11,7 @@ let fixture: ComponentFixture<WrapperGridElementComponent>;
const queryParam = 'test query';
const scopeParam = '7669c72a-3f2a-451f-a3b9-9210e7a4c02f';
const activatedRouteStub = {
queryParams: Observable.of({
queryParams: observableOf({
query: queryParam,
scope: scopeParam
})

View File

@@ -4,13 +4,13 @@ import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core';
import { By } from '@angular/platform-browser';
import { TruncatePipe } from '../../utils/truncate.pipe';
import { Item } from '../../../core/shared/item.model';
import { Observable } from 'rxjs';
import { of as observableOf } from 'rxjs';
let itemListElementComponent: ItemListElementComponent;
let fixture: ComponentFixture<ItemListElementComponent>;
const mockItemWithAuthorAndDate: Item = Object.assign(new Item(), {
bitstreams: Observable.of({}),
bitstreams: observableOf({}),
metadata: [
{
key: 'dc.contributor.author',
@@ -24,7 +24,7 @@ const mockItemWithAuthorAndDate: Item = Object.assign(new Item(), {
}]
});
const mockItemWithoutAuthorAndDate: Item = Object.assign(new Item(), {
bitstreams: Observable.of({}),
bitstreams: observableOf({}),
metadata: [
{
key: 'dc.title',

View File

@@ -1,6 +1,6 @@
import { CollectionSearchResultListElementComponent } from './collection-search-result-list-element.component';
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { Observable } from 'rxjs';
import { of as observableOf } from 'rxjs';
import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core';
import { By } from '@angular/platform-browser';
import { TruncatePipe } from '../../../utils/truncate.pipe';
@@ -12,7 +12,7 @@ let collectionSearchResultListElementComponent: CollectionSearchResultListElemen
let fixture: ComponentFixture<CollectionSearchResultListElementComponent>;
const truncatableServiceStub: any = {
isCollapsed: (id: number) => Observable.of(true),
isCollapsed: (id: number) => observableOf(true),
};
const mockCollectionWithAbstract: CollectionSearchResult = new CollectionSearchResult();

View File

@@ -1,6 +1,6 @@
import { CommunitySearchResultListElementComponent } from './community-search-result-list-element.component';
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { Observable } from 'rxjs';
import { of as observableOf } from 'rxjs';
import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core';
import { By } from '@angular/platform-browser';
import { TruncatePipe } from '../../../utils/truncate.pipe';
@@ -12,7 +12,7 @@ let communitySearchResultListElementComponent: CommunitySearchResultListElementC
let fixture: ComponentFixture<CommunitySearchResultListElementComponent>;
const truncatableServiceStub: any = {
isCollapsed: (id: number) => Observable.of(true),
isCollapsed: (id: number) => observableOf(true),
};
const mockCommunityWithAbstract: CommunitySearchResult = new CommunitySearchResult();

View File

@@ -1,7 +1,7 @@
import { ItemSearchResultListElementComponent } from './item-search-result-list-element.component';
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { Observable } from 'rxjs';
import { NO_ERRORS_SCHEMA, ChangeDetectionStrategy } from '@angular/core';
import { of as observableOf } from 'rxjs';
import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core';
import { By } from '@angular/platform-browser';
import { TruncatePipe } from '../../../utils/truncate.pipe';
import { Item } from '../../../../core/shared/item.model';
@@ -13,13 +13,13 @@ let itemSearchResultListElementComponent: ItemSearchResultListElementComponent;
let fixture: ComponentFixture<ItemSearchResultListElementComponent>;
const truncatableServiceStub: any = {
isCollapsed: (id: number) => Observable.of(true),
isCollapsed: (id: number) => observableOf(true),
};
const mockItemWithAuthorAndDate: ItemSearchResult = new ItemSearchResult();
mockItemWithAuthorAndDate.hitHighlights = [];
mockItemWithAuthorAndDate.dspaceObject = Object.assign(new Item(), {
bitstreams: Observable.of({}),
bitstreams: observableOf({}),
metadata: [
{
key: 'dc.contributor.author',
@@ -36,7 +36,7 @@ mockItemWithAuthorAndDate.dspaceObject = Object.assign(new Item(), {
const mockItemWithoutAuthorAndDate: ItemSearchResult = new ItemSearchResult();
mockItemWithoutAuthorAndDate.hitHighlights = [];
mockItemWithoutAuthorAndDate.dspaceObject = Object.assign(new Item(), {
bitstreams: Observable.of({}),
bitstreams: observableOf({}),
metadata: [
{
key: 'dc.title',

View File

@@ -18,7 +18,6 @@ import { PaginationComponentOptions } from './pagination-component-options.model
import { SortDirection, SortOptions } from '../../core/cache/models/sort-options.model';
import { hasValue, isNotEmpty } from '../empty.util';
import { PageInfo } from '../../core/shared/page-info.model';
import { isNumeric } from 'tslint';
/**
* The default pagination controls component.
@@ -419,7 +418,7 @@ export class PaginationComponent implements OnDestroy, OnInit {
*/
private validatePage(page: any): number {
let result = this.currentPage;
if (isNumeric(page)) {
if (!isNaN(page)) {
result = +page;
}
return result;

View File

@@ -1,7 +1,7 @@
import { RouteService } from './route.service';
import { async, TestBed } from '@angular/core/testing';
import { ActivatedRoute, convertToParamMap, Params } from '@angular/router';
import { Observable } from 'rxjs';
import { of as observableOf } from 'rxjs';
describe('RouteService', () => {
let service: RouteService;
@@ -24,8 +24,8 @@ describe('RouteService', () => {
{
provide: ActivatedRoute,
useValue: {
queryParams: Observable.of(paramObject),
queryParamMap: Observable.of(convertToParamMap(paramObject))
queryParams: observableOf(paramObject),
queryParamMap: observableOf(convertToParamMap(paramObject))
},
},
]

View File

@@ -1,5 +1,4 @@
import {distinctUntilChanged, map} from 'rxjs/operators';
import { distinctUntilChanged, map } from 'rxjs/operators';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import {
@@ -15,32 +14,44 @@ export class RouteService {
}
getQueryParameterValues(paramName: string): Observable<string[]> {
return this.route.queryParamMap.pipe(map((map) => [...map.getAll(paramName)]),distinctUntilChanged(),);
return this.route.queryParamMap.pipe(
map((params) => [...params.getAll(paramName)]),
distinctUntilChanged()
);
}
getQueryParameterValue(paramName: string): Observable<string> {
return this.route.queryParamMap.pipe(map((map) => map.get(paramName)),distinctUntilChanged(),);
return this.route.queryParamMap.pipe(
map((params) => params.get(paramName)),
distinctUntilChanged()
);
}
hasQueryParam(paramName: string): Observable<boolean> {
return this.route.queryParamMap.pipe(map((map) => map.has(paramName)),distinctUntilChanged(),);
return this.route.queryParamMap.pipe(
map((params) => params.has(paramName)),
distinctUntilChanged()
);
}
hasQueryParamWithValue(paramName: string, paramValue: string): Observable<boolean> {
return this.route.queryParamMap.pipe(map((map) => map.getAll(paramName).indexOf(paramValue) > -1),distinctUntilChanged(),);
return this.route.queryParamMap.pipe(
map((params) => params.getAll(paramName).indexOf(paramValue) > -1),
distinctUntilChanged()
);
}
getQueryParamsWithPrefix(prefix: string): Observable<Params> {
return this.route.queryParamMap.pipe(
map((map) => {
const params = {};
map.keys
.filter((key) => key.startsWith(prefix))
.forEach((key) => {
params[key] = [...map.getAll(key)];
});
return params;
}),
map((qparams) => {
const params = {};
qparams.keys
.filter((key) => key.startsWith(prefix))
.forEach((key) => {
params[key] = [...qparams.getAll(key)];
});
return params;
}),
distinctUntilChanged((a, b) => JSON.stringify(a) === JSON.stringify(b)),);
}
}

View File

@@ -1,5 +1,5 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { Observable } from 'rxjs';
import { of as observableOf } from 'rxjs';
import { TruncatablePartComponent } from './truncatable-part.component';
import { TruncatableService } from '../truncatable.service';
import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core';
@@ -15,9 +15,9 @@ describe('TruncatablePartComponent', () => {
const truncatableServiceStub: any = {
isCollapsed: (id: string) => {
if (id === id1) {
return Observable.of(true)
return observableOf(true)
} else {
return Observable.of(false);
return observableOf(false);
}
}
};

View File

@@ -1,5 +1,5 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { Observable } from 'rxjs';
import { of as observableOf } from 'rxjs';
import { TruncatableComponent } from './truncatable.component';
import { TruncatableService } from './truncatable.service';
import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core';
@@ -14,9 +14,9 @@ describe('TruncatableComponent', () => {
/* tslint:disable:no-empty */
isCollapsed: (id: string) => {
if (id === '1') {
return Observable.of(true)
return observableOf(true)
} else {
return Observable.of(false);
return observableOf(false);
}
},
expand: (id: string) => {

View File

@@ -1,9 +1,9 @@
import { Store } from '@ngrx/store';
import { async, TestBed } from '@angular/core/testing';
import { Observable } from 'rxjs';
import { TruncatableService } from './truncatable.service';
import { TruncatableCollapseAction, TruncatableExpandAction } from './truncatable.actions';
import { TruncatablesState } from './truncatable.reducer';
import { of as observableOf } from 'rxjs';
describe('TruncatableService', () => {
const id1 = '123';
@@ -13,7 +13,7 @@ describe('TruncatableService', () => {
/* tslint:disable:no-empty */
dispatch: {},
/* tslint:enable:no-empty */
select: Observable.of(true)
select: observableOf(true)
});
beforeEach(async(() => {
TestBed.configureTestingModule({

View File

@@ -8,23 +8,23 @@ const {
getAotPlugin
} = require('./webpack/webpack.aot');
module.exports = function(options) {
options = options || {};
if (options.aot) {
console.log(`Running build for ${options.client ? 'client' : 'server'} with AoT Compilation`)
module.exports = function(env, options) {
env = env || {};
if (env.aot) {
console.log(`Running build for ${env.client ? 'client' : 'server'} with AoT Compilation`)
}
let serverPartial = getServerWebpackPartial(options.aot);
let serverPartial = getServerWebpackPartial(env.aot);
let serverConfig = webpackMerge({}, commonPartial, serverPartial, {
plugins: [
getAotPlugin('server', !!options.aot)
getAotPlugin('server', !!env.aot)
]
});
let clientConfig = webpackMerge({}, commonPartial, clientPartial, {
plugins: [
getAotPlugin('client', !!options.aot)
getAotPlugin('client', !!env.aot)
]
});
@@ -35,13 +35,13 @@ module.exports = function(options) {
const configs = [];
if (!options.aot) {
if (!env.aot) {
configs.push(clientConfig, serverConfig);
} else if (options.client) {
} else if (env.client) {
configs.push(clientConfig);
} else if (options.server) {
} else if (env.server) {
configs.push(serverConfig);
}
return configs;
}
};

View File

@@ -1,104 +1,104 @@
const CopyWebpackPlugin = require('copy-webpack-plugin');
const {
root,
join
root,
join
} = require('./helpers');
module.exports = {
mode: 'development',
devtool: 'source-map',
resolve: {
extensions: ['.ts', '.js', '.json']
},
output: {
path: root('dist')
},
watchOptions: {
aggregateTimeout: 50,
},
module: {
rules: [{
test: /\.ts$/,
loader: '@ngtools/webpack'
},
{
test: /\.css$/,
use: [{
loader: 'to-string-loader',
options: {
sourceMap: true
mode: 'development',
devtool: 'source-map',
resolve: {
extensions: ['.ts', '.js', '.json']
},
output: {
path: root('dist')
},
watchOptions: {
aggregateTimeout: 50,
},
node: {
fs: "empty",
module: "empty"
},
module: {
rules: [{
test: /\.ts$/,
loader: '@ngtools/webpack'
},
{
test: /\.css$/,
use: [{
loader: 'to-string-loader',
options: {
sourceMap: true
}
},
{
loader: 'css-loader',
options: {
sourceMap: true
}
},
{
loader: 'postcss-loader',
options: {
sourceMap: true
}
}
]
},
{
test: /\.scss$/,
exclude: /node_modules/,
use: [{
loader: 'to-string-loader',
options: {
sourceMap: true
}
}, {
loader: 'raw-loader',
options: {
sourceMap: true
}
},
{
loader: 'postcss-loader',
options: {
sourceMap: true
}
},
{
loader: 'resolve-url-loader',
options: {
sourceMap: true
}
},
{
loader: 'sass-loader',
options: {
sourceMap: true
}
}
]
},
{
test: /\.html$/,
loader: 'raw-loader'
}
},
{
loader: 'css-loader',
options: {
sourceMap: true
}
},
{
loader: 'postcss-loader',
options: {
sourceMap: true
}
}
]
},
{
test: /\.scss$/,
exclude: /node_modules/,
use: [{
loader: 'to-string-loader',
options: {
sourceMap: true
}
}, {
loader: 'raw-loader',
options: {
sourceMap: true
}
},
{
loader: 'postcss-loader',
options: {
sourceMap: true
}
},
{
loader: 'resolve-url-loader',
options: {
sourceMap: true
}
},
{
loader: 'sass-loader',
options: {
sourceMap: true
}
}
]
},
{
test: /\.html$/,
loader: 'raw-loader'
},
{
test: /\.json$/,
loader: 'json-loader'
}
},
plugins: [
new CopyWebpackPlugin([{
from: join(__dirname, '..', 'node_modules', 'font-awesome', 'fonts'),
to: join('assets', 'fonts')
}, {
from: join(__dirname, '..', 'resources', 'images'),
to: join('assets', 'images')
}, {
from: join(__dirname, '..', 'resources', 'i18n'),
to: join('assets', 'i18n')
}])
]
},
plugins: [
new CopyWebpackPlugin([{
from: join(__dirname, '..', 'node_modules', 'font-awesome', 'fonts'),
to: join('assets', 'fonts')
}, {
from: join(__dirname, '..', 'resources', 'images'),
to: join('assets', 'images')
}, {
from: join(__dirname, '..', 'resources', 'i18n'),
to: join('assets', 'i18n')
}])
]
};

View File

@@ -11,9 +11,11 @@ module.exports = {
mode: 'production',
recordsOutputPath: root('webpack.records.json'),
plugins: [
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify('production'),
'process.env.AOT': true
new webpack.EnvironmentPlugin({
'process.env': {
'NODE_ENV': JSON.stringify('production'),
'AOT': true
}
}),
// Loader options

View File

@@ -178,17 +178,6 @@ module.exports = function (options) {
exclude: [root('src/index.html')]
},
/**
* Json loader support for *.json files.
*
* See: https://github.com/webpack/json-loader
*/
{
test: /\.json$/,
loader: 'json-loader',
exclude: [root('src/index.html')]
},
/**
* Instruments JS files with Istanbul for subsequent code coverage reporting.
* Instrument only testing sources.
@@ -288,4 +277,4 @@ module.exports = function (options) {
}
};
}
};

1146
yarn.lock

File diff suppressed because it is too large Load Diff