[Explore|Trunk]

Merge into trunk branch angular7 rev 55729



git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-portal/trunk@55965 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
argiro.kokogiannaki 2019-06-03 13:21:49 +00:00
parent e4c3b01e00
commit 247ef9dccd
20 changed files with 677 additions and 268 deletions

View File

@ -1,128 +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",
{"glob": "sitemap.xml", "input": "./sitemaps", "output": "./"},
{"glob": "sitemap.xml", "input": "./sitemaps", "output": "./assets"},
{ "glob": "**/*", "input": "./sitemaps/publication", "output": "./" },
{ "glob": "**/*", "input": "./sitemaps/dataset", "output": "./" },
{ "glob": "**/*", "input": "./sitemaps/software", "output": "./" },
{ "glob": "**/*", "input": "./sitemaps/other", "output": "./" },
{ "glob": "**/*", "input": "./sitemaps/project", "output": "./" },
{ "glob": "**/*", "input": "./sitemaps/organization", "output": "./" },
{ "glob": "**/*", "input": "./sitemaps/dataprovider", "output": "./" }
],
"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",
{"glob": "sitemap.xml", "input": "./sitemaps", "output": "./"},
{"glob": "sitemap.xml", "input": "./sitemaps", "output": "./assets"},
{ "glob": "**/*", "input": "./sitemaps/publication", "output": "./" },
{ "glob": "**/*", "input": "./sitemaps/dataset", "output": "./" },
{ "glob": "**/*", "input": "./sitemaps/software", "output": "./" },
{ "glob": "**/*", "input": "./sitemaps/other", "output": "./" },
{ "glob": "**/*", "input": "./sitemaps/project", "output": "./" },
{ "glob": "**/*", "input": "./sitemaps/organization", "output": "./" },
{ "glob": "**/*", "input": "./sitemaps/dataprovider", "output": "./" }
],
"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
}
}
}

267
explore/angular.json Normal file
View File

@ -0,0 +1,267 @@
{
"$schema": "./node_modules/@angular-devkit/core/src/workspace/workspace-schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
"openaire-search": {
"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",
{
"glob": "sitemap.xml",
"input": "src/sitemaps",
"output": "/"
},
{
"glob": "sitemap.xml",
"input": "src/sitemaps",
"output": "/assets"
},
{
"glob": "**/*",
"input": "src/sitemaps/publication",
"output": "/"
},
{
"glob": "**/*",
"input": "src/sitemaps/dataset",
"output": "/"
},
{
"glob": "**/*",
"input": "src/sitemaps/software",
"output": "/"
},
{
"glob": "**/*",
"input": "src/sitemaps/other",
"output": "/"
},
{
"glob": "**/*",
"input": "src/sitemaps/project",
"output": "/"
},
{
"glob": "**/*",
"input": "src/sitemaps/organization",
"output": "/"
},
{
"glob": "**/*",
"input": "src/sitemaps/dataprovider",
"output": "/"
}
],
"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": "openaire-search:build"
},
"configurations": {
"production": {
"browserTarget": "openaire-search:build:production"
}
}
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "openaire-search: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",
{
"glob": "sitemap.xml",
"input": "src/sitemaps",
"output": "/"
},
{
"glob": "sitemap.xml",
"input": "src/sitemaps",
"output": "/assets"
},
{
"glob": "**/*",
"input": "src/sitemaps/publication",
"output": "/"
},
{
"glob": "**/*",
"input": "src/sitemaps/dataset",
"output": "/"
},
{
"glob": "**/*",
"input": "src/sitemaps/software",
"output": "/"
},
{
"glob": "**/*",
"input": "src/sitemaps/other",
"output": "/"
},
{
"glob": "**/*",
"input": "src/sitemaps/project",
"output": "/"
},
{
"glob": "**/*",
"input": "src/sitemaps/organization",
"output": "/"
},
{
"glob": "**/*",
"input": "src/sitemaps/dataprovider",
"output": "/"
}
]
}
},
"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"
}
]
}
}
}
}
},
"openaire-search-e2e": {
"root": "e2e",
"sourceRoot": "e2e",
"projectType": "application",
"architect": {
"e2e": {
"builder": "@angular-devkit/build-angular:protractor",
"options": {
"protractorConfig": "./protractor.conf.js",
"devServerTarget": "openaire-search:serve"
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": [
"e2e/tsconfig.e2e.json"
],
"exclude": [
"**/node_modules/**"
]
}
}
}
}
},
"defaultProject": "openaire-search",
"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

@ -28,7 +28,7 @@
# pico ../src/robots.txt; # pico ../src/robots.txt;
# rm -rf ../src/assets/common-assets/.svn/; # rm -rf ../src/assets/common-assets/.svn/;
# rm -rf ../src/app/openaireLibrary/.svn/; # rm -rf ../src/app/openaireLibrary/.svn/;
# cd ..; npm run build:dynamic; cd deploy; # cd ..; npm run build:ssr; cd deploy;
# rm -rf ../src ../node_modules ../.idea/ ../installOpenaireLib.sh; # rm -rf ../src ../node_modules ../.idea/ ../installOpenaireLib.sh;
# cd ..; rm -rf deploy; # cd ..; rm -rf deploy;
# echo 'Now copy to the server!' # echo 'Now copy to the server!'

