[Connect|Trunk]

Merge into trunk branch angular7 rev 55968




git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-connect-portal/trunk@55971 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
argiro.kokogiannaki 2019-06-03 14:41:57 +00:00
parent 7049df4cd2
commit c1b26b43e6
13 changed files with 271 additions and 176 deletions

View File

@ -1,111 +0,0 @@
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"project": {
"name": "ng-universal-demo"
},
"apps": [
{
"root": "src",
"outDir": "dist/browser",
"assets": [
"assets",
"robots.txt"
],
"index": "index.html",
"main": "main.ts",
"polyfills": "polyfills.ts",
"test": "test.ts",
"tsconfig": "tsconfig.app.json",
"testTsconfig": "tsconfig.spec.json",
"prefix": "app",
"styles": [
"styles.css",
"../node_modules/datatables.net-dt/css/jquery.dataTables.css"
],
"scripts": [
"../node_modules/jquery/dist/jquery.js",
"../node_modules/datatables.net/js/jquery.dataTables.js"
],
"environmentSource": "environments/environment.ts",
"environments": {
"dev": "environments/environment.ts",
"prod": "environments/environment.prod.ts"
}
},
{
"platform": "server",
"root": "src",
"outDir": "dist/server",
"assets": [
"assets",
"robots.txt"
],
"index": "index.html",
"main": "main.server.ts",
"test": "test.ts",
"tsconfig": "tsconfig.server.json",
"testTsconfig": "tsconfig.spec.json",
"prefix": "app",
"styles": [
"styles.css"
],
"scripts": [],
"environmentSource": "environments/environment.ts",
"environments": {
"dev": "environments/environment.ts",
"prod": "environments/environment.prod.ts"
}
}
],
"e2e": {
"protractor": {
"config": "./protractor.conf.js"
}
},
"lint": [
{
"project": "src/tsconfig.app.json",
"exclude": "**/node_modules/**"
},
{
"project": "src/tsconfig.spec.json",
"exclude": "**/node_modules/**"
},
{
"project": "e2e/tsconfig.e2e.json",
"exclude": "**/node_modules/**"
}
],
"test": {
"karma": {
"config": "./karma.conf.js"
}
},
"defaults": {
"styleExt": "css",
"component": {
"spec": false,
"inlineStyle": true,
"inlineTemplate": true
},
"directive": {
"spec": false
},
"class": {
"spec": false
},
"guard": {
"spec": false
},
"module": {
"spec": false
},
"pipe": {
"spec": false
},
"service": {
"spec": false
}
}
}

177
angular.json Normal file
View File

@ -0,0 +1,177 @@
{
"$schema": "./node_modules/@angular-devkit/core/src/workspace/workspace-schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
"ng-universal-demo": {
"root": "",
"sourceRoot": "src",
"projectType": "application",
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist/browser",
"index": "src/index.html",
"main": "src/main.ts",
"tsConfig": "src/tsconfig.app.json",
"polyfills": "src/polyfills.ts",
"assets": [
"src/assets",
"src/robots.txt"
],
"styles": [
"src/styles.css",
"node_modules/datatables.net-dt/css/jquery.dataTables.css"
],
"scripts": [
"node_modules/jquery/dist/jquery.js",
"node_modules/datatables.net/js/jquery.dataTables.js"
]
},
"configurations": {
"production": {
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"aot": true,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
]
}
}
},
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
"browserTarget": "ng-universal-demo:build"
},
"configurations": {
"production": {
"browserTarget": "ng-universal-demo:build:production"
}
}
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "ng-universal-demo:build"
}
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"main": "src/test.ts",
"karmaConfig": "./karma.conf.js",
"polyfills": "src/polyfills.ts",
"tsConfig": "src/tsconfig.spec.json",
"scripts": [
"node_modules/jquery/dist/jquery.js",
"node_modules/datatables.net/js/jquery.dataTables.js"
],
"styles": [
"src/styles.css",
"node_modules/datatables.net-dt/css/jquery.dataTables.css"
],
"assets": [
"src/assets",
"src/robots.txt"
]
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": [
"src/tsconfig.app.json",
"src/tsconfig.spec.json"
],
"exclude": [
"**/node_modules/**"
]
}
},
"server": {
"builder": "@angular-devkit/build-angular:server",
"options": {
"outputPath": "dist/server",
"main": "src/main.server.ts",
"tsConfig": "src/tsconfig.server.json"
},
"configurations": {
"production": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
]
}
}
}
}
},
"ng-universal-demo-e2e": {
"root": "e2e",
"sourceRoot": "e2e",
"projectType": "application",
"architect": {
"e2e": {
"builder": "@angular-devkit/build-angular:protractor",
"options": {
"protractorConfig": "./protractor.conf.js",
"devServerTarget": "ng-universal-demo:serve"
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": [
"e2e/tsconfig.e2e.json"
],
"exclude": [
"**/node_modules/**"
]
}
}
}
}
},
"defaultProject": "ng-universal-demo",
"schematics": {
"@schematics/angular:class": {
"spec": false
},
"@schematics/angular:component": {
"spec": false,
"inlineStyle": true,
"inlineTemplate": true,
"prefix": "app",
"styleext": "css"
},
"@schematics/angular:directive": {
"spec": false,
"prefix": "app"
},
"@schematics/angular:guard": {
"spec": false
},
"@schematics/angular:module": {
"spec": false
},
"@schematics/angular:pipe": {
"spec": false
},
"@schematics/angular:service": {
"spec": false
}
}
}

