Update and refactor to the latest version of angular universal starter repo -> 2016-11-22

git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-portal/trunk@44619 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
argiro.kokogiannaki 2016-11-22 13:36:12 +00:00
parent 6a95445031
commit 34d56e4fb0
63 changed files with 1717 additions and 1210 deletions

6
portal-2/.gitignore vendored
View File

@ -8,5 +8,11 @@ npm-debug.log
/dist/
.idea
*.ngfactory.ts
*.css.shim.ts
.DS_Store
webpack.records.json
/npm-debug.log.*

View File

@ -16,18 +16,30 @@ A minimal Angular 2 starter for Universal JavaScript using TypeScript 2 and Webp
## Universal "Gotchas"
- To use `templateUrl` or `stylesUrl` you must use **`angular2-template-loader`** in your TS loaders.
> When building Universal components in Angular 2 there are a few things to keep in mind.
- To use `templateUrl` or `styleUrls` you must use **`angular2-template-loader`** in your TS loaders.
- This is already setup within this starter repo. Look at the webpack.config file [here](https://github.com/angular/universal-starter/blob/master/webpack.config.ts) for details & implementation.
- **`window`** & **`document`** do not exist on the server - so using them, or any library that uses them (jQuery for example) will not work.
- If you need to use them, consider limiting them to only your main.client and wrapping them situationally with the imported *isBrowser / isNode* features from Universal. `import { isBrowser, isNode } from 'angular2-universal';
- **`window`**, **`document`**, **`navigator`**, and other browser types - _do not exist on the server_ - so using them, or any library that uses them (jQuery for example) will not work. You do have some options, if you truly need some of this functionality:
- If you need to use them, consider limiting them to only your main.client and wrapping them situationally with the imported *isBrowser / isNode* features from Universal. `import { isBrowser, isNode } from 'angular2-universal'`;
- Another option is using `DOM` from ["@angular/platform-browser"](https://github.com/angular/angular/blob/e3687706c71beb7c9dbdae1bbb5fbbcea588c476/modules/%40angular/platform-browser/src/dom/dom_adapter.ts#L34)
- **Don't manipulate the nativeElement directly**. Use the _Renderer_. We do this to ensure that in any environment we're able to change our view.
```
constructor(element: ElementRef, renderer: Renderer) {
renderer.setElementStyle(element.nativeElement, 'font-size', 'x-large');
}
```
- The application runs XHR requests on the server & once again on the Client-side (when the application bootstraps)
- Use a [UniversalCache](https://github.com/angular/universal-starter/blob/master/src/app/universal-cache.ts) to save certain requests so they aren't re-ran again on the Client.
- Use a [UniversalCache](https://github.com/angular/universal-starter/blob/master/src/app/shared/api.service.ts#L47-L71) instead of regular Http, to save certain requests so they aren't re-ran again on the Client.
- Know the difference between attributes and properties in relation to the DOM.
- Keep your directives stateless as much as possible. For stateful directives, you may need to provide an attribute that reflects the corresponding property with an initial string value such as url in img tag. For our native <img src=""> element the src attribute is reflected as the src property of the element type HTMLImageElement.
## Upcoming Universal features
- SeoServices
- Universal fixes for Angular Core 2.1.1
- AoT funcionality is still a *work-in-progress*, but is available as of 2.1.0-rc1
## Installation
@ -44,6 +56,9 @@ A minimal Angular 2 starter for Universal JavaScript using TypeScript 2 and Webp
## Watch files
* `npm run watch` to build your client app and start a web server
## AoT and Prod
* `npm run build:prod:ngc` to compile the ngfactory files and build prod
## Edge case of server compatibility with Promise polyfills
If you have node modules with promise polyfill dependency on server - there is chance to get the following exception:

7
portal-2/empty.js Normal file
View File

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

View File

@ -8,9 +8,16 @@
},
"scripts": {
"watch": "webpack --watch",
"prebuild": "rimraf dist",
"build": "webpack",
"build:prod": "webpack --progress -p",
"watch:dev": "npm run server & npm run watch",
"clean:dist": "rimraf dist",
"clean:ngc": "rimraf **/*.ngfactory.ts",
"prebuild": "npm run clean:dist",
"build": "webpack --progress",
"build:prod:ngc": "npm run clean:ngc && npm run ngc && npm run clean:dist && npm run build:prod",
"build:prod:ngc:json": "npm run clean:ngc && npm run ngc && npm run clean:dist && npm run build:prod:json",
"build:prod": "webpack --config webpack.prod.config.ts",
"build:prod:json": "webpack --config webpack.prod.config.ts --json | webpack-bundle-size-analyzer",
"ngc": "ngc -p tsconfig.aot.json",
"prestart": "npm run build",
"server": "nodemon dist/server/index.js",
"debug:server": "node-nightly --inspect --debug-brk dist/server/index.js",
@ -18,6 +25,7 @@
"debug:start": "npm run build && npm run debug:server",
"predebug": "npm run build",
"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",
"debug": "node --debug-brk dist/server/index.js"
},
"license": "MIT",
@ -29,18 +37,18 @@
"Mark Pieszak <mpieszak84@gmail.com>"
],
"dependencies": {
"@angular/common": "2.1.0",
"@angular/compiler": "2.1.0",
"@angular/compiler-cli": "2.1.0",
"@angular/core": "2.1.0",
"@angular/forms": "2.1.0",
"@angular/http": "2.1.0",
"@angular/platform-browser": "2.1.0",
"@angular/platform-browser-dynamic": "2.1.0",
"@angular/platform-server": "2.1.0",
"@angular/router": "3.1.0",
"@ngtools/webpack": "^1.1.4",
"@ng-bootstrap/ng-bootstrap": "^1.0.0-alpha.6",
"@angular/common": "~2.2.1",
"@angular/compiler": "~2.2.1",
"@angular/compiler-cli": "~2.2.1",
"@angular/core": "~2.2.1",
"@angular/forms": "~2.2.1",
"@angular/http": "~2.2.1",
"@angular/platform-browser": "~2.2.1",
"@angular/platform-browser-dynamic": "~2.2.1",
"@angular/platform-server": "~2.2.1",
"@angular/router": "~3.2.1",
"@angular/upgrade": "~2.2.1",
"@ngtools/webpack": "~1.1.7",
"angular2-express-engine": "~2.1.0-rc.1",
"angular2-platform-node": "~2.1.0-rc.1",
"angular2-universal": "~2.1.0-rc.1",
@ -48,9 +56,11 @@
"body-parser": "^1.15.2",
"bootstrap": "^4.0.0-alpha.4",
"express": "^4.14.0",
"js.clone": "0.0.3",
"methods": "~1.1.2",
"preboot": "~4.5.2",
"rxjs": "5.0.0-beta.12",
"webfontloader": "^1.6.26",
"zone.js": "~0.6.26"
},
"devDependencies": {
@ -63,6 +73,7 @@
"@types/mime": "0.0.28",
"@types/node": "^6.0.38",
"@types/serve-static": "^1.7.27",
"@types/webfontloader": "^1.6.27",
"angular2-template-loader": "^0.4.0",
"awesome-typescript-loader": "^2.2.4",
"cookie-parser": "^1.4.3",
@ -72,11 +83,14 @@
"raw-loader": "^0.5.1",
"rimraf": "^2.5.4",
"string-replace-loader": "^1.0.5",
"ts-helpers": "^1.1.2",
"ts-node": "^1.3.0",
"typescript": "2.0.2",
"webpack": "2.1.0-beta.25",
"webpack-dev-middleware": "^1.6.1",
"webpack-dev-server": "2.1.0-beta.9",
"webpack-merge": "^0.13.0"
"v8-lazy-parse-webpack-plugin": "^0.3.0",
"webpack-bundle-analyzer": "1.4.1",
"webpack": "2.1.0-beta.27",
"webpack-dev-middleware": "^1.8.4",
"webpack-dev-server": "2.1.0-beta.11",
"webpack-merge": "~0.16.0"
}
}

81
portal-2/package.json_ Normal file
View File

@ -0,0 +1,81 @@
{
"name": "universal-starter",
"version": "2.0.0",
"description": "Angular 2 Universal starter kit by @AngularClass",
"repository": {
"type": "git",
"url": "https://github.com/angular/universal-starter.git"
},
"scripts": {
"watch": "webpack --watch",
"prebuild": "rimraf dist",
"build": "webpack",
"build:prod": "webpack --progress -p",
"prestart": "npm run build",
"server": "nodemon dist/server/index.js",
"debug:server": "node-nightly --inspect --debug-brk dist/server/index.js",
"start": "npm run server",
"debug:start": "npm run build && npm run debug:server",
"predebug": "npm run build",
"debug:build": "node-nightly --inspect --debug-brk node_modules/webpack/bin/webpack.js",
"debug": "node --debug-brk dist/server/index.js"
},
"license": "MIT",
"contributors": [
"AngularClass <hello@angularclass.com>",
"PatrickJS <patrick@angularclass.com>",
"Jeff Whelpley <jeff@gethuman.com>",
"Jeff Cross <crossj@google.com>",
"Mark Pieszak <mpieszak84@gmail.com>"
],
"dependencies": {
"@angular/common": "2.0.0",
"@angular/compiler": "2.0.0",
"@angular/core": "2.0.0",
"@angular/forms": "2.0.0",
"@angular/http": "2.0.0",
"@angular/platform-browser": "2.0.0",
"@angular/platform-browser-dynamic": "2.0.0",
"@angular/platform-server": "2.0.0",
"@angular/router": "3.0.0",
"@ng-bootstrap/ng-bootstrap": "^1.0.0-alpha.6",
"angular2-express-engine": "~2.0.11",
"angular2-platform-node": "~2.0.11",
"angular2-universal": "~2.0.11",
"angular2-universal-polyfills": "~2.0.11",
"body-parser": "^1.15.2",
"bootstrap": "^4.0.0-alpha.4",
"express": "^4.14.0",
"methods": "~1.1.2",
"ng2-webstorage": "^1.2.2",
"rxjs": "5.0.0-beta.12",
"zone.js": "0.6.23"
},
"devDependencies": {
"@angularclass/resolve-angular-routes": "^1.0.9",
"@types/body-parser": "0.0.29",
"@types/compression": "0.0.29",
"@types/cookie-parser": "^1.3.29",
"@types/express": "^4.0.32",
"@types/express-serve-static-core": "^4.0.33",
"@types/hammerjs": "^2.0.32",
"@types/mime": "0.0.28",
"@types/node": "^6.0.38",
"@types/serve-static": "^1.7.27",
"angular2-template-loader": "^0.4.0",
"cookie-parser": "^1.4.3",
"imports-loader": "^0.6.5",
"json-loader": "^0.5.4",
"nodemon": "^1.10.0",
"raw-loader": "^0.5.1",
"rimraf": "^2.5.4",
"string-replace-loader": "github:gdi2290/string-replace-loader",
"ts-loader": "^0.8.2",
"ts-node": "^1.3.0",
"typescript": "2.0.0",
"webpack": "2.1.0-beta.22",
"webpack-dev-middleware": "^1.6.1",
"webpack-dev-server": "^2.1.0-beta.0",
"webpack-merge": "^0.13.0"
}
}

View File

@ -0,0 +1,24 @@
/*
* THIS IS TEMPORARY TO PATCH 2.1.1+ Core bugs
*/
/* tslint:disable */
let __compiler__ = require('@angular/compiler');
import { __platform_browser_private__ } from '@angular/platform-browser';
import { __core_private__ } from '@angular/core';
let patch = false;
if (!__core_private__['ViewUtils']) {
patch = true;
__core_private__['ViewUtils'] = __core_private__['view_utils'];
}
if (__compiler__ && __compiler__.SelectorMatcher && __compiler__.CssSelector) {
patch = true;
(__compiler__).__compiler_private__ = {
SelectorMatcher: __compiler__.SelectorMatcher,
CssSelector: __compiler__.CssSelector
}
}

View File

@ -0,0 +1,44 @@
/*
* THIS IS TEMPORARY TO PATCH 2.1.1+ Core bugs
*/
/* tslint:disable */
let __compiler__ = require('@angular/compiler');
import { __platform_browser_private__ } from '@angular/platform-browser';
import { __core_private__ } from '@angular/core';
let patch = false;
if (!__core_private__['ViewUtils']) {
patch = true;
__core_private__['ViewUtils'] = __core_private__['view_utils'];
}
if (__compiler__ && __compiler__.SelectorMatcher && __compiler__.CssSelector) {
patch = true;
(__compiler__).__compiler_private__ = {
SelectorMatcher: __compiler__.SelectorMatcher,
CssSelector: __compiler__.CssSelector
}
}
if (patch) {
var __universal__ = require('angular2-platform-node/__private_imports__');
__universal__.ViewUtils = __core_private__['view_utils'];
__universal__.CssSelector = __universal__.CssSelector || __compiler__.CssSelector;
__universal__.SelectorMatcher = __universal__.SelectorMatcher || __compiler__.SelectorMatcher;
}
// Fix Material Support
function universalMaterialSupports(eventName: string): boolean { return Boolean(this.isCustomEvent(eventName)); }
__platform_browser_private__.HammerGesturesPlugin.prototype.supports = universalMaterialSupports;
// End Fix Material Support
// Fix Universal Style
import { NodeDomRootRenderer, NodeDomRenderer } from 'angular2-universal/node';
function renderComponentFix(componentProto: any) {
return new NodeDomRenderer(this, componentProto, this._animationDriver);
}
NodeDomRootRenderer.prototype.renderComponent = renderComponentFix;
// End Fix Universal Style

View File

@ -0,0 +1,194 @@
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
import {Injectable} from '@angular/core';
// es6-modules are used here
import {DomAdapter, getDOM} from '@angular/platform-browser/src/dom/dom_adapter';
/**
* Represent meta element.
*
* ### Example
*
* ```ts
* { name: 'application-name', content: 'Name of my application' },
* { name: 'description', content: 'A description of the page', id: 'desc' }
* // ...
* // Twitter
* { name: 'twitter:title', content: 'Content Title' }
* // ...
* // Google+
* { itemprop: 'name', content: 'Content Title' },
* { itemprop: 'description', content: 'Content Title' }
* // ...
* // Facebook / Open Graph
* { property: 'fb:app_id', content: '123456789' },
* { property: 'og:title', content: 'Content Title' }
* ```
*
* @experimental
*/
export interface MetaDefinition {
charset?: string;
content?: string;
httpEquiv?: string;
id?: string;
itemprop?: string;
name?: string;
property?: string;
scheme?: string;
url?: string;
[prop: string]: string;
}
/**
* A service that can be used to get and add meta tags.
*
* @experimental
*/
@Injectable()
export class Meta {
private _dom: DomAdapter = getDOM();
/**
* Adds a new meta tag to the dom.
*
* ### Example
*
* ```ts
* const name: MetaDefinition = {name: 'application-name', content: 'Name of my application'};
* const desc: MetaDefinition = {name: 'description', content: 'A description of the page'};
* const tags: HTMLMetaElement[] = this.meta.addTags([name, desc]);
* ```
*
* @param tags
* @returns {HTMLMetaElement[]}
*/
addTags(...tags: Array<MetaDefinition|MetaDefinition[]>): HTMLMetaElement[] {
const presentTags = this._flattenArray(tags);
if (presentTags.length === 0) return [];
return presentTags.map((tag: MetaDefinition) => this._addInternal(tag));
}
/**
* Gets the meta tag by the given selector. Returns element or null
* if there's no such meta element.
*
* ### Example
*
* ```ts
* const meta: HTMLMetaElement = this.meta.getTag('name=description');
* const twitterMeta: HTMLMetaElement = this.meta.getTag('name="twitter:title"');
* const fbMeta: HTMLMetaElement = this.meta.getTag('property="fb:app_id"');
* ```
*
* @param selector
* @returns {HTMLMetaElement}
*/
getTag(selector: string): HTMLMetaElement {
if (!selector) return null;
return this._dom.query(`meta[${selector}]`);
}
/**
* Updates the meta tag with the given selector.
*
* * ### Example
*
* ```ts
* const meta: HTMLMetaElement = this.meta.updateTag('name=description', {name: 'description',
* content: 'New description'});
* console.log(meta.content); // 'New description'
* ```
*
* @param selector
* @param tag updated tag definition
* @returns {HTMLMetaElement}
*/
updateTag(selector: string, tag: MetaDefinition): HTMLMetaElement {
const meta: HTMLMetaElement = this.getTag(selector);
if (!meta) {
// create element if it doesn't exist
return this._addInternal(tag);
}
return this._prepareMetaElement(tag, meta);
}
/**
* Removes meta tag with the given selector from the dom.
*
* ### Example
*
* ```ts
* this.meta.removeTagBySelector('name=description');
* ```
*
* @param selector
*/
removeTagBySelector(selector: string): void {
const meta: HTMLMetaElement = this.getTag(selector);
this.removeTagElement(meta);
}
/**
* Removes given meta element from the dom.
*
* ### Example
* ```ts
* const elem: HTMLMetaElement = this.meta.getTag('name=description');
* this.meta.removeTagElement(elem);
* ```
*
* @param meta meta element
*/
removeTagElement(meta: HTMLMetaElement): void {
if (meta) {
this._removeMetaElement(meta);
}
}
private _addInternal(tag: MetaDefinition): HTMLMetaElement {
const meta: HTMLMetaElement = this._createMetaElement();
this._prepareMetaElement(tag, meta);
this._appendMetaElement(meta);
return meta;
}
private _createMetaElement(): HTMLMetaElement {
return this._dom.createElement('meta') as HTMLMetaElement;
}
private _prepareMetaElement(tag: MetaDefinition, el: HTMLMetaElement): HTMLMetaElement {
Object.keys(tag).forEach((prop: string) => this._dom.setAttribute(el, prop, tag[prop]));
return el;
}
private _appendMetaElement(meta: HTMLMetaElement): void {
const head = this._dom.getElementsByTagName(this._dom.defaultDoc(), 'head')[0];
this._dom.appendChild(head, meta);
}
private _removeMetaElement(meta: HTMLMetaElement): void {
const head = this._dom.parentElement(meta);
this._dom.removeChild(head, meta);
}
private _flattenArray(input: any[], out: any[] = []): any[] {
if (input) {
for (let i = 0; i < input.length; i++) {
const item: any = input[i];
if (Array.isArray(item)) {
this._flattenArray(item, out);
} else if (item) {
out.push(item);
}
}
}
return out;
}
}

View File

@ -1,52 +0,0 @@
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { UniversalModule, isBrowser, isNode } from 'angular2-universal/browser'; // for AoT we need to manually split universal packages
import { App } from './app/app';
//for routing:
import { routing } from './app/app.routing';
import { Routes, RouterModule } from "@angular/router";
import { CacheService } from './app/universal-cache';
// custom modules::
import {ClaimModule} from './app/claimPages/claim.module';
import {SearchModule} from './app/searchPages/search.module';
import {DepoditModule} from './app/deposit/deposit.module';
import {LandingModule} from './app/landingPages/landing.module';
import {SharedComponentsModule} from './app/sharedComponents/sharedComponents.module'; //navbar
import {UtilsModule} from './app/utils/utils.module';
import {ServicesModule} from './app/services/services.module';
//Main Router Components
import {HomeComponent} from './app/home/home.component';
import {ErrorPageComponent} from './app/error/errorPage.component';
import {TestComponent} from './app/test/test.component';
@NgModule({
bootstrap: [ App ],
imports: [
UniversalModule, // BrowserModule, HttpModule, and JsonpModule are included
FormsModule,
ClaimModule,
SearchModule,
DepoditModule,
LandingModule,
SharedComponentsModule,
UtilsModule,
ServicesModule,
routing
],
declarations: [ App,
HomeComponent,
ErrorPageComponent,
TestComponent
],
providers: [
{ provide: 'isBrowser', useValue: isBrowser },
{ provide: 'isNode', useValue: isNode },
CacheService
]
})
export class MainModule {
}

View File

@ -1,52 +0,0 @@
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { UniversalModule } from 'angular2-universal';
import { App } from './app/app';
//for routing:
import { routing } from './app/app.routing';
import { Routes, RouterModule } from "@angular/router";
// custom modules::
import {ClaimModule} from './app/claimPages/claim.module';
import {SearchModule} from './app/searchPages/search.module';
import {DepoditModule} from './app/deposit/deposit.module';
import {LandingModule} from './app/landingPages/landing.module';
import {SharedComponentsModule} from './app/sharedComponents/sharedComponents.module'; //navbar
import {UtilsModule} from './app/utils/utils.module';
import {ServicesModule} from './app/services/services.module';
//Main Router Components
import {HomeComponent} from './app/home/home.component';
import {ErrorPageComponent} from './app/error/errorPage.component';
import {TestComponent} from './app/test/test.component';
@NgModule({
bootstrap: [ App ],
imports: [
UniversalModule, // BrowserModule, HttpModule, and JsonpModule are included
FormsModule,
ClaimModule,
SearchModule,
DepoditModule,
LandingModule,
SharedComponentsModule,
UtilsModule,
ServicesModule,
routing
],
declarations: [ App,
HomeComponent,
ErrorPageComponent,
TestComponent
],
providers: [
]
})
export class MainModule {
}

View File

@ -0,0 +1,11 @@
import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router';
@NgModule({
imports: [
RouterModule.forChild([
{ path: '', redirectTo: '/home', pathMatch: 'full' }
])
],
})
export class AppRoutingModule { }

View File

@ -0,0 +1,37 @@
import { Component, Directive, ElementRef, Renderer, ChangeDetectionStrategy, ViewEncapsulation } from '@angular/core';
//
/////////////////////////
// ** Example Directive
// Notice we don't touch the Element directly
@Directive({
selector: '[xLarge]'
})
export class XLargeDirective {
constructor(element: ElementRef, renderer: Renderer) {
// ** IMPORTANT **
// we must interact with the dom through -Renderer-
// for webworker/server to see the changes
renderer.setElementStyle(element.nativeElement, 'fontSize', 'x-large');
// ^^
}
}
@Component({
changeDetection: ChangeDetectionStrategy.Default,
encapsulation: ViewEncapsulation.Emulated,
selector: 'app',
styles: [`
`],
template: `
<div>
<navbar></navbar>
<main>
<router-outlet></router-outlet>
</main>
</div>`
})
export class AppComponent {
title = 'ftw';
}

47
portal-2/src/app/app.module.ts Executable file
View File

@ -0,0 +1,47 @@
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { SharedModule } from './shared/shared.module';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent, XLargeDirective } from './app.component';
// custom modules::
import {ClaimModule} from './claimPages/claim.module';
import {SearchModule} from './searchPages/search.module';
import {DepoditModule} from './deposit/deposit.module';
import {LandingModule} from './landingPages/landing.module';
import {SharedComponentsModule} from './sharedComponents/sharedComponents.module'; //navbar
import {UtilsModule} from './utils/utils.module';
import {TestModule} from './test/test.module';
import { HomeModule } from './home/home.module';
import { ErrorModule } from './error/error.module';
import {ServicesModule} from './services/services.module';
@NgModule({
declarations: [ AppComponent, XLargeDirective ],
imports: [
SharedModule,
HomeModule,
ClaimModule,
SearchModule,
DepoditModule,
LandingModule,
SharedComponentsModule,
UtilsModule,
ServicesModule,
TestModule,
HomeModule,
AppRoutingModule,
ErrorModule,
], exports:[]
})
export class AppModule {
}
export { AppComponent } from './app.component';

View File

@ -1,83 +0,0 @@
import { ModuleWithProviders } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import {ClaimsAdminComponent} from './claimPages/claims/claimsAdmin.component';
import {ClaimComponent} from './claimPages/claim/claim.component';
import {MyClaimsComponent} from './claimPages/myClaims/myClaims.component';
import {HomeComponent} from './home/home.component';
import { LinkingComponent } from './claimPages/linking/linking.component';
import { BulkLinkingComponent } from './claimPages/linking/bulkLinking.component';
import { PersonComponent } from './landingPages/person/person.component';
import { ProjectComponent } from './landingPages/project/project.component';
import { OrganizationComponent } from './landingPages/organization/organization.component';
import { DatasetComponent } from './landingPages/dataset/dataset.component';
import { PublicationComponent } from './landingPages/publication/publication.component';
import { DataProviderComponent } from './landingPages/dataProvider/dataProvider.component'
import { SearchComponent } from './searchPages/find/search.component';
import { SearchPublicationsComponent } from './searchPages/searchPublications.component';
import { SearchDataprovidersComponent } from './searchPages/searchDataproviders.component';
import { SearchProjectsComponent } from './searchPages/searchProjects.component';
import { SearchDatasetsComponent } from './searchPages/searchDatasets.component';
import { SearchOrganizationsComponent } from './searchPages/searchOrganizations.component';
import { SearchPeopleComponent } from './searchPages/searchPeople.component';
import { AdvancedSearchPublicationsComponent } from './searchPages/advanced/advancedSearchPublications.component';
import { AdvancedSearchDataProvidersComponent } from './searchPages/advanced/advancedSearchDataProviders.component';
import { AdvancedSearchProjectsComponent } from './searchPages/advanced/advancedSearchProjects.component';
import { AdvancedSearchDatasetsComponent } from './searchPages/advanced/advancedSearchDatasets.component';
import { AdvancedSearchPeopleComponent } from './searchPages/advanced/advancedSearchPeople.component';
import { AdvancedSearchOrganizationsComponent } from './searchPages/advanced/advancedSearchOrganizations.component';
import { DepositPublicationsComponent } from './deposit/depositPublications.component';
import { DepositDatasetsComponent } from './deposit/depositDatasets.component';
import { DepositPublicationsResultComponent } from './deposit/depositPublicationsResult.component';
import { DepositDatasetsResultComponent } from './deposit/depositDatasetsResult.component';
import { ErrorPageComponent } from './error/errorPage.component';
import { TestComponent } from './test/test.component';
import { SearchAllComponent } from './searchAll/searchAll.component';
import { SearchCompatibleDataprovidersComponent } from './searchPages/dataProviders/compatibleDataProviders.component';
import { SearchEntityRegistriesComponent } from './searchPages/dataProviders/entityRegistries.component';
const appRoutes: Routes = [
{ path: '', component: SearchComponent, pathMatch: 'full' },
{ path: 'claims', component: ClaimsAdminComponent },
{ path: 'home', component: HomeComponent },
{ path: 'claim', component: ClaimComponent },
{ path: 'myclaims', component: MyClaimsComponent },
{ path: 'search/person', component: PersonComponent },
{ path: 'search/project', component: ProjectComponent },
{ path: 'search/organization', component: OrganizationComponent },
{ path: 'search/dataset', component: DatasetComponent },
{ path: 'search/publication', component: PublicationComponent },
{ path: 'search/dataprovider', component: DataProviderComponent},
{ path: 'search/data-providers', component: SearchCompatibleDataprovidersComponent},
{ path: 'search/entity-registries', component: SearchEntityRegistriesComponent},
{ path: 'search/find', component: SearchComponent },
{ path: 'linking', component: LinkingComponent },
{ path: 'bulk-linking', component: BulkLinkingComponent},
{ path: 'search/find/publications', component: SearchPublicationsComponent },
{ path: 'search/find/dataproviders', component: SearchDataprovidersComponent },
{ path: 'search/find/projects', component: SearchProjectsComponent },
{ path: 'search/find/datasets', component: SearchDatasetsComponent },
{ path: 'search/find/organizations', component: SearchOrganizationsComponent },
{ path: 'search/find/people', component: SearchPeopleComponent },
{ path: 'search/advanced/publications', component: AdvancedSearchPublicationsComponent },
{ path: 'search/advanced/dataproviders', component: AdvancedSearchDataProvidersComponent },
{ path: 'search/advanced/projects', component: AdvancedSearchProjectsComponent },
{ path: 'search/advanced/datasets', component: AdvancedSearchDatasetsComponent },
{ path: 'search/advanced/people', component: AdvancedSearchPeopleComponent },
{ path: 'search/advanced/organizations', component: AdvancedSearchOrganizationsComponent },
{ path: 'deposit-publications', component: DepositPublicationsComponent },
{ path: 'deposit-datasets', component: DepositDatasetsComponent },
{ path: 'deposit-publications-result', component: DepositPublicationsResultComponent} ,
{ path: 'deposit-datasets-result', component: DepositDatasetsResultComponent },
{ path: 'test', component: TestComponent},
{ path: 'search', component: SearchAllComponent },
{ path: 'error', component: ErrorPageComponent},
{ path: '**', component: ErrorPageComponent } // it has to be the last one - otherwise the next declaration are ignored
];
export const routing: ModuleWithProviders = RouterModule.forRoot(appRoutes);

View File

@ -1,38 +0,0 @@
import { Component } from '@angular/core';
// require('bootstrap');
import 'rxjs/Rx';
//import {LocalStorageService} from "angular2-localstorage/LocalStorageEmitter";
//import {LockerModule, Locker, LockerConfig} from 'angular2-locker';
//import { LocalStorage } from 'angular2-universal';
//import {LocalStorageService, SessionStorageService} from 'ng2-webstorage';
//import {LocalStorage, SessionStorage} from 'ng2-webstorage';
@Component({
selector: 'app',
template: `
<div>
<navbar></navbar>
<main>
<router-outlet></router-outlet>
</main>
</div>`
})
export class App {
//constructor(storageService: LocalStorageService){}
//constructor(locker: Locker) {
// locker.set('something', "value");
//}
//
// constructor(private localSt:LocalStorageService) {}
//
// ngOnInit() {
// this.localSt.observe('key')
// .subscribe((value) => console.log('new value', value));
// }
//
// @LocalStorage()
// public boundValue;
}

View File

@ -0,0 +1,22 @@
import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router';
import {ClaimsAdminComponent} from './claims/claimsAdmin.component';
import {ClaimComponent} from './claim/claim.component';
import {MyClaimsComponent} from './myClaims/myClaims.component';
import { LinkingComponent } from './linking/linking.component';
import { BulkLinkingComponent } from './linking/bulkLinking.component';
@NgModule({
imports: [
RouterModule.forChild([
{ path: 'claims', component: ClaimsAdminComponent },
{ path: 'myclaims', component: MyClaimsComponent },
{ path: 'claim', component: ClaimComponent },
{ path: 'linking', component: LinkingComponent },
{ path: 'bulk-linking', component: BulkLinkingComponent},
])
]
})
export class ClaimRoutingModule { }

View File

@ -42,11 +42,13 @@ import {ClaimEntityFormatter} from '../utils/claimEntityFormatter.component';
import { Claim } from '../utils/entities/claim';
//helpers
import { ClaimRoutingModule } from './claim-routing.module';
@NgModule({
imports: [
CommonModule, FormsModule,
UtilsModule,
ServicesModule,
ClaimRoutingModule
],
declarations: [

View File

@ -0,0 +1,20 @@
import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router';
import { DepositPublicationsComponent } from './depositPublications.component';
import { DepositDatasetsComponent } from './depositDatasets.component';
import { DepositPublicationsResultComponent } from './depositPublicationsResult.component';
import { DepositDatasetsResultComponent } from './depositDatasetsResult.component';
@NgModule({
imports: [
RouterModule.forChild([
{ path: 'deposit-publications', component: DepositPublicationsComponent },
{ path: 'deposit-datasets', component: DepositDatasetsComponent },
{ path: 'deposit-publications-result', component: DepositPublicationsResultComponent} ,
{ path: 'deposit-datasets-result', component: DepositDatasetsResultComponent },
])
]
})
export class DepositRoutingModule { }

View File

@ -13,6 +13,7 @@ import { DepositDatasetsResultComponent } from './depositDatasetsResult.componen
import {ServicesModule} from '../services/services.module';
import {SearchModule} from '../searchPages/search.module';
import {DepositRoutingModule} from './deposit-routing.module';
//helpers
@ -21,7 +22,8 @@ import {SearchModule} from '../searchPages/search.module';
CommonModule, FormsModule,
UtilsModule,
ServicesModule,
SearchModule
SearchModule,
DepositRoutingModule
],
declarations: [
DepositComponent,

View File

@ -3,7 +3,7 @@ import {Observable} from 'rxjs/Observable';
import {OpenaireProperties, ErrorCodes} from '../utils/properties/openaireProperties';
import { ActivatedRoute } from '@angular/router';
import { SearchDataprovidersComponent } from '../searchPages/searchDataproviders.component';
import { SearchDataprovidersComponent } from '../searchPages/simple/searchDataproviders.component';
import { SearchDataprovidersService } from '../services/searchDataproviders.service';
import { SearchResultComponent } from '../searchPages/searchUtils/searchResult.component';

View File

@ -0,0 +1,15 @@
import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router';
import { ErrorPageComponent } from './errorPage.component';
@NgModule({
imports: [
RouterModule.forChild([
{ path: 'error', component: ErrorPageComponent},
{ path: '**', component: ErrorPageComponent},
])
]
})
export class ErrorRoutingModule { }

View File

@ -0,0 +1,19 @@
import { NgModule} from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { ErrorPageComponent } from './errorPage.component';
import { ErrorRoutingModule } from './error-routing.module';
@NgModule({
imports: [
CommonModule, FormsModule,
ErrorRoutingModule
],
declarations: [
ErrorPageComponent
]
})
export class ErrorModule { }

View File

@ -0,0 +1,14 @@
import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router';
import {HomeComponent} from './home.component';
@NgModule({
imports: [
RouterModule.forChild([
{ path: 'home', component: HomeComponent },
])
]
})
export class HomeRoutingModule { }

View File

@ -0,0 +1,21 @@
import { NgModule} from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import {HomeComponent} from './home.component';
import { HomeRoutingModule } from './home-routing.module';
@NgModule({
imports: [
CommonModule, FormsModule,
HomeRoutingModule
],
declarations: [
HomeComponent
],
exports: [
HomeComponent
]
})
export class HomeModule { }

View File

@ -1,6 +1,6 @@
import {Component, Input} from '@angular/core';
import { SearchDatasetsComponent } from '../../searchPages/searchDatasets.component';
import { SearchDatasetsComponent } from '../../searchPages/simple/searchDatasets.component';
import {SearchResultComponent} from '../../searchPages/searchUtils/searchResult.component';
import {OpenaireProperties} from '../../utils/properties/openaireProperties';

View File

@ -1,6 +1,6 @@
import {Component, Input} from '@angular/core';
import { SearchPublicationsComponent } from '../../searchPages/searchPublications.component';
import { SearchPublicationsComponent } from '../../searchPages/simple/searchPublications.component';
import {SearchResultComponent} from '../../searchPages/searchUtils/searchResult.component';
import {OpenaireProperties} from '../../utils/properties/openaireProperties';

View File

@ -1,9 +1,9 @@
import {Component, Input} from '@angular/core';
import {ActivatedRoute, Params} from '@angular/router';
import { SearchPublicationsComponent } from '../../searchPages/searchPublications.component';
import { SearchPublicationsComponent } from '../../searchPages/simple/searchPublications.component';
import { SearchPublicationsService } from '../../services/searchPublications.service';
import { SearchDatasetsComponent } from '../../searchPages/searchDatasets.component';
import { SearchDatasetsComponent } from '../../searchPages/simple/searchDatasets.component';
import { SearchDatasetsService } from '../../services/searchDatasets.service';
@Component({

View File

@ -0,0 +1,24 @@
import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router';
import { PersonComponent } from './person/person.component';
import { ProjectComponent } from './project/project.component';
import { OrganizationComponent } from './organization/organization.component';
import { DatasetComponent } from './dataset/dataset.component';
import { PublicationComponent } from './publication/publication.component';
import { DataProviderComponent } from './dataProvider/dataProvider.component'
@NgModule({
imports: [
RouterModule.forChild([
{ path: 'search/person', component: PersonComponent },
{ path: 'search/project', component: ProjectComponent },
{ path: 'search/organization', component: OrganizationComponent },
{ path: 'search/dataset', component: DatasetComponent },
{ path: 'search/publication', component: PublicationComponent },
{ path: 'search/dataprovider', component: DataProviderComponent},
])
]
})
export class LandingRoutingModule { }

View File

@ -31,13 +31,16 @@ import { OrganizationComponent } from './organization/organization.component';
import { DatasetComponent } from './dataset/dataset.component';
import { PublicationComponent } from './publication/publication.component';
import { LandingRoutingModule } from './landing-routing.module';
@NgModule({
imports: [
CommonModule, FormsModule,
UtilsModule,
ClaimModule,
ServicesModule,
SearchModule
SearchModule,
LandingRoutingModule
],
declarations: [

View File

@ -4,10 +4,10 @@ import {ActivatedRoute} from '@angular/router';
import {OrganizationService} from '../../services/organization.service';
import {OrganizationInfo} from '../../utils/entities/organizationInfo';
import { SearchDataprovidersComponent } from '../../searchPages/searchDataproviders.component';
import { SearchDataprovidersComponent } from '../../searchPages/simple/searchDataproviders.component';
import { SearchDataprovidersService } from '../../services/searchDataproviders.service';
import {SearchResultComponent} from '../../searchPages/searchUtils/searchResult.component';
import { SearchPublicationsComponent } from '../../searchPages/searchPublications.component';
import { SearchPublicationsComponent } from '../../searchPages/simple/searchPublications.component';
import { SearchPublicationsService } from '../../services/searchPublications.service';
import {OpenaireProperties} from '../../utils/properties/openaireProperties';

View File

@ -4,9 +4,9 @@ import { ActivatedRoute } from '@angular/router';
import {PersonService} from '../../services/person.service';
import { PersonInfo } from '../../utils/entities/personInfo';
import { SearchPublicationsComponent } from '../../searchPages/searchPublications.component';
import { SearchPublicationsComponent } from '../../searchPages/simple/searchPublications.component';
import { SearchPublicationsService } from '../../services/searchPublications.service';
import { SearchDatasetsComponent } from '../../searchPages/searchDatasets.component';
import { SearchDatasetsComponent } from '../../searchPages/simple/searchDatasets.component';
import { SearchDatasetsService } from '../../services/searchDatasets.service';
import { SearchResultComponent } from '../../searchPages/searchUtils/searchResult.component';

View File

@ -5,9 +5,9 @@ import {ProjectService} from '../../services/project.service';
import {ProjectInfo} from '../../utils/entities/projectInfo';
import {InlineClaimResultComponent} from '../../claimPages/inlineClaims/inlineClaimResult.component';
import { SearchPublicationsComponent } from '../../searchPages/searchPublications.component';
import { SearchPublicationsComponent } from '../../searchPages/simple/searchPublications.component';
import {SearchPublicationsService} from '../../services/searchPublications.service';
import { SearchDatasetsComponent } from '../../searchPages/searchDatasets.component';
import { SearchDatasetsComponent } from '../../searchPages/simple/searchDatasets.component';
import { SearchDatasetsService } from '../../services/searchDatasets.service';
import {SearchResultComponent} from '../../searchPages/searchUtils/searchResult.component';

View File

@ -0,0 +1,39 @@
// import { Component } from '@angular/core';
// import { Router } from '@angular/router';
// import { Http } from '@angular/http';
// // import { contentHeaders } from '../../common/headers';
//
// // const styles = require('./login.css');
// // const template = require('./login.html');
//
// @Component({
// selector: 'login',
// template: template,
// styles: [ styles ]
// })
// export class Login {
// constructor(public router: Router, public http: Http) {
// }
//
// login(event, username, password) {
// event.preventDefault();
// let body = JSON.stringify({ username, password });
// localStorage.setItem('id_token',"test");
// // this.http.post('http://localhost:3001/sessions/create', body, { headers: contentHeaders })
// // .subscribe(
// // response => {
// // localStorage.setItem('id_token', response.json().id_token);
// // this.router.navigate(['home']);
// // },
// // error => {
// // alert(error.text());
// // console.log(error.text());
// // }
// // );
// }
//
// signup(event) {
// event.preventDefault();
// this.router.navigate(['signup']);
// }
// }

View File

@ -3,12 +3,12 @@ import {Observable} from 'rxjs/Observable';
import {ActivatedRoute, Router} from '@angular/router';
import {Location} from '@angular/common';
import { SearchPublicationsComponent } from '../searchPublications.component';
import { SearchDataprovidersComponent } from '../searchDataproviders.component';
import { SearchProjectsComponent } from '../searchProjects.component';
import { SearchDatasetsComponent } from '../searchDatasets.component';
import { SearchOrganizationsComponent } from '../searchOrganizations.component';
import { SearchPeopleComponent } from '../searchPeople.component';
import { SearchPublicationsComponent } from '../simple/searchPublications.component';
import { SearchDataprovidersComponent } from '../simple/searchDataproviders.component';
import { SearchProjectsComponent } from '../simple/searchProjects.component';
import { SearchDatasetsComponent } from '../simple/searchDatasets.component';
import { SearchOrganizationsComponent } from '../simple/searchOrganizations.component';
import { SearchPeopleComponent } from '../simple/searchPeople.component';
import {SearchPublicationsService} from '../../services/searchPublications.service';
import {SearchDataprovidersService} from '../../services/searchDataproviders.service';

View File

@ -0,0 +1,42 @@
import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router';
import { SearchComponent } from './find/search.component';
import { SearchPublicationsComponent } from './simple/searchPublications.component';
import { SearchDataprovidersComponent } from './simple/searchDataproviders.component';
import { SearchProjectsComponent } from './simple/searchProjects.component';
import { SearchDatasetsComponent } from './simple/searchDatasets.component';
import { SearchOrganizationsComponent } from './simple/searchOrganizations.component';
import { SearchPeopleComponent } from './simple/searchPeople.component';
import { AdvancedSearchPublicationsComponent } from './advanced/advancedSearchPublications.component';
import { AdvancedSearchDataProvidersComponent } from './advanced/advancedSearchDataProviders.component';
import { AdvancedSearchProjectsComponent } from './advanced/advancedSearchProjects.component';
import { AdvancedSearchDatasetsComponent } from './advanced/advancedSearchDatasets.component';
import { AdvancedSearchPeopleComponent } from './advanced/advancedSearchPeople.component';
import { AdvancedSearchOrganizationsComponent } from './advanced/advancedSearchOrganizations.component';
import { SearchCompatibleDataprovidersComponent } from './dataProviders/compatibleDataProviders.component';
import { SearchEntityRegistriesComponent } from './dataProviders/entityRegistries.component';
@NgModule({
imports: [
RouterModule.forChild([
{ path: 'search/data-providers', component: SearchCompatibleDataprovidersComponent},
{ path: 'search/entity-registries', component: SearchEntityRegistriesComponent},
{ path: 'search/find', component: SearchComponent },
{ path: 'search', component: SearchComponent },
{ path: 'search/find/publications', component: SearchPublicationsComponent },
{ path: 'search/find/dataproviders', component: SearchDataprovidersComponent },
{ path: 'search/find/projects', component: SearchProjectsComponent },
{ path: 'search/find/datasets', component: SearchDatasetsComponent },
{ path: 'search/find/organizations', component: SearchOrganizationsComponent },
{ path: 'search/find/people', component: SearchPeopleComponent },
{ path: 'search/advanced/publications', component: AdvancedSearchPublicationsComponent },
{ path: 'search/advanced/dataproviders', component: AdvancedSearchDataProvidersComponent },
{ path: 'search/advanced/projects', component: AdvancedSearchProjectsComponent },
{ path: 'search/advanced/datasets', component: AdvancedSearchDatasetsComponent },
{ path: 'search/advanced/people', component: AdvancedSearchPeopleComponent },
{ path: 'search/advanced/organizations', component: AdvancedSearchOrganizationsComponent },
])
]
})
export class SearchRoutingModule { }

View File

@ -20,12 +20,12 @@ import {SearchDownloadComponent} from './searchUtils/searchDownload.component';
import {SearchResultComponent} from './searchUtils/searchResult.component';
import {SearchFilterComponent} from './searchUtils/searchFilter.component';
import {AdvancedSearchFormComponent} from './searchUtils/advancedSearchForm.component';
import { SearchPublicationsComponent } from './searchPublications.component';
import { SearchDataprovidersComponent } from './searchDataproviders.component';
import { SearchProjectsComponent } from './searchProjects.component';
import {SearchDatasetsComponent} from './searchDatasets.component';
import {SearchOrganizationsComponent} from './searchOrganizations.component';
import {SearchPeopleComponent} from './searchPeople.component';
import { SearchPublicationsComponent } from './simple/searchPublications.component';
import { SearchDataprovidersComponent } from './simple/searchDataproviders.component';
import { SearchProjectsComponent } from './simple/searchProjects.component';
import {SearchDatasetsComponent} from './simple/searchDatasets.component';
import {SearchOrganizationsComponent} from './simple/searchOrganizations.component';
import {SearchPeopleComponent} from './simple/searchPeople.component';
import {SearchComponent} from './find/search.component';
import {SearchCompatibleDataprovidersComponent} from './dataProviders/compatibleDataProviders.component';
@ -39,12 +39,14 @@ import { AdvancedSearchDatasetsComponent } from './advanced/advancedSearchDatase
import { AdvancedSearchPeopleComponent } from './advanced/advancedSearchPeople.component';
import { AdvancedSearchOrganizationsComponent } from './advanced/advancedSearchOrganizations.component';
import { SearchRoutingModule } from './search-routing.module';
@NgModule({
imports: [
CommonModule, FormsModule,
UtilsModule,
ServicesModule
ServicesModule,
SearchRoutingModule
],
declarations: [

View File

@ -1,14 +1,14 @@
import {Component, Input, ViewChild} from '@angular/core';
import { ActivatedRoute} from '@angular/router';
import {Location} from '@angular/common';
import { Filter, Value} from './searchUtils/searchHelperClasses.class';
import {SearchDataprovidersService} from '../services/searchDataproviders.service';
import {SearchResult} from '../utils/entities/searchResult';
import {OpenaireProperties, ErrorCodes} from '../utils/properties/openaireProperties';
import {SearchFields} from '../utils/properties/searchFields';
import {SearchPageComponent } from './searchUtils/searchPage.component';
import {ExportCSVComponent} from '../utils/exportCSV.component';
import {SearchUtilsClass } from './searchUtils/searchUtils.class';
import { Filter, Value} from '../searchUtils/searchHelperClasses.class';
import {SearchDataprovidersService} from '../../services/searchDataproviders.service';
import {SearchResult} from '../../utils/entities/searchResult';
import {OpenaireProperties, ErrorCodes} from '../../utils/properties/openaireProperties';
import {SearchFields} from '../../utils/properties/searchFields';
import {SearchPageComponent } from '../searchUtils/searchPage.component';
import {ExportCSVComponent} from '../../utils/exportCSV.component';
import {SearchUtilsClass } from '../searchUtils/searchUtils.class';
@Component({
selector: 'search-dataproviders',

View File

@ -1,14 +1,14 @@
import {Component, Input, ViewChild} from '@angular/core';
import { ActivatedRoute} from '@angular/router';
import {Location} from '@angular/common';
import { Filter, Value} from './searchUtils/searchHelperClasses.class';
import { Filter, Value} from '../searchUtils/searchHelperClasses.class';
import {SearchDatasetsService} from '../services/searchDatasets.service';
import {SearchResult} from '../utils/entities/searchResult';
import {OpenaireProperties, ErrorCodes} from '../utils/properties/openaireProperties';
import {SearchFields} from '../utils/properties/searchFields';
import {SearchPageComponent } from './searchUtils/searchPage.component';
import {SearchUtilsClass } from './searchUtils/searchUtils.class';
import {SearchDatasetsService} from '../../services/searchDatasets.service';
import {SearchResult} from '../../utils/entities/searchResult';
import {OpenaireProperties, ErrorCodes} from '../../utils/properties/openaireProperties';
import {SearchFields} from '../../utils/properties/searchFields';
import {SearchPageComponent } from '../searchUtils/searchPage.component';
import {SearchUtilsClass } from '../searchUtils/searchUtils.class';
@Component({
selector: 'search-datasets',

View File

@ -1,13 +1,13 @@
import {Component, Input, ViewChild} from '@angular/core';
import { ActivatedRoute} from '@angular/router';
import {Location} from '@angular/common';
import { Filter, Value} from './searchUtils/searchHelperClasses.class';
import {SearchOrganizationsService} from '../services/searchOrganizations.service';
import {SearchResult} from '../utils/entities/searchResult';
import {OpenaireProperties, ErrorCodes} from '../utils/properties/openaireProperties';
import {SearchFields} from '../utils/properties/searchFields';
import {SearchPageComponent } from './searchUtils/searchPage.component';
import {SearchUtilsClass } from './searchUtils/searchUtils.class';
import { Filter, Value} from '../searchUtils/searchHelperClasses.class';
import {SearchOrganizationsService} from '../../services/searchOrganizations.service';
import {SearchResult} from '../../utils/entities/searchResult';
import {OpenaireProperties, ErrorCodes} from '../../utils/properties/openaireProperties';
import {SearchFields} from '../../utils/properties/searchFields';
import {SearchPageComponent } from '../searchUtils/searchPage.component';
import {SearchUtilsClass } from '../searchUtils/searchUtils.class';
@Component({
selector: 'search-organizations',

View File

@ -2,14 +2,14 @@ import {Component, Input, ViewChild} from '@angular/core';
import { ActivatedRoute} from '@angular/router';
import {Location} from '@angular/common';
import { Filter, Value} from './searchUtils/searchHelperClasses.class';
import { Filter, Value} from '../searchUtils/searchHelperClasses.class';
import {SearchPeopleService} from '../services/searchPeople.service';
import {SearchResult} from '../utils/entities/searchResult';
import {OpenaireProperties, ErrorCodes} from '../utils/properties/openaireProperties';
import {SearchFields} from '../utils/properties/searchFields';
import {SearchPageComponent } from './searchUtils/searchPage.component';
import {SearchUtilsClass } from './searchUtils/searchUtils.class';
import {SearchPeopleService} from '../../services/searchPeople.service';
import {SearchResult} from '../../utils/entities/searchResult';
import {OpenaireProperties, ErrorCodes} from '../../utils/properties/openaireProperties';
import {SearchFields} from '../../utils/properties/searchFields';
import {SearchPageComponent } from '../searchUtils/searchPage.component';
import {SearchUtilsClass } from '../searchUtils/searchUtils.class';
@Component({
selector: 'search-people',

View File

@ -1,13 +1,13 @@
import {Component, Input, ViewChild} from '@angular/core';
import { ActivatedRoute} from '@angular/router';
import {Location} from '@angular/common';
import { Filter, Value} from './searchUtils/searchHelperClasses.class';
import {SearchProjectsService} from '../services/searchProjects.service';
import {SearchResult} from '../utils/entities/searchResult';
import {OpenaireProperties, ErrorCodes} from '../utils/properties/openaireProperties';
import {SearchFields} from '../utils/properties/searchFields';
import {SearchPageComponent } from './searchUtils/searchPage.component';
import {SearchUtilsClass } from './searchUtils/searchUtils.class';
import { Filter, Value} from '../searchUtils/searchHelperClasses.class';
import {SearchProjectsService} from '../../services/searchProjects.service';
import {SearchResult} from '../../utils/entities/searchResult';
import {OpenaireProperties, ErrorCodes} from '../../utils/properties/openaireProperties';
import {SearchFields} from '../../utils/properties/searchFields';
import {SearchPageComponent } from '../searchUtils/searchPage.component';
import {SearchUtilsClass } from '../searchUtils/searchUtils.class';
@Component({
selector: 'search-projects',

View File

@ -2,14 +2,14 @@ import {Component, Input, ViewChild} from '@angular/core';
import { ActivatedRoute} from '@angular/router';
import {Location} from '@angular/common';
import { Filter, Value} from './searchUtils/searchHelperClasses.class';
import { Filter, Value} from '../searchUtils/searchHelperClasses.class';
import {SearchPublicationsService} from '../services/searchPublications.service';
import {SearchResult} from '../utils/entities/searchResult';
import {OpenaireProperties, ErrorCodes} from '../utils/properties/openaireProperties';
import {SearchFields} from '../utils/properties/searchFields';
import {SearchPageComponent } from './searchUtils/searchPage.component';
import {SearchUtilsClass} from './searchUtils/searchUtils.class';
import {SearchPublicationsService} from '../../services/searchPublications.service';
import {SearchResult} from '../../utils/entities/searchResult';
import {OpenaireProperties, ErrorCodes} from '../../utils/properties/openaireProperties';
import {SearchFields} from '../../utils/properties/searchFields';
import {SearchPageComponent } from '../searchUtils/searchPage.component';
import {SearchUtilsClass} from '../searchUtils/searchUtils.class';
@Component({
selector: 'search-publications',

View File

@ -0,0 +1,29 @@
import { Injectable } from '@angular/core';
import { Http } from '@angular/http';
import { Observable } from 'rxjs/Observable';
import 'rxjs/add/observable/throw';
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/catch';
import { CacheService } from './cache.service';
@Injectable()
export class ApiService {
constructor(public _http: Http) {
}
/**
* whatever domain/feature method name
*/
get(url: string, options?: any) {
return this._http.get(url, options)
.map(res => res.json())
.catch(err => {
console.log('Error: ', err);
return Observable.throw(err);
});
}
}

View File

@ -1,9 +1,12 @@
import { Injectable, isDevMode } from '@angular/core';
import { Inject, Injectable, isDevMode } from '@angular/core';
@Injectable()
export class CacheService {
static KEY = 'CacheService';
_cache = new Map();
constructor(@Inject('LRU') public _cache: Map<string, any>) {
}
/**
* check if there is a value in our store

View File

@ -1,50 +1,30 @@
import { Injectable } from '@angular/core';
import { Http } from '@angular/http';
import { Observable } from 'rxjs/Observable';
import 'rxjs/add/observable/thorw';
import 'rxjs/add/observable/of';
import 'rxjs/add/operator/do';
import 'rxjs/add/operator/share';
import { CacheService } from './universal-cache';
import { CacheService } from '../cache.service';
import { ApiService } from '../api.service';
export function hashCode(str) {
export function hashCodeString(str: string): string {
let hash = 0;
if (str.length === 0) {
return hash;
return hash + '';
}
for (let i = 0; i < str.length; i++) {
let char = str.charCodeAt(i);
hash = ((hash << 5) - hash) + char;
hash = hash & hash; // Convert to 32bit integer
}
return hash;
}
@Injectable()
export class ApiService {
constructor(public _http: Http) {
}
/**
* whatever domain/feature method name
*/
get(url: string, options?: any) {
return this._http.get(url, options)
.map(res => res.json())
.catch(err => {
console.log('Error: ', err);
return Observable.throw(err);
});
}
return hash + '';
}
// domain/feature service
@Injectable()
export class ModelService {
constructor(public _api: ApiService, public _cache: Cache) {
// This is only one example of one Model depending on your domain
constructor(public _api: ApiService, public _cache: CacheService) {
}
@ -52,7 +32,10 @@ export class ModelService {
* whatever domain/feature method name
*/
get(url) {
// you want to return the cache if there is a response in it. This would cache the first response so if your API isn't idempotent you probably want to remove the item from the cache after you use it. LRU of 1
// you want to return the cache if there is a response in it.
// This would cache the first response so if your API isn't idempotent
// you probably want to remove the item from the cache after you use it. LRU of 10
// you can use also hashCodeString here
let key = url;
if (this._cache.has(key)) {
@ -65,5 +48,8 @@ export class ModelService {
})
.share();
}
// don't cache here since we're creating
create() {
// TODO
}
}

View File

@ -0,0 +1,52 @@
import { NgModule, ModuleWithProviders } from '@angular/core';
import { CommonModule } from '@angular/common';
import { RouterModule } from '@angular/router';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { ApiService } from './api.service';
import { ModelService } from './model/model.service';
const MODULES = [
// Do NOT include UniversalModule, HttpModule, or JsonpModule here
CommonModule,
RouterModule,
FormsModule,
ReactiveFormsModule
];
const PIPES = [
// put pipes here
];
const COMPONENTS = [
// put shared components here
];
const PROVIDERS = [
ModelService,
ApiService
]
@NgModule({
imports: [
...MODULES
],
declarations: [
...PIPES,
...COMPONENTS
],
exports: [
...MODULES,
...PIPES,
...COMPONENTS
]
})
export class SharedModule {
static forRoot(): ModuleWithProviders {
return {
ngModule: SharedModule,
providers: [
...PROVIDERS
]
};
}
}

View File

@ -45,27 +45,27 @@ import 'rxjs/Rx';
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Linking <span class=""></span></a>
<ul class="dropdown-menu">
<li><a routerLinkActive="active" routerLink="/claims">Claims Admin</a></li>
<li><a routerLink="/myclaims">My Claims</a></li>
<li><a routerLink="/linking">Linking</a></li>
<li><a routerLink="/bulk-linking">Bulk Linking</a></li>
<li><a href="/claims">Claims Admin</a></li>
<li><a href="/myclaims">My Claims</a></li>
<li><a href="/linking">Linking</a></li>
<li><a href="/bulk-linking">Bulk Linking</a></li>
</ul>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Deposit <span class=""></span></a>
<ul class="dropdown-menu">
<li><a routerLinkActive="active" routerLink="/deposit-publications">Deposit Publications</a></li>
<li><a routerLink="/deposit-datasets">Deposit Datasets</a></li>
<li><a href="/deposit-publications">Deposit Publications</a></li>
<li><a href="/deposit-datasets">Deposit Datasets</a></li>
</ul>
</li>
<li><a [queryParams]="{articleId: 'od_______908::3a5b2885656a91307156325644e73b92'}" routerLink="search/publication" >Publication </a></li>
<li><a [queryParams]="{datasetId: 'datacite____::430ac1c41b7f99b7b543ef737dc41a74'}" routerLink="search/dataset" >Dataset </a></li>
<li><a [queryParams]="{projectId: 'corda_______::2c37878a0cede85dbbd1081bb9b4a2f8'}" routerLink="search/project" >Project </a></li>
<li><a [queryParams]="{personId: 'datacite____::9da3a037961b36a634fcd40ab0bf6535'}" routerLink="search/person" >Person </a></li>
<li><a [queryParams]="{organizationId: 'dedup_wf_001::f686277c34bf457bbdf19e03589b5e81'}" routerLink="search/organization" >Organization </a></li>
<li><a [queryParams]="{datasourceId: 'opendoar____::798ed7d4ee7138d49b8828958048130a'}" routerLink="search/dataprovider" >Data Provider </a></li>
<li><a href = "search/publication?articleId=od_______908::3a5b2885656a91307156325644e73b92" >Publication </a></li>
<li><a href = "search/dataset?datasetId=datacite____::430ac1c41b7f99b7b543ef737dc41a74" >Dataset </a></li>
<li><a href = "search/project?projectId=corda_______::2c37878a0cede85dbbd1081bb9b4a2f8" >Project </a></li>
<li><a href = "search/person?personId=datacite____::9da3a037961b36a634fcd40ab0bf6535" >Person </a></li>
<li><a href = "search/organization?organizationId=dedup_wf_001::f686277c34bf457bbdf19e03589b5e81" >Organization </a></li>
<li><a href = "search/dataprovider?datasourceId=opendoar____::798ed7d4ee7138d49b8828958048130a" >Data Provider </a></li>
</ul>
</div><!-- /.navbar-collapse -->

View File

@ -0,0 +1,14 @@
import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router';
import { TestComponent } from './test.component';
@NgModule({
imports: [
RouterModule.forChild([
{ path: 'test', component: TestComponent},
])
]
})
export class TestRoutingModule { }

View File

@ -0,0 +1,23 @@
import { NgModule } from '@angular/core';
import { SharedModule } from '../shared/shared.module';
import { TestComponent } from './test.component';
import { TestRoutingModule } from './test-routing.module';
import {UtilsModule} from '../utils/utils.module';
import {ServicesModule} from '../services/services.module';
@NgModule({
imports: [
SharedModule,
TestRoutingModule,
UtilsModule,
ServicesModule
],
declarations: [
TestComponent
]
})
export class TestModule { }

View File

@ -1,3 +1,6 @@
var util = require('util');
var {Router} = require('express');
// Our API for demos only
import {fakeDataBase} from './db';
import {fakeDemoRedisCache} from './cache';
@ -22,3 +25,82 @@ export function serverApi(req, res) {
})
.then(data => res.json(data));
}
// todo API
var COUNT = 4;
var TODOS = [
{ id: 0, value: 'finish example', created_at: new Date(), completed: false },
{ id: 1, value: 'add tests', created_at: new Date(), completed: false },
{ id: 2, value: 'include development environment', created_at: new Date(), completed: false },
{ id: 3, value: 'include production environment', created_at: new Date(), completed: false }
];
export function createTodoApi() {
var router = Router()
router.route('/todos')
.get(function(req, res) {
console.log('GET');
// 70ms latency
setTimeout(function() {
res.json(TODOS);
}, 0);
})
.post(function(req, res) {
console.log('POST', util.inspect(req.body, {colors: true}));
var todo = req.body;
if (todo) {
TODOS.push({
value: todo.value,
created_at: new Date(),
completed: todo.completed,
id: COUNT++
});
return res.json(todo);
}
return res.end();
});
router.param('todo_id', function(req, res, next, todo_id) {
// ensure correct prop type
var id = Number(req.params.todo_id);
try {
var todo = TODOS[id];
req.todo_id = id;
req.todo = TODOS[id];
next();
} catch (e) {
next(new Error('failed to load todo'));
}
});
router.route('/todos/:todo_id')
.get(function(req, res) {
console.log('GET', util.inspect(req.todo, {colors: true}));
res.json(req.todo);
})
.put(function(req, res) {
console.log('PUT', util.inspect(req.body, {colors: true}));
var index = TODOS.indexOf(req.todo);
var todo = TODOS[index] = req.body;
res.json(todo);
})
.delete(function(req, res) {
console.log('DELETE', req.todo_id);
var index = TODOS.indexOf(req.todo);
TODOS.splice(index, 1);
res.json(req.todo);
});
return router;
};

92
portal-2/src/browser.module.ts Executable file
View File

@ -0,0 +1,92 @@
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { RouterModule } from '@angular/router';
import { UniversalModule, isBrowser, isNode, AUTO_PREBOOT } from 'angular2-universal/browser'; // for AoT we need to manually split universal packages
import { AppModule, AppComponent } from './app/app.module';
import { SharedModule } from './app/shared/shared.module';
import { CacheService } from './app/shared/cache.service';
// Will be merged into @angular/platform-browser in a later release
// see https://github.com/angular/angular/pull/12322
import { Meta } from './angular2-meta';
// import * as LRU from 'modern-lru';
export function getLRU(lru?: any) {
// use LRU for node
// return lru || new LRU(10);
return lru || new Map();
}
export function getRequest() {
return Zone.current.get('req') || {};
}
export function getResponse() {
return Zone.current.get('res') || {};
}
// TODO(gdi2290): refactor into Universal
export const UNIVERSAL_KEY = 'UNIVERSAL_CACHE';
@NgModule({
bootstrap: [ AppComponent ],
imports: [
UniversalModule, // BrowserModule, HttpModule, and JsonpModule are included
FormsModule,
RouterModule.forRoot([], { useHash: false }),
SharedModule.forRoot(),
AppModule,
],
providers: [
{ provide: 'isBrowser', useValue: isBrowser },
{ provide: 'isNode', useValue: isNode },
{ provide: 'req', useFactory: getRequest },
{ provide: 'res', useFactory: getResponse },
{ provide: 'LRU', useFactory: getLRU, deps: [] },
CacheService,
Meta,
// { provide: AUTO_PREBOOT, useValue: false } // turn off auto preboot complete
]
})
export class MainModule {
constructor(public cache: CacheService) {
// TODO(gdi2290): refactor into a lifecycle hook
this.doRehydrate();
}
doRehydrate() {
let defaultValue = {};
let serverCache = this._getCacheValue(CacheService.KEY, defaultValue);
this.cache.rehydrate(serverCache);
}
_getCacheValue(key: string, defaultValue: any): any {
// browser
const win: any = window;
if (win[UNIVERSAL_KEY] && win[UNIVERSAL_KEY][key]) {
let serverCache = defaultValue;
try {
serverCache = JSON.parse(win[UNIVERSAL_KEY][key]);
if (typeof serverCache !== typeof defaultValue) {
console.log('Angular Universal: The type of data from the server is different from the default value type');
serverCache = defaultValue;
}
} catch (e) {
console.log('Angular Universal: There was a problem parsing the server data during rehydrate');
serverCache = defaultValue;
}
return serverCache;
} else {
console.log('Angular Universal: UNIVERSAL_CACHE is missing');
}
return defaultValue;
}
}

View File

@ -0,0 +1,43 @@
// the polyfills must be the first thing imported
import 'angular2-universal-polyfills';
import 'ts-helpers';
import './__workaround.browser'; // temporary until 2.1.1 things are patched in Core
// Angular 2
import { enableProdMode } from '@angular/core';
import { platformBrowser } from '@angular/platform-browser';
// for AoT use platformBrowser
// import { platformUniversalDynamic } from 'angular2-universal/browser';
import { load as loadWebFont } from 'webfontloader';
// enable prod for faster renders
enableProdMode();
import { MainModuleNgFactory } from './browser.module.ngfactory';
export const platformRef = platformBrowser();
// on document ready bootstrap Angular 2
export function main() {
// Load fonts async
// https://github.com/typekit/webfontloader#configuration
loadWebFont({
google: {
families: ['Droid Sans']
}
});
return platformRef.bootstrapModuleFactory(MainModuleNgFactory);
}
// support async tag or hmr
switch (document.readyState) {
case 'loading':
document.addEventListener('DOMContentLoaded', () => main());
break;
case 'interactive':
case 'complete':
default:
main();
}

View File

@ -1,20 +1,41 @@
// the polyfills must be the first thing imported
import 'angular2-universal-polyfills';
import 'ts-helpers';
import './__workaround.browser'; // temporary until 2.1.1 things are patched in Core
// Angular 2
import { enableProdMode} from '@angular/core';
import { platformUniversalDynamic } from 'angular2-universal';
import { enableProdMode } from '@angular/core';
import { platformUniversalDynamic } from 'angular2-universal/browser';
import { load as loadWebFont } from 'webfontloader';
// enable prod for faster renders
enableProdMode();
// enableProdMode();
import { MainModule } from './app.browser.module';
import { MainModule } from './browser.module';
const platformRef = platformUniversalDynamic();
export const platformRef = platformUniversalDynamic();
// on document ready bootstrap Angular 2
document.addEventListener('DOMContentLoaded', () => {
export function main() {
// Load fonts async
// https://github.com/typekit/webfontloader#configuration
loadWebFont({
google: {
families: ['Droid Sans']
}
});
platformRef.bootstrapModule(MainModule);
return platformRef.bootstrapModule(MainModule);
}
});
// support async tag or hmr
switch (document.readyState) {
case 'loading':
document.addEventListener('DOMContentLoaded', () => main());
break;
case 'interactive':
case 'complete':
default:
main();
}

View File

@ -1,6 +1,6 @@
<!doctype html>
<html lang="en">
<head>
<html>
<head>
<title>OpenAIRE</title>
<meta charset="UTF-8">
<meta name="description" content="Open Access Infrastructure for Europe ">
@ -30,6 +30,6 @@
Loading Universal ...
</app>
<script src="/index.js"></script>
<script async src="/main.bundle.js"></script>
</body>
</html>

69
portal-2/src/node.module.ts Executable file
View File

@ -0,0 +1,69 @@
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { RouterModule } from '@angular/router';
import { UniversalModule, isBrowser, isNode } from 'angular2-universal/node'; // for AoT we need to manually split universal packages
import { AppModule, AppComponent } from './app/app.module';
import { SharedModule } from './app/shared/shared.module';
import { CacheService } from './app/shared/cache.service';
// Will be merged into @angular/platform-browser in a later release
// see https://github.com/angular/angular/pull/12322
import { Meta } from './angular2-meta';
export function getLRU() {
return new Map();
}
export function getRequest() {
return {};
}
export function getResponse() {
return {};
}
// TODO(gdi2290): refactor into Universal
export const UNIVERSAL_KEY = 'UNIVERSAL_CACHE';
@NgModule({
bootstrap: [ AppComponent ],
imports: [
UniversalModule, // BrowserModule, HttpModule, and JsonpModule are included
FormsModule,
RouterModule.forRoot([], { useHash: false }),
SharedModule.forRoot(),
AppModule,
],
providers: [
{ provide: 'isBrowser', useValue: isBrowser },
{ provide: 'isNode', useValue: isNode },
{ provide: 'req', useFactory: getRequest },
{ provide: 'res', useFactory: getResponse },
{ provide: 'LRU', useFactory: getLRU, deps: [] },
CacheService,
Meta,
]
})
export class MainModule {
constructor(public cache: CacheService) {
}
/**
* We need to use the arrow function here to bind the context as this is a gotcha
* in Universal for now until it's fixed
*/
universalDoDehydrate = (universalCache) => {
universalCache[CacheService.KEY] = JSON.stringify(this.cache.dehydrate());
}
/**
* Clear the cache after it's rendered
*/
universalAfterDehydrate = () => {
// comment out if LRU provided at platform level to be shared between each user
this.cache.clear();
}
}

102
portal-2/src/server.aot.ts Normal file
View File

@ -0,0 +1,102 @@
// the polyfills must be one of the first things imported in node.js.
// The only modules to be imported higher - node modules with es6-promise 3.x or other Promise polyfill dependency
// (rule of thumb: do it if you have zone.js exception that it has been overwritten)
// if you are including modules that modify Promise, such as NewRelic,, you must include them before polyfills
import 'angular2-universal-polyfills';
import 'ts-helpers';
import './__workaround.node'; // temporary until 2.1.1 things are patched in Core
import * as path from 'path';
import * as express from 'express';
import * as bodyParser from 'body-parser';
import * as cookieParser from 'cookie-parser';
import * as compression from 'compression';
// Angular 2
import { enableProdMode } from '@angular/core';
// Angular 2 Universal
import { createEngine } from 'angular2-express-engine';
// App
import { MainModuleNgFactory } from './node.module.ngfactory';
// Routes
import { routes } from './server.routes';
// enable prod for faster renders
enableProdMode();
const app = express();
const ROOT = path.join(path.resolve(__dirname, '..'));
// Express View
app.engine('.html', createEngine({
precompile: false, // this needs to be false when using ngFactory
ngModule: MainModuleNgFactory,
providers: [
// use only if you have shared state between users
// { provide: 'LRU', useFactory: () => new LRU(10) }
// stateless providers only since it's shared
]
}));
app.set('port', process.env.PORT || 3000);
app.set('views', __dirname);
app.set('view engine', 'html');
app.set('json spaces', 2);
app.use(cookieParser('Angular 2 Universal'));
app.use(bodyParser.json());
app.use(compression());
function cacheControl(req, res, next) {
// instruct browser to revalidate in 60 seconds
res.header('Cache-Control', 'max-age=60');
next();
}
// Serve static files
app.use('/assets', cacheControl, express.static(path.join(__dirname, 'assets'), {maxAge: 30}));
app.use(cacheControl, express.static(path.join(ROOT, 'dist/client'), {index: false}));
//
/////////////////////////
// ** Example API
// Notice API should be in aseparate process
import { serverApi, createTodoApi } from './backend/api';
// Our API for demos only
app.get('/data.json', serverApi);
app.use('/api', createTodoApi());
function ngApp(req, res) {
res.render('index', {
req,
res,
// time: true, // use this to determine what part of your app is slow only in development
preboot: false,
baseUrl: '/',
requestUrl: req.originalUrl,
originUrl: `http://localhost:${ app.get('port') }`
});
}
/**
* use universal for specific routes
*/
app.get('/', ngApp);
routes.forEach(route => {
app.get(`/${route}`, ngApp);
app.get(`/${route}/*`, ngApp);
});
app.get('*', function(req, res) {
res.setHeader('Content-Type', 'application/json');
var pojo = { status: 404, message: 'No Content' };
var json = JSON.stringify(pojo, null, 2);
res.status(404).send(json);
});
// Server
let server = app.listen(app.get('port'), () => {
console.log(`Listening on: http://localhost:${server.address().port}`);
});