View File

@ -9,55 +9,63 @@
"scripts": { "scripts": {
"ng": "ng", "ng": "ng",
"start": "ng serve --disable-host-check --host 0.0.0.0 --port 4300", "start": "ng serve --disable-host-check --host 0.0.0.0 --port 4300",
"start:dynamic": "npm run build:dynamic && npm run serve:dynamic", "start:ssr": "npm run build:ssr && npm run serve:ssr",
"start:static": "npm run build:static && npm run serve:static", "start:prerender": "npm run build:prerender && npm run serve:prerender",
"build": "ng build", "build": "ng build",
"build:client-and-server-bundles": "ng build --prod -sm --stats-json && ng build --prod --app 1 --output-hashing=false", "build:client-and-server-bundles": "ng build --prod --sourceMap --stats-json=true && ng run openaire-search:server:production",
"build:static": "npm run build:client-and-server-bundles && npm run webpack:server && npm run generate:static", "build:prerender": "npm run build:client-and-server-bundles && npm run webpack:server && npm run generate:prerender",
"build:dynamic": "npm run build:client-and-server-bundles && npm run webpack:server", "build:ssr": "npm run build:client-and-server-bundles && npm run webpack:server",
"generate:static": "cd dist && node prerender", "generate:prerender": "cd dist && node prerender",
"webpack:server": "webpack --config webpack.server.config.js --progress --colors", "webpack:server": "webpack --config webpack.server.config.js --progress --colors",
"serve:static": "cd dist/browser && http-server", "serve:prerender": "cd dist/browser && http-server",
"serve:dynamic": "node dist/server" "serve:ssr": "node dist/server"
}, },
"private": true, "private": true,
"dependencies": { "dependencies": {
"@angular/animations": "^4.2.4", "@angular/animations": "^7.2.14",
"@angular/common": "^4.2.4", "@angular/cdk": "^7.3.7",
"@angular/compiler": "^4.2.4", "@angular/common": "7.2.14",
"@angular/core": "^4.2.4", "@angular/compiler": "7.2.14",
"@angular/forms": "^4.2.4", "@angular/core": "7.2.14",
"@angular/http": "^4.2.4", "@angular/forms": "7.2.14",
"@angular/platform-browser": "^4.2.4", "@angular/http": "7.2.14",
"@angular/platform-browser-dynamic": "^4.2.4", "@angular/material": "^7.3.7",
"@angular/platform-server": "^4.2.4", "@angular/platform-browser": "7.2.14",
"@angular/router": "^4.2.4", "@angular/platform-browser-dynamic": "7.2.14",
"@nguniversal/express-engine": "^1.0.0-beta.3", "@angular/platform-server": "7.2.14",
"@nguniversal/module-map-ngfactory-loader": "^1.0.0-beta.3", "@angular/router": "7.2.14",
"angular-datatables": "^4.4.0", "@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", "citation-js": "^0.3.4",
"clipboard": "^1.5.16", "clipboard": "^1.5.16",
"core-js": "^2.4.1", "core-js": "^2.4.1",
"datatables.net": "^1.10.16", "datatables.net": "^1.10.19",
"datatables.net-dt": "^1.10.16", "datatables.net-dt": "^1.10.19",
"jquery": "^3.2.1", "jquery": "^3.4.1",
"ngx-json-ld": "0.1.6", "ngx-json-ld": "0.1.6",
"rxjs": "^5.4.2", "prom-client": "^11.3.0",
"ts-md5": "^1.2.0", "ts-md5": "^1.2.0",
"tslib": "^1.9.0",
"wikidata-sdk": "^5.2.9", "wikidata-sdk": "^5.2.9",
"zone.js": "^0.8.14" "zone.js": "^0.8.26"
}, },
"devDependencies": { "devDependencies": {
"@angular/cli": "^1.3.0", "@angular-devkit/build-angular": "~0.13.0",
"@angular/compiler-cli": "^4.2.4", "@angular/cli": "^7.3.9",
"@angular/language-service": "^4.2.4", "@angular/compiler-cli": "7.2.14",
"@types/datatables.net": "^1.10.8", "@angular/language-service": "7.2.14",
"@types/jquery": "^3.2.17", "@types/datatables.net": "^1.10.17",
"@types/jquery": "^3.3.29",
"@types/node": "^8.0.30", "@types/node": "^8.0.30",
"cpy-cli": "^1.0.1", "cpy-cli": "^1.0.1",
"http-server": "^0.10.0", "http-server": "^0.10.0",
"reflect-metadata": "^0.1.10", "reflect-metadata": "^0.1.10",
"ts-loader": "^2.3.7", "rxjs": "6.5.1",
"typescript": "~2.3.3" "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'; import { ROUTES } from './static.paths';
// * NOTE :: leave this as require() since this file is built Dynamically from webpack // * 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'); const BROWSER_FOLDER = join(process.cwd(), 'browser');
@ -27,7 +27,7 @@ let previousRender = Promise.resolve();
// Iterate each route path // Iterate each route path
ROUTES.forEach(route => { ROUTES.forEach(route => {
var fullPath = join(BROWSER_FOLDER, route); const fullPath = join(BROWSER_FOLDER, route);
// Make sure the directory structure is there // Make sure the directory structure is there
if(!existsSync(fullPath)){ if(!existsSync(fullPath)){

200
explore/prometheus.ts Normal file
View File

@ -0,0 +1,200 @@
import * as prom from 'prom-client';
export class Prometheus {
register = new prom.Registry();
counters: Map<string, prom.Counter> = new Map<string, prom.Counter>([
["/", new prom.Counter({
name: 'home',
help: 'Home Page Counter',
registers: [this.register]
})],
["/search/publication", new prom.Counter({
name: 'search_publication',
help: 'Publication Landing Page Counter',
registers: [this.register]
})],
["/search/dataset", new prom.Counter({
name: 'search_dataset',
help: 'Dataset Landing Page Counter',
registers: [this.register]
})],
["/search/software", new prom.Counter({
name: 'search_software',
help: 'Software Landing Page Counter',
registers: [this.register]
})],
["/search/other", new prom.Counter({
name: 'search_other',
help: 'Other Landing Page Counter',
registers: [this.register]
})],
["/search/project", new prom.Counter({
name: 'search_project',
help: 'Project Landing Page Counter',
registers: [this.register]
})],
["/search/dataprovider", new prom.Counter({
name: 'search_dataprovider',
help: 'DataProvider Landing Page Counter',
registers: [this.register]
})],
["/search/organization", new prom.Counter({
name: 'search_organization',
help: 'organization Landing Page Counter',
registers: [this.register]
})],
["/participate/deposit-datasets", new prom.Counter({
name: 'participate_deposit_datasets',
help: 'Participate Deposit Datasets Page Counter',
registers: [this.register]
})],
["/participate/deposit-datasets-result", new prom.Counter({
name: 'participate_deposit_datasets_result',
help: 'Participate Deposit Datasets Result Page Counter',
registers: [this.register]
})],
["/participate/deposit-subject-result", new prom.Counter({
name: 'participate_deposit_subject_result',
help: 'Participate Deposit Subject Result Page Counter',
registers: [this.register]
})],
["/participate/deposit-publications", new prom.Counter({
name: 'participate_deposit_publications',
help: 'Participate Deposit Publications Page Counter',
registers: [this.register]
})],
["/participate/deposit-publications-result", new prom.Counter({
name: 'participate_deposit_publications_result',
help: 'Participate Deposit Publications Result Page Counter',
registers: [this.register]
})],
["/search/find", new prom.Counter({
name: 'search_find',
help: 'Main Search Page Counter',
registers: [this.register]
})],
["/search/find/publications", new prom.Counter({
name: 'search_find_publications',
help: 'Publications Search Page Counter',
registers: [this.register]
})],
["/search/find/datasets", new prom.Counter({
name: 'search_find_datasets',
help: 'Datasets Search Page Counter',
registers: [this.register]
})],
["/search/find/software", new prom.Counter({
name: 'search_find_software',
help: 'Software Search Page Counter',
registers: [this.register]
})],
["/search/find/other", new prom.Counter({
name: 'search_find_other',
help: 'Other Search Page Counter',
registers: [this.register]
})],
["/search/find/projects", new prom.Counter({
name: 'search_find_projects',
help: 'Projects Search Page Counter',
registers: [this.register]
})],
["/search/find/dataproviders", new prom.Counter({
name: 'search_find_dataproviders',
help: 'DataProviders Search Page Counter',
registers: [this.register]
})],
["/search/find/organizations", new prom.Counter({
name: 'search_find_organizations',
help: 'Organizations Search Page Counter',
registers: [this.register]
})],
["/search/content-providers", new prom.Counter({
name: 'search_content_providers',
help: 'Repositories Search Page Counter',
registers: [this.register]
})],
["/search/content-providers-table", new prom.Counter({
name: 'search_content_providers_table',
help: 'Repositories Search Page Table Counter',
registers: [this.register]
})],
["/search/entity-registries", new prom.Counter({
name: 'search_entity_registries',
help: 'Registries Search Page Counter',
registers: [this.register]
})],
["/search/entity-registries-table", new prom.Counter({
name: 'search_entity_registries_table',
help: 'Registries Search Page Table Counter',
registers: [this.register]
})],
["/search/journals", new prom.Counter({
name: 'search_journals',
help: 'Journals Search Page Counter',
registers: [this.register]
})],
["/search/journals-table", new prom.Counter({
name: 'search_journals_table',
help: 'Journals Search Page Table Counter',
registers: [this.register]
})],
["/search/advanced/publications", new prom.Counter({
name: 'search_advanced_publications',
help: 'Publications Advanced Search Page Counter',
registers: [this.register]
})],
["/search/advanced/datasets", new prom.Counter({
name: 'search_advanced_datasets',
help: 'Datasets Advanced Search Page Counter',
registers: [this.register]
})],
["/search/advanced/software", new prom.Counter({
name: 'search_advanced_software',
help: 'Software Advanced Search Page Counter',
registers: [this.register]
})],
["/search/advanced/other", new prom.Counter({
name: 'search_advanced_other',
help: 'Other Advanced Search Page Counter',
registers: [this.register]
})],
["/search/advanced/projects", new prom.Counter({
name: 'search_advanced_projects',
help: 'Projects Advanced Search Page Counter',
registers: [this.register]
})],
["/search/advanced/dataproviders", new prom.Counter({
name: 'search_advanced_dataproviders',
help: 'DataProviders Advanced Search Page Counter',
registers: [this.register]
})],
["/search/advanced/organizations", new prom.Counter({
name: 'search_advanced_organizations',
help: 'Organizations Advanced Search Page Counter',
registers: [this.register]
})],
["/myclaims", new prom.Counter({
name: 'my_claims',
help: 'My Claims Page Counter',
registers: [this.register]
})],
["/claims", new prom.Counter({
name: 'claims',
help: 'Admin Claims Page Counter',
registers: [this.register]
})],
["/participate/claim", new prom.Counter({
name: 'participate_claim',
help: 'Linking Page Counter',
registers: [this.register]
})],
["/participate/direct-claim", new prom.Counter({
name: 'participate_direct_claim',
help: 'Direct Linking Page Counter',
registers: [this.register]
})]
]);
}

View File

@ -20,22 +20,29 @@ const DIST_FOLDER = join(process.cwd(), 'dist');
const template = readFileSync(join(DIST_FOLDER, 'browser', 'index.html')).toString(); const template = readFileSync(join(DIST_FOLDER, 'browser', 'index.html')).toString();
// * NOTE :: leave this as require() since this file is built Dynamically from webpack // * 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 // Express Engine
import { ngExpressEngine } from '@nguniversal/express-engine'; import {ngExpressEngine, RenderOptions} from '@nguniversal/express-engine';
// Import module map for lazy loading // Import module map for lazy loading
import { provideModuleMap } from '@nguniversal/module-map-ngfactory-loader'; import { provideModuleMap } from '@nguniversal/module-map-ngfactory-loader';
import {Prometheus} from "./prometheus";
import {Counter} from "prom-client";
/*
// Our Universal express-engine (found @ https://github.com/angular/universal/tree/master/modules/express-engine) // Our Universal express-engine (found @ https://github.com/angular/universal/tree/master/modules/express-engine)
// app.engine('html', ngExpressEngine({ app.engine('html', ngExpressEngine({
// bootstrap: AppServerModuleNgFactory, bootstrap: AppServerModuleNgFactory,
// providers: [ providers: [
// provideModuleMap(LAZY_MODULE_MAP) provideModuleMap(LAZY_MODULE_MAP)
// ] ]
// })); }));
*/
// be able to get request and get domain from there // be able to get request and get domain from there
app.engine('html', (_, options, callback) => {
const prometheus: Prometheus = new Prometheus();
app.engine('html', (_, options:RenderOptions, callback) => {
let engine = ngExpressEngine({ let engine = ngExpressEngine({
bootstrap: AppServerModuleNgFactory, bootstrap: AppServerModuleNgFactory,
providers: [ providers: [
@ -58,9 +65,25 @@ app.get('*.*', express.static(join(DIST_FOLDER, 'browser'), {
maxAge: '1y' maxAge: '1y'
})); }));
// ALl regular routes use the Universal engine app.get('/metrics', (req, res) => {
res.set('Content-Type', prometheus.register.contentType);
res.end(prometheus.register.metrics());
});
// All regular routes use the Universal engine
app.get('*', (req, res) => { app.get('*', (req, res) => {
res.render('index', { req }); let start = new Date();
let counter: Counter = prometheus.counters.get(req.path);
if(counter !== undefined) {
counter.inc(1, new Date());
res.render('index', { req });
// event triggers when express is done sending response
res.on('finish', function() {
// console.log(new Date().getTime() - start.getTime());
});
} else {
res.render('index', { req });
}
}); });
// Start up the Node server // Start up the Node server

View File

@ -1,12 +1,13 @@
import { Component, Directive, ElementRef, Renderer, ChangeDetectionStrategy, ViewEncapsulation } from '@angular/core'; import {Component, Directive, ElementRef, Renderer2, ChangeDetectionStrategy, ViewEncapsulation} from '@angular/core';
import {Observable} from 'rxjs/Observable'; import {Observable} from 'rxjs';
import {ActivatedRoute} from '@angular/router'; import {ActivatedRoute, NavigationStart, Router} from '@angular/router';
import { EnvProperties} from './openaireLibrary/utils/properties/env-properties'; import {EnvProperties} from './openaireLibrary/utils/properties/env-properties';
import{MenuItem, RootMenuItem} from './openaireLibrary/sharedComponents/menu'; import {MenuItem, RootMenuItem} from './openaireLibrary/sharedComponents/menu';
import { EnvironmentSpecificService} from './openaireLibrary/utils/properties/environment-specific.service'; import {EnvironmentSpecificService} from './openaireLibrary/utils/properties/environment-specific.service';
import {Session} from './openaireLibrary/login/utils/helper.class'; import {Session} from './openaireLibrary/login/utils/helper.class';
import {HelperFunctions} from "./openaireLibrary/utils/HelperFunctions.class";
@Component({ @Component({
//changeDetection: ChangeDetectionStrategy.Default, //changeDetection: ChangeDetectionStrategy.Default,
@ -16,99 +17,112 @@ import {Session} from './openaireLibrary/login/utils/helper.class';
`], `],
template: ` template: `
<navbar *ngIf= "properties" portal="explore" [environment]=properties.environment [onlyTop]=false [(communityId)]="properties.adminToolsCommunity" [userMenuItems]=userMenuItems [menuItems]=menuItems <navbar *ngIf="properties" portal="explore" [environment]=properties.environment [onlyTop]=false
[(APIUrl)]="properties.adminToolsAPIURL" [(logInUrl)]="properties.loginUrl" [(logOutUrl)]="properties.logoutUrl" [(cookieDomain)]="properties.cookieDomain"></navbar> [(communityId)]="properties.adminToolsCommunity" [userMenuItems]=userMenuItems [menuItems]=menuItems
<div class="custom-main-content" > [(APIUrl)]="properties.adminToolsAPIURL" [(logInUrl)]="properties.loginUrl"
<main> [(logOutUrl)]="properties.logoutUrl" [(cookieDomain)]="properties.cookieDomain"></navbar>
<router-outlet></router-outlet> <div class="custom-main-content">
</main> <main>
</div> <router-outlet></router-outlet>
<feedback *ngIf= "isClient && properties" portalName="Explore" [feedbackmail]=feedbackmail></feedback> </main>
<cookie-law *ngIf= "isClient" position="bottom"> </div>
OpenAIRE uses cookies in order to function properly.<br> <feedback *ngIf="isClient && properties" portalName="Explore" [feedbackmail]=feedbackmail></feedback>
Cookies are small pieces of data that websites store in your browser to allow us to give you the best browsing experience possible. <cookie-law *ngIf="isClient" position="bottom">
By using the OpenAIRE portal you accept our use of cookies. <a href="//ec.europa.eu/ipg/basics/legal/cookies/index_en.htm" target="_blank"> Read more <span class="uk-icon"> OpenAIRE uses cookies in order to function properly.<br>
<svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" icon="chevron-right" ratio="1"><polyline fill="none" stroke="#000" stroke-width="1.03" points="7 4 13 10 7 16"></polyline></svg> Cookies are small pieces of data that websites store in your browser to allow us to give you the best browsing
experience possible.
By using the OpenAIRE portal you accept our use of cookies. <a
href="//ec.europa.eu/ipg/basics/legal/cookies/index_en.htm" target="_blank"> Read more <span class="uk-icon">
<svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" icon="chevron-right"
ratio="1"><polyline fill="none" stroke="#000" stroke-width="1.03" points="7 4 13 10 7 16"></polyline></svg>
</span></a> </span></a>
</cookie-law> </cookie-law>
<bottom *ngIf= "isClient && properties" [environment]=properties.environment></bottom> <bottom *ngIf="isClient && properties" [environment]=properties.environment></bottom>
` `
}) })
export class AppComponent { export class AppComponent {
isClient:boolean = false; isClient: boolean = false;
clientLoad = 0; clientLoad = 0;
userMenuItems:MenuItem[] = [ new MenuItem("","My profile","","",false,[],[],{}), userMenuItems: MenuItem[] = [new MenuItem("", "My profile", "", "", false, [], [], {}),
new MenuItem("","My links","","/myclaims",false,[],["/myclaims"],{})] new MenuItem("", "My links", "", "/myclaims", false, [], ["/myclaims"], {})]
menuItems:RootMenuItem [] = [ menuItems: RootMenuItem [] = [
{rootItem: new MenuItem("search","Search","","/search/find",false,[],["/search/find"],{}),
items: [new MenuItem("","Publications","","/search/find/publications",false,["publication"],["/search/find/publications"],{}),
new MenuItem("","Research Data","","/search/find/datasets",false,["dataset"],["/search/find/datasets"],{}),
new MenuItem("","Software","","/search/find/software",false,["software"],["/search/find/software"],{}),
new MenuItem("","Other Research Products","","/search/find/other",false,["orp"],["/search/find/other"],{}),
new MenuItem("","Projects","","/search/find/projects/",false,["project"],["/search/find/projects"],{}),
new MenuItem("","Content Providers","","/search/find/dataproviders",false,["datasource"],["/search/find/dataproviders"],{}),
new MenuItem("","Organizations","","/search/find/organizations/",false,["organization"],["/search/find/organizations"],{})
]},
{ {
rootItem: new MenuItem("share","Share","","",false,[],["/participate/deposit-publications","/participate/deposit-datasets"],{}), rootItem: new MenuItem("search", "Search", "", "/search/find", false, [], ["/search/find"], {}),
items: [new MenuItem("","Publications","","/participate/deposit-publications",false,["publication"],["/participate/deposit-publications"],{}), items: [new MenuItem("", "Publications", "", "/search/find/publications", false, ["publication"], ["/search/find/publications"], {}),
new MenuItem("","Research Data","","/participate/deposit-datasets",false,["dataset"],["/participate/deposit-datasets"],{})] new MenuItem("", "Research Data", "", "/search/find/datasets", false, ["dataset"], ["/search/find/datasets"], {}),
new MenuItem("", "Software", "", "/search/find/software", false, ["software"], ["/search/find/software"], {}),
new MenuItem("", "Other Research Products", "", "/search/find/other", false, ["orp"], ["/search/find/other"], {}),
new MenuItem("", "Projects", "", "/search/find/projects/", false, ["project"], ["/search/find/projects"], {}),
new MenuItem("", "Content Providers", "", "/search/find/dataproviders", false, ["datasource"], ["/search/find/dataproviders"], {}),
new MenuItem("", "Organizations", "", "/search/find/organizations/", false, ["organization"], ["/search/find/organizations"], {})
]
}, },
{ {
rootItem: new MenuItem("link","Link","","/participate/claim",false,[],["/participate/claim"],{}), rootItem: new MenuItem("share", "Share", "", "", false, [], ["/participate/deposit-publications", "/participate/deposit-datasets"], {}),
items: [] items: [new MenuItem("", "Publications", "", "/participate/deposit-publications", false, ["publication"], ["/participate/deposit-publications"], {}),
new MenuItem("", "Research Data", "", "/participate/deposit-datasets", false, ["dataset"], ["/participate/deposit-datasets"], {})]
}, },
{ {
rootItem: new MenuItem("datasources","Content Providers","","",false,["datasource"],[],{}), rootItem: new MenuItem("link", "Link", "", "/participate/claim", false, [], ["/participate/claim"], {}),
items: [new MenuItem("","Data Policies","https://beta.openaire.eu/oa-policies-mandates","",false,["datasource"],[""],{}), items: []
new MenuItem("","Repositories","","/search/content-providers",false,["datasource"],["/search/content-providers"],{}), },
new MenuItem("","Journals","","/search/journals",false,["datasource"],["/search/journals"],{}), {
new MenuItem("","Registries","","/search/entity-registries",false,["datasource"],["/search/entity-registries"],{}), rootItem: new MenuItem("datasources", "Content Providers", "", "", false, ["datasource"], [], {}),
new MenuItem("","Browse all","","/search/find/dataproviders",false,["datasource"],["/search/find/dataproviders"],{})] items: [new MenuItem("", "Data Policies", "https://beta.openaire.eu/oa-policies-mandates", "", false, ["datasource"], [""], {}),
new MenuItem("", "Repositories", "", "/search/content-providers", false, ["datasource"], ["/search/content-providers"], {}),
new MenuItem("", "Journals", "", "/search/journals", false, ["datasource"], ["/search/journals"], {}),
new MenuItem("", "Registries", "", "/search/entity-registries", false, ["datasource"], ["/search/entity-registries"], {}),
new MenuItem("", "Browse all", "", "/search/find/dataproviders", false, ["datasource"], ["/search/find/dataproviders"], {})]
} }
]; ];
feedbackmail: string
properties: EnvProperties;
feedbackmail:string constructor(private route: ActivatedRoute, private propertiesService: EnvironmentSpecificService,
properties:EnvProperties; private router: Router) {
constructor( private route: ActivatedRoute, private propertiesService:EnvironmentSpecificService) { router.events.forEach((event) => {
} if (event instanceof NavigationStart) {
HelperFunctions.scroll();
}
});
}
ngOnInit() { ngOnInit() {
if (typeof document !== 'undefined') { if (typeof document !== 'undefined') {
try{ try {
this.isClient = true; this.isClient = true;
}catch (e) { } catch (e) {
} }
} }
this.propertiesService.loadEnvironment() this.propertiesService.loadEnvironment()
.then(es => { .then(es => {
this.propertiesService.setEnvProperties(es); this.propertiesService.setEnvProperties(es);
this.properties = this.propertiesService.envSpecific; this.properties = this.propertiesService.envSpecific;
this.feedbackmail = this.properties.feedbackmail; this.feedbackmail = this.properties.feedbackmail;
if(Session.isPortalAdministrator()){ if (Session.isPortalAdministrator()) {
this.userMenuItems.push(new MenuItem("","Manage all links","","/claims",false,[],["/claims"],{})); this.userMenuItems.push(new MenuItem("", "Manage all links", "", "/claims", false, [], ["/claims"], {}));
this.userMenuItems.push(new MenuItem("","Manage helptexts", this.userMenuItems.push(new MenuItem("", "Manage helptexts",
((this.properties.environment == "beta")?"https://beta.admin.connect.openaire.eu":"https://admin.explore.openaire.eu")+"/dashboard?communityId=openaire","",true,[],[],{})) ((this.properties.environment == "beta") ? "https://beta.admin.connect.openaire.eu" : "https://admin.explore.openaire.eu") + "/dashboard?communityId=openaire", "", true, [], [], {}))
}else if(Session.isClaimsCurator()){ } else if (Session.isClaimsCurator()) {
this.userMenuItems.push(new MenuItem("","Manage all links","","/claims",false,[],["/claims"],{})); this.userMenuItems.push(new MenuItem("", "Manage all links", "", "/claims", false, [], ["/claims"], {}));
} }
//console.log(this.properties.loginUrl); //console.log(this.properties.loginUrl);
}, error => { }, error => {
console.log("App couldn't fetch properties"); console.log("App couldn't fetch properties");
console.log(error); console.log(error);
}); });
} }
} }

View File

@ -4,7 +4,7 @@ import { SharedModule } from './shared/shared.module';
import { BrowserModule } from '@angular/platform-browser'; import { BrowserModule } from '@angular/platform-browser';
import { NoopAnimationsModule } from '@angular/platform-browser/animations'; import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { APP_BASE_HREF, CommonModule } from '@angular/common'; import { APP_BASE_HREF, CommonModule } from '@angular/common';
import { HttpModule } from '@angular/http'; import { HttpClientModule } from '@angular/common/http';
import { RouterModule } from '@angular/router'; import { RouterModule } from '@angular/router';
import { AppComponent } from './app.component'; import { AppComponent } from './app.component';
@ -15,6 +15,7 @@ import { CookieLawModule } from './openaireLibrary/sharedComponents/cookie-law/c
import {BottomModule} from './openaireLibrary/sharedComponents/bottom.module'; import {BottomModule} from './openaireLibrary/sharedComponents/bottom.module';
import {FeedbackModule} from './openaireLibrary/sharedComponents/feedback/feedback.module'; import {FeedbackModule} from './openaireLibrary/sharedComponents/feedback/feedback.module';
import { EnvironmentSpecificResolver} from './openaireLibrary/utils/properties/environmentSpecificResolver'; import { EnvironmentSpecificResolver} from './openaireLibrary/utils/properties/environmentSpecificResolver';
//import { EnvironmentSpecificService, REQUEST_TOKEN} from './openaireLibrary/utils/properties/environment-specific.service';
import { ErrorModule} from './openaireLibrary/error/error.module'; import { ErrorModule} from './openaireLibrary/error/error.module';
@ -27,7 +28,7 @@ import { AppRoutingModule } from './app-routing.module';
SharedModule, SharedModule,
NoopAnimationsModule, NoopAnimationsModule,
CommonModule, CommonModule,
HttpModule, HttpClientModule,
ErrorModule, ErrorModule,
NavigationBarModule, FeedbackModule, BottomModule, NavigationBarModule, FeedbackModule, BottomModule,
CookieLawModule, CookieLawModule,
@ -36,7 +37,14 @@ NavigationBarModule, FeedbackModule, BottomModule,
], ],
declarations: [ AppComponent, OpenaireErrorPageComponent], declarations: [ AppComponent, OpenaireErrorPageComponent],
exports: [ AppComponent ], exports: [ AppComponent ],
providers:[EnvironmentSpecificResolver ], providers:[
/*{
provide: REQUEST_TOKEN,
useClass: EnvironmentSpecificService
},*/
EnvironmentSpecificResolver
],
bootstrap: [AppComponent] bootstrap: [AppComponent]
}) })
// //

View File

@ -4,6 +4,7 @@ import {ModuleMapLoaderModule} from '@nguniversal/module-map-ngfactory-loader';
import {AppModule} from './app.module'; import {AppModule} from './app.module';
import {AppComponent} from './app.component'; import {AppComponent} from './app.component';
//import {REQUEST} from "@nguniversal/express-engine/tokens";
@NgModule({ @NgModule({
imports: [ imports: [
@ -17,4 +18,6 @@ import {AppComponent} from './app.component';
// imported AppModule, it needs to be repeated here. // imported AppModule, it needs to be repeated here.
bootstrap: [AppComponent], bootstrap: [AppComponent],
}) })
export class AppServerModule {} export class AppServerModule {
/*constructor(@Inject(REQUEST) private request: Request) {}*/
}

View File

@ -1,6 +1,6 @@
import {Component, ViewChild, Input} from '@angular/core'; import {Component, ViewChild, Input} from '@angular/core';
import {Location} from '@angular/common'; import {Location} from '@angular/common';
import {Observable} from 'rxjs/Observable'; import {Observable} from 'rxjs';
import {ActivatedRoute} from '@angular/router'; import {ActivatedRoute} from '@angular/router';
import {EnvProperties} from '../../openaireLibrary/utils/properties/env-properties'; import {EnvProperties} from '../../openaireLibrary/utils/properties/env-properties';

View File

@ -1,5 +1,5 @@
import {Component, Input} from '@angular/core'; import {Component, Input} from '@angular/core';
import {Observable} from 'rxjs/Observable'; import {Observable} from 'rxjs';
import {ActivatedRoute, Router} from '@angular/router'; import {ActivatedRoute, Router} from '@angular/router';
@Component({ @Component({

View File

@ -1,5 +1,5 @@
import {Component, Input} from '@angular/core'; import {Component, Input} from '@angular/core';
import {Observable} from 'rxjs/Observable'; import {Observable} from 'rxjs';
import {ActivatedRoute} from '@angular/router'; import {ActivatedRoute} from '@angular/router';
import {EnvProperties} from '../../openaireLibrary/utils/properties/env-properties'; import {EnvProperties} from '../../openaireLibrary/utils/properties/env-properties';

View File

@ -1,5 +1,5 @@
import {Component, Input} from '@angular/core'; import {Component, Input} from '@angular/core';
import {Observable} from 'rxjs/Observable'; import {Observable} from 'rxjs';
import {ZenodoInformationClass} from '../../openaireLibrary/deposit/utils/zenodoInformation.class'; import {ZenodoInformationClass} from '../../openaireLibrary/deposit/utils/zenodoInformation.class';
@Component({ @Component({

View File

@ -1,5 +1,5 @@
import {Component, Input, Output, EventEmitter, ViewChild, ChangeDetectionStrategy, ViewEncapsulation} from '@angular/core'; import {Component, Input, Output, EventEmitter, ViewChild, ChangeDetectionStrategy, ViewEncapsulation} from '@angular/core';
import {Observable} from 'rxjs/Observable'; import {Observable} from 'rxjs';
import {ActivatedRoute, Router} from '@angular/router'; import {ActivatedRoute, Router} from '@angular/router';
import {Location} from '@angular/common'; import {Location} from '@angular/common';
import "rxjs/add/observable/zip"; import "rxjs/add/observable/zip";
@ -92,9 +92,9 @@ public subPub;public subData;public subProjects;public subOrg; public subDataPr;
this.config.getCommunityInformation(this.properties.adminToolsAPIURL, this.properties.adminToolsCommunity ).subscribe(data => { this.config.getCommunityInformation(this.properties.adminToolsAPIURL, this.properties.adminToolsCommunity ).subscribe(data => {
var showEntity = {}; var showEntity = {};
for(var i=0; i< data.entities.length; i++){ for(var i=0; i< data['entities'].length; i++){
showEntity[""+data.entities[i]["pid"]+""] = data.entities[i]["isEnabled"]; showEntity[""+data['entities'][i]["pid"]+""] = data['entities'][i]["isEnabled"];
} }
this.showPublications = showEntity["publication"]; this.showPublications = showEntity["publication"];
this.showDatasets = showEntity["dataset"]; this.showDatasets = showEntity["dataset"];

View File

@ -1,5 +1,5 @@
import {Component, ElementRef} from '@angular/core'; import {Component, ElementRef} from '@angular/core';
import {Observable} from 'rxjs/Observable'; import {Observable} from 'rxjs';
@Component({ @Component({
selector: 'openaire-user', selector: 'openaire-user',

View File

@ -1,5 +1,5 @@
import {Component, Input} from '@angular/core'; import {Component, Input} from '@angular/core';
import {Observable} from 'rxjs/Observable'; import {Observable} from 'rxjs';
@Component({ @Component({

View File

@ -1 +1,2 @@
/* You can add global styles to this file, and also import other style files */ /* 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, "compileOnSave": false,
"compilerOptions": { "compilerOptions": {
"importHelpers": true,
"outDir": "./dist/out-tsc", "outDir": "./dist/out-tsc",
"sourceMap": true, "sourceMap": true,
"declaration": false, "declaration": false,
@ -14,6 +15,8 @@
"lib": [ "lib": [
"es2017", "es2017",
"dom" "dom"
] ],
"module": "es2015",
"baseUrl": "./"
} }
} }

View File

@ -4,6 +4,7 @@ const path = require('path');
const webpack = require('webpack'); const webpack = require('webpack');
module.exports = { module.exports = {
//mode: 'none',
entry: { entry: {
// This is our Express server for Dynamic universal // This is our Express server for Dynamic universal
server: './server.ts', server: './server.ts',
@ -14,6 +15,9 @@ module.exports = {
resolve: { extensions: ['.ts', '.js'] }, resolve: { extensions: ['.ts', '.js'] },
// Make sure we include all node_modules etc // Make sure we include all node_modules etc
externals: [/(node_modules|main\..*\.js)/,], externals: [/(node_modules|main\..*\.js)/,],
optimization: {
minimize: false
},
output: { output: {
// Puts the output at the root of the dist folder // Puts the output at the root of the dist folder
path: path.join(__dirname, 'dist'), path: path.join(__dirname, 'dist'),
@ -22,6 +26,12 @@ module.exports = {
module: { module: {
rules: [ rules: [
{ test: /\.ts$/, loader: 'ts-loader' } { 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: [ plugins: [
@ -39,4 +49,4 @@ module.exports = {
) )
] ]
} }