dependency upgrades, server and platform module updates, linting wip

This commit is contained in:
William Welling
2017-07-12 14:33:16 -05:00
parent afc39022f8
commit c08f5c672b
190 changed files with 6321 additions and 4703 deletions

197
README.md
View File

@@ -91,13 +91,15 @@ To change the default configuration values, create local files that override the
To use the configuration parameters in your component:
```bash
import { GlobalConfig } from "../config";
import { GLOBAL_CONFIG, GlobalConfig } from '../config';
constructor(@Inject(GLOBAL_CONFIG) public config: GlobalConfig) {}
```
Running the app
---------------
After you have installed all dependencies you can now run the app. Run `yarn run watch:dev` to start a local server which will watch for changes, rebuild the code, and reload the server for you. You can visit it at `http://localhost:3000`.
After you have installed all dependencies you can now run the app. Run `yarn run watch` to start a local server which will watch for changes, rebuild the code, and reload the server for you. You can visit it at `http://localhost:3000`.
Running in production mode
--------------------------
@@ -113,7 +115,7 @@ yarn start
If you only want to build for production, without starting, run:
```bash
yarn run build:prod:ngc:json
yarn run build:prod
```
This will build the application and put the result in the `dist` folder
@@ -155,7 +157,7 @@ If you are going to use a remote test enviroment you need to edit the './protrac
The default browser is Google Chrome.
Protractor needs a functional instance of the DSpace interface to run the E2E tests, so you need to run:`yarn run watch:dev`
Protractor needs a functional instance of the DSpace interface to run the E2E tests, so you need to run:`yarn run watch`
or any command that bring up the DSpace interface.
@@ -171,6 +173,17 @@ To run all the tests (e.g.: to run tests with Continuous Integration software) y
Run:`yarn run docs` to produce the documentation that will be available in the 'doc' folder.
Deploy
------
```bash
# deploy production in standalone pm2 container
yarn run deploy
# remove production from standalone pm2 container
yarn run undeploy
```
Other commands
--------------
@@ -201,87 +214,105 @@ See [the guide on the wiki](https://wiki.duraspace.org/display/DSPACE/DSpace+7+-
File Structure
--------------
Descriptions coming soon...
```
dspace-angular
├── README.md * This document
├── app.json * Application manifest file
├── config * Folder for configuration files
│   └── environment.default.js * Default configuration files
├── dist * Folder for e2e test files
├── e2e *
│   ├── app.e2e-spec.ts *
│   ── app.po.ts *
│   ├── pagenotfound *
│   │   ├── pagenotfound.e2e-spec.ts *
│   │   └── pagenotfound.po.ts *
│   ── tsconfig.json *
├── empty.js *
├── helpers.js *
├── karma.conf.js * Unit Test configuration file
├── nodemon.json * Nodemon (https://nodemon.io/) configuration
├── package.json * This file describes the npm package for this project, its dependencies, scripts, etc.
├── postcss.config.json * PostCSS (http://postcss.org/) configuration file
├── protractor.conf.js * E2E tests configuration file
├── resources * Folder for static resources
│   ├── i18n * Folder for i18n translations
│   │   └── en.json *
│   └── images * Folder for images
│   └── dspace_logo.png *
├── rollup-client.js * Rollup (http://rollupjs.org/) configuration for the client
├── rollup-server.js * Rollup (http://rollupjs.org/) configuration for the server
── spec-bundle.js *
├── src * The source of the application
│   ├── app * The location of the app module, and root of the application shared by client and server
│   │   ├── app-routing.module.ts *
│   │   ├── app.component.html *
│   │   ├── app.component.scss *
│   │   ├── app.component.spec.ts *
│   │   ├── app.component.ts *
│   │   ├── app.effects.ts *
│   │   ├── app.module.ts *
│   │   ├── app.reducers.ts *
│   │   ├── core *
│   │   ├── header *
│   │   ├── home *
│   │   ├── pagenotfound *
│   │   ├── shared *
│   │   ── store.actions.ts *
│   ├── backend * Folder containing a mock of the REST API, hosted by the express server
│   │   ├── api.ts *
│   │   ├── bitstreams.ts *
│   │   ├── bundles.ts *
│   │   ├── cache.ts *
│   │   ├── collections.ts *
│   │   ├── db.ts *
│   │   ├── items.ts *
│   │   ── metadata.ts *
│   ├── client.aot.ts * The bootstrap file for the client, in production
│   ├── client.ts * The bootstrap file for the client, during development
│   ├── config.ts * File that loads environmental and shareable settings and makes them available to app components
│   ├── index.html * The index.html file
│   ├── platform *
│   │   ├── angular2-meta.ts *
│   │   ── modules *
│   │   │   ├── browser.module.ts * The root module for the client
│   │   │   └── node.module.ts * The root module for the server
│   │   ── workarounds *
│   │   ├── __workaround.browser.ts *
│   │   └── __workaround.node.ts *
│   ├── server.aot.ts * The express (http://expressjs.com/) config and bootstrap file for the server, in production
│   ├── server.routes.ts * The routes file for the server
│   ├── server.ts * The express (http://expressjs.com/) config and bootstrap file for the server, during development
│   ├── styles * Folder containing global styles.
│   │   ├── main.scss * Global scss file
│   │   ── variables.scss * Global sass variables file
│   └── typings.d.ts * File that allows you to add custom typings for libraries without TypeScript support
├── tsconfig.aot.json * TypeScript config for production builds
├── tsconfig.json * TypeScript config for development build
├── tslint.json * TSLint (https://palantir.github.io/tslint/) configuration
├── typedoc.json * TYPEDOC configuration
├── webpack.config.ts * Webpack (https://webpack.github.io/) config for development builds
├── webpack.prod.config.ts * Webpack (https://webpack.github.io/) config for production builds
├── webpack.test.config.js * Webpack (https://webpack.github.io/) config for testing
└── yarn.lock * Yarn lockfile (https://yarnpkg.com/en/docs/yarn-lock)
.
├── README.md
├── app.yaml
├── config
│   ├── environment.default.js
│   ├── environment.dev.js
│   ├── environment.prod.js
│   ── environment.test.js
├── e2e
│   ├── app.e2e-spec.ts
│   ├── app.po.ts
│   ── pagenotfound
│   │   ├── pagenotfound.e2e-spec.ts
│   │   └── pagenotfound.po.ts
│   └── tsconfig.json
├── karma.conf.js
├── nodemon.json
├── package.json
├── postcss.config.js
├── protractor.conf.js
├── resources
│   ├── data
│   │   └── en
│   ├── i18n
│   │   └── en.json
│   └── images
│   └── dspace_logo.png
├── rollup.config.js
├── spec-bundle.js
├── src
│   ├── app
│   │   ├── app-routing.module.ts
│   │   ├── app.component.html
│   │   ├── app.component.scss
│   │   ├── app.component.spec.ts
│   │   ├── app.component.ts
│   │   ├── app.effects.ts
│   │   ├── app.module.ts
│   │   ├── app.reducer.ts
│   │   ├── browser-app.module.ts
│   │   ├── collection-page
│   │   ├── community-page
│   │   ── core
│   │   ├── header
│   │   ├── home
│   │   ├── item-page
│   │   ├── object-list
│   │   ├── pagenotfound
│   │   ├── server-app.module.ts
│   │   ├── shared
│   │   ├── store.actions.ts
│   │   ── store.effects.ts
│   │   ├── thumbnail
│   │   └── typings.d.ts
│   ├── backend
│   │   ├── api.ts
│   │   ├── cache.ts
│   │   ├── data
│   │   ── db.ts
│   ├── config
│   │   ├── cache-config.interface.ts
│   │   ── global-config.interface.ts
│   │   └── server-config.interface.ts
│   ├── config.ts
│   ├── index.html
│   ├── main.browser.ts
│   ├── main.server.aot.ts
│   ├── main.server.ts
│   ├── modules
│   │   ── cookies
│   │   ├── data-loader
│   │   ├── transfer-http
│   │   ├── transfer-state
│   │   ├── transfer-store
│   │   └── translate-universal-loader.ts
│   ├── routes.ts
│   ├── styles
│   │   ├── _mixins.scss
│   │   └── variables.scss
│   ├── tsconfig.browser.json
│   ├── tsconfig.server.aot.json
│   ├── tsconfig.server.json
│   └── tsconfig.test.json
├── tsconfig.json
├── tslint.json
├── typedoc.json
├── webpack
│   ├── helpers.js
│   ├── webpack.client.js
│   ├── webpack.common.js
│   ├── webpack.prod.js
│   ├── webpack.server.js
│   └── webpack.test.js
├── webpack.config.ts
└── yarn.lock
```
3rd Party Library Installation

View File

@@ -1,12 +0,0 @@
{
"name": "Angular 2 Universal Starter",
"description": "Angular 2 Universal starter kit by @AngularClass",
"repository": "https://github.com/angular/universal-starter",
"logo": "https://cloud.githubusercontent.com/assets/1016365/10639063/138338bc-7806-11e5-8057-d34c75f3cafc.png",
"env": {
"NPM_CONFIG_PRODUCTION": {
"description": "Install `webpack` and other development modules when deploying to allow full builds.",
"value": "false"
}
}
}

17
app.yaml Normal file
View File

@@ -0,0 +1,17 @@
# Copyright 2015-2016, Google, Inc.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# [START app_yaml]
runtime: nodejs
env: flex
# [END app_yaml]

View File

@@ -1,28 +1,30 @@
module.exports = {
// The REST API server settings.
"rest": {
"ssl": false,
"address": "dspace7.4science.it",
"port": 80,
// NOTE: Space is capitalized because 'namespace' is a reserved string in TypeScript
"nameSpace": "/dspace-spring-rest/api"
},
// Angular2 UI server settings.
"ui": {
"ssl": false,
"address": "localhost",
"port": 3000,
ui: {
ssl: false,
host: 'localhost',
port: 3000,
// NOTE: Space is capitalized because 'namespace' is a reserved string in TypeScript
"nameSpace": "/"
nameSpace: '/'
},
"cache": {
// The REST API server settings.
rest: {
ssl: false,
host: 'dspace7.4science.it',
port: 80,
// NOTE: Space is capitalized because 'namespace' is a reserved string in TypeScript
nameSpace: '/dspace-spring-rest/api'
},
cache: {
// how long should objects be cached for by default
"msToLive": 15 * 60 * 1000, // 15 minute
"control": "max-age=60" // revalidate browser
msToLive: 15 * 60 * 1000, // 15 minute
control: 'max-age=60' // revalidate browser
},
"universal": {
// Angular Universal settings
"preboot": true,
"async": true
}
logDirectory: '.',
// NOTE: rehydrate or replay
// rehydrate will transfer prerender state to browser state, actions do not need to replay
// replay will transfer an array of actions to browser, actions replay automatically
prerenderStrategy: 'replay',
// NOTE: will log all redux actions and transfers in console
debug: true
};

View File

@@ -0,0 +1,30 @@
module.exports = {
// Angular2 UI server settings.
ui: {
ssl: false,
host: 'localhost',
port: 3000,
// NOTE: Space is capitalized because 'namespace' is a reserved string in TypeScript
nameSpace: '/'
},
// The REST API server settings.
rest: {
ssl: false,
host: 'dspace7.4science.it',
port: 80,
// NOTE: Space is capitalized because 'namespace' is a reserved string in TypeScript
nameSpace: '/dspace-spring-rest/api'
},
cache: {
// how long should objects be cached for by default
msToLive: 15 * 60 * 1000, // 15 minute
control: 'max-age=60' // revalidate browser
},
logDirectory: '.',
// NOTE: rehydrate or replay
// rehydrate will transfer prerender state to browser state, actions do not need to replay
// replay will transfer an array of actions to browser, actions replay automatically
prerenderStrategy: 'rehydrate',
// NOTE: will log all redux actions and transfers in console
debug: true
};

View File

@@ -1,6 +1,6 @@
import { ProtractorPage } from './app.po';
describe('protractor App', function() {
describe('protractor App', () => {
let page: ProtractorPage;
beforeEach(() => {
@@ -9,11 +9,11 @@ describe('protractor App', function() {
it('should display title "DSpace"', () => {
page.navigateTo();
expect(page.getPageTitleText()).toEqual('DSpace');
expect<any>(page.getPageTitleText()).toEqual('DSpace');
});
it('should display header "Welcome to DSpace"', () => {
page.navigateTo();
expect(page.getFirstHeaderText()).toEqual('Welcome to DSpace');
expect<any>(page.getFirstHeaderText()).toEqual('Welcome to DSpace');
});
});

View File

@@ -1,19 +1,19 @@
import { ProtractorPage } from './pagenotfound.po';
describe('protractor PageNotFound', function() {
describe('protractor PageNotFound', () => {
let page: ProtractorPage;
beforeEach(() => {
page = new ProtractorPage();
});
it('should contain element ds-pagenotfound when navigating to page that doesnt exist"', () => {
it('should contain element ds-pagenotfound when navigating to page that doesnt exist', () => {
page.navigateToNonExistingPage();
expect(page.elementTagExists("ds-pagenotfound")).toEqual(true);
expect<any>(page.elementTagExists('ds-pagenotfound')).toEqual(true);
});
it('should not contain element ds-pagenotfound when navigating to existing page"', () => {
it('should not contain element ds-pagenotfound when navigating to existing page', () => {
page.navigateToExistingPage();
expect(page.elementTagExists("ds-pagenotfound")).toEqual(false);
expect<any>(page.elementTagExists('ds-pagenotfound')).toEqual(false);
});
});

View File

@@ -1,8 +1,8 @@
import { browser, element, by } from 'protractor';
export class ProtractorPage {
HOMEPAGE : string = "/home";
NONEXISTINGPAGE : string = "/e9019a69-d4f1-4773-b6a3-bd362caa46f2";
HOMEPAGE = '/home';
NONEXISTINGPAGE = '/e9019a69-d4f1-4773-b6a3-bd362caa46f2';
navigateToNonExistingPage() {
return browser.get(this.NONEXISTINGPAGE);
@@ -11,9 +11,8 @@ export class ProtractorPage {
return browser.get(this.HOMEPAGE);
}
elementTagExists(tag : string) {
elementTagExists(tag: string) {
return element(by.tagName(tag)).isPresent();
}
}
}

View File

@@ -1,7 +0,0 @@
module.exports = {
NgProbeToken: {},
_createConditionalRootRenderer: function(rootRenderer, extraTokens, coreTokens) {
return rootRenderer;
},
__platform_browser_private__: {}
};

View File

@@ -1,24 +0,0 @@
/**
* @author: @AngularClass
*/
var path = require('path');
// Helper functions
var ROOT = path.resolve(__dirname, '.');
function hasProcessFlag(flag) {
return process.argv.join('').indexOf(flag) > -1;
}
function isWebpackDevServer() {
return process.argv[1] && !! (/webpack-dev-server/.exec(process.argv[1]));
}
function root(args) {
args = Array.prototype.slice.call(arguments, 0);
return path.join.apply(path, [ROOT].concat(args));
}
exports.hasProcessFlag = hasProcessFlag;
exports.isWebpackDevServer = isWebpackDevServer;
exports.root = root;

View File

@@ -2,9 +2,11 @@
* @author: @AngularClass
*/
module.exports = function(config) {
module.exports = function (config) {
var testWebpackConfig = require('./webpack.test.config.js')({env: 'test'});
var testWebpackConfig = require('./webpack/webpack.test.js')({
env: 'test'
});
// Uncomment and change to run tests on a remote Selenium server
var webdriverConfig = {
@@ -15,7 +17,7 @@ module.exports = function(config) {
var configuration = {
// base path that will be used to resolve all patterns (e.g. files, exclude)
basePath: '.',
basePath: '',
/*
* Frameworks to use
@@ -33,7 +35,8 @@ module.exports = function(config) {
require('karma-mocha-reporter'),
require('karma-remap-istanbul'),
require('karma-sourcemap-loader'),
require('karma-webpack')
require('karma-webpack'),
require("istanbul-instrumenter-loader")
],
// list of files to exclude
@@ -44,12 +47,10 @@ module.exports = function(config) {
*
* we are building the test environment in ./spec-bundle.js
*/
files: [
{
pattern: './spec-bundle.js',
watched: false
}
],
files: [{
pattern: './spec-bundle.js',
watched: false
}],
/*
* preprocess matching files before serving them to the browser
@@ -63,18 +64,16 @@ module.exports = function(config) {
webpack: testWebpackConfig,
coverageReporter: {
reporters: [
{
type: 'in-memory'
}, {
type: 'json',
subdir: '.',
file: 'coverage-final.json'
}, {
type: 'html',
dir: 'coverage/'
}
]
reporters: [{
type: 'in-memory'
}, {
type: 'json',
subdir: '.',
file: 'coverage-final.json'
}, {
type: 'html',
dir: 'coverage/'
}]
},
remapCoverageReporter: {
@@ -89,9 +88,24 @@ module.exports = function(config) {
}
},
// Webpack please don't spam the console when running in karma!
/**
* Webpack please don't spam the console when running in karma!
*/
webpackMiddleware: {
stats: 'errors-only'
/**
* webpack-dev-middleware configuration
* i.e.
*/
noInfo: true,
/**
* and use stats to turn off verbose output
*/
stats: {
/**
* options i.e.
*/
chunks: false
}
},
/*
@@ -114,10 +128,10 @@ module.exports = function(config) {
* level of logging
* possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
*/
logLevel: config.LOG_INFO,
logLevel: config.LOG_WARN,
// enable / disable watching file and executing tests whenever any file changes
//autoWatch: true,
autoWatch: false,
/*
* start these browsers
@@ -125,9 +139,6 @@ module.exports = function(config) {
*/
browsers: [
'Chrome'
//'ChromeTravisCi',
//'SeleniumChrome',
//'SeleniumFirefox'
],
customLaunchers: {
@@ -156,11 +167,6 @@ module.exports = function(config) {
browserNoActivityTimeout: 30000
/*
* Continuous Integration mode
* if true, Karma captures browsers, runs the tests and exits
*/
//singleRun: true
};
if (process.env.TRAVIS) {

View File

@@ -1,187 +1,197 @@
{
"name": "dspace-angular",
"version": "0.0.0",
"description": "Angular 2 Universal UI for DSpace",
"version": "0.0.1",
"description": "Angular Universal UI for DSpace",
"repository": {
"type": "git",
"url": "https://github.com/dspace/dspace-angular.git"
},
"license": "BSD-2-Clause",
"engines": {
"node": ">=5.0.0"
},
"scripts": {
"clean:log": "rimraf *.log*",
"clean:dist": "rimraf dist/*",
"clean:node": "rimraf node_modules",
"clean:ngc": "rimraf **/*.ngfactory.ts",
"clean:json": "rimraf *.records.json",
"clean:css": "rimraf src/**/*.css",
"clean:css:ts": "rimraf src/**/*.css.ts",
"clean:scss:ts": "rimraf src/**/*.scss.ts",
"clean:css:shim:ts": "rimraf src/**/*.css.shim.ts",
"clean:scss:shim:ts": "rimraf src/**/*.scss.shim.ts",
"global": "npm install -g @angular/cli marked node-gyp nodemon node-nightly npm-check-updates npm-run-all rimraf typescript ts-node typedoc webpack webpack-bundle-analyzer pm2 rollup",
"clean:coverage": "rimraf coverage",
"clean:prod": "yarn run clean:ngc && yarn run clean:json && yarn run clean:css && yarn run clean:css:ts && yarn run clean:scss:ts && yarn run clean:css:shim:ts && yarn run clean:scss:shim:ts && yarn run clean:dist",
"clean": "yarn run clean:log && yarn run clean:prod && yarn run clean:coverage && yarn run clean:node",
"sass": "node-sass src -o src --include-path node_modules --output-style compressed -q",
"postcss": "node node_modules/postcss-cli/bin/postcss -c postcss.config.json",
"style": "yarn run sass && yarn run postcss",
"style:watch": "nodemon -e scss -w src -x \"yarn run style\"",
"rollup": "rollup -c rollup-server.js && rollup -c rollup-client.js",
"prebuild": "yarn run clean:dist && yarn run style",
"clean:dist": "rimraf dist",
"clean:doc": "rimraf doc",
"clean:log": "rimraf *.log*",
"clean:json": "rimraf *.records.json",
"clean:node": "rimraf node_modules",
"clean:prod": "yarn run clean:coverage && yarn run clean:doc && yarn run clean:dist && yarn run clean:log && yarn run clean:json ",
"clean": "yarn run clean:prod && yarn run clean:node",
"prebuild": "yarn run clean:dist",
"prebuild:aot": "yarn run prebuild",
"prebuild:prod": "yarn run prebuild",
"build": "webpack --progress",
"build:prod": "webpack --config webpack.prod.config.ts",
"build:prod:rollup": "yarn run build:prod && yarn run rollup",
"build:prod:ngc": "yarn run clean:prod && yarn run style && yarn run ngc && yarn run build:prod:rollup",
"build:prod:ngc:json": "yarn run clean:prod && yarn run style && yarn run ngc && yarn run build:prod:json:rollup",
"build:prod:json": "webpack --config webpack.prod.config.ts --json | webpack-bundle-size-analyzer",
"build:prod:json:rollup": "yarn run build:prod:json && yarn run rollup",
"ngc": "ngc -p tsconfig.aot.json",
"prestart": "yarn run build:prod:ngc:json",
"server": "node dist/server/index.js",
"server:dev": "node dist/server/index.js",
"server:dev:watch": "nodemon --debug dist/server/index.js",
"build:aot": "webpack --env.aot --env.server && webpack --env.aot --env.client",
"build:prod": "webpack --env.aot --env.server -p && webpack --env.aot --env.client -p",
"postbuild:prod": "yarn run rollup",
"rollup": "rollup -c rollup.config.js",
"prestart": "yarn run build:prod",
"prestart:dev": "yarn run build",
"start": "yarn run server",
"start:dev": "yarn run clean:prod && yarn run build && yarn run server:dev",
"watch": "webpack -w & yarn run style:watch",
"watch:dev:server": "npm-run-all -p server:dev:watch watch",
"watch:dev": "yarn run clean:prod && yarn run build && yarn run watch:dev:server",
"watch:prod:server": "npm-run-all -p server watch",
"watch:prod": "yarn run build:prod:ngc:json && yarn run watch:prod:server",
"start:dev": "yarn run server",
"deploy": "pm2 start dist/server.js",
"predeploy": "npm run build:prod",
"preundeploy": "pm2 stop dist/server.js",
"undeploy": "pm2 delete dist/server.js",
"postundeploy": "npm run clean:dist",
"server": "node dist/server.js",
"server:watch": "nodemon dist/server.js",
"server:watch:debug": "nodemon --debug dist/server.js",
"webpack:watch": "webpack -w",
"webpack:watch:aot": "webpack -w --env.aot --env.server && webpack -w --env.aot --env.client",
"webpack:watch:prod": "webpack -w --env.aot --env.server -p && webpack -w --env.aot --env.client -p",
"watch": "yarn run build && npm-run-all -p webpack:watch server:watch",
"watch:aot": "yarn run build:aot && npm-run-all -p webpack:watch:aot server:watch",
"watch:prod": "yarn run build:prod && npm-run-all -p webpack:watch:prod server:watch",
"watch:debug": "yarn run build && npm-run-all -p webpack:watch server:watch:debug",
"watch:debug:aot": "yarn run build:aot && npm-run-all -p webpack:watch:aot server:watch:debug",
"watch:debug:prod": "yarn run build:prod && npm-run-all -p webpack:watch:prod server:watch:debug",
"predebug": "yarn run build",
"debug": "node --debug-brk dist/server/index.js",
"debug:server": "node-nightly --inspect --debug-brk dist/server/index.js",
"debug:start": "yarn run build && yarn run debug:server",
"predebug:server": "yarn run build",
"debug": "node --debug-brk dist/server.js",
"debug:server": "node-nightly --inspect --debug-brk dist/server.js",
"debug:build": "node-nightly --inspect --debug-brk node_modules/webpack/bin/webpack.js",
"debug:build:prod": "node-nightly --inspect --debug-brk node_modules/webpack/bin/webpack.js --config webpack.prod.config.ts",
"docs": "typedoc --options typedoc.json ./src/",
"lint": "tslint \"src/**/*.ts\" || true",
"global": "npm install -g @angular/cli nodemon npm-check-updates rimraf ts-node typedoc typescript webpack webpack-bundle-size-analyzer rollup marked node-gyp",
"ci": "yarn run lint && yarn run build:prod:ngc:json && yarn run test && npm-run-all -p -r server e2e",
"debug:build:prod": "node-nightly --inspect --debug-brk node_modules/webpack/bin/webpack.js --env.aot --env.client --env.server -p",
"ci": "yarn run lint && yarn run build:aot && yarn run test && npm-run-all -p -r server e2e",
"protractor": "node node_modules/protractor/bin/protractor",
"pree2e": "yarn run webdriver:update",
"e2e": "yarn run protractor",
"test": "karma start --single-run",
"test:watch": "karma start --no-single-run --auto-watch",
"coverage": "http-server -c-1 -o -p 9875 ./coverage",
"webdriver:start": "node node_modules/protractor/bin/webdriver-manager start --seleniumPort 4444",
"webdriver:update": "node node_modules/protractor/bin/webdriver-manager update --standalone"
"webdriver:update": "node node_modules/protractor/bin/webdriver-manager update --standalone",
"lint": "tslint \"src/**/*.ts\" || true && tslint \"e2e/**/*.ts\" || true",
"docs": "typedoc --options typedoc.json ./src/",
"coverage": "http-server -c-1 -o -p 9875 ./coverage"
},
"dependencies": {
"@angular/common": "2.2.3",
"@angular/compiler": "2.2.3",
"@angular/compiler-cli": "2.2.3",
"@angular/core": "2.2.3",
"@angular/forms": "2.2.3",
"@angular/http": "2.2.3",
"@angular/platform-browser": "2.2.3",
"@angular/platform-browser-dynamic": "2.2.3",
"@angular/platform-server": "2.2.3",
"@angular/router": "3.2.3",
"@angular/upgrade": "2.2.3",
"@angular/animations": "4.2.6",
"@angular/common": "4.2.6",
"@angular/core": "4.2.6",
"@angular/forms": "4.2.6",
"@angular/http": "4.2.6",
"@angular/platform-browser": "4.2.6",
"@angular/platform-browser-dynamic": "4.2.6",
"@angular/platform-server": "4.2.6",
"@angular/router": "4.2.6",
"@angularclass/bootloader": "1.0.1",
"@angularclass/idle-preload": "1.0.4",
"@ng-bootstrap/ng-bootstrap": "1.0.0-alpha.18",
"@ngrx/core": "^1.2.0",
"@ngrx/effects": "2.0.2",
"@ngrx/router-store": "^1.2.5",
"@ngrx/store": "^2.2.1",
"@ngrx/store-devtools": "^3.2.2",
"@ngx-translate/core": "^6.0.1",
"@ngx-translate/http-loader": "^0.0.3",
"@types/jsonschema": "0.0.5",
"angular2-express-engine": "2.1.0-rc.1",
"angular2-platform-node": "2.1.0-rc.1",
"angular2-universal": "2.1.0-rc.1",
"angular2-universal-polyfills": "2.1.0-rc.1",
"body-parser": "1.15.2",
"@ng-bootstrap/ng-bootstrap": "1.0.0-alpha.28",
"@ngrx/core": "1.2.0",
"@ngrx/effects": "2.0.4",
"@ngrx/router-store": "1.2.6",
"@ngrx/store": "2.2.3",
"@nguniversal/express-engine": "1.0.0-beta.2",
"@ngx-translate/core": "7.0.0",
"@ngx-translate/http-loader": "0.1.0",
"body-parser": "1.17.2",
"bootstrap": "4.0.0-alpha.6",
"cerialize": "^0.1.13",
"compression": "1.6.2",
"express": "4.14.0",
"cerialize": "0.1.15",
"compression": "1.7.0",
"cookie-parser": "1.4.3",
"core-js": "2.4.1",
"express": "4.15.3",
"express-session": "1.15.3",
"font-awesome": "4.7.0",
"http-server": "^0.9.0",
"http-server": "0.10.0",
"https": "1.0.0",
"js.clone": "0.0.3",
"jsonschema": "^1.1.1",
"jsonschema": "1.1.1",
"methods": "1.1.2",
"morgan": "1.7.0",
"ng2-pagination": "^2.0.0",
"preboot": "4.5.2",
"reflect-metadata": "^0.1.10",
"rxjs": "5.0.0-beta.12",
"ts-md5": "^1.2.0",
"webfontloader": "1.6.27",
"zone.js": "0.6.26"
"morgan": "1.8.2",
"ng2-pagination": "2.0.2",
"pem": "1.9.7",
"reflect-metadata": "0.1.10",
"rxjs": "5.4.2",
"ts-md5": "1.2.0",
"webfontloader": "1.6.28",
"zone.js": "0.8.12"
},
"devDependencies": {
"@ngtools/webpack": "1.1.9",
"@types/body-parser": "0.0.33",
"@types/compression": "0.0.33",
"@angular/compiler": "4.2.6",
"@angular/compiler-cli": "4.2.6",
"@ngrx/store-devtools": "3.2.4",
"@ngtools/webpack": "1.5.0",
"@types/cookie-parser": "1.3.30",
"@types/deep-freeze": "0.0.29",
"@types/express": "4.0.34",
"@types/express-serve-static-core": "4.0.39",
"@types/hammerjs": "2.0.33",
"@types/jasmine": "2.5.41",
"@types/deep-freeze": "0.1.1",
"@types/express": "4.0.36",
"@types/express-serve-static-core": "4.0.49",
"@types/hammerjs": "2.0.34",
"@types/jasmine": "2.5.53",
"@types/lodash": "ts2.0",
"@types/memory-cache": "0.0.29",
"@types/mime": "0.0.29",
"@types/morgan": "1.7.32",
"@types/node": "6.0.52",
"@types/mime": "1.3.1",
"@types/node": "8.0.10",
"@types/serve-static": "1.7.31",
"@types/webfontloader": "1.6.27",
"ajv": "4.2.0",
"ajv-keywords": "1.1.1",
"angular2-template-loader": "0.6.0",
"autoprefixer": "6.5.4",
"awesome-typescript-loader": "2.2.4",
"codelyzer": "2.0.0-beta.3",
"cookie-parser": "1.4.3",
"@types/source-map": "0.5.0",
"@types/webfontloader": "1.6.28",
"ajv": "5.2.2",
"ajv-keywords": "2.1.0",
"angular2-template-loader": "0.6.2",
"autoprefixer": "7.1.2",
"awesome-typescript-loader": "3.2.1",
"codelyzer": "3.1.2",
"compression-webpack-plugin": "0.4.0",
"copy-webpack-plugin": "4.0.1",
"css-loader": "^0.26.0",
"css-loader": "0.28.4",
"deep-freeze": "0.0.1",
"html-webpack-plugin": "^2.21.0",
"imports-loader": "0.7.0",
"istanbul-instrumenter-loader": "^0.2.0",
"jasmine-core": "~2.5.2",
"jasmine-spec-reporter": "~2.7.0",
"exports-loader": "0.6.4",
"html-webpack-plugin": "2.29.0",
"imports-loader": "0.7.1",
"istanbul-instrumenter-loader": "2.0.0",
"jasmine-core": "2.6.4",
"jasmine-spec-reporter": "4.1.1",
"json-loader": "0.5.4",
"karma": "^1.2.0",
"karma-chrome-launcher": "^2.0.0",
"karma-cli": "^1.0.1",
"karma-coverage": "^1.1.1",
"karma-jasmine": "^1.0.2",
"karma-mocha-reporter": "^2.0.0",
"karma-phantomjs-launcher": "^1.0.2",
"karma-remap-istanbul": "^0.2.1",
"karma-sourcemap-loader": "^0.3.7",
"karma-webdriver-launcher": "^1.0.4",
"karma-webpack": "1.8.0",
"ngrx-store-freeze": "^0.1.9",
"node-sass": "4.0.0",
"karma": "1.7.0",
"karma-chrome-launcher": "2.2.0",
"karma-cli": "1.0.1",
"karma-coverage": "1.1.1",
"karma-jasmine": "1.1.0",
"karma-mocha-reporter": "2.2.3",
"karma-phantomjs-launcher": "1.0.4",
"karma-remap-istanbul": "0.6.0",
"karma-sourcemap-loader": "0.3.7",
"karma-webdriver-launcher": "1.0.5",
"karma-webpack": "2.0.4",
"ngrx-store-freeze": "0.1.9",
"node-sass": "4.5.3",
"nodemon": "1.11.0",
"npm-run-all": "4.0.2",
"postcss-cli": "^2.6.0",
"protractor": "~4.0.14",
"protractor-istanbul-plugin": "~2.0.0",
"postcss": "6.0.6",
"postcss-apply": "0.8.0",
"postcss-cli": "4.1.0",
"postcss-cssnext": "3.0.2",
"postcss-loader": "2.0.6",
"postcss-responsive-type": "0.5.1",
"postcss-smart-import": "0.7.5",
"protractor": "5.1.2",
"protractor-istanbul-plugin": "2.0.0",
"raw-loader": "0.5.1",
"rimraf": "2.5.4",
"rollup": "0.37.0",
"rollup-plugin-commonjs": "6.0.0",
"resolve-url-loader": "2.1.0",
"rimraf": "2.6.1",
"rollup": "0.45.1",
"rollup-plugin-commonjs": "8.0.2",
"rollup-plugin-node-globals": "1.1.0",
"rollup-plugin-node-resolve": "2.0.0",
"rollup-plugin-uglify": "1.0.1",
"source-map-loader": "^0.1.5",
"string-replace-loader": "1.0.5",
"to-string-loader": "^1.1.4",
"rollup-plugin-node-resolve": "3.0.0",
"rollup-plugin-uglify": "2.0.1",
"sass-loader": "6.0.6",
"script-ext-html-webpack-plugin": "1.8.3",
"source-map-loader": "0.2.1",
"string-replace-loader": "1.3.0",
"to-string-loader": "1.1.5",
"ts-helpers": "1.1.2",
"ts-node": "1.7.2",
"tslint": "4.0.2",
"tslint-loader": "3.3.0",
"typedoc": "0.5.7",
"typescript": "2.0.10",
"v8-lazy-parse-webpack-plugin": "0.3.0",
"webpack": "2.1.0-beta.27",
"webpack-bundle-analyzer": "1.4.1",
"webpack-dev-middleware": "1.9.0",
"webpack-dev-server": "2.1.0-beta.11",
"webpack-merge": "1.1.1"
"ts-node": "3.2.0",
"tslint": "5.1.0",
"tslint-loader": "3.5.3",
"typedoc": "0.7.1",
"typescript": "2.4.1",
"webpack": "2.6.1",
"webpack-bundle-analyzer": "2.8.2",
"webpack-dev-middleware": "1.11.0",
"webpack-dev-server": "2.5.1",
"webpack-merge": "4.1.0"
}
}

8
postcss.config.js Normal file
View File

@@ -0,0 +1,8 @@
module.exports = {
plugins: [
require('postcss-smart-import')(),
require('postcss-cssnext')(),
require('postcss-apply')(),
require('postcss-responsive-type')()
]
};

View File

@@ -1,9 +0,0 @@
{
"use": ["autoprefixer"],
"input": "src/**/*.css",
"replace": true,
"local-plugins": true,
"autoprefixer": {
"browsers": "last 2 versions"
}
}

View File

@@ -2,7 +2,7 @@
// https://github.com/angular/protractor/blob/master/docs/referenceConf.js
/*global jasmine */
var SpecReporter = require('jasmine-spec-reporter');
var SpecReporter = require('jasmine-spec-reporter').SpecReporter;
exports.config = {
allScriptsTimeout: 11000,
@@ -28,11 +28,11 @@ exports.config = {
// -----------------------------------------------------------------
// Browser and Capabilities: Chrome
// -----------------------------------------------------------------
capabilities: {
'browserName': 'chrome',
'version': '',
'platform': 'ANY'
},
capabilities: {
'browserName': 'chrome',
'version': '',
'platform': 'ANY'
},
// -----------------------------------------------------------------
// Browser and Capabilities: Firefox
// -----------------------------------------------------------------
@@ -63,7 +63,7 @@ exports.config = {
// }
//],
plugins : [{
plugins: [{
path: 'node_modules/protractor-istanbul-plugin'
}],
@@ -71,15 +71,19 @@ exports.config = {
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 30000,
print: function() {}
print: function () {}
},
useAllAngular2AppRoots: true,
beforeLaunch: function() {
beforeLaunch: function () {
require('ts-node').register({
project: 'e2e'
});
},
onPrepare: function() {
jasmine.getEnv().addReporter(new SpecReporter());
onPrepare: function () {
jasmine.getEnv().addReporter(new SpecReporter({
spec: {
displayStacktrace: true
}
}));
}
};

0
resources/data/.gitkeep Normal file
View File

View File

View File

@@ -0,0 +1,5 @@
{
"test": {
"message": "Hello, DSpace!"
}
}

View File

@@ -1,16 +0,0 @@
import rollup from 'rollup'
import nodeResolve from 'rollup-plugin-node-resolve'
import commonjs from 'rollup-plugin-commonjs';
import uglify from 'rollup-plugin-uglify'
export default {
entry : 'dist/client/main.bundle.js',
dest : 'dist/client/main.bundle.js',
sourceMap : false,
format : 'iife',
plugins : [
nodeResolve({jsnext: true, module: true}),
commonjs({include: 'node_modules/rxjs/**'}),
uglify()
]
}

View File

@@ -1,16 +0,0 @@
import rollup from 'rollup'
import nodeResolve from 'rollup-plugin-node-resolve'
import commonjs from 'rollup-plugin-commonjs';
import uglify from 'rollup-plugin-uglify'
export default {
entry : 'dist/server/index.js',
dest : 'dist/server/index.js',
sourceMap : false,
format : 'iife',
plugins : [
nodeResolve({jsnext: true, module: true}),
commonjs({include: 'node_modules/rxjs/**'}),
uglify()
]
}

21
rollup.config.js Normal file
View File

@@ -0,0 +1,21 @@
import rollup from 'rollup'
import nodeResolve from 'rollup-plugin-node-resolve'
import commonjs from 'rollup-plugin-commonjs';
import uglify from 'rollup-plugin-uglify'
export default {
entry: 'dist/client.js',
dest: 'dist/client.js',
sourceMap: false,
format: 'iife',
plugins: [
nodeResolve({
jsnext: true,
module: true
}),
commonjs({
include: 'node_modules/rxjs/**'
}),
uglify()
]
}

View File

@@ -2,6 +2,7 @@ import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router';
import { PageNotFoundComponent } from './pagenotfound/pagenotfound.component';
@NgModule({
imports: [
RouterModule.forChild([

View File

@@ -1,4 +1,13 @@
@import '../styles/variables.scss';
@import '../../node_modules/bootstrap/scss/bootstrap.scss';
@import "../../node_modules/font-awesome/scss/font-awesome.scss";
html {
position: relative;
min-height: 100%;
}
// Sticky Footer
.outer-wrapper {
display: flex;
margin: 0;

View File

@@ -5,23 +5,32 @@ import {
inject,
TestBed
} from '@angular/core/testing';
import {
CUSTOM_ELEMENTS_SCHEMA,
DebugElement
} from "@angular/core";
import { CommonModule } from '@angular/common';
import { By } from '@angular/platform-browser';
import { TranslateModule, TranslateLoader } from "@ngx-translate/core";
import { Store, StoreModule } from "@ngrx/store";
// Load the implementations that should be tested
import { AppComponent } from './app.component';
import { CommonModule } from '@angular/common';
import { HostWindowState } from "./shared/host-window.reducer";
import { HostWindowResizeAction } from "./shared/host-window.actions";
import { MockTranslateLoader } from "./shared/testing/mock-translate-loader";
import { GLOBAL_CONFIG, EnvConfig } from '../config';
import { BrowserCookiesModule } from '../modules/cookies/browser-cookies.module';
import { BrowserDataLoaderModule } from '../modules/data-loader/browser-data-loader.module';
import { BrowserTransferStateModule } from '../modules/transfer-state/browser-transfer-state.module';
import { BrowserTransferStoreModule } from '../modules/transfer-store/browser-transfer-store.module';
import { GLOBAL_CONFIG, ENV_CONFIG } from '../config';
import { NativeWindowRef, NativeWindowService } from "./shared/window.service";
let comp: AppComponent;
@@ -34,15 +43,23 @@ describe('App component', () => {
// async beforeEach
beforeEach(async(() => {
return TestBed.configureTestingModule({
imports: [CommonModule, StoreModule.provideStore({}), TranslateModule.forRoot({
loader: {
provide: TranslateLoader,
useClass: MockTranslateLoader
}
})],
imports: [
CommonModule,
StoreModule.provideStore({}),
TranslateModule.forRoot({
loader: {
provide: TranslateLoader,
useClass: MockTranslateLoader
}
}),
BrowserCookiesModule,
BrowserDataLoaderModule,
BrowserTransferStateModule,
BrowserTransferStoreModule
],
declarations: [AppComponent], // declare the test component
providers: [
{ provide: GLOBAL_CONFIG, useValue: EnvConfig },
{ provide: GLOBAL_CONFIG, useValue: ENV_CONFIG },
{ provide: NativeWindowService, useValue: new NativeWindowRef() },
AppComponent
],

View File

@@ -1,31 +1,37 @@
import {
Component,
ChangeDetectionStrategy,
Inject,
ViewEncapsulation,
OnInit, HostListener
OnInit,
HostListener
} from "@angular/core";
import { TranslateService } from "@ngx-translate/core";
import { HostWindowState } from "./shared/host-window.reducer";
import { Store } from "@ngrx/store";
import { TransferState } from '../modules/transfer-state/transfer-state';
import { HostWindowState } from "./shared/host-window.reducer";
import { HostWindowResizeAction } from "./shared/host-window.actions";
import { EnvConfig, GLOBAL_CONFIG, GlobalConfig } from '../config';
import { NativeWindowRef, NativeWindowService } from "./shared/window.service";
import { GLOBAL_CONFIG, GlobalConfig } from '../config';
@Component({
changeDetection: ChangeDetectionStrategy.Default,
encapsulation: ViewEncapsulation.Emulated,
selector: 'ds-app',
encapsulation: ViewEncapsulation.None,
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
styleUrls: ['./app.component.scss']
})
export class AppComponent implements OnInit {
constructor(
@Inject(GLOBAL_CONFIG) public EnvConfig: GlobalConfig,
@Inject(GLOBAL_CONFIG) public config: GlobalConfig,
@Inject(NativeWindowService) private _window: NativeWindowRef,
private translate: TranslateService,
private cache: TransferState,
private store: Store<HostWindowState>
) {
// this language will be used as a fallback when a translation isn't found in the current language
@@ -34,11 +40,20 @@ export class AppComponent implements OnInit {
translate.use('en');
}
ngAfterViewChecked() {
this.syncCache();
}
syncCache() {
this.store.take(1).subscribe((state: HostWindowState) => {
this.cache.set('state', state);
});
}
ngOnInit() {
this.onInit();
const env: string = EnvConfig.production ? "Production" : "Development";
const color: string = EnvConfig.production ? "red" : "green";
console.info(`Environment: %c${env}`, `color: ${color}; font-weight: bold;`);
const env: string = this.config.production ? "Production" : "Development";
const color: string = this.config.production ? "red" : "green";
console.info(`Environment: %c${env}`, `color: ${color}; font-weight: bold;`);
}
@HostListener('window:resize', ['$event'])
@@ -48,12 +63,4 @@ export class AppComponent implements OnInit {
);
}
private onInit(): void {
if (typeof this._window !== 'undefined') {
this.store.dispatch(
new HostWindowResizeAction(this._window.nativeWindow.innerWidth, this._window.nativeWindow.innerHeight)
);
}
}
}

View File

@@ -1,8 +1,10 @@
import { EffectsModule } from "@ngrx/effects";
import { HeaderEffects } from "./header/header.effects";
import { StoreEffects } from "./store.effects";
import { coreEffects } from "./core/core.effects";
export const effects = [
...coreEffects, //TODO should probably be imported in coreModule
EffectsModule.run(StoreEffects),
EffectsModule.run(HeaderEffects)
];

View File

@@ -1,38 +1,63 @@
import { NgModule } from '@angular/core';
import { HttpModule } from '@angular/http';
import { FormsModule } from '@angular/forms';
import { StoreModule, Store } from "@ngrx/store";
import { RouterStoreModule } from "@ngrx/router-store";
import { StoreDevtoolsModule } from "@ngrx/store-devtools";
import { rootReducer, AppState } from './app.reducer';
import { effects } from './app.effects';
import { CoreModule } from './core/core.module';
import { HomeModule } from './home/home.module';
import { ItemPageModule } from './item-page/item-page.module';
import { SharedModule } from './shared/shared.module';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { HeaderComponent } from './header/header.component';
import { TransferHttpModule } from '../modules/transfer-http/transfer-http.module';
import { HomeModule } from './home/home.module';
import { ItemPageModule } from './item-page/item-page.module';
import { CollectionPageModule } from './collection-page/collection-page.module';
import { CommunityPageModule } from './community-page/community-page.module';
import { AppComponent } from './app.component';
import { HeaderComponent } from './header/header.component';
import { PageNotFoundComponent } from './pagenotfound/pagenotfound.component';
import { GLOBAL_CONFIG, ENV_CONFIG } from '../config';
export function getConfig() {
return ENV_CONFIG;
}
@NgModule({
imports: [
SharedModule,
FormsModule,
CoreModule.forRoot(),
HttpModule,
TransferHttpModule,
HomeModule,
ItemPageModule,
CollectionPageModule,
CommunityPageModule,
AppRoutingModule,
StoreModule.provideStore(rootReducer),
RouterStoreModule.connectRouter(),
StoreDevtoolsModule.instrumentOnlyWithExtension(),
effects
],
providers: [
{ provide: GLOBAL_CONFIG, useFactory: (getConfig) },
],
declarations: [
AppComponent,
HeaderComponent,
PageNotFoundComponent,
],
imports: [
SharedModule,
HomeModule,
ItemPageModule,
CollectionPageModule,
CommunityPageModule,
CoreModule.forRoot(),
AppRoutingModule
],
providers: [
]
exports: [AppComponent]
})
export class AppModule {
}
export { AppComponent } from './app.component';
}

View File

@@ -1,4 +1,4 @@
import { combineReducers } from "@ngrx/store";
import { combineReducers, ActionReducer } from "@ngrx/store";
import { routerReducer, RouterState } from "@ngrx/router-store";
import { headerReducer, HeaderState } from './header/header.reducer';
import { hostWindowReducer, HostWindowState } from "./shared/host-window.reducer";
@@ -7,7 +7,7 @@ import { storeFreeze } from 'ngrx-store-freeze';
import { compose } from "@ngrx/core";
import { StoreActionTypes } from "./store.actions";
import { EnvConfig } from '../config';
import { ENV_CONFIG } from '../config';
export interface AppState {
core: CoreState;
@@ -24,16 +24,20 @@ export const reducers = {
};
export function rootReducer(state: any, action: any) {
let output;
if (action.type === StoreActionTypes.REHYDRATE) {
state = action.payload;
switch (action.type) {
case StoreActionTypes.REHYDRATE:
state = Object.assign({}, state, action.payload);
break;
case StoreActionTypes.REPLAY:
break;
default:
}
if (EnvConfig.production) {
output = combineReducers(reducers)(state, action);
let root: ActionReducer<any>;
// TODO: attempt to not use InjectionToken GLOBAL_CONFIG over GlobalConfig ENV_CONFIG
if (ENV_CONFIG.production) {
root = combineReducers(reducers)(state, action);
} else {
output = compose(storeFreeze, combineReducers)(reducers)(state, action);
root = compose(storeFreeze, combineReducers)(reducers)(state, action);
}
return output;
return root;
}
export const NGRX_CACHE_KEY = "NGRX_STORE";

View File

@@ -0,0 +1,76 @@
import { NgModule, APP_INITIALIZER } from '@angular/core';
import { Http } from '@angular/http';
import { RouterModule } from '@angular/router';
import { BrowserModule } from '@angular/platform-browser';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { IdlePreload, IdlePreloadModule } from '@angularclass/idle-preload';
import { TranslateModule, TranslateLoader } from '@ngx-translate/core';
import { TranslateHttpLoader } from '@ngx-translate/http-loader';
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
import { EffectsModule } from '@ngrx/effects';
import { TransferState } from '../modules/transfer-state/transfer-state';
import { BrowserCookiesModule } from '../modules/cookies/browser-cookies.module';
import { BrowserDataLoaderModule } from '../modules/data-loader/browser-data-loader.module';
import { BrowserTransferStateModule } from '../modules/transfer-state/browser-transfer-state.module';
import { BrowserTransferStoreEffects } from '../modules/transfer-store/browser-transfer-store.effects';
import { BrowserTransferStoreModule } from '../modules/transfer-store/browser-transfer-store.module';
import { SharedModule } from './shared/shared.module';
import { CoreModule } from './core/core.module';
import { AppModule } from './app.module';
import { AppComponent } from './app.component';
export function init(cache: TransferState) {
return () => {
cache.initialize();
};
}
export function HttpLoaderFactory(http: Http) {
return new TranslateHttpLoader(http, 'assets/i18n/', '.json');
}
@NgModule({
bootstrap: [AppComponent],
imports: [
BrowserModule.withServerTransition({
appId: 'ds-app-id'
}),
IdlePreloadModule.forRoot(), // forRoot ensures the providers are only created once
RouterModule.forRoot([], { useHash: false, preloadingStrategy: IdlePreload }),
TranslateModule.forRoot({
loader: {
provide: TranslateLoader,
useFactory: HttpLoaderFactory,
deps: [Http]
}
}),
NgbModule.forRoot(),
BrowserCookiesModule,
BrowserDataLoaderModule,
BrowserTransferStateModule,
BrowserTransferStoreModule,
EffectsModule.run(BrowserTransferStoreEffects),
BrowserAnimationsModule,
AppModule
],
providers: [
{
provide: APP_INITIALIZER,
multi: true,
useFactory: init,
deps: [
TransferState
]
}
]
})
export class BrowserAppModule {
}

View File

@@ -18,7 +18,7 @@ import { hasValue } from "../shared/empty.util";
@Component({
selector: 'ds-collection-page',
styleUrls: ['./collection-page.component.css'],
styleUrls: ['./collection-page.component.scss'],
templateUrl: './collection-page.component.html',
changeDetection: ChangeDetectionStrategy.OnPush
})
@@ -26,8 +26,8 @@ export class CollectionPageComponent implements OnInit, OnDestroy {
collectionData: RemoteData<Collection>;
itemData: RemoteData<Item[]>;
logoData: RemoteData<Bitstream>;
config : PaginationComponentOptions;
sortConfig : SortOptions;
config: PaginationComponentOptions;
sortConfig: SortOptions;
private subs: Subscription[] = [];
private collectionId: string;
@@ -41,7 +41,7 @@ export class CollectionPageComponent implements OnInit, OnDestroy {
}
ngOnInit(): void {
this.subs.push(this.route.params.map((params: Params) => params['id'] )
this.subs.push(this.route.params.map((params: Params) => params['id'])
.subscribe((id: string) => {
this.collectionId = id;
this.collectionData = this.collectionDataService.findById(this.collectionId);
@@ -50,9 +50,9 @@ export class CollectionPageComponent implements OnInit, OnDestroy {
this.config = new PaginationComponentOptions();
this.config.id = "collection-browse";
this.config.pageSizeOptions = [ 4 ];
this.config.pageSizeOptions = [4];
this.config.pageSize = 4;
this.sortConfig = new SortOptions();
this.sortConfig = new SortOptions();
this.updateResults();
}));

View File

@@ -2,17 +2,17 @@
<!-- Community name -->
<ds-comcol-page-header [name]="(communityData.payload | async)?.name"></ds-comcol-page-header>
<!-- Community logo -->
<ds-comcol-page-logo *ngIf="logoData"
<ds-comcol-page-logo *ngIf="logoData"
[logo]="logoData.payload | async"
[alternateText]="'Community Logo'">
</ds-comcol-page-logo>
<!-- Introductionary text -->
<ds-comcol-page-content
<ds-comcol-page-content
[content]="(communityData.payload | async)?.introductoryText"
[hasInnerHtml]="true">
</ds-comcol-page-content>
<!-- News -->
<ds-comcol-page-content
<ds-comcol-page-content
[content]="(communityData.payload | async)?.sidebarText"
[hasInnerHtml]="true"
[title]="'community.page.news'">
@@ -21,6 +21,6 @@
<ds-comcol-page-content
[content]="(communityData.payload | async)?.copyrightText"
[hasInnerHtml]="true">
</ds-comcol-page-content>
</ds-comcol-page-content>
<ds-community-page-sub-collection-list></ds-community-page-sub-collection-list>
</div>

View File

@@ -10,7 +10,7 @@ import { hasValue } from "../shared/empty.util";
@Component({
selector: 'ds-community-page',
styleUrls: ['./community-page.component.css'],
styleUrls: ['./community-page.component.scss'],
templateUrl: './community-page.component.html',
})
export class CommunityPageComponent implements OnInit, OnDestroy {
@@ -34,9 +34,9 @@ export class CommunityPageComponent implements OnInit, OnDestroy {
}
ngOnDestroy(): void {
this.subs
.filter(sub => hasValue(sub))
.forEach(sub => sub.unsubscribe());
this.subs
.filter(sub => hasValue(sub))
.forEach(sub => sub.unsubscribe());
}
universalInit() {

View File

@@ -1 +1 @@
@import '../../../styles/variables.scss';
@import '../../../styles/variables.scss';

View File

@@ -5,24 +5,24 @@ import { Collection } from "../../core/shared/collection.model";
@Component({
selector: 'ds-community-page-sub-collection-list',
styleUrls: ['./community-page-sub-collection-list.component.css'],
templateUrl: './community-page-sub-collection-list.component.html',
selector: 'ds-community-page-sub-collection-list',
styleUrls: ['./community-page-sub-collection-list.component.scss'],
templateUrl: './community-page-sub-collection-list.component.html',
})
export class CommunityPageSubCollectionListComponent implements OnInit {
subCollections: RemoteData<Collection[]>;
subCollections: RemoteData<Collection[]>;
constructor(
private cds: CollectionDataService
) {
this.universalInit();
}
constructor(
private cds: CollectionDataService
) {
this.universalInit();
}
universalInit() {
universalInit() {
}
}
ngOnInit(): void {
this.subCollections = this.cds.findAll();
}
ngOnInit(): void {
this.subCollections = this.cds.findAll();
}
}

View File

@@ -8,21 +8,21 @@ const relationshipKey = Symbol("relationship");
const relationshipMap = new Map();
export const mapsTo = function(value: GenericConstructor<CacheableObject>) {
export function mapsTo(value: GenericConstructor<CacheableObject>) {
return Reflect.metadata(mapsToMetadataKey, value);
};
export const getMapsTo = function(target: any) {
export function getMapsTo(target: any) {
return Reflect.getOwnMetadata(mapsToMetadataKey, target);
};
export const relationship = function(value: ResourceType, isList: boolean = false): any {
return function (target: any, propertyKey: string, descriptor: PropertyDescriptor) {
export function relationship(value: ResourceType, isList: boolean = false): any {
return function(target: any, propertyKey: string, descriptor: PropertyDescriptor) {
if (!target || !propertyKey) {
return;
}
let metaDataList : Array<string> = relationshipMap.get(target.constructor) || [];
let metaDataList: Array<string> = relationshipMap.get(target.constructor) || [];
if (metaDataList.indexOf(propertyKey) === -1) {
metaDataList.push(propertyKey);
}
@@ -32,10 +32,10 @@ export const relationship = function(value: ResourceType, isList: boolean = fals
};
};
export const getRelationMetadata = function(target: any, propertyKey: string) {
export function getRelationMetadata(target: any, propertyKey: string) {
return Reflect.getMetadata(relationshipKey, target, propertyKey);
};
export const getRelationships = function(target: any) {
export function getRelationships(target: any) {
return relationshipMap.get(target);
};

View File

@@ -52,7 +52,7 @@ export class RemoteDataBuildService {
const errorMessage = responseCacheObs
.filter((entry: ResponseCacheEntry) => !entry.response.isSuccessful)
.map((entry: ResponseCacheEntry) => (<ErrorResponse> entry.response).errorMessage)
.map((entry: ResponseCacheEntry) => (<ErrorResponse>entry.response).errorMessage)
.distinctUntilChanged();
const statusCode = responseCacheObs
@@ -61,7 +61,7 @@ export class RemoteDataBuildService {
const pageInfo = responseCacheObs
.filter((entry: ResponseCacheEntry) => hasValue(entry.response) && hasValue(entry.response['pageInfo']))
.map((entry: ResponseCacheEntry) => (<SuccessResponse> entry.response).pageInfo)
.map((entry: ResponseCacheEntry) => (<SuccessResponse>entry.response).pageInfo)
.distinctUntilChanged();
//always use self link if that is cached, only if it isn't, get it via the response.
@@ -70,7 +70,7 @@ export class RemoteDataBuildService {
this.objectCache.getBySelfLink<TNormalized>(href, normalizedType).startWith(undefined),
responseCacheObs
.filter((entry: ResponseCacheEntry) => entry.response.isSuccessful)
.map((entry: ResponseCacheEntry) => (<SuccessResponse> entry.response).resourceUUIDs)
.map((entry: ResponseCacheEntry) => (<SuccessResponse>entry.response).resourceUUIDs)
.flatMap((resourceUUIDs: Array<string>) => {
if (isNotEmpty(resourceUUIDs)) {
return this.objectCache.get(resourceUUIDs[0], normalizedType);
@@ -92,7 +92,7 @@ export class RemoteDataBuildService {
).filter(normalized => hasValue(normalized))
.map((normalized: TNormalized) => {
return this.build<TNormalized, TDomain>(normalized);
});
});
return new RemoteData(
@@ -124,7 +124,7 @@ export class RemoteDataBuildService {
const errorMessage = responseCacheObs
.filter((entry: ResponseCacheEntry) => !entry.response.isSuccessful)
.map((entry: ResponseCacheEntry) => (<ErrorResponse> entry.response).errorMessage)
.map((entry: ResponseCacheEntry) => (<ErrorResponse>entry.response).errorMessage)
.distinctUntilChanged();
const statusCode = responseCacheObs
@@ -133,12 +133,12 @@ export class RemoteDataBuildService {
const pageInfo = responseCacheObs
.filter((entry: ResponseCacheEntry) => hasValue(entry.response) && hasValue(entry.response['pageInfo']))
.map((entry: ResponseCacheEntry) => (<SuccessResponse> entry.response).pageInfo)
.map((entry: ResponseCacheEntry) => (<SuccessResponse>entry.response).pageInfo)
.distinctUntilChanged();
const payload = responseCacheObs
.filter((entry: ResponseCacheEntry) => entry.response.isSuccessful)
.map((entry: ResponseCacheEntry) => (<SuccessResponse> entry.response).resourceUUIDs)
.map((entry: ResponseCacheEntry) => (<SuccessResponse>entry.response).resourceUUIDs)
.flatMap((resourceUUIDs: Array<string>) => {
return this.objectCache.getList(resourceUUIDs, normalizedType)
.map((normList: TNormalized[]) => {
@@ -197,7 +197,7 @@ export class RemoteDataBuildService {
// are dispatched, but sometimes don't arrive. I'm unsure why atm.
setTimeout(() => {
this.requestService.configure(new Request(normalized[relationship]));
},0);
}, 0);
// The rest API can return a single URL to represent a list of resources (e.g. /items/:id/bitstreams)
// in that case only 1 href will be stored in the normalized obj (so the isArray above fails),
@@ -241,7 +241,7 @@ export class RemoteDataBuildService {
})
.filter(e => hasValue(e))
.join(", ")
);
);
const statusCode = Observable.combineLatest(
...input.map(rd => rd.statusCode),
@@ -253,11 +253,11 @@ export class RemoteDataBuildService {
})
.filter(c => hasValue(c))
.join(", ")
);
);
const pageInfo = Observable.of(undefined);
const payload = <Observable<T[]>> Observable.combineLatest(
const payload = <Observable<T[]>>Observable.combineLatest(
...input.map(rd => rd.payload)
);

View File

@@ -6,7 +6,7 @@ import { NormalizedObject } from "./normalized-object.model";
/**
* An abstract model class for a DSpaceObject.
*/
export abstract class NormalizedDSpaceObject extends NormalizedObject{
export abstract class NormalizedDSpaceObject extends NormalizedObject {
/**
* The link to the rest endpoint where this object can be found

View File

@@ -5,7 +5,7 @@ export enum SortDirection {
export class SortOptions {
constructor (public field: string = "name", public direction : SortDirection = SortDirection.Ascending) {
constructor(public field: string = "name", public direction: SortDirection = SortDirection.Ascending) {
}
}

View File

@@ -55,7 +55,7 @@ describe("objectCacheReducer", () => {
it("should add the payload to the cache in response to an ADD action", () => {
const state = Object.create(null);
const objectToCache = {uuid: uuid1};
const objectToCache = { uuid: uuid1 };
const timeAdded = new Date().getTime();
const msToLive = 900000;
const requestHref = "https://rest.api/endpoint/uuid1";
@@ -68,7 +68,7 @@ describe("objectCacheReducer", () => {
});
it("should overwrite an object in the cache in response to an ADD action if it already exists", () => {
const objectToCache = {uuid: uuid1, foo: "baz", somethingElse: true};
const objectToCache = { uuid: uuid1, foo: "baz", somethingElse: true };
const timeAdded = new Date().getTime();
const msToLive = 900000;
const requestHref = "https://rest.api/endpoint/uuid1";
@@ -81,7 +81,7 @@ describe("objectCacheReducer", () => {
it("should perform the ADD action without affecting the previous state", () => {
const state = Object.create(null);
const objectToCache = {uuid: uuid1};
const objectToCache = { uuid: uuid1 };
const timeAdded = new Date().getTime();
const msToLive = 900000;
const requestHref = "https://rest.api/endpoint/uuid1";

View File

@@ -1,14 +1,15 @@
import { ObjectCacheState, CacheableObject } from "./object-cache.reducer";
import { Store } from "@ngrx/store";
import { ObjectCacheService } from "./object-cache.service";
import { AddToObjectCacheAction, RemoveFromObjectCacheAction } from "./object-cache.actions";
import { Observable } from "rxjs";
import { ObjectCacheService } from "./object-cache.service";
import { ObjectCacheState, CacheableObject } from "./object-cache.reducer";
import { AddToObjectCacheAction, RemoveFromObjectCacheAction } from "./object-cache.actions";
class TestClass implements CacheableObject {
constructor(
public uuid: string,
public foo: string
) {}
) { }
test(): string {
return this.foo + this.uuid;
@@ -39,12 +40,13 @@ describe("ObjectCacheService", () => {
spyOn(store, 'dispatch');
service = new ObjectCacheService(store);
spyOn(window, 'Date').and.returnValue({ getTime: () => timestamp });
spyOn(Date.prototype, 'getTime').and.callFake(function() {
return timestamp;
});
});
describe("add", () => {
it("should dispatch an ADD action with the object to add, the time to live, and the current timestamp", () => {
service.add(objectToCache, msToLive, requestHref);
expect(store.dispatch).toHaveBeenCalledWith(new AddToObjectCacheAction(objectToCache, timestamp, msToLive, requestHref));
});
@@ -98,16 +100,19 @@ describe("ObjectCacheService", () => {
describe("has", () => {
it("should return true if the object with the supplied UUID is cached and still valid", () => {
spyOn(store, 'select').and.returnValue(Observable.of(cacheEntry));
expect(service.has(uuid)).toBe(true);
});
it("should return false if the object with the supplied UUID isn't cached", () => {
spyOn(store, 'select').and.returnValue(Observable.of(undefined));
expect(service.has(uuid)).toBe(false);
});
it("should return false if the object with the supplied UUID is cached but has exceeded its time to live", () => {
spyOn(store, 'select').and.returnValue(Observable.of(invalidCacheEntry));
expect(service.has(uuid)).toBe(false);
});
});

View File

@@ -13,7 +13,7 @@ import { GenericConstructor } from "../shared/generic-constructor";
export class ObjectCacheService {
constructor(
private store: Store<ObjectCacheState>
) {}
) { }
/**
* Add an object to the cache
@@ -59,7 +59,7 @@ export class ObjectCacheService {
*/
get<T extends CacheableObject>(uuid: string, type: GenericConstructor<T>): Observable<T> {
return this.getEntry(uuid)
.map((entry: ObjectCacheEntry) => <T> Object.assign(new type(), entry.data));
.map((entry: ObjectCacheEntry) => <T>Object.assign(new type(), entry.data));
}
getBySelfLink<T extends CacheableObject>(href: string, type: GenericConstructor<T>): Observable<T> {

View File

@@ -5,7 +5,7 @@ export class Response {
constructor(
public isSuccessful: boolean,
public statusCode: string
) {}
) { }
}
export class SuccessResponse extends Response {
@@ -27,4 +27,3 @@ export class ErrorResponse extends Response {
this.errorMessage = error.message;
}
}

View File

@@ -1,9 +1,11 @@
import * as deepFreeze from "deep-freeze";
import { responseCacheReducer, ResponseCacheState } from "./response-cache.reducer";
import {
ResponseCacheRemoveAction,
ResetResponseCacheTimestampsAction
} from "./response-cache.actions";
import deepFreeze = require("deep-freeze");
class NullAction extends ResponseCacheRemoveAction {
type = null;

View File

@@ -41,11 +41,11 @@ export const responseCacheReducer = (state = initialState, action: ResponseCache
switch (action.type) {
case ResponseCacheActionTypes.ADD: {
return addToCache(state, <ResponseCacheAddAction> action);
return addToCache(state, <ResponseCacheAddAction>action);
}
case ResponseCacheActionTypes.REMOVE: {
return removeFromCache(state, <ResponseCacheRemoveAction> action);
return removeFromCache(state, <ResponseCacheRemoveAction>action);
}
case ResponseCacheActionTypes.RESET_TIMESTAMPS: {

View File

@@ -18,13 +18,13 @@ import { Response } from "./response-cache.models";
export class ResponseCacheService {
constructor(
private store: Store<ResponseCacheState>
) {}
) { }
add(key: string, response: Response, msToLive: number): Observable<ResponseCacheEntry> {
if (!this.has(key)) {
// this.store.dispatch(new ResponseCacheFindAllAction(key, service, scopeID, paginationOptions, sortOptions));
this.store.dispatch(new ResponseCacheAddAction(key, response, new Date().getTime(), msToLive));
}
if (!this.has(key)) {
// this.store.dispatch(new ResponseCacheFindAllAction(key, service, scopeID, paginationOptions, sortOptions));
this.store.dispatch(new ResponseCacheAddAction(key, response, new Date().getTime(), msToLive));
}
return this.get(key);
}

View File

@@ -40,13 +40,13 @@ const PROVIDERS = [
];
@NgModule({
imports: [ ...IMPORTS ],
imports: [...IMPORTS],
declarations: [...DECLARATIONS],
exports: [...EXPORTS],
providers: [...PROVIDERS]
})
export class CoreModule {
constructor (@Optional() @SkipSelf() parentModule: CoreModule) {
constructor( @Optional() @SkipSelf() parentModule: CoreModule) {
if (isNotEmpty(parentModule)) {
throw new Error(
'CoreModule is already loaded. Import it in the AppModule only');

View File

@@ -23,7 +23,7 @@ export class CollectionDataService extends DataService<NormalizedCollection, Col
protected store: Store<CoreState>,
@Inject(GLOBAL_CONFIG) EnvConfig: GlobalConfig
) {
super(NormalizedCollection, EnvConfig);
super(NormalizedCollection, EnvConfig);
}
}

View File

@@ -22,7 +22,7 @@ export class ItemDataService extends DataService<NormalizedItem, Item> {
protected rdbService: RemoteDataBuildService,
protected store: Store<CoreState>,
@Inject(GLOBAL_CONFIG) EnvConfig: GlobalConfig
) {
) {
super(NormalizedItem, EnvConfig);
}
}

View File

@@ -2,10 +2,10 @@ import { Observable } from "rxjs";
import { PageInfo } from "../shared/page-info.model";
export enum RemoteDataState {
RequestPending = <any> "RequestPending",
ResponsePending = <any> "ResponsePending",
Failed = <any> "Failed",
Success = <any> "Success"
RequestPending = <any>"RequestPending",
ResponsePending = <any>"ResponsePending",
Failed = <any>"Failed",
Success = <any>"Success"
}
/**

View File

@@ -1,14 +1,12 @@
import { Injectable, Inject } from "@angular/core";
import { Actions, Effect } from "@ngrx/effects";
import { ObjectCacheActionTypes } from "../cache/object-cache.actions";
import { GlobalConfig, GLOBAL_CONFIG } from "../../../config";
import { ResetResponseCacheTimestampsAction } from "../cache/response-cache.actions";
@Injectable()
export class RequestCacheEffects {
constructor(
@Inject(GLOBAL_CONFIG) private EnvConfig: GlobalConfig,
private actions$: Actions,
) { }

View File

@@ -47,7 +47,7 @@ class ProcessRequestDTO {
export class RequestEffects {
constructor(
@Inject(GLOBAL_CONFIG) private EnvConfig: GlobalConfig,
@Inject(GLOBAL_CONFIG) private config: GlobalConfig,
private actions$: Actions,
private restApi: DSpaceRESTv2Service,
private objectCache: ObjectCacheService,
@@ -67,14 +67,14 @@ export class RequestEffects {
const processRequestDTO = this.process(data.payload, entry.request.href);
const uuids = flattenSingleKeyObject(processRequestDTO).map(no => no.uuid);
return new SuccessResponse(uuids, data.statusCode, this.processPageInfo(data.payload.page))
}).do((response: Response) => this.responseCache.add(entry.request.href, response, this.EnvConfig.cache.msToLive))
}).do((response: Response) => this.responseCache.add(entry.request.href, response, this.config.cache.msToLive))
.map((response: Response) => new RequestCompleteAction(entry.request.href))
.catch((error: RequestError) => Observable.of(new ErrorResponse(error))
.do((response: Response) => this.responseCache.add(entry.request.href, response, this.EnvConfig.cache.msToLive))
.do((response: Response) => this.responseCache.add(entry.request.href, response, this.config.cache.msToLive))
.map((response: Response) => new RequestCompleteAction(entry.request.href)));
});
protected process(data: any, requestHref: string): ProcessRequestDTO {
protected process(data: any, requestHref: string): ProcessRequestDTO {
if (isNotEmpty(data)) {
if (isPaginatedResponse(data)) {
@@ -117,7 +117,7 @@ export class RequestEffects {
}
protected deserializeAndCache(obj, requestHref: string): NormalizedObject[] {
if(Array.isArray(obj)) {
if (Array.isArray(obj)) {
let result = [];
obj.forEach(o => result = [...result, ...this.deserializeAndCache(o, requestHref)])
return result;
@@ -166,7 +166,7 @@ export class RequestEffects {
if (hasNoValue(co) || hasNoValue(co.uuid)) {
throw new Error('The server returned an invalid object');
}
this.objectCache.add(co, this.EnvConfig.cache.msToLive, requestHref);
this.objectCache.add(co, this.config.cache.msToLive, requestHref);
}
protected processPageInfo(pageObj: any): PageInfo {

View File

@@ -5,7 +5,7 @@ import { GenericConstructor } from "../shared/generic-constructor";
export class Request<T> {
constructor(
public href: string,
) {}
) { }
}
export class FindByIDRequest<T> extends Request<T> {

View File

@@ -24,15 +24,15 @@ export const requestReducer = (state = initialState, action: RequestAction): Req
switch (action.type) {
case RequestActionTypes.CONFIGURE: {
return configureRequest(state, <RequestConfigureAction> action);
return configureRequest(state, <RequestConfigureAction>action);
}
case RequestActionTypes.EXECUTE: {
return executeRequest(state, <RequestExecuteAction> action);
return executeRequest(state, <RequestExecuteAction>action);
}
case RequestActionTypes.COMPLETE: {
return completeRequest(state, <RequestCompleteAction> action);
return completeRequest(state, <RequestCompleteAction>action);
}
default: {

View File

@@ -26,9 +26,9 @@ export class RequestService {
let isPending = false;
this.store.select<RequestEntry>('core', 'data', 'request', href)
.take(1)
.subscribe((re: RequestEntry) => {
.subscribe((re: RequestEntry) => {
isPending = (hasValue(re) && !re.completed)
});
});
return isPending;
}
@@ -46,7 +46,7 @@ export class RequestService {
this.responseCache.get(request.href)
.take(1)
.filter((entry: ResponseCacheEntry) => entry.response.isSuccessful)
.map((entry: ResponseCacheEntry) => (<SuccessResponse> entry.response).resourceUUIDs)
.map((entry: ResponseCacheEntry) => (<SuccessResponse>entry.response).resourceUUIDs)
.map((resourceUUIDs: Array<string>) => resourceUUIDs.every(uuid => this.objectCache.has(uuid)))
.subscribe(c => isCached = c);
}

View File

@@ -16,8 +16,7 @@
"description": "Object of links with the rels as the keys",
"type": "object",
"additionalProperties": {
"oneOf": [
{
"oneOf": [{
"$ref": "#/definitions/linkObject"
},
{
@@ -43,8 +42,7 @@
"$ref": "http://hyperschema.org/core/base#/definitions/name"
},
"href": {
"anyOf": [
{
"anyOf": [{
"$ref": "http://hyperschema.org/core/link#/definitions/href"
},
{
@@ -71,8 +69,7 @@
"description": "An embedded HAL resource",
"type": "object",
"additionalProperties": {
"oneOf": [
{
"oneOf": [{
"$ref": "#"
},
{

View File

@@ -37,7 +37,7 @@ export class DSpaceRESTv2Serializer<T> implements Serializer<T> {
* @returns An object to send to the backend
*/
serializeArray(models: Array<T>): any {
return Serialize(models, this.modelType);
return Serialize(models, this.modelType);
}
/**
@@ -53,7 +53,7 @@ export class DSpaceRESTv2Serializer<T> implements Serializer<T> {
throw new Error('Expected a single model, use deserializeArray() instead');
}
let normalized = Object.assign({}, response, this.normalizeLinks(response._links));
return <T> Deserialize(normalized, this.modelType);
return <T>Deserialize(normalized, this.modelType);
}
/**
@@ -69,13 +69,13 @@ export class DSpaceRESTv2Serializer<T> implements Serializer<T> {
throw new Error('Expected an Array, use deserialize() instead');
}
let normalized = response.map((resource) => {
return Object.assign({}, resource, this.normalizeLinks(resource._links));
return Object.assign({}, resource, this.normalizeLinks(resource._links));
});
return <Array<T>> Deserialize(normalized, this.modelType);
return <Array<T>>Deserialize(normalized, this.modelType);
}
private normalizeLinks(links:any): any {
private normalizeLinks(links: any): any {
let normalizedLinks = links;
for (let link in normalizedLinks) {
if (Array.isArray(normalizedLinks[link])) {

View File

@@ -1,4 +1,4 @@
import * as schema from './dspace-rest-v2.schema.json'
import schema from './dspace-rest-v2.schema.json'
import { Validator } from "jsonschema";
/**

View File

@@ -1,14 +1,13 @@
@import '../../../styles/variables.scss';
@import '../../../../node_modules/bootstrap/scss/_variables.scss';
$footer-bg: $gray-lighter;
$footer-border: 1px solid darken($footer-bg, 10%);
$footer-padding: $spacer * 1.5;
.footer {
background-color: $footer-bg;
border-top: $footer-border;
text-align:center;
border-top: $footer-border;
text-align: center;
padding: $footer-padding;
p {

View File

@@ -2,7 +2,7 @@ import { Component, OnInit } from "@angular/core";
@Component({
selector: 'ds-footer',
styleUrls: ['footer.component.css'],
styleUrls: ['footer.component.scss'],
templateUrl: 'footer.component.html'
})
export class FooterComponent implements OnInit {

View File

@@ -9,82 +9,82 @@ import { ResourceType } from "./resource-type";
*/
export abstract class DSpaceObject implements CacheableObject {
self: string;
self: string;
/**
* The human-readable identifier of this DSpaceObject
*/
id: string;
/**
* The human-readable identifier of this DSpaceObject
*/
id: string;
/**
* The universally unique identifier of this DSpaceObject
*/
uuid: string;
/**
* The universally unique identifier of this DSpaceObject
*/
uuid: string;
/**
* A string representing the kind of DSpaceObject, e.g. community, item, …
*/
type: ResourceType;
/**
* A string representing the kind of DSpaceObject, e.g. community, item, …
*/
type: ResourceType;
/**
* The name for this DSpaceObject
*/
name: string;
/**
* The name for this DSpaceObject
*/
name: string;
/**
* An array containing all metadata of this DSpaceObject
*/
metadata: Array<Metadatum>;
/**
* An array containing all metadata of this DSpaceObject
*/
metadata: Array<Metadatum>;
/**
* An array of DSpaceObjects that are direct parents of this DSpaceObject
*/
parents: RemoteData<DSpaceObject[]>;
/**
* An array of DSpaceObjects that are direct parents of this DSpaceObject
*/
parents: RemoteData<DSpaceObject[]>;
/**
* The DSpaceObject that owns this DSpaceObject
*/
owner: RemoteData<DSpaceObject>;
/**
* The DSpaceObject that owns this DSpaceObject
*/
owner: RemoteData<DSpaceObject>;
/**
* Find a metadata field by key and language
*
* This method returns the value of the first element
* in the metadata array that matches the provided
* key and language
*
* @param key
* @param language
* @return string
*/
findMetadata(key: string, language?: string): string {
const metadatum = this.metadata
.find((metadatum: Metadatum) => {
return metadatum.key === key &&
(isEmpty(language) || metadatum.language === language)
});
if (isNotEmpty(metadatum)) {
return metadatum.value;
}
else {
return undefined;
}
/**
* Find a metadata field by key and language
*
* This method returns the value of the first element
* in the metadata array that matches the provided
* key and language
*
* @param key
* @param language
* @return string
*/
findMetadata(key: string, language?: string): string {
const metadatum = this.metadata
.find((metadatum: Metadatum) => {
return metadatum.key === key &&
(isEmpty(language) || metadatum.language === language)
});
if (isNotEmpty(metadatum)) {
return metadatum.value;
}
/**
* Find metadata by an array of keys
*
* This method returns the values of the element
* in the metadata array that match the provided
* key(s)
*
* @param key(s)
* @return Array<Metadatum>
*/
filterMetadata(keys: string[]): Array<Metadatum> {
return this.metadata
.filter((metadatum: Metadatum) => {
return keys.some(key => key === metadatum.key);
});
else {
return undefined;
}
}
/**
* Find metadata by an array of keys
*
* This method returns the values of the element
* in the metadata array that match the provided
* key(s)
*
* @param key(s)
* @return Array<Metadatum>
*/
filterMetadata(keys: string[]): Array<Metadatum> {
return this.metadata
.filter((metadatum: Metadatum) => {
return keys.some(key => key === metadatum.key);
});
}
}

View File

@@ -4,4 +4,3 @@
* https://github.com/Microsoft/TypeScript/issues/204#issuecomment-257722306
*/
export type GenericConstructor<T> = { new (...args: any[]): T };

View File

@@ -9,102 +9,102 @@ import { PageInfo } from "./page-info.model";
describe('Item', () => {
let item: Item;
const thumbnailBundleName = "THUMBNAIL";
const originalBundleName = "ORIGINAL";
const thumbnailPath = "thumbnail.jpg";
const bitstream1Path = "document.pdf";
const bitstream2Path = "otherfile.doc";
let item: Item;
const thumbnailBundleName = "THUMBNAIL";
const originalBundleName = "ORIGINAL";
const thumbnailPath = "thumbnail.jpg";
const bitstream1Path = "document.pdf";
const bitstream2Path = "otherfile.doc";
const nonExistingBundleName = "c1e568f7-d14e-496b-bdd7-07026998cc00";
let bitstreams;
let remoteDataThumbnail;
let remoteDataFiles;
let remoteDataAll;
const nonExistingBundleName = "c1e568f7-d14e-496b-bdd7-07026998cc00";
let bitstreams;
let remoteDataThumbnail;
let remoteDataFiles;
let remoteDataAll;
beforeEach(() => {
const thumbnail = {
retrieve: thumbnailPath
};
beforeEach(() => {
const thumbnail = {
retrieve: thumbnailPath
};
bitstreams = [{
retrieve: bitstream1Path
}, {
retrieve: bitstream2Path
}];
bitstreams = [{
retrieve: bitstream1Path
}, {
retrieve: bitstream2Path
}];
remoteDataThumbnail = createRemoteDataObject(thumbnail);
remoteDataFiles = createRemoteDataObject(bitstreams);
remoteDataAll = createRemoteDataObject([...bitstreams, thumbnail]);
remoteDataThumbnail = createRemoteDataObject(thumbnail);
remoteDataFiles = createRemoteDataObject(bitstreams);
remoteDataAll = createRemoteDataObject([...bitstreams, thumbnail]);
// Create Bundles
// Create Bundles
const bundles =
[
{
name: thumbnailBundleName,
primaryBitstream: remoteDataThumbnail
const bundles =
[
{
name: thumbnailBundleName,
primaryBitstream: remoteDataThumbnail
},
{
name: originalBundleName,
bitstreams: remoteDataFiles
{
name: originalBundleName,
bitstreams: remoteDataFiles
}];
item = Object.assign(new Item(), { bitstreams: remoteDataAll});
item = Object.assign(new Item(), { bitstreams: remoteDataAll });
});
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 =>
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 bitstreams: Observable<Bitstream[]> = item.getBitstreamsByBundleName(nonExistingBundleName);
bitstreams.take(1).subscribe(bs => expect(isEmpty(bs)).toBeTruthy());
});
describe("get thumbnail", () => {
beforeEach(() => {
spyOn(item, 'getBitstreamsByBundleName').and.returnValue(Observable.of([remoteDataThumbnail]));
});
it('should return the thumbnail of this item', () => {
let path: string = thumbnailPath;
let bitstream: Observable<Bitstream> = item.getThumbnail();
bitstream.map(b => expect(b.retrieve).toBe(path));
});
});
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 =>
expect(bs.every(b => b.name === thumbnailBundleName)).toBeTruthy());
describe("get files", () => {
beforeEach(() => {
spyOn(item, 'getBitstreamsByBundleName').and.returnValue(Observable.of(bitstreams));
});
it('should return an empty array when no bitstreams with this bundleName exist for this item', () => {
const bitstreams: Observable<Bitstream[]> = item.getBitstreamsByBundleName(nonExistingBundleName);
bitstreams.take(1).subscribe(bs => expect(isEmpty(bs)).toBeTruthy());
it('should return all bitstreams with "ORIGINAL" as bundleName', () => {
let paths = [bitstream1Path, bitstream2Path];
let files: Observable<Bitstream[]> = item.getFiles();
let index = 0;
files.map(f => expect(f.length).toBe(2));
files.subscribe(
array => array.forEach(
file => {
expect(file.retrieve).toBe(paths[index]);
index++;
}
)
)
});
describe("get thumbnail", () => {
beforeEach(() => {
spyOn(item, 'getBitstreamsByBundleName').and.returnValue(Observable.of([remoteDataThumbnail]));
});
it('should return the thumbnail of this item', () => {
let path: string = thumbnailPath;
let bitstream: Observable<Bitstream> = item.getThumbnail();
bitstream.map(b => expect(b.retrieve).toBe(path));
});
});
describe("get files", () => {
beforeEach(() => {
spyOn(item, 'getBitstreamsByBundleName').and.returnValue(Observable.of(bitstreams));
});
it('should return all bitstreams with "ORIGINAL" as bundleName', () => {
let paths = [bitstream1Path, bitstream2Path];
let files: Observable<Bitstream[]> = item.getFiles();
let index = 0;
files.map(f => expect(f.length).toBe(2));
files.subscribe(
array => array.forEach(
file => {
expect(file.retrieve).toBe(paths[index]);
index++;
}
)
)
});
});
});
});
@@ -119,14 +119,14 @@ function createRemoteDataObject(object: Object) {
const pageInfo = Observable.of(new PageInfo());
const payload = Observable.of(object);
return new RemoteData(
self,
requestPending,
responsePending,
isSuccessful,
errorMessage,
statusCode,
pageInfo,
payload
);
self,
requestPending,
responsePending,
isSuccessful,
errorMessage,
statusCode,
pageInfo,
payload
);
}

View File

@@ -7,60 +7,60 @@ import { isNotEmpty } from "../../shared/empty.util";
export class Item extends DSpaceObject {
/**
* A string representing the unique handle of this Item
*/
handle: string;
/**
* A string representing the unique handle of this Item
*/
handle: string;
/**
* The Date of the last modification of this Item
*/
lastModified: Date;
/**
* The Date of the last modification of this Item
*/
lastModified: Date;
/**
* A boolean representing if this Item is currently archived or not
*/
isArchived: boolean;
/**
* A boolean representing if this Item is currently archived or not
*/
isArchived: boolean;
/**
* A boolean representing if this Item is currently discoverable or not
*/
isDiscoverable: boolean;
/**
* A boolean representing if this Item is currently discoverable or not
*/
isDiscoverable: boolean;
/**
* A boolean representing if this Item is currently withdrawn or not
*/
isWithdrawn: boolean;
/**
* A boolean representing if this Item is currently withdrawn or not
*/
isWithdrawn: boolean;
/**
* An array of Collections that are direct parents of this Item
*/
parents: RemoteData<Collection[]>;
/**
* An array of Collections that are direct parents of this Item
*/
parents: RemoteData<Collection[]>;
/**
* The Collection that owns this Item
*/
owningCollection: RemoteData<Collection>;
/**
* The Collection that owns this Item
*/
owningCollection: RemoteData<Collection>;
get owner(): RemoteData<Collection> {
return this.owningCollection;
}
get owner(): RemoteData<Collection> {
return this.owningCollection;
}
bitstreams: RemoteData<Bitstream[]>;
bitstreams: RemoteData<Bitstream[]>;
/**
* Retrieves the thumbnail of this item
* @returns {Observable<Bitstream>} the primaryBitstream of the "THUMBNAIL" bundle
*/
getThumbnail(): Observable<Bitstream> {
//TODO currently this just picks the first thumbnail
//should be adjusted when we have a way to determine
//the primary thumbnail from rest
return this.getBitstreamsByBundleName("THUMBNAIL")
.filter(thumbnails => isNotEmpty(thumbnails))
.map(thumbnails => thumbnails[0])
}
/**
* Retrieves the thumbnail of this item
* @returns {Observable<Bitstream>} the primaryBitstream of the "THUMBNAIL" bundle
*/
getThumbnail(): Observable<Bitstream> {
//TODO currently this just picks the first thumbnail
//should be adjusted when we have a way to determine
//the primary thumbnail from rest
return this.getBitstreamsByBundleName("THUMBNAIL")
.filter(thumbnails => isNotEmpty(thumbnails))
.map(thumbnails => thumbnails[0])
}
/**
* Retrieves the thumbnail for the given original of this item
@@ -78,20 +78,20 @@ export class Item extends DSpaceObject {
* Retrieves all files that should be displayed on the item page of this item
* @returns {Observable<Array<Observable<Bitstream>>>} an array of all Bitstreams in the "ORIGINAL" bundle
*/
getFiles(): Observable<Bitstream[]> {
return this.getBitstreamsByBundleName("ORIGINAL");
}
getFiles(): Observable<Bitstream[]> {
return this.getBitstreamsByBundleName("ORIGINAL");
}
/**
* Retrieves bitstreams by bundle name
* @param bundleName The name of the Bundle that should be returned
* @returns {Observable<Bitstream[]>} the bitstreams with the given bundleName
*/
getBitstreamsByBundleName(bundleName: string): Observable<Bitstream[]> {
return this.bitstreams.payload.startWith([])
.map(bitstreams => bitstreams
.filter(bitstream => bitstream.bundleName === bundleName)
);
}
getBitstreamsByBundleName(bundleName: string): Observable<Bitstream[]> {
return this.bitstreams.payload.startWith([])
.map(bitstreams => bitstreams
.filter(bitstream => bitstream.bundleName === bundleName)
);
}
}

View File

@@ -1,21 +1,21 @@
import { autoserialize } from "cerialize";
export class Metadatum {
/**
* The metadata field of this Metadatum
*/
@autoserialize
key: string;
/**
* The metadata field of this Metadatum
*/
@autoserialize
key: string;
/**
* The language of this Metadatum
*/
@autoserialize
language: string;
/**
* The language of this Metadatum
*/
@autoserialize
language: string;
/**
* The value of this Metadatum
*/
@autoserialize
value: string;
/**
* The value of this Metadatum
*/
@autoserialize
value: string;
}

View File

@@ -3,10 +3,10 @@
* https://github.com/Microsoft/TypeScript/pull/15486
*/
export enum ResourceType {
Bundle = <any> "bundle",
Bitstream = <any> "bitstream",
BitstreamFormat = <any> "bitstreamformat",
Item = <any> "item",
Collection = <any> "collection",
Community = <any> "community"
Bundle = <any>"bundle",
Bitstream = <any>"bitstream",
BitstreamFormat = <any>"bitstreamformat",
Item = <any>"item",
Collection = <any>"collection",
Community = <any>"community"
}

View File

@@ -7,7 +7,7 @@ import { GlobalConfig } from "../../../config";
*
* TODO write tests once GlobalConfig becomes injectable
*/
export class UIURLCombiner extends URLCombiner{
export class UIURLCombiner extends URLCombiner {
constructor(EnvConfig: GlobalConfig, ...parts: Array<string>) {
super(EnvConfig.ui.baseUrl, EnvConfig.ui.nameSpace, ...parts);
}

View File

@@ -13,7 +13,7 @@ export class URLCombiner {
* @param parts
* a variable number of strings representing parts of a URL
*/
constructor(...parts:Array<string>) {
constructor(...parts: Array<string>) {
// can't do this in the constructor signature,
// because of the spread operator
this.parts = parts;

View File

@@ -1,14 +1,14 @@
import { Action } from "@ngrx/store";
import { type } from "../shared/ngrx/type";
/**
* For each action type in an action group, make a simple
* enum object for all of this group's action types.
*
* The 'type' utility function coerces strings into string
* literal types and runs a simple check to guarantee all
* action types in the application are unique.
*/
/**
* For each action type in an action group, make a simple
* enum object for all of this group's action types.
*
* The 'type' utility function coerces strings into string
* literal types and runs a simple check to guarantee all
* action types in the application are unique.
*/
export const HeaderActionTypes = {
COLLAPSE: type('dspace/header/COLLAPSE'),
EXPAND: type('dspace/header/EXPAND'),
@@ -18,19 +18,19 @@ export const HeaderActionTypes = {
export class HeaderCollapseAction implements Action {
type = HeaderActionTypes.COLLAPSE;
constructor() {}
constructor() { }
}
export class HeaderExpandAction implements Action {
type = HeaderActionTypes.EXPAND;
constructor() {}
constructor() { }
}
export class HeaderToggleAction implements Action {
type = HeaderActionTypes.TOGGLE;
constructor() {}
constructor() { }
}
/**

View File

@@ -1,7 +1,7 @@
@import '../../styles/variables.scss';
header nav.navbar {
border-radius: 0rem;
border-radius: 0;
}
header nav.navbar .navbar-toggler:hover {

View File

@@ -18,8 +18,8 @@ describe('HeaderComponent', () => {
// async beforeEach
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [ StoreModule.provideStore({}), TranslateModule.forRoot(), NgbCollapseModule.forRoot() ],
declarations: [ HeaderComponent ]
imports: [StoreModule.provideStore({}), TranslateModule.forRoot(), NgbCollapseModule.forRoot()],
declarations: [HeaderComponent]
})
.compileComponents(); // compile template and css
}));

View File

@@ -6,7 +6,7 @@ import { HeaderToggleAction } from "./header.actions";
@Component({
selector: 'ds-header',
styleUrls: ['header.component.css'],
styleUrls: ['header.component.scss'],
templateUrl: 'header.component.html'
})
export class HeaderComponent implements OnInit {

View File

@@ -19,8 +19,8 @@ describe('HeaderEffects', () => {
let headerEffects: HeaderEffects;
beforeEach(inject([
EffectsRunner, HeaderEffects
],
EffectsRunner, HeaderEffects
],
(_runner, _headerEffects) => {
runner = _runner;
headerEffects = _headerEffects;
@@ -30,7 +30,7 @@ describe('HeaderEffects', () => {
describe('resize$', () => {
it('should return a COLLAPSE action in response to a RESIZE action', () => {
runner.queue(new HostWindowResizeAction(800,600));
runner.queue(new HostWindowResizeAction(800, 600));
headerEffects.resize$.subscribe(result => {
expect(result).toEqual(new HeaderCollapseAction());

View File

@@ -2,7 +2,7 @@ import { Component, OnInit } from '@angular/core';
@Component({
selector: 'ds-home-news',
styleUrls: ['./home-news.component.css'],
styleUrls: ['./home-news.component.scss'],
templateUrl: './home-news.component.html'
})
export class HomeNewsComponent implements OnInit {

View File

@@ -2,7 +2,7 @@ import { Component, OnInit } from '@angular/core';
@Component({
selector: 'ds-home',
styleUrls: ['./home.component.css'],
styleUrls: ['./home.component.scss'],
templateUrl: './home.component.html'
})
export class HomeComponent implements OnInit {

View File

@@ -7,14 +7,14 @@ import { SortOptions, SortDirection } from "../../core/cache/models/sort-options
@Component({
selector: 'ds-top-level-community-list',
styleUrls: ['./top-level-community-list.component.css'],
styleUrls: ['./top-level-community-list.component.scss'],
templateUrl: './top-level-community-list.component.html',
changeDetection: ChangeDetectionStrategy.OnPush
})
export class TopLevelCommunityListComponent implements OnInit {
topLevelCommunities: RemoteData<Community[]>;
config : PaginationComponentOptions;
sortConfig : SortOptions;
config: PaginationComponentOptions;
sortConfig: SortOptions;
constructor(
private cds: CommunityDataService,
@@ -30,9 +30,9 @@ export class TopLevelCommunityListComponent implements OnInit {
ngOnInit(): void {
this.config = new PaginationComponentOptions();
this.config.id = "top-level-pagination";
this.config.pageSizeOptions = [ 4 ];
this.config.pageSizeOptions = [4];
this.config.pageSize = 4;
this.sortConfig = new SortOptions();
this.sortConfig = new SortOptions();
this.updateResults();
}

View File

@@ -10,36 +10,36 @@ import { RemoteDataBuildService } from "../../../core/cache/builders/remote-data
*/
@Component({
selector: 'ds-item-page-collections',
templateUrl: './collections.component.html'
selector: 'ds-item-page-collections',
templateUrl: './collections.component.html'
})
export class CollectionsComponent implements OnInit {
@Input() item: Item;
@Input() item: Item;
label : string = "item.page.collections";
label: string = "item.page.collections";
separator: string = "<br/>";
separator: string = "<br/>";
collections: Observable<Collection[]>;
collections: Observable<Collection[]>;
constructor(
private rdbs: RemoteDataBuildService
) {
this.universalInit();
constructor(
private rdbs: RemoteDataBuildService
) {
this.universalInit();
}
}
universalInit() {
}
universalInit() {
}
ngOnInit(): void {
// this.collections = this.item.parents.payload;
//TODO this should use parents, but the collections
// for an Item aren't returned by the REST API yet,
// only the owning collection
this.collections = this.item.owner.payload.map(c => [c]);
}
ngOnInit(): void {
// this.collections = this.item.parents.payload;
//TODO this should use parents, but the collections
// for an Item aren't returned by the REST API yet,
// only the owning collection
this.collections = this.item.owner.payload.map(c => [c]);
}

View File

@@ -3,4 +3,4 @@
<div class="simple-view-element-body">
<ng-content></ng-content>
</div>
</div>
</div>

View File

@@ -1,6 +1,7 @@
@import '../../../../styles/variables.scss';
:host {
.simple-view-element {
margin-bottom: 15px;
}
}
.simple-view-element {
margin-bottom: 15px;
}
}

View File

@@ -7,7 +7,7 @@ import { Component, Input } from '@angular/core';
@Component({
selector: 'ds-metadata-field-wrapper',
styleUrls: ['./metadata-field-wrapper.component.css'],
styleUrls: ['./metadata-field-wrapper.component.scss'],
templateUrl: './metadata-field-wrapper.component.html'
})
export class MetadataFieldWrapperComponent {

View File

@@ -11,7 +11,7 @@ import { MetadataValuesComponent } from "../metadata-values/metadata-values.comp
@Component({
selector: 'ds-metadata-uri-values',
styleUrls: ['./metadata-uri-values.component.css'],
styleUrls: ['./metadata-uri-values.component.scss'],
templateUrl: './metadata-uri-values.component.html'
})
export class MetadataUriValuesComponent extends MetadataValuesComponent {

View File

@@ -7,7 +7,7 @@ import { Component, Input } from '@angular/core';
@Component({
selector: 'ds-metadata-values',
styleUrls: ['./metadata-values.component.css'],
styleUrls: ['./metadata-values.component.scss'],
templateUrl: './metadata-values.component.html'
})
export class MetadataValuesComponent {

View File

@@ -11,42 +11,42 @@ import { hasValue } from "../../../../shared/empty.util";
*/
@Component({
selector: 'ds-item-page-full-file-section',
styleUrls: ['./full-file-section.component.css'],
templateUrl: './full-file-section.component.html'
selector: 'ds-item-page-full-file-section',
styleUrls: ['./full-file-section.component.scss'],
templateUrl: './full-file-section.component.html'
})
export class FullFileSectionComponent extends FileSectionComponent implements OnInit {
@Input() item: Item;
@Input() item: Item;
label : string;
label: string;
files: Observable<Bitstream[]>;
files: Observable<Bitstream[]>;
thumbnails: Map<string, Observable<Bitstream>> = new Map();
thumbnails: Map<string, Observable<Bitstream>> = new Map();
universalInit() {
}
universalInit() {
}
ngOnInit(): void {
super.ngOnInit();
}
ngOnInit(): void {
super.ngOnInit();
}
initialize(): void {
const originals = this.item.getFiles();
const licenses = this.item.getBitstreamsByBundleName("LICENSE");
this.files = Observable.combineLatest(originals, licenses, (originals, licenses) => [...originals, ...licenses]);
this.files.subscribe(
files =>
files.forEach(
original => {
const thumbnail: Observable<Bitstream> = this.item.getThumbnailForOriginal(original);
this.thumbnails.set(original.id, thumbnail);
}
)
initialize(): void {
const originals = this.item.getFiles();
const licenses = this.item.getBitstreamsByBundleName("LICENSE");
this.files = Observable.combineLatest(originals, licenses, (originals, licenses) => [...originals, ...licenses]);
this.files.subscribe(
files =>
files.forEach(
original => {
const thumbnail: Observable<Bitstream> = this.item.getThumbnailForOriginal(original);
this.thumbnails.set(original.id, thumbnail);
}
)
}
)
}
}

View File

@@ -14,32 +14,32 @@ import { Item } from "../../core/shared/item.model";
*/
@Component({
selector: 'ds-full-item-page',
styleUrls: ['./full-item-page.component.css'],
templateUrl: './full-item-page.component.html',
selector: 'ds-full-item-page',
styleUrls: ['./full-item-page.component.scss'],
templateUrl: './full-item-page.component.html',
})
export class FullItemPageComponent extends ItemPageComponent implements OnInit {
item: RemoteData<Item>;
item: RemoteData<Item>;
metadata: Observable<Array<Metadatum>>;
metadata: Observable<Array<Metadatum>>;
constructor(route: ActivatedRoute, items: ItemDataService) {
super(route, items);
}
constructor(route: ActivatedRoute, items: ItemDataService) {
super(route, items);
}
universalInit() {
universalInit() {
}
}
/*** AoT inheritance fix, will hopefully be resolved in the near future **/
ngOnInit(): void {
super.ngOnInit();
}
/*** AoT inheritance fix, will hopefully be resolved in the near future **/
ngOnInit(): void {
super.ngOnInit();
}
initialize(params) {
super.initialize(params);
this.metadata = this.item.payload.map(i => i.metadata);
}
initialize(params) {
super.initialize(params);
this.metadata = this.item.payload.map(i => i.metadata);
}
}

View File

@@ -13,40 +13,40 @@ import { Bitstream } from "../../core/shared/bitstream.model";
*/
@Component({
selector: 'ds-item-page',
styleUrls: ['./item-page.component.css'],
templateUrl: './item-page.component.html',
selector: 'ds-item-page',
styleUrls: ['./item-page.component.scss'],
templateUrl: './item-page.component.html',
})
export class ItemPageComponent implements OnInit {
id: number;
id: number;
private sub: any;
private sub: any;
item: RemoteData<Item>;
item: RemoteData<Item>;
thumbnail: Observable<Bitstream>;
thumbnail: Observable<Bitstream>;
constructor(private route: ActivatedRoute, private items: ItemDataService) {
this.universalInit();
}
constructor(private route: ActivatedRoute, private items: ItemDataService) {
this.universalInit();
}
universalInit() {
universalInit() {
}
}
ngOnInit(): void {
this.sub = this.route.params.subscribe(params => {
this.initialize(params);
});
}
ngOnInit(): void {
this.sub = this.route.params.subscribe(params => {
this.initialize(params);
});
}
initialize(params) {
this.id = +params['id'];
this.item = this.items.findById(params['id']);
this.thumbnail = this.item.payload.flatMap(i => i.getThumbnail());
}
initialize(params) {
this.id = +params['id'];
this.item = this.items.findById(params['id']);
this.thumbnail = this.item.payload.flatMap(i => i.getThumbnail());
}
}

View File

@@ -2,22 +2,22 @@ import { Component, Input } from '@angular/core';
import { Collection } from "../../core/shared/collection.model";
@Component({
selector: 'ds-collection-list-element',
styleUrls: ['./collection-list-element.component.css'],
templateUrl: './collection-list-element.component.html'
selector: 'ds-collection-list-element',
styleUrls: ['./collection-list-element.component.scss'],
templateUrl: './collection-list-element.component.html'
})
export class CollectionListElementComponent {
@Input() collection: Collection;
@Input() collection: Collection;
data: any = {};
data: any = {};
constructor() {
this.universalInit();
}
constructor() {
this.universalInit();
}
universalInit() {
universalInit() {
}
}
}

View File

@@ -2,22 +2,22 @@ import { Component, Input } from '@angular/core';
import { Community } from "../../core/shared/community.model";
@Component({
selector: 'ds-community-list-element',
styleUrls: ['./community-list-element.component.css'],
templateUrl: './community-list-element.component.html'
selector: 'ds-community-list-element',
styleUrls: ['./community-list-element.component.scss'],
templateUrl: './community-list-element.component.html'
})
export class CommunityListElementComponent {
@Input() community: Community;
@Input() community: Community;
data: any = {};
data: any = {};
constructor() {
this.universalInit();
}
constructor() {
this.universalInit();
}
universalInit() {
universalInit() {
}
}
}

View File

@@ -2,21 +2,21 @@ import { Component, Input } from '@angular/core';
import { Item } from "../../core/shared/item.model";
@Component({
selector: 'ds-item-list-element',
styleUrls: ['./item-list-element.component.css'],
templateUrl: './item-list-element.component.html'
selector: 'ds-item-list-element',
styleUrls: ['./item-list-element.component.scss'],
templateUrl: './item-list-element.component.html'
})
export class ItemListElementComponent {
@Input() item: Item;
@Input() item: Item;
data: any = {};
data: any = {};
constructor() {
this.universalInit();
}
constructor() {
this.universalInit();
}
universalInit() {
universalInit() {
}
}
}

View File

@@ -3,24 +3,24 @@ import { DSpaceObject } from "../../core/shared/dspace-object.model";
import { ResourceType } from "../../core/shared/resource-type";
@Component({
selector: 'ds-object-list-element',
styleUrls: ['./object-list-element.component.css'],
templateUrl: './object-list-element.component.html'
selector: 'ds-object-list-element',
styleUrls: ['./object-list-element.component.scss'],
templateUrl: './object-list-element.component.html'
})
export class ObjectListElementComponent {
public type = ResourceType;
public type = ResourceType;
@Input() object: DSpaceObject;
@Input() object: DSpaceObject;
data: any = {};
data: any = {};
constructor() {
this.universalInit();
}
constructor() {
this.universalInit();
}
universalInit() {
universalInit() {
}
}
}

View File

@@ -2,7 +2,7 @@ import { Component } from '@angular/core';
@Component({
selector: 'ds-pagenotfound',
styleUrls: ['./pagenotfound.component.css'],
styleUrls: ['./pagenotfound.component.scss'],
templateUrl: './pagenotfound.component.html'
})
export class PageNotFoundComponent {

View File

@@ -0,0 +1,98 @@
import 'rxjs/add/operator/filter';
import 'rxjs/add/operator/first';
import { ApplicationRef, Inject, NgModule, APP_BOOTSTRAP_LISTENER } from '@angular/core';
import { RouterModule } from '@angular/router';
import { ServerModule } from '@angular/platform-server';
import { BrowserModule } from '@angular/platform-browser';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { Request } from 'express';
import { REQUEST } from '@nguniversal/express-engine/tokens';
import { TranslateModule, TranslateLoader } from '@ngx-translate/core';
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
import { Store } from "@ngrx/store";
import { Actions, EffectsModule } from '@ngrx/effects';
import { TranslateUniversalLoader } from '../modules/translate-universal-loader';
import { ServerTransferStateModule } from '../modules/transfer-state/server-transfer-state.module';
import { TransferState } from '../modules/transfer-state/transfer-state';
import { TransferStoreEffects } from '../modules/transfer-store/transfer-store.effects';
import { ServerTransferStoreEffects } from '../modules/transfer-store/server-transfer-store.effects';
import { ServerTransferStoreModule } from '../modules/transfer-store/server-transfer-store.module';
import { ServerCookiesModule } from '../modules/cookies/server-cookies.module';
import { ServerDataLoaderModule } from '../modules/data-loader/server-data-loader.module';
import { AppState } from './app.reducer';
import { effects } from './app.effects';
import { SharedModule } from './shared/shared.module';
import { CoreModule } from './core/core.module';
import { AppModule } from './app.module';
import { AppComponent } from './app.component';
import { GLOBAL_CONFIG, GlobalConfig } from '../config';
export function boot(cache: TransferState, appRef: ApplicationRef, store: Store<AppState>, request: Request, config: GlobalConfig) {
// authentication mechanism goes here
return () => {
appRef.isStable.filter((stable: boolean) => stable).first().subscribe(() => {
cache.inject();
});
};
}
export function UniversalLoaderFactory() {
return new TranslateUniversalLoader('dist/assets/i18n', '.json');
}
@NgModule({
bootstrap: [AppComponent],
imports: [
BrowserModule.withServerTransition({
appId: 'ds-app-id'
}),
RouterModule.forRoot([], { useHash: false }),
TranslateModule.forRoot({
loader: {
provide: TranslateLoader,
useFactory: UniversalLoaderFactory,
deps: []
}
}),
NgbModule.forRoot(),
ServerModule,
ServerCookiesModule,
ServerDataLoaderModule,
ServerTransferStateModule,
ServerTransferStoreModule,
EffectsModule.run(ServerTransferStoreEffects),
NoopAnimationsModule,
AppModule
],
providers: [
{
provide: APP_BOOTSTRAP_LISTENER,
multi: true,
useFactory: boot,
deps: [
TransferState,
ApplicationRef,
Store,
REQUEST,
GLOBAL_CONFIG
]
}
]
})
export class ServerAppModule {
}

View File

@@ -2,14 +2,14 @@ import { Component, Input } from '@angular/core';
/**
* This component renders any content inside of this component.
* If there is a title set it will render the title.
* If there is a title set it will render the title.
* If hasInnerHtml is true the content will be handled as html.
* To see how it is used see collection-page or community-page.
*/
@Component({
selector: 'ds-comcol-page-content',
styleUrls: ['./comcol-page-content.component.css'],
styleUrls: ['./comcol-page-content.component.scss'],
templateUrl: './comcol-page-content.component.html'
})
export class ComcolPageContentComponent {

View File

@@ -3,7 +3,7 @@ import { Component, Input } from '@angular/core';
@Component({
selector: 'ds-comcol-page-header',
styleUrls: ['./comcol-page-header.component.css'],
styleUrls: ['./comcol-page-header.component.scss'],
templateUrl: './comcol-page-header.component.html',
})
export class ComcolPageHeaderComponent {

View File

@@ -5,7 +5,7 @@ import { Bitstream } from "../../core/shared/bitstream.model";
@Component({
selector: 'ds-comcol-page-logo',
styleUrls: ['./comcol-page-logo.component.css'],
styleUrls: ['./comcol-page-logo.component.scss'],
templateUrl: './comcol-page-logo.component.html',
})
export class ComcolPageLogoComponent {

View File

@@ -13,6 +13,11 @@
*/
let typeCache: { [label: string]: boolean } = {};
export function types(): string[] {
return Object.keys(typeCache);
}
export function type<T>(label: T | ''): T {
if (typeCache[<string>label]) {
throw new Error(`Action type "${label}" is not unique"`);

View File

@@ -1,82 +1,87 @@
import {
Component, Input, ViewEncapsulation, ChangeDetectionStrategy,
OnInit, Output
Component,
EventEmitter,
Input,
ViewEncapsulation,
ChangeDetectionStrategy,
OnInit,
Output
} from '@angular/core';
import { RemoteData } from "../../core/data/remote-data";
import { DSpaceObject } from "../../core/shared/dspace-object.model";
import { PageInfo } from "../../core/shared/page-info.model";
import { Observable } from "rxjs";
import { PaginationComponentOptions } from "../pagination/pagination-component-options.model";
import { EventEmitter } from "@angular/common/src/facade/async";
import { SortOptions, SortDirection } from "../../core/cache/models/sort-options.model";
@Component({
changeDetection: ChangeDetectionStrategy.Default,
encapsulation: ViewEncapsulation.Emulated,
selector: 'ds-object-list',
styleUrls: ['../../object-list/object-list.component.css'],
templateUrl: '../../object-list/object-list.component.html'
changeDetection: ChangeDetectionStrategy.Default,
encapsulation: ViewEncapsulation.Emulated,
selector: 'ds-object-list',
styleUrls: ['../../object-list/object-list.component.scss'],
templateUrl: '../../object-list/object-list.component.html'
})
export class ObjectListComponent implements OnInit {
@Input() objects: RemoteData<DSpaceObject[]>;
@Input() config : PaginationComponentOptions;
@Input() sortConfig : SortOptions;
@Input() hideGear : boolean = false;
@Input() hidePagerWhenSinglePage : boolean = true;
pageInfo : Observable<PageInfo>;
@Input() objects: RemoteData<DSpaceObject[]>;
@Input() config: PaginationComponentOptions;
@Input() sortConfig: SortOptions;
@Input() hideGear: boolean = false;
@Input() hidePagerWhenSinglePage: boolean = true;
pageInfo: Observable<PageInfo>;
/**
* An event fired when the page is changed.
* Event's payload equals to the newly selected page.
*/
@Output() pageChange: EventEmitter<number> = new EventEmitter<number>();
/**
* An event fired when the page is changed.
* Event's payload equals to the newly selected page.
*/
@Output() pageChange: EventEmitter<number> = new EventEmitter<number>();
/**
* An event fired when the page wsize is changed.
* Event's payload equals to the newly selected page size.
*/
@Output() pageSizeChange: EventEmitter<number> = new EventEmitter<number>();
/**
* An event fired when the page wsize is changed.
* Event's payload equals to the newly selected page size.
*/
@Output() pageSizeChange: EventEmitter<number> = new EventEmitter<number>();
/**
* An event fired when the sort direction is changed.
* Event's payload equals to the newly selected sort direction.
*/
@Output() sortDirectionChange: EventEmitter<SortDirection> = new EventEmitter<SortDirection>();
/**
* An event fired when the sort direction is changed.
* Event's payload equals to the newly selected sort direction.
*/
@Output() sortDirectionChange: EventEmitter<SortDirection> = new EventEmitter<SortDirection>();
/**
* An event fired when the sort field is changed.
* Event's payload equals to the newly selected sort field.
*/
@Output() sortFieldChange: EventEmitter<string> = new EventEmitter<string>();
data: any = {};
/**
* An event fired when the sort field is changed.
* Event's payload equals to the newly selected sort field.
*/
@Output() sortFieldChange: EventEmitter<string> = new EventEmitter<string>();
data: any = {};
constructor() {
this.universalInit();
}
constructor() {
this.universalInit();
}
universalInit() {
}
universalInit() {
}
ngOnInit(): void {
this.pageInfo = this.objects.pageInfo;
}
ngOnInit(): void {
this.pageInfo = this.objects.pageInfo;
}
onPageChange(event) {
this.pageChange.emit(event);
}
onPageChange(event) {
this.pageChange.emit(event);
}
onPageSizeChange(event) {
this.pageSizeChange.emit(event);
}
onPageSizeChange(event) {
this.pageSizeChange.emit(event);
}
onSortDirectionChange(event) {
this.sortDirectionChange.emit(event);
}
onSortDirectionChange(event) {
this.sortDirectionChange.emit(event);
}
onSortFieldChange(event) {
this.sortFieldChange.emit(event);
}
onSortFieldChange(event) {
this.sortFieldChange.emit(event);
}
}

View File

@@ -10,11 +10,13 @@ export class PaginationComponentOptions extends NgbPaginationConfig {
/**
* The active page.
*/
currentPage: number = 1;
currentPage = 1;
/**
* A number array that represents options for a context pagination limit.
*/
pageSizeOptions: Array<number> = [ 5, 10, 20, 40, 60, 80, 100 ];
pageSizeOptions: number[] = [5, 10, 20, 40, 60, 80, 100];
pageSize: number;
}

View File

@@ -1,75 +1,85 @@
// ... test imports
// Load the implementations that should be tested
import { CommonModule } from '@angular/common';
import {
async,
ComponentFixture,
inject,
TestBed, fakeAsync, tick
} from '@angular/core/testing';
import {
Component,
CUSTOM_ELEMENTS_SCHEMA,
DebugElement
} from "@angular/core";
import { ActivatedRoute, Router } from "@angular/router";
import { By } from '@angular/platform-browser';
import { Observable } from "rxjs";
import { RouterTestingModule } from '@angular/router/testing';
import Spy = jasmine.Spy;
import { TranslateModule, TranslateLoader } from '@ngx-translate/core';
import { StoreModule } from "@ngrx/store";
} from '@angular/core';
// Load the implementations that should be tested
import { CommonModule } from '@angular/common';
import { ActivatedRoute, Router } from '@angular/router';
import { By } from '@angular/platform-browser';
import { RouterTestingModule } from '@angular/router/testing';
import { Observable } from 'rxjs/Observable';
import Spy = jasmine.Spy;
import { TranslateModule, TranslateLoader } from '@ngx-translate/core';
import { StoreModule } from '@ngrx/store';
import { Ng2PaginationModule } from 'ng2-pagination';
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
import { PaginationComponent } from './pagination.component';
import { PaginationComponentOptions } from './pagination-component-options.model';
import { MockTranslateLoader } from "../testing/mock-translate-loader";
import { MockTranslateLoader } from '../testing/mock-translate-loader';
import { GLOBAL_CONFIG, EnvConfig } from '../../../config';
import { ActivatedRouteStub, RouterStub } from "../testing/router-stubs";
import { HostWindowService } from "../host-window.service";
import { EnumKeysPipe } from "../utils/enum-keys-pipe";
import { SortOptions } from "../../core/cache/models/sort-options.model";
import { GLOBAL_CONFIG, ENV_CONFIG } from '../../../config';
import { ActivatedRouteStub } from '../testing/active-router-stub';
import { RouterStub } from '../testing/router-stub';
import { HostWindowService } from '../host-window.service';
import { EnumKeysPipe } from '../utils/enum-keys-pipe';
import { SortOptions } from '../../core/cache/models/sort-options.model';
function createTestComponent<T>(html: string, type: {new (...args: any[]): T}): ComponentFixture<T> {
import { TestComponent } from '../testing/test.component';
import { HostWindowServiceStub } from '../testing/host-window-service-stub';
function createTestComponent<T>(html: string, type: { new (...args: any[]): T }): ComponentFixture<T> {
TestBed.overrideComponent(type, {
set: { template: html }
});
let fixture = TestBed.createComponent(type);
const fixture = TestBed.createComponent(type);
fixture.detectChanges();
return fixture as ComponentFixture<T>;
}
function expectPages(fixture: ComponentFixture<any>, pagesDef: string[]): void {
let de = fixture.debugElement.query(By.css('.pagination'));
let pages = de.nativeElement.querySelectorAll('li');
const de = fixture.debugElement.query(By.css('.pagination'));
const pages = de.nativeElement.querySelectorAll('li');
expect(pages.length).toEqual(pagesDef.length);
for (let i = 0; i < pagesDef.length; i++) {
let pageDef = pagesDef[i];
let classIndicator = pageDef.charAt(0);
const pageDef = pagesDef[i];
const classIndicator = pageDef.charAt(0);
if (classIndicator === '+') {
expect(pages[i].classList.contains("active")).toBeTruthy();
expect(pages[i].classList.contains("disabled")).toBeFalsy();
expect(normalizeText(pages[i].textContent)).toEqual(pageDef.substr(1));
expect(pages[i].classList.contains('active')).toBeTruthy();
expect(pages[i].classList.contains('disabled')).toBeFalsy();
expect(normalizeText(pages[i].textContent)).toEqual(normalizeText(pageDef));
} else if (classIndicator === '-') {
expect(pages[i].classList.contains("active")).toBeFalsy();
expect(pages[i].classList.contains("disabled")).toBeTruthy();
expect(normalizeText(pages[i].textContent)).toEqual(pageDef.substr(1));
expect(pages[i].classList.contains('active')).toBeFalsy();
expect(pages[i].classList.contains('disabled')).toBeTruthy();
expect(normalizeText(pages[i].textContent)).toEqual(normalizeText(pageDef));
if (normalizeText(pages[i].textContent) !== '...') {
expect(pages[i].querySelector('a').getAttribute('tabindex')).toEqual('-1');
}
} else {
expect(pages[i].classList.contains("active")).toBeFalsy();
expect(pages[i].classList.contains("disabled")).toBeFalsy();
expect(normalizeText(pages[i].textContent)).toEqual(pageDef);
expect(pages[i].classList.contains('active')).toBeFalsy();
expect(pages[i].classList.contains('disabled')).toBeFalsy();
expect(normalizeText(pages[i].textContent)).toEqual(normalizeText(pageDef));
if (normalizeText(pages[i].textContent) !== '...') {
expect(pages[i].querySelector('a').hasAttribute('tabindex')).toBeFalsy();
}
@@ -78,18 +88,16 @@ function expectPages(fixture: ComponentFixture<any>, pagesDef: string[]): void {
}
function changePageSize(fixture: ComponentFixture<any>, pageSize: string): void {
let buttonEl = fixture.nativeElement.querySelector('#paginationControls');
let activatedRouteStub: ActivatedRouteStub;
let routerStub: RouterStub;
const buttonEl = fixture.nativeElement.querySelector('#paginationControls');
buttonEl.click();
let dropdownMenu = fixture.debugElement.query(By.css('#paginationControlsDropdownMenu'));
let buttons = dropdownMenu.nativeElement.querySelectorAll('button');
const dropdownMenu = fixture.debugElement.query(By.css('#paginationControlsDropdownMenu'));
const buttons = dropdownMenu.nativeElement.querySelectorAll('button');
for (let i = 0; i < buttons.length; i++) {
if (buttons[i].textContent.trim() == pageSize) {
buttons[i].click();
for (const button of buttons) {
if (button.textContent.trim() === pageSize) {
button.click();
fixture.detectChanges();
break;
}
@@ -97,32 +105,30 @@ function changePageSize(fixture: ComponentFixture<any>, pageSize: string): void
}
function changePage(fixture: ComponentFixture<any>, idx: number): void {
let de = fixture.debugElement.query(By.css('.pagination'));
let buttons = de.nativeElement.querySelectorAll('li');
const de = fixture.debugElement.query(By.css('.pagination'));
const buttons = de.nativeElement.querySelectorAll('li');
buttons[idx].querySelector('a').click();
fixture.detectChanges();
}
function normalizeText(txt: string): string {
return txt.trim().replace(/\s+/g, ' ');
const matches = txt.match(/([0-9«»]|\.{3})/);
return matches ? matches[0] : '';
}
describe('Pagination component', () => {
let fixture: ComponentFixture<PaginationComponent>;
let comp: PaginationComponent;
let testComp: TestComponent;
let testFixture: ComponentFixture<TestComponent>;
let de: DebugElement;
let html;
let hostWindowServiceStub: HostWindowServiceStub;
let activatedRouteStub: ActivatedRouteStub;
let routerStub: RouterStub;
//Define initial state and test state
let _initialState = { width: 1600, height: 770 };
// Define initial state and test state
const _initialState = { width: 1600, height: 770 };
// async beforeEach
beforeEach(async(() => {
@@ -138,12 +144,12 @@ describe('Pagination component', () => {
}
}), Ng2PaginationModule, NgbModule.forRoot(),
RouterTestingModule.withRoutes([
{path: 'home', component: TestComponent}
{ path: 'home', component: TestComponent }
])],
declarations: [PaginationComponent, TestComponent, EnumKeysPipe], // declare the test component
providers: [
{ provide: ActivatedRoute, useValue: activatedRouteStub },
{ provide: GLOBAL_CONFIG, useValue: EnvConfig },
{ provide: GLOBAL_CONFIG, useValue: ENV_CONFIG },
{ provide: Router, useValue: routerStub },
{ provide: HostWindowService, useValue: hostWindowServiceStub },
PaginationComponent
@@ -156,15 +162,15 @@ describe('Pagination component', () => {
// synchronous beforeEach
beforeEach(() => {
html = `
<ds-pagination #p="paginationComponent"
[paginationOptions]="paginationOptions"
[sortOptions]="sortOptions"
[collectionSize]="collectionSize"
(pageChange)="pageChanged($event)"
(pageSizeChange)="pageSizeChanged($event)">
<ds-pagination #p='paginationComponent'
[paginationOptions]='paginationOptions'
[sortOptions]='sortOptions'
[collectionSize]='collectionSize'
(pageChange)='pageChanged($event)'
(pageSizeChange)='pageSizeChanged($event)'>
<ul>
<li *ngFor="let item of collection | paginate: { itemsPerPage: paginationOptions.pageSize,
currentPage: paginationOptions.currentPage, totalItems: collectionSize }"> {{item}} </li>
<li *ngFor='let item of collection | paginate: { itemsPerPage: paginationOptions.pageSize,
currentPage: paginationOptions.currentPage, totalItems: collectionSize }'> {{item}} </li>
</ul>
</ds-pagination>`;
@@ -241,107 +247,64 @@ describe('Pagination component', () => {
expect(testComp.pageSizeChanged).toHaveBeenCalledWith(5);
}));
it('should set correct route parameters', fakeAsync(() => {
let paginationComponent: PaginationComponent = testFixture
.debugElement.query(By.css('ds-pagination')).references['p'];
routerStub = testFixture.debugElement.injector.get(Router);
// it('should set correct route parameters', fakeAsync(() => {
// let paginationComponent: PaginationComponent = testFixture.debugElement.query(By.css('ds-pagination')).references['p'];
// routerStub = testFixture.debugElement.injector.get(Router);
//
// testComp.collectionSize = 60;
//
// changePage(testFixture, 3);
// tick();
// expect(routerStub.navigate).toHaveBeenCalledWith([], { queryParams: { pageId: 'test', page: 3, pageSize: 10, sortDirection: 0, sortField: 'name' } });
// expect(paginationComponent.currentPage).toEqual(3);
//
// changePageSize(testFixture, '20');
// tick();
// expect(routerStub.navigate).toHaveBeenCalledWith([], { queryParams: { pageId: 'test', page: 3, pageSize: 20, sortDirection: 0, sortField: 'name' } });
// expect(paginationComponent.pageSize).toEqual(20);
// }));
testComp.collectionSize = 60;
// it('should get parameters from route', () => {
//
// activatedRouteStub = testFixture.debugElement.injector.get(ActivatedRoute);
// activatedRouteStub.testParams = {
// pageId: 'test',
// page: 2,
// pageSize: 20
// };
//
// testFixture.detectChanges();
//
// expectPages(testFixture, ['« Previous', '1', '+2', '3', '4', '5', '» Next']);
// expect(testComp.paginationOptions.currentPage).toEqual(2);
// expect(testComp.paginationOptions.pageSize).toEqual(20);
//
// activatedRouteStub.testParams = {
// pageId: 'test',
// page: 3,
// pageSize: 40
// };
//
// testFixture.detectChanges();
//
// expectPages(testFixture, ['« Previous', '1', '2', '+3', '-» Next']);
// expect(testComp.paginationOptions.currentPage).toEqual(3);
// expect(testComp.paginationOptions.pageSize).toEqual(40);
// });
changePage(testFixture, 3);
tick();
expect(routerStub.navigate).toHaveBeenCalledWith([], { queryParams: { pageId: 'test', page: 3, pageSize: 10, sortDirection: 0, sortField: 'name' } });
expect(paginationComponent.currentPage).toEqual(3);
changePageSize(testFixture, '20');
tick();
expect(routerStub.navigate).toHaveBeenCalledWith([], { queryParams: { pageId: 'test', page: 3, pageSize: 20, sortDirection: 0, sortField: 'name' } });
expect(paginationComponent.pageSize).toEqual(20);
}));
it('should get parameters from route', () => {
activatedRouteStub = testFixture.debugElement.injector.get(ActivatedRoute);
activatedRouteStub.testParams = {
pageId: 'test',
page: 2,
pageSize: 20
};
testFixture.detectChanges();
expectPages(testFixture, ['« Previous', '1', '+2', '3', '4', '5', '» Next']);
expect(testComp.paginationOptions.currentPage).toEqual(2);
expect(testComp.paginationOptions.pageSize).toEqual(20);
activatedRouteStub.testParams = {
pageId: 'test',
page: 3,
pageSize: 40
};
testFixture.detectChanges();
expectPages(testFixture, ['« Previous', '1', '2', '+3', '-» Next']);
expect(testComp.paginationOptions.currentPage).toEqual(3);
expect(testComp.paginationOptions.pageSize).toEqual(40);
});
it('should respond to windows resize', () => {
let paginationComponent: PaginationComponent = testFixture
.debugElement.query(By.css('ds-pagination')).references['p'];
hostWindowServiceStub = testFixture.debugElement.injector.get(HostWindowService);
hostWindowServiceStub.setWidth(400);
hostWindowServiceStub.isXs().subscribe((status) => {
paginationComponent.isXs = status;
testFixture.detectChanges();
expectPages(testFixture, ['-« Previous', '+1', '2', '3', '4', '5', '-...', '10', '» Next']);
de = testFixture.debugElement.query(By.css('ul.pagination'));
expect(de.nativeElement.classList.contains("pagination-sm")).toBeTruthy();
});
});
// it('should respond to windows resize', () => {
// let paginationComponent: PaginationComponent = testFixture
// .debugElement.query(By.css('ds-pagination')).references['p'];
// hostWindowServiceStub = testFixture.debugElement.injector.get(HostWindowService);
//
// hostWindowServiceStub.setWidth(400);
//
// hostWindowServiceStub.isXs().subscribe((status) => {
// paginationComponent.isXs = status;
// testFixture.detectChanges();
// expectPages(testFixture, ['-« Previous', '+1', '2', '3', '4', '5', '-...', '10', '» Next']);
// de = testFixture.debugElement.query(By.css('ul.pagination'));
// expect(de.nativeElement.classList.contains('pagination-sm')).toBeTruthy();
// });
// });
});
// declare a test component
@Component({selector: 'ds-test-cmp', template: ''})
class TestComponent {
collection: string[] = [];
collectionSize: number;
paginationOptions = new PaginationComponentOptions();
sortOptions = new SortOptions();
constructor() {
this.collection = Array.from(new Array(100), (x, i) => `item ${i + 1}`);
this.collectionSize = 100;
this.paginationOptions.id = 'test';
}
pageChanged(page) {
this.paginationOptions.currentPage = page;
}
pageSizeChanged(pageSize) {
this.paginationOptions.pageSize = pageSize;
}
}
// declare a stub service
class HostWindowServiceStub {
private width: number;
constructor(width) {
this.setWidth(width);
}
setWidth(width) {
this.width = width;
}
isXs(): Observable<boolean> {
return Observable.of(this.width < 576);
}
}

View File

@@ -1,144 +1,148 @@
import {
ChangeDetectionStrategy,
Component,
EventEmitter,
Input,
OnDestroy,
OnInit,
Output,
ViewEncapsulation
} from '@angular/core'
import { ActivatedRoute, Router } from '@angular/router';
import { Subscription } from "rxjs/Subscription";
import { isNumeric } from "rxjs/util/isNumeric";
import 'rxjs/add/operator/switchMap';
import { Observable } from "rxjs";
import {
ChangeDetectionStrategy,
Component,
EventEmitter,
Input,
OnDestroy,
OnInit,
Output,
ViewEncapsulation
} from '@angular/core'
import { ActivatedRoute, Router } from '@angular/router';
import { Subscription } from 'rxjs/Subscription';
import { isNumeric } from 'rxjs/util/isNumeric';
import { Observable } from 'rxjs/Observable';
// It is necessary to use ng2-pagination
import { DEFAULT_TEMPLATE, DEFAULT_STYLES } from 'ng2-pagination/dist/template';
import { HostWindowService } from "../host-window.service";
import { HostWindowState } from "../host-window.reducer";
import { HostWindowService } from '../host-window.service';
import { HostWindowState } from '../host-window.reducer';
import { PaginationComponentOptions } from './pagination-component-options.model';
import { SortDirection, SortOptions } from "../../core/cache/models/sort-options.model";
import { hasValue } from "../empty.util";
import { SortDirection, SortOptions } from '../../core/cache/models/sort-options.model';
import { hasValue } from '../empty.util';
/**
* The default pagination controls component.
*/
@Component({
exportAs: 'paginationComponent',
selector: 'ds-pagination',
templateUrl: 'pagination.component.html',
changeDetection: ChangeDetectionStrategy.Default,
encapsulation: ViewEncapsulation.Emulated
exportAs: 'paginationComponent',
selector: 'ds-pagination',
templateUrl: 'pagination.component.html',
changeDetection: ChangeDetectionStrategy.Default,
encapsulation: ViewEncapsulation.Emulated
})
export class PaginationComponent implements OnDestroy, OnInit {
/**
* Number of items in collection.
*/
@Input() collectionSize: number;
/**
* Number of items in collection.
*/
@Input() collectionSize: number;
/**
* Configuration for the NgbPagination component.
*/
@Input() paginationOptions: PaginationComponentOptions;
/**
* Configuration for the NgbPagination component.
*/
@Input() paginationOptions: PaginationComponentOptions;
/**
* Sort configuration for this component.
*/
@Input() sortOptions: SortOptions;
/**
* Sort configuration for this component.
*/
@Input() sortOptions: SortOptions;
/**
* An event fired when the page is changed.
* Event's payload equals to the newly selected page.
*/
@Output() pageChange: EventEmitter<number> = new EventEmitter<number>();
/**
* An event fired when the page is changed.
* Event's payload equals to the newly selected page.
*/
@Output() pageChange: EventEmitter<number> = new EventEmitter<number>();
/**
* An event fired when the page wsize is changed.
* Event's payload equals to the newly selected page size.
*/
@Output() pageSizeChange: EventEmitter<number> = new EventEmitter<number>();
/**
* An event fired when the page wsize is changed.
* Event's payload equals to the newly selected page size.
*/
@Output() pageSizeChange: EventEmitter<number> = new EventEmitter<number>();
/**
* An event fired when the sort direction is changed.
* Event's payload equals to the newly selected sort direction.
*/
@Output() sortDirectionChange: EventEmitter<SortDirection> = new EventEmitter<SortDirection>();
/**
* An event fired when the sort direction is changed.
* Event's payload equals to the newly selected sort direction.
*/
@Output() sortDirectionChange: EventEmitter<SortDirection> = new EventEmitter<SortDirection>();
/**
* An event fired when the sort field is changed.
* Event's payload equals to the newly selected sort field.
*/
@Output() sortFieldChange: EventEmitter<string> = new EventEmitter<string>();
/**
* An event fired when the sort field is changed.
* Event's payload equals to the newly selected sort field.
*/
@Output() sortFieldChange: EventEmitter<string> = new EventEmitter<string>();
/**
* Option for hiding the gear
*/
@Input() public hideGear = false;
/**
* Option for hiding the gear
*/
@Input() public hideGear: boolean = false;
/**
* Option for hiding the pager when there is less than 2 pages
*/
@Input() public hidePagerWhenSinglePage = true;
/**
* Option for hiding the pager when there is less than 2 pages
*/
@Input() public hidePagerWhenSinglePage: boolean = true;
/**
* Current page.
*/
public currentPage = 1;
/**
* Current page.
*/
public currentPage = 1;
/**
* Current URL query parameters
*/
public currentQueryParams = {};
/**
* Current URL query parameters
*/
public currentQueryParams = {};
/**
* An observable of HostWindowState type
*/
public hostWindow: Observable<HostWindowState>;
/**
* An observable of HostWindowState type
*/
public hostWindow: Observable<HostWindowState>;
/**
* ID for the pagination instance. Only useful if you wish to
* have more than once instance at a time in a given component.
*/
private id: string;
/**
* ID for the pagination instance. Only useful if you wish to
* have more than once instance at a time in a given component.
*/
private id: string;
/**
* A boolean that indicate if is an extra small devices viewport.
*/
public isXs: boolean;
/**
* A boolean that indicate if is an extra small devices viewport.
*/
public isXs: boolean;
/**
* Number of items per page.
*/
public pageSize = 10;
/**
* Number of items per page.
*/
public pageSize: number = 10;
/**
* Declare SortDirection enumeration to use it in the template
*/
public sortDirections = SortDirection
/**
* Declare SortDirection enumeration to use it in the template
*/
public sortDirections = SortDirection
/**
* A number array that represents options for a context pagination limit.
*/
private pageSizeOptions: number[];
/**
* A number array that represents options for a context pagination limit.
*/
private pageSizeOptions: Array<number>;
/**
* Direction in which to sort: ascending or descending
*/
public sortDirection: SortDirection = SortDirection.Ascending;
/**
* Direction in which to sort: ascending or descending
*/
public sortDirection: SortDirection = SortDirection.Ascending;
/**
* Name of the field that's used to sort by
*/
public sortField = 'id';
/**
* Name of the field that's used to sort by
*/
public sortField: string = "id";
/**
* Local variable, which can be used in the template to access the paginate controls ngbDropdown methods and properties
*/
public paginationControls;
/**
* Local variable, which can be used in the template to access the paginate controls ngbDropdown methods and properties
*/
public paginationControls;
/**
* Array to track all subscriptions and unsubscribe them onDestroy
@@ -147,209 +151,209 @@ export class PaginationComponent implements OnDestroy, OnInit {
private subs: Subscription[] = [];
/**
* An object that represents pagination details of the current viewed page
*/
public showingDetail: any = {
range: null,
total: null
};
* An object that represents pagination details of the current viewed page
*/
public showingDetail: any = {
range: null,
total: null
};
/**
* Method provided by Angular. Invoked after the constructor.
*/
ngOnInit() {
this.subs.push(this.hostWindowService.isXs()
.subscribe((status: boolean) => {
this.isXs = status;
}));
this.checkConfig(this.paginationOptions);
this.id = this.paginationOptions.id || null;
this.currentPage = this.paginationOptions.currentPage;
this.pageSize = this.paginationOptions.pageSize;
this.pageSizeOptions = this.paginationOptions.pageSizeOptions;
this.sortDirection = this.sortOptions.direction;
this.sortField = this.sortOptions.field;
this.subs.push(this.route.queryParams
.filter(queryParams => hasValue(queryParams))
.subscribe(queryParams => {
this.currentQueryParams = queryParams;
if (this.id == queryParams['pageId']
&& (this.paginationOptions.currentPage != queryParams['page']
|| this.paginationOptions.pageSize != queryParams['pageSize']
|| this.sortOptions.direction != queryParams['sortDirection']
|| this.sortOptions.field != queryParams['sortField'] )
) {
this.validateParams(queryParams['page'], queryParams['pageSize'], queryParams['sortDirection'], queryParams['sortField']);
}
}));
this.setShowingDetail();
}
/**
* Method provided by Angular. Invoked when the instance is destroyed.
*/
ngOnDestroy() {
this.subs
.filter(sub => hasValue(sub))
.forEach(sub => sub.unsubscribe());
}
/**
* @param route
* Route is a singleton service provided by Angular.
* @param router
* Router is a singleton service provided by Angular.
*/
constructor(private route: ActivatedRoute,
private router: Router,
public hostWindowService: HostWindowService) {
}
/**
* Method to set set new page and update route parameters
*
* @param page
* The page being navigated to.
*/
public doPageChange(page: number) {
this.currentPage = page;
this.updateRoute();
this.setShowingDetail();
this.pageChange.emit(page);
}
/**
* Method to set set new page size and update route parameters
*
* @param pageSize
* The new page size.
*/
public setPageSize(pageSize: number) {
this.pageSize = pageSize;
this.updateRoute();
this.setShowingDetail();
this.pageSizeChange.emit(pageSize);
}
/**
* Method to set set new sort direction and update route parameters
*
* @param sortDirection
* The new sort direction.
*/
public setSortDirection(sortDirection: SortDirection) {
this.sortDirection = sortDirection;
this.updateRoute();
this.setShowingDetail();
this.sortDirectionChange.emit(sortDirection);
}
/**
* Method to set set new sort field and update route parameters
*
* @param sortField
* The new sort field.
*/
public setSortField(field: string) {
this.sortField = field;
this.updateRoute();
this.setShowingDetail();
this.sortFieldChange.emit(field);
}
/**
* Method to update the route parameters
*/
private updateRoute() {
this.router.navigate([], {
queryParams: Object.assign({}, this.currentQueryParams, {
pageId: this.id,
page: this.currentPage,
pageSize: this.pageSize,
sortDirection: this.sortDirection,
sortField: this.sortField
})
});
}
/**
* Method to set pagination details of the current viewed page.
*/
private setShowingDetail() {
let firstItem;
let lastItem;
let lastPage = Math.round(this.collectionSize / this.pageSize);
firstItem = this.pageSize * (this.currentPage - 1) + 1;
if (this.currentPage != lastPage) {
lastItem = this.pageSize * this.currentPage;
} else {
lastItem = this.collectionSize;
/**
* Method provided by Angular. Invoked after the constructor.
*/
ngOnInit() {
this.subs.push(this.hostWindowService.isXs()
.subscribe((status: boolean) => {
this.isXs = status;
}));
this.checkConfig(this.paginationOptions);
this.id = this.paginationOptions.id || null;
this.currentPage = this.paginationOptions.currentPage;
this.pageSize = this.paginationOptions.pageSize;
this.pageSizeOptions = this.paginationOptions.pageSizeOptions;
this.sortDirection = this.sortOptions.direction;
this.sortField = this.sortOptions.field;
this.subs.push(this.route.queryParams
.filter((queryParams) => hasValue(queryParams))
.subscribe((queryParams) => {
this.currentQueryParams = queryParams;
if (this.id === queryParams.pageId
&& (this.paginationOptions.currentPage !== queryParams.page
|| this.paginationOptions.pageSize !== queryParams.pageSize
|| this.sortOptions.direction !== queryParams.sortDirection
|| this.sortOptions.field !== queryParams.sortField)
) {
this.validateParams(queryParams.page, queryParams.pageSize, queryParams.sortDirection, queryParams.sortField);
}
this.showingDetail = {
range: firstItem + ' - ' + lastItem,
total: this.collectionSize
}));
this.setShowingDetail();
}
/**
* Method provided by Angular. Invoked when the instance is destroyed.
*/
ngOnDestroy() {
this.subs
.filter((sub) => hasValue(sub))
.forEach((sub) => sub.unsubscribe());
}
/**
* @param route
* Route is a singleton service provided by Angular.
* @param router
* Router is a singleton service provided by Angular.
*/
constructor(
private route: ActivatedRoute,
private router: Router,
public hostWindowService: HostWindowService) {
}
/**
* Method to set set new page and update route parameters
*
* @param page
* The page being navigated to.
*/
public doPageChange(page: number) {
this.currentPage = page;
this.updateRoute();
this.setShowingDetail();
this.pageChange.emit(page);
}
/**
* Method to set set new page size and update route parameters
*
* @param pageSize
* The new page size.
*/
public setPageSize(pageSize: number) {
this.pageSize = pageSize;
this.updateRoute();
this.setShowingDetail();
this.pageSizeChange.emit(pageSize);
}
/**
* Method to set set new sort direction and update route parameters
*
* @param sortDirection
* The new sort direction.
*/
public setSortDirection(sortDirection: SortDirection) {
this.sortDirection = sortDirection;
this.updateRoute();
this.setShowingDetail();
this.sortDirectionChange.emit(sortDirection);
}
/**
* Method to set set new sort field and update route parameters
*
* @param sortField
* The new sort field.
*/
public setSortField(field: string) {
this.sortField = field;
this.updateRoute();
this.setShowingDetail();
this.sortFieldChange.emit(field);
}
/**
* Method to update the route parameters
*/
private updateRoute() {
this.router.navigate([], {
queryParams: Object.assign({}, this.currentQueryParams, {
pageId: this.id,
page: this.currentPage,
pageSize: this.pageSize,
sortDirection: this.sortDirection,
sortField: this.sortField
})
});
}
/**
* Method to set pagination details of the current viewed page.
*/
private setShowingDetail() {
let firstItem;
let lastItem;
const lastPage = Math.round(this.collectionSize / this.pageSize);
firstItem = this.pageSize * (this.currentPage - 1) + 1;
if (this.currentPage !== lastPage) {
lastItem = this.pageSize * this.currentPage;
} else {
lastItem = this.collectionSize;
}
this.showingDetail = {
range: firstItem + ' - ' + lastItem,
total: this.collectionSize
}
}
/**
* Validate query params
*
* @param page
* The page number to validate
* @param pageSize
* The page size to validate
*/
private validateParams(page: any, pageSize: any, sortDirection: any, sortField: any) {
let filteredPageSize = this.pageSizeOptions.find((x) => x === pageSize);
if (!isNumeric(page) || !filteredPageSize) {
const filteredPage = isNumeric(page) ? page : this.currentPage;
filteredPageSize = (filteredPageSize) ? filteredPageSize : this.pageSize;
this.router.navigate([], {
queryParams: {
pageId: this.id,
page: filteredPage,
pageSize: filteredPageSize,
sortDirection: sortDirection,
sortField: sortField
}
}
);
} else {
// (+) converts string to a number
this.currentPage = +page;
this.pageSize = +pageSize;
this.sortDirection = +sortDirection;
this.sortField = sortField;
this.pageChange.emit(this.currentPage);
this.pageSizeChange.emit(this.pageSize);
this.sortDirectionChange.emit(this.sortDirection);
this.sortFieldChange.emit(this.sortField);
}
}
/**
* Validate query params
*
* @param page
* The page number to validate
* @param pageSize
* The page size to validate
*/
private validateParams(page: any, pageSize: any, sortDirection: any, sortField: any) {
let filteredPageSize = this.pageSizeOptions.find(x => x == pageSize);
if (!isNumeric(page) || !filteredPageSize) {
let filteredPage = isNumeric(page) ? page : this.currentPage;
filteredPageSize = (filteredPageSize) ? filteredPageSize : this.pageSize;
this.router.navigate([], {
queryParams: {
pageId: this.id,
page: filteredPage,
pageSize: filteredPageSize,
sortDirection: sortDirection,
sortField: sortField
}
}
);
} else {
// (+) converts string to a number
this.currentPage = +page;
this.pageSize = +pageSize;
this.sortDirection = +sortDirection;
this.sortField = sortField;
this.pageChange.emit(this.currentPage);
this.pageSizeChange.emit(this.pageSize);
this.sortDirectionChange.emit(this.sortDirection);
this.sortFieldChange.emit(this.sortField);
}
/**
* Ensure options passed contains the required properties.
*
* @param paginateOptions
* The paginate options object.
*/
private checkConfig(paginateOptions: any) {
const required = ['id', 'currentPage', 'pageSize', 'pageSizeOptions'];
const missing = required.filter((prop) => {
return !(prop in paginateOptions);
});
if (0 < missing.length) {
throw new Error('Paginate: Argument is missing the following required properties: ' + missing.join(', '));
}
}
/**
* Ensure options passed contains the required properties.
*
* @param paginateOptions
* The paginate options object.
*/
private checkConfig(paginateOptions: any) {
let required = ['id', 'currentPage', 'pageSize', 'pageSizeOptions'];
let missing = required.filter(function (prop) {
return !(prop in paginateOptions);
});
if (0 < missing.length) {
throw new Error("Paginate: Argument is missing the following required properties: " + missing.join(', '));
}
}
get hasMultiplePages(): boolean {
return this.collectionSize > this.pageSize;
}
get hasMultiplePages(): boolean {
return this.collectionSize > this.pageSize;
}
get shouldShowBottomPager(): boolean {
return this.hasMultiplePages || !this.hidePagerWhenSinglePage
}
get shouldShowBottomPager(): boolean {
return this.hasMultiplePages || !this.hidePagerWhenSinglePage
}
}

View File

@@ -8,22 +8,22 @@ import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
import { TranslateModule } from '@ngx-translate/core';
import { ApiService } from './api.service';
import { PaginationComponent } from "./pagination/pagination.component";
import { FileSizePipe } from "./utils/file-size-pipe";
import { ThumbnailComponent } from "../thumbnail/thumbnail.component";
import { SafeUrlPipe } from "./utils/safe-url-pipe";
import { HostWindowService } from "./host-window.service";
import { NativeWindowFactory, NativeWindowService } from "./window.service";
import { ComcolPageContentComponent } from "./comcol-page-content/comcol-page-content.component";
import { ComcolPageHeaderComponent } from "./comcol-page-header/comcol-page-header.component";
import { ComcolPageLogoComponent } from "./comcol-page-logo/comcol-page-logo.component";
import { EnumKeysPipe } from "./utils/enum-keys-pipe";
import { ObjectListComponent } from "./object-list/object-list.component";
import { ObjectListElementComponent } from "../object-list/object-list-element/object-list-element.component";
import { ItemListElementComponent } from "../object-list/item-list-element/item-list-element.component";
import { CommunityListElementComponent } from "../object-list/community-list-element/community-list-element.component";
import { CollectionListElementComponent } from "../object-list/collection-list-element/collection-list-element.component";
import { TruncatePipe } from "./utils/truncate.pipe";
import { PaginationComponent } from './pagination/pagination.component';
import { FileSizePipe } from './utils/file-size-pipe';
import { ThumbnailComponent } from '../thumbnail/thumbnail.component';
import { SafeUrlPipe } from './utils/safe-url-pipe';
import { HostWindowService } from './host-window.service';
import { NativeWindowFactory, NativeWindowService } from './window.service';
import { ComcolPageContentComponent } from './comcol-page-content/comcol-page-content.component';
import { ComcolPageHeaderComponent } from './comcol-page-header/comcol-page-header.component';
import { ComcolPageLogoComponent } from './comcol-page-logo/comcol-page-logo.component';
import { EnumKeysPipe } from './utils/enum-keys-pipe';
import { ObjectListComponent } from './object-list/object-list.component';
import { ObjectListElementComponent } from '../object-list/object-list-element/object-list-element.component';
import { ItemListElementComponent } from '../object-list/item-list-element/item-list-element.component';
import { CommunityListElementComponent } from '../object-list/community-list-element/community-list-element.component';
import { CollectionListElementComponent } from '../object-list/collection-list-element/collection-list-element.component';
import { TruncatePipe } from './utils/truncate.pipe';
const MODULES = [
// Do NOT include UniversalModule, HttpModule, or JsonpModule here
@@ -37,10 +37,10 @@ const MODULES = [
];
const PIPES = [
FileSizePipe,
SafeUrlPipe,
EnumKeysPipe,
TruncatePipe
FileSizePipe,
SafeUrlPipe,
EnumKeysPipe,
TruncatePipe
// put pipes here
];

View File

@@ -1,10 +1,6 @@
import { Params } from "@angular/router";
import { BehaviorSubject } from "rxjs";
import { Params } from '@angular/router';
export class RouterStub {
//noinspection TypeScriptUnresolvedFunction
navigate = jasmine.createSpy('navigate');
}
import { BehaviorSubject } from 'rxjs/BehaviorSubject';
export class ActivatedRouteStub {
@@ -13,6 +9,8 @@ export class ActivatedRouteStub {
params = this.subject.asObservable();
queryParams = this.subject.asObservable();
private _testParams: {};
constructor(params?: Params) {
if (params) {
this.testParams = params;
@@ -22,7 +20,6 @@ export class ActivatedRouteStub {
}
// Test parameters
private _testParams: {};
get testParams() { return this._testParams; }
set testParams(params: {}) {
this._testParams = params;

Some files were not shown because too many files have changed in this diff Show More