diff --git a/explore/.angular-cli.json b/explore/.angular-cli.json deleted file mode 100644 index 74a90a80..00000000 --- a/explore/.angular-cli.json +++ /dev/null @@ -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 - } - } - } diff --git a/explore/angular.json b/explore/angular.json new file mode 100644 index 00000000..2a185866 --- /dev/null +++ b/explore/angular.json @@ -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 + } + } +} diff --git a/explore/deploy/prepareDeploy.sh b/explore/deploy/prepareDeploy.sh index 12e43c28..cfa3ba99 100755 --- a/explore/deploy/prepareDeploy.sh +++ b/explore/deploy/prepareDeploy.sh @@ -28,7 +28,7 @@ # pico ../src/robots.txt; # rm -rf ../src/assets/common-assets/.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; # cd ..; rm -rf deploy; # echo 'Now copy to the server!' diff --git a/explore/package.json b/explore/package.json index df861566..31a7ab54 100644 --- a/explore/package.json +++ b/explore/package.json @@ -9,55 +9,63 @@ "scripts": { "ng": "ng", "start": "ng serve --disable-host-check --host 0.0.0.0 --port 4300", - "start:dynamic": "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 openaire-search: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", + "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" }, "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" } } diff --git a/explore/prerender.ts b/explore/prerender.ts index 5ddb8cd4..c6640067 100644 --- a/explore/prerender.ts +++ b/explore/prerender.ts @@ -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)){ diff --git a/explore/prometheus.ts b/explore/prometheus.ts new file mode 100644 index 00000000..ab95186a --- /dev/null +++ b/explore/prometheus.ts @@ -0,0 +1,200 @@ +import * as prom from 'prom-client'; + + +export class Prometheus { + + register = new prom.Registry(); + + counters: Map = new Map([ + ["/", 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] + })] + ]); +} diff --git a/explore/server.ts b/explore/server.ts index a9d3be7c..90c0739a 100644 --- a/explore/server.ts +++ b/explore/server.ts @@ -20,22 +20,29 @@ 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'; +import {Prometheus} from "./prometheus"; +import {Counter} from "prom-client"; +/* // Our Universal express-engine (found @ https://github.com/angular/universal/tree/master/modules/express-engine) -// app.engine('html', ngExpressEngine({ -// bootstrap: AppServerModuleNgFactory, -// providers: [ -// provideModuleMap(LAZY_MODULE_MAP) -// ] -// })); +app.engine('html', ngExpressEngine({ + bootstrap: AppServerModuleNgFactory, + providers: [ + provideModuleMap(LAZY_MODULE_MAP) + ] +})); +*/ // 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({ bootstrap: AppServerModuleNgFactory, providers: [ @@ -58,9 +65,25 @@ app.get('*.*', express.static(join(DIST_FOLDER, 'browser'), { 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) => { - 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 diff --git a/explore/src/app/app.component.ts b/explore/src/app/app.component.ts index ec6a9ef4..8573394c 100644 --- a/explore/src/app/app.component.ts +++ b/explore/src/app/app.component.ts @@ -1,12 +1,13 @@ -import { Component, Directive, ElementRef, Renderer, ChangeDetectionStrategy, ViewEncapsulation } from '@angular/core'; -import {Observable} from 'rxjs/Observable'; -import {ActivatedRoute} from '@angular/router'; +import {Component, Directive, ElementRef, Renderer2, ChangeDetectionStrategy, ViewEncapsulation} from '@angular/core'; +import {Observable} from 'rxjs'; +import {ActivatedRoute, NavigationStart, Router} from '@angular/router'; -import { EnvProperties} from './openaireLibrary/utils/properties/env-properties'; -import{MenuItem, RootMenuItem} from './openaireLibrary/sharedComponents/menu'; -import { EnvironmentSpecificService} from './openaireLibrary/utils/properties/environment-specific.service'; +import {EnvProperties} from './openaireLibrary/utils/properties/env-properties'; +import {MenuItem, RootMenuItem} from './openaireLibrary/sharedComponents/menu'; +import {EnvironmentSpecificService} from './openaireLibrary/utils/properties/environment-specific.service'; import {Session} from './openaireLibrary/login/utils/helper.class'; +import {HelperFunctions} from "./openaireLibrary/utils/HelperFunctions.class"; @Component({ //changeDetection: ChangeDetectionStrategy.Default, @@ -16,99 +17,112 @@ import {Session} from './openaireLibrary/login/utils/helper.class'; `], template: ` - -
-
- -
-
- - - OpenAIRE uses cookies in order to function properly.
- 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. Read more - + +
+
+ +
+
+ + + OpenAIRE uses cookies in order to function properly.
+ 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.
Read more + -
- + + -` + ` }) export class AppComponent { - isClient:boolean = false; - clientLoad = 0; + isClient: boolean = false; + clientLoad = 0; - userMenuItems:MenuItem[] = [ new MenuItem("","My profile","","",false,[],[],{}), - new MenuItem("","My links","","/myclaims",false,[],["/myclaims"],{})] + userMenuItems: MenuItem[] = [new MenuItem("", "My profile", "", "", false, [], [], {}), + new MenuItem("", "My links", "", "/myclaims", false, [], ["/myclaims"], {})] - 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"],{}) - ]}, + menuItems: RootMenuItem [] = [ { - rootItem: new MenuItem("share","Share","","",false,[],["/participate/deposit-publications","/participate/deposit-datasets"],{}), - 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("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("link","Link","","/participate/claim",false,[],["/participate/claim"],{}), - items: [] + rootItem: new MenuItem("share", "Share", "", "", false, [], ["/participate/deposit-publications", "/participate/deposit-datasets"], {}), + 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"],[],{}), - 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"],{})] + rootItem: new MenuItem("link", "Link", "", "/participate/claim", false, [], ["/participate/claim"], {}), + items: [] + }, + { + rootItem: new MenuItem("datasources", "Content Providers", "", "", false, ["datasource"], [], {}), + 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 - properties:EnvProperties; - constructor( private route: ActivatedRoute, private propertiesService:EnvironmentSpecificService) { - } + constructor(private route: ActivatedRoute, private propertiesService: EnvironmentSpecificService, + private router: Router) { + router.events.forEach((event) => { + if (event instanceof NavigationStart) { + HelperFunctions.scroll(); + } + }); + } - ngOnInit() { + ngOnInit() { - if (typeof document !== 'undefined') { - try{ - this.isClient = true; + if (typeof document !== 'undefined') { + try { + this.isClient = true; - }catch (e) { - } + } catch (e) { + } - } - this.propertiesService.loadEnvironment() - .then(es => { - this.propertiesService.setEnvProperties(es); - this.properties = this.propertiesService.envSpecific; - this.feedbackmail = this.properties.feedbackmail; - if(Session.isPortalAdministrator()){ - this.userMenuItems.push(new MenuItem("","Manage all links","","/claims",false,[],["/claims"],{})); - 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.propertiesService.loadEnvironment() + .then(es => { + this.propertiesService.setEnvProperties(es); + this.properties = this.propertiesService.envSpecific; + this.feedbackmail = this.properties.feedbackmail; + if (Session.isPortalAdministrator()) { + this.userMenuItems.push(new MenuItem("", "Manage all links", "", "/claims", false, [], ["/claims"], {})); + 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, [], [], {})) - }else if(Session.isClaimsCurator()){ - this.userMenuItems.push(new MenuItem("","Manage all links","","/claims",false,[],["/claims"],{})); + } else if (Session.isClaimsCurator()) { + this.userMenuItems.push(new MenuItem("", "Manage all links", "", "/claims", false, [], ["/claims"], {})); - } - //console.log(this.properties.loginUrl); - }, error => { - console.log("App couldn't fetch properties"); - console.log(error); + } + //console.log(this.properties.loginUrl); + }, error => { + console.log("App couldn't fetch properties"); + console.log(error); - }); - } + }); + } } diff --git a/explore/src/app/app.module.ts b/explore/src/app/app.module.ts index 88095938..19417301 100755 --- a/explore/src/app/app.module.ts +++ b/explore/src/app/app.module.ts @@ -4,7 +4,7 @@ import { SharedModule } from './shared/shared.module'; import { BrowserModule } from '@angular/platform-browser'; import { NoopAnimationsModule } from '@angular/platform-browser/animations'; 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 { AppComponent } from './app.component'; @@ -15,6 +15,7 @@ import { CookieLawModule } from './openaireLibrary/sharedComponents/cookie-law/c import {BottomModule} from './openaireLibrary/sharedComponents/bottom.module'; import {FeedbackModule} from './openaireLibrary/sharedComponents/feedback/feedback.module'; 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'; @@ -27,7 +28,7 @@ import { AppRoutingModule } from './app-routing.module'; SharedModule, NoopAnimationsModule, CommonModule, - HttpModule, + HttpClientModule, ErrorModule, NavigationBarModule, FeedbackModule, BottomModule, CookieLawModule, @@ -36,7 +37,14 @@ NavigationBarModule, FeedbackModule, BottomModule, ], declarations: [ AppComponent, OpenaireErrorPageComponent], exports: [ AppComponent ], - providers:[EnvironmentSpecificResolver ], + providers:[ + /*{ + provide: REQUEST_TOKEN, + useClass: EnvironmentSpecificService + },*/ + EnvironmentSpecificResolver + + ], bootstrap: [AppComponent] }) // diff --git a/explore/src/app/app.server.module.ts b/explore/src/app/app.server.module.ts index 79602ec8..ad1dab18 100644 --- a/explore/src/app/app.server.module.ts +++ b/explore/src/app/app.server.module.ts @@ -4,6 +4,7 @@ import {ModuleMapLoaderModule} from '@nguniversal/module-map-ngfactory-loader'; import {AppModule} from './app.module'; import {AppComponent} from './app.component'; +//import {REQUEST} from "@nguniversal/express-engine/tokens"; @NgModule({ imports: [ @@ -17,4 +18,6 @@ import {AppComponent} from './app.component'; // imported AppModule, it needs to be repeated here. bootstrap: [AppComponent], }) -export class AppServerModule {} +export class AppServerModule { + /*constructor(@Inject(REQUEST) private request: Request) {}*/ +} diff --git a/explore/src/app/claims/claimsAdmin/claimsAdmin.component.ts b/explore/src/app/claims/claimsAdmin/claimsAdmin.component.ts index 24d38f2b..8cba18f9 100644 --- a/explore/src/app/claims/claimsAdmin/claimsAdmin.component.ts +++ b/explore/src/app/claims/claimsAdmin/claimsAdmin.component.ts @@ -1,6 +1,6 @@ import {Component, ViewChild, Input} from '@angular/core'; import {Location} from '@angular/common'; -import {Observable} from 'rxjs/Observable'; +import {Observable} from 'rxjs'; import {ActivatedRoute} from '@angular/router'; import {EnvProperties} from '../../openaireLibrary/utils/properties/env-properties'; diff --git a/explore/src/app/claims/linking/linkingGeneric.component.ts b/explore/src/app/claims/linking/linkingGeneric.component.ts index ad2bd592..85226e02 100644 --- a/explore/src/app/claims/linking/linkingGeneric.component.ts +++ b/explore/src/app/claims/linking/linkingGeneric.component.ts @@ -1,5 +1,5 @@ import {Component, Input} from '@angular/core'; -import {Observable} from 'rxjs/Observable'; +import {Observable} from 'rxjs'; import {ActivatedRoute, Router} from '@angular/router'; @Component({ diff --git a/explore/src/app/claims/myClaims/myClaims.component.ts b/explore/src/app/claims/myClaims/myClaims.component.ts index bfbb69e8..ec8f2fde 100644 --- a/explore/src/app/claims/myClaims/myClaims.component.ts +++ b/explore/src/app/claims/myClaims/myClaims.component.ts @@ -1,5 +1,5 @@ import {Component, Input} from '@angular/core'; -import {Observable} from 'rxjs/Observable'; +import {Observable} from 'rxjs'; import {ActivatedRoute} from '@angular/router'; import {EnvProperties} from '../../openaireLibrary/utils/properties/env-properties'; diff --git a/explore/src/app/deposit/datasets/depositBySubjectResult.component.ts b/explore/src/app/deposit/datasets/depositBySubjectResult.component.ts index 419ea55a..873e3af6 100644 --- a/explore/src/app/deposit/datasets/depositBySubjectResult.component.ts +++ b/explore/src/app/deposit/datasets/depositBySubjectResult.component.ts @@ -1,5 +1,5 @@ import {Component, Input} from '@angular/core'; -import {Observable} from 'rxjs/Observable'; +import {Observable} from 'rxjs'; import {ZenodoInformationClass} from '../../openaireLibrary/deposit/utils/zenodoInformation.class'; @Component({ diff --git a/explore/src/app/home/home.component.ts b/explore/src/app/home/home.component.ts index 9de03ff0..a3aff14b 100644 --- a/explore/src/app/home/home.component.ts +++ b/explore/src/app/home/home.component.ts @@ -1,5 +1,5 @@ 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 {Location} from '@angular/common'; 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 => { 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.showDatasets = showEntity["dataset"]; diff --git a/explore/src/app/login/user.component.ts b/explore/src/app/login/user.component.ts index 0b7e1a32..76d70388 100644 --- a/explore/src/app/login/user.component.ts +++ b/explore/src/app/login/user.component.ts @@ -1,5 +1,5 @@ import {Component, ElementRef} from '@angular/core'; -import {Observable} from 'rxjs/Observable'; +import {Observable} from 'rxjs'; @Component({ selector: 'openaire-user', diff --git a/explore/src/app/userEmailPreferences/mailPrefs.component.ts b/explore/src/app/userEmailPreferences/mailPrefs.component.ts index cc533fd9..243303e3 100644 --- a/explore/src/app/userEmailPreferences/mailPrefs.component.ts +++ b/explore/src/app/userEmailPreferences/mailPrefs.component.ts @@ -1,5 +1,5 @@ import {Component, Input} from '@angular/core'; -import {Observable} from 'rxjs/Observable'; +import {Observable} from 'rxjs'; @Component({ diff --git a/explore/src/styles.css b/explore/src/styles.css index 90d4ee00..19273937 100644 --- a/explore/src/styles.css +++ b/explore/src/styles.css @@ -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'; diff --git a/explore/tsconfig.json b/explore/tsconfig.json index a6c016bf..8cd9a30b 100644 --- a/explore/tsconfig.json +++ b/explore/tsconfig.json @@ -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": "./" } -} +} \ No newline at end of file diff --git a/explore/webpack.server.config.js b/explore/webpack.server.config.js index 626690cc..fcfe2b5b 100644 --- a/explore/webpack.server.config.js +++ b/explore/webpack.server.config.js @@ -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,4 @@ module.exports = { ) ] } - \ No newline at end of file +