View File

@ -9,57 +9,65 @@
"scripts": {
"ng": "ng",
"start": " ng serve --disable-host-check --host 0.0.0.0",
"start:dynamic": "PORT=5000 npm run build:dynamic && npm run serve:dynamic",
"start:static": "npm run build:static && npm run serve:static",
"start:ssr": "npm run build:ssr && npm run serve:ssr",
"start:prerender": "npm run build:prerender && npm run serve:prerender",
"build": "ng build",
"build:client-and-server-bundles": "ng build --prod -sm --stats-json && ng build --prod --app 1 --output-hashing=false",
"build:static": "npm run build:client-and-server-bundles && npm run webpack:server && npm run generate:static",
"build:dynamic": "npm run build:client-and-server-bundles && npm run webpack:server",
"generate:static": "cd dist && node prerender",
"build:client-and-server-bundles": "ng build --prod --sourceMap --stats-json=true && ng run ng-universal-demo:server:production",
"build:prerender": "npm run build:client-and-server-bundles && npm run webpack:server && npm run generate:prerender",
"build:ssr": "npm run build:client-and-server-bundles && npm run webpack:server",
"generate:prerender": "cd dist && node prerender",
"webpack:server": "webpack --config webpack.server.config.js --progress --colors",
"serve:static": "cd dist/browser && http-server",
"serve:dynamic": "node dist/server"
"serve:prerender": "cd dist/browser && http-server",
"serve:ssr": "node dist/server"
},
"private": true,
"dependencies": {
"@angular/animations": "^4.2.4",
"@angular/common": "^4.2.4",
"@angular/compiler": "^4.2.4",
"@angular/core": "^4.2.4",
"@angular/forms": "^4.2.4",
"@angular/http": "^4.2.4",
"@angular/platform-browser": "^4.2.4",
"@angular/platform-browser-dynamic": "^4.2.4",
"@angular/platform-server": "^4.2.4",
"@angular/router": "^4.2.4",
"@nguniversal/express-engine": "^1.0.0-beta.3",
"@nguniversal/module-map-ngfactory-loader": "^1.0.0-beta.3",
"angular-datatables": "^4.4.0",
"@angular/animations": "^7.2.14",
"@angular/cdk": "^7.3.7",
"@angular/common": "7.2.14",
"@angular/compiler": "7.2.14",
"@angular/core": "7.2.14",
"@angular/forms": "7.2.14",
"@angular/http": "7.2.14",
"@angular/material": "^7.3.7",
"@angular/platform-browser": "7.2.14",
"@angular/platform-browser-dynamic": "7.2.14",
"@angular/platform-server": "7.2.14",
"@angular/router": "7.2.14",
"@nguniversal/express-engine": "^6.0.0",
"@nguniversal/module-map-ngfactory-loader": "^6.0.0",
"@types/express": "^4.16.1",
"angular-datatables": "^4.4.1",
"citation-js": "^0.3.4",
"clipboard": "^1.5.16",
"core-js": "^2.4.1",
"datatables.net": "^1.10.16",
"datatables.net-dt": "^1.10.16",
"jquery": "^3.2.1",
"ng-recaptcha": "^3.0.5",
"ng2-ckeditor": "1.1.9",
"datatables.net": "^1.10.19",
"datatables.net-dt": "^1.10.19",
"jquery": "^3.4.1",
"ngx-json-ld": "0.1.6",
"rxjs": "^5.4.2",
"prom-client": "^11.3.0",
"ts-md5": "^1.2.0",
"tslib": "^1.9.0",
"wikidata-sdk": "^5.2.9",
"zone.js": "^0.8.14"
"zone.js": "^0.8.26",
"ng-recaptcha": "^3.0.5",
"ng2-ckeditor": "1.1.9"
},
"devDependencies": {
"@angular/cli": "^1.3.0",
"@angular/compiler-cli": "^4.2.4",
"@angular/language-service": "^4.2.4",
"@types/datatables.net": "^1.10.8",
"@types/jquery": "^3.2.17",
"@angular-devkit/build-angular": "~0.13.0",
"@angular/cli": "^7.3.9",
"@angular/compiler-cli": "7.2.14",
"@angular/language-service": "7.2.14",
"@types/datatables.net": "^1.10.17",
"@types/jquery": "^3.3.29",
"@types/node": "^8.0.30",
"cpy-cli": "^1.0.1",
"http-server": "^0.10.0",
"reflect-metadata": "^0.1.10",
"ts-loader": "^2.3.7",
"typescript": "~2.3.3"
"rxjs": "6.5.1",
"rxjs-compat": "^6.5.1",
"ts-loader": "^4.2.0",
"typescript": "3.2.4",
"webpack-cli": "^3.3.2"
}
}