View File

@ -0,0 +1,23 @@
/**
* Server-side routes. Only the listed routes support html5pushstate.
* Has to match client side routes.
*
* Index (/) route does not have to be listed here.
*
* @example
* export const routes: string[] = [
* 'home', 'about'
* ];
**/
export const routes: string[] = [
'home',
'claims','claim','myclaims','linking','bulk-linking',
'search/person','search/publication','search/project','search/dataset','search/dataprovider','search/organization',
'search/find/people','search/find/publications','search/find/projects','search/find/datasets','search/find/dataproviders','search/find/organizations',
'search/advanced/people','search/advanced/publications','search/advanced/projects','search/advanced/datasets','search/advanced/dataproviders','search/advanced/organizations',
'deposit-publications','deposit-datasets','deposit-publications-result','deposit-datasets-result',
'search/data-providers','search/entity-registries',
'test',
'error'
];

View File

@ -3,19 +3,14 @@
// (rule of thumb: do it if you have zone.js exception that it has been overwritten)
// if you are including modules that modify Promise, such as NewRelic,, you must include them before polyfills
import 'angular2-universal-polyfills';
// Fix Universal Style
import { NodeDomRootRenderer, NodeDomRenderer } from 'angular2-universal/node';
function renderComponentFix(componentProto: any) {
return new NodeDomRenderer(this, componentProto, this._animationDriver);
}
NodeDomRootRenderer.prototype.renderComponent = renderComponentFix;
// End Fix Universal Style
import 'ts-helpers';
import './__workaround.node'; // temporary until 2.1.1 things are patched in Core
import * as path from 'path';
import * as express from 'express';
import * as bodyParser from 'body-parser';
import * as cookieParser from 'cookie-parser';
import * as compression from 'compression';
// Angular 2
import { enableProdMode } from '@angular/core';
@ -23,7 +18,10 @@ import { enableProdMode } from '@angular/core';
import { createEngine } from 'angular2-express-engine';
// App
import { MainModule } from './app.node.module';
import { MainModule } from './node.module';
// Routes
import { routes } from './server.routes';
// enable prod for faster renders
enableProdMode();
@ -33,752 +31,70 @@ const ROOT = path.join(path.resolve(__dirname, '..'));
// Express View
app.engine('.html', createEngine({
precompile: true,
ngModule: MainModule,
providers: [
// use only if you have shared state between users
// { provide: 'LRU', useFactory: () => new LRU(10) }
// stateless providers only since it's shared
]
}));
app.set('port', process.env.PORT || 3000);
app.set('views', __dirname);
app.set('view engine', 'html');
app.set('json spaces', 2);
app.use(cookieParser('Angular 2 Universal'));
app.use(bodyParser.json());
app.use(compression());
function cacheControl(req, res, next) {
// instruct browser to revalidate in 60 seconds
res.header('Cache-Control', 'max-age=60');
next();
}
// Serve static files
app.use('/assets', express.static(path.join(__dirname, 'assets'), {maxAge: 30}));
app.use(express.static(path.join(ROOT, 'dist/client'), {index: false}));
/* **AK** Add this path so that index.html can see files from node_modules folder (e.g. bootstrap files)*/
// app.use(express.static(path.join(ROOT, 'node_modules'), {index: false}));
// app.get('/bootstrap.css', express.static(path.join(ROOT, 'node_modules/bootstrap/dist/css/bootstrap.min.css')));
app.use('/assets', cacheControl, express.static(path.join(__dirname, 'assets'), {maxAge: 30}));
app.use(cacheControl, express.static(path.join(ROOT, 'dist/client'), {index: false}));
import { serverApi } from './backend/api';
//
/////////////////////////
// ** Example API
// Notice API should be in aseparate process
import { serverApi, createTodoApi } from './backend/api';
// Our API for demos only
app.get('/data.json', serverApi);
app.use('/api', createTodoApi());
function ngApp(req, res) {
res.render('index', {
req,
res,
// time: true, // use this to determine what part of your app is slow only in development
preboot: false,
baseUrl: '/',
requestUrl: req.originalUrl,
originUrl: 'http://localhost:3000'
originUrl: `http://localhost:${ app.get('port') }`
});
}
// Routes with html5pushstate
// ensure routes match client-side-app
/**
* use universal for specific routes
*/
app.get('/', ngApp);
app.get('/claims', ngApp);
app.get('/home', ngApp);
app.get('/claim', ngApp);
app.get('/myclaims', ngApp);
app.get('/linking', ngApp);
app.get('/bulk-linking', ngApp);
app.get('/search/person', ngApp);
app.get('/search/project', ngApp);
app.get('/search/organization', ngApp);
app.get('/search/dataset', ngApp);
app.get('/search/dataprovider', ngApp);
app.get('search/data-providers', ngApp);
app.get('search/entity-registries', ngApp);
app.get('/search/publication', ngApp);
app.get('/search', ngApp);
app.get('/search/find/publications', ngApp);
app.get('/search/advanced/publications', ngApp);
app.get('/search/advanced/dataproviders', ngApp);
app.get('/search/advanced/projects', ngApp);
app.get('/search/advanced/organizations', ngApp);
app.get('/search/advanced/people', ngApp);
app.get('/search/advanced/datasets', ngApp);
app.get('/search/find/dataproviders', ngApp);
app.get('/search/find/projects', ngApp);
app.get('/search/find/datasets', ngApp);
app.get('/search/find/organizations', ngApp);
app.get('/search/find/people', ngApp);
app.get('/deposit-publications', ngApp);
app.get('/deposit-datasets', ngApp);
app.get('/deposit-publications-result', ngApp);
app.get('/deposit-datasets-result', ngApp);
app.get('/error', ngApp);
app.get('/test', ngApp);
app.get('/refineResults.json', function(req, res) {
res.setHeader('Content-Type', 'application/json');
var pojo = {
"refineResults":[
{
"projectendyear":[
{
"name":"2016",
"id":"2016",
"count":"103"
},
{
"name":"2015",
"id":"2015",
"count":"91"
},
{
"name":"2013",
"id":"2013",
"count":"69"
},
{
"name":"2010",
"id":"2010",
"count":"60"
},
{
"name":"2011",
"id":"2011",
"count":"59"
},
{
"name":"2014",
"id":"2014",
"count":"59"
},
{
"name":"2012",
"id":"2012",
"count":"58"
},
{
"name":"2005",
"id":"2005",
"count":"54"
},
{
"name":"2000",
"id":"2000",
"count":"52"
},
{
"name":"2006",
"id":"2006",
"count":"51"
},
{
"name":"2007",
"id":"2007",
"count":"51"
},
{
"name":"2017",
"id":"2017",
"count":"49"
},
{
"name":"2009",
"id":"2009",
"count":"48"
},
{
"name":"2002",
"id":"2002",
"count":"43"
},
{
"name":"2004",
"id":"2004",
"count":"43"
},
{
"name":"2001",
"id":"2001",
"count":"41"
},
{
"name":"1999",
"id":"1999",
"count":"40"
},
{
"name":"2008",
"id":"2008",
"count":"37"
},
{
"name":"1997",
"id":"1997",
"count":"35"
},
{
"name":"2003",
"id":"2003",
"count":"35"
},
{
"name":"1998",
"id":"1998",
"count":"33"
},
{
"name":"1993",
"id":"1993",
"count":"28"
},
{
"name":"1995",
"id":"1995",
"count":"28"
},
{
"name":"1990",
"id":"1990",
"count":"27"
},
{
"name":"1994",
"id":"1994",
"count":"24"
},
{
"name":"1996",
"id":"1996",
"count":"23"
},
{
"name":"1992",
"id":"1992",
"count":"22"
},
{
"name":"1979",
"id":"1979",
"count":"19"
},
{
"name":"1988",
"id":"1988",
"count":"19"
},
{
"name":"1989",
"id":"1989",
"count":"18"
},
{
"name":"1991",
"id":"1991",
"count":"18"
},
{
"name":"1974",
"id":"1974",
"count":"17"
},
{
"name":"2018",
"id":"2018",
"count":"17"
},
{
"name":"1975",
"id":"1975",
"count":"14"
},
{
"name":"1986",
"id":"1986",
"count":"14"
},
{
"name":"1982",
"id":"1982",
"count":"13"
},
{
"name":"1987",
"id":"1987",
"count":"13"
},
{
"name":"1981",
"id":"1981",
"count":"12"
},
{
"name":"1985",
"id":"1985",
"count":"12"
},
{
"name":"1976",
"id":"1976",
"count":"11"
},
{
"name":"1983",
"id":"1983",
"count":"9"
},
{
"name":"2019",
"id":"2019",
"count":"9"
},
{
"name":"1973",
"id":"1973",
"count":"8"
},
{
"name":"1980",
"id":"1980",
"count":"8"
},
{
"name":"1968",
"id":"1968",
"count":"7"
},
{
"name":"1984",
"id":"1984",
"count":"7"
},
{
"name":"1970",
"id":"1970",
"count":"6"
},
{
"name":"1969",
"id":"1969",
"count":"5"
},
{
"name":"1978",
"id":"1978",
"count":"5"
},
{
"name":"2020",
"id":"2020",
"count":"5"
},
{
"name":"1966",
"id":"1966",
"count":"3"
},
{
"name":"1972",
"id":"1972",
"count":"3"
},
{
"name":"1977",
"id":"1977",
"count":"3"
},
{
"name":"1962",
"id":"1962",
"count":"2"
},
{
"name":"1963",
"id":"1963",
"count":"2"
},
{
"name":"1971",
"id":"1971",
"count":"2"
},
{
"name":"1960",
"id":"1960",
"count":"1"
},
{
"name":"1961",
"id":"1961",
"count":"1"
},
{
"name":"1964",
"id":"1964",
"count":"1"
},
{
"name":"1967",
"id":"1967",
"count":"1"
},
{
"name":"2021",
"id":"2021",
"count":"1"
}
]
},
{
"projectstartyear":[
{
"name":"2015",
"id":"2015",
"count":"75"
},
{
"name":"2008",
"id":"2008",
"count":"71"
},
{
"name":"2011",
"id":"2011",
"count":"66"
},
{
"name":"2009",
"id":"2009",
"count":"65"
},
{
"name":"2010",
"id":"2010",
"count":"65"
},
{
"name":"2003",
"id":"2003",
"count":"63"
},
{
"name":"2013",
"id":"2013",
"count":"62"
},
{
"name":"2012",
"id":"2012",
"count":"61"
},
{
"name":"2014",
"id":"2014",
"count":"61"
},
{
"name":"2005",
"id":"2005",
"count":"59"
},
{
"name":"2002",
"id":"2002",
"count":"54"
},
{
"name":"2004",
"id":"2004",
"count":"50"
},
{
"name":"2007",
"id":"2007",
"count":"49"
},
{
"name":"2006",
"id":"2006",
"count":"47"
},
{
"name":"1996",
"id":"1996",
"count":"45"
},
{
"name":"1997",
"id":"1997",
"count":"44"
},
{
"name":"1998",
"id":"1998",
"count":"44"
},
{
"name":"2001",
"id":"2001",
"count":"40"
},
{
"name":"2000",
"id":"2000",
"count":"38"
},
{
"name":"1999",
"id":"1999",
"count":"36"
},
{
"name":"1992",
"id":"1992",
"count":"34"
},
{
"name":"1991",
"id":"1991",
"count":"32"
},
{
"name":"1974",
"id":"1974",
"count":"31"
},
{
"name":"1994",
"id":"1994",
"count":"31"
},
{
"name":"1993",
"id":"1993",
"count":"30"
},
{
"name":"1990",
"id":"1990",
"count":"27"
},
{
"name":"1995",
"id":"1995",
"count":"27"
},
{
"name":"1987",
"id":"1987",
"count":"24"
},
{
"name":"1985",
"id":"1985",
"count":"23"
},
{
"name":"1988",
"id":"1988",
"count":"18"
},
{
"name":"2016",
"id":"2016",
"count":"18"
},
{
"name":"1989",
"id":"1989",
"count":"17"
},
{
"name":"1976",
"id":"1976",
"count":"16"
},
{
"name":"1986",
"id":"1986",
"count":"16"
},
{
"name":"1977",
"id":"1977",
"count":"14"
},
{
"name":"1980",
"id":"1980",
"count":"13"
},
{
"name":"1981",
"id":"1981",
"count":"12"
},
{
"name":"1983",
"id":"1983",
"count":"12"
},
{
"name":"1973",
"id":"1973",
"count":"10"
},
{
"name":"1968",
"id":"1968",
"count":"9"
},
{
"name":"1978",
"id":"1978",
"count":"8"
},
{
"name":"1979",
"id":"1979",
"count":"8"
},
{
"name":"1984",
"id":"1984",
"count":"8"
},
{
"name":"1972",
"id":"1972",
"count":"6"
},
{
"name":"1982",
"id":"1982",
"count":"6"
},
{
"name":"1967",
"id":"1967",
"count":"4"
},
{
"name":"1969",
"id":"1969",
"count":"4"
},
{
"name":"1961",
"id":"1961",
"count":"3"
},
{
"name":"1965",
"id":"1965",
"count":"3"
},
{
"name":"1970",
"id":"1970",
"count":"3"
},
{
"name":"1971",
"id":"1971",
"count":"3"
},
{
"name":"1975",
"id":"1975",
"count":"3"
},
{
"name":"1962",
"id":"1962",
"count":"2"
},
{
"name":"1917",
"id":"1917",
"count":"1"
},
{
"name":"1959",
"id":"1959",
"count":"1"
},
{
"name":"1960",
"id":"1960",
"count":"1"
},
{
"name":"1963",
"id":"1963",
"count":"1"
},
{
"name":"1966",
"id":"1966",
"count":"1"
}
]
},
{
"funderid":[
{
"name":"nsf_________::NSF",
"id":"nsf_________::NSF",
"count":"1060"
},
{
"name":"ec__________::EC",
"id":"ec__________::EC",
"count":"150"
},
{
"name":"nhmrc_______::NHMRC",
"id":"nhmrc_______::NHMRC",
"count":"90"
},
{
"name":"arc_________::ARC",
"id":"arc_________::ARC",
"count":"62"
},
{
"name":"fct_________::FCT",
"id":"fct_________::FCT",
"count":"50"
},
{
"name":"wt__________::WT",
"id":"wt__________::WT",
"count":"21"
},
{
"name":"sfi_________::SFI",
"id":"sfi_________::SFI",
"count":"17"
},
{
"name":"irb_hr______::MSES",
"id":"irb_hr______::MSES",
"count":"1"
}
]
},
{
"projectecsc39":[
{
"name":"false",
"id":"false",
"count":"96"
},
{
"name":"true",
"id":"true",
"count":"4"
}
]
}
]
};
var json = JSON.stringify(pojo, null, 2);
res.status(200).send(json);
routes.forEach(route => {
app.get(`/${route}`, ngApp);
app.get(`/${route}/*`, ngApp);
});
app.get('*', ngApp);
/*app.get('*', function(req, res) {
res.setHeader('Content-Type', 'application/json');
var pojo = { status: 404, message: 'No Content' };
var json = JSON.stringify(pojo, null, 2);
res.status(404).send(json);
});
*/
// Server
let server = app.listen(process.env.PORT || 3000, () => {
let server = app.listen(app.get('port'), () => {
console.log(`Listening on: http://localhost:${server.address().port}`);
});

View File

@ -21,13 +21,30 @@ import * as _ from 'lodash'
*
*/
// declare module '*'; // default type definitions for any for modules that are not found.
// caveat: if this is enabled and you do not have the proper module there may not be an error.
// suggestion: follow the pattern below with modern-lru which provides an alternative way to create an 'any' module.
// for legacy tslint etc to understand
declare module 'modern-lru' {
let x: any;
export = x;
}
declare var System: SystemJS;
interface SystemJS {
import: (path?: string) => Promise<any>;
}
// Extra variables that live on Global that will be replaced by webpack DefinePlugin
declare var ENV: string;
declare var HMR: boolean;
declare var Zone: {current: any};
interface GlobalEnvironment {
ENV;
HMR;
SystemJS: SystemJS;
System: SystemJS;
}
interface WebpackModule {

View File

@ -0,0 +1,28 @@
{
"compilerOptions": {
"declaration": false,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"module": "commonjs",
"moduleResolution": "node",
"outDir": "dist",
"sourceMap": true,
"sourceRoot": "src",
"noEmitHelpers": true,
"target": "es5",
"typeRoots": [
"node_modules/@types"
],
"lib": ["es6", "dom"]
},
"include": [
"./src/**/*.module.ts",
"./src/*.d.ts"
],
"angularCompilerOptions": {
"debug": false
},
"compileOnSave": false,
"buildOnSave": false,
"atom": { "rewriteTsconfig": false }
}

View File

@ -8,23 +8,19 @@
"outDir": "dist",
"sourceMap": true,
"sourceRoot": "src",
"noEmitHelpers": true,
"target": "es5",
"lib": ["es6", "dom"],
"types": [
"body-parser",
"compression",
"cookie-parser",
"express",
"express-serve-static-core",
"mime",
"node",
"serve-static",
"hammerjs"
]
"typeRoots": [
"node_modules/@types"
],
"lib": ["es6", "dom"]
},
"exclude": [
"node_modules"
],
"angularCompilerOptions": {
"debug": false
},
"compileOnSave": false,
"buildOnSave": false,
"atom": { "rewriteTsconfig": false }

View File

@ -1,20 +1,9 @@
var webpack = require('webpack');
var path = require('path');
var clone = require('js.clone');
var webpackMerge = require('webpack-merge');
var commonConfig = {
resolve: {
extensions: ['.ts', '.js', '.json']
},
module: {
loaders: [
// TypeScript
{ test: /\.ts$/, loaders: ['awesome-typescript-loader', 'angular2-template-loader'] },
{ test: /\.html$/, loader: 'raw-loader' },
{ test: /\.css$/, loader: 'raw-loader' },
{ test: /\.json$/, loader: 'json-loader' }
],
},
plugins: [
export var commonPlugins = [
new webpack.ContextReplacementPlugin(
// The (\\|\/) piece accounts for path separators in *nix and Windows
/angular(\\|\/)core(\\|\/)src(\\|\/)linker/,
@ -24,23 +13,44 @@ var commonConfig = {
}
),
// To use gzip, you can run 'npm install compression-webpack-plugin --save-dev'
// add 'var CompressionPlugin = require("compression-webpack-plugin");' on the top
// and comment out below codes
//
// new CompressionPlugin({
// asset: "[path].gz[query]",
// algorithm: "gzip",
// test: /\.js$|\.css$|\.html$/,
// threshold: 10240,
// minRatio: 0.8
// })
// Loader options
new webpack.LoaderOptionsPlugin({
}),
];
export var commonConfig = {
// https://webpack.github.io/docs/configuration.html#devtool
devtool: 'source-map',
resolve: {
extensions: ['.ts', '.js', '.json'],
modules: [ root('node_modules') ]
},
context: __dirname,
output: {
publicPath: '',
filename: '[name].bundle.js'
},
module: {
rules: [
// TypeScript
{ test: /\.ts$/, use: ['awesome-typescript-loader', 'angular2-template-loader'] },
{ test: /\.html$/, use: 'raw-loader' },
{ test: /\.css$/, use: 'raw-loader' },
{ test: /\.json$/, use: 'json-loader' }
],
},
plugins: [
// Use commonPlugins.
]
};
// Client.
export var clientPlugins = [
var clientConfig = {
];
export var clientConfig = {
target: 'web',
entry: './src/client',
output: {
@ -48,6 +58,7 @@ var clientConfig = {
},
node: {
global: true,
crypto: 'empty',
__dirname: true,
__filename: true,
process: true,
@ -56,53 +67,29 @@ var clientConfig = {
};
var serverConfig = {
// Server.
export var serverPlugins = [
];
export var serverConfig = {
target: 'node',
entry: './src/server', // use the entry file of the node server if everything is ts rather than es5
output: {
filename: 'index.js',
path: root('dist/server'),
libraryTarget: 'commonjs2'
},
module: {
loaders: [
{ test: /angular2-material/, loader: "imports-loader?window=>global" }
rules: [
{ test: /@angular(\\|\/)material/, use: "imports-loader?window=>global" }
],
},
externals: includeClientPackages([
// include these client packages so we can transform their source with webpack loaders
// '@angular/common',
// '@angular/compiler',
// '@angular/core',
// '@angular/forms',
// '@angular/http',
// '@angular/platform-browser',
// '@angular/platform-browser-dynamic',
// '@angular/platform-server',
// '@angular/router',
'@angular2-material/button',
'@angular2-material/button',
'@angular2-material/card',
'@angular2-material/checkbox',
'@angular2-material/core',
'@angular2-material/grid',
'@angular2-material/icon',
'@angular2-material/input',
'@angular2-material/list',
'@angular2-material/menu',
'@angular2-material/progress',
'@angular2-material/progress',
'@angular2-material/radio',
'@angular2-material/sidenav',
'@angular2-material/slider',
'@angular2-material/slide',
'@angular2-material/tabs',
'@angular2-material/toolbar',
'@angular2-material/tooltip'
]),
externals: includeClientPackages(
/@angularclass|@angular|angular2-|ng2-|ng-|@ng-|angular-|@ngrx|ngrx-|@angular2|ionic|@ionic|-angular2|-ng2|-ng/
),
node: {
global: true,
crypto: true,
__dirname: true,
__filename: true,
process: true,
@ -110,45 +97,37 @@ var serverConfig = {
}
};
// Default config
var defaultConfig = {
context: __dirname,
output: {
publicPath: path.resolve(__dirname),
filename: 'index.js'
}
};
var webpackMerge = require('webpack-merge');
module.exports = [
export default [
// Client
webpackMerge({}, defaultConfig, commonConfig, clientConfig),
webpackMerge(clone(commonConfig), clientConfig, { plugins: clientPlugins.concat(commonPlugins) }),
// Server
webpackMerge({}, defaultConfig, commonConfig, serverConfig)
webpackMerge(clone(commonConfig), serverConfig, { plugins: serverPlugins.concat(commonPlugins) })
];
function includeClientPackages(packages) {
// Helpers
export function includeClientPackages(packages, localModule?: string[]) {
return function(context, request, cb) {
if (packages && packages.indexOf(request) !== -1) {
if (localModule instanceof RegExp && localModule.test(request)) {
return cb();
}
return checkNodeImport(context, request, cb);
if (packages instanceof RegExp && packages.test(request)) {
return cb();
}
if (Array.isArray(packages) && packages.indexOf(request) !== -1) {
return cb();
}
if (!path.isAbsolute(request) && request.charAt(0) !== '.') {
return cb(null, 'commonjs ' + request);
}
return cb();
};
}
// Helpers
function checkNodeImport(context, request, cb) {
if (!path.isAbsolute(request) && request.charAt(0) !== '.') {
cb(null, 'commonjs ' + request); return;
}
cb();
}
function root(args) {
export function root(args) {
args = Array.prototype.slice.call(arguments, 0);
return path.join.apply(path, [__dirname].concat(args));
}

View File

@ -0,0 +1,152 @@
var webpack = require('webpack');
var path = require('path');
var clone = require('js.clone');
var webpackMerge = require('webpack-merge');
var V8LazyParseWebpackPlugin = require('v8-lazy-parse-webpack-plugin');
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
import webpackConfig, { root, includeClientPackages } from './webpack.config';
// var CompressionPlugin = require('compression-webpack-plugin');
export var commonPlugins = [
new V8LazyParseWebpackPlugin(),
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify('production'),
}),
// Loader options
new webpack.LoaderOptionsPlugin({
minimize: true,
debug: false
}),
new webpack.NormalModuleReplacementPlugin(
/facade(\\|\/)async/,
root('node_modules/@angular/core/src/facade/async.js')
),
new webpack.NormalModuleReplacementPlugin(
/facade(\\|\/)collection/,
root('node_modules/@angular/core/src/facade/collection.js')
),
new webpack.NormalModuleReplacementPlugin(
/facade(\\|\/)errors/,
root('node_modules/@angular/core/src/facade/errors.js')
),
new webpack.NormalModuleReplacementPlugin(
/facade(\\|\/)lang/,
root('node_modules/@angular/core/src/facade/lang.js')
),
new webpack.NormalModuleReplacementPlugin(
/facade(\\|\/)math/,
root('node_modules/@angular/core/src/facade/math.js')
),
];
export var commonConfig = {
output: {
filename: '[name].bundle.js',
chunkFilename: '[chunkhash].js'
},
};
// Client.
export var clientPlugins = [
new BundleAnalyzerPlugin({
analyzerMode: 'disabled', // change it to `server` to view bundle stats
reportFilename: 'report.html',
generateStatsFile: true,
statsFilename: 'stats.json',
}),
// To use gzip, you can run 'npm install compression-webpack-plugin --save-dev'
// add 'var CompressionPlugin = require("compression-webpack-plugin");' on the top
// and comment out below codes
//
// new CompressionPlugin({
// asset: "[path].gz[query]",
// algorithm: "gzip",
// test: /\.js$|\.css$|\.html$/,
// threshold: 10240,
// minRatio: 0.8
// }),
new webpack.optimize.UglifyJsPlugin({
// beautify: true,
// mangle: false,
output: {
comments: false
},
compress: {
warnings: false,
conditionals: true,
unused: true,
comparisons: true,
sequences: true,
dead_code: true,
evaluate: true,
if_return: true,
join_vars: true,
negate_iife: false // we need this for lazy v8
}
}),
new webpack.NormalModuleReplacementPlugin(
/@angular(\\|\/)upgrade/,
root('empty.js')
),
// problem with platformUniversalDynamic on the server/client
new webpack.NormalModuleReplacementPlugin(
/@angular(\\|\/)compiler/,
root('empty.js')
),
new webpack.NormalModuleReplacementPlugin(
/@angular(\\|\/)platform-browser-dynamic/,
root('empty.js')
),
new webpack.NormalModuleReplacementPlugin(
/dom(\\|\/)debug(\\|\/)ng_probe/,
root('empty.js')
),
new webpack.NormalModuleReplacementPlugin(
/dom(\\|\/)debug(\\|\/)by/,
root('empty.js')
),
new webpack.NormalModuleReplacementPlugin(
/src(\\|\/)debug(\\|\/)debug_node/,
root('empty.js')
),
new webpack.NormalModuleReplacementPlugin(
/src(\\|\/)debug(\\|\/)debug_renderer/,
root('empty.js')
),
// Waiting for https://github.com/ampedandwired/html-webpack-plugin/issues/446
// new webpack.optimize.AggressiveSplittingPlugin({
// minSize: 30000,
// maxSize: 250000
// }),
];
export var clientConfig = {
entry: './src/client.aot',
recordsOutputPath: root('webpack.records.json')
};
// Server.
export var serverPlugins = [
];
export var serverConfig = {
entry: './src/server.aot',
output: {
filename: 'index.js'
},
};
export default [
// Client
webpackMerge(webpackConfig[0], clone(commonConfig), clientConfig, {plugins: webpackConfig[0].plugins.concat(commonPlugins, clientPlugins) }),
// Server
webpackMerge(webpackConfig[1], clone(commonConfig), serverConfig, {plugins: webpackConfig[1].plugins.concat(commonPlugins, serverPlugins) })
];