View File

@ -16,7 +16,7 @@ import { renderModuleFactory } from '@angular/platform-server';
import { ROUTES } from './static.paths';
// * NOTE :: leave this as require() since this file is built Dynamically from webpack
const { AppServerModuleNgFactory, LAZY_MODULE_MAP } = require('./dist/server/main.bundle');
const { AppServerModuleNgFactory, LAZY_MODULE_MAP } = require('./dist/server/main');
const BROWSER_FOLDER = join(process.cwd(), 'browser');
@ -27,7 +27,7 @@ let previousRender = Promise.resolve();
// Iterate each route path
ROUTES.forEach(route => {
var fullPath = join(BROWSER_FOLDER, route);
const fullPath = join(BROWSER_FOLDER, route);
// Make sure the directory structure is there
if(!existsSync(fullPath)){

View File

@ -20,10 +20,10 @@ const DIST_FOLDER = join(process.cwd(), 'dist');
const template = readFileSync(join(DIST_FOLDER, 'browser', 'index.html')).toString();
// * NOTE :: leave this as require() since this file is built Dynamically from webpack
const { AppServerModuleNgFactory, LAZY_MODULE_MAP } = require('./dist/server/main.bundle');
const { AppServerModuleNgFactory, LAZY_MODULE_MAP } = require('./dist/server/main');
// Express Engine
import { ngExpressEngine } from '@nguniversal/express-engine';
import {ngExpressEngine, RenderOptions} from '@nguniversal/express-engine';
// Import module map for lazy loading
import { provideModuleMap } from '@nguniversal/module-map-ngfactory-loader';
@ -37,7 +37,7 @@ import { provideModuleMap } from '@nguniversal/module-map-ngfactory-loader';
// }));
// be able to get request and get domain from there
app.engine('html', (_, options, callback) => {
app.engine('html', (_, options: RenderOptions, callback) => {
let engine = ngExpressEngine({
bootstrap: AppServerModuleNgFactory,
providers: [

View File

@ -1,7 +1,7 @@
import {NgModule} from '@angular/core';
import {FormsModule} from '@angular/forms';
import {CommonModule} from '@angular/common';
import {HttpModule} from '@angular/http';
import {HttpClientModule} from "@angular/common/http";
import {BrowserModule} from '@angular/platform-browser';
import {NoopAnimationsModule} from '@angular/platform-browser/animations';
@ -29,7 +29,7 @@ import {SubscribeModule} from './utils/subscribe/subscribe.module';
SharedModule,
NoopAnimationsModule,
CommonModule,
HttpModule,
HttpClientModule,
ErrorModule,
CKEditorModule,
FormsModule,

View File

@ -1,5 +1,5 @@
import {Injectable, Inject} from '@angular/core';
import {Http, Response} from '@angular/http';
import {HttpClient} from "@angular/common/http";
import {Observable} from 'rxjs/Observable';
import 'rxjs/add/observable/of';
import 'rxjs/add/operator/do';
@ -8,15 +8,15 @@ import{EnvProperties} from '../openaireLibrary/utils/properties/env-properties';
@Injectable()
export class HtmlPageService {
constructor(private http: Http) {}
constructor(private http: HttpClient) {}
getHtmlContent (router: string, properties:EnvProperties, communityId:string ):any {
//console.info("get router html content for : "+router);
let url = properties.adminToolsAPIURL + '/htmlpagecontent?community='+communityId+'&page='+router;
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
.map(res => <Array<any>> res.json());
return this.http.get<Array<any>>((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url);
//.map(res => <Array<any>> res.json());
}

View File

@ -1,29 +1,36 @@
import { Injectable } from '@angular/core';
import { Http, Response, Headers, RequestOptions } from '@angular/http';
import {HttpClient} from "@angular/common/http";
import { Observable } from 'rxjs/Rx';
import { ResultInfo } from '../openaireLibrary/connect/results/resultInfo';
import { CommunityInfo } from '../openaireLibrary/connect/community/communityInfo';
import {map} from "rxjs/operators";
@Injectable()
export class SearchEntriesService {
private sizeOfDescription: number = 135;
constructor(private http:Http) {
constructor(private http:HttpClient) {
}
getTotal(url: string) {
return this.http.get(url).map(res => <any> res.json()).map(res => res.total);
return this.http.get(url)
//.map(res => <any> res.json())
.pipe(map(res => res['total']));
//.do(res => {console.log(res)});
}
countTotal(url:string) {
return this.http.get(url).map(res => <any> res.json()).map(res => res.length);
return this.http.get(url)
//.map(res => <any> res.json())
.pipe(map(res => res['length']));
}
getResults(url: string) {
return this.http.get(url).map(res => <any> res.json()).map(res => this.parseResults(res['results']));
return this.http.get(url)
//.map(res => <any> res.json())
.pipe(map(res => this.parseResults(res['results'])));
}
parseResults(data: any): ResultInfo[] {

View File

@ -1,36 +1,38 @@
import { Injectable } from '@angular/core';
import { Http, Response, Headers, RequestOptions } from '@angular/http';
import {HttpClient, HttpErrorResponse} from "@angular/common/http";
import { Observable } from 'rxjs/Rx';
import {StatisticsDisplay, StatisticsSummary} from "../../openaireLibrary/connect/statistics/statisticsEntities";
import {catchError, map} from "rxjs/operators";
import {throwError} from "rxjs";
@Injectable()
export class StatisticsService {
constructor(private http:Http) { }
constructor(private http:HttpClient) { }
getCommunityStatistics(apiUrl: string, communityId: string): Observable<StatisticsSummary> {
let url = `${apiUrl}communities/${communityId}`;
//console.log(`getting statistics summary from: ${url}`);
return this.http.get(url)
.map(res => <any>res.json())
.map(res => res.statistics)
return this.http.get<any>(url)
//.map(res => <any>res.json())
.pipe(map(res => res['statistics']));
}
getCommunityAdminStatisticsChoices(apiUrl: string, communityId: string): Observable<StatisticsDisplay> {
let url = `${apiUrl}/statistics/${communityId}`;
//console.log(`getting admin choices for statistics from: ${url}`);
return this.http.get(url)
.map(stats => <StatisticsDisplay>stats.json())
.catch(this.handleError);
return this.http.get<StatisticsDisplay>(url)
//.map(stats => <StatisticsDisplay>stats.json())
.pipe(catchError(this.handleError));
}
private handleError (error: Response) {
private handleError (error: HttpErrorResponse) {
// in a real world app, we may send the error to some remote logging infrastructure
// instead of just logging it to the console
console.log(error);
return Observable.throw(error || 'Server error');
return throwError(error || 'Server error');
}
}

View File

@ -39,7 +39,6 @@ import 'core-js/es6/set';
/** Evergreen browsers require these. **/
import 'core-js/es6/reflect';
import 'core-js/es7/reflect';
/**

View File

@ -1 +1,2 @@
/* You can add global styles to this file, and also import other style files */
@import '~@angular/material/prebuilt-themes/indigo-pink.css';

View File

@ -1,6 +1,7 @@
{
"compileOnSave": false,
"compilerOptions": {
"importHelpers": true,
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
@ -14,6 +15,8 @@
"lib": [
"es2017",
"dom"
]
],
"module": "es2015",
"baseUrl": "./"
}
}
}

View File

@ -4,6 +4,7 @@ const path = require('path');
const webpack = require('webpack');
module.exports = {
//mode: 'none',
entry: {
// This is our Express server for Dynamic universal
server: './server.ts',
@ -14,6 +15,9 @@ module.exports = {
resolve: { extensions: ['.ts', '.js'] },
// Make sure we include all node_modules etc
externals: [/(node_modules|main\..*\.js)/,],
optimization: {
minimize: false
},
output: {
// Puts the output at the root of the dist folder
path: path.join(__dirname, 'dist'),
@ -22,6 +26,12 @@ module.exports = {
module: {
rules: [
{ test: /\.ts$/, loader: 'ts-loader' }
,{
// Mark files inside `@angular/core` as using SystemJS style dynamic imports.
// Removing this will cause deprecation warnings to appear.
test: /(\\|\/)@angular(\\|\/)core(\\|\/).+\.js$/,
parser: { system: true },
},
]
},
plugins: [
@ -39,4 +49,3 @@ module.exports = {
)
]
}