diff --git a/workingUIKIT/README.md b/workingUIKIT/README.md new file mode 100644 index 00000000..87547810 --- /dev/null +++ b/workingUIKIT/README.md @@ -0,0 +1,150 @@ + +

+ + Universal Angular 2 + +

+ +# Angular 2 Universal Starter [![Universal Angular 2](https://img.shields.io/badge/universal-angular2-brightgreen.svg?style=flat)](https://github.com/angular/universal) +> Server-Side Rendering for Angular 2 + +A minimal Angular 2 starter for Universal JavaScript using TypeScript 2 and Webpack 2 + +> If you're looking for the Angular Universal repo go to [**angular/universal**](https://github.com/angular/universal) + +[![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy) + + +## Installation + +* `npm install` + +## Serve + +* `npm start` to build your client app and start a web server +* `npm run build` to prepare a distributable bundle + +## Development +* run `npm start` and `npm run watch` in two separate terminals to build your client app, start a web server, and allow file changes to update in realtime + +## Watch files +* `npm run watch` to build your client app and start a web server + +## AoT and Prod +* `npm run build:prod:ngc` to compile the ngfactory files and build prod + +###### +npm run build:prod:ngc +PORT = XXXX npm run server + +## Universal "Gotchas" + +> When building Universal components in Angular 2 there are a few things to keep in mind. + + - To use `templateUrl` or `styleUrls` you must use **`angular2-template-loader`** in your TS loaders. + - This is already setup within this starter repo. Look at the webpack.config file [here](https://github.com/angular/universal-starter/blob/master/webpack.config.ts) for details & implementation. + - **`window`**, **`document`**, **`navigator`**, and other browser types - _do not exist on the server_ - so using them, or any library that uses them (jQuery for example) will not work. You do have some options, if you truly need some of this functionality: + - If you need to use them, consider limiting them to only your main.client and wrapping them situationally with the imported *isBrowser / isNode* features from Universal. `import { isBrowser, isNode } from 'angular2-universal'`; + - Another option is using `DOM` from ["@angular/platform-browser"](https://github.com/angular/angular/blob/e3687706c71beb7c9dbdae1bbb5fbbcea588c476/modules/%40angular/platform-browser/src/dom/dom_adapter.ts#L34) + - **Don't manipulate the nativeElement directly**. Use the _Renderer_. We do this to ensure that in any environment we're able to change our view. +``` +constructor(element: ElementRef, renderer: Renderer) { + renderer.setElementStyle(element.nativeElement, 'font-size', 'x-large'); +} +``` + - The application runs XHR requests on the server & once again on the Client-side (when the application bootstraps) + - Use a [UniversalCache](https://github.com/angular/universal-starter/blob/master/src/%2Bapp/shared/model/model.service.ts#L34-L50) instead of regular Http, to save certain requests so they aren't re-ran again on the Client. ([Example useage here](https://github.com/angular/universal-starter/blob/cc71e2d5b2d783f2bb52eebd1b5c6fa0ba23f08a/src/%2Bapp/%2Bhome/home.component.ts#L22-L24)) + - Know the difference between attributes and properties in relation to the DOM. + - Keep your directives stateless as much as possible. For stateful directives, you may need to provide an attribute that reflects the corresponding property with an initial string value such as url in img tag. For our native `` element the src attribute is reflected as the src property of the element type HTMLImageElement. + +### Brotli Compression Support + +To enable Brotli compression for server response with fallback for gzip. Install the following packages +``` +npm install --save-dev iltorb accepts @types/accepts express-interceptor memory-cache @types/memory-cache +``` +and replace the following code from src/server.aot.ts. +``` + import * as compression from 'compression'; + + app.use(compression()); +``` +with +``` +import * as mcache from 'memory-cache'; +const { gzipSync } = require('zlib'); +const accepts = require('accepts'); +const { compressSync } = require('iltorb'); +const interceptor = require('express-interceptor'); + +app.use(interceptor((req, res)=>({ + // don't compress responses with this request header + isInterceptable: () => (!req.headers['x-no-compression']), + intercept: ( body, send ) => { + const encodings = new Set(accepts(req).encodings()); + const bodyBuffer = new Buffer(body); + // url specific key for response cache + const key = '__response__' + req.originalUrl || req.url; + let output = bodyBuffer; + // check if cache exists + if (mcache.get(key) === null) { + // check for encoding support + if (encodings.has('br')) { + // brotli + res.setHeader('Content-Encoding', 'br'); + output = compressSync(bodyBuffer); + mcache.put(key, {output, encoding: 'br'}); + } else if (encodings.has('gzip')) { + // gzip + res.setHeader('Content-Encoding', 'gzip'); + output = gzipSync(bodyBuffer); + mcache.put(key, {output, encoding: 'gzip'}); + } + } else { + const { output, encoding } = mcache.get(key); + if(encodings.has(encoding)){ + res.setHeader('Content-Encoding', encoding); + send(output); + return; + } + } + send(output); + } +}))); +``` +this will check the support, compress and cache the response. + +## Edge case of server compatibility with Promise polyfills + +If you have node modules with promise polyfill dependency on server - there is chance to get the following exception: +``` +Error: Zone.js has detected that ZoneAwarePromise `(window|global).Promise` has been overwritten. +``` +It occurs because [Zone.js](https://github.com/angular/zone.js/) Promise implementation is not +detected as Promise by some polyfills (e.g. [es6-promise](https://github.com/stefanpenner/es6-promise) before 4.x). + +To sort it out, you need such polyfills initialized before zone.js. Zone.js is initialized in 'angular2-universal-polyfills' +import of [server.ts](https://github.com/angular/universal-starter/blob/master/src/server.ts#L4). So import problematic +modules before this line. + +### Documentation +[Design Doc](https://docs.google.com/document/d/1q6g9UlmEZDXgrkY88AJZ6MUrUxcnwhBGS0EXbVlYicY) + +### Videos +Angular 2 Universal Patterns - ng-conf, May 2016 +[![Angular 2 Universal Patterns](http://img.youtube.com/vi/TCj_oC3m6_U/0.jpg)](https://www.youtube.com/watch?v=TCj_oC3m6_U) + +Angular Universal Source Code - ReadTheSource, January 2016 +[![Angular Universal Source Code](http://img.youtube.com/vi/qOjtFjXoebY/0.jpg)](https://www.youtube.com/watch?v=qOjtFjXoebY) + +Full Stack Angular 2 - AngularConnect, Oct 2015 +[![Full Stack Angular 2](https://img.youtube.com/vi/MtoHFDfi8FM/0.jpg)](https://www.youtube.com/watch?v=MtoHFDfi8FM) + +Angular 2 Server Rendering - Angular U, July 2015 +[![Angular 2 Server Rendering](http://img.youtube.com/vi/0wvZ7gakqV4/0.jpg)](http://www.youtube.com/watch?v=0wvZ7gakqV4) + +## [preboot.js](https://github.com/angular/preboot) +> Control server-rendered page and transfer state before client-side web app loads to the client-side-app. + +# License +[![MIT License](https://img.shields.io/badge/license-MIT-blue.svg?style=flat)](/LICENSE) diff --git a/workingUIKIT/app.json b/workingUIKIT/app.json new file mode 100644 index 00000000..1762bb6b --- /dev/null +++ b/workingUIKIT/app.json @@ -0,0 +1,12 @@ +{ + "name": "Angular 2 Universal Starter", + "description": "Angular 2 Universal starter kit by @AngularClass", + "repository": "https://github.com/angular/universal-starter", + "logo": "https://cloud.githubusercontent.com/assets/1016365/10639063/138338bc-7806-11e5-8057-d34c75f3cafc.png", + "env": { + "NPM_CONFIG_PRODUCTION": { + "description": "Install `webpack` and other development modules when deploying to allow full builds.", + "value": "false" + } + } +} diff --git a/workingUIKIT/empty.js b/workingUIKIT/empty.js new file mode 100644 index 00000000..b8ab065d --- /dev/null +++ b/workingUIKIT/empty.js @@ -0,0 +1,7 @@ +module.exports = { + NgProbeToken: {}, + _createConditionalRootRenderer: function(rootRenderer, extraTokens, coreTokens) { + return rootRenderer; + }, + __platform_browser_private__: {} +}; diff --git a/workingUIKIT/nodemon.json b/workingUIKIT/nodemon.json new file mode 100644 index 00000000..97a836fb --- /dev/null +++ b/workingUIKIT/nodemon.json @@ -0,0 +1,7 @@ +{ + "watch": [ + "dist", + "src/index.html" + ], + "ext" : "js ts json html" +} diff --git a/workingUIKIT/npm-shrinkwrap.json.stable b/workingUIKIT/npm-shrinkwrap.json.stable new file mode 100644 index 00000000..713847c4 --- /dev/null +++ b/workingUIKIT/npm-shrinkwrap.json.stable @@ -0,0 +1,2131 @@ +{ + "name": "universal-starter", + "version": "2.0.0", + "dependencies": { + "@angular/common": { + "version": "2.0.0", + "from": "@angular/common@2.0.0", + "resolved": "https://registry.npmjs.org/@angular/common/-/common-2.0.0.tgz" + }, + "@angular/compiler": { + "version": "2.0.0", + "from": "@angular/compiler@2.0.0", + "resolved": "https://registry.npmjs.org/@angular/compiler/-/compiler-2.0.0.tgz" + }, + "@angular/core": { + "version": "2.0.0", + "from": "@angular/core@2.0.0", + "resolved": "https://registry.npmjs.org/@angular/core/-/core-2.0.0.tgz" + }, + "@angular/forms": { + "version": "2.0.0", + "from": "@angular/forms@2.0.0", + "resolved": "https://registry.npmjs.org/@angular/forms/-/forms-2.0.0.tgz" + }, + "@angular/http": { + "version": "2.0.0", + "from": "@angular/http@2.0.0", + "resolved": "https://registry.npmjs.org/@angular/http/-/http-2.0.0.tgz" + }, + "@angular/platform-browser": { + "version": "2.0.0", + "from": "@angular/platform-browser@2.0.0", + "resolved": "https://registry.npmjs.org/@angular/platform-browser/-/platform-browser-2.0.0.tgz" + }, + "@angular/platform-browser-dynamic": { + "version": "2.0.0", + "from": "@angular/platform-browser-dynamic@2.0.0", + "resolved": "https://registry.npmjs.org/@angular/platform-browser-dynamic/-/platform-browser-dynamic-2.0.0.tgz" + }, + "@angular/platform-server": { + "version": "2.0.0", + "from": "@angular/platform-server@2.0.0", + "resolved": "https://registry.npmjs.org/@angular/platform-server/-/platform-server-2.0.0.tgz" + }, + "@angular/router": { + "version": "3.0.0", + "from": "@angular/router@3.0.0", + "resolved": "https://registry.npmjs.org/@angular/router/-/router-3.0.0.tgz" + }, + "@types/express": { + "version": "4.0.33", + "from": "@types/express@>=4.0.32 <5.0.0", + "resolved": "https://registry.npmjs.org/@types/express/-/express-4.0.33.tgz" + }, + "@types/express-serve-static-core": { + "version": "4.0.35", + "from": "@types/express-serve-static-core@>=4.0.33 <5.0.0", + "resolved": "https://registry.npmjs.org/@types/express-serve-static-core/-/express-serve-static-core-4.0.35.tgz" + }, + "@types/mime": { + "version": "0.0.28", + "from": "@types/mime@0.0.28", + "resolved": "https://registry.npmjs.org/@types/mime/-/mime-0.0.28.tgz" + }, + "@types/node": { + "version": "6.0.40", + "from": "@types/node@>=6.0.38 <7.0.0", + "resolved": "https://registry.npmjs.org/@types/node/-/node-6.0.40.tgz" + }, + "@types/serve-static": { + "version": "1.7.31", + "from": "@types/serve-static@>=1.7.27 <2.0.0", + "resolved": "https://registry.npmjs.org/@types/serve-static/-/serve-static-1.7.31.tgz" + }, + "abbrev": { + "version": "1.0.9", + "from": "abbrev@>=1.0.0 <2.0.0", + "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.0.9.tgz" + }, + "accepts": { + "version": "1.3.3", + "from": "accepts@>=1.3.3 <1.4.0", + "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.3.tgz" + }, + "acorn": { + "version": "3.3.0", + "from": "acorn@>=3.2.0 <4.0.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-3.3.0.tgz" + }, + "align-text": { + "version": "0.1.4", + "from": "align-text@>=0.1.3 <0.2.0", + "resolved": "https://registry.npmjs.org/align-text/-/align-text-0.1.4.tgz" + }, + "amdefine": { + "version": "1.0.0", + "from": "amdefine@>=0.0.4", + "resolved": "https://registry.npmjs.org/amdefine/-/amdefine-1.0.0.tgz" + }, + "angular2-express-engine": { + "version": "2.0.11", + "from": "angular2-express-engine@>=2.0.11 <2.1.0", + "resolved": "https://registry.npmjs.org/angular2-express-engine/-/angular2-express-engine-2.0.11.tgz" + }, + "angular2-platform-node": { + "version": "2.0.11", + "from": "angular2-platform-node@>=2.0.11 <2.1.0", + "resolved": "https://registry.npmjs.org/angular2-platform-node/-/angular2-platform-node-2.0.11.tgz", + "dependencies": { + "parse5": { + "version": "2.2.1", + "from": "parse5@>=2.2.1 <3.0.0", + "resolved": "https://registry.npmjs.org/parse5/-/parse5-2.2.1.tgz" + } + } + }, + "angular2-universal": { + "version": "2.0.11", + "from": "angular2-universal@>=2.0.11 <2.1.0", + "resolved": "https://registry.npmjs.org/angular2-universal/-/angular2-universal-2.0.11.tgz", + "dependencies": { + "parse5": { + "version": "2.2.1", + "from": "parse5@>=2.2.1 <3.0.0", + "resolved": "https://registry.npmjs.org/parse5/-/parse5-2.2.1.tgz" + } + } + }, + "angular2-universal-polyfills": { + "version": "2.0.11", + "from": "angular2-universal-polyfills@>=2.0.11 <2.1.0", + "resolved": "https://registry.npmjs.org/angular2-universal-polyfills/-/angular2-universal-polyfills-2.0.11.tgz" + }, + "ansi-regex": { + "version": "2.0.0", + "from": "ansi-regex@>=2.0.0 <3.0.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.0.0.tgz" + }, + "ansi-styles": { + "version": "2.2.1", + "from": "ansi-styles@>=2.2.1 <3.0.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz" + }, + "any-promise": { + "version": "1.3.0", + "from": "any-promise@>=1.3.0 <2.0.0", + "resolved": "https://registry.npmjs.org/any-promise/-/any-promise-1.3.0.tgz" + }, + "anymatch": { + "version": "1.3.0", + "from": "anymatch@>=1.3.0 <2.0.0", + "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-1.3.0.tgz" + }, + "arr-diff": { + "version": "2.0.0", + "from": "arr-diff@>=2.0.0 <3.0.0", + "resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-2.0.0.tgz" + }, + "arr-flatten": { + "version": "1.0.1", + "from": "arr-flatten@>=1.0.1 <2.0.0", + "resolved": "https://registry.npmjs.org/arr-flatten/-/arr-flatten-1.0.1.tgz" + }, + "array-flatten": { + "version": "1.1.1", + "from": "array-flatten@1.1.1", + "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz" + }, + "array-unique": { + "version": "0.2.1", + "from": "array-unique@>=0.2.1 <0.3.0", + "resolved": "https://registry.npmjs.org/array-unique/-/array-unique-0.2.1.tgz" + }, + "arrify": { + "version": "1.0.1", + "from": "arrify@>=1.0.0 <2.0.0", + "resolved": "https://registry.npmjs.org/arrify/-/arrify-1.0.1.tgz" + }, + "asn1.js": { + "version": "4.8.1", + "from": "asn1.js@>=4.0.0 <5.0.0", + "resolved": "https://registry.npmjs.org/asn1.js/-/asn1.js-4.8.1.tgz" + }, + "assert": { + "version": "1.4.1", + "from": "assert@>=1.1.1 <2.0.0", + "resolved": "https://registry.npmjs.org/assert/-/assert-1.4.1.tgz" + }, + "async": { + "version": "1.5.2", + "from": "async@>=1.3.0 <2.0.0", + "resolved": "https://registry.npmjs.org/async/-/async-1.5.2.tgz" + }, + "async-each": { + "version": "1.0.1", + "from": "async-each@>=1.0.0 <2.0.0", + "resolved": "https://registry.npmjs.org/async-each/-/async-each-1.0.1.tgz" + }, + "atob": { + "version": "1.1.3", + "from": "atob@>=1.1.0 <1.2.0", + "resolved": "https://registry.npmjs.org/atob/-/atob-1.1.3.tgz" + }, + "balanced-match": { + "version": "0.4.2", + "from": "balanced-match@>=0.4.1 <0.5.0", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-0.4.2.tgz" + }, + "Base64": { + "version": "0.2.1", + "from": "Base64@>=0.2.0 <0.3.0", + "resolved": "https://registry.npmjs.org/Base64/-/Base64-0.2.1.tgz" + }, + "base64-js": { + "version": "1.1.2", + "from": "base64-js@>=1.0.2 <2.0.0", + "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.1.2.tgz" + }, + "batch": { + "version": "0.5.3", + "from": "batch@0.5.3", + "resolved": "https://registry.npmjs.org/batch/-/batch-0.5.3.tgz" + }, + "big.js": { + "version": "3.1.3", + "from": "big.js@>=3.1.3 <4.0.0", + "resolved": "https://registry.npmjs.org/big.js/-/big.js-3.1.3.tgz" + }, + "binary-extensions": { + "version": "1.6.0", + "from": "binary-extensions@>=1.0.0 <2.0.0", + "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-1.6.0.tgz" + }, + "bluebird": { + "version": "3.4.6", + "from": "bluebird@>=3.0.5 <4.0.0", + "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.4.6.tgz" + }, + "bn.js": { + "version": "4.11.6", + "from": "bn.js@>=4.1.1 <5.0.0", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.6.tgz" + }, + "body-parser": { + "version": "1.15.2", + "from": "body-parser@>=1.15.2 <2.0.0", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.15.2.tgz" + }, + "brace-expansion": { + "version": "1.1.6", + "from": "brace-expansion@>=1.0.0 <2.0.0", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.6.tgz" + }, + "braces": { + "version": "1.8.5", + "from": "braces@>=1.8.2 <2.0.0", + "resolved": "https://registry.npmjs.org/braces/-/braces-1.8.5.tgz" + }, + "brorand": { + "version": "1.0.6", + "from": "brorand@>=1.0.1 <2.0.0", + "resolved": "https://registry.npmjs.org/brorand/-/brorand-1.0.6.tgz" + }, + "browserify-aes": { + "version": "1.0.6", + "from": "browserify-aes@>=1.0.4 <2.0.0", + "resolved": "https://registry.npmjs.org/browserify-aes/-/browserify-aes-1.0.6.tgz" + }, + "browserify-cipher": { + "version": "1.0.0", + "from": "browserify-cipher@>=1.0.0 <2.0.0", + "resolved": "https://registry.npmjs.org/browserify-cipher/-/browserify-cipher-1.0.0.tgz" + }, + "browserify-des": { + "version": "1.0.0", + "from": "browserify-des@>=1.0.0 <2.0.0", + "resolved": "https://registry.npmjs.org/browserify-des/-/browserify-des-1.0.0.tgz" + }, + "browserify-rsa": { + "version": "4.0.1", + "from": "browserify-rsa@>=4.0.0 <5.0.0", + "resolved": "https://registry.npmjs.org/browserify-rsa/-/browserify-rsa-4.0.1.tgz" + }, + "browserify-sign": { + "version": "4.0.0", + "from": "browserify-sign@>=4.0.0 <5.0.0", + "resolved": "https://registry.npmjs.org/browserify-sign/-/browserify-sign-4.0.0.tgz" + }, + "browserify-zlib": { + "version": "0.1.4", + "from": "browserify-zlib@>=0.1.4 <0.2.0", + "resolved": "https://registry.npmjs.org/browserify-zlib/-/browserify-zlib-0.1.4.tgz" + }, + "buffer": { + "version": "4.9.1", + "from": "buffer@>=4.3.0 <5.0.0", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-4.9.1.tgz" + }, + "buffer-shims": { + "version": "1.0.0", + "from": "buffer-shims@>=1.0.0 <2.0.0", + "resolved": "https://registry.npmjs.org/buffer-shims/-/buffer-shims-1.0.0.tgz" + }, + "buffer-xor": { + "version": "1.0.3", + "from": "buffer-xor@>=1.0.2 <2.0.0", + "resolved": "https://registry.npmjs.org/buffer-xor/-/buffer-xor-1.0.3.tgz" + }, + "builtin-modules": { + "version": "1.1.1", + "from": "builtin-modules@>=1.0.0 <2.0.0", + "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-1.1.1.tgz" + }, + "bytes": { + "version": "2.4.0", + "from": "bytes@2.4.0", + "resolved": "https://registry.npmjs.org/bytes/-/bytes-2.4.0.tgz" + }, + "camelcase": { + "version": "1.2.1", + "from": "camelcase@>=1.0.2 <2.0.0", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-1.2.1.tgz" + }, + "center-align": { + "version": "0.1.3", + "from": "center-align@>=0.1.1 <0.2.0", + "resolved": "https://registry.npmjs.org/center-align/-/center-align-0.1.3.tgz" + }, + "chalk": { + "version": "1.1.3", + "from": "chalk@>=1.0.0 <2.0.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz" + }, + "chokidar": { + "version": "1.6.0", + "from": "chokidar@>=1.4.3 <2.0.0", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-1.6.0.tgz" + }, + "cipher-base": { + "version": "1.0.3", + "from": "cipher-base@>=1.0.0 <2.0.0", + "resolved": "https://registry.npmjs.org/cipher-base/-/cipher-base-1.0.3.tgz" + }, + "cliui": { + "version": "2.1.0", + "from": "cliui@>=2.1.0 <3.0.0", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-2.1.0.tgz" + }, + "clone": { + "version": "1.0.2", + "from": "clone@>=1.0.2 <2.0.0", + "resolved": "https://registry.npmjs.org/clone/-/clone-1.0.2.tgz" + }, + "code-point-at": { + "version": "1.0.0", + "from": "code-point-at@>=1.0.0 <2.0.0", + "resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.0.0.tgz" + }, + "colors": { + "version": "1.1.2", + "from": "colors@>=1.0.3 <2.0.0", + "resolved": "https://registry.npmjs.org/colors/-/colors-1.1.2.tgz" + }, + "commander": { + "version": "2.9.0", + "from": "commander@>=2.9.0 <3.0.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.9.0.tgz" + }, + "compressible": { + "version": "2.0.8", + "from": "compressible@>=2.0.8 <2.1.0", + "resolved": "https://registry.npmjs.org/compressible/-/compressible-2.0.8.tgz" + }, + "compression": { + "version": "1.6.2", + "from": "compression@>=1.5.2 <2.0.0", + "resolved": "https://registry.npmjs.org/compression/-/compression-1.6.2.tgz", + "dependencies": { + "bytes": { + "version": "2.3.0", + "from": "bytes@2.3.0", + "resolved": "https://registry.npmjs.org/bytes/-/bytes-2.3.0.tgz" + } + } + }, + "concat-map": { + "version": "0.0.1", + "from": "concat-map@0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz" + }, + "config-chain": { + "version": "1.1.10", + "from": "config-chain@>=1.1.5 <1.2.0", + "resolved": "https://registry.npmjs.org/config-chain/-/config-chain-1.1.10.tgz" + }, + "configstore": { + "version": "1.4.0", + "from": "configstore@>=1.0.0 <2.0.0", + "resolved": "https://registry.npmjs.org/configstore/-/configstore-1.4.0.tgz" + }, + "connect-history-api-fallback": { + "version": "1.3.0", + "from": "connect-history-api-fallback@>=1.2.0 <2.0.0", + "resolved": "https://registry.npmjs.org/connect-history-api-fallback/-/connect-history-api-fallback-1.3.0.tgz" + }, + "console-browserify": { + "version": "1.1.0", + "from": "console-browserify@>=1.1.0 <2.0.0", + "resolved": "https://registry.npmjs.org/console-browserify/-/console-browserify-1.1.0.tgz" + }, + "constants-browserify": { + "version": "1.0.0", + "from": "constants-browserify@>=1.0.0 <2.0.0", + "resolved": "https://registry.npmjs.org/constants-browserify/-/constants-browserify-1.0.0.tgz" + }, + "content-disposition": { + "version": "0.5.1", + "from": "content-disposition@0.5.1", + "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.1.tgz" + }, + "content-type": { + "version": "1.0.2", + "from": "content-type@>=1.0.2 <1.1.0", + "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.2.tgz" + }, + "cookie": { + "version": "0.3.1", + "from": "cookie@0.3.1", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.3.1.tgz" + }, + "cookie-signature": { + "version": "1.0.6", + "from": "cookie-signature@1.0.6", + "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz" + }, + "core-util-is": { + "version": "1.0.2", + "from": "core-util-is@>=1.0.0 <1.1.0", + "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz" + }, + "create-ecdh": { + "version": "4.0.0", + "from": "create-ecdh@>=4.0.0 <5.0.0", + "resolved": "https://registry.npmjs.org/create-ecdh/-/create-ecdh-4.0.0.tgz" + }, + "create-hash": { + "version": "1.1.2", + "from": "create-hash@>=1.1.0 <2.0.0", + "resolved": "https://registry.npmjs.org/create-hash/-/create-hash-1.1.2.tgz" + }, + "create-hmac": { + "version": "1.1.4", + "from": "create-hmac@>=1.1.0 <2.0.0", + "resolved": "https://registry.npmjs.org/create-hmac/-/create-hmac-1.1.4.tgz" + }, + "crypto-browserify": { + "version": "3.11.0", + "from": "crypto-browserify@>=3.11.0 <4.0.0", + "resolved": "https://registry.npmjs.org/crypto-browserify/-/crypto-browserify-3.11.0.tgz" + }, + "css": { + "version": "2.2.1", + "from": "css@>=2.2.1 <3.0.0", + "resolved": "https://registry.npmjs.org/css/-/css-2.2.1.tgz" + }, + "date-now": { + "version": "0.1.4", + "from": "date-now@>=0.1.4 <0.2.0", + "resolved": "https://registry.npmjs.org/date-now/-/date-now-0.1.4.tgz" + }, + "debug": { + "version": "2.2.0", + "from": "debug@>=2.2.0 <2.3.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.2.0.tgz" + }, + "decamelize": { + "version": "1.2.0", + "from": "decamelize@>=1.0.0 <2.0.0", + "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz" + }, + "deep-extend": { + "version": "0.4.1", + "from": "deep-extend@>=0.4.0 <0.5.0", + "resolved": "https://registry.npmjs.org/deep-extend/-/deep-extend-0.4.1.tgz" + }, + "depd": { + "version": "1.1.0", + "from": "depd@>=1.1.0 <1.2.0", + "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.0.tgz" + }, + "des.js": { + "version": "1.0.0", + "from": "des.js@>=1.0.0 <2.0.0", + "resolved": "https://registry.npmjs.org/des.js/-/des.js-1.0.0.tgz" + }, + "destroy": { + "version": "1.0.4", + "from": "destroy@>=1.0.4 <1.1.0", + "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz" + }, + "diff": { + "version": "2.2.3", + "from": "diff@>=2.1.1 <3.0.0", + "resolved": "https://registry.npmjs.org/diff/-/diff-2.2.3.tgz" + }, + "diffie-hellman": { + "version": "5.0.2", + "from": "diffie-hellman@>=5.0.0 <6.0.0", + "resolved": "https://registry.npmjs.org/diffie-hellman/-/diffie-hellman-5.0.2.tgz" + }, + "domain-browser": { + "version": "1.1.7", + "from": "domain-browser@>=1.1.1 <2.0.0", + "resolved": "https://registry.npmjs.org/domain-browser/-/domain-browser-1.1.7.tgz" + }, + "duplexer": { + "version": "0.1.1", + "from": "duplexer@>=0.1.1 <0.2.0", + "resolved": "https://registry.npmjs.org/duplexer/-/duplexer-0.1.1.tgz" + }, + "duplexify": { + "version": "3.4.5", + "from": "duplexify@>=3.2.0 <4.0.0", + "resolved": "https://registry.npmjs.org/duplexify/-/duplexify-3.4.5.tgz" + }, + "editorconfig": { + "version": "0.13.2", + "from": "editorconfig@>=0.13.2 <0.14.0", + "resolved": "https://registry.npmjs.org/editorconfig/-/editorconfig-0.13.2.tgz" + }, + "ee-first": { + "version": "1.1.1", + "from": "ee-first@1.1.1", + "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz" + }, + "elliptic": { + "version": "6.3.2", + "from": "elliptic@>=6.0.0 <7.0.0", + "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.3.2.tgz" + }, + "emojis-list": { + "version": "2.0.1", + "from": "emojis-list@>=2.0.0 <3.0.0", + "resolved": "https://registry.npmjs.org/emojis-list/-/emojis-list-2.0.1.tgz" + }, + "encodeurl": { + "version": "1.0.1", + "from": "encodeurl@>=1.0.1 <1.1.0", + "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.1.tgz" + }, + "end-of-stream": { + "version": "1.0.0", + "from": "end-of-stream@1.0.0", + "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.0.0.tgz" + }, + "enhanced-resolve": { + "version": "0.9.1", + "from": "enhanced-resolve@>=0.9.0 <0.10.0", + "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-0.9.1.tgz" + }, + "errno": { + "version": "0.1.4", + "from": "errno@>=0.1.3 <0.2.0", + "resolved": "https://registry.npmjs.org/errno/-/errno-0.1.4.tgz" + }, + "error-ex": { + "version": "1.3.0", + "from": "error-ex@>=1.2.0 <2.0.0", + "resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.0.tgz" + }, + "es6-promise": { + "version": "3.0.2", + "from": "es6-promise@>=3.0.2 <3.1.0", + "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-3.0.2.tgz" + }, + "es6-shim": { + "version": "0.35.1", + "from": "es6-shim@>=0.35.0 <0.36.0", + "resolved": "https://registry.npmjs.org/es6-shim/-/es6-shim-0.35.1.tgz" + }, + "escape-html": { + "version": "1.0.3", + "from": "escape-html@>=1.0.3 <1.1.0", + "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz" + }, + "escape-string-regexp": { + "version": "1.0.5", + "from": "escape-string-regexp@>=1.0.2 <2.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz" + }, + "etag": { + "version": "1.7.0", + "from": "etag@>=1.7.0 <1.8.0", + "resolved": "https://registry.npmjs.org/etag/-/etag-1.7.0.tgz" + }, + "event-stream": { + "version": "3.3.4", + "from": "event-stream@>=3.3.0 <3.4.0", + "resolved": "https://registry.npmjs.org/event-stream/-/event-stream-3.3.4.tgz" + }, + "eventemitter3": { + "version": "1.2.0", + "from": "eventemitter3@>=1.0.0 <2.0.0", + "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-1.2.0.tgz" + }, + "events": { + "version": "1.1.1", + "from": "events@>=1.0.0 <2.0.0", + "resolved": "https://registry.npmjs.org/events/-/events-1.1.1.tgz" + }, + "eventsource": { + "version": "0.1.6", + "from": "eventsource@>=0.1.6 <0.2.0", + "resolved": "https://registry.npmjs.org/eventsource/-/eventsource-0.1.6.tgz" + }, + "evp_bytestokey": { + "version": "1.0.0", + "from": "evp_bytestokey@>=1.0.0 <2.0.0", + "resolved": "https://registry.npmjs.org/evp_bytestokey/-/evp_bytestokey-1.0.0.tgz" + }, + "expand-brackets": { + "version": "0.1.5", + "from": "expand-brackets@>=0.1.4 <0.2.0", + "resolved": "https://registry.npmjs.org/expand-brackets/-/expand-brackets-0.1.5.tgz" + }, + "expand-range": { + "version": "1.8.2", + "from": "expand-range@>=1.8.1 <2.0.0", + "resolved": "https://registry.npmjs.org/expand-range/-/expand-range-1.8.2.tgz" + }, + "express": { + "version": "4.14.0", + "from": "express@>=4.14.0 <5.0.0", + "resolved": "https://registry.npmjs.org/express/-/express-4.14.0.tgz" + }, + "extglob": { + "version": "0.3.2", + "from": "extglob@>=0.3.1 <0.4.0", + "resolved": "https://registry.npmjs.org/extglob/-/extglob-0.3.2.tgz" + }, + "faye-websocket": { + "version": "0.10.0", + "from": "faye-websocket@>=0.10.0 <0.11.0", + "resolved": "https://registry.npmjs.org/faye-websocket/-/faye-websocket-0.10.0.tgz" + }, + "filename-regex": { + "version": "2.0.0", + "from": "filename-regex@>=2.0.0 <3.0.0", + "resolved": "https://registry.npmjs.org/filename-regex/-/filename-regex-2.0.0.tgz" + }, + "fill-range": { + "version": "2.2.3", + "from": "fill-range@>=2.1.0 <3.0.0", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-2.2.3.tgz" + }, + "finalhandler": { + "version": "0.5.0", + "from": "finalhandler@0.5.0", + "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-0.5.0.tgz" + }, + "find-up": { + "version": "1.1.2", + "from": "find-up@>=1.0.0 <2.0.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-1.1.2.tgz" + }, + "for-in": { + "version": "0.1.6", + "from": "for-in@>=0.1.5 <0.2.0", + "resolved": "https://registry.npmjs.org/for-in/-/for-in-0.1.6.tgz" + }, + "for-own": { + "version": "0.1.4", + "from": "for-own@>=0.1.3 <0.2.0", + "resolved": "https://registry.npmjs.org/for-own/-/for-own-0.1.4.tgz" + }, + "forwarded": { + "version": "0.1.0", + "from": "forwarded@>=0.1.0 <0.2.0", + "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.1.0.tgz" + }, + "fresh": { + "version": "0.3.0", + "from": "fresh@0.3.0", + "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.3.0.tgz" + }, + "from": { + "version": "0.1.3", + "from": "from@>=0.0.0 <1.0.0", + "resolved": "https://registry.npmjs.org/from/-/from-0.1.3.tgz" + }, + "fs.realpath": { + "version": "1.0.0", + "from": "fs.realpath@>=1.0.0 <2.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz" + }, + "get-caller-file": { + "version": "1.0.2", + "from": "get-caller-file@>=1.0.1 <2.0.0", + "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-1.0.2.tgz" + }, + "glob": { + "version": "7.1.0", + "from": "glob@>=7.0.5 <8.0.0", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.0.tgz" + }, + "glob-base": { + "version": "0.3.0", + "from": "glob-base@>=0.3.0 <0.4.0", + "resolved": "https://registry.npmjs.org/glob-base/-/glob-base-0.3.0.tgz" + }, + "glob-parent": { + "version": "2.0.0", + "from": "glob-parent@>=2.0.0 <3.0.0", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-2.0.0.tgz" + }, + "got": { + "version": "3.3.1", + "from": "got@>=3.2.0 <4.0.0", + "resolved": "https://registry.npmjs.org/got/-/got-3.3.1.tgz", + "dependencies": { + "object-assign": { + "version": "3.0.0", + "from": "object-assign@>=3.0.0 <4.0.0", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-3.0.0.tgz" + } + } + }, + "graceful-fs": { + "version": "4.1.6", + "from": "graceful-fs@>=4.1.4 <5.0.0", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.6.tgz" + }, + "graceful-readlink": { + "version": "1.0.1", + "from": "graceful-readlink@>=1.0.0", + "resolved": "https://registry.npmjs.org/graceful-readlink/-/graceful-readlink-1.0.1.tgz" + }, + "has-ansi": { + "version": "2.0.0", + "from": "has-ansi@>=2.0.0 <3.0.0", + "resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz" + }, + "has-flag": { + "version": "1.0.0", + "from": "has-flag@>=1.0.0 <2.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-1.0.0.tgz" + }, + "hash.js": { + "version": "1.0.3", + "from": "hash.js@>=1.0.0 <2.0.0", + "resolved": "https://registry.npmjs.org/hash.js/-/hash.js-1.0.3.tgz" + }, + "hosted-git-info": { + "version": "2.1.5", + "from": "hosted-git-info@>=2.1.4 <3.0.0", + "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.1.5.tgz" + }, + "http-browserify": { + "version": "1.7.0", + "from": "http-browserify@>=1.3.2 <2.0.0", + "resolved": "https://registry.npmjs.org/http-browserify/-/http-browserify-1.7.0.tgz" + }, + "http-errors": { + "version": "1.5.0", + "from": "http-errors@>=1.5.0 <1.6.0", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.5.0.tgz", + "dependencies": { + "inherits": { + "version": "2.0.1", + "from": "inherits@2.0.1", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.1.tgz" + } + } + }, + "http-proxy": { + "version": "1.15.1", + "from": "http-proxy@>=1.14.0 <2.0.0", + "resolved": "https://registry.npmjs.org/http-proxy/-/http-proxy-1.15.1.tgz" + }, + "http-proxy-middleware": { + "version": "0.17.1", + "from": "http-proxy-middleware@>=0.17.1 <0.18.0", + "resolved": "https://registry.npmjs.org/http-proxy-middleware/-/http-proxy-middleware-0.17.1.tgz", + "dependencies": { + "lodash": { + "version": "4.16.1", + "from": "lodash@>=4.14.2 <5.0.0", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.16.1.tgz" + } + } + }, + "https-browserify": { + "version": "0.0.1", + "from": "https-browserify@0.0.1", + "resolved": "https://registry.npmjs.org/https-browserify/-/https-browserify-0.0.1.tgz" + }, + "iconv-lite": { + "version": "0.4.13", + "from": "iconv-lite@0.4.13", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.13.tgz" + }, + "ie-shim": { + "version": "0.1.0", + "from": "ie-shim@>=0.1.0 <0.2.0", + "resolved": "https://registry.npmjs.org/ie-shim/-/ie-shim-0.1.0.tgz" + }, + "ieee754": { + "version": "1.1.6", + "from": "ieee754@>=1.1.4 <2.0.0", + "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.1.6.tgz" + }, + "ignore-by-default": { + "version": "1.0.1", + "from": "ignore-by-default@>=1.0.0 <2.0.0", + "resolved": "https://registry.npmjs.org/ignore-by-default/-/ignore-by-default-1.0.1.tgz" + }, + "imurmurhash": { + "version": "0.1.4", + "from": "imurmurhash@>=0.1.4 <0.2.0", + "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz" + }, + "indexof": { + "version": "0.0.1", + "from": "indexof@0.0.1", + "resolved": "https://registry.npmjs.org/indexof/-/indexof-0.0.1.tgz" + }, + "infinity-agent": { + "version": "2.0.3", + "from": "infinity-agent@>=2.0.0 <3.0.0", + "resolved": "https://registry.npmjs.org/infinity-agent/-/infinity-agent-2.0.3.tgz" + }, + "inflight": { + "version": "1.0.5", + "from": "inflight@>=1.0.4 <2.0.0", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.5.tgz" + }, + "inherits": { + "version": "2.0.3", + "from": "inherits@>=2.0.1 <3.0.0", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz" + }, + "ini": { + "version": "1.3.4", + "from": "ini@>=1.3.4 <2.0.0", + "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.4.tgz" + }, + "interpret": { + "version": "1.0.1", + "from": "interpret@>=1.0.0 <2.0.0", + "resolved": "https://registry.npmjs.org/interpret/-/interpret-1.0.1.tgz" + }, + "invert-kv": { + "version": "1.0.0", + "from": "invert-kv@>=1.0.0 <2.0.0", + "resolved": "https://registry.npmjs.org/invert-kv/-/invert-kv-1.0.0.tgz" + }, + "ipaddr.js": { + "version": "1.1.1", + "from": "ipaddr.js@1.1.1", + "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.1.1.tgz" + }, + "is-arrayish": { + "version": "0.2.1", + "from": "is-arrayish@>=0.2.1 <0.3.0", + "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz" + }, + "is-binary-path": { + "version": "1.0.1", + "from": "is-binary-path@>=1.0.0 <2.0.0", + "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-1.0.1.tgz" + }, + "is-buffer": { + "version": "1.1.4", + "from": "is-buffer@>=1.0.2 <2.0.0", + "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.4.tgz" + }, + "is-builtin-module": { + "version": "1.0.0", + "from": "is-builtin-module@>=1.0.0 <2.0.0", + "resolved": "https://registry.npmjs.org/is-builtin-module/-/is-builtin-module-1.0.0.tgz" + }, + "is-dotfile": { + "version": "1.0.2", + "from": "is-dotfile@>=1.0.0 <2.0.0", + "resolved": "https://registry.npmjs.org/is-dotfile/-/is-dotfile-1.0.2.tgz" + }, + "is-equal-shallow": { + "version": "0.1.3", + "from": "is-equal-shallow@>=0.1.3 <0.2.0", + "resolved": "https://registry.npmjs.org/is-equal-shallow/-/is-equal-shallow-0.1.3.tgz" + }, + "is-extendable": { + "version": "0.1.1", + "from": "is-extendable@>=0.1.1 <0.2.0", + "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-0.1.1.tgz" + }, + "is-extglob": { + "version": "1.0.0", + "from": "is-extglob@>=1.0.0 <2.0.0", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-1.0.0.tgz" + }, + "is-finite": { + "version": "1.0.1", + "from": "is-finite@>=1.0.0 <2.0.0", + "resolved": "https://registry.npmjs.org/is-finite/-/is-finite-1.0.1.tgz" + }, + "is-fullwidth-code-point": { + "version": "1.0.0", + "from": "is-fullwidth-code-point@>=1.0.0 <2.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz" + }, + "is-glob": { + "version": "2.0.1", + "from": "is-glob@>=2.0.0 <3.0.0", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-2.0.1.tgz" + }, + "is-npm": { + "version": "1.0.0", + "from": "is-npm@>=1.0.0 <2.0.0", + "resolved": "https://registry.npmjs.org/is-npm/-/is-npm-1.0.0.tgz" + }, + "is-number": { + "version": "2.1.0", + "from": "is-number@>=2.1.0 <3.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-2.1.0.tgz" + }, + "is-posix-bracket": { + "version": "0.1.1", + "from": "is-posix-bracket@>=0.1.0 <0.2.0", + "resolved": "https://registry.npmjs.org/is-posix-bracket/-/is-posix-bracket-0.1.1.tgz" + }, + "is-primitive": { + "version": "2.0.0", + "from": "is-primitive@>=2.0.0 <3.0.0", + "resolved": "https://registry.npmjs.org/is-primitive/-/is-primitive-2.0.0.tgz" + }, + "is-redirect": { + "version": "1.0.0", + "from": "is-redirect@>=1.0.0 <2.0.0", + "resolved": "https://registry.npmjs.org/is-redirect/-/is-redirect-1.0.0.tgz" + }, + "is-stream": { + "version": "1.1.0", + "from": "is-stream@>=1.0.0 <2.0.0", + "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz" + }, + "is-utf8": { + "version": "0.2.1", + "from": "is-utf8@>=0.2.0 <0.3.0", + "resolved": "https://registry.npmjs.org/is-utf8/-/is-utf8-0.2.1.tgz" + }, + "isarray": { + "version": "1.0.0", + "from": "isarray@1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz" + }, + "isobject": { + "version": "2.1.0", + "from": "isobject@>=2.0.0 <3.0.0", + "resolved": "https://registry.npmjs.org/isobject/-/isobject-2.1.0.tgz" + }, + "js-beautify": { + "version": "1.6.4", + "from": "js-beautify@>=1.6.4 <2.0.0", + "resolved": "https://registry.npmjs.org/js-beautify/-/js-beautify-1.6.4.tgz" + }, + "json3": { + "version": "3.3.2", + "from": "json3@>=3.3.2 <4.0.0", + "resolved": "https://registry.npmjs.org/json3/-/json3-3.3.2.tgz" + }, + "json5": { + "version": "0.5.0", + "from": "json5@>=0.5.0 <0.6.0", + "resolved": "https://registry.npmjs.org/json5/-/json5-0.5.0.tgz" + }, + "kind-of": { + "version": "3.0.4", + "from": "kind-of@>=3.0.2 <4.0.0", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.0.4.tgz" + }, + "latest-version": { + "version": "1.0.1", + "from": "latest-version@>=1.0.0 <2.0.0", + "resolved": "https://registry.npmjs.org/latest-version/-/latest-version-1.0.1.tgz" + }, + "lazy-cache": { + "version": "1.0.4", + "from": "lazy-cache@>=1.0.3 <2.0.0", + "resolved": "https://registry.npmjs.org/lazy-cache/-/lazy-cache-1.0.4.tgz" + }, + "lcid": { + "version": "1.0.0", + "from": "lcid@>=1.0.0 <2.0.0", + "resolved": "https://registry.npmjs.org/lcid/-/lcid-1.0.0.tgz" + }, + "load-json-file": { + "version": "1.1.0", + "from": "load-json-file@>=1.0.0 <2.0.0", + "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-1.1.0.tgz" + }, + "loader-runner": { + "version": "2.2.0", + "from": "loader-runner@>=2.1.0 <3.0.0", + "resolved": "https://registry.npmjs.org/loader-runner/-/loader-runner-2.2.0.tgz" + }, + "loader-utils": { + "version": "0.2.16", + "from": "loader-utils@>=0.2.15 <0.3.0", + "resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-0.2.16.tgz" + }, + "lodash": { + "version": "3.10.1", + "from": "lodash@>=3.10.1 <4.0.0", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-3.10.1.tgz" + }, + "lodash._arraycopy": { + "version": "3.0.0", + "from": "lodash._arraycopy@>=3.0.0 <4.0.0", + "resolved": "https://registry.npmjs.org/lodash._arraycopy/-/lodash._arraycopy-3.0.0.tgz" + }, + "lodash._arrayeach": { + "version": "3.0.0", + "from": "lodash._arrayeach@>=3.0.0 <4.0.0", + "resolved": "https://registry.npmjs.org/lodash._arrayeach/-/lodash._arrayeach-3.0.0.tgz" + }, + "lodash._baseassign": { + "version": "3.2.0", + "from": "lodash._baseassign@>=3.0.0 <4.0.0", + "resolved": "https://registry.npmjs.org/lodash._baseassign/-/lodash._baseassign-3.2.0.tgz" + }, + "lodash._basecallback": { + "version": "3.3.1", + "from": "lodash._basecallback@>=3.0.0 <4.0.0", + "resolved": "https://registry.npmjs.org/lodash._basecallback/-/lodash._basecallback-3.3.1.tgz" + }, + "lodash._basecopy": { + "version": "3.0.1", + "from": "lodash._basecopy@>=3.0.0 <4.0.0", + "resolved": "https://registry.npmjs.org/lodash._basecopy/-/lodash._basecopy-3.0.1.tgz" + }, + "lodash._baseeach": { + "version": "3.0.4", + "from": "lodash._baseeach@>=3.0.0 <4.0.0", + "resolved": "https://registry.npmjs.org/lodash._baseeach/-/lodash._baseeach-3.0.4.tgz" + }, + "lodash._basefind": { + "version": "3.0.0", + "from": "lodash._basefind@>=3.0.0 <4.0.0", + "resolved": "https://registry.npmjs.org/lodash._basefind/-/lodash._basefind-3.0.0.tgz" + }, + "lodash._basefindindex": { + "version": "3.6.0", + "from": "lodash._basefindindex@>=3.0.0 <4.0.0", + "resolved": "https://registry.npmjs.org/lodash._basefindindex/-/lodash._basefindindex-3.6.0.tgz" + }, + "lodash._basefor": { + "version": "3.0.3", + "from": "lodash._basefor@>=3.0.0 <4.0.0", + "resolved": "https://registry.npmjs.org/lodash._basefor/-/lodash._basefor-3.0.3.tgz" + }, + "lodash._baseisequal": { + "version": "3.0.7", + "from": "lodash._baseisequal@>=3.0.0 <4.0.0", + "resolved": "https://registry.npmjs.org/lodash._baseisequal/-/lodash._baseisequal-3.0.7.tgz" + }, + "lodash._bindcallback": { + "version": "3.0.1", + "from": "lodash._bindcallback@>=3.0.0 <4.0.0", + "resolved": "https://registry.npmjs.org/lodash._bindcallback/-/lodash._bindcallback-3.0.1.tgz" + }, + "lodash._createassigner": { + "version": "3.1.1", + "from": "lodash._createassigner@>=3.0.0 <4.0.0", + "resolved": "https://registry.npmjs.org/lodash._createassigner/-/lodash._createassigner-3.1.1.tgz" + }, + "lodash._getnative": { + "version": "3.9.1", + "from": "lodash._getnative@>=3.0.0 <4.0.0", + "resolved": "https://registry.npmjs.org/lodash._getnative/-/lodash._getnative-3.9.1.tgz" + }, + "lodash._isiterateecall": { + "version": "3.0.9", + "from": "lodash._isiterateecall@>=3.0.0 <4.0.0", + "resolved": "https://registry.npmjs.org/lodash._isiterateecall/-/lodash._isiterateecall-3.0.9.tgz" + }, + "lodash.assign": { + "version": "3.2.0", + "from": "lodash.assign@>=3.0.0 <4.0.0", + "resolved": "https://registry.npmjs.org/lodash.assign/-/lodash.assign-3.2.0.tgz" + }, + "lodash.defaults": { + "version": "3.1.2", + "from": "lodash.defaults@>=3.1.2 <4.0.0", + "resolved": "https://registry.npmjs.org/lodash.defaults/-/lodash.defaults-3.1.2.tgz" + }, + "lodash.find": { + "version": "3.2.1", + "from": "lodash.find@>=3.2.1 <4.0.0", + "resolved": "https://registry.npmjs.org/lodash.find/-/lodash.find-3.2.1.tgz" + }, + "lodash.isarguments": { + "version": "3.1.0", + "from": "lodash.isarguments@>=3.0.0 <4.0.0", + "resolved": "https://registry.npmjs.org/lodash.isarguments/-/lodash.isarguments-3.1.0.tgz" + }, + "lodash.isarray": { + "version": "3.0.4", + "from": "lodash.isarray@>=3.0.0 <4.0.0", + "resolved": "https://registry.npmjs.org/lodash.isarray/-/lodash.isarray-3.0.4.tgz" + }, + "lodash.isplainobject": { + "version": "3.2.0", + "from": "lodash.isplainobject@>=3.2.0 <4.0.0", + "resolved": "https://registry.npmjs.org/lodash.isplainobject/-/lodash.isplainobject-3.2.0.tgz" + }, + "lodash.istypedarray": { + "version": "3.0.6", + "from": "lodash.istypedarray@>=3.0.0 <4.0.0", + "resolved": "https://registry.npmjs.org/lodash.istypedarray/-/lodash.istypedarray-3.0.6.tgz" + }, + "lodash.keys": { + "version": "3.1.2", + "from": "lodash.keys@>=3.0.0 <4.0.0", + "resolved": "https://registry.npmjs.org/lodash.keys/-/lodash.keys-3.1.2.tgz" + }, + "lodash.keysin": { + "version": "3.0.8", + "from": "lodash.keysin@>=3.0.0 <4.0.0", + "resolved": "https://registry.npmjs.org/lodash.keysin/-/lodash.keysin-3.0.8.tgz" + }, + "lodash.merge": { + "version": "3.3.2", + "from": "lodash.merge@>=3.3.2 <4.0.0", + "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-3.3.2.tgz" + }, + "lodash.pairs": { + "version": "3.0.1", + "from": "lodash.pairs@>=3.0.0 <4.0.0", + "resolved": "https://registry.npmjs.org/lodash.pairs/-/lodash.pairs-3.0.1.tgz" + }, + "lodash.restparam": { + "version": "3.6.1", + "from": "lodash.restparam@>=3.0.0 <4.0.0", + "resolved": "https://registry.npmjs.org/lodash.restparam/-/lodash.restparam-3.6.1.tgz" + }, + "lodash.toplainobject": { + "version": "3.0.0", + "from": "lodash.toplainobject@>=3.0.0 <4.0.0", + "resolved": "https://registry.npmjs.org/lodash.toplainobject/-/lodash.toplainobject-3.0.0.tgz" + }, + "longest": { + "version": "1.0.1", + "from": "longest@>=1.0.1 <2.0.0", + "resolved": "https://registry.npmjs.org/longest/-/longest-1.0.1.tgz" + }, + "lowercase-keys": { + "version": "1.0.0", + "from": "lowercase-keys@>=1.0.0 <2.0.0", + "resolved": "https://registry.npmjs.org/lowercase-keys/-/lowercase-keys-1.0.0.tgz" + }, + "lru-cache": { + "version": "3.2.0", + "from": "lru-cache@>=3.2.0 <4.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-3.2.0.tgz" + }, + "make-error": { + "version": "1.2.1", + "from": "make-error@>=1.1.1 <2.0.0", + "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.2.1.tgz" + }, + "map-stream": { + "version": "0.1.0", + "from": "map-stream@>=0.1.0 <0.2.0", + "resolved": "https://registry.npmjs.org/map-stream/-/map-stream-0.1.0.tgz" + }, + "media-typer": { + "version": "0.3.0", + "from": "media-typer@0.3.0", + "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz" + }, + "memory-fs": { + "version": "0.2.0", + "from": "memory-fs@>=0.2.0 <0.3.0", + "resolved": "https://registry.npmjs.org/memory-fs/-/memory-fs-0.2.0.tgz" + }, + "merge-descriptors": { + "version": "1.0.1", + "from": "merge-descriptors@1.0.1", + "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz" + }, + "methods": { + "version": "1.1.2", + "from": "methods@>=1.1.2 <1.2.0", + "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz" + }, + "micromatch": { + "version": "2.3.11", + "from": "micromatch@>=2.1.5 <3.0.0", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-2.3.11.tgz" + }, + "miller-rabin": { + "version": "4.0.0", + "from": "miller-rabin@>=4.0.0 <5.0.0", + "resolved": "https://registry.npmjs.org/miller-rabin/-/miller-rabin-4.0.0.tgz" + }, + "mime": { + "version": "1.3.4", + "from": "mime@1.3.4", + "resolved": "https://registry.npmjs.org/mime/-/mime-1.3.4.tgz" + }, + "mime-db": { + "version": "1.24.0", + "from": "mime-db@>=1.24.0 <1.25.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.24.0.tgz" + }, + "mime-types": { + "version": "2.1.12", + "from": "mime-types@>=2.1.11 <2.2.0", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.12.tgz" + }, + "minimalistic-assert": { + "version": "1.0.0", + "from": "minimalistic-assert@>=1.0.0 <2.0.0", + "resolved": "https://registry.npmjs.org/minimalistic-assert/-/minimalistic-assert-1.0.0.tgz" + }, + "minimatch": { + "version": "3.0.3", + "from": "minimatch@>=3.0.0 <4.0.0", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.3.tgz" + }, + "minimist": { + "version": "0.0.8", + "from": "minimist@0.0.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz" + }, + "mkdirp": { + "version": "0.5.1", + "from": "mkdirp@>=0.5.0 <0.6.0", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz" + }, + "ms": { + "version": "0.7.1", + "from": "ms@0.7.1", + "resolved": "https://registry.npmjs.org/ms/-/ms-0.7.1.tgz" + }, + "negotiator": { + "version": "0.6.1", + "from": "negotiator@0.6.1", + "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.1.tgz" + }, + "nested-error-stacks": { + "version": "1.0.2", + "from": "nested-error-stacks@>=1.0.0 <2.0.0", + "resolved": "https://registry.npmjs.org/nested-error-stacks/-/nested-error-stacks-1.0.2.tgz" + }, + "node-libs-browser": { + "version": "1.0.0", + "from": "node-libs-browser@>=1.0.0 <2.0.0", + "resolved": "https://registry.npmjs.org/node-libs-browser/-/node-libs-browser-1.0.0.tgz" + }, + "nopt": { + "version": "3.0.6", + "from": "nopt@>=3.0.1 <3.1.0", + "resolved": "https://registry.npmjs.org/nopt/-/nopt-3.0.6.tgz" + }, + "normalize-package-data": { + "version": "2.3.5", + "from": "normalize-package-data@>=2.3.2 <3.0.0", + "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.3.5.tgz" + }, + "normalize-path": { + "version": "2.0.1", + "from": "normalize-path@>=2.0.1 <3.0.0", + "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-2.0.1.tgz" + }, + "number-is-nan": { + "version": "1.0.0", + "from": "number-is-nan@>=1.0.0 <2.0.0", + "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.0.tgz" + }, + "object-assign": { + "version": "4.1.0", + "from": "object-assign@>=4.0.1 <5.0.0", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.0.tgz" + }, + "object.omit": { + "version": "2.0.0", + "from": "object.omit@>=2.0.0 <3.0.0", + "resolved": "https://registry.npmjs.org/object.omit/-/object.omit-2.0.0.tgz" + }, + "on-finished": { + "version": "2.3.0", + "from": "on-finished@>=2.3.0 <2.4.0", + "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz" + }, + "on-headers": { + "version": "1.0.1", + "from": "on-headers@>=1.0.1 <1.1.0", + "resolved": "https://registry.npmjs.org/on-headers/-/on-headers-1.0.1.tgz" + }, + "once": { + "version": "1.3.3", + "from": "once@>=1.3.0 <1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.3.3.tgz" + }, + "opn": { + "version": "4.0.2", + "from": "opn@4.0.2", + "resolved": "https://registry.npmjs.org/opn/-/opn-4.0.2.tgz" + }, + "original": { + "version": "1.0.0", + "from": "original@>=0.0.5", + "resolved": "https://registry.npmjs.org/original/-/original-1.0.0.tgz", + "dependencies": { + "url-parse": { + "version": "1.0.5", + "from": "url-parse@>=1.0.0 <1.1.0", + "resolved": "https://registry.npmjs.org/url-parse/-/url-parse-1.0.5.tgz" + } + } + }, + "os-browserify": { + "version": "0.2.1", + "from": "os-browserify@>=0.2.0 <0.3.0", + "resolved": "https://registry.npmjs.org/os-browserify/-/os-browserify-0.2.1.tgz" + }, + "os-homedir": { + "version": "1.0.1", + "from": "os-homedir@>=1.0.0 <2.0.0", + "resolved": "https://registry.npmjs.org/os-homedir/-/os-homedir-1.0.1.tgz" + }, + "os-locale": { + "version": "1.4.0", + "from": "os-locale@>=1.4.0 <2.0.0", + "resolved": "https://registry.npmjs.org/os-locale/-/os-locale-1.4.0.tgz" + }, + "os-tmpdir": { + "version": "1.0.1", + "from": "os-tmpdir@>=1.0.0 <2.0.0", + "resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.1.tgz" + }, + "osenv": { + "version": "0.1.3", + "from": "osenv@>=0.1.0 <0.2.0", + "resolved": "https://registry.npmjs.org/osenv/-/osenv-0.1.3.tgz" + }, + "package-json": { + "version": "1.2.0", + "from": "package-json@>=1.0.0 <2.0.0", + "resolved": "https://registry.npmjs.org/package-json/-/package-json-1.2.0.tgz" + }, + "pako": { + "version": "0.2.9", + "from": "pako@>=0.2.0 <0.3.0", + "resolved": "https://registry.npmjs.org/pako/-/pako-0.2.9.tgz" + }, + "parse-asn1": { + "version": "5.0.0", + "from": "parse-asn1@>=5.0.0 <6.0.0", + "resolved": "https://registry.npmjs.org/parse-asn1/-/parse-asn1-5.0.0.tgz" + }, + "parse-glob": { + "version": "3.0.4", + "from": "parse-glob@>=3.0.4 <4.0.0", + "resolved": "https://registry.npmjs.org/parse-glob/-/parse-glob-3.0.4.tgz" + }, + "parse-json": { + "version": "2.2.0", + "from": "parse-json@>=2.2.0 <3.0.0", + "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-2.2.0.tgz" + }, + "parse5": { + "version": "1.3.2", + "from": "parse5@1.3.2", + "resolved": "https://registry.npmjs.org/parse5/-/parse5-1.3.2.tgz" + }, + "parseurl": { + "version": "1.3.1", + "from": "parseurl@>=1.3.1 <1.4.0", + "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.1.tgz" + }, + "path-browserify": { + "version": "0.0.0", + "from": "path-browserify@0.0.0", + "resolved": "https://registry.npmjs.org/path-browserify/-/path-browserify-0.0.0.tgz" + }, + "path-exists": { + "version": "2.1.0", + "from": "path-exists@>=2.0.0 <3.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-2.1.0.tgz" + }, + "path-is-absolute": { + "version": "1.0.0", + "from": "path-is-absolute@>=1.0.0 <2.0.0", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.0.tgz" + }, + "path-to-regexp": { + "version": "0.1.7", + "from": "path-to-regexp@0.1.7", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz" + }, + "path-type": { + "version": "1.1.0", + "from": "path-type@>=1.0.0 <2.0.0", + "resolved": "https://registry.npmjs.org/path-type/-/path-type-1.1.0.tgz" + }, + "pause-stream": { + "version": "0.0.11", + "from": "pause-stream@0.0.11", + "resolved": "https://registry.npmjs.org/pause-stream/-/pause-stream-0.0.11.tgz" + }, + "pbkdf2": { + "version": "3.0.8", + "from": "pbkdf2@>=3.0.3 <4.0.0", + "resolved": "https://registry.npmjs.org/pbkdf2/-/pbkdf2-3.0.8.tgz" + }, + "pify": { + "version": "2.3.0", + "from": "pify@>=2.0.0 <3.0.0", + "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz" + }, + "pinkie": { + "version": "2.0.4", + "from": "pinkie@>=2.0.0 <3.0.0", + "resolved": "https://registry.npmjs.org/pinkie/-/pinkie-2.0.4.tgz" + }, + "pinkie-promise": { + "version": "2.0.1", + "from": "pinkie-promise@>=2.0.0 <3.0.0", + "resolved": "https://registry.npmjs.org/pinkie-promise/-/pinkie-promise-2.0.1.tgz" + }, + "preboot": { + "version": "4.5.2", + "from": "preboot@4.5.2", + "resolved": "https://registry.npmjs.org/preboot/-/preboot-4.5.2.tgz" + }, + "prepend-http": { + "version": "1.0.4", + "from": "prepend-http@>=1.0.0 <2.0.0", + "resolved": "https://registry.npmjs.org/prepend-http/-/prepend-http-1.0.4.tgz" + }, + "preserve": { + "version": "0.2.0", + "from": "preserve@>=0.2.0 <0.3.0", + "resolved": "https://registry.npmjs.org/preserve/-/preserve-0.2.0.tgz" + }, + "process": { + "version": "0.11.9", + "from": "process@>=0.11.0 <0.12.0", + "resolved": "https://registry.npmjs.org/process/-/process-0.11.9.tgz" + }, + "process-nextick-args": { + "version": "1.0.7", + "from": "process-nextick-args@>=1.0.6 <1.1.0", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz" + }, + "proto-list": { + "version": "1.2.4", + "from": "proto-list@>=1.2.1 <1.3.0", + "resolved": "https://registry.npmjs.org/proto-list/-/proto-list-1.2.4.tgz" + }, + "proxy-addr": { + "version": "1.1.2", + "from": "proxy-addr@>=1.1.2 <1.2.0", + "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-1.1.2.tgz" + }, + "prr": { + "version": "0.0.0", + "from": "prr@>=0.0.0 <0.1.0", + "resolved": "https://registry.npmjs.org/prr/-/prr-0.0.0.tgz" + }, + "ps-tree": { + "version": "1.1.0", + "from": "ps-tree@>=1.0.1 <2.0.0", + "resolved": "https://registry.npmjs.org/ps-tree/-/ps-tree-1.1.0.tgz" + }, + "pseudomap": { + "version": "1.0.2", + "from": "pseudomap@>=1.0.1 <2.0.0", + "resolved": "https://registry.npmjs.org/pseudomap/-/pseudomap-1.0.2.tgz" + }, + "public-encrypt": { + "version": "4.0.0", + "from": "public-encrypt@>=4.0.0 <5.0.0", + "resolved": "https://registry.npmjs.org/public-encrypt/-/public-encrypt-4.0.0.tgz" + }, + "punycode": { + "version": "1.4.1", + "from": "punycode@>=1.2.4 <2.0.0", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz" + }, + "qs": { + "version": "6.2.0", + "from": "qs@6.2.0", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.2.0.tgz" + }, + "querystring": { + "version": "0.2.0", + "from": "querystring@0.2.0", + "resolved": "https://registry.npmjs.org/querystring/-/querystring-0.2.0.tgz" + }, + "querystring-es3": { + "version": "0.2.1", + "from": "querystring-es3@>=0.2.0 <0.3.0", + "resolved": "https://registry.npmjs.org/querystring-es3/-/querystring-es3-0.2.1.tgz" + }, + "querystringify": { + "version": "0.0.4", + "from": "querystringify@>=0.0.0 <0.1.0", + "resolved": "https://registry.npmjs.org/querystringify/-/querystringify-0.0.4.tgz" + }, + "randomatic": { + "version": "1.1.5", + "from": "randomatic@>=1.1.3 <2.0.0", + "resolved": "https://registry.npmjs.org/randomatic/-/randomatic-1.1.5.tgz" + }, + "randombytes": { + "version": "2.0.3", + "from": "randombytes@>=2.0.0 <3.0.0", + "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.0.3.tgz" + }, + "range-parser": { + "version": "1.2.0", + "from": "range-parser@>=1.2.0 <1.3.0", + "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.0.tgz" + }, + "raw-body": { + "version": "2.1.7", + "from": "raw-body@>=2.1.7 <2.2.0", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.1.7.tgz" + }, + "rc": { + "version": "1.1.6", + "from": "rc@>=1.0.1 <2.0.0", + "resolved": "https://registry.npmjs.org/rc/-/rc-1.1.6.tgz", + "dependencies": { + "minimist": { + "version": "1.2.0", + "from": "minimist@>=1.2.0 <2.0.0", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz" + } + } + }, + "read-all-stream": { + "version": "3.1.0", + "from": "read-all-stream@>=3.0.0 <4.0.0", + "resolved": "https://registry.npmjs.org/read-all-stream/-/read-all-stream-3.1.0.tgz" + }, + "read-pkg": { + "version": "1.1.0", + "from": "read-pkg@>=1.0.0 <2.0.0", + "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-1.1.0.tgz" + }, + "read-pkg-up": { + "version": "1.0.1", + "from": "read-pkg-up@>=1.0.1 <2.0.0", + "resolved": "https://registry.npmjs.org/read-pkg-up/-/read-pkg-up-1.0.1.tgz" + }, + "readable-stream": { + "version": "2.1.5", + "from": "readable-stream@>=2.0.2 <3.0.0", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.1.5.tgz" + }, + "readdirp": { + "version": "2.1.0", + "from": "readdirp@>=2.0.0 <3.0.0", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-2.1.0.tgz" + }, + "reflect-metadata": { + "version": "0.1.2", + "from": "reflect-metadata@0.1.2", + "resolved": "https://registry.npmjs.org/reflect-metadata/-/reflect-metadata-0.1.2.tgz" + }, + "regex-cache": { + "version": "0.4.3", + "from": "regex-cache@>=0.4.2 <0.5.0", + "resolved": "https://registry.npmjs.org/regex-cache/-/regex-cache-0.4.3.tgz" + }, + "registry-url": { + "version": "3.1.0", + "from": "registry-url@>=3.0.0 <4.0.0", + "resolved": "https://registry.npmjs.org/registry-url/-/registry-url-3.1.0.tgz" + }, + "repeat-element": { + "version": "1.1.2", + "from": "repeat-element@>=1.1.2 <2.0.0", + "resolved": "https://registry.npmjs.org/repeat-element/-/repeat-element-1.1.2.tgz" + }, + "repeat-string": { + "version": "1.5.4", + "from": "repeat-string@>=1.5.2 <2.0.0", + "resolved": "https://registry.npmjs.org/repeat-string/-/repeat-string-1.5.4.tgz" + }, + "repeating": { + "version": "1.1.3", + "from": "repeating@>=1.1.2 <2.0.0", + "resolved": "https://registry.npmjs.org/repeating/-/repeating-1.1.3.tgz" + }, + "require-directory": { + "version": "2.1.1", + "from": "require-directory@>=2.1.1 <3.0.0", + "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz" + }, + "require-main-filename": { + "version": "1.0.1", + "from": "require-main-filename@>=1.0.1 <2.0.0", + "resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-1.0.1.tgz" + }, + "requires-port": { + "version": "1.0.0", + "from": "requires-port@>=1.0.0 <2.0.0", + "resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz" + }, + "resolve-url": { + "version": "0.2.1", + "from": "resolve-url@>=0.2.1 <0.3.0", + "resolved": "https://registry.npmjs.org/resolve-url/-/resolve-url-0.2.1.tgz" + }, + "right-align": { + "version": "0.1.3", + "from": "right-align@>=0.1.1 <0.2.0", + "resolved": "https://registry.npmjs.org/right-align/-/right-align-0.1.3.tgz" + }, + "ripemd160": { + "version": "1.0.1", + "from": "ripemd160@>=1.0.0 <2.0.0", + "resolved": "https://registry.npmjs.org/ripemd160/-/ripemd160-1.0.1.tgz" + }, + "rxjs": { + "version": "5.0.0-beta.12", + "from": "rxjs@5.0.0-beta.12", + "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-5.0.0-beta.12.tgz" + }, + "semver": { + "version": "5.3.0", + "from": "semver@>=5.0.3 <6.0.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.3.0.tgz" + }, + "semver-diff": { + "version": "2.1.0", + "from": "semver-diff@>=2.0.0 <3.0.0", + "resolved": "https://registry.npmjs.org/semver-diff/-/semver-diff-2.1.0.tgz" + }, + "send": { + "version": "0.14.1", + "from": "send@0.14.1", + "resolved": "https://registry.npmjs.org/send/-/send-0.14.1.tgz" + }, + "serve-index": { + "version": "1.8.0", + "from": "serve-index@>=1.7.2 <2.0.0", + "resolved": "https://registry.npmjs.org/serve-index/-/serve-index-1.8.0.tgz" + }, + "serve-static": { + "version": "1.11.1", + "from": "serve-static@>=1.11.1 <1.12.0", + "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.11.1.tgz" + }, + "set-blocking": { + "version": "2.0.0", + "from": "set-blocking@>=2.0.0 <3.0.0", + "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz" + }, + "set-immediate-shim": { + "version": "1.0.1", + "from": "set-immediate-shim@>=1.0.1 <2.0.0", + "resolved": "https://registry.npmjs.org/set-immediate-shim/-/set-immediate-shim-1.0.1.tgz" + }, + "setprototypeof": { + "version": "1.0.1", + "from": "setprototypeof@1.0.1", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.0.1.tgz" + }, + "sha.js": { + "version": "2.4.5", + "from": "sha.js@>=2.3.6 <3.0.0", + "resolved": "https://registry.npmjs.org/sha.js/-/sha.js-2.4.5.tgz" + }, + "sigmund": { + "version": "1.0.1", + "from": "sigmund@>=1.0.1 <2.0.0", + "resolved": "https://registry.npmjs.org/sigmund/-/sigmund-1.0.1.tgz" + }, + "slide": { + "version": "1.1.6", + "from": "slide@>=1.1.5 <2.0.0", + "resolved": "https://registry.npmjs.org/slide/-/slide-1.1.6.tgz" + }, + "sockjs": { + "version": "0.3.17", + "from": "sockjs@0.3.17", + "resolved": "https://registry.npmjs.org/sockjs/-/sockjs-0.3.17.tgz" + }, + "sockjs-client": { + "version": "1.1.1", + "from": "sockjs-client@1.1.1", + "resolved": "https://registry.npmjs.org/sockjs-client/-/sockjs-client-1.1.1.tgz", + "dependencies": { + "faye-websocket": { + "version": "0.11.0", + "from": "faye-websocket@>=0.11.0 <0.12.0", + "resolved": "https://registry.npmjs.org/faye-websocket/-/faye-websocket-0.11.0.tgz" + } + } + }, + "source-list-map": { + "version": "0.1.6", + "from": "source-list-map@>=0.1.0 <0.2.0", + "resolved": "https://registry.npmjs.org/source-list-map/-/source-list-map-0.1.6.tgz" + }, + "source-map": { + "version": "0.1.43", + "from": "source-map@>=0.1.38 <0.2.0", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.1.43.tgz" + }, + "source-map-resolve": { + "version": "0.3.1", + "from": "source-map-resolve@>=0.3.0 <0.4.0", + "resolved": "https://registry.npmjs.org/source-map-resolve/-/source-map-resolve-0.3.1.tgz" + }, + "source-map-support": { + "version": "0.4.2", + "from": "source-map-support@>=0.4.0 <0.5.0", + "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.4.2.tgz", + "dependencies": { + "source-map": { + "version": "0.1.32", + "from": "source-map@0.1.32", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.1.32.tgz" + } + } + }, + "source-map-url": { + "version": "0.3.0", + "from": "source-map-url@>=0.3.0 <0.4.0", + "resolved": "https://registry.npmjs.org/source-map-url/-/source-map-url-0.3.0.tgz" + }, + "spdx-correct": { + "version": "1.0.2", + "from": "spdx-correct@>=1.0.0 <1.1.0", + "resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-1.0.2.tgz" + }, + "spdx-expression-parse": { + "version": "1.0.3", + "from": "spdx-expression-parse@>=1.0.0 <1.1.0", + "resolved": "https://registry.npmjs.org/spdx-expression-parse/-/spdx-expression-parse-1.0.3.tgz" + }, + "spdx-license-ids": { + "version": "1.2.2", + "from": "spdx-license-ids@>=1.0.2 <2.0.0", + "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-1.2.2.tgz" + }, + "split": { + "version": "0.3.3", + "from": "split@>=0.3.0 <0.4.0", + "resolved": "https://registry.npmjs.org/split/-/split-0.3.3.tgz" + }, + "statuses": { + "version": "1.3.0", + "from": "statuses@>=1.3.0 <2.0.0", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.3.0.tgz" + }, + "stream-browserify": { + "version": "2.0.1", + "from": "stream-browserify@>=2.0.1 <3.0.0", + "resolved": "https://registry.npmjs.org/stream-browserify/-/stream-browserify-2.0.1.tgz" + }, + "stream-cache": { + "version": "0.0.2", + "from": "stream-cache@>=0.0.1 <0.1.0", + "resolved": "https://registry.npmjs.org/stream-cache/-/stream-cache-0.0.2.tgz" + }, + "stream-combiner": { + "version": "0.0.4", + "from": "stream-combiner@>=0.0.4 <0.1.0", + "resolved": "https://registry.npmjs.org/stream-combiner/-/stream-combiner-0.0.4.tgz" + }, + "stream-shift": { + "version": "1.0.0", + "from": "stream-shift@>=1.0.0 <2.0.0", + "resolved": "https://registry.npmjs.org/stream-shift/-/stream-shift-1.0.0.tgz" + }, + "string_decoder": { + "version": "0.10.31", + "from": "string_decoder@>=0.10.0 <0.11.0", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz" + }, + "string-length": { + "version": "1.0.1", + "from": "string-length@>=1.0.0 <2.0.0", + "resolved": "https://registry.npmjs.org/string-length/-/string-length-1.0.1.tgz" + }, + "string-width": { + "version": "1.0.2", + "from": "string-width@>=1.0.1 <2.0.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz" + }, + "strip-ansi": { + "version": "3.0.1", + "from": "strip-ansi@>=3.0.0 <4.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz" + }, + "strip-bom": { + "version": "2.0.0", + "from": "strip-bom@>=2.0.0 <3.0.0", + "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-2.0.0.tgz" + }, + "strip-json-comments": { + "version": "1.0.4", + "from": "strip-json-comments@>=1.0.4 <1.1.0", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-1.0.4.tgz" + }, + "supports-color": { + "version": "2.0.0", + "from": "supports-color@>=2.0.0 <3.0.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz" + }, + "symbol-observable": { + "version": "1.0.2", + "from": "symbol-observable@>=1.0.1 <2.0.0", + "resolved": "https://registry.npmjs.org/symbol-observable/-/symbol-observable-1.0.2.tgz" + }, + "tapable": { + "version": "0.1.10", + "from": "tapable@>=0.1.8 <0.2.0", + "resolved": "https://registry.npmjs.org/tapable/-/tapable-0.1.10.tgz" + }, + "through": { + "version": "2.3.8", + "from": "through@>=2.3.1 <2.4.0", + "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz" + }, + "timed-out": { + "version": "2.0.0", + "from": "timed-out@>=2.0.0 <3.0.0", + "resolved": "https://registry.npmjs.org/timed-out/-/timed-out-2.0.0.tgz" + }, + "timers-browserify": { + "version": "1.4.2", + "from": "timers-browserify@>=1.0.1 <2.0.0", + "resolved": "https://registry.npmjs.org/timers-browserify/-/timers-browserify-1.4.2.tgz" + }, + "touch": { + "version": "1.0.0", + "from": "touch@1.0.0", + "resolved": "https://registry.npmjs.org/touch/-/touch-1.0.0.tgz", + "dependencies": { + "nopt": { + "version": "1.0.10", + "from": "nopt@>=1.0.10 <1.1.0", + "resolved": "https://registry.npmjs.org/nopt/-/nopt-1.0.10.tgz" + } + } + }, + "tsconfig": { + "version": "5.0.3", + "from": "tsconfig@>=5.0.2 <6.0.0", + "resolved": "https://registry.npmjs.org/tsconfig/-/tsconfig-5.0.3.tgz", + "dependencies": { + "strip-json-comments": { + "version": "2.0.1", + "from": "strip-json-comments@>=2.0.0 <3.0.0", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz" + } + } + }, + "tty-browserify": { + "version": "0.0.0", + "from": "tty-browserify@0.0.0", + "resolved": "https://registry.npmjs.org/tty-browserify/-/tty-browserify-0.0.0.tgz" + }, + "type-is": { + "version": "1.6.13", + "from": "type-is@>=1.6.13 <1.7.0", + "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.13.tgz" + }, + "uglify-js": { + "version": "2.6.4", + "from": "uglify-js@>=2.6.0 <2.7.0", + "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-2.6.4.tgz", + "dependencies": { + "async": { + "version": "0.2.10", + "from": "async@>=0.2.6 <0.3.0", + "resolved": "https://registry.npmjs.org/async/-/async-0.2.10.tgz" + }, + "source-map": { + "version": "0.5.6", + "from": "source-map@>=0.5.1 <0.6.0", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.6.tgz" + }, + "yargs": { + "version": "3.10.0", + "from": "yargs@>=3.10.0 <3.11.0", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-3.10.0.tgz" + } + } + }, + "uglify-to-browserify": { + "version": "1.0.2", + "from": "uglify-to-browserify@>=1.0.0 <1.1.0", + "resolved": "https://registry.npmjs.org/uglify-to-browserify/-/uglify-to-browserify-1.0.2.tgz" + }, + "undefsafe": { + "version": "0.0.3", + "from": "undefsafe@0.0.3", + "resolved": "https://registry.npmjs.org/undefsafe/-/undefsafe-0.0.3.tgz" + }, + "unpipe": { + "version": "1.0.0", + "from": "unpipe@1.0.0", + "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz" + }, + "update-notifier": { + "version": "0.5.0", + "from": "update-notifier@0.5.0", + "resolved": "https://registry.npmjs.org/update-notifier/-/update-notifier-0.5.0.tgz" + }, + "urix": { + "version": "0.1.0", + "from": "urix@>=0.1.0 <0.2.0", + "resolved": "https://registry.npmjs.org/urix/-/urix-0.1.0.tgz" + }, + "url": { + "version": "0.11.0", + "from": "url@>=0.11.0 <0.12.0", + "resolved": "https://registry.npmjs.org/url/-/url-0.11.0.tgz", + "dependencies": { + "punycode": { + "version": "1.3.2", + "from": "punycode@1.3.2", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.3.2.tgz" + } + } + }, + "url-parse": { + "version": "1.1.3", + "from": "url-parse@>=1.1.1 <2.0.0", + "resolved": "https://registry.npmjs.org/url-parse/-/url-parse-1.1.3.tgz" + }, + "util": { + "version": "0.10.3", + "from": "util@>=0.10.3 <0.11.0", + "resolved": "https://registry.npmjs.org/util/-/util-0.10.3.tgz", + "dependencies": { + "inherits": { + "version": "2.0.1", + "from": "inherits@2.0.1", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.1.tgz" + } + } + }, + "util-deprecate": { + "version": "1.0.2", + "from": "util-deprecate@>=1.0.1 <1.1.0", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz" + }, + "utils-merge": { + "version": "1.0.0", + "from": "utils-merge@1.0.0", + "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.0.tgz" + }, + "uuid": { + "version": "2.0.3", + "from": "uuid@>=2.0.1 <3.0.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-2.0.3.tgz" + }, + "validate-npm-package-license": { + "version": "3.0.1", + "from": "validate-npm-package-license@>=3.0.1 <4.0.0", + "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.1.tgz" + }, + "vary": { + "version": "1.1.0", + "from": "vary@>=1.1.0 <1.2.0", + "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.0.tgz" + }, + "vm-browserify": { + "version": "0.0.4", + "from": "vm-browserify@0.0.4", + "resolved": "https://registry.npmjs.org/vm-browserify/-/vm-browserify-0.0.4.tgz" + }, + "watchpack": { + "version": "1.1.0", + "from": "watchpack@>=1.0.0 <2.0.0", + "resolved": "https://registry.npmjs.org/watchpack/-/watchpack-1.1.0.tgz", + "dependencies": { + "async": { + "version": "2.0.0-rc.4", + "from": "async@2.0.0-rc.4", + "resolved": "https://registry.npmjs.org/async/-/async-2.0.0-rc.4.tgz" + }, + "lodash": { + "version": "4.16.1", + "from": "lodash@>=4.3.0 <5.0.0", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.16.1.tgz" + } + } + }, + "webpack-dev-middleware": { + "version": "1.8.1", + "from": "webpack-dev-middleware@>=1.6.1 <2.0.0", + "resolved": "https://registry.npmjs.org/webpack-dev-middleware/-/webpack-dev-middleware-1.8.1.tgz", + "dependencies": { + "memory-fs": { + "version": "0.3.0", + "from": "memory-fs@>=0.3.0 <0.4.0", + "resolved": "https://registry.npmjs.org/memory-fs/-/memory-fs-0.3.0.tgz" + } + } + }, + "webpack-sources": { + "version": "0.1.2", + "from": "webpack-sources@>=0.1.0 <0.2.0", + "resolved": "https://registry.npmjs.org/webpack-sources/-/webpack-sources-0.1.2.tgz", + "dependencies": { + "source-map": { + "version": "0.5.6", + "from": "source-map@>=0.5.3 <0.6.0", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.6.tgz" + } + } + }, + "websocket-driver": { + "version": "0.6.5", + "from": "websocket-driver@>=0.5.1", + "resolved": "https://registry.npmjs.org/websocket-driver/-/websocket-driver-0.6.5.tgz" + }, + "websocket-extensions": { + "version": "0.1.1", + "from": "websocket-extensions@>=0.1.1", + "resolved": "https://registry.npmjs.org/websocket-extensions/-/websocket-extensions-0.1.1.tgz" + }, + "which-module": { + "version": "1.0.0", + "from": "which-module@>=1.0.0 <2.0.0", + "resolved": "https://registry.npmjs.org/which-module/-/which-module-1.0.0.tgz" + }, + "window-size": { + "version": "0.1.0", + "from": "window-size@0.1.0", + "resolved": "https://registry.npmjs.org/window-size/-/window-size-0.1.0.tgz" + }, + "wordwrap": { + "version": "0.0.2", + "from": "wordwrap@0.0.2", + "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.2.tgz" + }, + "wrap-ansi": { + "version": "2.0.0", + "from": "wrap-ansi@>=2.0.0 <3.0.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-2.0.0.tgz" + }, + "wrappy": { + "version": "1.0.2", + "from": "wrappy@>=1.0.0 <2.0.0", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz" + }, + "write-file-atomic": { + "version": "1.2.0", + "from": "write-file-atomic@>=1.1.2 <2.0.0", + "resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-1.2.0.tgz" + }, + "xdg-basedir": { + "version": "2.0.0", + "from": "xdg-basedir@>=2.0.0 <3.0.0", + "resolved": "https://registry.npmjs.org/xdg-basedir/-/xdg-basedir-2.0.0.tgz" + }, + "xhr2": { + "version": "0.1.3", + "from": "xhr2@>=0.1.3 <0.2.0", + "resolved": "https://registry.npmjs.org/xhr2/-/xhr2-0.1.3.tgz" + }, + "xtend": { + "version": "4.0.1", + "from": "xtend@>=4.0.0 <5.0.0", + "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz" + }, + "y18n": { + "version": "3.2.1", + "from": "y18n@>=3.2.1 <4.0.0", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-3.2.1.tgz" + }, + "yargs": { + "version": "4.8.1", + "from": "yargs@>=4.7.1 <5.0.0", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-4.8.1.tgz", + "dependencies": { + "cliui": { + "version": "3.2.0", + "from": "cliui@>=3.2.0 <4.0.0", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-3.2.0.tgz" + }, + "lodash.assign": { + "version": "4.2.0", + "from": "lodash.assign@>=4.0.3 <5.0.0", + "resolved": "https://registry.npmjs.org/lodash.assign/-/lodash.assign-4.2.0.tgz" + }, + "window-size": { + "version": "0.2.0", + "from": "window-size@>=0.2.0 <0.3.0", + "resolved": "https://registry.npmjs.org/window-size/-/window-size-0.2.0.tgz" + } + } + }, + "yargs-parser": { + "version": "2.4.1", + "from": "yargs-parser@>=2.4.1 <3.0.0", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-2.4.1.tgz", + "dependencies": { + "camelcase": { + "version": "3.0.0", + "from": "camelcase@>=3.0.0 <4.0.0", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-3.0.0.tgz" + }, + "lodash.assign": { + "version": "4.2.0", + "from": "lodash.assign@>=4.0.6 <5.0.0", + "resolved": "https://registry.npmjs.org/lodash.assign/-/lodash.assign-4.2.0.tgz" + } + } + }, + "zone.js": { + "version": "0.6.23", + "from": "zone.js@0.6.23", + "resolved": "https://registry.npmjs.org/zone.js/-/zone.js-0.6.23.tgz" + } + } +} diff --git a/workingUIKIT/package.json b/workingUIKIT/package.json new file mode 100644 index 00000000..06548ad4 --- /dev/null +++ b/workingUIKIT/package.json @@ -0,0 +1,109 @@ +{ + "name": "universal-starter", + "version": "2.0.0", + "description": "Angular 2 Universal starter kit by @AngularClass", + "repository": { + "type": "git", + "url": "https://github.com/angular/universal-starter.git" + }, + "scripts": { + "watch": "node --max_old_space_size=4096 node_modules/webpack/bin/webpack.js --watch", + "watch:dev": "npm run server & npm run watch", + "clean:dist": "rimraf dist", + "clean:ngc": "rimraf **/*.ngfactory.ts **/*.css.shim.ts", + "prebuild": "npm run clean:dist", + "build": "webpack --progress", + "build:prod:ngc": "npm run clean:ngc && npm run ngc && npm run clean:dist && npm run build:prod", + "build:prod:ngc:json": "npm run clean:ngc && npm run ngc && npm run clean:dist && npm run build:prod:json", + "build:prod": "node --max_old_space_size=4096 node_modules/webpack/bin/webpack.js --config webpack.prod.config.ts", + "build:prod:json": "webpack --config webpack.prod.config.ts --json | webpack-bundle-size-analyzer", + "ngc": "ngc -p tsconfig.aot.json", + "prestart": "npm run build", + "minify": "uglifyjs dist/client/main.bundle.js --screw-ie8 --compress --mangle --output dist/client/main.bundle.min.js", + "minify-test": "uglifyjs dist/client/main.bundle.js --output dist/client/main.xmin.js", + "server": "nodemon dist/server/index.js", + "debug:server": "node-nightly --inspect --debug-brk dist/server/index.js", + "start": "npm run server", + "debug:start": "npm run build && npm run debug:server", + "predebug": "npm run build", + "debug:build": "node-nightly --inspect --debug-brk node_modules/webpack/bin/webpack.js", + "debug:build:prod": "node-nightly --inspect --debug-brk node_modules/webpack/bin/webpack.js --config webpack.prod.config.ts", + "debug": "node --debug-brk dist/server/index.js" + }, + "license": "MIT", + "contributors": [ + "AngularClass ", + "PatrickJS ", + "Jeff Whelpley ", + "Jeff Cross ", + "Mark Pieszak " + ], + "dependencies": { + "@angular/common": "~2.1.2", + "@angular/compiler": "~2.1.2", + "@angular/compiler-cli": "~2.1.2", + "@angular/core": "~2.1.2", + "@angular/forms": "~2.1.2", + "@angular/http": "~2.1.2", + "@angular/platform-browser": "~2.1.2", + "@angular/platform-browser-dynamic": "~2.1.2", + "@angular/platform-server": "~2.1.2", + "@angular/router": "~3.1.2", + "@angular/upgrade": "~2.1.2", + "@angularclass/bootloader": "~1.0.1", + "@angularclass/idle-preload": "~1.0.4", + "@types/clipboard": "^1.5.31", + "angular2-express-engine": "~2.1.0-rc.1", + "angular2-platform-node": "~2.1.0-rc.1", + "angular2-universal": "~2.1.0-rc.1", + "angular2-universal-polyfills": "~2.1.0-rc.1", + "base64url": "^2.0.0", + "body-parser": "^1.15.2", + "citation-js": "^0.3.0-2", + "clipboard": "^1.5.16", + "compression": "^1.6.2", + "express": "^4.14.0", + "js.clone": "0.0.3", + "methods": "~1.1.2", + "morgan": "^1.7.0", + "preboot": "~4.5.2", + "rxjs": "5.0.0-beta.12", + "ts-md5": "^1.2.0", + "webfontloader": "^1.6.26", + "zone.js": "~0.6.26" + }, + "devDependencies": { + "@types/morgan": "^1.7.32", + "@types/body-parser": "0.0.29", + "@types/compression": "0.0.29", + "@types/cookie-parser": "^1.3.29", + "@types/express": "^4.0.32", + "@types/express-serve-static-core": "^4.0.33", + "@types/hammerjs": "^2.0.32", + "@types/mime": "0.0.28", + "@types/node": "^6.0.38", + "@types/serve-static": "^1.7.27", + "@types/webfontloader": "^1.6.27", + "@ngtools/webpack": "~1.1.7", + "angular2-template-loader": "^0.4.0", + "awesome-typescript-loader": "^2.2.4", + "cookie-parser": "^1.4.3", + "imports-loader": "^0.6.5", + "json-loader": "^0.5.4", + "nodemon": "^1.10.0", + "raw-loader": "^0.5.1", + "reflect-metadata": "0.1.8", + "rimraf": "^2.5.4", + "string-replace-loader": "^1.0.5", + "ts-helpers": "^1.1.2", + "ts-node": "^1.3.0", + "typescript": "2.0.2", + "uglify-js": "^2.7.4", + "v8-lazy-parse-webpack-plugin": "^0.3.0", + "webpack": "2.1.0-beta.27", + "webpack-bundle-analyzer": "1.4.1", + "webpack-dev-middleware": "^1.8.4", + "webpack-dev-server": "2.1.0-beta.11", + "webpack-merge": "~0.16.0" + } +} diff --git a/workingUIKIT/package.json_ b/workingUIKIT/package.json_ new file mode 100644 index 00000000..81ae0ea2 --- /dev/null +++ b/workingUIKIT/package.json_ @@ -0,0 +1,81 @@ +{ + "name": "universal-starter", + "version": "2.0.0", + "description": "Angular 2 Universal starter kit by @AngularClass", + "repository": { + "type": "git", + "url": "https://github.com/angular/universal-starter.git" + }, + "scripts": { + "watch": "webpack --watch", + "prebuild": "rimraf dist", + "build": "webpack", + "build:prod": "webpack --progress -p", + "prestart": "npm run build", + "server": "nodemon dist/server/index.js", + "debug:server": "node-nightly --inspect --debug-brk dist/server/index.js", + "start": "npm run server", + "debug:start": "npm run build && npm run debug:server", + "predebug": "npm run build", + "debug:build": "node-nightly --inspect --debug-brk node_modules/webpack/bin/webpack.js", + "debug": "node --debug-brk dist/server/index.js" + }, + "license": "MIT", + "contributors": [ + "AngularClass ", + "PatrickJS ", + "Jeff Whelpley ", + "Jeff Cross ", + "Mark Pieszak " + ], + "dependencies": { + "@angular/common": "2.0.0", + "@angular/compiler": "2.0.0", + "@angular/core": "2.0.0", + "@angular/forms": "2.0.0", + "@angular/http": "2.0.0", + "@angular/platform-browser": "2.0.0", + "@angular/platform-browser-dynamic": "2.0.0", + "@angular/platform-server": "2.0.0", + "@angular/router": "3.0.0", + "@ng-bootstrap/ng-bootstrap": "^1.0.0-alpha.6", + "angular2-express-engine": "~2.0.11", + "angular2-platform-node": "~2.0.11", + "angular2-universal": "~2.0.11", + "angular2-universal-polyfills": "~2.0.11", + "body-parser": "^1.15.2", + "bootstrap": "^4.0.0-alpha.4", + "express": "^4.14.0", + "methods": "~1.1.2", + "ng2-webstorage": "^1.2.2", + "rxjs": "5.0.0-beta.12", + "zone.js": "0.6.23" + }, + "devDependencies": { + "@angularclass/resolve-angular-routes": "^1.0.9", + "@types/body-parser": "0.0.29", + "@types/compression": "0.0.29", + "@types/cookie-parser": "^1.3.29", + "@types/express": "^4.0.32", + "@types/express-serve-static-core": "^4.0.33", + "@types/hammerjs": "^2.0.32", + "@types/mime": "0.0.28", + "@types/node": "^6.0.38", + "@types/serve-static": "^1.7.27", + "angular2-template-loader": "^0.4.0", + "cookie-parser": "^1.4.3", + "imports-loader": "^0.6.5", + "json-loader": "^0.5.4", + "nodemon": "^1.10.0", + "raw-loader": "^0.5.1", + "rimraf": "^2.5.4", + "string-replace-loader": "github:gdi2290/string-replace-loader", + "ts-loader": "^0.8.2", + "ts-node": "^1.3.0", + "typescript": "2.0.0", + "webpack": "2.1.0-beta.22", + "webpack-dev-middleware": "^1.6.1", + "webpack-dev-server": "^2.1.0-beta.0", + "webpack-merge": "^0.13.0" + } +} diff --git a/workingUIKIT/src/__workaround.browser.ts b/workingUIKIT/src/__workaround.browser.ts new file mode 100644 index 00000000..026f505f --- /dev/null +++ b/workingUIKIT/src/__workaround.browser.ts @@ -0,0 +1,21 @@ + +/* + * THIS IS TEMPORARY TO PATCH 2.1.1+ Core bugs + */ + +/* tslint:disable */ +let __compiler__ = require('@angular/compiler'); +import { __platform_browser_private__ } from '@angular/platform-browser'; +import { __core_private__ } from '@angular/core'; +if (!__core_private__['ViewUtils']) { + __core_private__['ViewUtils'] = __core_private__['view_utils']; +} + + + +if (__compiler__ && __compiler__.SelectorMatcher && __compiler__.CssSelector) { + (__compiler__).__compiler_private__ = { + SelectorMatcher: __compiler__.SelectorMatcher, + CssSelector: __compiler__.CssSelector + } +} diff --git a/workingUIKIT/src/__workaround.node.ts b/workingUIKIT/src/__workaround.node.ts new file mode 100644 index 00000000..ed39c8d3 --- /dev/null +++ b/workingUIKIT/src/__workaround.node.ts @@ -0,0 +1,44 @@ + +/* + * THIS IS TEMPORARY TO PATCH 2.1.1+ Core bugs + */ + +/* tslint:disable */ +let __compiler__ = require('@angular/compiler'); +import { __platform_browser_private__ } from '@angular/platform-browser'; +import { __core_private__ } from '@angular/core'; +let patch = false; +if (!__core_private__['ViewUtils']) { + patch = true; + __core_private__['ViewUtils'] = __core_private__['view_utils']; +} + + + +if (__compiler__ && __compiler__.SelectorMatcher && __compiler__.CssSelector) { + patch = true; + (__compiler__).__compiler_private__ = { + SelectorMatcher: __compiler__.SelectorMatcher, + CssSelector: __compiler__.CssSelector + } +} + +if (patch) { + var __universal__ = require('angular2-platform-node/__private_imports__'); + __universal__.ViewUtils = __core_private__['view_utils']; + __universal__.CssSelector = __universal__.CssSelector || __compiler__.CssSelector; + __universal__.SelectorMatcher = __universal__.SelectorMatcher || __compiler__.SelectorMatcher; +} + +// Fix Material Support +function universalMaterialSupports(eventName: string): boolean { return Boolean(this.isCustomEvent(eventName)); } +__platform_browser_private__.HammerGesturesPlugin.prototype.supports = universalMaterialSupports; +// End Fix Material Support + +// Fix Universal Style +import { NodeDomRootRenderer, NodeDomRenderer } from 'angular2-universal/node'; +function renderComponentFix(componentProto: any) { + return new NodeDomRenderer(this, componentProto, this._animationDriver); +} +NodeDomRootRenderer.prototype.renderComponent = renderComponentFix; +// End Fix Universal Style diff --git a/workingUIKIT/src/angular2-meta.ts b/workingUIKIT/src/angular2-meta.ts new file mode 100644 index 00000000..5f4f48e3 --- /dev/null +++ b/workingUIKIT/src/angular2-meta.ts @@ -0,0 +1,216 @@ +/** + * @license + * Copyright Google Inc. All Rights Reserved. + * + * Use of this source code is governed by an MIT-style license that can be + * found in the LICENSE file at https://angular.io/license + */ + +import {Injectable, Inject} from '@angular/core'; +// es6-modules are used here +import {DomAdapter, getDOM} from '@angular/platform-browser/src/dom/dom_adapter'; +import {DOCUMENT} from '@angular/platform-browser'; +/** + * Represent meta element. + * + * ### Example + * + * ```ts + * { name: 'application-name', content: 'Name of my application' }, + * { name: 'description', content: 'A description of the page', id: 'desc' } + * // ... + * // Twitter + * { name: 'twitter:title', content: 'Content Title' } + * // ... + * // Google+ + * { itemprop: 'name', content: 'Content Title' }, + * { itemprop: 'description', content: 'Content Title' } + * // ... + * // Facebook / Open Graph + * { property: 'fb:app_id', content: '123456789' }, + * { property: 'og:title', content: 'Content Title' } + * ``` + * + * @experimental + */ +export interface MetaDefinition { + charset?: string; + content?: string; + httpEquiv?: string; + id?: string; + itemprop?: string; + name?: string; + property?: string; + scheme?: string; + url?: string; + [prop: string]: string; +} + +/** + * A service that can be used to get and add meta tags. + * + * @experimental + */ +@Injectable() +export class Meta { + private _dom: DomAdapter = getDOM(); + constructor( @Inject(DOCUMENT) private _document: any) { } + /** + * Sets the title of the page + */ + setTitle(title: string) { + this._document.title = title + } + /** + * Adds a new meta tag to the dom. + * + * ### Example + * + * ```ts + * const name: MetaDefinition = {name: 'application-name', content: 'Name of my application'}; + * const desc: MetaDefinition = {name: 'description', content: 'A description of the page'}; + * const tags: HTMLMetaElement[] = this.meta.addTags([name, desc]); + * ``` + * + * @param tags + * @returns {HTMLMetaElement[]} + */ + addTags(...tags: Array): HTMLMetaElement[] { + const presentTags = this._flattenArray(tags); + if (presentTags.length === 0) return []; + return presentTags.map((tag: MetaDefinition) => this._addInternal(tag)); + } + + /** + * Gets the meta tag by the given selector. Returns element or null + * if there's no such meta element. + * + * ### Example + * + * ```ts + * const meta: HTMLMetaElement = this.meta.getTag('name=description'); + * const twitterMeta: HTMLMetaElement = this.meta.getTag('name="twitter:title"'); + * const fbMeta: HTMLMetaElement = this.meta.getTag('property="fb:app_id"'); + * ``` + * + * @param selector + * @returns {HTMLMetaElement} + */ + getTag(selector: string): HTMLMetaElement { + if (!selector) return null; + return this._dom.query(`meta[${selector}]`); + } + + /** + * Updates the meta tag with the given selector. + * + * * ### Example + * + * ```ts + * const meta: HTMLMetaElement = this.meta.updateTag('name=description', {name: 'description', + * content: 'New description'}); + * console.log(meta.content); // 'New description' + * ``` + * + * @param selector + * @param tag updated tag definition + * @returns {HTMLMetaElement} + */ + updateTag(selector: string, tag: MetaDefinition): HTMLMetaElement { + const meta: HTMLMetaElement = this.getTag(selector); + if (!meta) { + // create element if it doesn't exist + return this._addInternal(tag); + } + return this._prepareMetaElement(tag, meta); + } + + updateMeta(name, content) { + const head = this._document.head; + let childNodesAsList = this._dom.childNodesAsList(head); + let metaEl = childNodesAsList.find(el => el['attribs'] ? el['attribs'].name == name : false); + if (metaEl) metaEl['attribs'].content = content; + } + updateProperty(property, content) { + const head = this._document.head; + let childNodesAsList = this._dom.childNodesAsList(head); + let metaEl = childNodesAsList.find(el => el['attribs'] ? el['attribs'].property == property : false); + if (metaEl) metaEl['attribs'].content = content; + } + + /** + * Removes meta tag with the given selector from the dom. + * + * ### Example + * + * ```ts + * this.meta.removeTagBySelector('name=description'); + * ``` + * + * @param selector + */ + removeTagBySelector(selector: string): void { + const meta: HTMLMetaElement = this.getTag(selector); + this.removeTagElement(meta); + } + + /** + * Removes given meta element from the dom. + * + * ### Example + * ```ts + * const elem: HTMLMetaElement = this.meta.getTag('name=description'); + * this.meta.removeTagElement(elem); + * ``` + * + * @param meta meta element + */ + removeTagElement(meta: HTMLMetaElement): void { + if (meta) { + this._removeMetaElement(meta); + } + } + + private _addInternal(tag: MetaDefinition): HTMLMetaElement { + const meta: HTMLMetaElement = this._createMetaElement(); + this._prepareMetaElement(tag, meta); + this._appendMetaElement(meta); + return meta; + } + + private _createMetaElement(): HTMLMetaElement { + return this._dom.createElement('meta') as HTMLMetaElement; + } + + private _prepareMetaElement(tag: MetaDefinition, el: HTMLMetaElement): HTMLMetaElement { + Object.keys(tag).forEach((prop: string) => this._dom.setAttribute(el, prop, tag[prop])); + return el; + } + + // private _appendMetaElement(meta: HTMLMetaElement): void { + // const head = this._dom.getElementsByTagName(this._dom.defaultDoc(), 'head')[0]; + // this._dom.appendChild(head, meta); + // } + private _appendMetaElement(meta: HTMLMetaElement): void { + const head = this._document.head; + this._dom.appendChild(head, meta); + } + private _removeMetaElement(meta: HTMLMetaElement): void { + const head = this._dom.parentElement(meta); + this._dom.removeChild(head, meta); + } + + private _flattenArray(input: any[], out: any[] = []): any[] { + if (input) { + for (let i = 0; i < input.length; i++) { + const item: any = input[i]; + if (Array.isArray(item)) { + this._flattenArray(item, out); + } else if (item) { + out.push(item); + } + } + } + return out; + } +} diff --git a/workingUIKIT/src/app/app-routing.module.ts b/workingUIKIT/src/app/app-routing.module.ts new file mode 100644 index 00000000..617677d5 --- /dev/null +++ b/workingUIKIT/src/app/app-routing.module.ts @@ -0,0 +1,177 @@ +import { NgModule } from '@angular/core'; +import { RouterModule } from '@angular/router'; + +export function getPublicationModule() { + return System.import('./landingPages/publication/publication.module' + (process.env.AOT ? '.ngfactory' : '')) + .then(mod => mod[(process.env.AOT ? 'PublicationModuleNgFactory' : 'PublicationModule')]); +} +export function getDatasetModule() { + return System.import('./landingPages/dataset/dataset.module' + (process.env.AOT ? '.ngfactory' : '')) + .then(mod => mod[(process.env.AOT ? 'DatasetModuleNgFactory' : 'DatasetModule')]); +} +export function getPersonModule() { + return System.import('./landingPages/person/person.module' + (process.env.AOT ? '.ngfactory' : '')) + .then(mod => mod[(process.env.AOT ? 'PersonModuleNgFactory' : 'PersonModule')]); +} +export function getProjectModule() { + return System.import('./landingPages/project/project.module' + (process.env.AOT ? '.ngfactory' : '')) + .then(mod => mod[(process.env.AOT ? 'ProjectModuleNgFactory' : 'ProjectModule')]); +} +export function getOrganizationModule() { + return System.import('./landingPages/organization/organization.module' + (process.env.AOT ? '.ngfactory' : '')) + .then(mod => mod[(process.env.AOT ? 'OrganizationModuleNgFactory' : 'OrganizationModule')]); +} +export function getDepositDatasetsModule() { + return System.import('./deposit/datasets/depositDatasets.module' + (process.env.AOT ? '.ngfactory' : '')) + .then(mod => mod[(process.env.AOT ? 'DepositDatasetsModuleNgFactory' : 'DepositDatasetsModule')]); +} +export function getDepositDatasetsResultsModule() { + return System.import('./deposit/datasets/depositDatasetsResults.module' + (process.env.AOT ? '.ngfactory' : '')) + .then(mod => mod[(process.env.AOT ? 'DepositDatasetsResultsModuleNgFactory' : 'DepositDatasetsResultsModule')]); +} + +export function getDepositPublicationsModule() { + return System.import('./deposit/publications/depositPublications.module' + (process.env.AOT ? '.ngfactory' : '')) + .then(mod => mod[(process.env.AOT ? 'DepositPublicationsModuleNgFactory' : 'DepositPublicationsModule')]); +} +export function getDepositPublicationsResultsModule() { + return System.import('./deposit/publications/depositPublicationsResults.module' + (process.env.AOT ? '.ngfactory' : '')) + .then(mod => mod[(process.env.AOT ? 'DepositPublicationsResultsModuleNgFactory' : 'DepositPublicationsResultsModule')]); +} +export function getDataProviderModule() { + return System.import('./landingPages/dataProvider/dataProvider.module' + (process.env.AOT ? '.ngfactory' : '')) + .then(mod => mod[(process.env.AOT ? 'DataProviderModuleNgFactory' : 'DataProviderModule')]); +} +export function getMainSearchModule() { + return System.import('./searchPages/find/mainSearch.module' + (process.env.AOT ? '.ngfactory' : '')) + .then(mod => mod[(process.env.AOT ? 'MainSearchModuleNgFactory' : 'MainSearchModule')]); +} +export function getSearchPublicationsModule() { + return System.import('./searchPages/simple/searchPublications.module' + (process.env.AOT ? '.ngfactory' : '')) + .then(mod => mod[(process.env.AOT ? 'SearchPublicationsModuleNgFactory' : 'SearchPublicationsModule')]); +} +export function getSearchDatasetsModule() { + return System.import('./searchPages/simple/searchDatasets.module' + (process.env.AOT ? '.ngfactory' : '')) + .then(mod => mod[(process.env.AOT ? 'SearchDatasetsModuleNgFactory' : 'SearchDatasetsModule')]); +} +export function getSearchProjectsModule() { + return System.import('./searchPages/simple/searchProjects.module' + (process.env.AOT ? '.ngfactory' : '')) + .then(mod => mod[(process.env.AOT ? 'SearchProjectsModuleNgFactory' : 'SearchProjectsModule')]); +} +export function getSearchOrganizationsModule() { + return System.import('./searchPages/simple/searchOrganizations.module' + (process.env.AOT ? '.ngfactory' : '')) + .then(mod => mod[(process.env.AOT ? 'SearchOrganizationsModuleNgFactory' : 'SearchOrganizationsModule')]); +} +export function getSearchDataProvidersModule() { + return System.import('./searchPages/simple/searchDataProviders.module' + (process.env.AOT ? '.ngfactory' : '')) + .then(mod => mod[(process.env.AOT ? 'SearchDataProvidersModuleNgFactory' : 'SearchDataProvidersModule')]); +} +export function getSearchPeopleModule() { + return System.import('./searchPages/simple/searchPeople.module' + (process.env.AOT ? '.ngfactory' : '')) + .then(mod => mod[(process.env.AOT ? 'SearchPeopleModuleNgFactory' : 'SearchPeopleModule')]); +} +export function getCompatibleDataProvidersModule() { + return System.import('./searchPages/dataProviders/compatibleDataProviders.module' + (process.env.AOT ? '.ngfactory' : '')) + .then(mod => mod[(process.env.AOT ? 'CompatibleDataProvidersModuleNgFactory' : 'CompatibleDataProvidersModule')]); +} +export function getEntityRegistriesModule() { + return System.import('./searchPages/dataProviders/entityRegistries.module' + (process.env.AOT ? '.ngfactory' : '')) + .then(mod => mod[(process.env.AOT ? 'EntityRegistriesModuleNgFactory' : 'EntityRegistriesModule')]); +} +export function getAdvancedSearchPublicationsModule() { + return System.import('./searchPages/advanced/advancedSearchPublications.module' + (process.env.AOT ? '.ngfactory' : '')) + .then(mod => mod[(process.env.AOT ? 'AdvancedSearchPublicationsModuleNgFactory' : 'AdvancedSearchPublicationsModule')]); +} +export function getAdvancedSearchDatasetsModule() { + return System.import('./searchPages/advanced/advancedSearchDatasets.module' + (process.env.AOT ? '.ngfactory' : '')) + .then(mod => mod[(process.env.AOT ? 'AdvancedSearchDatasetsModuleNgFactory' : 'AdvancedSearchDatasetsModule')]); +} +export function getAdvancedSearchOrganizationsModule() { + return System.import('./searchPages/advanced/advancedSearchOrganizations.module' + (process.env.AOT ? '.ngfactory' : '')) + .then(mod => mod[(process.env.AOT ? 'AdvancedSearchOrganizationsModuleNgFactory' : 'AdvancedSearchOrganizationsModule')]); +} +export function getAdvancedSearchDataProvidersModule() { + return System.import('./searchPages/advanced/advancedSearchDataProviders.module' + (process.env.AOT ? '.ngfactory' : '')) + .then(mod => mod[(process.env.AOT ? 'AdvancedSearchDataProvidersModuleNgFactory' : 'AdvancedSearchDataProvidersModule')]); +} +export function getAdvancedSearchProjectsModule() { + return System.import('./searchPages/advanced/advancedSearchProjects.module' + (process.env.AOT ? '.ngfactory' : '')) + .then(mod => mod[(process.env.AOT ? 'AdvancedSearchProjectsModuleNgFactory' : 'AdvancedSearchProjectsModule')]); +} +export function getAdvancedSearchPeopleModule() { + return System.import('./searchPages/advanced/advancedSearchPeople.module' + (process.env.AOT ? '.ngfactory' : '')) + .then(mod => mod[(process.env.AOT ? 'AdvancedSearchPeopleModuleNgFactory' : 'AdvancedSearchPeopleModule')]); +} +export function gethtmlProjectReportModule() { + return System.import('./landingPages/htmlProjectReport/htmlProjectReport.module' + (process.env.AOT ? '.ngfactory' : '')) + .then(mod => mod[(process.env.AOT ? 'HtmlProjectReportModuleNgFactory' : 'HtmlProjectReportModule')]); +} +export function getMyClaimsModule() { + return System.import('./claims/myClaims/myClaims.module' + (process.env.AOT ? '.ngfactory' : '')) + .then(mod => mod[(process.env.AOT ? 'MyClaimsModuleNgFactory' : 'MyClaimsModule')]); +} + +export function getClaimsAdminModule() { + return System.import('./claims/claimsAdmin/claimsAdmin.module' + (process.env.AOT ? '.ngfactory' : '')) + .then(mod => mod[(process.env.AOT ? 'ClaimsAdminModuleNgFactory' : 'ClaimsAdminModule')]); +} + +export function getClaimsByTokenModule() { + return System.import('./claims/claimsByToken/claimsByToken.module' + (process.env.AOT ? '.ngfactory' : '')) + .then(mod => mod[(process.env.AOT ? 'ClaimsByTokenModuleNgFactory' : 'ClaimsByTokenModule')]); +} + +export function getLinkingModule() { + return System.import('./claims/linking/linkingGeneric.module' + (process.env.AOT ? '.ngfactory' : '')) + .then(mod => mod[(process.env.AOT ? 'LinkingGenericModuleNgFactory' : 'LinkingGenericModule')]); +} + +export function getDirectLinkingModule() { + return System.import('./claims/directLinking/directLinking.module' + (process.env.AOT ? '.ngfactory' : '')) + .then(mod => mod[(process.env.AOT ? 'DirectLinkingModuleNgFactory' : 'DirectLinkingModule')]); +} +export function getUserModule() { + return System.import('./login/user.module' + (process.env.AOT ? '.ngfactory' : '')) + .then(mod => mod[(process.env.AOT ? 'UserModuleNgFactory' : 'UserModule')]); +} +@NgModule({ + imports: [ + RouterModule.forChild([ + { path: '', redirectTo: '/search/find', pathMatch: 'full'}, + { path: 'search/publication', loadChildren: getPublicationModule }, + { path: 'search/dataset', loadChildren: getDatasetModule }, + { path: 'search/person', loadChildren: getPersonModule }, + { path: 'search/organization', loadChildren: getOrganizationModule }, + { path: 'search/project', loadChildren: getProjectModule }, + { path: 'search/dataprovider', loadChildren: getDataProviderModule }, + { path: 'participate/deposit-datasets', loadChildren: getDepositDatasetsModule }, + { path: 'participate/deposit-datasets-result', loadChildren: getDepositDatasetsResultsModule }, + { path: 'participate/deposit-publications', loadChildren: getDepositPublicationsModule }, + { path: 'participate/deposit-publications-result', loadChildren: getDepositPublicationsResultsModule }, + { path: 'search/find', loadChildren: getMainSearchModule }, + { path: 'search/find/publications', loadChildren: getSearchPublicationsModule }, + { path: 'search/find/datasets', loadChildren: getSearchDatasetsModule }, + { path: 'search/find/projects', loadChildren: getSearchProjectsModule }, + { path: 'search/find/dataproviders', loadChildren: getSearchDataProvidersModule }, + { path: 'search/find/organizations', loadChildren: getSearchOrganizationsModule }, + { path: 'search/find/people', loadChildren: getSearchPeopleModule }, + { path: 'search/data-providers', loadChildren: getCompatibleDataProvidersModule }, + { path: 'search/entity-registries', loadChildren: getEntityRegistriesModule }, + { path: 'search/advanced/publications', loadChildren: getAdvancedSearchPublicationsModule }, + { path: 'search/advanced/datasets', loadChildren: getAdvancedSearchDatasetsModule }, + { path: 'search/advanced/organizations', loadChildren: getAdvancedSearchOrganizationsModule }, + { path: 'search/advanced/dataproviders', loadChildren: getAdvancedSearchDataProvidersModule }, + { path: 'search/advanced/projects', loadChildren: getAdvancedSearchProjectsModule }, + { path: 'search/advanced/people', loadChildren: getAdvancedSearchPeopleModule }, + { path: 'project-report', loadChildren: gethtmlProjectReportModule }, + { path: 'myclaims', loadChildren: getMyClaimsModule }, + { path: 'claims', loadChildren: getClaimsAdminModule }, + { path: 'participate/claim', loadChildren: getLinkingModule }, + { path: 'participate/direct-claim', loadChildren: getDirectLinkingModule }, + { path: 'claims-project-manager', loadChildren: getClaimsByTokenModule }, + { path: 'user-info', loadChildren: getUserModule }, + + ]) + ], +}) +export class AppRoutingModule { } diff --git a/workingUIKIT/src/app/app.component.ts b/workingUIKIT/src/app/app.component.ts new file mode 100644 index 00000000..fde6260d --- /dev/null +++ b/workingUIKIT/src/app/app.component.ts @@ -0,0 +1,66 @@ +import { Component, Directive, ElementRef, Renderer, ChangeDetectionStrategy, ViewEncapsulation } from '@angular/core'; + +// +///////////////////////// +// ** Example Directive +// Notice we don't touch the Element directly + +@Directive({ + selector: '[xLarge]' +}) +export class XLargeDirective { + constructor(element: ElementRef, renderer: Renderer) { + // ** IMPORTANT ** + // we must interact with the dom through -Renderer- + // for webworker/server to see the changes + renderer.setElementStyle(element.nativeElement, 'fontSize', 'x-large'); + // ^^ + } +} + +@Component({ + changeDetection: ChangeDetectionStrategy.Default, + encapsulation: ViewEncapsulation.Emulated, + selector: 'app', + styles: [` + `], + template: ` + + + + +
+
+
+
+ +
+ +
+
+ + + + +
+
+
+ + 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 { + title = 'ftw'; +} diff --git a/workingUIKIT/src/app/app.module.ts b/workingUIKIT/src/app/app.module.ts new file mode 100755 index 00000000..354e42dc --- /dev/null +++ b/workingUIKIT/src/app/app.module.ts @@ -0,0 +1,31 @@ +import { NgModule } from '@angular/core'; +import { FormsModule } from '@angular/forms'; + + +import { SharedModule } from './shared/shared.module'; + +import { AppRoutingModule } from './app-routing.module'; +import { AppComponent, XLargeDirective } from './app.component'; +import {SharedComponentsModule} from './sharedComponents/sharedComponents.module'; //navbar +import { ErrorModule } from './error/error.module'; +import { CacheService } from './shared/cache.service'; +import { CookieLawModule } from './sharedComponents/cookie-law/cookie-law.module'; + +@NgModule({ + declarations: [ AppComponent, XLargeDirective ], + imports: [ + SharedModule, + + SharedComponentsModule, + AppRoutingModule, + ErrorModule, + CookieLawModule, + + ], exports:[], + providers:[CacheService] + +}) +export class AppModule { +} + +export { AppComponent } from './app.component'; diff --git a/workingUIKIT/src/app/claims/claim-utils/claim.ts b/workingUIKIT/src/app/claims/claim-utils/claim.ts new file mode 100644 index 00000000..b5378c5f --- /dev/null +++ b/workingUIKIT/src/app/claims/claim-utils/claim.ts @@ -0,0 +1,15 @@ +export class Claim { + id: string; + sourceType: string; + targetType: string; + sourceId: string; + targetId: string; + date: string; + DOI: string; + project: Project + userMail: string; + +} +export class Project{ + +} diff --git a/workingUIKIT/src/app/claims/claim-utils/claimContextSearchForm.component.ts b/workingUIKIT/src/app/claims/claim-utils/claimContextSearchForm.component.ts new file mode 100644 index 00000000..13c7675e --- /dev/null +++ b/workingUIKIT/src/app/claims/claim-utils/claimContextSearchForm.component.ts @@ -0,0 +1,228 @@ +import {Component, Input,Output, EventEmitter, ViewChild} from '@angular/core'; +import {Observable} from 'rxjs/Observable'; +import { Router} from '@angular/router'; +import {ContextsService} from './service/contexts.service'; +import {ClaimContext} from './claimEntities.class'; +import { StaticAutoCompleteComponent } from '../../utils/staticAutoComplete/staticAutoComplete.component'; +declare var UIkit:any; +import {Session} from '../../login/utils/helper.class'; +import {ErrorCodes} from '../../login/utils/guardHelper.class'; + +@Component({ + // moduleId: module.id, + selector: 'claim-contexts-search-form', + template: ` + +
+
Search for Communities:
+ + + + + +
+ + + + +
+ + + +
+ + ` + +}) +export class ClaimContextSearchFormComponent { +// @Input() public inline:boolean = false ; // for claimed started from landing pages +public showComponent:boolean = true ; // for claimed started from landing pages +@Input() public selectedList; +//The following need to be kept in case we have to save the current state +@Input() public projects; +@Input() public results; +@Input() public inlineEntity; +public selectedCommunityId:string = "0"; +public selectedCategoryId:string ="0"; +// @Output() contextSelected = new EventEmitter(); + +@ViewChild (StaticAutoCompleteComponent) autocomplete : StaticAutoCompleteComponent ; + +public query = ''; +public filteredList = []; +public communities:string[]; +public selectedCommunityLabel:string = "Community:"; + +public categories:string[]; +public selectedCategoryLabel:string ="Category:"; +public concepts = []; +public warningMessage = ""; +public infoMessage = ""; +public loading:boolean = false; +ngOnInit() { + this.getCommunities(); +} +constructor(private _contextService: ContextsService,private router: Router) { + +} + +select($event){ + var item = $event.value; + + var context: ClaimContext= { community: this.selectedCommunityLabel, category: this.selectedCategoryLabel, concept: item }; + var found:boolean = false; + this.warningMessage = ""; + for (var _i = 0; _i < this.selectedList.length; _i++) { + let item = this.selectedList[_i]; + if(item.concept.id == context.concept.id){ + found=true; + // this.warningMessage = "Concept already in selected list"; + } + } + if (!found) { + + this.selectedList.push(context); + UIkit.notify({ + message : 'A context is selected.', + status : 'info', + timeout : 1000, + pos : 'top-center' + }); + + }else{ + UIkit.notify({ + message : 'The context is already on your list.', + status : 'warning', + timeout : 1000, + pos : 'top-center' + }); + } +} + +getCommunities () { + if(!Session.isValidAndRemove()){ + this.saveStateAndRedirectLogin(); + + }else{ + this.loading = true; + var token=Session.getUserJwt(); + this._contextService.getCommunities(token).subscribe( + data => { + this.communities = data.communities; + this.loading = false; + }, + err => { + console.log(err); + this.loading = false; + } + ); + } + } + getCategories () { + console.log(" Getting Categories... "); + this.loading = true; + this.categories=[]; + if(this.selectedCommunityId != '0'){ + if(!Session.isValidAndRemove()){ + this.saveStateAndRedirectLogin(); + + }else{ + var token=Session.getUserJwt(); + this._contextService.getCategories(this.selectedCommunityId, token).subscribe( + data => { + this.categories = data.category; + this.concepts = []; + this.addCommunityInConcepts(); + this.filteredList = []; + if (this.query !== ""){ + var event = {value: ""}; + event.value = this.query; + } + this.loading = false; + }, + err => { + console.log(err); + this.loading = false; + } + ); + } + } + } + getConcepts () { + this.loading = true; + if(this.selectedCategoryId != '0'){ + if(!Session.isValidAndRemove()){ + this.saveStateAndRedirectLogin(); + }else{ + this.concepts = []; + this.addCommunityInConcepts(); + var token=Session.getUserJwt(); + this._contextService.getConcepts(this.selectedCategoryId, "",token).subscribe( + data => { + this.concepts = data; + this.addCommunityInConcepts(); + if (this.query !== ""){ + var event = {value: ""}; + event.value = this.query; + // this.filter(event); + } + this.loading = false; + }, + err => { + console.log(err); + this.loading = false; + } + ); + } + }else{ + this.concepts=[]; + this.loading = false; + } + } + communityChanged(communityId:string, communityLabel:string){ + console.log(communityId +" "+communityLabel); + console.log(this.selectedCommunityId +" "); + this.warningMessage = ""; + this.infoMessage = ""; + if(this.selectedCommunityId != communityId){ + this.selectedCommunityId = communityId; + this.selectedCommunityLabel = communityLabel; + this.getCategories(); + } + + } + categoryChanged(categoryId:string, categoryLabel:string){ + this.warningMessage = ""; + this.infoMessage = ""; + if(this.selectedCategoryId != categoryId){ + this.selectedCategoryId = categoryId; + this.selectedCategoryLabel = categoryLabel; + this.getConcepts(); + } + + } +addCommunityInConcepts(){ + this.concepts.push({"id":this.selectedCommunityId, "label":this.selectedCommunityLabel}); + this.autocomplete.updateList(this.concepts); +} +saveStateAndRedirectLogin(){ + if(this.projects != null){ + localStorage.setItem("projects", JSON.stringify(this.projects)); + } + localStorage.setItem("contexts", JSON.stringify(this.selectedList)); + if(this.results != null){ + localStorage.setItem("results", JSON.stringify(this.results)); + } + if(this.inlineEntity != null){ + localStorage.setItem("inlineEntity", JSON.stringify(this.inlineEntity)); + } + + this.router.navigate(['/user-info'], { queryParams: { "errorCode": ErrorCodes.NOT_VALID, "redirectUrl": this.router.url } }); +} +} diff --git a/workingUIKIT/src/app/claims/claim-utils/claimContextSearchForm.module.ts b/workingUIKIT/src/app/claims/claim-utils/claimContextSearchForm.module.ts new file mode 100644 index 00000000..345d2c93 --- /dev/null +++ b/workingUIKIT/src/app/claims/claim-utils/claimContextSearchForm.module.ts @@ -0,0 +1,20 @@ +import { NgModule } from '@angular/core'; + +import { SharedModule } from '../../shared/shared.module'; +import { ClaimContextSearchFormComponent } from './claimContextSearchForm.component'; + import{ContextsServiceModule} from './service/contextsService.module'; + import {StaticAutocompleteModule} from '../../utils/staticAutoComplete/staticAutoComplete.module'; + import { RouterModule } from '@angular/router'; + +@NgModule({ + imports: [ + SharedModule,RouterModule, + ContextsServiceModule, + StaticAutocompleteModule + + ], + declarations: [ + ClaimContextSearchFormComponent + ], exports: [ClaimContextSearchFormComponent ] +}) +export class ClaimContextSearchFormModule { } diff --git a/workingUIKIT/src/app/claims/claim-utils/claimEntities.class.ts b/workingUIKIT/src/app/claims/claim-utils/claimEntities.class.ts new file mode 100644 index 00000000..0430d5c7 --- /dev/null +++ b/workingUIKIT/src/app/claims/claim-utils/claimEntities.class.ts @@ -0,0 +1,37 @@ +//Classes used in linking / inlinelinking when selecting an entity +export class ClaimResult{ + public id: string; + public type: string; + public source: string; + public title: string; + public url: string; + public result: any; + public accessRights: string = "OPEN"; + public embargoEndDate: string; + public date: string; + public authors: string[] =[]; + public publisher: string; + public description: string; + public resourceType:string; +} +export class ClaimProject{ + public funderId: string; + public funderName: string; + public projectId: string; + public projectName: string; + public projectAcronym: string; + public startDate: string; + public endDate: string; + public code: string; + public jurisdiction: string; + public fundingLevel0: string; + + +} + +export class ClaimContext{ + public community: string; + public category: string; + public concept:any; + +} diff --git a/workingUIKIT/src/app/claims/claim-utils/claimProjectSearchForm.component.ts b/workingUIKIT/src/app/claims/claim-utils/claimProjectSearchForm.component.ts new file mode 100644 index 00000000..9edd91f1 --- /dev/null +++ b/workingUIKIT/src/app/claims/claim-utils/claimProjectSearchForm.component.ts @@ -0,0 +1,194 @@ +import {Component, Input,Output, ElementRef, EventEmitter, ViewChild} from '@angular/core'; +import {Observable} from 'rxjs/Observable'; +import {SearchProjectsService} from '../../services/searchProjects.service'; +import {ProjectService} from '../../landingPages/project/project.service'; +import {ModalLoading} from '../../utils/modal/loading.component'; +import { Subject } from 'rxjs/Subject'; +import {ClaimProject} from './claimEntities.class'; +declare var UIkit:any; +@Component({ + selector: 'claim-projects-search-form', + // styleUrls: ['/autoComplete.component.css'], + + template: ` +
+
+ + +
+ Search for projects: +
+ + +
+
+ + + +
+ ` + +}) +export class ClaimProjectsSearchFormComponent { + ngOnInit() { + this.getFunders(); + } + @ViewChild (ModalLoading) loading : ModalLoading ; + + // @Input() public inline: boolean = false ; // for claimed started from landing pages + public query = ''; + @Input() public selectedProjects=[] ; + public elementRef; + + public funders:string[]; + public selectedFunderId:string ="0"; + selectedFunderName:string ="Select funder:"; + @Output() projectSelected = new EventEmitter(); + + public projects:string[]; + public warningMessage = ""; + public infoMessage = ""; + + // public searchTermStream = new Subject(); + // filtered: Observable<{}> = this.searchTermStream + // .debounceTime(300).distinctUntilChanged() + // .switchMap((term: string) => this._projectService.searchForProjectsObs(term, this.selectedFunderId)); + public tries:number = 0 ; + public keywordlimit = 3; + +constructor(private _service: ProjectService, private _projectService: SearchProjectsService, myElement: ElementRef) { + this.elementRef = myElement; +} + + +// search() { +// console.info("heeere "+this.query ); +// this.infoMessage = ""; +// // this.filtered = []; +// if(this.query == ""){ +// this.tries = 0; +// this.warningMessage = ""; +// } else if(this.query && this.query.length < this.keywordlimit){ +// this.tries++; +// if(this.tries == this.keywordlimit -1 ){ +// this.warningMessage = "Type at least " + this.keywordlimit + " characters"; +// this.tries = 0; +// } +// }else{ +// console.info("doo the search "+this.query ); +// +// this.tries = 0; +// this.warningMessage = ""; +// this.searchTermStream.next(this.query); +// +// } +// +// } +select(item){ + this.query = ""; + // this.searchTermStream.next(this.query); //clear + item = item.value; + var project: ClaimProject = new ClaimProject(); + project.funderId = (this.selectedFunderId=="0")?item.funderId:this.selectedFunderId; + project.funderName = (this.selectedFunderId=="0")?item.funderName:this.selectedFunderName; + project.projectId = item.id; + project.projectName = item.projectName; + project.projectAcronym = item.projectAcronym; + project.startDate = item.startDate; + project.endDate = item.endDate; + project.code = item.code; + project.jurisdiction = item.jurisdiction; + project.fundingLevel0 = item.fundingLevel0; + + console.log(item); + + + // this._service.getProjectDates(project.projectId).subscribe( + // data => { + // project.startDate = data.startDate; + // project.endDate = data.endDate; + // }, + // err => console.log(err) + // ); + var index:number =this.selectedProjects.indexOf(project); + var found:boolean = false; + this.warningMessage = ""; + + for (var _i = 0; _i < this.selectedProjects.length; _i++) { + let item = this.selectedProjects[_i]; + if(item.projectId == project.projectId){ + found=true; + this.warningMessage = "Project already in selected list"; + } + } + + if (!found) { + this.selectedProjects.push(project); + this.projectSelected.emit({ + value: true + }); + UIkit.notify({ + message : 'A project "'+item.projectName+'" is selected.', + status : 'info', + timeout : 1000, + pos : 'top-center' + }); + }else{ + UIkit.notify({ + message : 'The project is already on your list.', + status : 'warning', + timeout : 1000, + pos : 'top-center' + }); + } + +} +showItem(item):string{ + return ((item.field[1]['@value'])?item.field[1]['@value']+" - ":"" ) + item.field[3]['@value']; +} +remove(item){ + var index:number =this.selectedProjects.indexOf(item); + if (index > -1) { + this.selectedProjects.splice(index, 1); + } + +} +handleClick(event){ + var clickedComponent = event.target; + var inside = false; + do { + if (clickedComponent === this.elementRef.nativeElement) { + inside = true; + } + clickedComponent = clickedComponent.parentNode; + } while (clickedComponent); + +} +getFunders () { + console.info("Getting Funders...."); + this._projectService.getFunders().subscribe( + data => { + this.funders = data[1]; + + }, + err => console.log(err) + ); + } + + getProjects () { + if(this.selectedFunderId != '0'){ + + } + } +funderChanged(funderId:string, funderName:string){ + this.selectedFunderId = funderId; + this.selectedFunderName = funderName; + console.info("Selected funder:"+this.selectedFunderId+ ' name:'+funderName ); + +} + +} diff --git a/workingUIKIT/src/app/claims/claim-utils/claimProjectSearchForm.module.ts b/workingUIKIT/src/app/claims/claim-utils/claimProjectSearchForm.module.ts new file mode 100644 index 00000000..ab5c00bb --- /dev/null +++ b/workingUIKIT/src/app/claims/claim-utils/claimProjectSearchForm.module.ts @@ -0,0 +1,25 @@ +import { NgModule } from '@angular/core'; + +import { SharedModule } from '../../shared/shared.module'; +import { CommonModule } from '@angular/common'; + +import {ClaimProjectsSearchFormComponent} from './claimProjectSearchForm.component'; +import {LoadingModalModule} from '../../utils/modal/loadingModal.module'; + +import {ProjectServiceModule} from '../../landingPages/project/projectService.module'; +import {ProjectsServiceModule} from '../../services/projectsService.module'; +import {EntitiesAutocompleteModule} from '../../utils/entitiesAutoComplete/entitiesAutoComplete.module'; + + @NgModule({ + imports: [ + SharedModule, CommonModule, LoadingModalModule, ProjectServiceModule, ProjectsServiceModule, EntitiesAutocompleteModule + ], + providers:[ + ], + declarations: [ + ClaimProjectsSearchFormComponent + + ], + exports: [ClaimProjectsSearchFormComponent ] +}) +export class ClaimProjectsSearchFormModule { } diff --git a/workingUIKIT/src/app/claims/claim-utils/claimResultSearchForm.component.html b/workingUIKIT/src/app/claims/claim-utils/claimResultSearchForm.component.html new file mode 100644 index 00000000..eb6de00c --- /dev/null +++ b/workingUIKIT/src/app/claims/claim-utils/claimResultSearchForm.component.html @@ -0,0 +1,182 @@ +
+ Search for research results: +
+ + + + +
+
+ +
+ +
    +
  • +
    + + + + +
    +
    + +
    +
    +
    +
      +
    • +
      + {{item.title}} + {{item.title}} + +
      + + + +
    • +
    +
    +
    +
  • +
  • +
    + + + + +
    +
    + +
    +
    +
    +
      +
    • +
      + {{result['title'].name}} + {{result['title'].name}} + +
      + + + + +
    • +
    +
    +
    +
  • +
  • +
    + + + +
    No results found
    + +
    +
    Not the right author? Choose one of these: + + + + + + + +
    + Results for + {{authorGivenName}} {{authorFamilyName}} - {{authorId}} : + + +
    +
    + +
    + +
    +
    +
      +
    • +
      + {{item['work-title']['title'].value}} + +
      + + + +
    • +
    +
    No results found
    +
    +
    +
    +
  • +
  • + + + + +
    +
    +
    + +
    +
    +
    +
      +
    • +
      + {{item.title}} + {{item.title}} + + +
      + + + +
    • +
    + +
    +
    +
  • +
  • + + + + +
    +
    +
    + +
    +
    +
    +
      +
    • +
      + {{result['title'].name}} + {{result['title'].name}} + + + +
      + + + + +
    • +
    +
    +
    +
  • +
+
diff --git a/workingUIKIT/src/app/claims/claim-utils/claimResultSearchForm.component.ts b/workingUIKIT/src/app/claims/claim-utils/claimResultSearchForm.component.ts new file mode 100644 index 00000000..4ef71519 --- /dev/null +++ b/workingUIKIT/src/app/claims/claim-utils/claimResultSearchForm.component.ts @@ -0,0 +1,582 @@ +import {Component, Input, Output, EventEmitter} from '@angular/core'; +import { ActivatedRoute } from '@angular/router'; +import {SearchCrossrefService} from '../claim-utils/service/searchCrossref.service'; +import {SearchOrcidService} from '../claim-utils/service/searchOrcid.service'; +import {SearchPublicationsService} from '../../services/searchPublications.service'; +import { SearchDataciteService } from '../claim-utils/service/searchDatacite.service'; +import {SearchDatasetsService} from '../../services/searchDatasets.service'; + +import { ErrorCodes} from '../../utils/properties/openaireProperties'; +import {ClaimResult} from '../claim-utils/claimEntities.class'; +import{DOI} from '../../utils/string-utils.class'; + +@Component({ + selector: 'claim-result-search-form', + templateUrl: 'claimResultSearchForm.component.html', + +}) +export class ClaimResultSearchFormComponent { + constructor (private _searchDataciteService: SearchDataciteService, private _searchDatasetsService:SearchDatasetsService, + private _searchCrossrefService: SearchCrossrefService,private _searchOrcidService: SearchOrcidService, private _searchPublicationsService: SearchPublicationsService, + private route: ActivatedRoute) { + var myDate = new Date(); + this.todayDate = myDate.getFullYear()+ "-" +(myDate.getMonth() + 1) + "-" + myDate.getDate() ; + this.nextDate = (myDate.getFullYear()+100)+ "-" +(myDate.getMonth() + 1) + "-" + myDate.getDate() ; + + } + ngOnInit() { + if(this.keyword !=null && this.keyword.length > 0){ + this.search(); + } +} + + + page : number = 1; + size:number = 10; + navigateTo: string = "Search"; + source: string = "datacite"; + type : string = "dataset"; + showSearchResults:boolean=false; + // searchType ="publication"; + @Input() public select:boolean = true ; + @Input() public keyword:string = ''; + @Input() public selectedResults:ClaimResult[]; + // @Output() datasetsChange = new EventEmitter(); + // @Output() publicationsChange = new EventEmitter(); + + // @Output() resultsChange = new EventEmitter(); + + public errorCodes:ErrorCodes = new ErrorCodes(); + + dataciteResults=[]; + dataciteResultsNum:number = null; + // dataciteResultsNum : Observable = null; + dataciteStatus = this.errorCodes.NONE; + datacitePage : number = 1; + + openaireData=[]; + openaireDataNum:number = 0 ; + openaireDataStatus = this.errorCodes.NONE; + openaireDataPage : number = 1; + + public warningMessage = ""; + public infoMessage = ""; + + public todayDate = ''; + public nextDate = ''; + public DOIs:string[] = []; + sub: any; + + + + crossrefResults=[]; + crossrefResultsNum : number = null; + crossrefPage : number = 1; + crossrefStatus:number = this.errorCodes.NONE; + + openairePubs = []; + openairePubsNum: number ; + openairePubsPage : number = 1; + openairePubsStatus:number = this.errorCodes.NONE; + + orcidResults: string[]; + orcidResultsNum: number ; + totalPages: number; + orcidResultsToShow: string[]; + orcidPage : number = 1; + orcidStatus:number = this.errorCodes.NONE; + authorId: string; + authorGivenName: string; + authorFamilyName: string; + + authorIds: string[]; + authorGivenNames: string[]; + authorFamilyNames: string[]; + + authorsNum : number ; + + + + search(){ + this.warningMessage = ""; + this.infoMessage = ""; + this.DOIs = DOI.getDOIsFromString(this.keyword); + this.getCrossrefResults(this.keyword, this.size,1); + this.searchOrcid(this.keyword); + this.searchOpenairePubs(this.keyword, this.size, 1); + this.searchDatacite(this.keyword,10,1); + this.searchOpenaireData(this.keyword,10,1); + this.showSearchResults = true; + + } + +private getCrossrefResults (term: string, size : number, page : number) { + this.crossrefStatus = this.errorCodes.LOADING; + if( this.DOIs.length > 0 ){ + this._searchCrossrefService.searchCrossrefByDOIs(this.DOIs).subscribe( + data => { + if(data != null) { + this.crossrefResults = data.items; + this.crossrefPage=page; + this.crossrefResultsNum = data['total-results']; + if(data.items == 0){ + this._searchCrossrefService.searchCrossrefResults(term, size, page).subscribe( + data => { + if(data != null) { + this.crossrefResults = data.items; + this.crossrefPage=page; + this.crossrefResultsNum = data['total-results']; + this.crossrefStatus = this.errorCodes.DONE; + + }else{ + this.crossrefStatus = this.errorCodes.ERROR; + } + }, + err =>{ + console.log(err.status); + this.crossrefStatus = this.errorCodes.ERROR; + } + + ); + }else{ + this.crossrefStatus = this.errorCodes.DONE; + } + } + }, + err => { + //console.log(err); + this._searchCrossrefService.searchCrossrefResults(term, size, page).subscribe( + data => { + this.crossrefResults = data.items; + this.crossrefPage=page; + this.crossrefResultsNum = data['total-results']; + this.crossrefStatus = this.errorCodes.DONE; + + }, + err => { + console.log(err.status); + this.crossrefStatus = this.errorCodes.ERROR; + } + + ); + } + ); + + }else{ + + + this._searchCrossrefService.searchCrossrefResults(term, size, page).subscribe( + data => { + if(data != null) { + this.crossrefResults = data.items; + this.crossrefPage=page; + this.crossrefResultsNum = data['total-results']; + this.crossrefStatus = this.errorCodes.DONE; + + }else{ + this.crossrefStatus = this.errorCodes.ERROR; + } + + }, + err => { + console.log(err.status); + this.crossrefStatus = this.errorCodes.ERROR; + } + ); + } + } + private searchOpenairePubs(term: string, size : number, page : number) { + + if(this.DOIs.length > 0 ){ + this.openairePubsStatus = this.errorCodes.LOADING; + this._searchPublicationsService.searchPublicationsByDois(this.DOIs, null, page, size, []).subscribe( + data => { + if(data != null) { + this.openairePubsPage=page; + this.openairePubsNum = data[0]; + this.openairePubs = data[1]; + this.openairePubsStatus = this.errorCodes.DONE; + if(this.openairePubsNum == 0){ + this.openairePubsStatus = this.errorCodes.NONE; + } + }else { + this.openairePubsStatus = this.errorCodes.ERROR; + } + }, + err => { + this.openairePubsStatus = this.errorCodes.ERROR; + console.log(err.status); + } + ); + }else{ + this.openairePubsStatus = this.errorCodes.LOADING; + this._searchPublicationsService.searchPublications('q='+term, null, page, size, []).subscribe( + data => { + if(data != null) { + this.openairePubsPage=page; + this.openairePubsNum = data[0]; + this.openairePubs = data[1]; + this.openairePubsStatus = this.errorCodes.DONE; + if(this.openairePubsNum == 0){ + this.openairePubsStatus = this.errorCodes.NONE; + } + }else { + this.openairePubsStatus = this.errorCodes.ERROR; + } + }, + err => { + this.openairePubsStatus = this.errorCodes.ERROR; + console.log(err.status); + } + ); + } + } + + private searchOrcid (term: string) { + if(this.DOIs.length > 0){ + this.orcidStatus = this.errorCodes.NONE; + return; + } + this.orcidStatus = this.errorCodes.LOADING; + this.authorIds = new Array(); + this.authorGivenNames = new Array(); + this.authorFamilyNames = new Array(); + + this.getOrcidAuthor(term); + + console.info('searchOrcid in searchOrcid file'); + } + + private readData(data: any) { + this.authorIds.push(data[2].path); + + if(data[0] != null) { + this.authorGivenNames.push(data[0].value); + } else { + this.authorGivenNames.push(""); + } + if(data[1] != null) { + this.authorFamilyNames.push(data[1].value); + } else { + this.authorFamilyNames.push(""); + } + } + + private getOrcidAuthor (term: string) { + this.orcidResultsNum = null; + + //passing structures in order to fill them in service + this._searchOrcidService.searchOrcidAuthor(term, this.authorIds, + this.authorGivenNames, this.authorFamilyNames).subscribe( + data => { + if(data != null && data == true) { + this.getOrcidResultsByIndex(0); + } + + this.orcidStatus = this.errorCodes.NONE; + + }, + err => this.errorHandler(err, term) + + ); + } + + private errorHandler(err: any, term: string) { + if(err.status == 404){ + this.getOrcidAuthors(term); + } else { + this.orcidStatus = this.errorCodes.ERROR; + console.log(err.status); + + } + } + + private getOrcidAuthors (term: string) { + this.orcidResultsNum = null; + + //passing structures in order to fill them in service + this._searchOrcidService.searchOrcidAuthors(term, this.authorIds, + this.authorGivenNames, this.authorFamilyNames).subscribe( + data => { + if(data != null && data == true) { + this.getOrcidResultsByIndex(0); + }else{ + this.orcidStatus = this.errorCodes.ERROR; + } + + }, + err => { + this.orcidStatus = this.errorCodes.ERROR; + console.log(err.status); + } + ); + } + + + private getOrcidResultsByIndex (index:number) { + if(this.authorIds.length > index) { + this.orcidStatus = this.errorCodes.LOADING; + let id = this.authorIds[index]; + this.authorGivenName = this.authorGivenNames[index]; + this.authorFamilyName = this.authorFamilyNames[index]; + this.getOrcidResultsById(id); + } + } + private getOrcidResultsById (id:string) { + + var index = this.authorIds.indexOf(id); + this.authorGivenName = this.authorGivenNames[index]; + this.authorFamilyName = this.authorFamilyNames[index]; + this.authorId = id; + console.info("getOrcidResultsById: "+id); + this._searchOrcidService.searchOrcidPublications(id).subscribe( + data => { + if(data != null) { + this.orcidResults=data['orcid-work']; + this.orcidResultsNum = data['orcid-work'].length; + this.orcidPage = 1; + if((this.orcidResultsNum % this.size) == 0){ + this.totalPages=parseInt(''+(this.orcidResultsNum/this.size)); + } else{ + this.totalPages=parseInt(''+(this.orcidResultsNum/this.size+1)); + } + + this.orcidResultsToShow = this.orcidResults.slice(0,10); + + this.orcidStatus = this.errorCodes.DONE; + if(this.orcidResultsNum == 0){ + this.orcidStatus = this.errorCodes.NONE; + } + } else { + this.orcidResultsNum = 0; + this.totalPages=0; + this.orcidStatus = this.errorCodes.NONE; + } + + }, + err => { + console.log(err.status); + this.orcidStatus = this.errorCodes.ERROR; + } + ); + + + } + +/* +Is it USED??? +private remove(item){ + this.warningMessage = ""; + this.infoMessage = ""; + var index:number =this.selectedResults.indexOf(item); + item.selected=false; + if (index > -1) { + this.selectedResults.splice(index, 1); + // this.publicationsChange.emit({ + // value: this.selectedResults + // }); + } + + }*/ +private crossrefPageChange($event) { + this.crossrefPage=$event.value; + this.crossrefResults=[]; + console.log("Crossref chaenged "+this.crossrefPage); + this.getCrossrefResults(this.keyword,this.size,this.crossrefPage); +} +private orcidPageChange($event) { + this.orcidPage=$event.value; + this.orcidResultsToShow=[]; + this.orcidResultsToShow = this.orcidResults.slice(($event.value-1)*this.size, $event.value*this.size); +} +private openairePubsPageChange($event) { + this.openairePubsPage=$event.value; + this.searchOpenairePubs(this.keyword,this.size,this.openairePubsPage); +} +datacitePageChange($event) { + this.datacitePage=$event.value; + this.dataciteResults=[]; + this.searchDatacite(this.keyword,10,this.datacitePage); + this.warningMessage = ""; + this.infoMessage = ""; + +} +openaireDataPageChange($event) { + this.openaireDataPage=$event.value; + this.openaireData=[]; + this.searchOpenaireData(this.keyword,10,this.openaireDataPage); + this.warningMessage = ""; + this.infoMessage = ""; + +} + + + private isSelected(id:string){ + + var found:boolean = false; + this.warningMessage = ""; + for (var _i = 0; _i < this.selectedResults.length; _i++) { + let item = this.selectedResults[_i]; + if(item.id == id){ + found=true; + this.warningMessage = "Publication already in selected list"; + } + } + return found; + + + } + // isSelected(id:string){ + // + // var found:boolean = false; + // this.warningMessage = ""; + // for (var _i = 0; _i < this.selectedResults.length; _i++) { + // let item = this.selectedResults[_i]; + // if(item.id == id){ + // found=true; + // break; + // } + // } + // return found; + // } + private searchDatacite (term: string, size : number, page : number) { + this.getDataciteResults(term,size,page); + this.warningMessage = ""; + this.infoMessage = ""; + + } + private searchOpenaireData (term: string, size : number, page : number) { + if(this.DOIs.length > 0 ){ + this.openaireDataStatus = this.errorCodes.LOADING; + this._searchDatasetsService.searchDatasetsByDois(this.DOIs, null, page, size, []).subscribe( + data => { + if(data != null) { + this.openaireDataPage=page; + this.openaireDataNum = data[0]; + this.openaireData = data[1]; + this.openaireDataStatus = this.errorCodes.DONE; + if(this.openaireDataNum == 0){ + this.openaireDataStatus = this.errorCodes.NONE; + } + } + }, + err => { + this.openaireDataStatus = this.errorCodes.ERROR; + console.log(err.status); + } + ); + }else{ + this._searchDatasetsService.searchDatasets('q='+term+'', null, page, size, []).subscribe( + data => { + if(data != null) { + this.openaireDataPage=page; + this.openaireDataNum = data[0]; + this.openaireData = data[1]; + this.openaireDataStatus = this.errorCodes.DONE; + if(this.openaireDataNum == 0){ + this.openaireDataStatus = this.errorCodes.NONE; + } + } + }, + err => { + this.openaireDataStatus = this.errorCodes.ERROR; + console.log(err.status); + } + ); + } + this.warningMessage = ""; + this.infoMessage = ""; + + } + private getDataciteResults (term: string, size : number, page : number) { + this._searchDataciteService.searchDataciteResults(term, size, page).subscribe( + data => { + this.dataciteResults = data.docs; + this.datacitePage=page; + this.dataciteResultsNum = data.numFound; + this.dataciteStatus = this.errorCodes.DONE; + + + }, + err => { + this.dataciteStatus = this.errorCodes.ERROR; + console.log(err); + } + + ); + } + + add(item, itemId,itemSource,itemType, itemUrl, itemTitle, date, accessmode){ + console.log(' adding ' + itemType + " From " + itemSource+" "+ itemTitle); + var result: ClaimResult = new ClaimResult(); + result.id = itemId; + result.type = itemType; + result.source = itemSource; + + result.title = (Array.isArray(itemTitle) && itemTitle.length > 0 )?itemTitle[0]:itemTitle; + result.url = itemUrl; + result.accessRights = 'OPEN'; + result.embargoEndDate = this.nextDate; + result.date = date; + result.result = item; + if(item.publisher){ + result.publisher = item.publisher; + } + + if(itemSource == 'datacite'){ + if(item.creator){ + result.authors =[] + for(var i=0; i< item.creator.length; i++){ + result.authors.push(item.creator[i]); + } + } + + // result = {id: itemId, type :itemType, source : itemSource, title: itemTitle,url: itemUrl, result: item, accessRights: 'OPEN', embargoEndDate: this.nextDate, date : date}; + }else if (itemSource == 'openaire'){ + //TODO put right access rights + // result = {id:itemId, type :itemType, source : itemSource, title: itemTitle,url: itemUrl, result: item, accessRights: accessMode, embargoEndDate: this.nextDate, date: date}; + // result = {id:itemId, type :itemType, source : itemSource, title: itemTitle,url: itemUrl, result: item, accessRights: accessmode, embargoEndDate: this.nextDate, date : date}; + result.embargoEndDate = accessmode; + + }else if(itemSource == 'crossref'){ + date = (date == null) ? null : date.substring(0,10); + result.date = date; + result.resourceType = item.type; + result.description = item.abstract; + if(item.author){ + result.authors =[] + for(var i=0; i< item.author.length; i++){ + result.authors.push(item.author[i].family +" "+ item.author[i].given ); + } + } + // result = {id: itemId, type :itemType, source : itemSource, title: itemTitle,url: itemUrl, result: item, accessRights: 'OPEN', embargoEndDate: this.nextDate, date: date}; + }else if (itemSource == 'orcid'){ + date = (date == null) ? null : date + "-01.-01" + result.date = date; + if(item['work-type']){ + result.resourceType = item.type; + + } + if(item.contributors){ + result.authors =[] + for(var i=0; i< item.contributors.length; i++){ + result.authors.push(item.contributors[i]); + } + } + // result = {id:itemId, type :itemType, source : itemSource, title: itemTitle,url: itemUrl, result: item, accessRights: 'OPEN', embargoEndDate: this.nextDate, date: date}; + } + var found:boolean = this.isSelected( result.id); + + this.warningMessage = ""; + if (!found) { + this.selectedResults.push(result); + // this.resultsChange.emit({ + // value: this.selectedResults + // }); + }else{ + this.warningMessage = "Dataset already in selected list"; + } + + } + +} diff --git a/workingUIKIT/src/app/claims/claim-utils/claimResultSearchForm.module.ts b/workingUIKIT/src/app/claims/claim-utils/claimResultSearchForm.module.ts new file mode 100644 index 00000000..a7874d35 --- /dev/null +++ b/workingUIKIT/src/app/claims/claim-utils/claimResultSearchForm.module.ts @@ -0,0 +1,28 @@ +import { NgModule } from '@angular/core'; + +import { SharedModule } from '../../shared/shared.module'; +import { CommonModule } from '@angular/common'; +import {ClaimResultSearchFormComponent} from './claimResultSearchForm.component'; + +import {SearchDataciteService} from './service/searchDatacite.service'; +import {SearchCrossrefServiceModule} from './service/searchCrossrefService.module'; +import {SearchOrcidService} from './service/searchOrcid.service'; + +import {PublicationsServiceModule} from '../../services/publicationsService.module'; +import {DatasetsServiceModule} from '../../services/datasetsService.module'; +import {PagingModule } from '../../utils/paging.module'; + + @NgModule({ + imports: [ + SharedModule, CommonModule, PublicationsServiceModule, DatasetsServiceModule, PagingModule, SearchCrossrefServiceModule + ], + providers:[ + SearchDataciteService, SearchOrcidService + ], + declarations: [ + ClaimResultSearchFormComponent + + ], + exports: [ClaimResultSearchFormComponent ] +}) +export class ClaimResultSearchFormModule { } diff --git a/workingUIKIT/src/app/claims/claim-utils/displayClaims/displayClaims.component.html b/workingUIKIT/src/app/claims/claim-utils/displayClaims/displayClaims.component.html new file mode 100644 index 00000000..919b9e77 --- /dev/null +++ b/workingUIKIT/src/app/claims/claim-utils/displayClaims/displayClaims.component.html @@ -0,0 +1,89 @@ + +
+ + +
+ Filter By: +
+
+ + + + +
+ +
+
+ +
+ +
+ +
+ Show + + + Showing {{(size*page - size +1)}} to {{(size*page>resultsNum)?resultsNum:(size*page)}} of {{resultsNum}} claims + +
+
+ + +
+ An Error occured. +
+
+ User session is not valid. Please login again. +
+ + + +
+
+
+ You have selected {{selected.length}} claim(s) +
+
+
+ +
+ +
+
+ + +
+
No entries found.
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Research Result Link to Claimed by Claimed Date
{{claim.userMail}}{{claim.date}}
+ + + diff --git a/workingUIKIT/src/app/claims/claim-utils/displayClaims/displayClaims.component.ts b/workingUIKIT/src/app/claims/claim-utils/displayClaims/displayClaims.component.ts new file mode 100644 index 00000000..ef5fea12 --- /dev/null +++ b/workingUIKIT/src/app/claims/claim-utils/displayClaims/displayClaims.component.ts @@ -0,0 +1,465 @@ +import {Component, ViewChild, Input} from '@angular/core'; +import {Location} from '@angular/common'; +import {Observable} from 'rxjs/Observable'; +import {ActivatedRoute, Router} from '@angular/router'; +import {ClaimsService} from '../service/claims.service'; +import {ModalLoading} from '../../../utils/modal/loading.component'; +import {AlertModal} from '../../../utils/modal/alert'; +import {Session} from '../../../login/utils/helper.class'; + + +@Component({ + selector: 'displayClaims', + templateUrl: 'displayClaims.component.html', + providers:[ ClaimsService] + +}) +export class DisplayClaimsComponent { + constructor (private _claimService: ClaimsService, private route: ActivatedRoute, private _router:Router, private location: Location) { + } + + ngOnInit() { + this.sub = this.route.queryParams.subscribe(params => { + if( this.myClaims){ + this.fetchBy = "User"; + this.fetchId = Session.getUserEmail(); + }else{ + + this.fetchBy = params['fetchBy']; + this.fetchBy = (this.types.indexOf(this.fetchBy) != -1)? this.fetchBy:'All'; + this.fetchId = params['fetchId']; + this.fetchId = this.fetchId?this.fetchId:''; + + } + + let page = (params['page']=== undefined)?1:+params['page']; + let size = (params['size']=== undefined)?10:+params['size']; + + this.keyword = (params['keyword']?params['keyword']:""); + this.inputkeyword = this.keyword; + this.page = ( page <= 0 ) ? 1 : page; + this.size = ( size <= 0 ) ? 10 : size; + this.entityTypes = []//(params['types']?params['types']:[]); + this.setTypes(params['types']); // check the appropriate checkboxes + this.setSortby(params['sort']); + this.getClaims(); + + }); + + } + ngOnDestroy() { + this.sub.unsubscribe(); + } + sub: any; + //string because comes as input from component directive + @Input() enableDelete: boolean = false; + @Input() myClaims: boolean= false ; + @Input() isAdmin:boolean = false; + page : number; + size:number; + sizes = [10,20,30,50]; + keyword:string; // the keyword string to give to the request as parameter + inputkeyword:string; // the string written in the input field (keyword=inputkeyword when its length is bigger than 3 and the user stops typing) + lengths = [10,20,30,50]; + types = ["All","Project","Context","Result","User"]; + @Input() fetchBy:string; + @Input() fetchId:string; + + navigateTo: string = "Claims"; + resultsNum: number ; + claims: string[]; + + @ViewChild (ModalLoading) loading : ModalLoading ; + + //checkboxes: + publicationCB = false; + datasetCB = false; + contextCB = false; + projectCB = false; + entityTypes : string[] =[] ; + + descending = true; + sortby = "date"; + + selected=[]; + deleteMessage:string = ""; + showErrorMessage:boolean = false; + userValidMessage:string = ""; + + //params for pagingFormatter to use when navigate to page + params; + @ViewChild(AlertModal) alert; + + claimsDeleted:number = 0; + + getClaims () { + if(!Session.isValidAndRemove()){ + this.userValidMessage = "User session has expired. Please login again."; + + }else{ + var token=Session.getUserJwt(); + this.selected=[]; + var types = ''; + this.showErrorMessage = false; + for (var type of this.entityTypes){ + types+=(types.length>0?'&':'')+"types="+type; + } + if(this.fetchBy =="Project" ){ + this._claimService.getClaimsByProject(this.size,this.page,this.fetchId,this.keyword,this.sortby,this.descending, types,token).subscribe( + data => { + this.claims = data.data; + this.resultsNum= data.total; + }, + err => { + console.log(err); + this.showErrorMessage = true; + } + ); + }else if(this.fetchBy =="User"){ + this._claimService.getClaimsByUser(this.size,this.page,this.fetchId,this.keyword,this.sortby,this.descending, types,token).subscribe( + data => { + this.claims = data.data; + this.resultsNum= data.total; + }, + err => { + console.log(err); + this.showErrorMessage = true; + } + ); + }else if(this.fetchBy =="Result"){ + this._claimService.getClaimsByResult(this.size,this.page,this.fetchId,this.keyword,this.sortby,this.descending, types,token).subscribe( + data => { + this.claims = data.data; + this.resultsNum= data.total; + }, + err => { + console.log(err); + this.showErrorMessage = true; + } + ); + }else if(this.fetchBy =="Context"){ + this._claimService.getClaimsBycontext(this.size,this.page,this.fetchId,this.keyword,this.sortby,this.descending, types,token).subscribe( + data => { + this.claims = data.data; + this.resultsNum= null; + this.resultsNum= data.total;//data.length; //TODO get the total results num + }, + err => { + console.log(err); + this.showErrorMessage = true; + } + ); + }else{ + this._claimService.getClaims(this.size,this.page,this.keyword,this.sortby,this.descending, types,token).subscribe( + data => { + this.claims = data.data; + this.resultsNum = null; + this.resultsNum= data.total;//data.length; //TODO get the total results num + }, + err => { + console.log(err); + this.showErrorMessage = true; + } + ); + } + } +} + + + goTo(page:number = 1){ + + this.page = page; + + this.location.go(location.pathname,this.getParametersString()); + this.getClaims(); + } + getParameters(){ + var params = {} + if(this.myClaims){ + params={ page: this.page, size: this.size, types: this.entityTypes, keyword : this.keyword, sort: this.getSortby() }; + }else{ + params={ page: this.page, size: this.size, types: this.entityTypes, fetchBy: this.fetchBy, fetchId:this.fetchId, keyword : this.keyword, sort: this.getSortby() }; + } + return params; + } + + getParametersString(){ + var params=''; + params+=(this.page==1?"":(params.length>0?'&':'')+"page="+this.page); + params+=(this.size==10?"":(params.length>0?'&':'')+"size="+this.size); + // params+=(this.entityTypes==''?"":(params.length>0?'&':'')+"types="+this.entityTypes); + var types=""; + for (var type of this.entityTypes){ + types+=(types.length>0?',':'')+type; + } + params+=(types.length>0)?"types="+types:""; + + if(this.isAdmin ){ + params+=(this.fetchBy=='All'?"":(params.length>0?'&':'')+"fetchBy="+this.fetchBy); + params+=(this.fetchId==''?"":(params.length>0?'&':'')+"fetchId="+this.fetchId); + } + params+=(this. getSortby()=='datedesc'?"":(params.length>0?'&':'')+"sort="+this. getSortby()); + params+=(this.keyword==''?"":(params.length>0?'&':'')+"keyword="+this.keyword); + return params; + } + changeSize(size: number ){ + this.goTo(); + } + + clearFilters(){ + this.keyword = ''; + this.inputkeyword = ''; + this.publicationCB = false; + this.projectCB = false; + this.datasetCB = false; + this.contextCB = false; + this.entityTypes = []; + this.goTo(); + } + + changeOrderby(sortby:string){ + if(sortby==this.sortby){ + this.descending = !this.descending; + }else{ + this.sortby = sortby; + this.descending = false; + } + this.goTo(); + } + setSortby(sortby:string){ + if(!sortby|| sortby == "datedesc"){ + this.descending = true; + this.sortby = "date"; + }else if(sortby == "dateasc"){ + this.descending = false; + this.sortby = "date"; + }else if(sortby == "userasc"){ + this.descending = false; + this.sortby = "user"; + }else if(sortby == "userdesc"){ + this.descending = true; + this.sortby = "user"; + }if(sortby =="sourceasc"){ + this.descending = false; + this.sortby = "source"; + }else if(sortby == "sourcedesc"){ + this.descending = true; + this.sortby = "source"; + }else if(sortby == "targetasc"){ + this.descending = false; + this.sortby = "target"; + }else if(sortby == "targetdesc"){ + this.descending = true; + this.sortby = "target"; + } + } + getSortby():string{ + if(this.descending){ + return this.sortby+"desc"; + }else{ + return this.sortby+"asc"; + } + + } + changeType(){ + this.entityTypes = []; + if(this.publicationCB){ + this.entityTypes.push('publication'); + } + if(this.datasetCB){ + this.entityTypes.push('dataset'); + } + if(this.projectCB){ + this.entityTypes.push('project'); + } + if(this.contextCB){ + this.entityTypes.push('context'); + } + + this.goTo(); + } + setTypes(types:string){ + if(!types){ + return; + } + if(types.length > 0){ + this.entityTypes = []; + if(types.indexOf("publication")!=-1){ + this.publicationCB = true; + this.entityTypes.push("publication"); + } + if(types.indexOf("dataset")!=-1){ + this.datasetCB = true; + this.entityTypes.push("dataset"); + } + if(types.indexOf("project")!=-1){ + this.projectCB = true; + this.entityTypes.push("project"); + } + if(types.indexOf("context")!=-1){ + this.contextCB = true; + this.entityTypes.push("context"); + } + } + if(this.publicationCB && this.datasetCB && this.contextCB && this.projectCB){ + this.entityTypes=[]; + } + } + changekeyword(){ + + if(this.inputkeyword.length >= 3 || this.inputkeyword.length == 0 ){ + this.keyword = this.inputkeyword; + this.page = 1; + this.goTo(); + } + + } + select(item:any,event){ + this.deleteMessage=""; + var value = event.currentTarget.checked; + if(value){ + this.selected.push(item); + }else{ + for (var _i = 0; _i < this.selected.length; _i++) { + let claim = this.selected[_i]; + if(claim['id'] == item.id){ + this.selected.splice(_i, 1); + } + } + + + } + } + selectAll(){ + this.selected = []; + for (var _i = 0; _i < this.claims.length; _i++) { + let claim = this.claims[_i]; + this.selected.push(claim); + } + this.deleteMessage = ""; + } + deselectAll(){ + this.selected = []; + this.deleteMessage=""; + } + isSelected(id:string){ + for (var _i = 0; _i < this.selected.length; _i++) { + let claim = this.selected[_i]; + if(claim['id'] == id){ + return true; + } + } + return false; + } + + + confirmOpen(){ + if(this.selected.length <= 0){ + + }else{ + this.alert.cancelButton = true; + this.alert.okButton = true; + this.alert.alertTitle = "Delete "+this.selected.length+" claim(s)"; + this.alert.message = this.selected.length+" claims will be deleted. Do you want to proceed? "; + this.alert.okButtonText = "Yes"; + this.alert.cancelButtonText = "No"; + this.alert.open(); + } + } + confirmClose(data){ + this.delete(); + } + delete(){ + this.deleteMessage=""; + this.loading.open(); + this.claimsDeleted = 0; + var ids = []; + for (var i = 0; i < this.selected.length; i++){ + var id =this.selected[i].id; + ids.push(id); + // var selected =this.selected[i].id; + // console.warn("Deleting claim with id:"+id); + // this.deleteById(id); + //TODO for multiple concurrent + } + this.batchDeleteById(ids); + } + + deleteById(id:string){ + if(!Session.isValidAndRemove()){ + this.userValidMessage = "User session has expired. Please login again."; + + }else{ + var token=Session.getUserJwt(); + console.log("Deleting claim with id:"+id); + // this._claimService.deleteClaimById(id); + this._claimService.deleteClaimById(id,token).subscribe( + res => { + console.log('Delete response'+res.code ); + console.log("Deleted claim with id:"+ id); + //remove this claim from the + let newClaims=this.claims; + for (var _i = 0; _i < this.claims.length; _i++) { + let claim = this.claims[_i]; + if(claim['id'] == id){ + newClaims.splice(_i, 1); + } + } + //TODO should call getClaims??? + this.claimsDeleted++; + this.claims = newClaims; + if(this.claimsDeleted == this.selected.length){ + this.resultsNum = this.resultsNum - this.selected.length; + this.loading.close(); + this.selected = []; + } + + + }); + } + } + batchDeleteById(ids:string[]){ + if(!Session.isValidAndRemove()){ + this.userValidMessage = "User session has expired. Please login again."; + + }else{ + var token=Session.getUserJwt(); + console.warn("Deleting claim with ids:"+ids); + this._claimService.deleteBulk(ids,token).subscribe( + res => { + console.info('Delete response'+res.code ); + console.warn("Deleted ids:"+ res.deletedIds); + console.warn("Not found ids:"+ res.notFoundIds); + //remove this claim from the + let newClaims=this.claims; + for(var id of res.deletedIds){ + for (var _i = 0; _i < this.claims.length; _i++) { + let claim = this.claims[_i]; + if(claim['id'] == id){ + newClaims.splice(_i, 1); + } + } + for (var _i = 0; _i < this.selected.length; _i++) { + let claim = this.selected[_i]; + if(claim['id'] == id){ + this.selected.splice(_i, 1); + } + } + } + this.claims = newClaims; + this.resultsNum = this.resultsNum - res.deletedIds.length; + this.loading.close(); + if(res.deletedIds.length>0){ + this.deleteMessage=this.deleteMessage+'
'+res.deletedIds.length+' claim(s) successfully deleted.
'; + } + if(res.notFoundIds.length>0){ + this.deleteMessage=this.deleteMessage+'
'+res.notFoundIds.length+' claim(s) couldn\'t be deleted.
'; + } + }); + } + } + pageChange($event) { + var page:number = +$event.value + this.goTo(page); + } +} diff --git a/workingUIKIT/src/app/claims/claim-utils/displayClaims/displayClaims.module.ts b/workingUIKIT/src/app/claims/claim-utils/displayClaims/displayClaims.module.ts new file mode 100644 index 00000000..095ab6c7 --- /dev/null +++ b/workingUIKIT/src/app/claims/claim-utils/displayClaims/displayClaims.module.ts @@ -0,0 +1,28 @@ +import { NgModule} from '@angular/core'; +import { CommonModule } from '@angular/common'; +import { FormsModule } from '@angular/forms'; +import {ClaimServiceModule} from '../service/claimsService.module'; +import {DisplayClaimsComponent} from './displayClaims.component'; +import {LoadingModalModule} from '../../../utils/modal/loadingModal.module'; +import {AlertModalModule} from '../../../utils/modal/alertModal.module'; +import {ClaimEntityFormatterModule} from '../entityFormatter/claimEntityFormatter.module'; +import {PagingModule } from '../../../utils/paging.module'; +// import { Claim } from '../claim'; +//helpers + + @NgModule({ + imports: [ + CommonModule, FormsModule, ClaimServiceModule, LoadingModalModule, AlertModalModule, +ClaimEntityFormatterModule, PagingModule + + ], + declarations: [ + DisplayClaimsComponent + + ], + providers: [ ], + exports: [ + DisplayClaimsComponent + ] +}) +export class DisplayClaimsModule { } diff --git a/workingUIKIT/src/app/claims/claim-utils/entityFormatter/claimEntityFormatter.component.ts b/workingUIKIT/src/app/claims/claim-utils/entityFormatter/claimEntityFormatter.component.ts new file mode 100644 index 00000000..f2611255 --- /dev/null +++ b/workingUIKIT/src/app/claims/claim-utils/entityFormatter/claimEntityFormatter.component.ts @@ -0,0 +1,36 @@ +import {Component, Input} from '@angular/core'; + +//Usage Example " " + +//externalUrl +@Component({ + selector: 'claim-entity', + template: ` + +
+ ({{type}}) + +
+
+ (Project) + +
+
+ (Context) +
{{entity.title}}
+
+ ` +}) + +export class ClaimEntityFormatter { + @Input() entity: string[]; + @Input() type: string; + + constructor () {} + + ngOnInit() { + + } + + +} diff --git a/workingUIKIT/src/app/claims/claim-utils/entityFormatter/claimEntityFormatter.module.ts b/workingUIKIT/src/app/claims/claim-utils/entityFormatter/claimEntityFormatter.module.ts new file mode 100644 index 00000000..01a1d0ac --- /dev/null +++ b/workingUIKIT/src/app/claims/claim-utils/entityFormatter/claimEntityFormatter.module.ts @@ -0,0 +1,24 @@ +import { NgModule} from '@angular/core'; +import { CommonModule } from '@angular/common'; +import { FormsModule } from '@angular/forms'; +import { RouterModule } from '@angular/router'; + +import {ProjectTitleFormatter} from './projectTitleFormatter.component'; +import {PublicationTitleFormatter} from './publicationTitleFormatter.component'; +import {ClaimEntityFormatter} from './claimEntityFormatter.component'; + + @NgModule({ + imports: [ + CommonModule, RouterModule + ], + declarations: [ + ProjectTitleFormatter, PublicationTitleFormatter, ClaimEntityFormatter + + ], + providers: [ ], + exports: [ + ProjectTitleFormatter, PublicationTitleFormatter, ClaimEntityFormatter + + ] +}) +export class ClaimEntityFormatterModule { } diff --git a/workingUIKIT/src/app/claims/claim-utils/entityFormatter/projectTitleFormatter.component.ts b/workingUIKIT/src/app/claims/claim-utils/entityFormatter/projectTitleFormatter.component.ts new file mode 100644 index 00000000..a6c56ba6 --- /dev/null +++ b/workingUIKIT/src/app/claims/claim-utils/entityFormatter/projectTitleFormatter.component.ts @@ -0,0 +1,25 @@ +import {Component, Input} from '@angular/core'; +import {OpenaireProperties} from '../../../utils/properties/openaireProperties'; +import {RouterHelper} from '../../../utils/routerHelper.class'; + +//Usage Example " " + +@Component({ + selector: 'project-title', + template: ` + + ` +}) + +export class ProjectTitleFormatter { + @Input() project: string[]; + public url:string; + public routerHelper:RouterHelper = new RouterHelper(); + constructor () {} + + ngOnInit() { + this.url = OpenaireProperties.getsearchLinkToProject() + "?projectId=" + this.project["openaireId"]; + } +} diff --git a/workingUIKIT/src/app/claims/claim-utils/entityFormatter/publicationTitleFormatter.component.ts b/workingUIKIT/src/app/claims/claim-utils/entityFormatter/publicationTitleFormatter.component.ts new file mode 100644 index 00000000..615bfd03 --- /dev/null +++ b/workingUIKIT/src/app/claims/claim-utils/entityFormatter/publicationTitleFormatter.component.ts @@ -0,0 +1,26 @@ +import {Component, Input} from '@angular/core'; + +//Usage Example " " + +@Component({ + selector: 'publication-title', + template: ` +
+
{{title}}
+
{{title}}
+
+ ` +}) + +export class PublicationTitleFormatter { + @Input() title: string[]; + @Input() url: string[]; + + constructor () {} + + ngOnInit() { + + } + + +} diff --git a/workingUIKIT/src/app/claims/claim-utils/service/claims.service.ts b/workingUIKIT/src/app/claims/claim-utils/service/claims.service.ts new file mode 100644 index 00000000..01f35f78 --- /dev/null +++ b/workingUIKIT/src/app/claims/claim-utils/service/claims.service.ts @@ -0,0 +1,152 @@ +import {Injectable} from '@angular/core'; +import {Jsonp, URLSearchParams,ResponseOptions, RequestOptions, Headers} from '@angular/http'; +import {Http, Response} from '@angular/http'; +import {Observable} from 'rxjs/Observable'; +// import {Claim} from '../claim'; +import {OpenaireProperties} from '../../../utils/properties/openaireProperties'; +import 'rxjs/add/observable/of'; +import 'rxjs/add/operator/do'; +import 'rxjs/add/operator/share'; +import { CacheService } from '../../../shared/cache.service'; + +@Injectable() +export class ClaimsService { + private baseUrl; + constructor(private jsonp: Jsonp, private http: Http, public _cache: CacheService) { + this.baseUrl = OpenaireProperties.getClaimsAPIURL(); + } + + private getClaimRequest(size : number, page : number, url :string, fromCache:boolean,token:string):any { + console.info('ClaimsService: Claims request: '+url); + let key = url; + if (fromCache && this._cache.has(key)) { + return Observable.of(this._cache.get(key)); + } + return this.http.get( url+"&token="+token) + .map(request => request.json()) + .do(request => console.info("Get claims: offset = "+(size*(page-1)) + " limit ="+size )) + .catch(this.handleError) + .do(res => { + this._cache.set(key, res); + }); + } + getClaims( size : number, page : number, keyword:string, sortby: string, descending: boolean, types: string,token:string):any { + console.info('ClaimsService: getClaims ' ); + console.info('ClaimsService: Types : '+types ); + let url = this.baseUrl +"claims"+"?offset="+(size*(page-1) + "&limit="+size)+"&keyword="+keyword+"&sortby="+sortby+"&descending="+descending+"&"+types; + return this.getClaimRequest(size,page,url,true,token); + + } + getClaimsByUser( size : number, page : number, user:string, keyword:string, sortby: string, descending: boolean, types: string,token:string):any { + console.info('ClaimsService: getClaims for user : '+user); + let url = this.baseUrl +"users/"+user+"/claims"+"?offset="+(size*(page-1) + "&limit="+size)+"&keyword="+keyword+"&sortby="+sortby+"&descending="+descending+"&"+types; + return this.getClaimRequest(size,page,url,false,token); + + } + getClaimsBycontext( size : number, page : number, contextId:string, keyword:string, sortby: string, descending: boolean, types: string,token:string):any { + console.info('ClaimsService: getClaims for context : '+contextId); + let url = this.baseUrl +"contexts/"+contextId+"/claims"+"?offset="+(size*(page-1) + "&limit="+size)+"&keyword="+keyword+"&sortby="+sortby+"&descending="+descending+"&"+types; + return this.getClaimRequest(size,page,url,true,token); + + } + getClaimsByResult( size : number, page : number, resultId:string, keyword:string, sortby: string, descending: boolean, types: string,token:string):any { + console.info('ClaimsService: getClaims for result : '+resultId); + let url = this.baseUrl +"results/"+resultId+"/claims"+"?offset="+(size*(page-1) + "&limit="+size)+"&keyword="+keyword+"&sortby="+sortby+"&descending="+descending+"&"+types; + return this.getClaimRequest(size,page,url,true,token); + + } + getClaimsByProject( size : number, page : number, projectId:string, keyword:string, sortby: string, descending: boolean, types: string,token:string):any { + console.info('ClaimsService: getClaims for project : '+projectId); + let url = this.baseUrl +"projects/"+projectId+"/claims"+"?offset="+(size*(page-1) + "&limit="+size)+"&keyword="+keyword+"&sortby="+sortby+"&descending="+descending+"&"+types; + return this.getClaimRequest(size,page,url,true,token); + } + + deleteClaimById(claimId:string,token:string):any{ + console.warn('Trying to delete claim with id : '+claimId); + let url = this.baseUrl +"claims/"+claimId+"?token="+token; + let headers = new Headers({ 'Content-Type': 'application/json' }); + let options = new RequestOptions({ headers: headers }); + return this.http.delete( url, options).map(request => request.json()) + // .do(request => console.info("After delete" )) + .catch(this.handleError); + + } + deleteBulk(claimIds:string[],token:string):any{ + + console.warn('Trying to delete claims with ids : '+claimIds); + var url = ""; + + for(var claimId of claimIds){ + url=url+(url.length >0 ?"&":"")+"claimId="+claimId; + } + url= this.baseUrl +"claims/bulk?"+url+"&token="+token; + let headers = new Headers({ 'Content-Type': 'application/json' }); + let options = new RequestOptions({ headers: headers }); + return this.http.delete( url, options).map(request => request.json()) + // .do(request => console.info("After delete" )) + .catch(this.handleError); + + } + insertBulkClaims(claims,token:string):any{ + console.warn('Trying toinsert claims : '+claims); + let url = this.baseUrl +"claims/bulk"+"?token="+token; + let body = JSON.stringify( claims ); + console.warn('Json body: : '+body); + let headers = new Headers({ 'Content-Type': 'application/json' }); + let options = new RequestOptions({ headers: headers }); + return this.http.post(url, body, options) + .map(res => res.json()) + .do(request => console.info("Insert Response:"+request.status) ) + .catch(this.handleError); + + } + insertClaim(claim,token:string):any{ + console.warn('Trying toinsert claim : '+claim); + let url = this.baseUrl +"claims"+"?token="+token; + let body = JSON.stringify( claim ); + let headers = new Headers({ 'Content-Type': 'application/json' }); + let options = new RequestOptions({ headers: headers }); + return this.http.post(url, body, options) + .map(res => res.json()) + .do(request => console.info("Insert Response:"+request.status) ) + .catch(this.handleError); + + } + insertDirectRecords(records,token:string):any{ + console.warn('Trying to feedrecords : '+records); + let url = this.baseUrl +"feed/bulk"+"?token="+token; + let body = JSON.stringify( records ); + console.warn('Json body: : '+body); + let headers = new Headers({ 'Content-Type': 'application/json' }); + let options = new RequestOptions({ headers: headers }); + return this.http.post(url, body, options) + .map(res => res.json()) + .do(request => console.info("Insert Response:"+request) ) + .catch(this.handleError); + + } + private handleError (error: Response) { + // 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'); + } + + getClaim(id:string,token:string):any { + let url = this.baseUrl+"claims/"+id+"?token="+token; + return new Promise((resolve, reject) => { + this.http.get(url) + .map(res => res.json()) + .subscribe( + data => { + resolve(data.data); + }, + err => { + reject(err); + } + ) + ; + }); + } + +} diff --git a/workingUIKIT/src/app/claims/claim-utils/service/claimsService.module.ts b/workingUIKIT/src/app/claims/claim-utils/service/claimsService.module.ts new file mode 100644 index 00000000..5272312e --- /dev/null +++ b/workingUIKIT/src/app/claims/claim-utils/service/claimsService.module.ts @@ -0,0 +1,20 @@ +import { NgModule} from '@angular/core'; +import { CommonModule } from '@angular/common'; +import { FormsModule } from '@angular/forms'; + +import {ClaimsService} from './claims.service'; + + +@NgModule({ + imports: [ + CommonModule, FormsModule + ], + declarations: [ + ], + providers:[ + ClaimsService +], + exports: [ + ] +}) +export class ClaimServiceModule { } diff --git a/workingUIKIT/src/app/claims/claim-utils/service/contexts.service.ts b/workingUIKIT/src/app/claims/claim-utils/service/contexts.service.ts new file mode 100644 index 00000000..c580cf2b --- /dev/null +++ b/workingUIKIT/src/app/claims/claim-utils/service/contexts.service.ts @@ -0,0 +1,88 @@ +import {Injectable} from '@angular/core'; +import {Jsonp, URLSearchParams,ResponseOptions} from '@angular/http'; +import {Http, Response} from '@angular/http'; +import {Observable} from 'rxjs/Observable'; +import {Claim} from '../claim'; +import {OpenaireProperties} from '../../../utils/properties/openaireProperties'; +import {AutoCompleteValue} from '../../../searchPages/searchUtils/searchHelperClasses.class'; +import 'rxjs/add/observable/of'; +import 'rxjs/add/operator/do'; +import 'rxjs/add/operator/share'; +import { CacheService } from '../../../shared/cache.service'; + +@Injectable() +export class ContextsService { + private baseUrl; + constructor(private http: Http, public _cache: CacheService) { + this.baseUrl = OpenaireProperties.getClaimsAPIURL(); + } + + public getCommunities(token:string):any { + let url = this.baseUrl + 'communities'; + let key = url; + if (this._cache.has(key)) { + return Observable.of(this._cache.get(key)); + } + + console.info('ContextsService: request communities '+url); + return this.http.get( url+"?token="+token) + .map(request => request.json().data) + // .do(request => console.info("Get claims: offset = ")) + .catch(this.handleError) + .do(res => { + this._cache.set(key, res); + }); + } + public getCategories(communityId :string,token:string):any { + console.info('ContextsService: request categories for community with id '+communityId); + let url= this.baseUrl + 'communities/' + communityId + '/categories'; + let key = url; + if (this._cache.has(key)) { + return Observable.of(this._cache.get(key)); + } + + return this.http.get( url+"?token="+token) + .map(request => request.json().data) + // .do(request => console.info("Get claims: offset = " )) + .catch(this.handleError) + .do(res => { + this._cache.set(key, res); + }); + } + public getConcepts(categoryId :string, keyword: string,token:string):any { + console.info('ContextsService: request concept for category with id '+categoryId + ' and keyword '+ keyword); + let url= this.baseUrl + 'categories/' + categoryId+ "/concepts"; + let key = url; + if (this._cache.has(key)) { + return Observable.of(this._cache.get(key)); + } + + return this.http.get( url+"?token="+token) + .map(request => request.json().data) + .map(res => this.parse(res.concept)) + // .do(res => console.info(res )) + .catch(this.handleError) + .do(res => { + this._cache.set(key, res); + }); + } + parse (data: any):AutoCompleteValue[] { + var array:AutoCompleteValue[] =[] + for(var i = 0; i < data.length; i++){ + var value:AutoCompleteValue = new AutoCompleteValue(); + value.id = data[i].id; + value.label = data[i].label; + array.push(value); + } + + return array; + + } + + private handleError (error: Response) { + // 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'); + } +} diff --git a/workingUIKIT/src/app/claims/claim-utils/service/contextsService.module.ts b/workingUIKIT/src/app/claims/claim-utils/service/contextsService.module.ts new file mode 100644 index 00000000..6bd55ced --- /dev/null +++ b/workingUIKIT/src/app/claims/claim-utils/service/contextsService.module.ts @@ -0,0 +1,20 @@ +import { NgModule} from '@angular/core'; +import { CommonModule } from '@angular/common'; +import { FormsModule } from '@angular/forms'; + +import {ContextsService} from './contexts.service'; + + +@NgModule({ + imports: [ + CommonModule, FormsModule + ], + declarations: [ + ], + providers:[ + ContextsService +], + exports: [ + ] +}) +export class ContextsServiceModule { } diff --git a/workingUIKIT/src/app/claims/claim-utils/service/directIndexClaim.service.ts b/workingUIKIT/src/app/claims/claim-utils/service/directIndexClaim.service.ts new file mode 100644 index 00000000..7a4ec1ea --- /dev/null +++ b/workingUIKIT/src/app/claims/claim-utils/service/directIndexClaim.service.ts @@ -0,0 +1,39 @@ +import {Injectable} from '@angular/core'; +import {Jsonp, URLSearchParams,ResponseOptions, RequestOptions, Headers} from '@angular/http'; +import {Http, Response} from '@angular/http'; +import {Observable} from 'rxjs/Observable'; +import {OpenaireProperties} from '../../../utils/properties/openaireProperties'; +import 'rxjs/add/observable/of'; +import 'rxjs/add/operator/do'; +import 'rxjs/add/operator/share'; + +@Injectable() +export class DirectIndexClaimService { + private baseUrl; + constructor(private jsonp: Jsonp, private http: Http) { + this.baseUrl = OpenaireProperties.getClaimsAPIURL(); + } + + public directClaim(record:any):any { + console.log("in direct claim service"); + let url = "http://beta.services.openaire.eu:8280/is/mvc/api/publications/feedObject"; + // let body = JSON.stringify( record ); + // console.warn('Direct Json body: : '+body); + console.warn('Direct Json record: : '+record); + let headers = new Headers({ 'Content-Type': 'application/json' }); + let options = new RequestOptions({ headers: headers }); + return this.http.post(url, record, options) + .map(res => res.json()) + .do(request => console.info("DirectClaim Response:"+request) ) + .catch(this.handleError); + + + } + private handleError (error: Response) { + // 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'); + } + +} diff --git a/workingUIKIT/src/app/claims/claim-utils/service/searchCrossref.service.ts b/workingUIKIT/src/app/claims/claim-utils/service/searchCrossref.service.ts new file mode 100644 index 00000000..7b39af69 --- /dev/null +++ b/workingUIKIT/src/app/claims/claim-utils/service/searchCrossref.service.ts @@ -0,0 +1,84 @@ +import {Injectable} from '@angular/core'; +import {Http, Response} from '@angular/http'; +import {Observable} from 'rxjs/Observable'; +import {OpenaireProperties} from '../../../utils/properties/openaireProperties'; +import 'rxjs/add/observable/of'; +import 'rxjs/add/operator/do'; +import 'rxjs/add/operator/share'; +import { CacheService } from '../../../shared/cache.service'; +@Injectable() +export class SearchCrossrefService { + constructor( private http: Http, public _cache: CacheService) {} + + + searchCrossrefResults (term: string, size : number, page : number):any { + let url = OpenaireProperties.getSearchCrossrefAPIURL()+'?query='+term+'&rows='+size+'&offset='+(size*(page-1)); + let key = url; + if (this._cache.has(key)) { + return Observable.of(this._cache.get(key)); + } + + return this.http.get( url) + .map(request => request.json().message) + .do(items => console.log("Crossref Results: total results = "+items['total-results']+" keyword = "+term)) + .do(res => { + this._cache.set(key, res); + }); + //.catch(this.handleError); + + } + searchCrossrefByDOIs(DOIs: string[]):any { + /* + $request ="http://api.crossref.org/works"."?filter="; + foreach($dois as $doi){ + $request.="doi:".urlencode( trim($doi)).","; + } + */ + var doisParams = ""; + for(var i =0 ;i < DOIs.length; i++){ + doisParams+=(doisParams.length > 0?",":"")+'doi:'+DOIs[i]; + } + let url = OpenaireProperties.getSearchCrossrefAPIURL()+'?filter='+doisParams; + let key = url; + if (this._cache.has(key)) { + return Observable.of(this._cache.get(key)); + } + + return this.http.get( url) + .map(request => request.json().message) + .do(items => console.log("Crossref Results: total results = "+items['total-results']+" for doi = "+doisParams)) + .do(res => { + this._cache.set(key, res); + }); + //.catch(this.handleError); + + } + searchCrossrefByMultipleDOIs(dois: string[]):any { + let url = OpenaireProperties.getSearchCrossrefAPIURL()+'?filter=doi:'; + for(var i=0; i request.json().message) + .do(items => console.log("Crossref Results: total results = "+items['total-results'])). + do(res => { + this._cache.set(key, res); + }); + //.catch(this.handleError); + + } + + private handleError (error: Response) { + // 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'); + } + +} diff --git a/workingUIKIT/src/app/claims/claim-utils/service/searchCrossrefService.module.ts b/workingUIKIT/src/app/claims/claim-utils/service/searchCrossrefService.module.ts new file mode 100644 index 00000000..798acdb3 --- /dev/null +++ b/workingUIKIT/src/app/claims/claim-utils/service/searchCrossrefService.module.ts @@ -0,0 +1,20 @@ +import { NgModule} from '@angular/core'; +import { CommonModule } from '@angular/common'; +import { FormsModule } from '@angular/forms'; + +import {SearchCrossrefService} from './searchCrossref.service'; + + +@NgModule({ + imports: [ + CommonModule, FormsModule + ], + declarations: [ + ], + providers:[ + SearchCrossrefService +], + exports: [ + ] +}) +export class SearchCrossrefServiceModule { } diff --git a/workingUIKIT/src/app/claims/claim-utils/service/searchDatacite.service.ts b/workingUIKIT/src/app/claims/claim-utils/service/searchDatacite.service.ts new file mode 100644 index 00000000..37a1a635 --- /dev/null +++ b/workingUIKIT/src/app/claims/claim-utils/service/searchDatacite.service.ts @@ -0,0 +1,43 @@ +import {Injectable} from '@angular/core'; +import {Http, Response} from '@angular/http'; +import {Observable} from 'rxjs/Observable'; +import {OpenaireProperties} from '../../../utils/properties/openaireProperties'; +import 'rxjs/add/observable/of'; +import 'rxjs/add/operator/do'; +import 'rxjs/add/operator/share'; +import { CacheService } from '../../../shared/cache.service'; +@Injectable() +export class SearchDataciteService { + constructor(private http: Http, public _cache: CacheService) {} + + searchDataciteResults (term: string, size : number, page : number):any { + console.info("In search datacite results "+term); + let url = OpenaireProperties.getSearchDataciteAPIURL()+'?q='+term+'&fl=doi,title,creator,publisher&wt=json&rows='+size+'&start='+(size*(page-1)); + let key = url; + if (this._cache.has(key)) { + return Observable.of(this._cache.get(key)); + } + return this.http.get( url) + .map(request => request.json().response) + .do(items => console.log("Datacite Results: total results = "+items['numFound']+" keyword = "+term)) + .do(res => { + this._cache.set(key, res); + }); + //.catch(this.handleError); + } + + + private handleError (error: Response) { + // 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'); + } + private extractData(res: Response) { + if (res.status < 200 || res.status >= 300) { + throw new Error('Bad response status: ' + res.status); + } + let body = res.json(); + return body.data || { }; + } +} diff --git a/workingUIKIT/src/app/claims/claim-utils/service/searchOrcid.service.ts b/workingUIKIT/src/app/claims/claim-utils/service/searchOrcid.service.ts new file mode 100644 index 00000000..1d710a50 --- /dev/null +++ b/workingUIKIT/src/app/claims/claim-utils/service/searchOrcid.service.ts @@ -0,0 +1,141 @@ +import {Injectable} from '@angular/core'; +import {URLSearchParams} from '@angular/http'; +import {Http, Response} from '@angular/http'; +import { Headers, RequestOptions } from '@angular/http'; +import {Observable} from 'rxjs/Observable'; +import {OpenaireProperties} from '../../../utils/properties/openaireProperties'; +import 'rxjs/add/observable/of'; +import 'rxjs/add/operator/do'; +import 'rxjs/add/operator/share'; +import { CacheService } from '../../../shared/cache.service'; +@Injectable() +export class SearchOrcidService { + constructor( private http: Http, public _cache: CacheService) {} + + + searchOrcidAuthor (term: string, authorIds: string[], + authorGivenNames: string[], authorFamilyNames: string[]):any { + console.info("In searchOrcidAuthor: "+term); + + var headers = new Headers(); + headers.append('Accept', 'application/orcid+json'); + + let url = OpenaireProperties.getSearchOrcidURL()+term+'/orcid-bio'; + let key = url; + if (this._cache.has(key)) { + return Observable.of(this._cache.get(key)).map(res => this.parseOrcidAuthor(res, authorIds, authorGivenNames, authorFamilyNames)); + } + return this.http.get(url, { headers: headers }) + .map(res => res.json()['orcid-profile']) + .map(res => [res['orcid-bio']['personal-details']['given-names'], + res['orcid-bio']['personal-details']['family-name'], + res['orcid-identifier']]) + .do(res => { + this._cache.set(key, res); + }) + .map(res => this.parseOrcidAuthor(res, authorIds, authorGivenNames, authorFamilyNames)); + } + + searchOrcidAuthors (term: string, authorIds: string[], + authorGivenNames: string[], authorFamilyNames: string[]):any { + console.info("In search Orcid authors for keyword: "+term); + + var headers = new Headers(); + headers.append('Accept', 'application/orcid+json'); + + let url = OpenaireProperties.getSearchOrcidURL()+'search/orcid-bio?defType=edismax&q='+term+'&qf=given-name^1.0+family-name^2.0+other-names^1.0+credit-name^1.0&start=0&rows=10'; + let key = url; + if (this._cache.has(key)) { + return Observable.of(this._cache.get(key)).map(res => this.parseOrcidAuthors(res, authorIds, authorGivenNames, authorFamilyNames)); + } + return this.http.get(url, { headers: headers }) + .map(res => res.json()['orcid-search-results']['orcid-search-result']) + .do(res => { + this._cache.set(key, res); + }) + .map(res => this.parseOrcidAuthors(res, authorIds, authorGivenNames, authorFamilyNames)); + + } + + searchOrcidPublications (id: string):any { + console.info("In search Orcid publications for author: "+id); + + var headers = new Headers(); + headers.append('Accept', 'application/orcid+json'); + + let url = OpenaireProperties.getSearchOrcidURL()+id+'/orcid-works'; + let key = url; + if (this._cache.has(key)) { + return Observable.of(this._cache.get(key)); + } + return this.http.get(url, { headers: headers }) + .map(res => res.json()['orcid-profile']['orcid-activities']['orcid-works']) + .do(res => { + this._cache.set(key, res); + }); + //.map(res => res['orcid-work']); + } + + + parseOrcidAuthor (data: any, authorIds: string[], + authorGivenNames: string[], authorFamilyNames: string[]):any { + + if(data[2] != null) { + authorIds.push(data[2].path); + + if(data[0] != null) { + authorGivenNames.push(data[0].value); + } else { + authorGivenNames.push(""); + } + if(data[1] != null) { + authorFamilyNames.push(data[1].value); + } else { + authorFamilyNames.push(""); + } + + return true; + } + + return false; + } + + parseOrcidAuthors (data: any, authorIds: string[], + authorGivenNames: string[], authorFamilyNames: string[]):any { + let ret: boolean = false; + let mydata: any; + let length: number; + + if(data != null) { + length = data.length!=undefined ? data.length : 1; + + for(let i=0; iStart Over`, + +}) +export class StartOverComponent { + constructor () { + + + } + ngOnInit() { + +} + + + // @Input() public inlineEntity = null; + @Input() public type:string; + @Input() public linkTo:string; + @Input() public results; + @Input() public projects; + @Input() public contexts; + + + startOver(){ + console.log("projects:"+this.projects.length +" contexts:"+this.contexts.length + " results:"+this.results.length ); + if(this.type != null && this.linkTo != null){ + console.log("inline"); + if(this.linkTo == "project"){ + this.projects.splice(0, this.projects.length); + }else if(this.linkTo == "context"){ + this.contexts.splice(0, this.contexts.length); + }else if(this.linkTo == "result"){ + this.results.splice(0, this.results.length); + } + }else{ + console.log("generic"); + this.results.splice(0, this.results.length); + this.projects.splice(0, this.projects.length); + this.contexts.splice(0, this.contexts.length); + } + console.log("projects:"+this.projects.length +" contexts:"+this.contexts.length + " results:"+this.results.length ); + } + +} diff --git a/workingUIKIT/src/app/claims/claim-utils/startOver.module.ts b/workingUIKIT/src/app/claims/claim-utils/startOver.module.ts new file mode 100644 index 00000000..314e85ca --- /dev/null +++ b/workingUIKIT/src/app/claims/claim-utils/startOver.module.ts @@ -0,0 +1,15 @@ +import { NgModule } from '@angular/core'; +import { SharedModule } from '../../shared/shared.module'; +import { CommonModule } from '@angular/common'; +import {StartOverComponent} from './startOver.component'; + + @NgModule({ + imports: [ + SharedModule, CommonModule + ], + declarations: [ + StartOverComponent + ], + exports: [StartOverComponent ] +}) +export class StartOverModule { } diff --git a/workingUIKIT/src/app/claims/claim.module.ts b/workingUIKIT/src/app/claims/claim.module.ts new file mode 100644 index 00000000..113e8597 --- /dev/null +++ b/workingUIKIT/src/app/claims/claim.module.ts @@ -0,0 +1,68 @@ +// import { NgModule} from '@angular/core'; +// import { CommonModule } from '@angular/common'; +// import { FormsModule } from '@angular/forms'; +// // +// import {UtilsModule} from '../utils/utils.module'; +// import {ServicesModule} from '../services/services.module'; +// +// import { ClaimsService} from '../services/claims.service'; +// //main +// import {ClaimComponent} from './claim/claim.component'; +// import {ClaimsAdminComponent} from './claims/claimsAdmin.component'; +// import {MyClaimsComponent} from './myClaims/myClaims.component'; +// import {LinkingHomeComponent} from './linking/linkingHome.component'; +// import {LinkingComponent} from './linking/linking.component'; +// import { BulkLinkingComponent } from './linking/bulkLinking.component'; +// +// import {BulkClaimComponent} from './linking/bulkClaim/bulkClaim.component'; +// import {ClaimsComponent} from './claim-utils/claims.component'; +// +// import {ClaimContextComponent} from './claim-utils/claimContext.component'; +// import {ClaimProjectsComponent} from './claim-utils/claimProject.component'; +// import {ClaimResultComponent} from './claim-utils/claimResult.component'; +// import {ClaimPublicationComponent} from './claim-utils/claimPublication.component'; +// import {ClaimDatasetComponent} from './claim-utils/claimDataset.component'; +// +// import {ClaimInsertComponent} from './linking/insertClaim/insertClaim.component'; +// +// import {ClaimSelectedContextsComponent} from './linking/selected/selectedContexts.component'; +// import {ClaimSelectedComponent} from './linking/selected/selected.component'; +// import {ClaimSelectedDatasetsComponent} from './linking/selected/selectedDatasets.component'; +// import {ClaimSelectedResultsComponent} from './linking/selected/selectedResults.component'; +// import {ClaimSelectedProjectsComponent} from './linking/selected/selectedProjects.component'; +// import {ClaimSelectedPublicationsComponent} from './linking/selected/selectedPublications.component'; +// +// import {LinkingGenericComponent} from './linking/linkingGeneric.component'; +// +// import {InlineClaimContextComponent} from './inlineClaims/inlineClaimContext.component'; +// import {InlineClaimProjectComponent} from './inlineClaims/inlineClaimProject.component'; +// import {InlineClaimResultComponent} from './inlineClaims/inlineClaimResult.component'; +// import {ClaimEntityFormatter} from '../utils/claimEntityFormatter.component'; +// +// import { Claim } from '../utils/entities/claim'; +// //helpers +// +// import { ClaimRoutingModule } from './claim-routing.module'; +// @NgModule({ +// imports: [ +// CommonModule, FormsModule, +// UtilsModule, +// ServicesModule, +// ClaimRoutingModule +// +// ], +// declarations: [ +// ClaimsAdminComponent, MyClaimsComponent, ClaimComponent, ClaimsComponent, +// BulkLinkingComponent, LinkingComponent, LinkingHomeComponent, LinkingGenericComponent, +// InlineClaimContextComponent, InlineClaimProjectComponent, InlineClaimResultComponent, ClaimSelectedComponent, +// ClaimContextComponent, ClaimSelectedContextsComponent, ClaimInsertComponent, ClaimProjectsComponent, ClaimSelectedProjectsComponent, +// ClaimResultComponent, ClaimSelectedPublicationsComponent, ClaimSelectedDatasetsComponent, ClaimSelectedResultsComponent, ClaimPublicationComponent, +// ClaimDatasetComponent, BulkClaimComponent, +// ClaimEntityFormatter +// ], +// providers: [ ClaimsService ], +// exports: [ +// InlineClaimContextComponent, InlineClaimProjectComponent, InlineClaimResultComponent +// ] +// }) +// export class ClaimModule { } diff --git a/workingUIKIT/src/app/claims/claim/claim.component.html b/workingUIKIT/src/app/claims/claim/claim.component.html new file mode 100644 index 00000000..41ecc151 --- /dev/null +++ b/workingUIKIT/src/app/claims/claim/claim.component.html @@ -0,0 +1,10 @@ +
+

Here is the claim with id : {{id}}

+
+ {{claim.id }} || {{claim.userMail }} || + {{claim | json}} {{claim | json}} +
+
+
+

No proper id...

+
diff --git a/workingUIKIT/src/app/claims/claim/claim.component.ts b/workingUIKIT/src/app/claims/claim/claim.component.ts new file mode 100644 index 00000000..786270cd --- /dev/null +++ b/workingUIKIT/src/app/claims/claim/claim.component.ts @@ -0,0 +1,43 @@ +import {Component} from '@angular/core'; +import {Observable} from 'rxjs/Observable'; +import {ActivatedRoute, Router} from '@angular/router'; + +import {ClaimsService} from '../../services/claims.service'; +// import {Claim} from '../../utils/entities/claim'; + +@Component({ + selector: 'claim', + templateUrl: 'claim.component.html', + +}) +export class ClaimComponent { + constructor (private _claimService: ClaimsService, + private route: ActivatedRoute, private _router:Router) {} + ngOnInit() { + this.sub = this.route.queryParams.subscribe(params => { + + this.id = params['id']; + console.info("Claim id:"+this.id +" " +params['id']); + if(this.id!=null){ + this.getClaim(this.id); + } + }); + + +} +ngOnDestroy() { + this.sub.unsubscribe(); +} + sub: any; + id : string; + claim : any; + getClaim (id: string) { + this._claimService.getClaim(id) + .then(data => { + this.claim = data; + console.log(data); + }) ; + } + + +} diff --git a/workingUIKIT/src/app/claims/claimsAdmin/claimsAdmin-routing.module.ts b/workingUIKIT/src/app/claims/claimsAdmin/claimsAdmin-routing.module.ts new file mode 100644 index 00000000..7fdd5996 --- /dev/null +++ b/workingUIKIT/src/app/claims/claimsAdmin/claimsAdmin-routing.module.ts @@ -0,0 +1,15 @@ +import { NgModule } from '@angular/core'; +import { RouterModule } from '@angular/router'; +import { AdminLoginGuard} from'../../login/adminLoginGuard.guard'; + +import { ClaimsAdminComponent } from './claimsAdmin.component'; + +@NgModule({ + imports: [ + RouterModule.forChild([ + { path: '', component: ClaimsAdminComponent, canActivate: [AdminLoginGuard]}, + + ]) + ] +}) +export class ClaimsAdminRoutingModule { } diff --git a/workingUIKIT/src/app/claims/claimsAdmin/claimsAdmin.component.ts b/workingUIKIT/src/app/claims/claimsAdmin/claimsAdmin.component.ts new file mode 100644 index 00000000..3eec3b19 --- /dev/null +++ b/workingUIKIT/src/app/claims/claimsAdmin/claimsAdmin.component.ts @@ -0,0 +1,26 @@ +import {Component, ViewChild, Input} from '@angular/core'; +import {Location} from '@angular/common'; +import {Observable} from 'rxjs/Observable'; + +@Component({ + selector: 'claims-admin', + template: ` +
+ + +
+ `, + +}) +export class ClaimsAdminComponent { + constructor ( ) { + + } + ngOnInit() { + } +} diff --git a/workingUIKIT/src/app/claims/claimsAdmin/claimsAdmin.module.ts b/workingUIKIT/src/app/claims/claimsAdmin/claimsAdmin.module.ts new file mode 100644 index 00000000..d1fd96b4 --- /dev/null +++ b/workingUIKIT/src/app/claims/claimsAdmin/claimsAdmin.module.ts @@ -0,0 +1,23 @@ +import { NgModule } from '@angular/core'; + +import { SharedModule } from '../../shared/shared.module'; +import { ClaimsAdminComponent } from './claimsAdmin.component'; +import { ClaimsAdminRoutingModule } from './claimsAdmin-routing.module'; +// import{ClaimServiceModule} from '../claim-utils/service/claimsService.module'; +import {DisplayClaimsModule} from '../claim-utils/displayClaims/displayClaims.module'; +import { AdminLoginGuard} from'../../login/adminLoginGuard.guard'; + +@NgModule({ + imports: [ + SharedModule, + ClaimsAdminRoutingModule, + // ClaimServiceModule, + DisplayClaimsModule + + ], + providers:[AdminLoginGuard], + declarations: [ + ClaimsAdminComponent + ] +}) +export class ClaimsAdminModule { } diff --git a/workingUIKIT/src/app/claims/claimsByToken/claimsByToken-routing.module.ts b/workingUIKIT/src/app/claims/claimsByToken/claimsByToken-routing.module.ts new file mode 100644 index 00000000..9c0f4180 --- /dev/null +++ b/workingUIKIT/src/app/claims/claimsByToken/claimsByToken-routing.module.ts @@ -0,0 +1,14 @@ +import { NgModule } from '@angular/core'; +import { RouterModule } from '@angular/router'; +import { LoginGuard} from'../../login/loginGuard.guard'; +import { ClaimsByTokenComponent } from './claimsByToken.component'; + +@NgModule({ + imports: [ + RouterModule.forChild([ + { path: '', component: ClaimsByTokenComponent, canActivate: [LoginGuard]} + + ]) + ] +}) +export class ClaimsByTokenRoutingModule { } diff --git a/workingUIKIT/src/app/claims/claimsByToken/claimsByToken.component.ts b/workingUIKIT/src/app/claims/claimsByToken/claimsByToken.component.ts new file mode 100644 index 00000000..cde79125 --- /dev/null +++ b/workingUIKIT/src/app/claims/claimsByToken/claimsByToken.component.ts @@ -0,0 +1,310 @@ +import {Component, ViewChild, Input} from '@angular/core'; +import {Location} from '@angular/common'; +import {Observable} from 'rxjs/Observable'; +import {ActivatedRoute, Router, Params} from '@angular/router'; +import {ClaimsByTokenService} from './claimsByToken.service'; + +import {ModalSelect} from '../../utils/modal/selectModal.component'; +import {ModalLoading} from '../../utils/modal/loading.component'; + +import {Session} from '../../login/utils/helper.class'; + +import {RouterHelper} from '../../utils/routerHelper.class'; + +@Component({ + selector: 'claims-project-manager', + template: ` + + + + + +
+
+ + +

Oops! Your email does not give you the authority to view claims for the selected project. Please contact the administrators.

+
+
+ +
+

Pending Claims for project: + + {{project['name']}} ({{project['funderName']}}) + +

+ +
+
No pending claims found.
+
+ +
+ + + + + + + + + + + + + + + + + + + + +
Research ResultClaimed byClaimed DateApprove
{{claim.userMail}}{{claim.date}} + + + +
+ +

Already Curated Claims

+ +
+
No curated claims found.
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
Research ResultClaimed byClaimed DateCurated byCuration DateApproved
{{claim.userMail}}{{claim.date}}{{claim.curatedBy}}{{claim.curationDate}} + + + + + +
+ + +
*Note that claims you did not approved or disapproved are considered as right (but not curated)
+ + + + +
+ `, + +}) +export class ClaimsByTokenComponent { + //change true - false to accept: yes - no + public token: string = ""; + public sub: any; + public project: any; + private claims:any = []; + public pending_claims: any = []; + public curated_claims: any = []; + public selectedRight: Set; + public selectedWrong: Set; + public editable: Set; + public contact_person: string[] = ["Konstantina", "Argiro", "Katerina"]; + + // when 'empty' show form to fill email, when 'valid' show proper claims, when 'invalid' show no matched entry-wanna retry + public accessStatus: string;// = "empty"; + + @ViewChild (ModalSelect) selectModal : ModalSelect; + @ViewChild (ModalLoading) loading : ModalLoading ; + + public routerHelper:RouterHelper = new RouterHelper(); + + constructor ( private route: ActivatedRoute, private _router:Router, private claimsByTokenService: ClaimsByTokenService ) { + + } + ngOnInit() { + this.sub = this.route.queryParams.subscribe(params => { + this.token = params['token']; + this.selectedRight = new Set(); + this.selectedWrong = new Set(); + this.editable = new Set(); + //this.openSelect(); + //this.setMessageSelect("Please select your identity:"); + //this.setOptionsSelect(this.contact_person); + this.validateJWTandToken(); + } + ); + } + + validateJWTandToken() { + var jwtToken=Session.getUserJwt(); + if(this.token) { + this.claimsByTokenService.getClaims(this.token, jwtToken).subscribe( + data => { + this.closeLoading(); + this.accessStatus = "valid"; + //console.info(data); + this.claims = data.data; + for(let claim of this.claims) { + if(claim.targetType == "project") { + this.project = claim.target; + } else { + this.project = claim.source; + } + if(claim.curatedBy) { + this.curated_claims.push(claim); + } else { + this.pending_claims.push(claim); + } + } + }, + err => { + this.accessStatus = "invalid"; + console.log(err); + } + ); + } else { + this.accessStatus = "invalid"; + } + } + + selectApprove(id:string, event) { + var value = event.currentTarget.checked; + if(value){ + this.selectedRight.add(id); + this.selectedWrong.delete(id); + console.info(this.selectedRight); + }else{ + this.selectedRight.delete(id); + console.info(this.selectedRight); + } + } + + selectDisapprove(id:string,event) { + var value = event.currentTarget.checked; + if(value){ + this.selectedWrong.add(id); + this.selectedRight.delete(id); + }else{ + this.selectedWrong.delete(id); + } + } + + isSelectedRight(id:string) { + return this.selectedRight.has(id); + } + + isSelectedWrong(id:string) { + return this.selectedWrong.has(id); + } + + isRight(claim: any) { + //claim.approved = true; + if(this.isSelectedRight(claim.id)) { + return true; + } else if(claim.approved == true && !this.isSelectedWrong(claim.id)) { + return true; + } + + return false; + } + + isWrong(claim: any) { + if(this.isSelectedWrong(claim.id)) { + return true; + } else if(claim.approved == false && !this.isSelectedRight(claim.id)) { + return true; + } + + return false; + } + + saveChanges() { + console.info("Changes Saved!"); + var jwtToken=Session.getUserJwt(); + + this.claimsByTokenService.updateClaimsCuration(jwtToken, this.selectedRight, this.selectedWrong).subscribe( + data => { + console.info(data); + }, + err => { + console.log(err); + } + ); + + } + + public closeLoading(){ + if(this.loading){ + this.loading.close(); + } + } + + curatorSelected(selected: string) { + console.info("selected curator: "+selected); + } + + public openSelect(){ + if(this.selectModal){ + this.selectModal.open(); + } + } + + public setMessageSelect(message: string){ + if(this.selectModal){ + this.selectModal.message = message; + } + } + + public setOptionsSelect(options: string[]){ + if(this.selectModal){ + this.selectModal.options = options; + } + } +} diff --git a/workingUIKIT/src/app/claims/claimsByToken/claimsByToken.module.ts b/workingUIKIT/src/app/claims/claimsByToken/claimsByToken.module.ts new file mode 100644 index 00000000..a9e68591 --- /dev/null +++ b/workingUIKIT/src/app/claims/claimsByToken/claimsByToken.module.ts @@ -0,0 +1,36 @@ +import { NgModule } from '@angular/core'; +import { RouterModule } from '@angular/router'; + +import { SharedModule } from '../../shared/shared.module'; +import { ClaimsByTokenComponent } from './claimsByToken.component'; +import { ClaimsByTokenService } from './claimsByToken.service'; +import { ClaimsByTokenRoutingModule } from './claimsByToken-routing.module'; +import {ClaimEntityFormatterModule} from '../claim-utils/entityFormatter/claimEntityFormatter.module'; +// import{ClaimServiceModule} from '../claim-utils/service/claimsService.module'; +//import {DisplayClaimsModule} from '../claim-utils/displayClaims/displayClaims.module'; +import {SelectModalModule} from '../../utils/modal/selectModal.module'; +import {LoadingModalModule} from '../../utils/modal/loadingModal.module'; + +import {LoginGuard} from'../../login/loginGuard.guard'; + +@NgModule({ + imports: [ + RouterModule, + SharedModule, + ClaimsByTokenRoutingModule, + ClaimEntityFormatterModule, + SelectModalModule, + LoadingModalModule + // ClaimServiceModule, + //DisplayClaimsModule + + ], + providers:[ + ClaimsByTokenService, + LoginGuard + ], + declarations: [ + ClaimsByTokenComponent + ] +}) +export class ClaimsByTokenModule { } diff --git a/workingUIKIT/src/app/claims/claimsByToken/claimsByToken.service.ts b/workingUIKIT/src/app/claims/claimsByToken/claimsByToken.service.ts new file mode 100644 index 00000000..d38a7c96 --- /dev/null +++ b/workingUIKIT/src/app/claims/claimsByToken/claimsByToken.service.ts @@ -0,0 +1,79 @@ +import {Injectable} from '@angular/core'; +import {Http, Response} from '@angular/http'; +import {Jsonp, URLSearchParams,ResponseOptions, RequestOptions, Headers} from '@angular/http'; +import {Observable} from 'rxjs/Observable'; +import {OpenaireProperties} from '../../utils/properties/openaireProperties'; +import 'rxjs/add/operator/do'; +import { CacheService } from '../../shared/cache.service'; +@Injectable() +export class ClaimsByTokenService { + + constructor(private http: Http, public _cache: CacheService) {} + + getClaims(token: string, jwtToken: string):any { + console.info("getClaims in service"); + + let url = OpenaireProperties.getClaimsAPIURL()+"projects/corda__h2020::94c962e736df90a5075a7f660ba3d7f6/claims" + +"?&token="+jwtToken; + let key = url; + if (this._cache.has(key)) { + return Observable.of(this._cache.get(key)); + } + return this.http.get(url) + //.map(res => res.text()) + .map(request => request.json()) + .do(res => { + this._cache.set(key, res); + }); + } + + +/* + getClaims(email: string, token: string, user_token: string):any { + let url = OpenaireProperties.getClaimsAPIURL(); // What else? + let body = JSON.stringify( {"email": email, "token": token} ); + console.warn('Json body: : '+body); + let headers = new Headers({ 'Content-Type': 'application/json' }); + let options = new RequestOptions({ headers: headers }); + return this.http.post(url, body, options) + .map(res => res.json()) + .do(request => console.info("Insert Response:"+request.status) ) + .catch(this.handleError); + } +*/ + + updateClaimsCuration(jwtToken: string, selectedRight: Set, selectedWrong: Set) { + let url = OpenaireProperties.getClaimsAPIURL() + "curate/bulk?token="+jwtToken; + let claimsCurationInfo: any = []; //e.g.: [{"id":"2","approved":true},{"id":"1","approved":true}] + + selectedRight.forEach(function(selected) { + console.info(selected); + let claimCurationInfo: {"id": string, "approved": boolean} = {"id": selected, "approved": true}; + claimsCurationInfo.push(claimCurationInfo); + }); + + selectedWrong.forEach(function(selected) { + let claimCurationInfo: any = {"id": selected, "approved": false}; + claimsCurationInfo.push(claimCurationInfo); + }); + + console.info("\n\n"+claimsCurationInfo); + + + let body = JSON.stringify( claimsCurationInfo ); + console.warn('Json body: : '+body); + let headers = new Headers({ 'Content-Type': 'application/json' }); + let options = new RequestOptions({ headers: headers }); + return this.http.post(url, body, options) + .map(res => res.json()) + .do(request => console.info("Insert Response:"+request.status) ) + .catch(this.handleError); + } + + private handleError (error: Response) { + // 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'); + } +} diff --git a/workingUIKIT/src/app/claims/directLinking/directLinking-routing.module.ts b/workingUIKIT/src/app/claims/directLinking/directLinking-routing.module.ts new file mode 100644 index 00000000..cf42c202 --- /dev/null +++ b/workingUIKIT/src/app/claims/directLinking/directLinking-routing.module.ts @@ -0,0 +1,15 @@ +import { NgModule } from '@angular/core'; +import { RouterModule } from '@angular/router'; +import { LoginGuard} from'../../login/loginGuard.guard'; + +import { DirectLinkingComponent } from './directLinking.component'; + +@NgModule({ + imports: [ + RouterModule.forChild([ + { path: '', component: DirectLinkingComponent, canActivate: [LoginGuard]}, + + ]) + ] +}) +export class DirectLinkingRoutingModule { } diff --git a/workingUIKIT/src/app/claims/directLinking/directLinking.component.ts b/workingUIKIT/src/app/claims/directLinking/directLinking.component.ts new file mode 100644 index 00000000..b8c2d80e --- /dev/null +++ b/workingUIKIT/src/app/claims/directLinking/directLinking.component.ts @@ -0,0 +1,254 @@ +import {Component, Input} from '@angular/core'; +import {Observable} from 'rxjs/Observable'; +import {ActivatedRoute, Router} from '@angular/router'; +import {EntitiesSearchService} from '../../utils/entitiesAutoComplete/entitySearch.service'; +import {ClaimProject, ClaimResult} from '../claim-utils/claimEntities.class'; +import {SearchPublicationsService} from '../../services/searchPublications.service'; +import {SearchDatasetsService} from '../../services/searchDatasets.service'; + +@Component({ + selector: 'directLinking', + template: ` +
+ + +
+
+ Link {{(type=="project")?'Project':' Research result'}}: +
+
+ +
+ +
+
+
+ {{displayedResult.title}} + {{displayedResult.title}} +
+ + +
+ +
+ +
+ {{projects[0].funderName}} | {{projects[0].projectName}} {{(projects[0].projectAcronym)?'('+projects[0].projectAcronym+')':''}} + +
+ + +
+ +
+ +
+
+ +
+ + + +
+
+
+ +
+
+ +
+
+ +` + +}) +export class DirectLinkingComponent { + contexts=[]; + projects=[]; + + results = []; + + linkType:string ="project"; // link type (selected in home page) : project, context, software, etc + /* url Parameters for inline linking */ + id:string = null; //entity id + type:string = null; // entity type (publication or dataset) + linkTo:string = null; // entity type (project or context or result) + + entityTypes=["dataset", "publication", "project","context"]; + inlineResult:ClaimResult =null; + displayedResult:ClaimResult =null; + sub:any =null; + show:string="claim"; //{claim,result} + validInput:boolean = null;//'true; + constructor ( private _router: Router, private route: ActivatedRoute, private entitySearch:EntitiesSearchService, private publicationsSearch:SearchPublicationsService, private datasetsSearch:SearchDatasetsService) { + + } + ngOnInit() { + if(localStorage.getItem("projects")){ + this.projects = JSON.parse(localStorage.getItem("projects")); + } + if(localStorage.getItem("contexts")){ + this.contexts = JSON.parse(localStorage.getItem("contexts")); + } + if(localStorage.getItem("results")){ + this.results = JSON.parse(localStorage.getItem("results")); + } + if(localStorage.getItem("results")){ + this.results = JSON.parse(localStorage.getItem("results")); + } + if(localStorage.getItem("inlineEntity")){ + this.inlineResult = JSON.parse(localStorage.getItem("inlineEntity")); + } + + localStorage.removeItem("projects"); + localStorage.removeItem("contexts"); + localStorage.removeItem("results"); + localStorage.removeItem("inlineEntity"); + + this.sub = this.route.queryParams.subscribe(params => { + this.id = params['id']; + this.type = params['type']; + this.linkTo = params['linkTo']; + if(this.type!=null && this.linkTo!=null){ + this.type = (this.entityTypes.indexOf(this.type) != -1)? this.type:'publication'; + this.linkTo = (this.entityTypes.indexOf(this.linkTo) != -1 || this.linkTo == "result")? this.linkTo:'project'; + this.show = (this.linkTo != "result")?"claim":"result"; + this.linkType = this.linkTo; + var isInlineResult:boolean = false; // is a link result - result + if((this.type == "publication" || this.type == "dataset") && ((this.linkTo == "publication" || this.linkTo == "dataset") || this.linkTo == "result" )){ + isInlineResult = true; + } + if(this.type == "project"){ + this.linkType = "project"; + this.getProjectById(this.id); + }else if(this.type == "publication"){ + this.getPublicationById(this.id,isInlineResult); + }else if(this.type == "dataset"){ + this.getDatasetById(this.id,isInlineResult); + }else{ + this.validInput = this.isValidInput(null); + } + + }else{ + this.validInput = this.isValidInput(null); + + } + + }); + } + isValidInput(result){ + if(result == null){ + return false; + }else if(this.type == "project" && this.linkTo != "result"){ + return false; + }else if(["dataset","publication"].indexOf(this.type) != -1 && (["project","context","result"].indexOf(this.linkTo) == -1)){ + return false; + }else if(["project","dataset","publication"].indexOf(this.type) == -1){ + return false; + }else{ + return true; + } + } + getProjectById(id:string){ + this.sub = this.entitySearch.fetchByType(id,"project").subscribe( + data => { + console.log(data); + var item =data[0]; + var project: ClaimProject = new ClaimProject(); + project.funderId = item.funderId; + project.funderName = item.funderName; + project.projectId = id; + project.projectName = item.projectName; + project.projectAcronym = item.projectAcronym; + project.startDate = item.startDate; + project.endDate = item.endDate; + project.code = item.code; + project.jurisdiction = item.jurisdiction; + project.fundingLevel0 = item.fundingLevel0; + + this.projects.push( project); + this.validInput = this.isValidInput(project); + + }, + err => { + this.validInput = this.isValidInput(null); + console.log("An error occured") + }); + } + getPublicationById(id:string, isInlineResult:boolean){ + + this.sub = this.publicationsSearch.searchPublicationById(id).subscribe( + data => { + var item =data[0]; + var result: ClaimResult = new ClaimResult(); + result.id=id; + result.type="publication"; + result.source="openaire"; + result.title = item['title'].name; + result.url= item['title'].url; + result.result = item; + result.accessRights = item['title'].accessMode; + result.date = item.year; + this.displayedResult = result; + if(isInlineResult){ + this.inlineResult = result; + }else{ + this.results.push( result); + } + this.validInput = this.isValidInput(result); + }, + err => { + this.validInput = this.isValidInput(null); + console.log("An error occured") + }); + } + getDatasetById(id:string, isInlineResult:boolean){ + this.sub = this.datasetsSearch.searchDatasetById(id).subscribe( + data => { + var item =data[0]; + var result: ClaimResult = new ClaimResult(); + result.id=id; + result.type="dataset"; + result.source="openaire"; + result.title = item['title'].name; + result.url= item['title'].url; + result.result = item; + result.accessRights = item['title'].accessMode; + result.date = item.year; this.displayedResult = result; + if(isInlineResult){ + this.inlineResult = result; + }else{ + this.results.push( result); + } + this.validInput = this.isValidInput(result); + }, + err => { + this.validInput = this.isValidInput(null); + console.log("An error occured") + }); + + } + + + + resultsChange($event) { + this.results=$event.value; + } + + projectsChange($event) { + this.projects=$event.value; + } + + + + +} diff --git a/workingUIKIT/src/app/claims/directLinking/directLinking.module.ts b/workingUIKIT/src/app/claims/directLinking/directLinking.module.ts new file mode 100644 index 00000000..bc216b8f --- /dev/null +++ b/workingUIKIT/src/app/claims/directLinking/directLinking.module.ts @@ -0,0 +1,33 @@ +import { NgModule } from '@angular/core'; + +import { SharedModule } from '../../shared/shared.module'; +import { DirectLinkingComponent } from './directLinking.component'; +import { DirectLinkingRoutingModule } from './directLinking-routing.module'; + +import {SelectedProjectsModule} from '../linking/selected/selectedProjects.module'; +import {SelectedContextsModule} from '../linking/selected/selectedContexts.module'; +import {SelectedPublicationsModule} from '../linking/selected/selectedResults.module'; +import {InsertClaimsModule} from '../linking/insertClaim/insertClaim.module'; +import {StartOverModule} from '../claim-utils/startOver.module'; + +import {EntitySearchServiceModule} from '../../utils/entitiesAutoComplete/entitySearchService.module'; +import {PublicationsServiceModule} from '../../services/publicationsService.module'; +import {DatasetsServiceModule} from '../../services/datasetsService.module'; +import {LoginGuard} from'../../login/loginGuard.guard'; + + + +@NgModule({ + imports: [ + SharedModule, + DirectLinkingRoutingModule,SelectedProjectsModule, SelectedContextsModule, SelectedPublicationsModule, InsertClaimsModule, + EntitySearchServiceModule, PublicationsServiceModule, DatasetsServiceModule, StartOverModule + + + ], + providers:[LoginGuard], + declarations: [ + DirectLinkingComponent + ], exports:[DirectLinkingComponent] +}) +export class DirectLinkingModule { } diff --git a/workingUIKIT/src/app/claims/linking/bulkClaim/bulkClaim.component.ts b/workingUIKIT/src/app/claims/linking/bulkClaim/bulkClaim.component.ts new file mode 100644 index 00000000..75190374 --- /dev/null +++ b/workingUIKIT/src/app/claims/linking/bulkClaim/bulkClaim.component.ts @@ -0,0 +1,218 @@ +import {Component, Input, Output, EventEmitter,ViewChild} from '@angular/core'; +import {Observable} from 'rxjs/Observable'; +import {SearchCrossrefService} from '../../claim-utils/service/searchCrossref.service'; +import {ModalLoading} from '../../../utils/modal/loading.component'; +import {Dates, DOI} from '../../../utils/string-utils.class'; + + +@Component({ + selector: 'bulk-claim', + template: ` +
+
+
Upload a DOI csv file:
+ + + + + + + +
+ + +
+
+
Upload information:
+ Upload a csv file containing a list of DOIs. For each DOI found in the file, metadata will be fetched from CrossRef. + Available results will be linked with the selected Projects and Contexts. + + +
+ + +
+ ` + +}) +//[(ngModel)]="date" +export class BulkClaimComponent { + filesToUpload: Array; + navigateTo: string = "Search"; + source: string = "crossref"; + type : string = "publication"; + resultsFromSearch:number; + @Input() public select:boolean = true ; + @Input() public publications; + + allIds:string[] = []; + foundIds:string[] = []; + duplicateIds:string[] = []; + notFoundIds:string[] = []; + noValidIds:string[] = []; + showReport:boolean = false; + showInfo :boolean = false; + @ViewChild (ModalLoading) loading : ModalLoading ; + errorMessage = ""; + infoMEssage = ""; + enableUpload:boolean = true; + constructor(private _searchCrossrefService: SearchCrossrefService) { + this.filesToUpload = []; + + + } + ngOnInit() {} + + upload() { + this.enableUpload = false; + this.showReport = false; + this.errorMessage = ""; + if(this.filesToUpload.length == 0){ + this.errorMessage = "There is no selected file to upload."; + return ; + } + this.loading.open(); + + this.makeFileRequest("http://localhost:8000/upload", [], this.filesToUpload).then((result) => { + var rows = (result as any).split('\n'); // I have used space, you can use any thing. + var i = 0; + this.duplicateIds = []; + this.allIds = []; + this.foundIds = []; + this.noValidIds = []; + this.publications.slice(0,this.publications.length); + this.notFoundIds = []; + + for(i=0;i-1){ + this.duplicateIds.push(id); + }else{ + this.allIds.push(id); + this.fetchResult(id,accessMode,embargoDate); + } + }else{ + this.noValidIds.push(id); + } + } + + } + + }, (error) => { + this.enableUpload = true; + console.log(error); + this.loading.close(); + this.errorMessage = "An error occured while uploading..."; + }); + } + private removeDoubleQuotes(value){ + if(value.indexOf('"')== 0){ + value = value.substring(1,value.length); + } + var index =+value.indexOf('"'); + if(index == (value.length - 1) || index == (value.length - 2) ){ + value = value.substring(0,index); + } + return value; + } + private validateAccessMode(value){ + var accessModes = ["OPEN", "CLOSED", "EMBARGO"]; + if(accessModes.indexOf(value) > -1){ + return true; + } + + return false; + } + + fileChangeEvent(fileInput: any){ + this.filesToUpload = > fileInput.target.files; + } + + makeFileRequest(url: string, params: Array, files: Array) { + return new Promise((resolve, reject) => { + var formData: any = new FormData(); + var xhr = new XMLHttpRequest(); + for(var i = 0; i < files.length; i++) { + formData.append("uploads[]", files[i], files[i].name); + } + xhr.onreadystatechange = function () { + if (xhr.readyState == 4) { + if (xhr.status == 200) { + resolve(xhr.response); + } else { + reject(xhr.response); + } + } + } + xhr.open("POST", url, true); + xhr.send(formData); + }); + } + + fetchResult(id:string,accessMode:string,date:string){ + this._searchCrossrefService.searchCrossrefByDOIs([id]).subscribe( + data => { + + var crossrefResult = data.items[0]; + if(data.items.length > 0){ + this.foundIds.push(id); + var result = {id: id, type :'publication', source : 'crossref', + title: crossrefResult.title,url: crossrefResult.URL, result: crossrefResult, accessRights: accessMode, embargoEndDate: date, date : crossrefResult.created['date-time']}; + this.publications.push(result); + + + }else{ + this.notFoundIds.push(id); + } + this.endOfFetching(); + }, + err => { + console.log(err); + this.notFoundIds.push(id); + this.endOfFetching(); + } + ); + } + + endOfFetching(){ + if(this.allIds.length == this.foundIds.length+this.notFoundIds.length+ this.duplicateIds.length+this.noValidIds.length ){ + this.showReport = true; + this.enableUpload = true; + this.loading.close(); + + } + + } +} diff --git a/workingUIKIT/src/app/claims/linking/bulkClaim/bulkClaim.module.ts b/workingUIKIT/src/app/claims/linking/bulkClaim/bulkClaim.module.ts new file mode 100644 index 00000000..4f460152 --- /dev/null +++ b/workingUIKIT/src/app/claims/linking/bulkClaim/bulkClaim.module.ts @@ -0,0 +1,15 @@ +import { NgModule } from '@angular/core'; + +import { SharedModule } from '../../../shared/shared.module'; +import {LoadingModalModule} from '../../../utils/modal/loadingModal.module'; +import {BulkClaimComponent} from './bulkClaim.component'; +import {SearchCrossrefServiceModule} from '../../claim-utils/service/searchCrossrefService.module'; +@NgModule({ + imports: [ + SharedModule, LoadingModalModule, SearchCrossrefServiceModule + ], + declarations: [ +BulkClaimComponent + ], exports:[ BulkClaimComponent] +}) +export class BulkClaimModule { } diff --git a/workingUIKIT/src/app/claims/linking/bulkLinking.component.ts b/workingUIKIT/src/app/claims/linking/bulkLinking.component.ts new file mode 100644 index 00000000..96e32dcf --- /dev/null +++ b/workingUIKIT/src/app/claims/linking/bulkLinking.component.ts @@ -0,0 +1,16 @@ +// import {Component, Input} from '@angular/core'; +// import {Observable} from 'rxjs/Observable'; +// +// @Component({ +// selector: 'bulk-linking', +// //providers: [MdRadioDispatcher], +// template: ` +// +// ` +// +// }) +// //[(ngModel)]="date" +// export class BulkLinkingComponent { +// constructor () { +// } +// } diff --git a/workingUIKIT/src/app/claims/linking/bulkLinking.module.ts b/workingUIKIT/src/app/claims/linking/bulkLinking.module.ts new file mode 100644 index 00000000..55c71221 --- /dev/null +++ b/workingUIKIT/src/app/claims/linking/bulkLinking.module.ts @@ -0,0 +1,20 @@ +// import { NgModule } from '@angular/core'; +// +// import { SharedModule } from '../../shared/shared.module'; +// import { BulkLinkingComponent } from './bulkLinking.component'; +// import { BulkLinkingRoutingModule } from './bulkLinking-routing.module'; +// import {LinkingGenericModule} from './linkingGeneric.module'; +// import {BulkClaimModule} from './bulkClaim/bulkClaim.module'; +// @NgModule({ +// imports: [ +// SharedModule, +// BulkLinkingRoutingModule, +// LinkingGenericModule, +// BulkClaimModule +// +// ], +// declarations: [ +// BulkLinkingComponent +// ], exports:[BulkLinkingComponent] +// }) +// export class BulkLinkingModule { } diff --git a/workingUIKIT/src/app/claims/linking/insertClaim/insertClaim.component.ts b/workingUIKIT/src/app/claims/linking/insertClaim/insertClaim.component.ts new file mode 100644 index 00000000..49f4ad03 --- /dev/null +++ b/workingUIKIT/src/app/claims/linking/insertClaim/insertClaim.component.ts @@ -0,0 +1,364 @@ +import {Component, Input, Output, EventEmitter, ViewChild} from '@angular/core'; +import {Observable} from 'rxjs/Observable'; +import {Router} from '@angular/router'; +import {ClaimsService} from '../../claim-utils/service/claims.service'; +import {DirectIndexClaimService} from '../../claim-utils/service/directIndexClaim.service'; + +import {ModalLoading} from '../../../utils/modal/loading.component'; +import {AlertModal} from '../../../utils/modal/alert'; +import {Md5} from 'ts-md5/dist/md5'; +import {Session} from '../../../login/utils/helper.class'; +import {ErrorCodes} from '../../../login/utils/guardHelper.class'; + +@Component({ + selector: 'claim-insert', + template: ` +
+ +
+
+ +
+ + + + + + + ` +}) +export class ClaimInsertComponent { + constructor (private claimService: ClaimsService,private directIndexClaimService:DirectIndexClaimService, private _router:Router) {} + ngOnInit() { + // console.info("Inlineentity:" +(this.inlineEntity)?this.inlineEntity+(this.inlineEntity.id)?this.inlineEntity.id:"no id":"null"+ + " show "+ (!this.claiming && this.showButton) ); + } + + + @Input() public contexts; + @Input() public projects; + @Input() public results; + @Input() public showButton:boolean = true; + @Input() show='claim'; + @Input() inlineEntity = null; // the entity from the landing page + @Output() showChange = new EventEmitter(); + + @ViewChild (ModalLoading) loading : ModalLoading ; + @ViewChild(AlertModal) alert; + + public claiming =false; + public error = false; + public errorMessage = ""; + public warningMessage = ""; + public claimsTODO:number = 0; + public claims:number = 0; + + private servicesRespond:number = 0; + private insertedClaims=[]; + private errorInClaims=[]; + private insertedRecords=[]; + private errorInRecords=[]; +public validateInsertions(){ + // console.info("Inlineentity:" +(this.inlineEntity)?this.inlineEntity+(this.inlineEntity.id)?this.inlineEntity.id:"no id":"null"+ + " show "+ (!this.claiming && this.showButton) ); + if(this.validate()){ + if(this.validateDates()){ + this.insert(); + return true; + } + } + return +} +private insert(){ + this.servicesRespond = 0; + this.insertedClaims=[]; + this.errorInClaims=[]; + this.insertedRecords=[]; + this.errorInRecords=[]; + if(!Session.isValidAndRemove()){ + this.showButton = false; + localStorage.setItem("projects", JSON.stringify(this.projects)); + localStorage.setItem("contexts", JSON.stringify(this.contexts)); + localStorage.setItem("results", JSON.stringify(this.results)); + if(this.inlineEntity != null){ + localStorage.setItem("inlineEntity", JSON.stringify(this.inlineEntity)); + } + + this._router.navigate(['/user-info'], { queryParams: { "errorCode": ErrorCodes.NOT_VALID, "redirectUrl": this._router.url} }); + + }else{ + this.claiming = true; + var user=Session.getUserEmail(); + var token=Session.getUserJwt(); + this.loading.open(); + var claims = []; + var directclaims = []; + if(this.results){ + console.info("results: "+this.results.length); + + for (var i = 0; i < this.results.length; i++) { + var result=this.results[i]; + if(["crossref","datacite","orcid"].indexOf(result.source) != -1){ + directclaims.push({"id":result.id, "record":this.createDirectClaim(result,this.projects,this.contexts)}); + } + if(this.contexts){ + for (var j = 0; j < this.contexts.length; j++) { + var context = this.contexts[j]; + var claim = this.createContextClaim(result, context, user); + claims.push(claim); + } + } + if(this.projects){ + for (var k = 0; k < this.projects.length; k++) { + var project = this.projects[k]; + var projectClaim = this.createProjectClaim(result, project, user); + claims.push(projectClaim); + } + } + if(this.inlineEntity != null){ + var resultClaim = this.createResultClaim(this.inlineEntity, result, user); + claims.push(resultClaim); + } + + } + } + console.info("\n\ndirectclaims: "+directclaims.length+"\n\n"); + this.claimService.insertDirectRecords(directclaims,token).subscribe( + data => { + this.insertedRecords = data.insertedIds; + + this.errorInRecords = data.errorInClaims; + this.afterclaimsInsertion(); + }, + err => { + err=err.json(); + if(err.insertedIds && err.insertedIds.length >0){ + this.insertedRecords = err.insertedIds; + } + if(err.errorInClaims && err.errorInClaims.length >0){ + this.errorInRecords = err.errorInClaims; + } + this.afterclaimsInsertion(); + } + ); + console.info("try to insert "+claims.length+" claims"); + this.claimService.insertBulkClaims(claims,token).subscribe( + data => { + this.insertedClaims = data.insertedIds; + this.errorInClaims = data.errorInClaims; + this.afterclaimsInsertion(); + }, + err => { + err=err.json(); + if(err.insertedIds && err.insertedIds.length >0){ + this.insertedClaims = err.insertedIds; + } + if(err.errorInClaims && err.errorInClaims.length >0){ + this.errorInClaims = err.errorInClaims; + } + this.afterclaimsInsertion(); + } + ); + } + +} +private validate(){ + this.warningMessage = ""; + this.errorMessage = ""; + if( this.results && this.results.length == 0){ + this.warningMessage = "There are no research results selected."; + }else if((!this.contexts|| this.contexts.length==0 )&&(!this.projects|| this.projects.length==0 )&& ( this.inlineEntity == null)){ + this.warningMessage = "There are no projects or concepts to link."; + // }else if (this.inline && !this.inlineEntity){ + // this.errorMessage = "No inline entity"; + // console.log(this.inline + " "+ this.inlineEntity); + }else{ + return true; + } + return false; +} +private validateDates(){ + if(this.projects){ + for (var k = 0; k < this.projects.length; k++) { + var project = this.projects[k]; + console.info(project.startDate+" "+project.endDate + " "+project.projectAcronym); + if(this.results){ + for (var i = 0; i < this.results.length; i++) { + var result = this.results[i]; + if(result.date && result.date != null){ + console.info("Date :"+ result.date + " & embargoEndDate :" +result.embargoEndDate ); + if((project.startDate && result.date < project.startDate) || ( project.endDate && result.date > project.endDate) ){ + this.confirmOpen(); + return false; + } + } + } + } + + + } + } + if(this.results){ + for (var i = 0; i < this.results.length; i++) { + var result = this.results[i]; + if(result.date && result.date != null){ + console.info("Date :"+ result.date + " & embargoEndDate :" +result.embargoEndDate ); + if((result.embargoEndDate && result.embargoEndDate != null) && result.date >result.embargoEndDate ){ + this.confirmOpen(); + return false; + } + } + } + } + + return true; +} +private afterclaimsInsertion(){ + + this.servicesRespond++; + if(this.servicesRespond == 2){ + this.loading.close(); + this.claiming = false; + + if(this.errorInClaims.length == 0 && this.insertedClaims.length > 0 && this.errorInRecords.length == 0){ + + this._router.navigate( ['/myclaims'] ); + this.showChange.emit({ + value: this.show + }); + }else{ + this.errorsInClaimsInsertion(); + } + } +} +private errorsInClaimsInsertion(){ + this.errorMessage = ""; + this.loading.close(); + this.error = true; + this.claiming = false; + this.showButton = true; + var text ="" + console.log("Errors: this.errorInRecords.length: "+this.errorInRecords.length+" - this.errorInClaims.length: "+this.errorInClaims.length); + if(this.errorInRecords.length>0){ + text+="
The following records couldn't automatically inserted to the Openaire Info space:
    "; + for(var i=0; i< this.errorInRecords.length ; i++){ + for(var k=0; k< this.results.length ; k++){ + if(this.results[k].id == this.errorInRecords[i]){ + text+="
  • "+this.results[i].title+" from "+this.results[i].source+"
  • "; + } + } + } + text+="
"; + + } + if(this.errorInClaims.length > 0){ + text+="
The following links couldn't be saved:
    "; + for(var i=0; i< this.errorInClaims.length ; i++){ + // var claim = { claimedBy : user, sourceId : context.concept.id, sourceType : "context", sourceCollectedFrom:"openaire", sourceAccessRights:"OPEN", sourceEmbargoEndDate:"no", targetId : result.id , targetType : result.type, targetCollectedFrom: result.source, targetAccessRights:result.accessRights, targetEmbargoEndDate: (result.embargoEndDate == null?"":result.embargoEndDate)}; + + text+="
  • "+this.errorInClaims[i].sourceType+": "+this.errorInClaims[i].sourceId +"(from"+this.errorInClaims[i].sourceCollectedFrom+") link to "+this.errorInClaims[i].targetType+": "+this.errorInClaims[i].targetId +"(from"+this.errorInClaims[i].targetCollectedFrom+")
  • "; + + } + text+="
"; + } + this.errorMessage+="
An error occured:
"+text; + console.log(text); + // if(this.inline){ + // this.show = "error"; + // this.showChange.emit({ + // value: this.show + // }); + // } + +} + + + + private createContextClaim(result:any, context:any, user:any){ + var claim = { claimedBy : user, sourceId : context.concept.id, sourceType : "context", sourceCollectedFrom:"openaire", sourceAccessRights:"OPEN", sourceEmbargoEndDate:"no", targetId : result.id , targetType : result.type, targetCollectedFrom: result.source, targetAccessRights:result.accessRights, targetEmbargoEndDate: (result.embargoEndDate == null?"":result.embargoEndDate)}; + return claim; + } + private createProjectClaim(result:any, project:any, user:any){ + //project.projectId + // var dummyID = "dummyID"; + var claim = { claimedBy : user, sourceId : project.projectId, sourceType : "project", sourceCollectedFrom:"openaire", sourceAccessRights:"OPEN", sourceEmbargoEndDate:"", targetId : result.id , targetType : result.type, targetCollectedFrom: result.source, targetAccessRights:result.accessRights, targetEmbargoEndDate: (result.embargoEndDate == null?"":result.embargoEndDate)}; + return claim; + } + private createResultClaim(inlineResult:any, result:any, user:any){ + var claim = { claimedBy : user, sourceId : result.id, sourceType : result.type, sourceCollectedFrom: result.source, sourceAccessRights: result.accessRights, sourceEmbargoEndDate: result.embargoEndDate, targetId : inlineResult.id , targetType : inlineResult.type, targetCollectedFrom: inlineResult.source, targetAccessRights: inlineResult.accessRights, targetEmbargoEndDate: (inlineResult.embargoEndDate == null?"":inlineResult.embargoEndDate)}; + return claim; + } +createDirectClaim(result, projects, contexts){ + var entity = {}; + var md5_id = Md5.hashStr(result.id); + entity["originalId"]="user:claim__"+md5_id; + entity["title"]=result.title; + entity["title"] =(Array.isArray(result.title) && result.title.length > 0 )?result.title[0]:result.title; + + if(result.authors && result.authors.length > 0){ + entity["authors"]=result.authors; + } + if(result.publisher){ + entity["publisher"]=result.publisher; + } + if(result.description){ + entity["description"]=result.description; + } + // entity["language"]=""; no info + entity["type"]=result.type; + if(result.source == "crossref" || result.source == "datacite"){ + entity["pids"]= [];//{type:string, value:string}[]; + entity["pids"].push({type:"doi",value:result.id}) + } + entity["licenseCode"]=result.accessRights; + if(result.accessRights == "EMBARGO"){ + entity["embargoEndDate"]=result.embargoEndDate; + } + if(result.type =="publication"){ + entity["resourceType"]="0001"; + }else{ + entity["resourceType"]="0021"; + } + entity["url"]=result.url; + entity["hostedById"]="openaire____::1256f046-bf1f-4afc-8b47-d0b147148b18"; + if(result.source == "crossref"){ + entity["collectedFromId"]="openaire____::crossref"; + }else if(result.source == "datacite"){ + entity["collectedFromId"]="openaire____::datacite"; + }else if(result.source == "orcid"){ + entity["collectedFromId"]="openaire____::orcid"; + }else if(result.source == "orpenaire"){ + entity["collectedFromId"]="openaire____::driver"; + } + + if(projects.length>0){ + entity["linksToProjects"]=[]; + for(var i =0; i < projects.length; i++){ + // "info:eu-repo/grantAgreement/EC/FP7/283595/EU//OpenAIREplus", + entity["linksToProjects"].push("info:eu-repo/grantAgreement/"+projects[i].funderName+"/"+projects[i].fundingLevel0+"/"+projects[i].code+"/"+projects[i].jurisdiction+"/"+projects[i].projectName+"/"+projects[i].projectAcronym); + } + } + if(contexts.length > 0){ + entity["contexts"]=[]; + for(var i =0; i < contexts.length; i++){ + entity["contexts"].push(contexts[i].concept.id); + } + } + var json = JSON.stringify(entity); + console.log("\nJSON:\n"+json); + return entity; + + + +} + confirmOpen(){ + this.alert.cancelButton = true; + this.alert.okButton = true; + this.alert.alertTitle = "Invalid dates"; + this.alert.message = "There is a research result whose publication date is after project end date or before project start date. Or embargo end date of a research result is before research result's publication date."; + this.alert.okButtonText = "Procceed anyway"; + this.alert.cancelButtonText = "Cancel"; + this.alert.open(); + } + confirmClose(data){ + this.insert(); + } +} diff --git a/workingUIKIT/src/app/claims/linking/insertClaim/insertClaim.module.ts b/workingUIKIT/src/app/claims/linking/insertClaim/insertClaim.module.ts new file mode 100644 index 00000000..61781664 --- /dev/null +++ b/workingUIKIT/src/app/claims/linking/insertClaim/insertClaim.module.ts @@ -0,0 +1,18 @@ +import { NgModule } from '@angular/core'; + +import { SharedModule } from '../../../shared/shared.module'; +import {AlertModalModule} from '../../../utils/modal/alertModal.module'; +import {LoadingModalModule} from '../../../utils/modal/loadingModal.module'; +import {ClaimInsertComponent} from './insertClaim.component'; +import {ClaimServiceModule} from '../../claim-utils/service/claimsService.module'; +import {DirectIndexClaimService} from '../../claim-utils/service/directIndexClaim.service'; + +@NgModule({ + imports: [ + SharedModule, AlertModalModule, LoadingModalModule, ClaimServiceModule + ], + declarations: [ClaimInsertComponent], + providers:[DirectIndexClaimService], + exports:[ ClaimInsertComponent] +}) +export class InsertClaimsModule { } diff --git a/workingUIKIT/src/app/claims/linking/linking-routing.module.ts b/workingUIKIT/src/app/claims/linking/linking-routing.module.ts new file mode 100644 index 00000000..315f4502 --- /dev/null +++ b/workingUIKIT/src/app/claims/linking/linking-routing.module.ts @@ -0,0 +1,15 @@ +import { NgModule } from '@angular/core'; +import { RouterModule } from '@angular/router'; +import { LoginGuard} from'../../login/loginGuard.guard'; + +import { LinkingGenericComponent } from './linkingGeneric.component'; + +@NgModule({ + imports: [ + RouterModule.forChild([ + { path: '', component: LinkingGenericComponent, canActivate: [LoginGuard]}, + + ]) + ] +}) +export class LinkingRoutingModule { } diff --git a/workingUIKIT/src/app/claims/linking/linking.component.ts b/workingUIKIT/src/app/claims/linking/linking.component.ts new file mode 100644 index 00000000..dbf7a23f --- /dev/null +++ b/workingUIKIT/src/app/claims/linking/linking.component.ts @@ -0,0 +1,16 @@ +// import {Component, Input} from '@angular/core'; +// import {Observable} from 'rxjs/Observable'; +// import {LinkingGenericComponent} from './linkingGeneric.component'; +// +// @Component({ +// selector: 'linking', +// template: ` +// +// ` +// +// }) +// export class LinkingComponent { +// constructor () { +// } +// +// } diff --git a/workingUIKIT/src/app/claims/linking/linking.module.ts b/workingUIKIT/src/app/claims/linking/linking.module.ts new file mode 100644 index 00000000..6044de4a --- /dev/null +++ b/workingUIKIT/src/app/claims/linking/linking.module.ts @@ -0,0 +1,19 @@ +// import { NgModule } from '@angular/core'; +// +// import { SharedModule } from '../../shared/shared.module'; +// import { LinkingComponent } from './linking.component'; +// import { LinkingRoutingModule } from './linking-routing.module'; +// import {LinkingGenericModule} from './linkingGeneric.module'; +// +// @NgModule({ +// imports: [ +// SharedModule, +// LinkingRoutingModule, +// LinkingGenericModule +// +// ], +// declarations: [ +// LinkingComponent +// ], exports:[LinkingComponent] +// }) +// export class LinkingModule { } diff --git a/workingUIKIT/src/app/claims/linking/linkingGeneric.component.ts b/workingUIKIT/src/app/claims/linking/linkingGeneric.component.ts new file mode 100644 index 00000000..0fb474e9 --- /dev/null +++ b/workingUIKIT/src/app/claims/linking/linkingGeneric.component.ts @@ -0,0 +1,147 @@ +import {Component, Input} from '@angular/core'; +import {Observable} from 'rxjs/Observable'; +import {ActivatedRoute, Router} from '@angular/router'; +import {EntitiesSearchService} from '../../utils/entitiesAutoComplete/entitySearch.service'; +import {ClaimProject, ClaimResult} from '../claim-utils/claimEntities.class'; +import {SearchPublicationsService} from '../../services/searchPublications.service'; +import {SearchDatasetsService} from '../../services/searchDatasets.service'; + +@Component({ + selector: 'linking-generic', + template: ` +
+ + + + +
+
+ +
+
+ +
+
+ +
+ + +
+ + + + + +
+ + +` + +}) +export class LinkingGenericComponent { + + @Input() bulkMode: boolean = false; + sourceType:string; + targetType:string; + step:number = 1; + contexts=[]; + projects=[]; + results = []; + show = "result"; + date='8-6-2016'; + keyword: string = ""; + linkType:string ="project"; // link type (selected in home page) : project, context, software, etc + /* url Parameters for inline linking */ + id:string = null; //entity id + type:string = null; // entity type (publication or dataset) + linkTo:string = null; // entity type (project or context or result) + + entityTypes=["dataset", "publication", "project","context"]; + inlineResult:ClaimResult =null; + sub:any =null; + constructor ( private _router: Router, private route: ActivatedRoute, private entitySearch:EntitiesSearchService, private publicationsSearch:SearchPublicationsService, private datasetsSearch:SearchDatasetsService) { + + } + ngOnInit() { + if( typeof localStorage !== 'undefined') { + if(localStorage.getItem("projects")){ + this.projects = JSON.parse(localStorage.getItem("projects")); + + } + if(localStorage.getItem("contexts")){ + this.contexts = JSON.parse(localStorage.getItem("contexts")); + } + if(localStorage.getItem("results")){ + this.results = JSON.parse(localStorage.getItem("results")); + + } + localStorage.removeItem("projects"); + localStorage.removeItem("contexts"); + localStorage.removeItem("results"); + } + } + + next(){ + + if((this.show == 'result' && this.keyword == '')||(this.show == 'dataset' || this.show == 'publication')){ + this.show='claim'; + + } + } + prev(){ + if(this.show == 'claim'){ + this.show='result'; + } + } + + + resultsChange($event) { + this.results=$event.value; + } + + projectsChange($event) { + this.projects=$event.value; + } + + linkTypeChange($event) { + + this.linkType =$event.value; + this.show="result"; + if(this.bulkMode){ + this.show="claim"; + } + } + + showChange($event) { + this.show=$event.value; + this.showChangedType($event.value); + } + + showChangedType(type:string) { + this.show=type; + if(this.show == 'project' || this.show == 'context' || this.show == 'software'){ + this.linkType = this.show; + } + } + +} diff --git a/workingUIKIT/src/app/claims/linking/linkingGeneric.module.ts b/workingUIKIT/src/app/claims/linking/linkingGeneric.module.ts new file mode 100644 index 00000000..4c260b22 --- /dev/null +++ b/workingUIKIT/src/app/claims/linking/linkingGeneric.module.ts @@ -0,0 +1,29 @@ +import { NgModule } from '@angular/core'; + +import { SharedModule } from '../../shared/shared.module'; +import {SelectedProjectsModule} from './selected/selectedProjects.module'; +import {SelectedContextsModule} from './selected/selectedContexts.module'; +import {SelectedPublicationsModule} from './selected/selectedResults.module'; +import {InsertClaimsModule} from './insertClaim/insertClaim.module'; +import {LinkingGenericComponent} from './linkingGeneric.component'; +import {EntitySearchServiceModule} from '../../utils/entitiesAutoComplete/entitySearchService.module'; +import {PublicationsServiceModule} from '../../services/publicationsService.module'; +import {DatasetsServiceModule} from '../../services/datasetsService.module'; +import { LinkingRoutingModule } from './linking-routing.module'; +import {StartOverModule} from '../claim-utils/startOver.module'; +import {LoginGuard} from'../../login/loginGuard.guard'; + +@NgModule({ + imports: [ + SharedModule, SelectedProjectsModule, SelectedContextsModule, + SelectedPublicationsModule, + InsertClaimsModule, + EntitySearchServiceModule, PublicationsServiceModule, DatasetsServiceModule, LinkingRoutingModule, StartOverModule, + ], + providers:[LoginGuard], + declarations: [ + LinkingGenericComponent + ], exports:[ + LinkingGenericComponent ] +}) +export class LinkingGenericModule { } diff --git a/workingUIKIT/src/app/claims/linking/linkingHome.component.ts b/workingUIKIT/src/app/claims/linking/linkingHome.component.ts new file mode 100644 index 00000000..c3fb6c23 --- /dev/null +++ b/workingUIKIT/src/app/claims/linking/linkingHome.component.ts @@ -0,0 +1,57 @@ +// import {Component, Output, EventEmitter, Input} from '@angular/core'; +// import {Observable} from 'rxjs/Observable'; +// +// @Component({ +// selector: 'linking-home', +// template: ` +// +// +//
+//
+// Link with project +//

Link your research result with funded projects.

+//
+// +//
+// Link with Community +//

Link your research result with research communities.

+//
+// +//
+//
+// Bulk mode linking +//

Link Research Results to projects & communities, providing a CSV file with research results' DOIs

+// +//
+//
+//
+//
+// Linking +//

Search for Research Results and link them to projects & communities

+// +//
+//
+// +//
+// +// ` +// +// }) +// +// export class LinkingHomeComponent { +// @Output() linkTypeChange = new EventEmitter(); +// @Input() bulkMode:boolean = false; +// linkType:string = "project"; +// select(type:string){ +// this.linkType = type; +// this.linkTypeChange.emit({ +// value: this.linkType +// }); +// } +// +// } diff --git a/workingUIKIT/src/app/claims/linking/selected/selectedContexts.component.ts b/workingUIKIT/src/app/claims/linking/selected/selectedContexts.component.ts new file mode 100644 index 00000000..4a95ff69 --- /dev/null +++ b/workingUIKIT/src/app/claims/linking/selected/selectedContexts.component.ts @@ -0,0 +1,83 @@ +import {Component, Input,Output, EventEmitter} from '@angular/core'; +import {ClaimContext} from '../../claim-utils/claimEntities.class'; + +@Component({ + selector: 'claim-selected-contexts', + template: ` + + + +
+

{{title}} ({{(contexts.length)}})

+
+
+ +
    +
  • + {{context.community }} > {{context.category}} > {{context.concept.label}} + + +
  • +
+
There are no communities
+
+
+ + + ` +}) +export class ClaimSelectedContextsComponent { + ngOnInit() { + var myDate = new Date(); + this.todayDate=( myDate.getFullYear()+ "-" +myDate.getMonth() + 1) + "-" + myDate.getDate() ; + this.nextDate= ( (myDate.getFullYear()+100)+ "-" +myDate.getMonth() + 1) + "-" + myDate.getDate() ; + //2015-05-01 + // if(this.linkType == "context"){ + this.showsearch = true + // }else{ + // this.showsearch = false; + // } +} + + + @Input() contexts:ClaimContext[]; + //The following need to be kept in case we have to save the current state + @Input() public projects; + @Input() public results; + @Input() public inlineEntity; + @Input() componentClass:string = ""; //"" or "col-sm-6" for horizontal display (besides projects) + @Input() show='home'; + @Input() title='Communities'; + @Input() linkType:string = "project"; + + @Input() hideType; + @Input() bulkMode:boolean = false; + @Output() showChange = new EventEmitter(); + + showsearch:boolean = false; + + todayDate = ''; + nextDate = ''; + + showType(type){ + if(type != this.show){ + this.show = type; + this.showChange.emit({ + value: this.show + }); + } + } + + + removeContext(item:any){ + var index:number =this.contexts.indexOf(item); + if (index > -1) { + this.contexts.splice(index, 1); + } + + } + contextSelected($event) { + // this.showsearch = false; + } + +} diff --git a/workingUIKIT/src/app/claims/linking/selected/selectedContexts.module.ts b/workingUIKIT/src/app/claims/linking/selected/selectedContexts.module.ts new file mode 100644 index 00000000..746c5edd --- /dev/null +++ b/workingUIKIT/src/app/claims/linking/selected/selectedContexts.module.ts @@ -0,0 +1,15 @@ +import { NgModule } from '@angular/core'; + +import { SharedModule } from '../../../shared/shared.module'; +import {ClaimSelectedContextsComponent} from './selectedContexts.component'; +import {ClaimContextSearchFormModule} from '../../claim-utils/claimContextSearchForm.module'; + + @NgModule({ + imports: [ + SharedModule, ClaimContextSearchFormModule + ], + declarations: [ + ClaimSelectedContextsComponent + ], exports:[ClaimSelectedContextsComponent] +}) +export class SelectedContextsModule { } diff --git a/workingUIKIT/src/app/claims/linking/selected/selectedProjects.component.ts b/workingUIKIT/src/app/claims/linking/selected/selectedProjects.component.ts new file mode 100644 index 00000000..63f92dfd --- /dev/null +++ b/workingUIKIT/src/app/claims/linking/selected/selectedProjects.component.ts @@ -0,0 +1,99 @@ +import {Component, Input,Output, EventEmitter} from '@angular/core'; +import {ClaimProject} from '../../claim-utils/claimEntities.class'; +import {RouterHelper} from '../../../utils/routerHelper.class'; + +@Component({ + selector: 'claim-selected-projects', + template: ` + +
+

{{title}} ({{(projects.length)}}) + +

+ + +
+ + + ` +}) +export class ClaimSelectedProjectsComponent { + + +ngOnInit() { + var myDate = new Date(); + this.todayDate=( myDate.getFullYear()+ "-" +myDate.getMonth() + 1) + "-" + myDate.getDate() ; + this.nextDate= ( (myDate.getFullYear()+100)+ "-" +myDate.getMonth() + 1) + "-" + myDate.getDate() ; + // if(this.linkType == "project"){ + this.showsearch = true + // }else{ + // this.showsearch = false; + // } + //2015-05-01 +} + + +@Input() projects: ClaimProject[]; +@Input() show='home'; +@Input() title='Projects'; +@Input() linkType:string = "project"; +@Input() hideType; +@Input() bulkMode:boolean = false; +@Input() linkToResults:boolean = true; +@Output() projectsChange = new EventEmitter(); +@Output() showChange = new EventEmitter(); +showsearch:boolean = false; + +todayDate = ''; +nextDate = ''; +public routerHelper:RouterHelper = new RouterHelper(); + +removeProject(item:any){ + var index:number =this.projects.indexOf(item); + if (index > -1) { + this.projects.splice(index, 1); + } + this.projectsChange.emit({ + value: this.projects + }); +} +showType(type){ +if(type != this.show){ + this.show = type; + this.showChange.emit({ + value: this.show + }); +} +} +projectSelected($event) { + // this.showsearch = false; +} + + +} diff --git a/workingUIKIT/src/app/claims/linking/selected/selectedProjects.module.ts b/workingUIKIT/src/app/claims/linking/selected/selectedProjects.module.ts new file mode 100644 index 00000000..528ee92f --- /dev/null +++ b/workingUIKIT/src/app/claims/linking/selected/selectedProjects.module.ts @@ -0,0 +1,17 @@ + +import { NgModule } from '@angular/core'; +import { RouterModule } from '@angular/router'; + +import { SharedModule } from '../../../shared/shared.module'; +import {ClaimSelectedProjectsComponent} from './selectedProjects.component'; +import {ClaimProjectsSearchFormModule} from '../../claim-utils/claimProjectSearchForm.module'; + + @NgModule({ + imports: [ + SharedModule, RouterModule, ClaimProjectsSearchFormModule + ], + declarations: [ + ClaimSelectedProjectsComponent + ], exports:[ClaimSelectedProjectsComponent] +}) +export class SelectedProjectsModule { } diff --git a/workingUIKIT/src/app/claims/linking/selected/selectedResults.component.ts b/workingUIKIT/src/app/claims/linking/selected/selectedResults.component.ts new file mode 100644 index 00000000..1b776133 --- /dev/null +++ b/workingUIKIT/src/app/claims/linking/selected/selectedResults.component.ts @@ -0,0 +1,185 @@ +import {Component, Input,Output, EventEmitter, ViewChild} from '@angular/core'; +import {AlertModal} from '../../../utils/modal/alert'; +import {ClaimResult} from '../../claim-utils/claimEntities.class'; +// import {IMyOptions} from '../../../utils/my-date-picker/interfaces/my-options.interface'; +// import {IMyDateModel} from '../../../utils/my-date-picker/interfaces/my-date-model.interface'; +import {IMyOptions, IMyDateModel} from '../../../utils/my-date-picker/interfaces/index'; +import {Dates} from '../../../utils/string-utils.class'; + +@Component({ + selector: 'claim-selected-results', + template: ` + + +
+

{{title}} ({{results.length}})

+
+ +
+
+ + +
+
+ +
There are no research results
+ +
    +
  • +
    +
    +
    + + {{pub.title}} + {{pub.title}} + +
    + + + + + + + + + + + + + +
    +
    + + + + + + + + +
    +
    + + + + +
    +
    +
  • + +
+ + +
+
+
+ + ` + +}) +export class ClaimSelectedResultsComponent { + ngOnInit() { + var myDate = new Date(); + this.nextDate = { date: { year: myDate.getFullYear()+10, month: (myDate.getMonth()+1), day: myDate.getDate() } }; + //2015-05-01 + +} + + @Input() results: ClaimResult[]; + @Input() title:string = "Research Results"; + @Input() showAccessRights:boolean = false; + @Input() bulkMode:boolean = false; + // @Output()resultsChange = new EventEmitter(); + @Input() showSearch:boolean = false; + nextDate = {}; + @ViewChild(AlertModal) alertApplyAll; + +public commonAccessRights = "OPEN"; // for access rights- changes when user apply a change to every result +public commonEmbargoEndDate; // for access rights: embargoEndDate - changes when user apply a change to every result +accessTypes = ["OPEN","CLOSED","EMBARGO","RESTRICTED"]; +private myDatePickerOptions: IMyOptions = { + // other options... + dateFormat: 'yyyy-mm-dd', + selectionTxtFontSize: '15px', + height:'28px', + width: '100%', + editableDateField: false, + showClearDateBtn: false + }; + + + removePublication(item:any){ + var index:number =this.results.indexOf(item); + if (index > -1) { + this.results.splice(index, 1); + } + // this.resultsChange.emit({ + // value: this.results + // }); + } + + + onDateChanged (event:any, item:any) { + item.embargoEndDate = Dates.getDateFromString(event.formatted); + if(this.results.length > 1 ){ + this.commonAccessRights = "EMBARGO"; + this.commonEmbargoEndDate = item.embargoEndDate; + this.confirmOpen(); + } + + } + // resultsChanged($event) { + // this.results=$event.value; + // this.resultsChange.emit({ + // value: this.results + // }); + // } + /* The following methods: + *typeChanged + *confirmOpen + *confirmClose + implement the functionality: change accessRights of a publication - apply to all if asked */ + accessRightsTypeChanged (type:any, item:any) { + item.accessRights = type; + if(this.results.length > 1 ){ + this.commonAccessRights = type; + if(this.commonAccessRights != "EMBARGO"){ + this.commonEmbargoEndDate = item.embargoEndDate; + this.confirmOpen(); + } + } + + } + confirmOpen(){ + this.alertApplyAll.cancelButton = true; + this.alertApplyAll.okButton = true; + this.alertApplyAll.alertTitle = "Change access rights"; + this.alertApplyAll.message = "Do you wish to apply the change to every result?"; + this.alertApplyAll.okButtonText = "Yes"; + this.alertApplyAll.cancelButtonText = "No"; + this.alertApplyAll.open(); + } + confirmClose(data){ + for (var i = 0; i < this.results.length; i++) { + if(this.results[i].source != 'openaire' ){ + this.results[i].accessRights = this.commonAccessRights; + if(this.commonAccessRights == "EMBARGO"){ + this.results[i].embargoEndDate = this.commonEmbargoEndDate; + } + } + } + } +} diff --git a/workingUIKIT/src/app/claims/linking/selected/selectedResults.module.ts b/workingUIKIT/src/app/claims/linking/selected/selectedResults.module.ts new file mode 100644 index 00000000..4d21b36a --- /dev/null +++ b/workingUIKIT/src/app/claims/linking/selected/selectedResults.module.ts @@ -0,0 +1,18 @@ +import { NgModule } from '@angular/core'; + +import { SharedModule } from '../../../shared/shared.module'; +import {ClaimSelectedResultsComponent} from './selectedResults.component'; +import {AlertModalModule} from '../../../utils/modal/alertModal.module'; +import {ClaimResultSearchFormModule} from '../../claim-utils/claimResultSearchForm.module'; +import { MyDatePickerModule } from '../../../utils/my-date-picker/my-date-picker.module'; +import {BulkClaimModule} from '../bulkClaim/bulkClaim.module'; + +@NgModule({ + imports: [ + SharedModule, AlertModalModule, ClaimResultSearchFormModule, MyDatePickerModule, BulkClaimModule + ], + declarations: [ + ClaimSelectedResultsComponent + ], exports:[ClaimSelectedResultsComponent] +}) +export class SelectedPublicationsModule { } diff --git a/workingUIKIT/src/app/claims/myClaims/myClaims-routing.module.ts b/workingUIKIT/src/app/claims/myClaims/myClaims-routing.module.ts new file mode 100644 index 00000000..287797a5 --- /dev/null +++ b/workingUIKIT/src/app/claims/myClaims/myClaims-routing.module.ts @@ -0,0 +1,15 @@ +import { NgModule } from '@angular/core'; +import { RouterModule } from '@angular/router'; +import { LoginGuard} from'../../login/loginGuard.guard'; + +import { MyClaimsComponent } from './myClaims.component'; + +@NgModule({ + imports: [ + RouterModule.forChild([ + { path: '', component: MyClaimsComponent, canActivate: [LoginGuard]}, + + ]) + ] +}) +export class MyClaimsRoutingModule { } diff --git a/workingUIKIT/src/app/claims/myClaims/myClaims.component.ts b/workingUIKIT/src/app/claims/myClaims/myClaims.component.ts new file mode 100644 index 00000000..c7bc727a --- /dev/null +++ b/workingUIKIT/src/app/claims/myClaims/myClaims.component.ts @@ -0,0 +1,29 @@ +import {Component, Input} from '@angular/core'; +import {Observable} from 'rxjs/Observable'; + + + +@Component({ + selector: 'my-claims', + template: ` +
+ + +
+ +` + +}) + export class MyClaimsComponent { + constructor () { + } + ngOnInit() { + + } + +} diff --git a/workingUIKIT/src/app/claims/myClaims/myClaims.module.ts b/workingUIKIT/src/app/claims/myClaims/myClaims.module.ts new file mode 100644 index 00000000..b3ea8b07 --- /dev/null +++ b/workingUIKIT/src/app/claims/myClaims/myClaims.module.ts @@ -0,0 +1,23 @@ +import { NgModule } from '@angular/core'; + +import { SharedModule } from '../../shared/shared.module'; +import { MyClaimsComponent } from './myClaims.component'; +import { MyClaimsRoutingModule } from './myClaims-routing.module'; +// import{ClaimServiceModule} from '../claim-utils/service/claimsService.module'; +import {DisplayClaimsModule} from '../claim-utils/displayClaims/displayClaims.module'; +import {LoginGuard} from'../../login/loginGuard.guard'; + +@NgModule({ + imports: [ + SharedModule, + MyClaimsRoutingModule, + // ClaimServiceModule, + DisplayClaimsModule + + ], + providers:[LoginGuard], + declarations: [ + MyClaimsComponent + ] +}) +export class MyClaimsModule { } diff --git a/workingUIKIT/src/app/claims/myClaimsDemo.component.ts b/workingUIKIT/src/app/claims/myClaimsDemo.component.ts new file mode 100644 index 00000000..6490a59c --- /dev/null +++ b/workingUIKIT/src/app/claims/myClaimsDemo.component.ts @@ -0,0 +1,51 @@ +// import {Component, Input} from '@angular/core'; +// import {Observable} from 'rxjs/Observable'; +// import { Router } from '@angular/router'; +// +// +// +// @Component({ +// selector: 'my-claims-demo', +// template: ` +//
+// +//
+// +// +// +//

Extra parameters for claims admin

+// +// +// +// +// +// +// +//
+//
+// +// +// +// ` +// //(click)="changeOrderby('target')" +// //od_______908::3a5b2885656a91307156325644e73b92 +// +// }) +// export class MyClaimsDemoComponent { +// constructor ( private _router: Router ) { +// } +// user:string="argirok@di.uoa.gr"; +// ngOnInit() { +// +// } +// goToPub(id: number){ +// this._router.navigate( ['Publication', { articleId: id}] ); +// } +// } diff --git a/workingUIKIT/src/app/deposit/datasets/depositDatasets-routing.module.ts b/workingUIKIT/src/app/deposit/datasets/depositDatasets-routing.module.ts new file mode 100644 index 00000000..6c139e2b --- /dev/null +++ b/workingUIKIT/src/app/deposit/datasets/depositDatasets-routing.module.ts @@ -0,0 +1,16 @@ +import { NgModule } from '@angular/core'; +import { RouterModule } from '@angular/router'; + +import { DepositDatasetsComponent } from './depositDatasets.component'; +import { DepositDatasetsResultComponent } from './depositDatasetsResult.component'; +import {FreeGuard} from'../../login/freeGuard.guard'; + +@NgModule({ + imports: [ + RouterModule.forChild([ + { path: '', component: DepositDatasetsComponent, canActivate: [FreeGuard] } + + ]) + ] +}) +export class DepositDatasetsRoutingModule { } diff --git a/workingUIKIT/src/app/deposit/datasets/depositDatasets.component.ts b/workingUIKIT/src/app/deposit/datasets/depositDatasets.component.ts new file mode 100644 index 00000000..489e60d9 --- /dev/null +++ b/workingUIKIT/src/app/deposit/datasets/depositDatasets.component.ts @@ -0,0 +1,12 @@ +import {Component} from '@angular/core'; + +@Component({ + selector: 'deposit-datasets', + template: ` + + ` +}) + +export class DepositDatasetsComponent { + +} diff --git a/workingUIKIT/src/app/deposit/datasets/depositDatasets.module.ts b/workingUIKIT/src/app/deposit/datasets/depositDatasets.module.ts new file mode 100644 index 00000000..e37a282f --- /dev/null +++ b/workingUIKIT/src/app/deposit/datasets/depositDatasets.module.ts @@ -0,0 +1,29 @@ +import { NgModule } from '@angular/core'; +import { CommonModule } from '@angular/common'; +import { FormsModule } from '@angular/forms'; + +import { DepositDatasetsComponent } from './depositDatasets.component'; +import { DepositDatasetsResultComponent } from './depositDatasetsResult.component'; + +import {DepositDatasetsRoutingModule} from './depositDatasets-routing.module'; +import {DepoditModule} from '../deposit.module'; +import {FreeGuard} from'../../login/freeGuard.guard'; + +@NgModule({ + imports: [ + CommonModule, FormsModule, + DepoditModule, + DepositDatasetsRoutingModule + ], + declarations: [ + + DepositDatasetsComponent, + + ], + exports: [ + DepositDatasetsComponent, + ], + providers: [FreeGuard + ] +}) +export class DepositDatasetsModule { } diff --git a/workingUIKIT/src/app/deposit/datasets/depositDatasetsResult.component.ts b/workingUIKIT/src/app/deposit/datasets/depositDatasetsResult.component.ts new file mode 100644 index 00000000..8f62b636 --- /dev/null +++ b/workingUIKIT/src/app/deposit/datasets/depositDatasetsResult.component.ts @@ -0,0 +1,12 @@ +import {Component} from '@angular/core'; + +@Component({ + selector: 'deposit-datasets-result', + template: ` + + ` +}) + +export class DepositDatasetsResultComponent { + +} diff --git a/workingUIKIT/src/app/deposit/datasets/depositDatasetsResults-routing.module.ts b/workingUIKIT/src/app/deposit/datasets/depositDatasetsResults-routing.module.ts new file mode 100644 index 00000000..158810f0 --- /dev/null +++ b/workingUIKIT/src/app/deposit/datasets/depositDatasetsResults-routing.module.ts @@ -0,0 +1,15 @@ +import { NgModule } from '@angular/core'; +import { RouterModule } from '@angular/router'; + +import { DepositDatasetsResultComponent } from './depositDatasetsResult.component'; +import {FreeGuard} from'../../login/freeGuard.guard'; + +@NgModule({ + imports: [ + RouterModule.forChild([ + { path: '', component: DepositDatasetsResultComponent, canActivate: [FreeGuard] } + + ]) + ] +}) +export class DepositDatasetsResultsRoutingModule { } diff --git a/workingUIKIT/src/app/deposit/datasets/depositDatasetsResults.module.ts b/workingUIKIT/src/app/deposit/datasets/depositDatasetsResults.module.ts new file mode 100644 index 00000000..d4704b5b --- /dev/null +++ b/workingUIKIT/src/app/deposit/datasets/depositDatasetsResults.module.ts @@ -0,0 +1,28 @@ +import { NgModule } from '@angular/core'; +import { CommonModule } from '@angular/common'; +import { FormsModule } from '@angular/forms'; + +import { DepositDatasetsResultComponent } from './depositDatasetsResult.component'; + +import {DepositDatasetsResultsRoutingModule} from './depositDatasetsResults-routing.module'; +import {DepoditModule} from '../deposit.module'; +import {FreeGuard} from'../../login/freeGuard.guard'; + +@NgModule({ + imports: [ + CommonModule, FormsModule, + DepoditModule, + DepositDatasetsResultsRoutingModule + ], + declarations: [ + + DepositDatasetsResultComponent, + + ], + exports: [ + DepositDatasetsResultComponent, + ], + providers: [FreeGuard + ] +}) +export class DepositDatasetsResultsModule { } diff --git a/workingUIKIT/src/app/deposit/deposit.component.ts b/workingUIKIT/src/app/deposit/deposit.component.ts new file mode 100644 index 00000000..82cd98e1 --- /dev/null +++ b/workingUIKIT/src/app/deposit/deposit.component.ts @@ -0,0 +1,106 @@ +import {Component, Input} from '@angular/core'; +import {Observable} from 'rxjs/Observable'; +import { Router } from '@angular/router'; +import {OpenaireProperties, ErrorCodes} from '../utils/properties/openaireProperties'; +import { Meta} from '../../angular2-meta'; + + +@Component({ + selector: 'deposit', + template: ` +
+ + +
+

+ + Are you a grant recipient from the following: H2020; FP7 with SC39; or ERC? + + Then you are required to publish in + open access (). + One way to do this is to deposit your {{requestFor}} into an + open access repository (). +

+

+ Click the following to find more information: + FP7 guidelines (), + H2020 guidelines (), + ERC guidelines () OR + ask a question () to OpenAIRE’s national representative. +

+ +

Locate data provider via your institution

+ +
+ + + + +
+
+
+ ` +}) + +export class DepositComponent { + @Input() keyword: string=''; + public openAccess: string; + public openAccessRepo: string; + public fp7Guidlines: string; + public h2020Guidlines: string; + public ercGuidlines: string; + public helpdesk: string; + @Input() compatibility: string = ''; + @Input() requestFor: string = "Publications"; + + public status: number; + public errorCodes:ErrorCodes = new ErrorCodes(); + public selectedId: string = ""; + public warningMessage: string = ""; + + constructor (private _router: Router, private _meta: Meta) { + + this.openAccess = OpenaireProperties.getOpenAccess(); + this.openAccessRepo = OpenaireProperties.getOpenAccessRepo(); + this.fp7Guidlines = OpenaireProperties.getFP7Guidlines(); + this.h2020Guidlines = OpenaireProperties.getH2020Guidlines(); + this.ercGuidlines = OpenaireProperties.getERCGuidlines(); + this.helpdesk = OpenaireProperties.getHelpdesk(); + this.updateTitle("Deposit "+this.requestFor); + this.updateDescription("Openaire, repositories, open access, data provider, compatibility, organization, deposit "+ this.requestFor); + } + updateDescription(description:string){ + this._meta.updateMeta("description", description); + this._meta.updateMeta("og:description", description); + } + updateTitle(title:string){ + var _suffix ="| OpenAIRE"; + var _title = ((title.length> 50 ) ?title.substring(0,50):title) + _suffix; + this._meta.setTitle(_title ); + this._meta.updateMeta("og:title",_title); + } + + + organizationSelected(id: string) { + console.info("organization selected"); + if(id && id.length > 0){ + if(this.requestFor == "Publications") { + this._router.navigate( ['participate/deposit-publications-result'], { queryParams: { "organizationId": id } } ); + } else if(this.requestFor == "Research Data") { + this._router.navigate( ['participate/deposit-datasets-result'], { queryParams: { "organizationId": id } } ); + } + } else { + this.warningMessage = "No organization selected"; + } + } + + valueChanged($event){ + this.selectedId = $event.value; + } +} diff --git a/workingUIKIT/src/app/deposit/deposit.module.ts b/workingUIKIT/src/app/deposit/deposit.module.ts new file mode 100644 index 00000000..85ff6657 --- /dev/null +++ b/workingUIKIT/src/app/deposit/deposit.module.ts @@ -0,0 +1,37 @@ +/* Common Component of deposit for both datasets & ppublications*/ + +import { NgModule } from '@angular/core'; +import { CommonModule } from '@angular/common'; +import { FormsModule } from '@angular/forms'; +import { RouterModule } from '@angular/router'; + +import { DepositComponent } from './deposit.component'; +import { DepositResultComponent } from './depositResult.component'; +import {EntitiesAutocompleteModule} from '../utils/entitiesAutoComplete/entitiesAutoComplete.module'; +import {DataProvidersServiceModule} from '../services/dataProvidersService.module'; +import {OrganizationServiceModule} from '../services/organizationService.module'; +import {SearchResultsModule } from '../searchPages/searchUtils/searchResults.module'; + + + @NgModule({ + imports: [ + CommonModule, FormsModule, + RouterModule, + EntitiesAutocompleteModule, + DataProvidersServiceModule, + OrganizationServiceModule, + SearchResultsModule + ], + declarations: [ + DepositComponent, + DepositResultComponent + + ], + exports: [ + DepositComponent, + DepositResultComponent + ], + providers: [ + ] +}) +export class DepoditModule { } diff --git a/workingUIKIT/src/app/deposit/depositResult.component.ts b/workingUIKIT/src/app/deposit/depositResult.component.ts new file mode 100644 index 00000000..3ee3e580 --- /dev/null +++ b/workingUIKIT/src/app/deposit/depositResult.component.ts @@ -0,0 +1,204 @@ +import {Component, Input} from '@angular/core'; +import {Observable} from 'rxjs/Observable'; +import {OpenaireProperties, ErrorCodes} from '../utils/properties/openaireProperties'; +import { Router } from '@angular/router'; +import { ActivatedRoute } from '@angular/router'; +import { FetchDataproviders } from '../utils/fetchEntitiesClasses/fetchDataproviders.class'; +import { SearchDataprovidersService } from '../services/searchDataproviders.service'; + +import {OrganizationService} from '../services/organization.service'; +import { Meta} from '../../angular2-meta'; + +import {RouterHelper} from '../utils/routerHelper.class'; + +@Component({ + selector: 'deposit-result', + template: ` +
+ + + + + + +
+

+ Data providers for institution: + + {{organization['name']}} () + + {{organization['name']}} +

+ + +
+ +
+

Please use the information/contacts shown below to deposit your {{requestFor}}.

+ + + + +
+ + +
+
+ + An error occured. + + No data providers found for institution: + + {{organization['name']}} + + {{organization['name']}} + . +
+
+ No organization with ID: {{organizationId}} found. +
+
+ An error occured. +
+
+ No ID for organization. +
+ + You can still deposit your {{requestFor}} in + OpenAIRE's Zenodo catch-all repository () + hosted by CERN. +
+ + +
+ ` +}) + +export class DepositResultComponent { + public organization: {"name": string, "url": string}; + public organizationId: string = ""; + + public status: number; + public errorCodes:ErrorCodes = new ErrorCodes(); + + sub: any; + subDataproviders: any; + + public routerHelper:RouterHelper = new RouterHelper(); + public fetchDataproviders : FetchDataproviders; + public linkToSearchDataproviders = ""; + public zenodo: string; + @Input() compatibility: string = ''; + @Input() requestFor: string = "Publications"; + + constructor (private _router: Router, + private route: ActivatedRoute, + private _searchDataprovidersService: SearchDataprovidersService, + private _organizationService: OrganizationService, private _meta: Meta) { + + this.zenodo = OpenaireProperties.getZenodoURL(); + this.fetchDataproviders = new FetchDataproviders(this._searchDataprovidersService); + + this.status = this.errorCodes.LOADING; + this.updateTitle("Deposit "+this.requestFor); + this.updateDescription("Openaire, repositories, open access, data provider, compatibility, organization, deposit "+ this.requestFor); + } + updateDescription(description:string){ + this._meta.updateMeta("description", description); + this._meta.updateMeta("og:description", description); + } + updateTitle(title:string){ + var _suffix ="| OpenAIRE"; + var _title = ((title.length> 50 ) ?title.substring(0,50):title) + _suffix; + this._meta.setTitle(_title ); + this._meta.updateMeta("og:title",_title); + } + + + ngOnInit() { + console.info('depositResult init'); + + this.sub = this.route.queryParams.subscribe(params => { + this.organizationId = params['organizationId']; + console.info("Id is :"+this.organizationId); + if(this.organizationId){ + this.getOrganizationInfo(); + } + }); + } + + ngDoCheck() { + if(this.organizationId == "" || this.organizationId == undefined) { + this.organizationId = ""; + this.status = this.errorCodes.ERROR; + } + } + + ngOnDestroy() { + this.sub.unsubscribe(); + if(this.subDataproviders != undefined) { + this.subDataproviders.unsubscribe(); + } + } + + private searchDataproviders() { + // if(this.organization != undefined) { + // this.fetchDataproviders.getResults(this.organization.name, false, 1, 10); + // } else if(this.organizationId != undefined) { + this.fetchDataproviders.getResultsForDeposit( this.organizationId,this.requestFor, 1, 10); + //} + this.linkToSearchDataproviders = OpenaireProperties.getLinkToSearchDataProviders(); + } + + private getOrganizationInfo () { + console.info("inside getOrganizationInfo of component"); + + this._organizationService.getOrganizationInfo(this.organizationId).subscribe( + data => { + this.organization = data.title; + this.status = this.errorCodes.DONE; + this.subDataproviders = this.route.queryParams.subscribe(params => { + this.searchDataproviders(); + }); + }, + err => { + //console.log(err) + + if(err.status == '404') { + this.status = this.errorCodes.NONE; + console.info("none"); + } else { + this.status = this.errorCodes.ERROR; + console.info("error"); + } + } + ); + } + + goToDeposit() { + if(this.requestFor == "Publications") { + this._router.navigate( ['participate/deposit-publications'] ); + } else if(this.requestFor == "Research Data") { + this._router.navigate( ['participate/deposit-datasets'] ); + } + } +} diff --git a/workingUIKIT/src/app/deposit/publications/depositPublications-routing.module.ts b/workingUIKIT/src/app/deposit/publications/depositPublications-routing.module.ts new file mode 100644 index 00000000..e7fbcc84 --- /dev/null +++ b/workingUIKIT/src/app/deposit/publications/depositPublications-routing.module.ts @@ -0,0 +1,15 @@ +import { NgModule } from '@angular/core'; +import { RouterModule } from '@angular/router'; + +import { DepositPublicationsComponent } from './depositPublications.component'; +import {FreeGuard} from'../../login/freeGuard.guard'; + +@NgModule({ + imports: [ + RouterModule.forChild([ + { path: '', component: DepositPublicationsComponent, canActivate: [FreeGuard] } + + ]) + ] +}) +export class DepositPublicationsRoutingModule { } diff --git a/workingUIKIT/src/app/deposit/publications/depositPublications.component.ts b/workingUIKIT/src/app/deposit/publications/depositPublications.component.ts new file mode 100644 index 00000000..5669e685 --- /dev/null +++ b/workingUIKIT/src/app/deposit/publications/depositPublications.component.ts @@ -0,0 +1,16 @@ +import {Component} from '@angular/core'; + +@Component({ + selector: 'deposit-publications', + template: ` + +

Or locate data provider in map

+
+ +
+ ` +}) + +export class DepositPublicationsComponent { + public mapUrl ="https://beta.openaire.eu/stats/markers-demo.html"; +} diff --git a/workingUIKIT/src/app/deposit/publications/depositPublications.module.ts b/workingUIKIT/src/app/deposit/publications/depositPublications.module.ts new file mode 100644 index 00000000..77ccc00e --- /dev/null +++ b/workingUIKIT/src/app/deposit/publications/depositPublications.module.ts @@ -0,0 +1,29 @@ +import { NgModule } from '@angular/core'; +import { CommonModule } from '@angular/common'; +import { FormsModule } from '@angular/forms'; + +import { DepositPublicationsComponent } from './depositPublications.component'; + +import {DepositPublicationsRoutingModule} from './depositPublications-routing.module'; +import {DepoditModule} from '../deposit.module'; +import {IFrameModule} from '../../utils/iframe.module'; +import {FreeGuard} from'../../login/freeGuard.guard'; + +@NgModule({ + imports: [ + CommonModule, FormsModule, + DepoditModule, + DepositPublicationsRoutingModule,IFrameModule + ], + declarations: [ + + DepositPublicationsComponent, + + ], + exports: [ + DepositPublicationsComponent, + ], + providers: [FreeGuard + ] +}) +export class DepositPublicationsModule { } diff --git a/workingUIKIT/src/app/deposit/publications/depositPublicationsResult-routing.module.ts b/workingUIKIT/src/app/deposit/publications/depositPublicationsResult-routing.module.ts new file mode 100644 index 00000000..bdd8a8f2 --- /dev/null +++ b/workingUIKIT/src/app/deposit/publications/depositPublicationsResult-routing.module.ts @@ -0,0 +1,15 @@ +import { NgModule } from '@angular/core'; +import { RouterModule } from '@angular/router'; + +import { DepositPublicationsResultComponent } from './depositPublicationsResult.component'; +import {FreeGuard} from'../../login/freeGuard.guard'; + +@NgModule({ + imports: [ + RouterModule.forChild([ + { path: '', component: DepositPublicationsResultComponent, canActivate: [FreeGuard] } + + ]) + ] +}) +export class DepositPublicationsResultRoutingModule { } diff --git a/workingUIKIT/src/app/deposit/publications/depositPublicationsResult.component.ts b/workingUIKIT/src/app/deposit/publications/depositPublicationsResult.component.ts new file mode 100644 index 00000000..c7da81eb --- /dev/null +++ b/workingUIKIT/src/app/deposit/publications/depositPublicationsResult.component.ts @@ -0,0 +1,12 @@ +import {Component} from '@angular/core'; + +@Component({ + selector: 'deposit-publications-result', + template: ` + + ` +}) + +export class DepositPublicationsResultComponent { + +} diff --git a/workingUIKIT/src/app/deposit/publications/depositPublicationsResults.module.ts b/workingUIKIT/src/app/deposit/publications/depositPublicationsResults.module.ts new file mode 100644 index 00000000..d5f5bb90 --- /dev/null +++ b/workingUIKIT/src/app/deposit/publications/depositPublicationsResults.module.ts @@ -0,0 +1,28 @@ +import { NgModule } from '@angular/core'; +import { CommonModule } from '@angular/common'; +import { FormsModule } from '@angular/forms'; + +import { DepositPublicationsResultComponent } from './depositPublicationsResult.component'; + +import {DepositPublicationsResultRoutingModule} from './depositPublicationsResult-routing.module'; +import {DepoditModule} from '../deposit.module'; +import {FreeGuard} from'../../login/freeGuard.guard'; + +@NgModule({ + imports: [ + CommonModule, FormsModule, + DepoditModule, + DepositPublicationsResultRoutingModule + ], + declarations: [ + + DepositPublicationsResultComponent, + + ], + exports: [ + DepositPublicationsResultComponent, + ], + providers: [FreeGuard + ] +}) +export class DepositPublicationsResultsModule { } diff --git a/workingUIKIT/src/app/error/error-routing.module.ts b/workingUIKIT/src/app/error/error-routing.module.ts new file mode 100644 index 00000000..e3dc1986 --- /dev/null +++ b/workingUIKIT/src/app/error/error-routing.module.ts @@ -0,0 +1,15 @@ +import { NgModule } from '@angular/core'; +import { RouterModule } from '@angular/router'; + +import { ErrorPageComponent } from './errorPage.component'; + +@NgModule({ + imports: [ + RouterModule.forChild([ + { path: 'error', component: ErrorPageComponent}, + { path: '**', component: ErrorPageComponent}, + + ]) + ] +}) +export class ErrorRoutingModule { } diff --git a/workingUIKIT/src/app/error/error.module.ts b/workingUIKIT/src/app/error/error.module.ts new file mode 100644 index 00000000..d1905ce6 --- /dev/null +++ b/workingUIKIT/src/app/error/error.module.ts @@ -0,0 +1,19 @@ +import { NgModule} from '@angular/core'; +import { CommonModule } from '@angular/common'; +import { FormsModule } from '@angular/forms'; + +import { ErrorPageComponent } from './errorPage.component'; +import { ErrorRoutingModule } from './error-routing.module'; + +@NgModule({ + imports: [ + CommonModule, FormsModule, + ErrorRoutingModule + + ], + declarations: [ +ErrorPageComponent + +] +}) +export class ErrorModule { } diff --git a/workingUIKIT/src/app/error/errorPage.component.ts b/workingUIKIT/src/app/error/errorPage.component.ts new file mode 100644 index 00000000..a59c7037 --- /dev/null +++ b/workingUIKIT/src/app/error/errorPage.component.ts @@ -0,0 +1,35 @@ +import { Component, Input } from '@angular/core'; +import { Location } from '@angular/common'; + +@Component({ + selector: 'error', + template: ` +
+

+ Bad karma: we can't find that page! +

+
+ +

+ You asked for {{page}}, but despite our computers looking very hard, we could not find it. What happened ? +

+ +
    +
  • the link you clicked to arrive here has a typo in it
  • +
  • or somehow we removed that page, or gave it another name
  • +
  • or, quite unlikely for sure, maybe you typed it yourself and there was a little mistake ?
  • +
+ +
+ ` +}) + +export class ErrorPageComponent { + public page: string; + + constructor (private _location: Location) { + this.page = _location.path(true); + //this.page = _router.url; + //this.page = location.href; + } +} diff --git a/workingUIKIT/src/app/landingPages/addThis.component.ts b/workingUIKIT/src/app/landingPages/addThis.component.ts new file mode 100644 index 00000000..52951668 --- /dev/null +++ b/workingUIKIT/src/app/landingPages/addThis.component.ts @@ -0,0 +1,40 @@ +import {Component, ElementRef, Input} from '@angular/core'; +import {ActivatedRoute} from '@angular/router'; + + interface addthis { + layers: refresh; + } + interface refresh { + refresh: Function; + } + declare var addthis: addthis; + +// +@Component({ + selector: 'addThis', + template: ` +
+ ` +}) +export class AddThisComponent { + private sub:any; + + + constructor(private route: ActivatedRoute) { + + } + ngOnInit() { + this.sub = this.route.queryParams.subscribe(data => { + + if (typeof document !== 'undefined') { + try{ + addthis.layers.refresh(); + }catch (e) { + } + } + }); + + } + + +} diff --git a/workingUIKIT/src/app/landingPages/dataProvider/dataProvider-routing.module.ts b/workingUIKIT/src/app/landingPages/dataProvider/dataProvider-routing.module.ts new file mode 100644 index 00000000..5911e19e --- /dev/null +++ b/workingUIKIT/src/app/landingPages/dataProvider/dataProvider-routing.module.ts @@ -0,0 +1,14 @@ +import { NgModule } from '@angular/core'; +import { RouterModule } from '@angular/router'; + +import { DataProviderComponent } from './dataProvider.component'; +import {FreeGuard} from'../../login/freeGuard.guard'; + +@NgModule({ + imports: [ + RouterModule.forChild([ + { path: '', component: DataProviderComponent, canActivate: [FreeGuard] } + ]) +] +}) +export class DataProviderRoutingModule { } diff --git a/workingUIKIT/src/app/landingPages/dataProvider/dataProvider.component.html b/workingUIKIT/src/app/landingPages/dataProvider/dataProvider.component.html new file mode 100644 index 00000000..6494c176 --- /dev/null +++ b/workingUIKIT/src/app/landingPages/dataProvider/dataProvider.component.html @@ -0,0 +1,165 @@ +
+ + + +
+ +
+ + + +
+
Type:
+
{{dataProviderInfo.type}}
+
Compatibility:
+
{{dataProviderInfo.compatibility}}
+
OAI-PMH:
+
+ + + {{dataProviderInfo.oaiPmhURL}} + + +
+
Countries:
+
{{dataProviderInfo.countries}}
+
+ + +
+ + +
    + +
  • + + + + + + + + + + + + + + +
    +
    + There are no statistics +
    +
    +

    Latest Documents Timeline

    + +

    Documents Types

    + +
    + + +
    +
    +

    Funders in Data Providers Publications

    + +

    Projects with most Publications

    + + +
    +
    +
    +

    Projects with most Research Data

    + +
    +
    +
    +
    + + + + + + + +
  • +
+
+ +
+ +
+
    +
  • +
    +
    Share - Bookmark +
    +
    + +
    +
    +
  • + +
  • +
    +
    Page Views: {{pageViews}}
    +
    +
  • +
+
+
+
diff --git a/workingUIKIT/src/app/landingPages/dataProvider/dataProvider.component.ts b/workingUIKIT/src/app/landingPages/dataProvider/dataProvider.component.ts new file mode 100644 index 00000000..624b26c3 --- /dev/null +++ b/workingUIKIT/src/app/landingPages/dataProvider/dataProvider.component.ts @@ -0,0 +1,297 @@ +import {Component, ViewChild, ElementRef} from '@angular/core'; +import {Observable} from 'rxjs/Observable'; +import {DataProviderService} from './dataProvider.service'; +import {DataProviderInfo} from '../../utils/entities/dataProviderInfo'; +import {ActivatedRoute} from '@angular/router'; +import { Meta} from '../../../angular2-meta'; +import { FetchPublications } from '../../utils/fetchEntitiesClasses/fetchPublications.class'; +import { SearchPublicationsService } from '../../services/searchPublications.service'; +import { FetchDatasets } from '../../utils/fetchEntitiesClasses/fetchDatasets.class'; +import { SearchDatasetsService } from '../../services/searchDatasets.service'; +import { FetchProjects } from '../../utils/fetchEntitiesClasses/fetchProjects.class'; +import { SearchProjectsService } from '../../services/searchProjects.service'; +import { FetchDataproviders } from '../../utils/fetchEntitiesClasses/fetchDataproviders.class'; +import { SearchDataprovidersService } from '../../services/searchDataproviders.service'; +import {OpenaireProperties} from '../../utils/properties/openaireProperties'; +import {RouterHelper} from '../../utils/routerHelper.class'; +@Component({ + selector: 'dataprovider', + templateUrl: 'dataProvider.component.html', + }) + +export class DataProviderComponent { + + sub: any; + datasourceId: string; + public dataProviderInfo: DataProviderInfo; + + private showAllReferences: boolean = false; + private showAllRelResData: boolean = false; + private showAllSimilPubl: boolean = false; + private showAllBioentities: boolean = false; + private showFundingDetails: boolean = false; + + private bioentitiesNum: number = 0; + + private result ; + + public warningMessage = ""; + public errorMessage = ""; + public relatedDataprovidersResultsType: string; + public paramsForSearchLink = {};//: string = ""; + + public reloadPublications: boolean = true; + public reloadDatasets: boolean = true; + public reloadProjects: boolean = true; + public reloadDataproviders: boolean = true; +public reloadRelatedDatasources: boolean = true; + public metricsClicked: boolean; + private viewsFrameUrl: string; + private downloadsFrameUrl: string; + private totalViews: number; + private totalDownloads: number; + private pageViews: number; + + public statsClicked: boolean = false; + private docsTimelineUrl: string; + private docsTypesUrl:string; + private pubsFunderUrl:string; + private dataProjectsUrl:string ; + private pubsProjectsUrl:string; + + public fetchPublications : FetchPublications; + public fetchDatasets: FetchDatasets; + public fetchProjects: FetchProjects; + public fetchDataproviders: FetchDataproviders; + public fetchResultsAggregators: any; + + private nativeElement : Node; + + public routerHelper:RouterHelper = new RouterHelper(); + showTabs:boolean = false; + constructor (private element: ElementRef, + private _dataproviderService: DataProviderService, + private route: ActivatedRoute, + private _meta: Meta, + private _searchPublicationsService: SearchPublicationsService, + private _searchDatasetsService: SearchDatasetsService, + private _searchProjectsService: SearchProjectsService, + private _searchDataprovidersService: SearchDataprovidersService) { + this.fetchPublications = new FetchPublications(this._searchPublicationsService); + this.fetchDatasets = new FetchDatasets(this._searchDatasetsService); + this.fetchProjects = new FetchProjects(this._searchProjectsService); + this.fetchDataproviders = new FetchDataproviders(this._searchDataprovidersService); + + } + + ngOnInit() { + this.sub = this.route.queryParams.subscribe(data => { + this.updateTitle("Data provider"); + this.updateDescription("Data provider, search, repositories, open access"); + this.datasourceId = data['datasourceId']; + if(this.datasourceId){ + this.getDataProviderInfo(this.datasourceId); + }else{ + // console.info("Datasource id not found"); + } + + if (typeof document !== 'undefined') { + this.element.nativeElement.scrollIntoView(); + } + }); + + } + + ngOnDestroy() { + this.sub.unsubscribe(); + } + getDataProviderInfo(id:string) { + this.warningMessage = ''; + this.errorMessage="" + this.showTabs = false ; + if(this.datasourceId==null || this.datasourceId==''){ + this.warningMessage="No valid datasource id"; + }else{ + this._dataproviderService.getDataproviderInfo(this.datasourceId).subscribe( + data => { + this.dataProviderInfo = data; + this.initTabs(); + this.showTabs = true ; + this.updateTitle(this.dataProviderInfo.title.name); + this.updateDescription("Data provider, search, repositories, open access,"+this.dataProviderInfo.title.name); + }, + err => { + console.log(err) + // console.info("error"); + this.errorMessage = 'No dataProvider found'; + } + ); + } + } + updateDescription(description:string){ + this._meta.updateMeta("description", description); + this._meta.updateMeta("og:description", description); + } + updateTitle(title:string){ + var _suffix ="| OpenAIRE"; + var _title = ((title.length> 50 ) ?title.substring(0,50):title) + _suffix; + this._meta.setTitle(_title ); + this._meta.updateMeta("og:title",_title); + } + public initTabs(){ + + if(this.dataProviderInfo.tabs != undefined && this.dataProviderInfo.tabs.length > 0) { + this.reloadPublications = true; + this.reloadDatasets = true; + this.reloadProjects = true; + this.reloadDataproviders = true; + this.reloadRelatedDatasources = true; + this.statsClicked = false; + + this.search(this.dataProviderInfo.tabs[0].content, 1, 10); + this.count(1, 0); + + this.metricsClicked = false; + + this.viewsFrameUrl = OpenaireProperties.getFramesAPIURL()+'merge.php?com=query&data=[{"query":"dtsrcRepoViews","dtsrcName":"'+this.datasourceId+'","table":"","fields":[{"fld":"sum","agg":"sum","type":"chart","yaxis":1,"c":false}],"xaxis":{"name":"month","agg":"sum"},"group":"","color":"","type":"chart","size":30,"sort":"xaxis","xStyle":{"r":-30,"s":"0","l":"-","ft":"-","wt":"-"},"title":"","subtitle":"","xaxistitle":"","yaxisheaders":["Monthly views"],"generalxaxis":"","theme":0,"in":[]}]&info_types=["spline"]&stacking=&steps=false&fontFamily=Courier&spacing=[5,0,0,0]&style=[{"color":"rgba(0, 0, 0, 1)","size":"18"},{"color":"rgba(0, 0, 0, 1)","size":"18"},{"color":"000000","size":""},{"color":"000000","size":""}]&backgroundColor=rgba(255,255,255,1)&colors[]=rgba(124, 181, 236, 1)&colors[]=rgba(67, 67, 72, 1)&colors[]=rgba(144, 237, 125, 1)&colors[]=rgba(247, 163, 92, 1)&colors[]=rgba(128, 133, 233, 1)&colors[]=rgba(241, 92, 128, 1)&colors[]=rgba(228, 211, 84, 1)&colors[]=rgba(43, 144, 143, 1)&colors[]=rgba(244, 91, 91, 1)&colors[]=rgba(145, 232, 225, 1)&xlinew=0&ylinew=1&legends=true&tooltips=true&persistent=false'; + /*this.viewsFrameUrl = OpenaireProperties.getFramesAPIURL()+'merge.php?com=query&data=[{"query":"dtsrcOpenAIRETimeline", "dtsrcName":"'+this.datasourceId+'", "table":"","fields":[{"fld":"sum","agg":"sum","type":"column","yaxis":1,"c":false}],"xaxis":{"name":"month","agg":"sum"},"group":"","color":"","type":"chart","size":30,"sort":"xaxis","xStyle":{"r":-30,"s":"0","l":"-","ft":"-","wt":"-"},"title":"","subtitle":"","xaxistitle":"OpenAIRE","yaxisheaders":["Monthly views"],"generalxaxis":"","theme":0,"in":[],"filters":[{"name":"","values":[""],"to":"-1"}]},{"query":"dtsrcRepoTimeline", "dtsrcName":"'+this.datasourceId+'", "table":"","fields":[{"fld":"sum","agg":"sum","type":"column","yaxis":1,"c":false}],"xaxis":{"name":"month","agg":"sum"},"group":" ","color":"","type":"chart","size":30,"sort":"xaxis","xStyle":{"r":-30,"s":"0","l":"-","ft":"-","wt":"-"},"title":"","subtitle":"","xaxistitle":"Repository","yaxisheaders":[""],"generalxaxis":"","theme":0,"in":[],"filters":[{"name":"","values":[""],"to":"-1"}]}]&info_types=["column","column"]&stacking=normal&steps=false&fontFamily=Courier&spacing=[5,0,0,0]&style=[{"color":"rgba(0, 0, 0, 1)","size":"18"},{"color":"rgba(0, 0, 0, 1)","size":"18"},{"color":"000000","size":""},{"color":"000000","size":""}]&backgroundColor=rgba(255,255,255,1)&colors[]=rgba(124, 181, 236, 1)&colors[]=rgba(67, 67, 72, 1)&colors[]=rgba(144, 237, 125, 1)&colors[]=rgba(247, 163, 92, 1)&colors[]=rgba(128, 133, 233, 1)&colors[]=rgba(241, 92, 128, 1)&colors[]=rgba(228, 211, 84, 1)&colors[]=rgba(43, 144, 143, 1)&colors[]=rgba(244, 91, 91, 1)&colors[]=rgba(145, 232, 225, 1)&xlinew=0&ylinew=1&legends=true&tooltips=true'; + */ + + this.downloadsFrameUrl = OpenaireProperties.getFramesAPIURL()+'merge.php?com=query&data=[{"query":"dtsrcRepoDownloads","dtsrcName":"'+this.datasourceId+'","table":"","fields":[{"fld":"sum","agg":"sum","type":"chart","yaxis":1,"c":false}],"xaxis":{"name":"month","agg":"sum"},"group":"","color":"","type":"chart","size":30,"sort":"xaxis","xStyle":{"r":-30,"s":"0","l":"-","ft":"-","wt":"-"},"title":"","subtitle":"","xaxistitle":"","yaxisheaders":["Monthly downloads"],"generalxaxis":"","theme":0,"in":[]}]&info_types=["spline"]&stacking=&steps=false&fontFamily=Courier&spacing=[5,0,0,0]&style=[{"color":"rgba(0, 0, 0, 1)","size":"18"},{"color":"rgba(0, 0, 0, 1)","size":"18"},{"color":"000000","size":""},{"color":"000000","size":""}]&backgroundColor=rgba(255,255,255,1)&colors[]=rgba(124, 181, 236, 1)&colors[]=rgba(67, 67, 72, 1)&colors[]=rgba(144, 237, 125, 1)&colors[]=rgba(247, 163, 92, 1)&colors[]=rgba(128, 133, 233, 1)&colors[]=rgba(241, 92, 128, 1)&colors[]=rgba(228, 211, 84, 1)&colors[]=rgba(43, 144, 143, 1)&colors[]=rgba(244, 91, 91, 1)&colors[]=rgba(145, 232, 225, 1)&xlinew=0&ylinew=1&legends=true&tooltips=true&persistent=false'; + /* + this.downloadsFrameUrl = OpenaireProperties.getFramesAPIURL()+'merge.php?com=query&data=[{"query":"dtsrcDownloadsTimeline","dtsrcName":"'+this.datasourceId+'","table":"","fields":[{"fld":"sum","agg":"sum","type":"chart","yaxis":1,"c":false}],"xaxis":{"name":"month","agg":"sum"},"group":"","color":"","type":"chart","size":30,"sort":"xaxis","xStyle":{"r":-30,"s":"0","l":"-","ft":"-","wt":"-"},"title":"","subtitle":"","xaxistitle":"","yaxisheaders":["Monthly downloads"],"generalxaxis":"","theme":0,"in":[]}]&info_types=["spline"]&stacking=&steps=false&fontFamily=Courier&spacing=[5,0,0,0]&style=[{"color":"rgba(0, 0, 0, 1)","size":"18"},{"color":"rgba(0, 0, 0, 1)","size":"18"},{"color":"000000","size":""},{"color":"000000","size":""}]&backgroundColor=rgba(255,255,255,1)&colors[]=rgba(124, 181, 236, 1)&colors[]=rgba(67, 67, 72, 1)&colors[]=rgba(144, 237, 125, 1)&colors[]=rgba(247, 163, 92, 1)&colors[]=rgba(128, 133, 233, 1)&colors[]=rgba(241, 92, 128, 1)&colors[]=rgba(228, 211, 84, 1)&colors[]=rgba(43, 144, 143, 1)&colors[]=rgba(244, 91, 91, 1)&colors[]=rgba(145, 232, 225, 1)&xlinew=0&ylinew=1&legends=true&tooltips=true'; + */ + + this.docsTimelineUrl ='https://beta.openaire.eu/stats/chart.php?com=query&persistent=false&data={"query":"dtsrcYear","dtsrcName":"'+this.datasourceId+'","table": "result", "fields": [{"fld": "number", "agg": "count", "type": "line", "yaxis":1, "c":true}], "xaxis":{"name": "year", "agg": "avg"}, "group": "", "color": "", "type": "chart", "size":30, "sort": "xaxis", "xStyle":{"r": "-", "s": "-", "l": "-", "ft": "-", "wt": "-"}, "yaxisheaders": [""], "fieldsheaders": ["Documents"], "in": [{"f":0, "text": "Yearly"}], "filters": [{"name":"year","max":"2016","min":"1997"},{"name": "result_datasources-datasource-name", "values":[""], "to": "-1"}],"having": [], "incfilters": [], "inchaving": [], "title": "", "subtitle": "", "xaxistitle": "Year"}&w=600&h=250'; + this.docsTypesUrl = 'https://beta.openaire.eu/stats/chart.php?com=query&persistent=false&data={"query":"dtsrcPubs","dtsrcName":"'+this.datasourceId+'", "table": "result", "fields": [{"fld": "number", "agg": "count", "type": "pie", "yaxis":1, "c":false}], "xaxis":{"name": "result_classifications-type", "agg": "avg"}, "group": "", "color": "", "type": "chart", "size":30, "sort": "xaxis", "xStyle":{"r": "-", "s": "-", "l": "-", "ft": "-", "wt": "-"}, "yaxisheaders": [""], "fieldsheaders": ["Documents"], "in": [], "filters": [{"name": "result_datasources-datasource-name", "values": [""], "to": "-1"}], "having": [], "incfilters": [], "inchaving": [], "title": "", "subtitle": "", "xaxistitle": ""}&w=600&h=250'; + this.pubsFunderUrl =' https://beta.openaire.eu/stats/chart.php?com=query&persistent=false&data={"query":"dtsrcPubsFund","dtsrcName":"'+this.datasourceId+'", "table": "result", "fields": [{"fld": "number", "agg": "count", "type": "pie", "yaxis":1, "c":false}], "xaxis":{"name": "result_classifications-type", "agg": "avg"}, "group": "", "color": "", "type": "chart", "size":30, "sort": "xaxis", "xStyle":{"r": "-", "s": "-", "l": "-", "ft": "-", "wt": "-"}, "yaxisheaders": [""], "fieldsheaders": ["Documents"], "in": [], "filters": [{"name": "result_datasources-datasource-name", "values": [""], "to": "-1"}], "having": [], "incfilters": [], "inchaving": [], "title": "", "subtitle": "", "xaxistitle": ""}&w=600&h=250'; + this.dataProjectsUrl ='https://beta.openaire.eu/stats/chart.php?com=query&persistent=false&data={"query":"dtsrcProjData","dtsrcName":"'+this.datasourceId+'", "table": "result", "fields": [{"fld": "number", "agg": "count", "type": "bar", "yaxis":1, "c":false}], "xaxis":{"name": "result_classifications-type", "agg": "avg"}, "group": "", "color": "", "type": "chart", "size":30, "sort": "xaxis", "xStyle":{"r": "-", "s": "-", "l": "-", "ft": "-", "wt": "-"}, "yaxisheaders": [""], "fieldsheaders": ["Datasets"], "in": [], "filters": [{"name": "result_datasources-datasource-name", "values": [""], "to": "-1"}], "having": [], "incfilters": [], "inchaving": [], "title": "", "subtitle": "", "xaxistitle": ""}&w=600&h=250'; + this.pubsProjectsUrl ='https://beta.openaire.eu/stats/chart.php?com=query&persistent=false&data={"query":"dtsrcProjPubs","dtsrcName":"'+this.datasourceId+'", "table": "result", "fields": [{"fld": "number", "agg": "count", "type": "bar", "yaxis":1, "c":false}], "xaxis":{"name": "result_classifications-type", "agg": "avg"}, "group": "", "color": "", "type": "chart", "size":30, "sort": "xaxis", "xStyle":{"r": "-", "s": "-", "l": "-", "ft": "-", "wt": "-"}, "yaxisheaders": [""], "fieldsheaders": ["Publications"], "in": [], "filters": [{"name": "result_datasources-datasource-name", "values": [""], "to": "-1"}], "having": [], "incfilters": [], "inchaving": [], "title": "", "subtitle": "", "xaxistitle": ""}&w=600&h=250'; + + //if({"name": "Publications", "content": "publicationsTab"} in this.dataProviderInfo.tabs) { + if(this.dataProviderInfo.tabs.some(function (tab) { + return tab.name === 'Publications'; + })) { + this.relatedDataprovidersResultsType = 'publications'; + this.fetchResultsAggregators = new FetchPublications(this._searchPublicationsService); + } else { + this.relatedDataprovidersResultsType = 'datasets'; + this.fetchResultsAggregators = new FetchDatasets(this._searchDatasetsService); + } + } + if(this.dataProviderInfo.resultsBy == "collectedFrom") { + //this.paramsForSearchLink = "?collectedFrom="+this.datasourceId+"&co=and"; + this.paramsForSearchLink = this.routerHelper.createQueryParams(['collectedFrom', 'co'], [this.datasourceId, 'and']); + } else if (this.dataProviderInfo.resultsBy == "hostedBy") { + //this.paramsForSearchLink = "?hostedBy="+this.datasourceId+"&ho=and"; + this.paramsForSearchLink = this.routerHelper.createQueryParams(['hostedBy', 'ho'], [this.datasourceId, 'and']); + } + + } + + private count(page: number, size: number) { + console.info("number of tabs: "+this.dataProviderInfo.tabs.length); + + for(let i=1; i this.parseDataProviderInfo(res)); + } + return this.http.get(url) + .map(res => res.json()) + .map(res => res['result']['metadata']['oaf:entity']) + .map(res => [res['oaf:datasource'], + res['oaf:datasource']['datasourcetype'], + res['oaf:datasource']['openairecompatibility'], + res['oaf:datasource']['accessinfopackage'], + res['oaf:datasource']['rels']['rel'] + ]).do(res => { + this._cache.set(key, res); + }) + .map(res => this.parseDataProviderInfo(res)); + + } + + private handleError (error: Response) { + // 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'); + } + + parseDataProviderInfo (data: any):any { + this.dataProviderInfo = new DataProviderInfo(); + + if(data[0] != null) { + this.dataProviderInfo.title = {"name": data[0].officialname, "url": data[0].websiteurl}; + } + + if(data[1] != null) { + this.dataProviderInfo.type = data[1].classname; + + if(data[1].classid == "entityregistry" || data[1].classid == "entityregistry::projects" || data[1].classid == "entityregistry::repositories") { + this.dataProviderInfo.registry = true; + console.info("true"); + } else { + this.dataProviderInfo.registry = false; + console.info("false"); + } + console.info(this.dataProviderInfo.type); + + if(this.dataProviderInfo.tabs == undefined) { + this.dataProviderInfo.tabs = new Array<{"name": string, "content": string}>(); + } + + if(this.dataProviderInfo.tabsInTypes.publicationsTab.has(data[1].classid)) { + this.dataProviderInfo.tabs.push({"name": "Publications", "content": "publicationsTab"}); + } + if(this.dataProviderInfo.tabsInTypes.datasetsTab.has(data[1].classid)) { + this.dataProviderInfo.tabs.push({"name": "Datasets", "content": "datasetsTab"}); + } + + if(this.dataProviderInfo.tabsInTypes.projectsTab.has(data[1].classid)) { + this.dataProviderInfo.tabs.push({"name": "Projects", "content": "projectsTab"}); + } + if(this.dataProviderInfo.tabsInTypes.datasourcesTab.has(data[1].classid)) { + this.dataProviderInfo.tabs.push({"name": "Datasources", "content": "datasourcesTab"}); + } + this.dataProviderInfo.tabs.push({"name": "Organizations", "content": "organizationsTab"}); + + if(this.dataProviderInfo.tabsInTypes.relatedDatasourcesTab.has(data[1].classid)) { + this.dataProviderInfo.tabs.push({"name": "Related Data Providers", "content": "relatedDatasourcesTab"}); + } + + if(this.dataProviderInfo.tabsInTypes.statisticsTab.has(data[1].classid)) { + this.dataProviderInfo.tabs.push({"name": "Statistics", "content": "statisticsTab"}); + } + + this.dataProviderInfo.tabs.push({"name": "Metrics", "content": "metricsTab"}); + + if(this.dataProviderInfo.resultTypes.collectedFrom.has(data[1].classid)) { + this.dataProviderInfo.resultsBy = "collectedFrom"; + } else if(this.dataProviderInfo.resultTypes.hostedBy.has(data[1].classid)) { + this.dataProviderInfo.resultsBy = "hostedBy"; + } + } + + if(!this.dataProviderInfo.registry) { + if(data[2] != null) { + this.dataProviderInfo.compatibility = data[2].classname; + } + + if(data[3] != null) { + let oaiPmhURL: string; + if(Array.isArray(data[3])) { + oaiPmhURL = data[3][0]; + } + else { + oaiPmhURL = data[3]; + } + + if(oaiPmhURL != '' && oaiPmhURL != 'unknown') { + this.dataProviderInfo.oaiPmhURL = oaiPmhURL; + } + } + } + + if(data[4] != null) { + let mydata; + let counter = 0; + let countriesSet: Set; + let length = data[4].length!=undefined ? data[4].length : 1; + + for(let i=0; i(); + this.dataProviderInfo.countries = new Array(); + countriesSet = new Set(); + } + + this.dataProviderInfo.organizations[counter] = {"name": "", "id": ""}; + this.dataProviderInfo.organizations[counter]['name'] = mydata.legalname; + this.dataProviderInfo.organizations[counter]['id'] = /*OpenaireProperties.getsearchLinkToOrganization()+*/mydata['to'].content; + + if(mydata.country != '' && mydata['country'].classname != '') { + if(!countriesSet.has(mydata['country'].classname)) { + this.dataProviderInfo.countries.push(mydata['country'].classname); + countriesSet.add(mydata['country'].classname); + } + } + + counter++; + } + } + } + } + + //this.printPublicationInfo(); + return this.dataProviderInfo; + + } + + printDataProviderInfo() { + + } + +} diff --git a/workingUIKIT/src/app/landingPages/dataProvider/datasetsTab.component.ts b/workingUIKIT/src/app/landingPages/dataProvider/datasetsTab.component.ts new file mode 100644 index 00000000..b64116c7 --- /dev/null +++ b/workingUIKIT/src/app/landingPages/dataProvider/datasetsTab.component.ts @@ -0,0 +1,40 @@ +import {Component, Input} from '@angular/core'; +import { FetchDatasets } from '../../utils/fetchEntitiesClasses/fetchDatasets.class'; + +import {OpenaireProperties} from '../../utils/properties/openaireProperties'; + +@Component({ + selector: 'datasetsTab', + template: ` +
+ There are no datasets +
+ + + ` +}) + +export class DatasetsTabComponent { + @Input() paramsForSearchLink = {}; + @Input() fetchDatasets : FetchDatasets; + public linkToSearchDatasets = ""; + + constructor () {} + + ngOnInit() { + this.linkToSearchDatasets = OpenaireProperties.getLinkToAdvancedSearchDatasets(); + } + + ngOnDestroy() {} +} diff --git a/workingUIKIT/src/app/landingPages/dataProvider/datasourcesTab.component.ts b/workingUIKIT/src/app/landingPages/dataProvider/datasourcesTab.component.ts new file mode 100644 index 00000000..602e420d --- /dev/null +++ b/workingUIKIT/src/app/landingPages/dataProvider/datasourcesTab.component.ts @@ -0,0 +1,44 @@ +import {Component, Input} from '@angular/core'; +import { FetchDataproviders } from '../../utils/fetchEntitiesClasses/fetchDataproviders.class'; + +import {OpenaireProperties} from '../../utils/properties/openaireProperties'; + +@Component({ + selector: 'datasourcesTab', + template: ` +
+ There are no datasources +
+ + + ` +}) + +export class DatasourcesTabComponent { + + @Input() paramsForSearchLink = {}; + @Input() fetchDataproviders : FetchDataproviders; + public linkToSearchDataproviders = ""; + + constructor () {} + + ngOnInit() { + console.info("datasources tab: init"); + this.linkToSearchDataproviders = OpenaireProperties.getLinkToAdvancedSearchDataProviders(); + // console.info(this.linkToSearchDataproviders); + } + + ngOnDestroy() {} +} diff --git a/workingUIKIT/src/app/landingPages/dataProvider/organizationsTab.component.ts b/workingUIKIT/src/app/landingPages/dataProvider/organizationsTab.component.ts new file mode 100644 index 00000000..d247ac28 --- /dev/null +++ b/workingUIKIT/src/app/landingPages/dataProvider/organizationsTab.component.ts @@ -0,0 +1,35 @@ +import {Component, Input} from '@angular/core'; + +@Component({ + selector: 'organizationsTab', + template: ` +
+ There are no organizations +
+ +
+
+

+ + + {{item['name']}} + +

+

+ {{item['name']}} +

+
+
+ ` +}) + +export class OrganizationsTabComponent { + + @Input() organizations: {"name": string, "id": string}[] ; + + constructor () {} + + ngOnInit() {} + + ngOnDestroy() {} +} diff --git a/workingUIKIT/src/app/landingPages/dataProvider/projectsTab.component.ts b/workingUIKIT/src/app/landingPages/dataProvider/projectsTab.component.ts new file mode 100644 index 00000000..ef260b8b --- /dev/null +++ b/workingUIKIT/src/app/landingPages/dataProvider/projectsTab.component.ts @@ -0,0 +1,42 @@ +import {Component, Input} from '@angular/core'; + +import { FetchProjects } from '../../utils/fetchEntitiesClasses/fetchProjects.class'; + +import {OpenaireProperties} from '../../utils/properties/openaireProperties'; + +@Component({ + selector: 'projectsTab', + template: ` +
+ There are no projects +
+ + + ` +}) + +export class ProjectsTabComponent { + + @Input() paramsForSearchLink = {}; + @Input() fetchProjects : FetchProjects; + public linkToSearchProjects = ""; + + constructor () {} + + ngOnInit() { + this.linkToSearchProjects = OpenaireProperties.getLinkToAdvancedSearchProjects(); + } + + ngOnDestroy() {} +} diff --git a/workingUIKIT/src/app/landingPages/dataProvider/publicationsTab.component.ts b/workingUIKIT/src/app/landingPages/dataProvider/publicationsTab.component.ts new file mode 100644 index 00000000..6b00c3ce --- /dev/null +++ b/workingUIKIT/src/app/landingPages/dataProvider/publicationsTab.component.ts @@ -0,0 +1,44 @@ +import {Component, Input} from '@angular/core'; +import { FetchPublications } from '../../utils/fetchEntitiesClasses/fetchPublications.class'; + +import {OpenaireProperties} from '../../utils/properties/openaireProperties'; + +@Component({ + selector: 'publicationsTab', + template: ` +
+ There are no publications +
+ + + ` +}) + +export class PublicationsTabComponent { + @Input() paramsForSearchLink = {};//: string = ""; + @Input() fetchPublications : FetchPublications; + public linkToSearchPublications = ""; + + constructor () {} + + ngOnInit() { + this.linkToSearchPublications = OpenaireProperties.getLinkToAdvancedSearchPublications();//+this.paramsForSearchLink; + console.info("publications tab: init"); + } + + ngOnDestroy() {} +} diff --git a/workingUIKIT/src/app/landingPages/dataProvider/relatedDatasourcesTab.component.ts b/workingUIKIT/src/app/landingPages/dataProvider/relatedDatasourcesTab.component.ts new file mode 100644 index 00000000..d858f9fe --- /dev/null +++ b/workingUIKIT/src/app/landingPages/dataProvider/relatedDatasourcesTab.component.ts @@ -0,0 +1,77 @@ +import {Component, Input} from '@angular/core'; + +import { FetchPublications } from '../../utils/fetchEntitiesClasses/fetchPublications.class'; +import { FetchDatasets } from '../../utils/fetchEntitiesClasses/fetchDatasets.class'; + +import {OpenaireProperties} from '../../utils/properties/openaireProperties'; +import {RouterHelper} from '../../utils/routerHelper.class'; + +@Component({ + selector: 'relatedDatasourcesTab', + template: ` + +
+ There are no related dataproviders +
+ +
+ + + + + + + + + + + + + +
Data Provider NameNumber of {{type}}
+ + + + {{item.name}} + + + + + {{item.count}} + +
+
+ ` +}) + +export class RelatedDatasourcesTabComponent { + @Input() type: string; + @Input() dataproviderId: string; + @Input() fetchResults : any; + public linkToSearchResults: string = ""; + public searchLinkToDataProvider: string = ""; + public routerHelper:RouterHelper = new RouterHelper(); + + //public queryParams: string[] = []; + //public queryParamsIds: string[] = []; + + constructor () {} + + ngOnInit() { + console.info("related datasources tab: init"); + if(this.type == "publications") { + this.linkToSearchResults = OpenaireProperties.getLinkToAdvancedSearchPublications();//+"?&hostedBy=";//+ +"&ho=and&collectedFrom="+ +"&co=and"; + } else { + this.linkToSearchResults = OpenaireProperties.getLinkToAdvancedSearchDatasets(); + } + this.searchLinkToDataProvider = OpenaireProperties.getsearchLinkToDataProvider(); + /*queryParams.push("hostedBy"); + queryParams.push("ho"); + queryParams.push("collectedFrom"); + queryParams.push("co"); + queryParamsIds.push()*/ + } + + ngOnDestroy() {} +} diff --git a/workingUIKIT/src/app/landingPages/dataProvider/statisticsTab.component.ts b/workingUIKIT/src/app/landingPages/dataProvider/statisticsTab.component.ts new file mode 100644 index 00000000..a32c2610 --- /dev/null +++ b/workingUIKIT/src/app/landingPages/dataProvider/statisticsTab.component.ts @@ -0,0 +1,66 @@ +import {Component, Input} from '@angular/core'; +import { SearchDatasetsComponent } from '../../searchPages/simple/searchDatasets.component'; +import { SearchPublicationsComponent } from '../../searchPages/simple/searchPublications.component'; +import {OpenaireProperties} from '../../utils/properties/openaireProperties'; + +@Component({ + selector: 'statisticsTab', + template: ` +
+
+ There are no statistics +
+
+

Latest Documents Timeline

+ +

Documents Types

+ +
+ + +
+
+

Funders in Data Providers Publications

+ +

Projects with most Publications

+ + +
+
+
+

Projects with most Research Data

+ + +
+
+
+
+ ` +}) + +export class StatisticsTabComponent { + + @Input() statistics; + @Input() id; + @Input() searchDatasetsComponent : SearchDatasetsComponent; + @Input() searchPublicationsComponent : SearchPublicationsComponent; + @Input() show : boolean = false; + + private docsTimelineUrl: string; + private docsTypesUrl:string; + private pubsFunderUrl:string; + private dataProjectsUrl:string ; + private pubsProjectsUrl:string; + constructor () {} + + ngOnInit() { + + this.docsTimelineUrl ='https://beta.openaire.eu/stats/chart.php?com=query&persistent=false&data={"query":"dtsrcYear","dtsrcName":"'+this.id+'","table": "result", "fields": [{"fld": "number", "agg": "count", "type": "line", "yaxis":1, "c":true}], "xaxis":{"name": "year", "agg": "avg"}, "group": "", "color": "", "type": "chart", "size":30, "sort": "xaxis", "xStyle":{"r": "-", "s": "-", "l": "-", "ft": "-", "wt": "-"}, "yaxisheaders": [""], "fieldsheaders": ["Documents"], "in": [{"f":0, "text": "Yearly"}], "filters": [{"name":"year","max":"2016","min":"1997"},{"name": "result_datasources-datasource-name", "values":[""], "to": "-1"}],"having": [], "incfilters": [], "inchaving": [], "title": "", "subtitle": "", "xaxistitle": "Year"}&w=600&h=250'; + this.docsTypesUrl = 'https://beta.openaire.eu/stats/chart.php?com=query&persistent=false&data={"query":"dtsrcPubs","dtsrcName":"'+this.id+'", "table": "result", "fields": [{"fld": "number", "agg": "count", "type": "pie", "yaxis":1, "c":false}], "xaxis":{"name": "result_classifications-type", "agg": "avg"}, "group": "", "color": "", "type": "chart", "size":30, "sort": "xaxis", "xStyle":{"r": "-", "s": "-", "l": "-", "ft": "-", "wt": "-"}, "yaxisheaders": [""], "fieldsheaders": ["Documents"], "in": [], "filters": [{"name": "result_datasources-datasource-name", "values": [""], "to": "-1"}], "having": [], "incfilters": [], "inchaving": [], "title": "", "subtitle": "", "xaxistitle": ""}&w=600&h=250'; + this.pubsFunderUrl =' https://beta.openaire.eu/stats/chart.php?com=query&persistent=false&data={"query":"dtsrcPubsFund","dtsrcName":"'+this.id+'", "table": "result", "fields": [{"fld": "number", "agg": "count", "type": "pie", "yaxis":1, "c":false}], "xaxis":{"name": "result_classifications-type", "agg": "avg"}, "group": "", "color": "", "type": "chart", "size":30, "sort": "xaxis", "xStyle":{"r": "-", "s": "-", "l": "-", "ft": "-", "wt": "-"}, "yaxisheaders": [""], "fieldsheaders": ["Documents"], "in": [], "filters": [{"name": "result_datasources-datasource-name", "values": [""], "to": "-1"}], "having": [], "incfilters": [], "inchaving": [], "title": "", "subtitle": "", "xaxistitle": ""}&w=600&h=250'; + this.dataProjectsUrl ='https://beta.openaire.eu/stats/chart.php?com=query&persistent=false&data={"query":"dtsrcProjData","dtsrcName":"'+this.id+'", "table": "result", "fields": [{"fld": "number", "agg": "count", "type": "bar", "yaxis":1, "c":false}], "xaxis":{"name": "result_classifications-type", "agg": "avg"}, "group": "", "color": "", "type": "chart", "size":30, "sort": "xaxis", "xStyle":{"r": "-", "s": "-", "l": "-", "ft": "-", "wt": "-"}, "yaxisheaders": [""], "fieldsheaders": ["Datasets"], "in": [], "filters": [{"name": "result_datasources-datasource-name", "values": [""], "to": "-1"}], "having": [], "incfilters": [], "inchaving": [], "title": "", "subtitle": "", "xaxistitle": ""}&w=600&h=250'; + this.pubsProjectsUrl ='https://beta.openaire.eu/stats/chart.php?com=query&persistent=false&data={"query":"dtsrcProjPubs","dtsrcName":"'+this.id+'", "table": "result", "fields": [{"fld": "number", "agg": "count", "type": "bar", "yaxis":1, "c":false}], "xaxis":{"name": "result_classifications-type", "agg": "avg"}, "group": "", "color": "", "type": "chart", "size":30, "sort": "xaxis", "xStyle":{"r": "-", "s": "-", "l": "-", "ft": "-", "wt": "-"}, "yaxisheaders": [""], "fieldsheaders": ["Publications"], "in": [], "filters": [{"name": "result_datasources-datasource-name", "values": [""], "to": "-1"}], "having": [], "incfilters": [], "inchaving": [], "title": "", "subtitle": "", "xaxistitle": ""}&w=600&h=250'; + } + + ngOnDestroy() {} +} diff --git a/workingUIKIT/src/app/landingPages/dataProvider/tabs.component.ts b/workingUIKIT/src/app/landingPages/dataProvider/tabs.component.ts new file mode 100644 index 00000000..d902a734 --- /dev/null +++ b/workingUIKIT/src/app/landingPages/dataProvider/tabs.component.ts @@ -0,0 +1,388 @@ +import {Component, Input, Renderer, ElementRef} from '@angular/core'; +import {ActivatedRoute, Params} from '@angular/router'; +//import { DOCUMENT } from '@angular/platform-browser'; + +import { FetchPublications } from '../../utils/fetchEntitiesClasses/fetchPublications.class'; +import { SearchPublicationsService } from '../../services/searchPublications.service'; +import { FetchDatasets } from '../../utils/fetchEntitiesClasses/fetchDatasets.class'; +import { SearchDatasetsService } from '../../services/searchDatasets.service'; +import { FetchProjects } from '../../utils/fetchEntitiesClasses/fetchProjects.class'; +import { SearchProjectsService } from '../../services/searchProjects.service'; +import { FetchDataproviders } from '../../utils/fetchEntitiesClasses/fetchDataproviders.class'; +import { SearchDataprovidersService } from '../../services/searchDataproviders.service'; + +import {OpenaireProperties} from '../../utils/properties/openaireProperties'; +import {RouterHelper} from '../../utils/routerHelper.class'; + +@Component({ + selector: 'tabs', + template: ` + Tabs_0_content:{{tabs[0].content}} & length: {{tabs.length}} +
+ + +
    + +
  • + + + + + + + + + + + + + + +
    +
    + There are no statistics +
    +
    +

    Latest Documents Timeline

    + +

    Documents Types

    + +
    + + +
    +
    +

    Funders in Data Providers Publications

    + +

    Projects with most Publications

    + + +
    +
    +
    +

    Projects with most Research Data

    + +
    +
    +
    +
    + + + + + + + +
  • +
+
+ ` +}) + +export class TabsComponent { + + @Input() id: string; + @Input() name: string; + @Input() resultsBy: string; + @Input() tabs: {"name": string, "content": string}[]; + //@Input() publications; + //@Input() datasets; + @Input() statistics; + //@Input() projects; + //@Input() datasources; + @Input() organizations: {"name": string, "url": string}[]; + + @Input() _dataproviderService; + + public relatedDataprovidersResultsType: string; + + public paramsForSearchLink = {};//: string = ""; + + public reloadPublications: boolean = true; + public reloadDatasets: boolean = true; + public reloadProjects: boolean = true; + public reloadDataproviders: boolean = true; + public reloadRelatedDatasources: boolean = true; + public metricsClicked: boolean; + private viewsFrameUrl: string; + private downloadsFrameUrl: string; + private totalViews: number; + private totalDownloads: number; + + public statsClicked: boolean = false; + private docsTimelineUrl: string; + private docsTypesUrl:string; + private pubsFunderUrl:string; + private dataProjectsUrl:string ; + private pubsProjectsUrl:string; + + public fetchPublications : FetchPublications; + public fetchDatasets: FetchDatasets; + public fetchProjects: FetchProjects; + public fetchDataproviders: FetchDataproviders; + public fetchResultsAggregators: any; + + private nativeElement : Node; + + public routerHelper:RouterHelper = new RouterHelper(); + showTabs:boolean = false; + private sub: any; + + constructor (private renderer : Renderer, private element : ElementRef,private route: ActivatedRoute, + private _searchPublicationsService: SearchPublicationsService, + private _searchDatasetsService: SearchDatasetsService, + private _searchProjectsService: SearchProjectsService, + private _searchDataprovidersService: SearchDataprovidersService) { + this.fetchPublications = new FetchPublications(this._searchPublicationsService); + this.fetchDatasets = new FetchDatasets(this._searchDatasetsService); + this.fetchProjects = new FetchProjects(this._searchProjectsService); + this.fetchDataproviders = new FetchDataproviders(this._searchDataprovidersService); + } + + ngOnInit() { + this.hideTabs(true); + this.initTabs("init"); + this.hideTabs(false); + } + public hideTabs(hide:boolean){ + this.showTabs = !hide; + } + public initTabs(from){ + console.log("\nCALL init from "+from+" "+this.tabs.length+"\n "); + + if(this.tabs != undefined && this.tabs.length > 0) { + this.reloadPublications = true; + this.reloadDatasets = true; + this.reloadProjects = true; + this.reloadDataproviders = true; + this.reloadRelatedDatasources = true; + this.statsClicked = false; + + this.search(this.tabs[0].content, 1, 10); + this.count(1, 0); + + this.metricsClicked = false; + this.viewsFrameUrl = OpenaireProperties.getFramesAPIURL()+'merge.php?com=query&data=[{"query":"dtsrcOpenAIRETimeline", "dtsrcName":"'+this.id+'", "table":"","fields":[{"fld":"sum","agg":"sum","type":"column","yaxis":1,"c":false}],"xaxis":{"name":"month","agg":"sum"},"group":"","color":"","type":"chart","size":30,"sort":"xaxis","xStyle":{"r":-30,"s":"0","l":"-","ft":"-","wt":"-"},"title":"","subtitle":"","xaxistitle":"OpenAIRE","yaxisheaders":["Monthly views"],"generalxaxis":"","theme":0,"in":[],"filters":[{"name":"","values":[""],"to":"-1"}]},{"query":"dtsrcRepoTimeline", "dtsrcName":"'+this.id+'", "table":"","fields":[{"fld":"sum","agg":"sum","type":"column","yaxis":1,"c":false}],"xaxis":{"name":"month","agg":"sum"},"group":" ","color":"","type":"chart","size":30,"sort":"xaxis","xStyle":{"r":-30,"s":"0","l":"-","ft":"-","wt":"-"},"title":"","subtitle":"","xaxistitle":"Repository","yaxisheaders":[""],"generalxaxis":"","theme":0,"in":[],"filters":[{"name":"","values":[""],"to":"-1"}]}]&info_types=["column","column"]&stacking=normal&steps=false&fontFamily=Courier&spacing=[5,0,0,0]&style=[{"color":"rgba(0, 0, 0, 1)","size":"18"},{"color":"rgba(0, 0, 0, 1)","size":"18"},{"color":"000000","size":""},{"color":"000000","size":""}]&backgroundColor=rgba(255,255,255,1)&colors[]=rgba(124, 181, 236, 1)&colors[]=rgba(67, 67, 72, 1)&colors[]=rgba(144, 237, 125, 1)&colors[]=rgba(247, 163, 92, 1)&colors[]=rgba(128, 133, 233, 1)&colors[]=rgba(241, 92, 128, 1)&colors[]=rgba(228, 211, 84, 1)&colors[]=rgba(43, 144, 143, 1)&colors[]=rgba(244, 91, 91, 1)&colors[]=rgba(145, 232, 225, 1)&xlinew=0&ylinew=1&legends=true&tooltips=true'; + this.downloadsFrameUrl = OpenaireProperties.getFramesAPIURL()+'merge.php?com=query&data=[{"query":"dtsrcDownloadsTimeline","dtsrcName":"'+this.id+'","table":"","fields":[{"fld":"sum","agg":"sum","type":"chart","yaxis":1,"c":false}],"xaxis":{"name":"month","agg":"sum"},"group":"","color":"","type":"chart","size":30,"sort":"xaxis","xStyle":{"r":-30,"s":"0","l":"-","ft":"-","wt":"-"},"title":"","subtitle":"","xaxistitle":"","yaxisheaders":["Monthly downloads"],"generalxaxis":"","theme":0,"in":[]}]&info_types=["spline"]&stacking=&steps=false&fontFamily=Courier&spacing=[5,0,0,0]&style=[{"color":"rgba(0, 0, 0, 1)","size":"18"},{"color":"rgba(0, 0, 0, 1)","size":"18"},{"color":"000000","size":""},{"color":"000000","size":""}]&backgroundColor=rgba(255,255,255,1)&colors[]=rgba(124, 181, 236, 1)&colors[]=rgba(67, 67, 72, 1)&colors[]=rgba(144, 237, 125, 1)&colors[]=rgba(247, 163, 92, 1)&colors[]=rgba(128, 133, 233, 1)&colors[]=rgba(241, 92, 128, 1)&colors[]=rgba(228, 211, 84, 1)&colors[]=rgba(43, 144, 143, 1)&colors[]=rgba(244, 91, 91, 1)&colors[]=rgba(145, 232, 225, 1)&xlinew=0&ylinew=1&legends=true&tooltips=true'; + + this.docsTimelineUrl ='https://beta.openaire.eu/stats/chart.php?com=query&persistent=false&data={"query":"dtsrcYear","dtsrcName":"'+this.id+'","table": "result", "fields": [{"fld": "number", "agg": "count", "type": "line", "yaxis":1, "c":true}], "xaxis":{"name": "year", "agg": "avg"}, "group": "", "color": "", "type": "chart", "size":30, "sort": "xaxis", "xStyle":{"r": "-", "s": "-", "l": "-", "ft": "-", "wt": "-"}, "yaxisheaders": [""], "fieldsheaders": ["Documents"], "in": [{"f":0, "text": "Yearly"}], "filters": [{"name":"year","max":"2016","min":"1997"},{"name": "result_datasources-datasource-name", "values":[""], "to": "-1"}],"having": [], "incfilters": [], "inchaving": [], "title": "", "subtitle": "", "xaxistitle": "Year"}&w=600&h=250'; + this.docsTypesUrl = 'https://beta.openaire.eu/stats/chart.php?com=query&persistent=false&data={"query":"dtsrcPubs","dtsrcName":"'+this.id+'", "table": "result", "fields": [{"fld": "number", "agg": "count", "type": "pie", "yaxis":1, "c":false}], "xaxis":{"name": "result_classifications-type", "agg": "avg"}, "group": "", "color": "", "type": "chart", "size":30, "sort": "xaxis", "xStyle":{"r": "-", "s": "-", "l": "-", "ft": "-", "wt": "-"}, "yaxisheaders": [""], "fieldsheaders": ["Documents"], "in": [], "filters": [{"name": "result_datasources-datasource-name", "values": [""], "to": "-1"}], "having": [], "incfilters": [], "inchaving": [], "title": "", "subtitle": "", "xaxistitle": ""}&w=600&h=250'; + this.pubsFunderUrl =' https://beta.openaire.eu/stats/chart.php?com=query&persistent=false&data={"query":"dtsrcPubsFund","dtsrcName":"'+this.id+'", "table": "result", "fields": [{"fld": "number", "agg": "count", "type": "pie", "yaxis":1, "c":false}], "xaxis":{"name": "result_classifications-type", "agg": "avg"}, "group": "", "color": "", "type": "chart", "size":30, "sort": "xaxis", "xStyle":{"r": "-", "s": "-", "l": "-", "ft": "-", "wt": "-"}, "yaxisheaders": [""], "fieldsheaders": ["Documents"], "in": [], "filters": [{"name": "result_datasources-datasource-name", "values": [""], "to": "-1"}], "having": [], "incfilters": [], "inchaving": [], "title": "", "subtitle": "", "xaxistitle": ""}&w=600&h=250'; + this.dataProjectsUrl ='https://beta.openaire.eu/stats/chart.php?com=query&persistent=false&data={"query":"dtsrcProjData","dtsrcName":"'+this.id+'", "table": "result", "fields": [{"fld": "number", "agg": "count", "type": "bar", "yaxis":1, "c":false}], "xaxis":{"name": "result_classifications-type", "agg": "avg"}, "group": "", "color": "", "type": "chart", "size":30, "sort": "xaxis", "xStyle":{"r": "-", "s": "-", "l": "-", "ft": "-", "wt": "-"}, "yaxisheaders": [""], "fieldsheaders": ["Datasets"], "in": [], "filters": [{"name": "result_datasources-datasource-name", "values": [""], "to": "-1"}], "having": [], "incfilters": [], "inchaving": [], "title": "", "subtitle": "", "xaxistitle": ""}&w=600&h=250'; + this.pubsProjectsUrl ='https://beta.openaire.eu/stats/chart.php?com=query&persistent=false&data={"query":"dtsrcProjPubs","dtsrcName":"'+this.id+'", "table": "result", "fields": [{"fld": "number", "agg": "count", "type": "bar", "yaxis":1, "c":false}], "xaxis":{"name": "result_classifications-type", "agg": "avg"}, "group": "", "color": "", "type": "chart", "size":30, "sort": "xaxis", "xStyle":{"r": "-", "s": "-", "l": "-", "ft": "-", "wt": "-"}, "yaxisheaders": [""], "fieldsheaders": ["Publications"], "in": [], "filters": [{"name": "result_datasources-datasource-name", "values": [""], "to": "-1"}], "having": [], "incfilters": [], "inchaving": [], "title": "", "subtitle": "", "xaxistitle": ""}&w=600&h=250'; + + //if({"name": "Publications", "content": "publicationsTab"} in this.tabs) { + if(this.tabs.some(function (tab) { + return tab.name === 'Publications'; + })) { + this.relatedDataprovidersResultsType = 'publications'; + this.fetchResultsAggregators = new FetchPublications(this._searchPublicationsService); + } else { + this.relatedDataprovidersResultsType = 'datasets'; + this.fetchResultsAggregators = new FetchDatasets(this._searchDatasetsService); + } + } + if(this.resultsBy == "collectedFrom") { + //this.paramsForSearchLink = "?collectedFrom="+this.id+"&co=and"; + this.paramsForSearchLink = this.routerHelper.createQueryParams(['collectedFrom', 'co'], [this.id, 'and']); + } else if (this.resultsBy == "hostedBy") { + //this.paramsForSearchLink = "?hostedBy="+this.id+"&ho=and"; + this.paramsForSearchLink = this.routerHelper.createQueryParams(['hostedBy', 'ho'], [this.id, 'and']); + } + + } + + ngOnDestroy() { + //this.sub.unsubscribe(); + } + + // ngOnChanges() { + // console.info("on changes dataprovider tabs"); + // if(this.tabs != undefined && this.tabs.length > 0) { + // /*if(typeof document !== undefined) { + // let element = document.getElementById(this.tabs[0].content); + // if(element != null) { + // element.className = "uk-active"; + // element.setAttribute("aria-expanded", "true"); + // } + // + // let element2 = document.getElementById("firstTab-content"); + // if(element2 != null) { + // element2.className = "uk-active"; + // element2.setAttribute("aria-hidden", "false"); + // } + // }*/ + // + // this.reloadPublications = true; + // this.reloadDatasets = true; + // this.reloadProjects = true; + // this.reloadDataproviders = true; + // this.reloadRelatedDatasources = true; + // this.statsClicked = false; + // + // this.search(this.tabs[0].content, 1, 10); + // this.count(1, 0); + // + // this.metricsClicked = false; + // this.viewsFrameUrl = OpenaireProperties.getFramesAPIURL()+'merge.php?com=query&data=[{"query":"dtsrcOpenAIRETimeline", "dtsrcName":"'+this.id+'", "table":"","fields":[{"fld":"sum","agg":"sum","type":"column","yaxis":1,"c":false}],"xaxis":{"name":"month","agg":"sum"},"group":"","color":"","type":"chart","size":30,"sort":"xaxis","xStyle":{"r":-30,"s":"0","l":"-","ft":"-","wt":"-"},"title":"","subtitle":"","xaxistitle":"OpenAIRE","yaxisheaders":["Monthly views"],"generalxaxis":"","theme":0,"in":[],"filters":[{"name":"","values":[""],"to":"-1"}]},{"query":"dtsrcRepoTimeline", "dtsrcName":"'+this.id+'", "table":"","fields":[{"fld":"sum","agg":"sum","type":"column","yaxis":1,"c":false}],"xaxis":{"name":"month","agg":"sum"},"group":" ","color":"","type":"chart","size":30,"sort":"xaxis","xStyle":{"r":-30,"s":"0","l":"-","ft":"-","wt":"-"},"title":"","subtitle":"","xaxistitle":"Repository","yaxisheaders":[""],"generalxaxis":"","theme":0,"in":[],"filters":[{"name":"","values":[""],"to":"-1"}]}]&info_types=["column","column"]&stacking=normal&steps=false&fontFamily=Courier&spacing=[5,0,0,0]&style=[{"color":"rgba(0, 0, 0, 1)","size":"18"},{"color":"rgba(0, 0, 0, 1)","size":"18"},{"color":"000000","size":""},{"color":"000000","size":""}]&backgroundColor=rgba(255,255,255,1)&colors[]=rgba(124, 181, 236, 1)&colors[]=rgba(67, 67, 72, 1)&colors[]=rgba(144, 237, 125, 1)&colors[]=rgba(247, 163, 92, 1)&colors[]=rgba(128, 133, 233, 1)&colors[]=rgba(241, 92, 128, 1)&colors[]=rgba(228, 211, 84, 1)&colors[]=rgba(43, 144, 143, 1)&colors[]=rgba(244, 91, 91, 1)&colors[]=rgba(145, 232, 225, 1)&xlinew=0&ylinew=1&legends=true&tooltips=true'; + // this.downloadsFrameUrl = OpenaireProperties.getFramesAPIURL()+'merge.php?com=query&data=[{"query":"dtsrcDownloadsTimeline","dtsrcName":"'+this.id+'","table":"","fields":[{"fld":"sum","agg":"sum","type":"chart","yaxis":1,"c":false}],"xaxis":{"name":"month","agg":"sum"},"group":"","color":"","type":"chart","size":30,"sort":"xaxis","xStyle":{"r":-30,"s":"0","l":"-","ft":"-","wt":"-"},"title":"","subtitle":"","xaxistitle":"","yaxisheaders":["Monthly downloads"],"generalxaxis":"","theme":0,"in":[]}]&info_types=["spline"]&stacking=&steps=false&fontFamily=Courier&spacing=[5,0,0,0]&style=[{"color":"rgba(0, 0, 0, 1)","size":"18"},{"color":"rgba(0, 0, 0, 1)","size":"18"},{"color":"000000","size":""},{"color":"000000","size":""}]&backgroundColor=rgba(255,255,255,1)&colors[]=rgba(124, 181, 236, 1)&colors[]=rgba(67, 67, 72, 1)&colors[]=rgba(144, 237, 125, 1)&colors[]=rgba(247, 163, 92, 1)&colors[]=rgba(128, 133, 233, 1)&colors[]=rgba(241, 92, 128, 1)&colors[]=rgba(228, 211, 84, 1)&colors[]=rgba(43, 144, 143, 1)&colors[]=rgba(244, 91, 91, 1)&colors[]=rgba(145, 232, 225, 1)&xlinew=0&ylinew=1&legends=true&tooltips=true'; + // + // this.docsTimelineUrl ='https://beta.openaire.eu/stats/chart.php?com=query&persistent=false&data={"query":"dtsrcYear","dtsrcName":"'+this.id+'","table": "result", "fields": [{"fld": "number", "agg": "count", "type": "line", "yaxis":1, "c":true}], "xaxis":{"name": "year", "agg": "avg"}, "group": "", "color": "", "type": "chart", "size":30, "sort": "xaxis", "xStyle":{"r": "-", "s": "-", "l": "-", "ft": "-", "wt": "-"}, "yaxisheaders": [""], "fieldsheaders": ["Documents"], "in": [{"f":0, "text": "Yearly"}], "filters": [{"name":"year","max":"2016","min":"1997"},{"name": "result_datasources-datasource-name", "values":[""], "to": "-1"}],"having": [], "incfilters": [], "inchaving": [], "title": "", "subtitle": "", "xaxistitle": "Year"}&w=600&h=250'; + // this.docsTypesUrl = 'https://beta.openaire.eu/stats/chart.php?com=query&persistent=false&data={"query":"dtsrcPubs","dtsrcName":"'+this.id+'", "table": "result", "fields": [{"fld": "number", "agg": "count", "type": "pie", "yaxis":1, "c":false}], "xaxis":{"name": "result_classifications-type", "agg": "avg"}, "group": "", "color": "", "type": "chart", "size":30, "sort": "xaxis", "xStyle":{"r": "-", "s": "-", "l": "-", "ft": "-", "wt": "-"}, "yaxisheaders": [""], "fieldsheaders": ["Documents"], "in": [], "filters": [{"name": "result_datasources-datasource-name", "values": [""], "to": "-1"}], "having": [], "incfilters": [], "inchaving": [], "title": "", "subtitle": "", "xaxistitle": ""}&w=600&h=250'; + // this.pubsFunderUrl =' https://beta.openaire.eu/stats/chart.php?com=query&persistent=false&data={"query":"dtsrcPubsFund","dtsrcName":"'+this.id+'", "table": "result", "fields": [{"fld": "number", "agg": "count", "type": "pie", "yaxis":1, "c":false}], "xaxis":{"name": "result_classifications-type", "agg": "avg"}, "group": "", "color": "", "type": "chart", "size":30, "sort": "xaxis", "xStyle":{"r": "-", "s": "-", "l": "-", "ft": "-", "wt": "-"}, "yaxisheaders": [""], "fieldsheaders": ["Documents"], "in": [], "filters": [{"name": "result_datasources-datasource-name", "values": [""], "to": "-1"}], "having": [], "incfilters": [], "inchaving": [], "title": "", "subtitle": "", "xaxistitle": ""}&w=600&h=250'; + // this.dataProjectsUrl ='https://beta.openaire.eu/stats/chart.php?com=query&persistent=false&data={"query":"dtsrcProjData","dtsrcName":"'+this.id+'", "table": "result", "fields": [{"fld": "number", "agg": "count", "type": "bar", "yaxis":1, "c":false}], "xaxis":{"name": "result_classifications-type", "agg": "avg"}, "group": "", "color": "", "type": "chart", "size":30, "sort": "xaxis", "xStyle":{"r": "-", "s": "-", "l": "-", "ft": "-", "wt": "-"}, "yaxisheaders": [""], "fieldsheaders": ["Datasets"], "in": [], "filters": [{"name": "result_datasources-datasource-name", "values": [""], "to": "-1"}], "having": [], "incfilters": [], "inchaving": [], "title": "", "subtitle": "", "xaxistitle": ""}&w=600&h=250'; + // this.pubsProjectsUrl ='https://beta.openaire.eu/stats/chart.php?com=query&persistent=false&data={"query":"dtsrcProjPubs","dtsrcName":"'+this.id+'", "table": "result", "fields": [{"fld": "number", "agg": "count", "type": "bar", "yaxis":1, "c":false}], "xaxis":{"name": "result_classifications-type", "agg": "avg"}, "group": "", "color": "", "type": "chart", "size":30, "sort": "xaxis", "xStyle":{"r": "-", "s": "-", "l": "-", "ft": "-", "wt": "-"}, "yaxisheaders": [""], "fieldsheaders": ["Publications"], "in": [], "filters": [{"name": "result_datasources-datasource-name", "values": [""], "to": "-1"}], "having": [], "incfilters": [], "inchaving": [], "title": "", "subtitle": "", "xaxistitle": ""}&w=600&h=250'; + // } + // + // if(this.resultsBy == "collectedFrom") { + // this.paramsForSearchLink = "?collectedFrom="+this.id+"&co=and"; + // } else if (this.resultsBy == "hostedBy") { + // this.paramsForSearchLink = "?hostedBy="+this.id+"&ho=and"; + // } + // } + + private count(page: number, size: number) { + console.info("number of tabs: "+this.tabs.length); + + for(let i=1; i + + + + + +
+
+ + +
+ + ({{datasetInfo.date}}) +
+ +
+
Publisher:
+
{{datasetInfo.publisher}}
+
Type:
+
{{datasetInfo.type}}
+
Embargo end date:
+
{{datasetInfo.embargoEndDate}}
+ + + + +
+ +
+
{{datasetInfo.description}}
+
+ + + + +
    +
  • +
    + There are no related research results +
    +
    +
    +

    {{provenanceaction}}

    + + +
    +
    +
  • + +
  • +
    + There are no similar research results +
    +
    + +
    +
  • +
  • + + + + + + +
  • +
+
+ +
+ +
+
+
diff --git a/workingUIKIT/src/app/landingPages/dataset/dataset.component.ts b/workingUIKIT/src/app/landingPages/dataset/dataset.component.ts new file mode 100644 index 00000000..e4f309cb --- /dev/null +++ b/workingUIKIT/src/app/landingPages/dataset/dataset.component.ts @@ -0,0 +1,131 @@ +import {Component, ViewChild, ElementRef} from '@angular/core'; +import {Observable} from 'rxjs/Observable'; +import {DatasetService} from './dataset.service'; +import {DatasetInfo} from '../../utils/entities/datasetInfo'; +import {ActivatedRoute} from '@angular/router'; +import {OpenaireProperties} from '../../utils/properties/openaireProperties' +import {RouterHelper} from '../../utils/routerHelper.class'; +import { Meta} from '../../../angular2-meta'; + +@Component({ + selector: 'dataset', + templateUrl: 'dataset.component.html', +}) + +export class DatasetComponent { + public datasetInfo: DatasetInfo; + + public showAllCollectedFrom: boolean = false; + public showAllDownloadFrom: boolean = false; + public showAllFundedBy: boolean = false; + + private showStyle: boolean = false; + private showAllReferences: boolean = false; + private showAllRelResData: boolean = false; + private showAllSimilPubl: boolean = false; + private showAllBioentities: boolean = false; + private datasetId : string ; + private result ; + sub: any; + private metricsClicked: boolean; + private viewsFrameUrl: string; + private downloadsFrameUrl: string; + private totalViews: number; + private totalDownloads: number; + private pageViews: number; + + public relatedResearchResultsNum: number = 0; + + public warningMessage = ""; + public errorMessage = ""; + public routerHelper:RouterHelper = new RouterHelper(); + + constructor (private element: ElementRef, + private _datasetService: DatasetService, + private route: ActivatedRoute, + private _meta: Meta) {} + + ngOnInit() { + this.sub = this.route.queryParams.subscribe(params => { + this.datasetInfo = null; + this.updateTitle("Dataset"); + this.updateDescription("Dataset, search, open access"); + + this.datasetId = params['datasetId']; + console.info("Id is :"+this.datasetId); + + if(this.datasetId){ + this.getDatasetInfo(this.datasetId); + }else{ + this.warningMessage="No valid dataset id"; + } + + this.metricsClicked = false; + + this.viewsFrameUrl = OpenaireProperties.getFramesAPIURL()+'merge.php?com=query&data=[{"query":"resRepoViews", "resTitle":"'+this.datasetId+'", "table":"","fields":[{"fld":"sum","agg":"sum","type":"column","yaxis":1,"c":false}],"xaxis":{"name":"month","agg":"sum"},"group":" ","color":"","type":"chart","size":30,"sort":"xaxis","xStyle":{"r":-30,"s":"0","l":"-","ft":"-","wt":"-"},"title":"","subtitle":"","xaxistitle":"Repository","yaxisheaders":["Monthly views"],"generalxaxis":"","theme":0,"in":[],"filters":[{"name":"","values":[""],"to":"-1"}]}]&info_types=["column"]&stacking=normal&steps=false&fontFamily=Courier&spacing=[5,0,0,0]&style=[{"color":"rgba(0, 0, 0, 1)","size":"18"},{"color":"rgba(0, 0, 0, 1)","size":"18"},{"color":"000000","size":""},{"color":"000000","size":""}]&backgroundColor=rgba(255,255,255,1)&colors[]=rgba(67, 67, 72, 1)&colors[]=rgba(144, 237, 125, 1)&colors[]=rgba(247, 163, 92, 1)&colors[]=rgba(128, 133, 233, 1)&colors[]=rgba(241, 92, 128, 1)&colors[]=rgba(228, 211, 84, 1)&colors[]=rgba(43, 144, 143, 1)&colors[]=rgba(244, 91, 91, 1)&colors[]=rgba(145, 232, 225, 1)&xlinew=0&ylinew=1&legends=true&tooltips=true&persistent=false'; + /*this.viewsFrameUrl = OpenaireProperties.getFramesAPIURL()+'merge.php?com=query&data=[{"query":"resViewsTimeline", "resTitle":"'+this.datasetId+'", "table":"","fields":[{"fld":"sum","agg":"sum","type":"column","yaxis":1,"c":false}],"xaxis":{"name":"month","agg":"sum"},"group":" ","color":"","type":"chart","size":30,"sort":"xaxis","xStyle":{"r":-30,"s":"0","l":"-","ft":"-","wt":"-"},"title":"","subtitle":"","xaxistitle":"Repository","yaxisheaders":["Monthly views"],"generalxaxis":"","theme":0,"in":[],"filters":[{"name":"","values":[""],"to":"-1"}]}]&info_types=["column"]&stacking=normal&steps=false&fontFamily=Courier&spacing=[5,0,0,0]&style=[{"color":"rgba(0, 0, 0, 1)","size":"18"},{"color":"rgba(0, 0, 0, 1)","size":"18"},{"color":"000000","size":""},{"color":"000000","size":""}]&backgroundColor=rgba(255,255,255,1)&colors[]=rgba(124, 181, 236, 1)&colors[]=rgba(67, 67, 72, 1)&colors[]=rgba(144, 237, 125, 1)&colors[]=rgba(247, 163, 92, 1)&colors[]=rgba(128, 133, 233, 1)&colors[]=rgba(241, 92, 128, 1)&colors[]=rgba(228, 211, 84, 1)&colors[]=rgba(43, 144, 143, 1)&colors[]=rgba(244, 91, 91, 1)&colors[]=rgba(145, 232, 225, 1)&xlinew=0&ylinew=1&legends=true&tooltips=true&persistent=false'; + */ + + this.downloadsFrameUrl = OpenaireProperties.getFramesAPIURL()+'merge.php?com=query&data=[{"query":"resRepoDownloads", "resTitle":"'+this.datasetId+'", "table":"","fields":[{"fld":"sum","agg":"sum","type":"column","yaxis":1,"c":false}],"xaxis":{"name":"month","agg":"sum"},"group":" ","color":"","type":"chart","size":30,"sort":"xaxis","xStyle":{"r":-30,"s":"0","l":"-","ft":"-","wt":"-"},"title":"","subtitle":"","xaxistitle":"Repository","yaxisheaders":["Monthly downloads"],"generalxaxis":"","theme":0,"in":[],"filters":[{"name":"","values":[""],"to":"-1"}]}]&info_types=["column"]&stacking=normal&steps=false&fontFamily=Courier&spacing=[5,0,0,0]&style=[{"color":"rgba(0, 0, 0, 1)","size":"18"},{"color":"rgba(0, 0, 0, 1)","size":"18"},{"color":"000000","size":""},{"color":"000000","size":""}]&backgroundColor=rgba(255,255,255,1)&colors[]=rgba(67, 67, 72, 1)&colors[]=rgba(144, 237, 125, 1)&colors[]=rgba(247, 163, 92, 1)&colors[]=rgba(128, 133, 233, 1)&colors[]=rgba(241, 92, 128, 1)&colors[]=rgba(228, 211, 84, 1)&colors[]=rgba(43, 144, 143, 1)&colors[]=rgba(244, 91, 91, 1)&colors[]=rgba(145, 232, 225, 1)&xlinew=0&ylinew=1&legends=true&tooltips=true&persistent=false'; + /*this.downloadsFrameUrl = OpenaireProperties.getFramesAPIURL()+'merge.php?com=query&data=[{"query":"resRepoDownloadTimeline", "resTitle":"'+this.datasetId+'", "table":"","fields":[{"fld":"sum","agg":"sum","type":"column","yaxis":1,"c":false}],"xaxis":{"name":"month","agg":"sum"},"group":" ","color":"","type":"chart","size":30,"sort":"xaxis","xStyle":{"r":-30,"s":"0","l":"-","ft":"-","wt":"-"},"title":"","subtitle":"","xaxistitle":"Repository","yaxisheaders":["Monthly downloads"],"generalxaxis":"","theme":0,"in":[],"filters":[{"name":"","values":[""],"to":"-1"}]}]&info_types=["column"]&stacking=normal&steps=false&fontFamily=Courier&spacing=[5,0,0,0]&style=[{"color":"rgba(0, 0, 0, 1)","size":"18"},{"color":"rgba(0, 0, 0, 1)","size":"18"},{"color":"000000","size":""},{"color":"000000","size":""}]&backgroundColor=rgba(255,255,255,1)&colors[]=rgba(67, 67, 72, 1)&colors[]=rgba(144, 237, 125, 1)&colors[]=rgba(247, 163, 92, 1)&colors[]=rgba(128, 133, 233, 1)&colors[]=rgba(241, 92, 128, 1)&colors[]=rgba(228, 211, 84, 1)&colors[]=rgba(43, 144, 143, 1)&colors[]=rgba(244, 91, 91, 1)&colors[]=rgba(145, 232, 225, 1)&xlinew=0&ylinew=1&legends=true&tooltips=true'; + */ + if (typeof document !== 'undefined') { + this.element.nativeElement.scrollIntoView(); + } + }); + + } + + ngOnDestroy() { + this.sub.unsubscribe(); + } + + getDatasetInfo(id:string) { + this.warningMessage = ''; + this.errorMessage="" + + this._datasetService.getDatasetInfo(id).subscribe( + data => { + this.datasetInfo = data; + this.updateTitle(this.datasetInfo.title.name); + this.updateDescription("Dataset, search, repositories, open access,"+this.datasetInfo.title.name); + this.result = [] + this.result = {id: id, type :"dataset", source : "openaire", title: this.datasetInfo.title,url: '', result: '', accessRights: this.datasetInfo.bestlicense, embargoEndDate: ''}; + + let relatedResearchResultsNum = 0; + if(this.datasetInfo.relatedResearchResults != undefined) { + this.datasetInfo.relatedResearchResults.forEach(function (value, key, map) { + relatedResearchResultsNum += value.length; + }); + } + this.relatedResearchResultsNum = relatedResearchResultsNum; + }, + err => { + console.log(err) + console.info("error"); + + this.errorMessage = 'No dataset found'; + } + ); + } + + showChange($event) { + this.showAllReferences=$event.value; + } + + public metricsResults($event) { + this.totalViews = $event.totalViews; + this.totalDownloads = $event.totalDownloads; + this.pageViews = $event.pageViews; + } + updateDescription(description:string){ + this._meta.updateMeta("description", description); + this._meta.updateMeta("og:description", description); + } + updateTitle(title:string){ + var _suffix ="| OpenAIRE"; + var _title = ((title.length> 50 ) ?title.substring(0,50):title) + _suffix; + this._meta.setTitle(_title ); + this._meta.updateMeta("og:title",_title); + } +} diff --git a/workingUIKIT/src/app/landingPages/dataset/dataset.module.ts b/workingUIKIT/src/app/landingPages/dataset/dataset.module.ts new file mode 100644 index 00000000..68252bc3 --- /dev/null +++ b/workingUIKIT/src/app/landingPages/dataset/dataset.module.ts @@ -0,0 +1,36 @@ +//import {MaterialModule} from '@angular/material'; +import { NgModule} from '@angular/core'; +import { CommonModule } from '@angular/common'; +import { FormsModule } from '@angular/forms'; +import { SharedModule } from '../../shared/shared.module'; +import { RouterModule } from '@angular/router'; + +import { DatasetService} from './dataset.service'; +import { DatasetComponent } from './dataset.component'; +import { DatasetRoutingModule } from './dataset-routing.module'; +import {MetricsModule} from '../metrics.module'; +import {IFrameModule} from '../../utils/iframe.module'; +import {AltMetricsModule} from '../../utils/altmetrics.module'; +import {CiteThisModule} from '../landing-utils/citeThis/citeThis.module'; + +import { ResultLandingModule } from '../resultLanding.module'; +import { LandingModule } from '../landing.module'; +import {FreeGuard} from'../../login/freeGuard.guard'; + +@NgModule({ + imports: [ + //MaterialModule.forRoot(), + CommonModule, FormsModule,SharedModule, RouterModule, LandingModule, CiteThisModule, + ResultLandingModule, DatasetRoutingModule, MetricsModule, IFrameModule, AltMetricsModule + ], + declarations: [ + DatasetComponent + ], + providers:[ + DatasetService, FreeGuard + ], + exports: [ + DatasetComponent + ] +}) +export class DatasetModule { } diff --git a/workingUIKIT/src/app/landingPages/dataset/dataset.service.ts b/workingUIKIT/src/app/landingPages/dataset/dataset.service.ts new file mode 100644 index 00000000..c33e791c --- /dev/null +++ b/workingUIKIT/src/app/landingPages/dataset/dataset.service.ts @@ -0,0 +1,666 @@ +import {Injectable} from '@angular/core'; +import {Http, Response} from '@angular/http'; +import {Observable} from 'rxjs/Observable'; +import {DatasetInfo} from '../../utils/entities/datasetInfo'; +import {OpenaireProperties} from '../../utils/properties/openaireProperties'; +import 'rxjs/add/observable/of'; +import 'rxjs/add/operator/do'; +import 'rxjs/add/operator/share'; +import { CacheService } from '../../shared/cache.service'; + +@Injectable() +export class DatasetService { + + constructor(private http: Http, public _cache: CacheService) {} + + datasetInfo: DatasetInfo; + + getDatasetInfo (id: string):any { + console.info("getDatasetInfo in service"); + + let url = OpenaireProperties. getSearchAPIURLLast()+'datasets/'+id+"?format=json"; + let key = url; + if (this._cache.has(key)) { + return Observable.of(this._cache.get(key)).map(res => this.parseDatasetInfo(res)); + } + + return this.http.get(url) + .map(res => res.json()) + .do(res => console.info(res['result']['metadata']['oaf:entity'])) + .map(res => res['result']['metadata']['oaf:entity']['oaf:result']) + .map(res => [res, + res['title'], + res['rels']['rel'], + res['children'], + res['pid'], + res['subject'], + res['bestlicense'], + res['collectedfrom'], + res['context'], + res['resulttype'] + ]).do(res => { + this._cache.set(key, res); + }) + .map(res => this.parseDatasetInfo(res)); + } + + private handleError (error: Response) { + // 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'); + } + + parseDatasetInfo (data: any):any { + this.datasetInfo = new DatasetInfo(); + + if(data[0] != null) { + this.datasetInfo.date = data[0].dateofacceptance.substring(0,4); + this.datasetInfo.dateofacceptance = data[0].dateofacceptance; + this.datasetInfo.publisher = data[0].publisher; + if(!Array.isArray(data[0].description)) { + this.datasetInfo.description = data[0].description; + } else { + this.datasetInfo.description = data[0].description[0]; + } + this.datasetInfo.embargoEndDate = data[0].embargoenddate; + } + this.datasetInfo.title = {"name": "", "url": "", "accessMode": ""}; + if(data[0]['bestlicense'].hasOwnProperty("classid")) { + this.datasetInfo.title.accessMode = data[0]['bestlicense'].classid; + } + if(data[1] != null) { + if(Array.isArray(data[1])) { + this.datasetInfo.title['name'] = data[1][0].content; + } else { + this.datasetInfo.title['name'] = data[1].content; + } + } + + if(data[2] != null) { + let mydata; + let counter = 0; + let length = data[2].length!=undefined ? data[2].length : 1; + + for(let i=0; i(); + } + + this.datasetInfo.authors[mydata.ranking-1] = {"name": "", "id": ""}; + this.datasetInfo.authors[mydata.ranking-1]['name'] = mydata.fullname; + this.datasetInfo.authors[mydata.ranking-1]['id'] = /*OpenaireProperties.getsearchLinkToPerson()+*/mydata['to'].content; + } else if(mydata['to'].class == "isProducedBy") { + if(this.datasetInfo.fundedByProjects == undefined) { + this.datasetInfo.fundedByProjects = new Array< + { "id": string, "acronym": string, "title": string, + "funderShortname": string, "funderName": string, + "funding": string, "inline": boolean + }>(); + } + + counter = this.datasetInfo.fundedByProjects.length; + + this.datasetInfo.fundedByProjects[counter] = { + "id": "", "acronym": "", "title": "", + "funderShortname": "", "funderName": "", + "funding": "", "inline": false + } + + this.datasetInfo.fundedByProjects[counter]['id'] = + /*OpenaireProperties.getsearchLinkToProject()+*/mydata['to'].content; + this.datasetInfo.fundedByProjects[counter]['acronym'] = mydata.acronym; + this.datasetInfo.fundedByProjects[counter]['title'] = mydata.title; + + if(mydata.hasOwnProperty("funding")) { + let length1 = Array.isArray(mydata['funding']) ? mydata['funding'].length : 1; + + for(let j=0; j(); + } + */ + if(this.datasetInfo.relatedResearchResults == undefined) { + this.datasetInfo.relatedResearchResults = + new Map(); + } + + if(!this.datasetInfo.relatedResearchResults.has(provenanceAction)) { + this.datasetInfo.relatedResearchResults.set(provenanceAction, + new Array<{ "name": string, "id": string, "date": string, + "trust": string, "class": string}>()); + } + + counter = this.datasetInfo.relatedResearchResults.get(provenanceAction).length; + this.datasetInfo.relatedResearchResults.get(provenanceAction)[counter] = {"name": "", "id": "", "date": "", "trust": "", "class": ""} + + //let url; + if(mydata['resulttype'].classname == "publication") { + //url = OpenaireProperties.getsearchLinkToPublication()+mydata['to'].content; + this.datasetInfo.relatedResearchResults.get(provenanceAction)[counter]['class'] = "publication"; + } else { + //url = OpenaireProperties.getsearchLinkToDataset()+mydata['to'].content; + this.datasetInfo.relatedResearchResults.get(provenanceAction)[counter]['class'] = "dataset"; + } + + this.datasetInfo.relatedResearchResults.get(provenanceAction)[counter]['id'] = mydata['to'].content; + //this.datasetInfo.relatedResearchResults[counter]['url'] = url; + let titleName = Array.isArray(mydata['title']) ? mydata['title'][0].content : mydata['title'].content; + this.datasetInfo.relatedResearchResults.get(provenanceAction)[counter]['name'] = titleName; + this.datasetInfo.relatedResearchResults.get(provenanceAction)[counter]['date'] = mydata.dateofacceptance.substring(0,4);; + this.datasetInfo.relatedResearchResults.get(provenanceAction)[counter]['trust'] = Math.round(mydata.trust*100)+"%"; + + } else if(mydata['to'].class == "hasAmongTopNSimilarDocuments") { + if(this.datasetInfo.similarResearchResults == undefined) { + this.datasetInfo.similarResearchResults = new Array<{ + "name": string, "id": string, "date": string, + "trust": string, "class": string}>(); + } + + counter = this.datasetInfo.similarResearchResults.length; + this.datasetInfo.similarResearchResults[counter] = {"name": "", "id": "", "date": "", "trust": "", "class": ""} + + //let url; + if(mydata['resulttype'].classname == "publication") { + //url = OpenaireProperties.getsearchLinkToPublication()+mydata['to'].content; + this.datasetInfo.similarResearchResults[counter]['class'] = "publication"; + } else { + //url = OpenaireProperties.getsearchLinkToDataset()+mydata['to'].content; + this.datasetInfo.similarResearchResults[counter]['class'] = "dataset"; + } + + this.datasetInfo.similarResearchResults[counter]['id'] = mydata['to'].content; + //this.datasetInfo.similarResearchResults[counter]['url'] = url; + let titleName = Array.isArray(mydata['title']) ? mydata['title'][0].content : mydata['title'].content; + this.datasetInfo.similarResearchResults[counter]['name'] = titleName; + this.datasetInfo.similarResearchResults[counter]['date'] = mydata.dateofacceptance.substring(0,4);; + this.datasetInfo.similarResearchResults[counter]['trust'] = Math.round(mydata.trust*100)+"%"; + + + } + } + } + + if(this.datasetInfo.authors != undefined) { + this.datasetInfo.authors = this.datasetInfo.authors.filter(function (item) { + return (item != undefined); + }); + } + } + + if(data[3] != null) { + if(data[3].hasOwnProperty("instance")) { + this.datasetInfo.downloadFrom = new Map(); + this.datasetInfo.publishedIn = new Map() + + let length = data[3]['instance'].length!=undefined ? data[3]['instance'].length : 1; + + let counter = 0; + let counter1 = 0; + let counter2 = 0; + let mydata; + for(let i=0; i(); + } + + counter2 = this.datasetInfo.downloadFrom.get(key)['url'].length; + this.datasetInfo.downloadFrom.get(key)['url'][counter2] = url; + + if(this.datasetInfo.downloadFrom.get(key)['accessMode'] == null) { + this.datasetInfo.downloadFrom.get(key)['accessMode'] = new Array(); + } + + if(mydata.hasOwnProperty("licence")) { + this.datasetInfo.downloadFrom.get(key)['accessMode'].push(mydata['licence'].classid); + //this.datasetInfo.downloadFrom.get(mydata['hostedby'].name)['accessMode'][counter2] = mydata['licence'].classid; + + switch (this.datasetInfo.downloadFrom.get(key)['bestAccessMode']) { + case null: + this.datasetInfo.downloadFrom.get(key)['bestAccessMode'] = mydata['licence'].classid; + break; + case "CLOSED": + if(mydata['licence'].classid == "OPEN" || + mydata['licence'].classid == "EMBARGO" || + mydata['licence'].classid == "RESTRICTED") { + this.datasetInfo.downloadFrom.get(key)['bestAccessMode'] = mydata['licence'].classid; + } + break; + case "RESTRICTED": + if(mydata['licence'].classid == "OPEN" || + mydata['licence'].classid == "EMBARGO") { + this.datasetInfo.downloadFrom.get(key)['bestAccessMode'] = mydata['licence'].classid; + } + break; + case "EMBARGO": + if(mydata['licence'].classid == "OPEN") { + this.datasetInfo.downloadFrom.get(key)['bestAccessMode'] = mydata['licence'].classid; + } + break; + } + } else { + //this.datasetInfo.downloadFrom.get(mydata['hostedby'].name)['accessMode'][counter2] = ""; + this.datasetInfo.downloadFrom.get(key)['accessMode'].push(""); + } + } else { + if(data[0] != null && data[0].hasOwnProperty("source")) { + let key: string; + if(Array.isArray(data[0].source)) { + if(!this.datasetInfo.publishedIn.has(data[0]['source'][counter1])) { + key = data[0]['source'][counter1]; + } + } else { + if(!this.datasetInfo.publishedIn.has(data[0]['source'])) { + key = data[0]['source']; + } + } + + this.datasetInfo.publishedIn.set(key, {"url": null, "accessMode": null, "bestAccessMode": null}); + + if(this.datasetInfo.publishedIn.get(key)['url'] == null) { + this.datasetInfo.publishedIn.get(key)['url'] = new Array(); + } + + counter2 = this.datasetInfo.publishedIn.get(key)['url'].length; + this.datasetInfo.publishedIn.get(key)['url'][counter2] = url; + + if(this.datasetInfo.publishedIn.get(key)['accessMode'] == null) { + this.datasetInfo.publishedIn.get(key)['accessMode'] = new Array(); + } + + if(mydata.hasOwnProperty("licence")) { + //this.datasetInfo.publishedIn.get(key)['accessMode'][counter2] = mydata['licence'].classid; + this.datasetInfo.publishedIn.get(key)['accessMode'].push(mydata['licence'].classid); + switch (this.datasetInfo.publishedIn.get(key)['bestAccessMode']) { + case null: + this.datasetInfo.publishedIn.get(key)['bestAccessMode'] = mydata['licence'].classid; + break; + case "CLOSED": + if(mydata['licence'].classid == "OPEN" || + mydata['licence'].classid == "EMBARGO" || + mydata['licence'].classid == "RESTRICTED") { + this.datasetInfo.publishedIn.get(key)['bestAccessMode'] = mydata['licence'].classid; + } + break; + case "RESTRICTED": + if(mydata['licence'].classid == "OPEN" || + mydata['licence'].classid == "EMBARGO") { + this.datasetInfo.publishedIn.get(key)['bestAccessMode'] = mydata['licence'].classid; + } + break; + case "EMBARGO": + if(mydata['licence'].classid == "OPEN") { + this.datasetInfo.publishedIn.get(key)['bestAccessMode'] = mydata['licence'].classid; + } + break; + } + } else { + //this.datasetInfo.publishedIn.get(key)['accessMode'][counter2] = ""; + this.datasetInfo.publishedIn.get(key)['accessMode'].push(""); + } + counter1++; + } + } + if(this.datasetInfo.title != undefined) { + if(this.datasetInfo.title['url'] == undefined) { + this.datasetInfo.title['url'] = url; + } + + switch (this.datasetInfo.title['licence']) { + case undefined: + this.datasetInfo.title['licence'] = mydata['licence'].classid; + this.datasetInfo.title['url'] = url; + break; + case "CLOSED": + if(mydata['licence'].classid == "OPEN" || + mydata['licence'].classid == "EMBARGO" || + mydata['licence'].classid == "RESTRICTED") { + this.datasetInfo.title['licence'] = mydata['licence'].classid; + this.datasetInfo.title['url'] = url; + } + break; + case "RESTRICTED": + if(mydata['licence'].classid == "OPEN" || + mydata['licence'].classid == "EMBARGO") { + this.datasetInfo.title['licence'] = mydata['licence'].classid; + this.datasetInfo.title['url'] = url; + } + break; + case "EMBARGO": + if(mydata['licence'].classid == "OPEN") { + this.datasetInfo.title['licence'] = mydata['licence'].classid; + this.datasetInfo.title['url'] = url; + } + break; + } + } + } + } + } + } + } + + if(data[4] != null) { + let counter = 0; + this.datasetInfo.identifiers = new Map(); + + if(data[4].hasOwnProperty("classname") && data[4]['classname'] != "") { + if(data[4].classname == "doi" || data[4].classname == "pmc") { + if(!this.datasetInfo.identifiers.has(data[4].classname)) { + this.datasetInfo.identifiers.set(data[4].classname, new Array()); + } + counter = this.datasetInfo.identifiers.get(data[4].classname).length; + this.datasetInfo.identifiers.get(data[4].classname)[counter] = data[4].content; + } + } else { + for(let i=0; i()); + } + counter = this.datasetInfo.identifiers.get(data[4][i].classname).length; + this.datasetInfo.identifiers.get(data[4][i].classname)[counter] = data[4][i].content; + } + } + } + } + + if(data[5] != null) { + let mydata; + let length = data[7].length!=undefined ? data[5].length : 1; + + for(let i=0; i(); + } + + if(!this.datasetInfo.classifiedSubjects.has(mydata.classname)) { + this.datasetInfo.classifiedSubjects.set(mydata.classname, new Array()); + } + + this.datasetInfo.classifiedSubjects.get(mydata.classname).push(mydata.content); + } else { + if(mydata.classid == "keyword") { + if(this.datasetInfo.subjects == undefined) { + this.datasetInfo.subjects = new Array(); + } + + this.datasetInfo.subjects.push(mydata.content); + } else { + if(this.datasetInfo.otherSubjects == undefined) { + this.datasetInfo.otherSubjects = new Map(); + } + + if(!this.datasetInfo.otherSubjects.has(mydata.classname)) { + this.datasetInfo.otherSubjects.set(mydata.classname, new Array()); + } + this.datasetInfo.otherSubjects.get(mydata.classname).push(mydata.content); + } + } + } + } + } + + if(data[6] != null) { + this.datasetInfo.bestlicense = data[6].classid; + } + + if(data[7] != null) { + this.datasetInfo.collectedFrom = new Array<{"name": string, "id": string}>(); + + let mydata; + let length = data[7].length!=undefined ? data[7].length : 1; + for(let i=0; i(); + } + + this.datasetInfo.downloadFrom.set(this.datasetInfo.publisher, {"url": null, "accessMode": null, "bestAccessMode": null}); + + let url = OpenaireProperties.getDoiURL()+this.datasetInfo.identifiers.get("doi"); + this.datasetInfo.downloadFrom.get(this.datasetInfo.publisher)['url'] = new Array(); + this.datasetInfo.downloadFrom.get(this.datasetInfo.publisher)['accessMode'] = new Array(); + + this.datasetInfo.downloadFrom.get(this.datasetInfo.publisher)['url'][0] = url; + this.datasetInfo.downloadFrom.get(this.datasetInfo.publisher)['accessMode'][0] = ""; + + if(this.datasetInfo.title != undefined && this.datasetInfo.title['url'] == "") { + this.datasetInfo.title['url'] = url; + } + } + + if(data[8] != null) { + this.datasetInfo.contexts = new Array< + { "labelContext": string, "labelCategory": string, "labelConcept": string, "inline": boolean}>(); + + let position = 0; + let labels = ""; + let mydata; + let length = data[8].length!=undefined ? data[8].length : 1; + for(let i=0; i 1 ? mydata['category']['concept'][j] : mydata['category']['concept']; + + this.datasetInfo.contexts[position] = {"labelContext": "", "labelCategory": "", "labelConcept": "", inline: false}; + this.datasetInfo.contexts[position]['labelContext'] = mydata.label; + this.datasetInfo.contexts[position]['labelCategory'] = mydata['category'].label;; + this.datasetInfo.contexts[position]['labelConcept'] = mydata1.label; + + position++; + } + } else { + this.datasetInfo.contexts[position] = {"labelContext": "", "labelCategory": "", "labelConcept": "", inline: false}; + this.datasetInfo.contexts[position]['labelContext'] = mydata.label; + this.datasetInfo.contexts[position]['labelCategory'] = mydata['category'].label;; + this.datasetInfo.contexts[position]['labelConcept'] = null; + } + } else { + this.datasetInfo.contexts[position] = {"labelContext": "", "labelCategory": "", "labelConcept": "", inline: false}; + this.datasetInfo.contexts[position]['labelContext'] = mydata.label; + this.datasetInfo.contexts[position]['labelCategory'] = null; + this.datasetInfo.contexts[position]['labelConcept'] = null; + } + } + } + } + + if(data[9] != null && this.datasetInfo.type == undefined) { + if(data[9].hasOwnProperty('classname')) { + this.datasetInfo.type = data[9].classname; + } + } + + + //this.printdatasetInfo(); + return this.datasetInfo; + + } + + printDatasetInfo() { + console.info("DATE: "+this.datasetInfo.date); + console.info("PUBLISHER: "+this.datasetInfo.publisher); + console.info("DESCRIPTION: "+this.datasetInfo.description); + + console.info("TITLE: "+this.datasetInfo.title); + + console.info("AUTHORS: "+this.datasetInfo.authors); + console.info("\nFUNDED BY PROJECTS:"); + if(this.datasetInfo.fundedByProjects != undefined) { + this.datasetInfo.fundedByProjects.forEach(function (value, key, map) { + console.info(key + " = " + value); + }); + } else { + console.info("undefined"); + } + console.info("\n"); +/* + console.info("\nRELATED RESEARCH DATA:"); + if(this.datasetInfo.relatedResearchData != undefined) { + this.datasetInfo.relatedResearchData.forEach(function (value, key, map) { + console.info(key + " = " + value); + }); + } else { + console.info("undefined"); + } + console.info("\n"); + + console.info("\nSIMILAR datasetS:"); + if(this.datasetInfo.similarPublications != undefined) { + this.datasetInfo.similarPublications.forEach(function (value, key, map) { + console.info(key + " = " + value); + }); + } else { + console.info("undefined"); + } + console.info("\n"); +*/ + console.info("TYPE: "+this.datasetInfo.type); + console.info("\nDOWNLOAD FROM:"); + if(this.datasetInfo.downloadFrom != undefined) { + this.datasetInfo.downloadFrom.forEach(function (value, key, map) { + console.info(key + " = " + value); + }); + } else { + console.info("undefined"); + } + console.info("\n"); + + console.info("\nIDENTIFIERS:"); + if(this.datasetInfo.identifiers != undefined) { + this.datasetInfo.identifiers.forEach(function (value, key, map) { + console.info(key + " = " + value); + }); + } else { + console.info("undefined"); + } + console.info("\n"); + + console.info("SUBJECTS: "+this.datasetInfo.subjects); + console.info("\nCLASSIFIED OBJECTS:"); + if(this.datasetInfo.classifiedSubjects != undefined) { + this.datasetInfo.classifiedSubjects.forEach(function (value, key, map) { + console.info(key + " = " + value); + }); + } else { + console.info("undefined"); + } + console.info("\n"); + + console.info("BEST LICENSE: "+this.datasetInfo.bestlicense); + + console.info("\nCOLLECTED FROM:"); + if(this.datasetInfo.collectedFrom != undefined) { + this.datasetInfo.collectedFrom.forEach(function (value, key, map) { + console.info(key + " = " + value); + }); + } else { + console.info("undefined"); + } + console.info("\n"); + + console.info("\nDOWNLOAD FROM:"); + if(this.datasetInfo.downloadFrom != undefined) { + this.datasetInfo.downloadFrom.forEach(function (value, key, map) { + console.info(key + " = " + value); + }); + } else { + console.info("undefined"); + } + console.info("\n"); + } +} diff --git a/workingUIKIT/src/app/landingPages/htmlProjectReport/htmlProjectReport-routing.module.ts b/workingUIKIT/src/app/landingPages/htmlProjectReport/htmlProjectReport-routing.module.ts new file mode 100644 index 00000000..8d7db9ef --- /dev/null +++ b/workingUIKIT/src/app/landingPages/htmlProjectReport/htmlProjectReport-routing.module.ts @@ -0,0 +1,14 @@ +import { NgModule } from '@angular/core'; +import { RouterModule } from '@angular/router'; + +import { HtmlProjectReportComponent } from './htmlProjectReport.component'; +import {FreeGuard} from'../../login/freeGuard.guard'; + +@NgModule({ + imports: [ + RouterModule.forChild([ + { path: '', component: HtmlProjectReportComponent , canActivate: [FreeGuard]} + ]) +] +}) +export class HtmlProjectReportRoutingModule { } diff --git a/workingUIKIT/src/app/landingPages/htmlProjectReport/htmlProjectReport.component.ts b/workingUIKIT/src/app/landingPages/htmlProjectReport/htmlProjectReport.component.ts new file mode 100644 index 00000000..afb72665 --- /dev/null +++ b/workingUIKIT/src/app/landingPages/htmlProjectReport/htmlProjectReport.component.ts @@ -0,0 +1,130 @@ +import {Component} from '@angular/core'; +import {Observable} from 'rxjs/Observable'; +import {ActivatedRoute, Params} from '@angular/router'; +import {isBrowser, isNode} from 'angular2-universal'; +import {HtmlProjectReportService} from './htmlProjectReport.service'; +import {ProjectService} from '../project/project.service'; + +@Component({ + selector: 'htmlProjectReport', + template: ` +
+ + +
+

Raw html is copied. Please paste it on an html file.

+
+ +

{{header1}}

+

{{header2}}

+
+
+ ` + }) +export class HtmlProjectReportComponent{ + public projectId: string; + public totalResults: number; + + public header1: string; + public header2: string; + public htmlResult: string = ""; + + public sub; + public subHTML; + public subHTMLInfo; + + public copied: boolean = false; + + constructor ( private route: ActivatedRoute, + private htmlService: HtmlProjectReportService, + private _projectService: ProjectService) { + } + + ngOnInit() { + this.sub = this.route.queryParams.subscribe(params => { + this.projectId = params['projectId']; + this.totalResults = params['size']; + + this.createHeaders(); + this.createClipboard(); + }); + } + + ngOnDestroy() {} + + createHeaders() { + this._projectService.getHTMLInfo(this.projectId).subscribe( + data => { + this.createHeader1(data); + }, + err => { + console.log(err); + } + ); + + this.header2 = this.totalResults+" publications"; + } + + createClipboard() { + let intro: string = ''; + intro += ''; + intro += ''; + intro += ''+this.header1+'' + intro += ''; + intro += ''; + + if (typeof window !== 'undefined') { + this.htmlService.getHTML(this.projectId, this.totalResults).subscribe( + data => { + let body: string = intro+'

'+this.header1+'

'+this.header2+'

'+data+''; + + this.htmlResult = data; + + let clipboard; + let Clipboard; + Clipboard = require('clipboard'); + clipboard = new Clipboard('.btn', { + /*target: function(trigger) { + return document.getElementById("clipboard"); + }*/ + text: function(trigger) { + return body;//document.getElementById("clipboard").getAttribute('innerHTML');//"aaaa"+tmp+"oo"; + } + }); + }, + err => { + console.log(err); + } + ); + } + } + + createHeader1(data: {"title": string, "acronym": string, "callIdentifier": string}) { + console.info(data); + this.header1 = "Publications of Project "; + + if(data != undefined) { + if(data.title != undefined && data.title != "") { + this.header1 += data.title; + } + if((data.title != undefined && data.title != "") && + ((data.acronym != undefined && data.acronym != "") || + (data.callIdentifier != undefined && data.callIdentifier != ""))) { + this.header1 += "("; + } + if(data.acronym != undefined && data.acronym != "") { + this.header1 += data.acronym + " - "; + } + if(data.callIdentifier != undefined && data.callIdentifier != "") { + this.header1 += data.callIdentifier; + } + if((data.title != undefined && data.title != "") && + ((data.acronym != undefined && data.acronym != "") || + (data.callIdentifier != undefined && data.callIdentifier != ""))) { + this.header1 += ")"; + } + } + } +} diff --git a/workingUIKIT/src/app/landingPages/htmlProjectReport/htmlProjectReport.module.ts b/workingUIKIT/src/app/landingPages/htmlProjectReport/htmlProjectReport.module.ts new file mode 100644 index 00000000..00218772 --- /dev/null +++ b/workingUIKIT/src/app/landingPages/htmlProjectReport/htmlProjectReport.module.ts @@ -0,0 +1,27 @@ +//import {MaterialModule} from '@angular/material'; +import { NgModule} from '@angular/core'; +import { CommonModule } from '@angular/common'; +import { FormsModule } from '@angular/forms'; +import { ProjectServiceModule} from '../project/projectService.module'; +import { CacheService } from '../../shared/cache.service'; + +import {HtmlProjectReportService} from './htmlProjectReport.service'; +import {HtmlProjectReportComponent} from './htmlProjectReport.component'; +import { HtmlProjectReportRoutingModule } from './htmlProjectReport-routing.module'; +import {FreeGuard} from'../../login/freeGuard.guard'; + +@NgModule({ + imports: [ + CommonModule, FormsModule, HtmlProjectReportRoutingModule, ProjectServiceModule + ], + declarations: [ + HtmlProjectReportComponent + ], + providers:[ + HtmlProjectReportService,CacheService, FreeGuard + ], + exports: [ + HtmlProjectReportComponent + ] +}) +export class HtmlProjectReportModule { } diff --git a/workingUIKIT/src/app/landingPages/htmlProjectReport/htmlProjectReport.service.ts b/workingUIKIT/src/app/landingPages/htmlProjectReport/htmlProjectReport.service.ts new file mode 100644 index 00000000..1c9ec92f --- /dev/null +++ b/workingUIKIT/src/app/landingPages/htmlProjectReport/htmlProjectReport.service.ts @@ -0,0 +1,27 @@ +import {Injectable} from '@angular/core'; +import {Http, Response} from '@angular/http'; +import {Observable} from 'rxjs/Observable'; +import {OpenaireProperties} from '../../utils/properties/openaireProperties'; +import 'rxjs/add/operator/do'; +import { CacheService } from '../../shared/cache.service'; +@Injectable() +export class HtmlProjectReportService { + + constructor(private http: Http, public _cache: CacheService) {} + + getHTML(id: string, size: number):any { + console.info("getHTML in service"); + //let url = OpenaireProperties. getSearchAPIURLLast() + 'publications/' +id+"?format=json"; + let url = OpenaireProperties.getCsvAPIURL(); + url += 'resources?format=html&page=0&size='+size+'&type=publications&query=(((oaftype exact result) and (resulttypeid exact publication)) and (relprojectid exact "'+id+'"))'; + let key = url; + if (this._cache.has(key)) { + return Observable.of(this._cache.get(key)); + } + return this.http.get(url) + .map(res => res.text()) + .do(res => { + this._cache.set(key, res); + }); + } +} diff --git a/workingUIKIT/src/app/landingPages/landing-utils/citeThis/citation.class.ts b/workingUIKIT/src/app/landingPages/landing-utils/citeThis/citation.class.ts new file mode 100644 index 00000000..3a8f42d8 --- /dev/null +++ b/workingUIKIT/src/app/landingPages/landing-utils/citeThis/citation.class.ts @@ -0,0 +1,110 @@ +export class Citation{ + public templates:string[]=["bibtex","chicago","ieee","science","apa","cell","harvard","mla","nature","acm"]; + + bibtex:string =` `; + ieee_csl:string =` `; + chicago_csl:string =` `; + science_csl:string =' '; + cell_csl:string =' '; + mla_csl:string =' '; + nature_csl:string =' '; +//nature_csl:string =' '; + acm_csl:string =' '; + + public getOptionsBy(template:string):any{ + if(template == "bibtex"){ + var options:any ={ // Subsequent calls + format: 'string', + type: 'string', + style: 'bibtex' + } + return options; + }else if(template == "apa"){ + var options:any ={ // Subsequent calls + format: 'string', + type: 'string', + style: 'citation-apa' + } + return options; + }else if(template == "harvard"){ + var options:any ={ // Subsequent calls + format: 'string', + type: 'string', + style: 'citation-harvard1' + } + return options; + }else if(template == "chicago"){ + var options:any ={ // Subsequent calls + format: 'string', + type: 'string', + style: 'citation-chicago', + template:this.chicago_csl + } + return options; + }else if(template == "ieee"){ + var options:any ={ // Subsequent calls + format: 'string', + type: 'string', + style: 'citation-ieee', + template:this.ieee_csl + } + return options; + }else if(template == "science"){ + var options:any ={ // Subsequent calls + format: 'string', + type: 'string', + style: 'citation-science', + template:this.science_csl + } + return options; + }else if(template == "cell"){ + var options:any ={ // Subsequent calls + format: 'string', + type: 'string', + style: 'citation-cell', + template:this.cell_csl + } + return options; + }else if(template == "mla"){ + var options:any ={ // Subsequent calls + format: 'string', + type: 'string', + style: 'citation-mla', + template:this.mla_csl + } + return options; + }else if(template == "nature"){ + var options:any ={ // Subsequent calls + format: 'string', + type: 'string', + style: 'citation-nature', + template:this.nature_csl + } + return options; + }else if(template == "acm"){ + var options:any ={ // Subsequent calls + format: 'string', + type: 'string', + style: 'citation-acm', + template:this.acm_csl + } + return options; + } + + + } + +} +export class CitationData{ + public id:string; + public type:string; + public title:string; + public DOI:string; + public "container-title":string; + public publisher:string; + public author:{given:string, family:string, 'parse-names':boolean}[] =[]; + public issued:any[] =[];//{"date-parts":string[]}[] =[]; + public date:string; + public authors:string[] =[]; + +} diff --git a/workingUIKIT/src/app/landingPages/landing-utils/citeThis/citeThis.component.ts b/workingUIKIT/src/app/landingPages/landing-utils/citeThis/citeThis.component.ts new file mode 100644 index 00000000..299418a3 --- /dev/null +++ b/workingUIKIT/src/app/landingPages/landing-utils/citeThis/citeThis.component.ts @@ -0,0 +1,115 @@ +import {Component, ElementRef, Input} from '@angular/core'; +import {ActivatedRoute} from '@angular/router'; +import {Citation, CitationData} from './citation.class'; + +// +@Component({ + selector: 'citeThis', + template: ` + +
+
+
Cite this article
+
+ +
{{citationText}}
+
+
+
+ ` +}) +export class CiteThisComponent { + private sub:any; + public selectedStyle:string; + public citationText:string; + public citation:Citation = new Citation(); + public cite: any; + @Input() result: any; + @Input() id: string; + + public data;//= '[ { "id": "Q23571040", "type": "apple", "title": "Correlation of the Base Strengths of Amines 1", "DOI": "10.1021/ja01577a030", "author": [ { "given": "H. K.", "family": "Hall" } ], "issued": [ { "date-parts": [ "1957", "1", "1" ] } ], "container-title": "Journal of the American Chemical Society", "volume": "79", "issue": "20", "page": "5441-5444" } ]'; + + + constructor(private route: ActivatedRoute) { + this.selectedStyle = this.citation.templates[0]; + } + + ngOnInit() { + // this.Cite + // this.sub = this.route.queryParams.subscribe(data => { + this.parseData(); + var Cite = require('citation-js'); + this.cite = new Cite(this.data); + // this.cite.setData(this.data); + this.citationText = this.cite.get(this.citation.getOptionsBy(this.selectedStyle)); + // }); + } + parseData(){ + var citationData:CitationData = new CitationData(); + // try{ + + citationData.id = this.id; + if(this.result.types != undefined && this.result.types.length > 0 && this.result.types[0]){ + citationData.type = this.result.types[0].toLowerCase(); + }else if(this.result.type != undefined ){ + citationData.type = this.result.type.toLowerCase(); + } + if(this.result.title && this.result.title.name){ + citationData.title = this.result.title.name; + } + if(this.result.journal && this.result.journal.journal){ + citationData["container-title"] = this.result.journal.journal; + } + if(this.result.publisher){ + citationData.publisher = this.result.publisher; + } + if( this.result.authors){ + citationData.author = []; + for (var i =0 ;i < this.result.authors.length; i++){ + if(this.result.authors[i].name && this.result.authors[i].name.indexOf(", ") !== -1){ + citationData.author.push({given:this.result.authors[i].name.split(", ")[0], family:this.result.authors[i].name.split(", ")[1], 'parse-names':true}); + }else{ + citationData.author.push({given:"", family:this.result.authors[i].name, 'parse-names':true}); + } + citationData.authors.push(this.result.authors[i].name); + } + } + if(this.result.dateofacceptance != undefined){ + citationData.issued = []; + //[this.result.dateofacceptance.substring(0,4),this.result.dateofacceptance.substring(5,7),this.result.dateofacceptance.substring(8,10)] + citationData.issued.push({"date-parts":["2011","1","1"]}); + // + // // citationData.issued[0]["date-parts"].push(this.result.dateofacceptance.substring(0,4)); + // // citationData.issued[0]["date-parts"].push(this.result.dateofacceptance.substring(5,7)); + // if(this.result.dateofacceptance.substring(5,6)=="0"){ + // citationData.issued[0]["date-parts"][1] =(this.result.dateofacceptance.substring(6,7)); + // + // } + // // citationData.issued[0]["date-parts"].push(this.result.dateofacceptance.substring(8,10)); + // if(this.result.dateofacceptance.substring(8,9)=="0"){ + // citationData.issued[0]["date-parts"][2]=(this.result.dateofacceptance.substring(9,10)); + // + // } + citationData.date = this.result.dateofacceptance ; + console.log(citationData.issued[0]["date-parts"][0]+" "+citationData.issued[0]["date-parts"][1]+" "+citationData.issued[0]["date-parts"][2] + "--->"+ citationData.date) + } + + + // }catch (e) { + // console.log("Error parsing data for citeThis component"); + // console.log(e); + // + // citationData = new CitationData(); + // } + this.data = JSON.stringify([citationData]); + console.log(this.data); + + } + styleChanged(){ + this.citationText = this.cite.get(this.citation.getOptionsBy(this.selectedStyle)); + + } + +} diff --git a/workingUIKIT/src/app/landingPages/landing-utils/citeThis/citeThis.module.ts b/workingUIKIT/src/app/landingPages/landing-utils/citeThis/citeThis.module.ts new file mode 100644 index 00000000..4a14a36a --- /dev/null +++ b/workingUIKIT/src/app/landingPages/landing-utils/citeThis/citeThis.module.ts @@ -0,0 +1,23 @@ +import { NgModule} from '@angular/core'; +import { CommonModule } from '@angular/common'; +import { FormsModule } from '@angular/forms'; + + import {CiteThisComponent} from './citeThis.component'; + +@NgModule({ + imports: [ + + CommonModule, FormsModule + ], + declarations: [ + CiteThisComponent + ], + providers:[ + + ], + exports: [ + + CiteThisComponent + ] +}) +export class CiteThisModule { } diff --git a/workingUIKIT/src/app/landingPages/landing.module.ts b/workingUIKIT/src/app/landingPages/landing.module.ts new file mode 100644 index 00000000..98402228 --- /dev/null +++ b/workingUIKIT/src/app/landingPages/landing.module.ts @@ -0,0 +1,24 @@ +/* This module contains all common components for all landing pages */ + +import { NgModule} from '@angular/core'; +import { CommonModule } from '@angular/common'; +import { FormsModule } from '@angular/forms'; + +import {TabPagingComponent} from './tabPaging.component'; +import {ShowTitleComponent} from './showTitle.component'; +import {AddThisComponent} from './addThis.component'; +@NgModule({ + imports: [ + + CommonModule, FormsModule + ], + declarations: [ + TabPagingComponent, ShowTitleComponent, AddThisComponent + ], + providers:[ + ], + exports: [ + TabPagingComponent, ShowTitleComponent, AddThisComponent + ] +}) +export class LandingModule { } diff --git a/workingUIKIT/src/app/landingPages/metrics.component.ts b/workingUIKIT/src/app/landingPages/metrics.component.ts new file mode 100644 index 00000000..b3332a63 --- /dev/null +++ b/workingUIKIT/src/app/landingPages/metrics.component.ts @@ -0,0 +1,147 @@ +import {Component, Input, Output, EventEmitter} from '@angular/core'; +import {Metrics} from '../utils/entities/metrics'; +import {MetricsService } from '../services/metrics.service'; +import {ErrorCodes} from '../utils/properties/openaireProperties'; + +@Component({ + selector: 'metrics', + template: ` + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Total Views + Total Publication Views + Total Downloads + Total Publication Downloads +
+ {{metrics.totalViews}} + + ( {{metrics.totalOpenaireViews}} from OpenAIRE ) + + + {{metrics.totalDownloads}} + + ( {{metrics.totalOpenaireDownloads}} from OpenAIRE ) + +
+ + + + + + + + + + + + + + + + +
FromNumber Of ViewsNumber Of Downloads
+ + {{metrics.infos.get(key).name}} + + + {{metrics.infos.get(key).numOfViews}} + + ( {{metrics.infos.get(key).openaireViews}} from OpenAIRE ) + + + {{metrics.infos.get(key).numOfDownloads}} + + ( {{metrics.infos.get(key).openaireDownloads}} from OpenAIRE ) + +
+ ` + }) + +export class MetricsComponent { + @Output() metricsResults = new EventEmitter(); + @Input() id: string; + @Input() type: string; + @Input() name: string = ""; + public metrics: Metrics; + public errorCodes:ErrorCodes; + public status: number; + + constructor (private _metricsService: MetricsService) {} + + ngOnInit() { + this.errorCodes = new ErrorCodes(); + this.status = this.errorCodes.LOADING; + this.getMetrics(); + } + + + getMetrics() { + //if(this.id == undefined || this.id == "") { + // console.log("supplied id in metrics is not acceptable"); + //} + //if(this.type == undefined || this.type == "") { + // console.log("supplied id in metrics is not acceptable"); + //} + + this._metricsService.getMetrics(this.id, this.type).subscribe( + data => { + this.metrics = data; + this.status = this.errorCodes.DONE; + this.metricsResults.emit({ + totalViews: this.metrics.totalViews, + totalDownloads: this.metrics.totalDownloads, + pageViews: this.metrics.pageViews + }); + }, + err => { + console.log(err); + this.status = this.errorCodes.ERROR; + if(err.status == '404') { + this.status = this.errorCodes.NOT_AVAILABLE; + } + this.metricsResults.emit({ + totalViews: 0, + totalDownloads: 0 + }); + } + ); + } +} diff --git a/workingUIKIT/src/app/landingPages/metrics.module.ts b/workingUIKIT/src/app/landingPages/metrics.module.ts new file mode 100644 index 00000000..ccd0dcee --- /dev/null +++ b/workingUIKIT/src/app/landingPages/metrics.module.ts @@ -0,0 +1,26 @@ +/* This module contains all common components for all landing pages */ + +import { NgModule} from '@angular/core'; +import { CommonModule } from '@angular/common'; +import { FormsModule } from '@angular/forms'; + + import {MetricsComponent} from './metrics.component'; + import { MetricsService } from '../services/metrics.service'; + +@NgModule({ + imports: [ + + CommonModule, FormsModule + ], + declarations: [ + MetricsComponent + ], + providers:[ + MetricsService + ], + exports: [ + + MetricsComponent + ] +}) +export class MetricsModule { } diff --git a/workingUIKIT/src/app/landingPages/organization/organization-routing.module.ts b/workingUIKIT/src/app/landingPages/organization/organization-routing.module.ts new file mode 100644 index 00000000..aaf1fa89 --- /dev/null +++ b/workingUIKIT/src/app/landingPages/organization/organization-routing.module.ts @@ -0,0 +1,14 @@ +import { NgModule } from '@angular/core'; +import { RouterModule } from '@angular/router'; + +import { OrganizationComponent } from './organization.component'; +import {FreeGuard} from'../../login/freeGuard.guard'; + +@NgModule({ + imports: [ + RouterModule.forChild([ + { path: '', component: OrganizationComponent, canActivate: [FreeGuard] } + ]) +] +}) +export class OrganizationRoutingModule { } diff --git a/workingUIKIT/src/app/landingPages/organization/organization.component.html b/workingUIKIT/src/app/landingPages/organization/organization.component.html new file mode 100644 index 00000000..caf4cc96 --- /dev/null +++ b/workingUIKIT/src/app/landingPages/organization/organization.component.html @@ -0,0 +1,183 @@ +
+ + + + +
+
+ + + +
+
Name:
+
{{organizationInfo.name}}
+
Country:
+
{{organizationInfo.country}}
+
+ + + + +
+ +
+
    +
  • +
    +
    Share - Bookmark +
    +
    + +
    +
    +
  • + + +
  • + + + + Projects report(CSV) for {{funder.name}} + +
  • + +
  • + + + Publications report(CSV) for {{funder.name}} + +
  • +
    +
+
+
+ + +
diff --git a/workingUIKIT/src/app/landingPages/organization/organization.component.ts b/workingUIKIT/src/app/landingPages/organization/organization.component.ts new file mode 100644 index 00000000..87885498 --- /dev/null +++ b/workingUIKIT/src/app/landingPages/organization/organization.component.ts @@ -0,0 +1,377 @@ +import {Component, ViewChild, ElementRef} from '@angular/core'; +import {Observable} from 'rxjs/Observable'; +import {ActivatedRoute} from '@angular/router'; + +import {OrganizationService} from '../../services/organization.service'; +import {OrganizationInfo} from '../../utils/entities/organizationInfo'; +import {ReportsService} from '../../services/reports.service'; +import {FetchDataproviders} from '../../utils/fetchEntitiesClasses/fetchDataproviders.class'; +import {SearchPublicationsService} from '../../services/searchPublications.service'; +import {SearchDataprovidersService} from '../../services/searchDataproviders.service'; +import {SearchProjectsService} from '../../services/searchProjects.service'; +import { Meta} from '../../../angular2-meta'; +import {OpenaireProperties} from '../../utils/properties/openaireProperties'; +import {SearchingProjectsTabComponent} from '../searchingProjectsInTab.component'; +import {RouterHelper} from '../../utils/routerHelper.class'; + +import {ModalLoading} from '../../utils/modal/loading.component'; +import {AlertModal} from '../../utils/modal/alert'; + +@Component({ + selector: 'organization', + templateUrl: 'organization.component.html', +}) + +export class OrganizationComponent { + + organizationInfo: OrganizationInfo; + //private metrics: string; + private organizationId: string; + private projectsNum: number = 0; + private fundersSet: Set; + private emptyFundersSet: boolean = true; + public warningMessage = ""; + public errorMessage = ""; + + public downloadURLAPI: string; + public csvProjectParamsHead: string; + public csvPublicationParamsHead: string; + public csvParamsTail: string; + + sub: any; + subDataproviders: any; + subDataprovidersCount: any; + + private fetchDataproviders : FetchDataproviders; + private linkToSearchDataproviders:string = ""; + @ViewChild (SearchingProjectsTabComponent) searchingProjectsTabComponent : SearchingProjectsTabComponent ; + private projectFunders:string[] = []; + + public routerHelper:RouterHelper = new RouterHelper(); + + @ViewChild (ModalLoading) loading : ModalLoading ; + @ViewChild(AlertModal) alertApplyAll; + + private funder: string; + private funderId: string; + private count: number; + + constructor (private element: ElementRef, + private _organizationService: OrganizationService, + private route: ActivatedRoute, + private _searchDataprovidersService: SearchDataprovidersService, + private _reportsService: ReportsService, + private _searchPublicationsService: SearchPublicationsService, + private _searchProjectsService: SearchProjectsService, private _meta: Meta) { + + this.fetchDataproviders = new FetchDataproviders(this._searchDataprovidersService); + } + + ngOnInit() { + console.info('organization init'); + this.sub = this.route.queryParams.subscribe(params => { + this.organizationInfo=null; + this.updateTitle("Organization"); + this.updateDescription("Organization, country, projects, search, repositories, open access"); + + this.organizationId = params['organizationId']; + console.info("Id is :"+this.organizationId); + + if(this.organizationId){ + this.getOrganizationInfo(); + }else{ + this.warningMessage="No valid organization id"; + } + + if (typeof document !== 'undefined') { + this.element.nativeElement.scrollIntoView(); + } + + this.csvParamsTail = '" and relorganizationid exact "'+this.organizationId+'" ))'; + + }); + + this.downloadURLAPI = OpenaireProperties.getCsvAPIURL(); + this.csvProjectParamsHead = 'format=csv&type=projects&page=0&query=( (oaftype exact project)and (funderid exact "'; + //this.csvPublicationParamsHead = 'format=csv-special&type=publications&page=0&query=((((oaftype exact result) and (resulttypeid exact publication)) and (funderid exact '; +/* + this.subDataprovidersCount = this.route.queryParams.subscribe(params => { + this._searchDataprovidersService.numOfDataproviders("organizations/"+this.organizationId+"/datasources/count").subscribe( + data => { + this.fetchDataproviders.searchUtils.totalResults = data; + console.info("this.fetchDataproviders.searchUtils.totalResults = "+this.fetchDataproviders.searchUtils.totalResults); + }, + err => { + console.log(err); + } + ); + }) +*/ + } + + + ngOnDestroy() { + this.sub.unsubscribe(); + if(this.subDataproviders != undefined) { + this.subDataproviders.unsubscribe(); + } + //this.subDataprovidersCount.unsubscribe(); + } + + private getOrganizationInfo () { + + this.warningMessage = ''; + this.errorMessage="" + + this._organizationService.getOrganizationInfo(this.organizationId).subscribe( + data => { + if(data == null) { + this.errorMessage = 'No organization found'; + } else { + this.organizationInfo = data; + this.updateTitle(this.organizationInfo.title.name); + this.updateDescription("Organization, country, projects, search, repositories, open access"+this.organizationInfo.title.name); + + this.fetchDataproviders.getNumForEntity("organization", this.organizationId); + + /*let projectsNum = 0; + + if(this.organizationInfo.projects != undefined) { + this.fundersSet = new Set(); + this.organizationInfo.projects.forEach(function (value, key, map) { + projectsNum += value.length; + this.fundersSet.add(key); + }.bind(this)); + } + + this.projectsNum = projectsNum;*/ + } + }, + err => { + console.log(err) + + this.errorMessage = 'No organization found'; + } + ); + } +/* + private getMetrics() { + console.info("getOrganizationMetrics: component"); + this._organizationService.getMetrics(this.organizationId).subscribe( + data => { + this.metrics = data; + }, + err => { + console.log(err); + } + ); + } +*/ + private handleClick(funder: string) { + if(this.emptyFundersSet) { + this.fundersSet.clear(); + this.emptyFundersSet = false; + } + + if(this.fundersSet.has(funder)) { + this.fundersSet.delete(funder); + + if(this.fundersSet.size == 0) { + this.organizationInfo.projects.forEach(function (value, key, map) { + this.fundersSet.add(key); + }.bind(this)); + this.emptyFundersSet = true; + } + console.info(funder+" funder deleted"); + } else { + this.fundersSet.add(funder); + console.info(funder+" funder added"); + } + } + + //private getProjectsData(key: string): any { + //return this.projectsData; + //} + + private searchDataproviders() { + this.fetchDataproviders.getResultsForEntity("organization", this.organizationId, 1, 10); + this.linkToSearchDataproviders = OpenaireProperties.getLinkToAdvancedSearchDataProviders();// + "?organization=" + this.organizationId + "&or=and";; + } + + private searchDataprovidersInit() { + if(this.subDataproviders == undefined && this.fetchDataproviders.searchUtils.totalResults > 0) { + this.subDataproviders = this.route.queryParams.subscribe(params => { + this.searchDataproviders(); + }); + } + } + + downloadfile(url:string){ + console.log("Downloading file: "+ url); + + this.openLoading(); + this.setMessageLoading("Downloading CSV file"); + + this._reportsService.downloadCSVFile(url).subscribe( + data => { + this.closeLoading(); + window.open(window.URL.createObjectURL(data)); + }, + error => console.log("Error downloading the file."), + () => console.log('Completed file download.')); + } + + downloadPublicationsFile(funder: string, funderId:string, count:number){ + console.log("Downloading publications file"); + + this.openLoading(); + this.setMessageLoading("Downloading CSV file"); + + let response: string[] = []; + let totalResponse: string = ""; + let projects = []; + let counter: number = count; + let title: boolean = false; + this._searchProjectsService.getProjectsForOrganizations(this.organizationId,' and (funderid exact '+ funderId + ' ) ',1,count,[]).subscribe( + data => + { + projects = data[1]; + for(let index=0; index < projects.length; index++) { + this._searchPublicationsService.numOfEntityPublications(projects[index].id, "projects/").subscribe( + data => + { + // let index: number = this.organizationInfo.projects.get(funder).indexOf(project); + + let url: string; + if(index == 0 || !title) { + url = this.downloadURLAPI+"projects/"+projects[index].id+"/publications?format=csv-special&size="+data; + } else { + url = this.downloadURLAPI+"projects/"+projects[index].id+"/publications?format=csv-special-notitle&size="+data; + } + + if(data == 0) { + counter--; + response[index] = ""; + if(counter == 0) { + for(let i=0; i + { + counter--; + + response[index] = data; + + if(counter == 0) { + for(let i=0; i console.log("Error downloading the file."), + () => console.log('Completed file download.') + ); + } + }, + error => console.log("Error getting number of publications for project.")); + }//); + + }, + error => console.log("Error getting projects project.")); + + // let counter: number = this.organizationInfo.projects.get(funder).length; + // + // for(let project of this.organizationInfo.projects.get(funder)) { + // this._searchPublicationsService.numOfEntityPublications(project.id, "projects/").subscribe( + // data => + // { + // let index: number = this.organizationInfo.projects.get(funder).indexOf(project); + // + // let url: string; + // if(index == 0) { + // url = this.downloadURLAPI+"projects/"+project.id+"/publications?format=csv-special&size="+data; + // } else { + // url = this.downloadURLAPI+"projects/"+project.id+"/publications?format=csv-special-notitle&size="+data; + // } + // + // this._reportsService.getCSVResponse(url).subscribe( + // data => + // { + // counter--; + // + // response[index] = data; + // + // if(counter == 0) { + // for(let i=0; i console.log("Error downloading the file."), + // () => console.log('Completed file download.')); + // }, + // error => console.log("Error getting number of publications for project.")); + // }//); + } + updateDescription(description:string){ + this._meta.updateMeta("description", description); + this._meta.updateMeta("og:description", description); + } + updateTitle(title:string){ + var _suffix ="| OpenAIRE"; + var _title = ((title.length> 50 ) ?title.substring(0,50):title) + _suffix; + this._meta.setTitle(_title ); + this._meta.updateMeta("og:title",_title); + } + + public openLoading(){ + if(this.loading){ + this.loading.open(); + } + } + public closeLoading(){ + if(this.loading){ + this.loading.close(); + } + } + public setMessageLoading(message: string){ + if(this.loading){ + this.loading.message = message; + } + } + + confirmOpen(funder: string, funderId:string, count:number){ + this.alertApplyAll.cancelButton = true; + this.alertApplyAll.okButton = true; + this.alertApplyAll.alertTitle = "CSV FILE"; + this.alertApplyAll.message = "Do you wish to download a CSV file?\nNote that this process may take a while."; + this.alertApplyAll.okButtonText = "Yes"; + this.alertApplyAll.cancelButtonText = "No"; + this.alertApplyAll.open(); + + this.funder = funder; + this.funderId = funderId; + this.count = count; + } + confirmClose(data){ + this.downloadPublicationsFile(this.funder, this.funderId, this.count); + } +} diff --git a/workingUIKIT/src/app/landingPages/organization/organization.module.ts b/workingUIKIT/src/app/landingPages/organization/organization.module.ts new file mode 100644 index 00000000..d7f4a2a8 --- /dev/null +++ b/workingUIKIT/src/app/landingPages/organization/organization.module.ts @@ -0,0 +1,50 @@ +import { NgModule} from '@angular/core'; +import { CommonModule } from '@angular/common'; +import { FormsModule } from '@angular/forms'; +import { RouterModule } from '@angular/router'; + +import {LoadingModalModule} from '../../utils/modal/loadingModal.module'; +import {AlertModalModule} from '../../utils/modal/alertModal.module'; + +import { OrganizationServiceModule} from '../../services/organizationService.module'; +// import { ProjectsServiceModule} from '../../services/projectsService.module'; +import { OrganizationComponent } from './organization.component'; +import { OrganizationRoutingModule } from './organization-routing.module'; + +import { LandingModule } from '../landing.module'; +import {TabResultModule } from '../../searchPages/searchUtils/tabResult.module'; +import {DataProvidersServiceModule} from '../../services/dataProvidersService.module'; +import {ReportsServiceModule} from '../../services/reportsService.module'; +import {PublicationsServiceModule} from '../../services/publicationsService.module'; +import {ProjectsServiceModule} from '../../services/projectsService.module'; + +import { SearchingProjectsTabModule} from '../searchingProjectsInTab.module'; +import {FreeGuard} from'../../login/freeGuard.guard'; + +@NgModule({ + imports: [ + CommonModule, FormsModule, RouterModule, + LoadingModalModule, AlertModalModule, + LandingModule, + OrganizationRoutingModule, + TabResultModule, + DataProvidersServiceModule, + ReportsServiceModule, + OrganizationServiceModule, + SearchingProjectsTabModule, + OrganizationServiceModule, + PublicationsServiceModule, + ProjectsServiceModule + + ], + declarations: [ + OrganizationComponent, + ], + providers:[ + FreeGuard + ], + exports: [ + OrganizationComponent + ] +}) +export class OrganizationModule { } diff --git a/workingUIKIT/src/app/landingPages/person/person-routing.module.ts b/workingUIKIT/src/app/landingPages/person/person-routing.module.ts new file mode 100644 index 00000000..224f2c86 --- /dev/null +++ b/workingUIKIT/src/app/landingPages/person/person-routing.module.ts @@ -0,0 +1,14 @@ +import { NgModule } from '@angular/core'; +import { RouterModule } from '@angular/router'; + +import { PersonComponent } from './person.component'; +import {FreeGuard} from'../../login/freeGuard.guard'; + +@NgModule({ + imports: [ + RouterModule.forChild([ + { path: '', component: PersonComponent, canActivate: [FreeGuard] } + ]) +] +}) +export class PersonRoutingModule { } diff --git a/workingUIKIT/src/app/landingPages/person/person.component.html b/workingUIKIT/src/app/landingPages/person/person.component.html new file mode 100644 index 00000000..09a55295 --- /dev/null +++ b/workingUIKIT/src/app/landingPages/person/person.component.html @@ -0,0 +1,93 @@ +
+ + + +
+
+

{{personInfo.fullname}}

+ +
+
Last name:
+
{{personInfo.secondnames}}
+
First name:
+
{{personInfo.firstname}}
+
Country:
+
{{personInfo.country}}
+
+ + + + +
+ +
+
    +
  • +
    +
    Share - Bookmark +
    +
    + +
    +
    +
  • +
+
+
+
diff --git a/workingUIKIT/src/app/landingPages/person/person.component.ts b/workingUIKIT/src/app/landingPages/person/person.component.ts new file mode 100644 index 00000000..e9cdfc4c --- /dev/null +++ b/workingUIKIT/src/app/landingPages/person/person.component.ts @@ -0,0 +1,161 @@ + import {Component, ElementRef} from '@angular/core'; +import {Observable} from 'rxjs/Observable'; +import { ActivatedRoute, Route} from '@angular/router'; +import {PersonService} from './person.service'; +import { PersonInfo } from '../../utils/entities/personInfo'; + +import { FetchPublications } from '../../utils/fetchEntitiesClasses/fetchPublications.class'; +import { SearchPublicationsService } from '../../services/searchPublications.service'; +import { FetchDatasets } from '../../utils/fetchEntitiesClasses/fetchDatasets.class'; +import { SearchDatasetsService } from '../../services/searchDatasets.service'; + +import {OpenaireProperties} from '../../utils/properties/openaireProperties'; +import { Meta} from '../../../angular2-meta'; + +@Component({ + selector: 'person', + templateUrl: 'person.component.html', +}) + +export class PersonComponent { + sub: any; + subPublications: any; + subDatasets: any; + subDatasetsCount: any; + + public fetchPublications : FetchPublications; + private linkToSearchPublications = ""; + public fetchDatasets : FetchDatasets; + private linkToSearchDatasets = ""; + + personInfo: PersonInfo; + private personId: string; + public warningMessage = ""; + public errorMessage = ""; + public showTabs = false; + + constructor (private element: ElementRef, + private _personService: PersonService, + private route: ActivatedRoute, + private _searchPublicationsService: SearchPublicationsService, + private _searchDatasetsService: SearchDatasetsService, private _meta: Meta) { + + this.fetchPublications = new FetchPublications( this._searchPublicationsService); + this.fetchDatasets = new FetchDatasets( this._searchDatasetsService); + // this.scrollUp = this._route.events.subscribe((path) => { + // element.nativeElement.scrollIntoView(); + // }); + } + + ngOnInit() { + console.info('person init'); + this.sub = this.route.queryParams.subscribe(params => { + if (typeof document !== 'undefined') { + this.element.nativeElement.scrollIntoView(); + } + + this.personInfo = null; + this.updateTitle("Person"); + this.updateDescription("person, publication, research data, search, open access"); + + this.personId = params['personId']; + console.info("Id is :"+this.personId); + + if(this.personId){ + + this.showTabs = false; + this.fetchPersonInfo(); + this.showTabs = true; + this.searchPublications(); + + }else{ + this.warningMessage="No valid person id"; + } + + if (typeof document !== 'undefined') { + this.element.nativeElement.scrollIntoView(); + } + }); + + + /*this.subDatasetsCount = this.route.queryParams.subscribe(params => { + this._searchDatasetsService.numOfEntityDatasets(this.personId, "people/").subscribe( + data => { + this.fetchDatasets.searchUtils.totalResults = data; + }, + err => { + console.log(err); + } + ); + })*/ + } + + private searchDatasetsInit() { + if(this.subDatasets == undefined && this.fetchDatasets.searchUtils.totalResults > 0) { + this.subDatasets = this.route.queryParams.subscribe(params => { + this.searchDatasets(); + }); + } + } + + ngOnDestroy() { + this.sub.unsubscribe(); + // this.subPublications.unsubscribe(); + // if(this.subDatasets != undefined) { + // this.subDatasets.unsubscribe(); + // } + // this.subDatasetsCount.unsubscribe(); + } + + + private fetchPersonInfo () { + console.info("inside fetchPersonInfo of component"); + + this.warningMessage = ''; + this.errorMessage="" + + this._personService.getPersonInfo(this.personId).subscribe( + data => { + this.personInfo = data; + this.updateTitle(this.personInfo.fullname); + this.updateDescription("person, publication, research data, search, open access, "+this.personInfo.fullname); + + this._searchDatasetsService.numOfEntityDatasets(this.personId, "people/").subscribe( + data => { + this.fetchDatasets.searchUtils.totalResults = data; + }, + err => { + console.log(err); + } + ); + }, + err => { + + console.log(err) + console.info("error"); + + this.errorMessage = 'No person found'; + } + ); + } + + private searchPublications() { + this.fetchPublications.getResultsForEntity("person", this.personId, 1, 10); + this.linkToSearchPublications = OpenaireProperties.getLinkToAdvancedSearchPublications();// + "?person=" + this.personId + "&pe=and"; + } + + private searchDatasets() { + this.fetchDatasets.getResultsForEntity("person", this.personId, 1, 10); + this.linkToSearchDatasets = OpenaireProperties.getLinkToAdvancedSearchDatasets();// + "?person=" + this.personId + "&pe=and"; + } + updateDescription(description:string){ + this._meta.updateMeta("description", description); + this._meta.updateMeta("og:description", description); + } + updateTitle(title:string){ + var _suffix ="| OpenAIRE"; + var _title = ((title.length> 50 ) ?title.substring(0,50):title) + _suffix; + this._meta.setTitle(_title ); + this._meta.updateMeta("og:title",_title); + } +} diff --git a/workingUIKIT/src/app/landingPages/person/person.module.ts b/workingUIKIT/src/app/landingPages/person/person.module.ts new file mode 100644 index 00000000..8fd98ecc --- /dev/null +++ b/workingUIKIT/src/app/landingPages/person/person.module.ts @@ -0,0 +1,34 @@ +import { NgModule} from '@angular/core'; +import { CommonModule } from '@angular/common'; +import { FormsModule } from '@angular/forms'; +import { RouterModule } from '@angular/router'; + +import { PersonService} from './person.service'; +import { PersonComponent } from './person.component'; +import { PersonRoutingModule } from './person-routing.module'; + +import { LandingModule } from '../landing.module'; +import {TabResultModule } from '../../searchPages/searchUtils/tabResult.module'; +import {DatasetsServiceModule} from '../../services/datasetsService.module'; +import {PublicationsServiceModule} from '../../services/publicationsService.module'; +import {FreeGuard} from'../../login/freeGuard.guard'; + +@NgModule({ + imports: [ + CommonModule, FormsModule, RouterModule, + LandingModule, + PersonRoutingModule, + TabResultModule, + DatasetsServiceModule, PublicationsServiceModule + ], + declarations: [ + PersonComponent + ], + providers:[ + PersonService, FreeGuard + ], + exports: [ + PersonComponent + ] +}) +export class PersonModule { } diff --git a/workingUIKIT/src/app/landingPages/person/person.service.ts b/workingUIKIT/src/app/landingPages/person/person.service.ts new file mode 100644 index 00000000..55a13a1d --- /dev/null +++ b/workingUIKIT/src/app/landingPages/person/person.service.ts @@ -0,0 +1,80 @@ +import {Injectable} from '@angular/core'; +import {Http, Response} from '@angular/http'; +import {Observable} from 'rxjs/Observable'; +import 'rxjs/add/observable/of'; +import 'rxjs/add/operator/do'; +import 'rxjs/add/operator/share'; + +import { CacheService } from '../../shared/cache.service'; +import {PersonInfo} from '../../utils/entities/personInfo'; +import {OpenaireProperties} from '../../utils/properties/openaireProperties' + +export function hashCodeString(str: string): string { + let hash = 0; + if (str.length === 0) { + return hash + ''; + } + for (let i = 0; i < str.length; i++) { + let char = str.charCodeAt(i); + hash = ((hash << 5) - hash) + char; + hash = hash & hash; // Convert to 32bit integer + } + return hash + ''; +} + +@Injectable() +export class PersonService { + + constructor(private http: Http, public _cache: CacheService) {} + + personInfo: PersonInfo; + + getPersonInfo (id: string):any { + + console.info("getPersonInfo in service"); + + let url = OpenaireProperties. getSearchAPIURLLast()+'people/'+id+"?format=json"; + let key = url; + if (this._cache.has(key)) { + return Observable.of(this._cache.get(key)).map(res => this.parsePersonInfo(res)); + } + return this.http.get(url) + .map(res => res.json()) + .map(res => res['result']['metadata']['oaf:entity']['oaf:person']) + .do(res => { + this._cache.set(key, res); + }) + .map(res => this.parsePersonInfo(res)); + + + + } + + private handleError (error: Response) { + // 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'); + } + + parsePersonInfo (data: any):any { + console.info("parsePersonInfo"); + this.personInfo = new PersonInfo(); + + if(data != null) { + if(data.hasOwnProperty('firstname')) { + this.personInfo.firstname = data.firstname; + } + if(data.hasOwnProperty('secondnames')) { + this.personInfo.secondnames = data.secondnames; + } + if(data.hasOwnProperty('fullname')) { + this.personInfo.fullname = data.fullname; + } + } + + return this.personInfo; + + } + +} diff --git a/workingUIKIT/src/app/landingPages/project/project-routing.module.ts b/workingUIKIT/src/app/landingPages/project/project-routing.module.ts new file mode 100644 index 00000000..1a419d3f --- /dev/null +++ b/workingUIKIT/src/app/landingPages/project/project-routing.module.ts @@ -0,0 +1,13 @@ +import { NgModule } from '@angular/core'; +import { RouterModule } from '@angular/router'; + +import { ProjectComponent } from './project.component'; + +@NgModule({ + imports: [ + RouterModule.forChild([ + { path: '', component: ProjectComponent } + ]) +] +}) +export class ProjectRoutingModule { } diff --git a/workingUIKIT/src/app/landingPages/project/project.component.html b/workingUIKIT/src/app/landingPages/project/project.component.html new file mode 100644 index 00000000..12901d69 --- /dev/null +++ b/workingUIKIT/src/app/landingPages/project/project.component.html @@ -0,0 +1,244 @@ +
+ + + +
+
+ +
+

{{projectName}}

+

{{projectName}}

+
+ +
+
Title:
+
{{projectInfo.title}}
+
Funding:
+
{{projectInfo.funding}}
+
Call:
+
{{projectInfo.callIdentifier}}
+
Contract (GA) number:
+
{{projectInfo.contractNum}}
+
Start Date:
+
{{projectInfo.startDate}}
+
End Date:
+
{{projectInfo.endDate}}
+
Open Access mandate:
+
{{projectInfo.openAccessMandate}}
+
Special Clause 39:
+
{{projectInfo.specialClause39}}
+
Organizations:
+
+ + + + + {{organization.name}} + {{organization.name}}, + +
+
More information:
+
+ + + {{projectInfo.urlInfo}} + + +
+
+ + + + + +
+ +
+ +
+
+ +
diff --git a/workingUIKIT/src/app/landingPages/project/project.component.ts b/workingUIKIT/src/app/landingPages/project/project.component.ts new file mode 100644 index 00000000..d0237bb8 --- /dev/null +++ b/workingUIKIT/src/app/landingPages/project/project.component.ts @@ -0,0 +1,286 @@ +import {Component, ViewChild, ElementRef} from '@angular/core'; +import {Observable} from 'rxjs/Observable'; +import {ActivatedRoute, Params} from '@angular/router'; +import {ProjectService} from './project.service'; +import {ProjectInfo} from '../../utils/entities/projectInfo'; +import {RouterHelper} from '../../utils/routerHelper.class'; + +import { FetchPublications } from '../../utils/fetchEntitiesClasses/fetchPublications.class'; +import { SearchPublicationsService } from '../../services/searchPublications.service'; +import { FetchDatasets } from '../../utils/fetchEntitiesClasses/fetchDatasets.class'; +import { SearchDatasetsService } from '../../services/searchDatasets.service'; + +import {ModalLoading} from '../../utils/modal/loading.component'; + +import {ReportsService} from '../../services/reports.service'; +import {OpenaireProperties} from '../../utils/properties/openaireProperties'; +import { Meta} from '../../../angular2-meta'; + + +@Component({ + selector: 'project', + templateUrl: 'project.component.html', + }) +export class ProjectComponent{ + + public projectId : string ; + public projectInfo: ProjectInfo; + public projectName: string; + public metricsClicked: boolean; + public viewsFrameUrl: string; + public downloadsFrameUrl: string; + private totalViews: number; + private totalDownloads: number; + private pageViews: number; + public statsClicked: boolean; + public chartScientificResultsUrl: string; + public chartAccessModeUrl: string; + public chartDatasourcesUrl: string; + + public publications_dynamic: string; + public datasets_dynamic: string; + + public project ; + + public downloadURLAPI: string; + public csvParams: string; + + public warningMessage = ""; + public errorMessage = ""; + + sub: any; + subPublications: any; + subDatasets: any; + subDatasetsCount: any; + + public fetchPublications : FetchPublications; + public linkToSearchPublications = ""; + public fetchDatasets : FetchDatasets; + public linkToSearchDatasets = ""; + public routerHelper:RouterHelper = new RouterHelper(); + + @ViewChild (ModalLoading) loading : ModalLoading ; + + constructor ( private element: ElementRef, + private _projectService: ProjectService, + private route: ActivatedRoute, + private _searchPublicationsService: SearchPublicationsService, + private _searchDatasetsService: SearchDatasetsService, + private _reportsService: ReportsService, private _meta: Meta) { + console.info('project constructor.'); + } + + ngOnInit() { + this.sub = this.route.queryParams.subscribe(params => { + this.metricsClicked = false; + this.statsClicked = false; + + this.fetchPublications = new FetchPublications( this._searchPublicationsService); + this.fetchDatasets = new FetchDatasets(this._searchDatasetsService); + + this.updateTitle("Project"); + this.updateDescription("project, funding, open access, publications, datasets, "); + + this.projectId = params['projectId']; + console.info("Id is :"+this.projectId); + if(this.projectId){ + this.publications_dynamic = + ""; + + this.datasets_dynamic = + ""; + + this.getProjectInfo(this.projectId); + // this.subPublications = this.route.queryParams.subscribe(params => { + this.searchPublications(); + // }); + + this.subDatasetsCount = this._searchDatasetsService.numOfEntityDatasets(this.projectId, "projects/").subscribe( + data => { + this.fetchDatasets.searchUtils.totalResults = data; + }, + err => { + console.log(err); + }); + }else{ + this.warningMessage="No valid project id"; + } + + this.downloadURLAPI = OpenaireProperties.getCsvAPIURL(); + + this.createClipboard(); + this.csvParams = "format=csv-special&page=0&type=publications&query=(((oaftype exact result) and (resulttypeid exact publication)) and (relprojectid exact "+this.projectId+"))&size="; + + if (typeof document !== 'undefined') { + this.element.nativeElement.scrollIntoView(); + } + }); +} + + + ngOnDestroy() { + this.sub.unsubscribe(); + this.subDatasetsCount.unsubscribe(); + } + + createClipboard() { + if(typeof window !== 'undefined') { + + let publ_clipboard, datasets_clipboard; + let Clipboard; + Clipboard = require('clipboard'); + publ_clipboard = new Clipboard('.publ_clipboard_btn'); + datasets_clipboard = new Clipboard('.datasets_clipboard_btn'); + } + } + + private searchPublications() { + this.fetchPublications.getResultsForEntity("project", this.projectId, 1, 10); + this.linkToSearchPublications = OpenaireProperties.getLinkToAdvancedSearchPublications();// + "?project=" + this.projectId+"&pr=and"; + } + + private searchDatasets() { + this.fetchDatasets.getResultsForEntity("project", this.projectId, 1, 10); + this.linkToSearchDatasets = OpenaireProperties.getLinkToAdvancedSearchDatasets();// + "?project=" + this.projectId+"&pr=and"; + } + + private searchDatasetsInit() { + if(this.subDatasets == undefined && this.fetchDatasets.searchUtils.totalResults > 0) { + this.searchDatasets(); + } + } + + getProjectInfo (id:string) { + console.info("inside getProjectInfo of component"); + this.warningMessage = ''; + this.errorMessage="" + this._projectService.getProjectInfo(id).subscribe( + data => { + this.projectInfo = data; + this.projectName = this.projectInfo.acronym; + if(this.projectName == undefined || this.projectName == '') { + this.projectName = this.projectInfo.title; + } + this.updateTitle(this.projectName); + this.updateDescription("project, funding, open access, publications, datasets, "+this.projectName+ ","+this.projectInfo.funder); + this.project= { funderId: "", funderName: this.projectInfo.funder, projectId: this.projectId, projectName: this.projectInfo.title, projectAcronym: this.projectInfo.acronym, startDate: this.projectInfo.startDate, endDate: this.projectInfo.endDate }; + + this.viewsFrameUrl = OpenaireProperties.getFramesAPIURL()+'merge.php?com=query&data=[{"query":"projRepoViews","projTitle":"'+this.projectId+'","table":"","fields":[{"fld":"sum","agg":"sum","type":"column","yaxis":1,"c":false}],"xaxis":{"name":"month","agg":"sum"},"group":"","color":"","type":"chart","size":30,"sort":"xaxis","xStyle":{"r":-30,"s":"0","l":"-","ft":"-","wt":"-"},"title":"","subtitle":"","xaxistitle":"","yaxisheaders":["Monthly views"],"generalxaxis":"","theme":0,"in":[]}]&info_types=["spline"]&stacking=&steps=false&fontFamily=Courier&spacing=[5,0,0,0]&style=[{"color":"rgba(0, 0, 0, 1)","size":"18"},{"color":"rgba(0, 0, 0, 1)","size":"18"},{"color":"000000","size":""},{"color":"000000","size":""}]&backgroundColor=rgba(255,255,255,1)&colors[]=rgba(124, 181, 236, 1)&colors[]=rgba(67, 67, 72, 1)&colors[]=rgba(144, 237, 125, 1)&colors[]=rgba(247, 163, 92, 1)&colors[]=rgba(128, 133, 233, 1)&colors[]=rgba(241, 92, 128, 1)&colors[]=rgba(228, 211, 84, 1)&colors[]=rgba(43, 144, 143, 1)&colors[]=rgba(244, 91, 91, 1)&colors[]=rgba(145, 232, 225, 1)&xlinew=0&ylinew=1&legends=true&tooltips=true&persistent=false'; + /*this.viewsFrameUrl = OpenaireProperties.getFramesAPIURL()+'merge.php?com=query&data=[{"query":"projViewsTimeline","projTitle":"'+this.projectId+'","table":"","fields":[{"fld":"sum","agg":"sum","type":"column","yaxis":1,"c":false}],"xaxis":{"name":"month","agg":"sum"},"group":"","color":"","type":"chart","size":30,"sort":"xaxis","xStyle":{"r":-30,"s":"0","l":"-","ft":"-","wt":"-"},"title":"","subtitle":"","xaxistitle":"","yaxisheaders":["Monthly views"],"generalxaxis":"","theme":0,"in":[]}]&info_types=["spline"]&stacking=&steps=false&fontFamily=Courier&spacing=[5,0,0,0]&style=[{"color":"rgba(0, 0, 0, 1)","size":"18"},{"color":"rgba(0, 0, 0, 1)","size":"18"},{"color":"000000","size":""},{"color":"000000","size":""}]&backgroundColor=rgba(255,255,255,1)&colors[]=rgba(124, 181, 236, 1)&colors[]=rgba(67, 67, 72, 1)&colors[]=rgba(144, 237, 125, 1)&colors[]=rgba(247, 163, 92, 1)&colors[]=rgba(128, 133, 233, 1)&colors[]=rgba(241, 92, 128, 1)&colors[]=rgba(228, 211, 84, 1)&colors[]=rgba(43, 144, 143, 1)&colors[]=rgba(244, 91, 91, 1)&colors[]=rgba(145, 232, 225, 1)&xlinew=0&ylinew=1&legends=true&tooltips=true'; + */ + + this.downloadsFrameUrl = OpenaireProperties.getFramesAPIURL()+'merge.php?com=query&data=[{"query":"projRepoDownloads","projTitle":"'+this.projectId+'","table":"","fields":[{"fld":"sum","agg":"sum","type":"column","yaxis":1,"c":false}],"xaxis":{"name":"month","agg":"sum"},"group":"","color":"","type":"chart","size":30,"sort":"xaxis","xStyle":{"r":-30,"s":"0","l":"-","ft":"-","wt":"-"},"title":"","subtitle":"","xaxistitle":"","yaxisheaders":["Monthly downloads"],"generalxaxis":"","theme":0,"in":[]}]&info_types=["spline"]&stacking=&steps=false&fontFamily=Courier&spacing=[5,0,0,0]&style=[{"color":"rgba(0, 0, 0, 1)","size":"18"},{"color":"rgba(0, 0, 0, 1)","size":"18"},{"color":"000000","size":""},{"color":"000000","size":""}]&backgroundColor=rgba(255,255,255,1)&colors[]=rgba(124, 181, 236, 1)&colors[]=rgba(67, 67, 72, 1)&colors[]=rgba(144, 237, 125, 1)&colors[]=rgba(247, 163, 92, 1)&colors[]=rgba(128, 133, 233, 1)&colors[]=rgba(241, 92, 128, 1)&colors[]=rgba(228, 211, 84, 1)&colors[]=rgba(43, 144, 143, 1)&colors[]=rgba(244, 91, 91, 1)&colors[]=rgba(145, 232, 225, 1)&xlinew=0&ylinew=1&legends=true&tooltips=true&persistent=false'; + /* + this.downloadsFrameUrl = OpenaireProperties.getFramesAPIURL()+'merge.php?com=query&data=[{"query":"projDownloadsTimeline","projTitle":"'+this.projectId+'","table":"","fields":[{"fld":"sum","agg":"sum","type":"column","yaxis":1,"c":false}],"xaxis":{"name":"month","agg":"sum"},"group":"","color":"","type":"chart","size":30,"sort":"xaxis","xStyle":{"r":-30,"s":"0","l":"-","ft":"-","wt":"-"},"title":"","subtitle":"","xaxistitle":"","yaxisheaders":["Monthly downloads"],"generalxaxis":"","theme":0,"in":[]}]&info_types=["spline"]&stacking=&steps=false&fontFamily=Courier&spacing=[5,0,0,0]&style=[{"color":"rgba(0, 0, 0, 1)","size":"18"},{"color":"rgba(0, 0, 0, 1)","size":"18"},{"color":"000000","size":""},{"color":"000000","size":""}]&backgroundColor=rgba(255,255,255,1)&colors[]=rgba(124, 181, 236, 1)&colors[]=rgba(67, 67, 72, 1)&colors[]=rgba(144, 237, 125, 1)&colors[]=rgba(247, 163, 92, 1)&colors[]=rgba(128, 133, 233, 1)&colors[]=rgba(241, 92, 128, 1)&colors[]=rgba(228, 211, 84, 1)&colors[]=rgba(43, 144, 143, 1)&colors[]=rgba(244, 91, 91, 1)&colors[]=rgba(145, 232, 225, 1)&xlinew=0&ylinew=1&legends=true&tooltips=true'; + */ + + //stats tab charts + this.chartScientificResultsUrl='https://beta.openaire.eu/stats/chart.php?com=query&persistent=false&data={"query":"projScient","projTitle":"'+this.projectId+'", "table": "result", "fields": [{"fld": "number", "agg": "count", "type": "spline", "yaxis":1, "c":false}], "xaxis":{"name": "result_classifications-type", "agg": "avg"}, "group": "", "color": "", "type": "chart", "size":30, "sort": "xaxis", "xStyle":{"r": "-", "s": "-", "l": "-", "ft": "-", "wt": "-"}, "yaxisheaders": [""], "fieldsheaders": ["Publications"], "in": [], "filters": [{"name": "result_datasources-datasource-name", "values": [" "], "to": "-1"}], "having": [], "incfilters": [], "inchaving": [], "title": "", "subtitle": "", "xaxistitle": ""}&w=600&h=250'; + this.chartAccessModeUrl='https://beta.openaire.eu/stats/chart.php?com=query&persistent=false&data={"query":"projOA","projTitle":"'+this.projectId+'", "table": "result", "fields": [{"fld": "number", "agg": "count", "type": "pie", "yaxis":1, "c":false}], "xaxis":{"name": "result_classifications-type", "agg": "avg"}, "group": "", "color": "", "type": "chart", "size":30, "sort": "xaxis", "xStyle":{"r": "-", "s": "-", "l": "-", "ft": "-", "wt": "-"}, "yaxisheaders": [""], "fieldsheaders": ["Publications"], "in": [], "filters": [{"name": "result_datasources-datasource-name", "values": [" "], "to": "-1"}], "having": [], "incfilters": [], "inchaving": [], "title": "", "subtitle": "", "xaxistitle": ""}&w=600&h=250'; + this.chartDatasourcesUrl= 'https://beta.openaire.eu/stats/chart.php?com=query&persistent=false&data={"query":"projPubsRepos","projTitle":"'+this.projectId+'", "table": "result", "fields": [{"fld": "number", "agg": "count", "type": "column", "yaxis":1, "c":false}], "xaxis":{"name": "result_classifications-type", "agg": "avg"}, "group": "", "color": "", "type": "chart", "size":30, "sort": "xaxis", "xStyle":{"r": "-", "s": "-", "l": "-", "ft": "-", "wt": "-"}, "yaxisheaders": [""], "fieldsheaders": ["Publications"], "in": [], "filters": [{"name": "result_datasources-datasource-name", "values": [" "], "to": "-1"}], "having": [], "incfilters": [], "inchaving": [], "title": "", "subtitle": "", "xaxistitle": ""}&w=600&h=250'; + }, + err => { + console.log(err); + this.errorMessage = 'No project found'; + } + ); + } + downloadfile(url:string){ + console.log("Downloading file: "+ url); + + this.openLoading(); + this.setMessageLoading("Downloading CSV file"); + + this._reportsService.downloadCSVFile(url).subscribe( + data => { + this.closeLoading(); + window.open(window.URL.createObjectURL(data)); + }, + error => console.log("Error downloading the file."), + () => console.log('Completed file download.') + ); + } + + showHTML(){ + let info:string = "

Publications of Project "; + + if(this.projectInfo.title != undefined && this.projectInfo.title != "") { + info += this.projectInfo.title; + } + if((this.projectInfo.title != undefined && this.projectInfo.title != "") && + ((this.projectInfo.acronym != undefined && this.projectInfo.acronym != "") || + (this.projectInfo.callIdentifier != undefined && this.projectInfo.callIdentifier != ""))) { + info += "("; + } + if(this.projectInfo.acronym != undefined && this.projectInfo.acronym != "") { + info += this.projectInfo.acronym + " - "; + } + if(this.projectInfo.callIdentifier != undefined && this.projectInfo.callIdentifier != "") { + info += this.projectInfo.callIdentifier; + } + if((this.projectInfo.title != undefined && this.projectInfo.title != "") && + ((this.projectInfo.acronym != undefined && this.projectInfo.acronym != "") || + (this.projectInfo.callIdentifier != undefined && this.projectInfo.callIdentifier != ""))) { + info += ")"; + } + info +="

"; + info += "

"+this.fetchPublications.searchUtils.totalResults+" publications

"; + + let htmlParams = 'resources?format=html&page=0&size='+this.fetchPublications.searchUtils.totalResults+'&type=publications&query=(((oaftype exact result) and (resulttypeid exact publication)) and (relprojectid exact "'+this.projectId+'"))'; + this._reportsService.downloadHTMLFile(this.downloadURLAPI+htmlParams, info) + .subscribe(data => this.funct(data), + error => console.log("Error downloading the file."), + () => console.log('Completed file download.')); + } + funct(data) { + var win = window.open(window.URL.createObjectURL(data)); + } + + public metricsResults($event) { + this.totalViews = $event.totalViews; + this.totalDownloads = $event.totalDownloads; + this.pageViews = $event.pageViews; + } + updateDescription(description:string){ + this._meta.updateMeta("description", description); + this._meta.updateMeta("og:description", description); + } + updateTitle(title:string){ + var _suffix ="| OpenAIRE"; + var _title = ((title.length> 50 ) ?title.substring(0,50):title) + _suffix; + this._meta.setTitle(_title ); + this._meta.updateMeta("og:title",_title); + } + + + public openLoading(){ + if(this.loading){ + this.loading.open(); + } + } + public closeLoading(){ + if(this.loading){ + this.loading.close(); + } + } + public setMessageLoading(message: string){ + if(this.loading){ + this.loading.message = message; + } + } + +} diff --git a/workingUIKIT/src/app/landingPages/project/project.module.ts b/workingUIKIT/src/app/landingPages/project/project.module.ts new file mode 100644 index 00000000..cbbea93e --- /dev/null +++ b/workingUIKIT/src/app/landingPages/project/project.module.ts @@ -0,0 +1,38 @@ +//import {MaterialModule} from '@angular/material'; +import { NgModule} from '@angular/core'; +import { CommonModule } from '@angular/common'; +import { FormsModule } from '@angular/forms'; +import { RouterModule } from '@angular/router'; + +import { ProjectServiceModule} from './projectService.module'; +// import {HtmlProgressReportService} from './htmlProgressReport.service'; +import{LoadingModalModule} from '../../utils/modal/loadingModal.module'; + +import { ProjectComponent } from './project.component'; +import { ProjectRoutingModule } from './project-routing.module'; +import {IFrameModule} from '../../utils/iframe.module'; +import {MetricsModule} from '../metrics.module'; +import {ReportsServiceModule} from '../../services/reportsService.module'; +import {PublicationsServiceModule} from '../../services/publicationsService.module'; +import {DatasetsServiceModule} from '../../services/datasetsService.module'; +import {TabResultModule } from '../../searchPages/searchUtils/tabResult.module'; +import { LandingModule } from '../landing.module'; + +@NgModule({ + imports: [ + CommonModule, FormsModule, RouterModule, LandingModule, + ProjectRoutingModule, LoadingModalModule, + TabResultModule, IFrameModule, MetricsModule, ReportsServiceModule, PublicationsServiceModule, DatasetsServiceModule, ProjectServiceModule + ], + declarations: [ + ProjectComponent + ], + providers:[ + // ProjectService, + // HtmlProgressReportService + ], + exports: [ + ProjectComponent + ] +}) +export class ProjectModule { } diff --git a/workingUIKIT/src/app/landingPages/project/project.service.ts b/workingUIKIT/src/app/landingPages/project/project.service.ts new file mode 100644 index 00000000..1293f32e --- /dev/null +++ b/workingUIKIT/src/app/landingPages/project/project.service.ts @@ -0,0 +1,204 @@ +import {Injectable} from '@angular/core'; +import {Http, Response} from '@angular/http'; +import {Observable} from 'rxjs/Observable'; +import {ProjectInfo} from '../../utils/entities/projectInfo'; +import {OpenaireProperties} from '../../utils/properties/openaireProperties'; +import 'rxjs/add/observable/of'; +import 'rxjs/add/operator/do'; +import 'rxjs/add/operator/share'; +import { CacheService } from '../../shared/cache.service'; +@Injectable() +export class ProjectService { + + constructor(private http: Http, public _cache: CacheService) {} + + projectInfo: ProjectInfo; + + getProjectInfo (id: string):any { + console.info("getProjectInfo in service"); + + let url = OpenaireProperties. getSearchAPIURLLast() + 'projects/'+id+"?format=json"; + let key = url; + if (this._cache.has(key)) { + return Observable.of(this._cache.get(key)) + .map(res => this.parseProjectInfo(res)); + } + return this.http.get(url) + .map(res => res.json()) + .map(res => res['result']['metadata']['oaf:entity']['oaf:project']) + .map(res => [res, + res['fundingtree'], + res['rels']['rel']]) + .do(res => { + this._cache.set(key, res); + }) + .map(res => this.parseProjectInfo(res)); + + } + + /* + get project strtDate and endDate + */ + getProjectDates (id: string):any { + + let url = OpenaireProperties. getSearchAPIURLLast()+'projects/'+id+"?format=json"; + let key = url+'_projectDates'; + if (this._cache.has(key)) { + return Observable.of(this._cache.get(key)) + .map(res => [res, + res['fundingtree'], + res['rels']['rel']]) + .map(res => this.parseProjectDates(id,res)) + } + return this.http.get(url) + .map(res => res.json()) + .map(res => res['result']['metadata']['oaf:entity']['oaf:project']) + .do(res => { + this._cache.set(key, res); + }) + .map(res => [res, + res['fundingtree'], + res['rels']['rel']]) + .map(res => this.parseProjectDates(id,res)) + + } + + getHTMLInfo(id: string): any { + console.info("getHTMLInfo in service"); + + let url = OpenaireProperties. getSearchAPIURLLast() + 'projects/'+id+"?format=json"; + let key = url; + if (this._cache.has(key)) { + return Observable.of(this._cache.get(key)) + .map(res => this.parseHTMLInfo(res)); + } + return this.http.get(url) + .map(res => res.json()) + .map(res => res['result']['metadata']['oaf:entity']['oaf:project']) + .do(res => { + this._cache.set(key, res); + }) + .map(res => this.parseHTMLInfo(res)); + } + + private handleError (error: Response) { + // 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'); + } + + parseHTMLInfo (data: any):any { + let htmlInfo: {"title": string, "acronym": string, "callIdentifier": string}; + + if(data != null) { + htmlInfo = {"title": data.title, "acronym": data.acronym, "callIdentifier": data.callidentifier}; + } + console.info(htmlInfo); + return htmlInfo; + } + + parseProjectInfo (data: any):any { + this.projectInfo = new ProjectInfo(); + + if(data[0] != null) { + this.projectInfo.acronym = data[0].acronym; + if(Array.isArray(data[0]['title'])) { + this.projectInfo.title = data[0].title[0]; + } else { + this.projectInfo.title = data[0].title; + } + this.projectInfo.callIdentifier = data[0].callidentifier; + this.projectInfo.contractNum = data[0].code; + this.projectInfo.startDate = data[0].startdate; + this.projectInfo.endDate = data[0].enddate; + this.projectInfo.openAccessMandate = data[0].oamandatepublications; + this.projectInfo.specialClause39 = data[0].ecsc39; + } + if(data[1] != null) { + if(data[1]['funder'] != null) { + this.projectInfo.funder = data[1]['funder'].shortname; + } + + let funding; + this.projectInfo.funding = ""; + + if(data[1]['funding_level_2'] != null) { + funding = data[1]['funding_level_2'].id; + } else if(data[1]['funding_level_1'] != null) { + funding = data[1]['funding_level_1'].id; + } else if(data[1]['funding_level_0'] != null) { + funding = data[1]['funding_level_0'].id; + } + + if(funding != undefined) { + funding = funding.split("::"); + for(let i=1; i(); + + let name = ""; + let id = ""; + + if(!Array.isArray(data[2])) { + if(data[2].hasOwnProperty("legalshortname")) { + name = data[2].legalshortname; + } else if(data[2].hasOwnProperty("legalname")) { + name = data[2].legalname; + } + + if(data[2].hasOwnProperty("to") && name != "") { + id = /*OpenaireProperties.getsearchLinkToOrganization()+*/data[2]['to'].content; + } + if(name != "") { + this.projectInfo.organizations.push({"name": name, "id": id}); + } + } else { + for(let i=0; i + + + + + +
+
+ + + + + + + +
+ + ({{publicationInfo.date}}) +
+ +
+
Publisher:
+
{{publicationInfo.publisher}}
+
Journal:
+
+ {{publicationInfo.journal['journal']}} + + ( + + + issn: {{publicationInfo.journal['issn']}} + + + lissn: {{publicationInfo.journal['lissn']}} + + + ) + +
+
Languages:
+
{{publicationInfo.languages}}
+
Types:
+
{{publicationInfo.types}}
+
Embargo end date:
+
{{publicationInfo.embargoEndDate}}
+ + + + +
+ +
+
{{publicationInfo.description}}
+
+ + + + + +
    +
  • +
    + There are no references +
    + +
    + + + +
    + +

    + {{item['name']}} +

    +
    + +
    +
    + +

    + {{item['name']}} +

    +
    +
    + + + +
    +
  • + +
  • +
    + There are no related research results +
    +
    +
    +

    {{provenanceaction}}

    + + +
    +
    +
  • + + +
  • +
    + There are no similar research results +
    +
    + + +
    +
  • + +
  • +
    + There are no related organizations +
    +
    + + + + + + + + + + + + + + +
    OrganizationTrust
    + + {{organization['name']}} + ( + {{organization.shortname}} + ) + +

    + {{organization['name']}} + ( + {{organization.shortname}} + ) +

    +
    Website url: + {{organization.websiteUrl}} +
    +
    Country: {{organization.country}}
    +
    +
    +
    + {{organization['trust']}} +
    +
    +
    +

    no trust found

    +
    +
    + + +
    +
  • + +
  • + + + + + + + + + + + + + +
    Bio EntitySite Name
    + + + {{keyIn}} + + + + {{key}} +
    +
  • +
  • + + + + + + + + + + + + +
    Site Name
    + + + {{item.name}} + + +
    +
  • +
  • + + + + + + + +
  • +
+
+ +
+ +
+
+
+ + + diff --git a/workingUIKIT/src/app/landingPages/publication/publication.component.ts b/workingUIKIT/src/app/landingPages/publication/publication.component.ts new file mode 100644 index 00000000..3d0c933e --- /dev/null +++ b/workingUIKIT/src/app/landingPages/publication/publication.component.ts @@ -0,0 +1,208 @@ +import {Component, ViewChild, ElementRef} from '@angular/core'; +import {Observable} from 'rxjs/Observable'; +import {PublicationService} from './publication.service'; +import {PublicationInfo} from '../../utils/entities/publicationInfo'; +import {ActivatedRoute} from '@angular/router'; +import {OpenaireProperties} from '../../utils/properties/openaireProperties'; +import {RouterHelper} from '../../utils/routerHelper.class'; +import { Meta} from '../../../angular2-meta'; + + + +@Component({ + selector: 'publication', + templateUrl: 'publication.component.html', + +}) + +export class PublicationComponent { + + public showAllCollectedFrom: boolean = false; + public showAllDownloadFrom: boolean = false; + public showAllFundedBy: boolean = false; + public showAllPublishedIn: boolean = false; + + sub: any; + articleId: string; + public publicationInfo: PublicationInfo; + private metricsClicked: boolean; + private viewsFrameUrl: string; + private downloadsFrameUrl: string; + private totalViews: number; + private totalDownloads: number; + private pageViews: number; + + public showAllReferences: boolean = false; + public showAllRelResData: boolean = false; + public showAllSimilPubl: boolean = false; + public showAllBioentities: boolean = false; + public showFundingDetails: boolean = false; + + public bioentitiesNum: number = 0; + public relatedResearchResultsNum: number = 0; + + private doi: string; + + public result ; + + public warningMessage = ""; + public errorMessage = ""; + public routerHelper:RouterHelper = new RouterHelper(); + + constructor ( private element: ElementRef, + private _publicationService: PublicationService, + private route: ActivatedRoute, private _meta: Meta) { } + + ngOnInit() { + this.sub = this.route.queryParams.subscribe(data => { + this.publicationInfo = null; + this.updateTitle("Publication"); + this.updateDescription("Publication, open access, collected from"); + + this.articleId = data['articleId']; + console.info("Article id is :"+this.articleId); + + if(this.articleId){ + + this.getPublicationInfo(this.articleId); + // if (typeof document !== 'undefined') { + // switcher(UIkit); + // } + }else{ + this.warningMessage="No valid publication id"; + } + this.metricsClicked = false; + + this.viewsFrameUrl = OpenaireProperties.getFramesAPIURL()+'merge.php?com=query&data=[{"query":"resRepoViews", "resTitle":"'+this.articleId+'", "table":"","fields":[{"fld":"sum","agg":"sum","type":"column","yaxis":1,"c":false}],"xaxis":{"name":"month","agg":"sum"},"group":" ","color":"","type":"chart","size":30,"sort":"xaxis","xStyle":{"r":-30,"s":"0","l":"-","ft":"-","wt":"-"},"title":"","subtitle":"","xaxistitle":"Repository","yaxisheaders":["Monthly views"],"generalxaxis":"","theme":0,"in":[],"filters":[{"name":"","values":[""],"to":"-1"}]}]&info_types=["column"]&stacking=normal&steps=false&fontFamily=Courier&spacing=[5,0,0,0]&style=[{"color":"rgba(0, 0, 0, 1)","size":"18"},{"color":"rgba(0, 0, 0, 1)","size":"18"},{"color":"000000","size":""},{"color":"000000","size":""}]&backgroundColor=rgba(255,255,255,1)&colors[]=rgba(67, 67, 72, 1)&colors[]=rgba(144, 237, 125, 1)&colors[]=rgba(247, 163, 92, 1)&colors[]=rgba(128, 133, 233, 1)&colors[]=rgba(241, 92, 128, 1)&colors[]=rgba(228, 211, 84, 1)&colors[]=rgba(43, 144, 143, 1)&colors[]=rgba(244, 91, 91, 1)&colors[]=rgba(145, 232, 225, 1)&xlinew=0&ylinew=1&legends=true&tooltips=true&persistent=false'; + /*this.viewsFrameUrl = OpenaireProperties.getFramesAPIURL()+'merge.php?com=query&data=[{"query":"resViewsTimeline", "resTitle":"'+this.articleId+'", "table":"","fields":[{"fld":"sum","agg":"sum","type":"column","yaxis":1,"c":false}],"xaxis":{"name":"month","agg":"sum"},"group":" ","color":"","type":"chart","size":30,"sort":"xaxis","xStyle":{"r":-30,"s":"0","l":"-","ft":"-","wt":"-"},"title":"","subtitle":"","xaxistitle":"Repository","yaxisheaders":["Monthly views"],"generalxaxis":"","theme":0,"in":[],"filters":[{"name":"","values":[""],"to":"-1"}]}]&info_types=["column"]&stacking=normal&steps=false&fontFamily=Courier&spacing=[5,0,0,0]&style=[{"color":"rgba(0, 0, 0, 1)","size":"18"},{"color":"rgba(0, 0, 0, 1)","size":"18"},{"color":"000000","size":""},{"color":"000000","size":""}]&backgroundColor=rgba(255,255,255,1)&colors[]=rgba(124, 181, 236, 1)&colors[]=rgba(67, 67, 72, 1)&colors[]=rgba(144, 237, 125, 1)&colors[]=rgba(247, 163, 92, 1)&colors[]=rgba(128, 133, 233, 1)&colors[]=rgba(241, 92, 128, 1)&colors[]=rgba(228, 211, 84, 1)&colors[]=rgba(43, 144, 143, 1)&colors[]=rgba(244, 91, 91, 1)&colors[]=rgba(145, 232, 225, 1)&xlinew=0&ylinew=1&legends=true&tooltips=true&persistent=false'; + */ + + this.downloadsFrameUrl = OpenaireProperties.getFramesAPIURL()+'merge.php?com=query&data=[{"query":"resRepoDownloads", "resTitle":"'+this.articleId+'", "table":"","fields":[{"fld":"sum","agg":"sum","type":"column","yaxis":1,"c":false}],"xaxis":{"name":"month","agg":"sum"},"group":" ","color":"","type":"chart","size":30,"sort":"xaxis","xStyle":{"r":-30,"s":"0","l":"-","ft":"-","wt":"-"},"title":"","subtitle":"","xaxistitle":"Repository","yaxisheaders":["Monthly downloads"],"generalxaxis":"","theme":0,"in":[],"filters":[{"name":"","values":[""],"to":"-1"}]}]&info_types=["column"]&stacking=normal&steps=false&fontFamily=Courier&spacing=[5,0,0,0]&style=[{"color":"rgba(0, 0, 0, 1)","size":"18"},{"color":"rgba(0, 0, 0, 1)","size":"18"},{"color":"000000","size":""},{"color":"000000","size":""}]&backgroundColor=rgba(255,255,255,1)&colors[]=rgba(67, 67, 72, 1)&colors[]=rgba(144, 237, 125, 1)&colors[]=rgba(247, 163, 92, 1)&colors[]=rgba(128, 133, 233, 1)&colors[]=rgba(241, 92, 128, 1)&colors[]=rgba(228, 211, 84, 1)&colors[]=rgba(43, 144, 143, 1)&colors[]=rgba(244, 91, 91, 1)&colors[]=rgba(145, 232, 225, 1)&xlinew=0&ylinew=1&legends=true&tooltips=true&persistent=false'; + /*this.downloadsFrameUrl = OpenaireProperties.getFramesAPIURL()+'merge.php?com=query&data=[{"query":"resRepoDownloadTimeline", "resTitle":"'+this.articleId+'", "table":"","fields":[{"fld":"sum","agg":"sum","type":"column","yaxis":1,"c":false}],"xaxis":{"name":"month","agg":"sum"},"group":" ","color":"","type":"chart","size":30,"sort":"xaxis","xStyle":{"r":-30,"s":"0","l":"-","ft":"-","wt":"-"},"title":"","subtitle":"","xaxistitle":"Repository","yaxisheaders":["Monthly downloads"],"generalxaxis":"","theme":0,"in":[],"filters":[{"name":"","values":[""],"to":"-1"}]}]&info_types=["column"]&stacking=normal&steps=false&fontFamily=Courier&spacing=[5,0,0,0]&style=[{"color":"rgba(0, 0, 0, 1)","size":"18"},{"color":"rgba(0, 0, 0, 1)","size":"18"},{"color":"000000","size":""},{"color":"000000","size":""}]&backgroundColor=rgba(255,255,255,1)&colors[]=rgba(67, 67, 72, 1)&colors[]=rgba(144, 237, 125, 1)&colors[]=rgba(247, 163, 92, 1)&colors[]=rgba(128, 133, 233, 1)&colors[]=rgba(241, 92, 128, 1)&colors[]=rgba(228, 211, 84, 1)&colors[]=rgba(43, 144, 143, 1)&colors[]=rgba(244, 91, 91, 1)&colors[]=rgba(145, 232, 225, 1)&xlinew=0&ylinew=1&legends=true&tooltips=true'; + */ + if (typeof document !== 'undefined') { + this.element.nativeElement.scrollIntoView(); + } + }); + } + + ngOnDestroy() { + this.sub.unsubscribe(); + } + + getPublicationInfo(id:string) { + this.warningMessage = ''; + this.errorMessage="" + + this._publicationService.getPublicationInfo(this.articleId).subscribe( + data => { + this.publicationInfo = data; + + + // this.result = [] + // this.result = {id: id, type :"dataset", source : "openaire", title: this.publicationInfo.title,url: '', result: '', accessRights: this.publicationInfo.bestlicense, embargoEndDate: ''}; + this.updateTitle(this.publicationInfo.title.name); + this.updateDescription("Dataset, search, repositories, open access,"+this.publicationInfo.title.name); + + let bioentitiesNum = 0; + if(this.publicationInfo.bioentities != undefined) { + this.publicationInfo.bioentities.forEach(function (value, key, map) { + bioentitiesNum += value.size; + }); + } + this.bioentitiesNum = bioentitiesNum; + + let relatedResearchResultsNum = 0; + if(this.publicationInfo.relatedResearchResults != undefined) { + this.publicationInfo.relatedResearchResults.forEach(function (value, key, map) { + relatedResearchResultsNum += value.length; + }); + } + this.relatedResearchResultsNum = relatedResearchResultsNum; + + this.result = {id: this.articleId, type :"publication", source : "openaire", title: this.publicationInfo.title,url: '', result: '', accessRights: this.publicationInfo.bestlicense, embargoEndDate: ''}; + // this.result.push(result_); + + if(this.publicationInfo.identifiers != undefined && this.publicationInfo.identifiers.has('doi')) { + this.doi = this.publicationInfo.identifiers.get('doi')[0]; + } + }, + err => { + console.log(err); + console.info("error"); + + this.errorMessage = 'No publication found'; + } + ); + } + + showChange($event) { + this.showAllReferences=$event.value; + } + + public downloadClicked($event) { + this.totalViews = $event.totalViews; + this.totalDownloads = $event.totalDownloads; + } + + public metricsResults($event) { + this.totalViews = $event.totalViews; + this.totalDownloads = $event.totalDownloads; + this.pageViews = $event.pageViews; + } + + public buildTooltip(item: { "id": string, "acronym": string, "title": string, + "funderShortname": string, "funderName": string, + "funding": string, "code": string, inline: boolean}) { + let tooltipContent: string = ""; + + if(item.title) { + tooltipContent += "

"+item.title+"

"; + } + if(item.code) { + tooltipContent += "Project Code: "+item.code; + } + if(item.funderName || item.funderShortname) { + tooltipContent += "
Funder: "; + if(item.funderName && item.funderShortname) { + tooltipContent += item.funderName + " ("+ item.funderShortname +")"; + } else if(item.funderName) { + tooltipContent += item.funderName; + } else { + tooltipContent += item.funderShortname; + } + + tooltipContent += "
"; + } + + if(item.funding) { + tooltipContent += "
Funding: "+ item.funding + "
"; + } + + if(tooltipContent) { + tooltipContent = "
" + tooltipContent + "
"; + } + + return tooltipContent; + /*
+

{{item['title']}}

+ Project Code: {{item['code']}} +
+ Funder: {{item['funderName']}} ({{item['funderShortname']}}) +
+
+ Funding: {{item['funding']}} +
+
*/ + } + updateDescription(description:string){ + this._meta.updateMeta("description", description); + this._meta.updateMeta("og:description", description); + } + updateTitle(title:string){ + var _suffix ="| OpenAIRE"; + var _title = ((title.length> 50 ) ?title.substring(0,50):title) + _suffix; + this._meta.setTitle(_title ); + this._meta.updateMeta("og:title",_title); + } +} diff --git a/workingUIKIT/src/app/landingPages/publication/publication.module.ts b/workingUIKIT/src/app/landingPages/publication/publication.module.ts new file mode 100644 index 00000000..1c4dd98a --- /dev/null +++ b/workingUIKIT/src/app/landingPages/publication/publication.module.ts @@ -0,0 +1,36 @@ +//import {MaterialModule} from '@angular/material'; +import { NgModule} from '@angular/core'; +import { CommonModule } from '@angular/common'; +import { FormsModule } from '@angular/forms'; +import { SharedModule } from '../../shared/shared.module'; +import { RouterModule } from '@angular/router'; + +import { PublicationService} from './publication.service'; +import { PublicationComponent } from './publication.component'; +import { PublicationRoutingModule } from './publication-routing.module'; +import {MetricsModule} from '../metrics.module'; +import {IFrameModule} from '../../utils/iframe.module'; +import {AltMetricsModule} from '../../utils/altmetrics.module'; +import {CiteThisModule} from '../landing-utils/citeThis/citeThis.module'; + + +import { ResultLandingModule } from '../resultLanding.module'; +import { LandingModule } from '../landing.module'; +import {FreeGuard} from'../../login/freeGuard.guard'; + +@NgModule({ + imports: [ + CommonModule, FormsModule, LandingModule,SharedModule, RouterModule, CiteThisModule, + ResultLandingModule, PublicationRoutingModule, IFrameModule, MetricsModule, AltMetricsModule + ], + declarations: [ + PublicationComponent + ], + providers:[ + PublicationService, FreeGuard + ], + exports: [ + PublicationComponent + ] +}) +export class PublicationModule { } diff --git a/workingUIKIT/src/app/landingPages/publication/publication.service.ts b/workingUIKIT/src/app/landingPages/publication/publication.service.ts new file mode 100644 index 00000000..07c4b7a3 --- /dev/null +++ b/workingUIKIT/src/app/landingPages/publication/publication.service.ts @@ -0,0 +1,690 @@ +import {Injectable} from '@angular/core'; +import {Http, Response} from '@angular/http'; +import {Observable} from 'rxjs/Observable'; +import {PublicationInfo} from '../../utils/entities/publicationInfo'; +import {OpenaireProperties} from '../../utils/properties/openaireProperties'; +import 'rxjs/add/observable/of'; +import 'rxjs/add/operator/do'; +import 'rxjs/add/operator/share'; +import { CacheService } from '../../shared/cache.service'; +@Injectable() +export class PublicationService { + + constructor(private http: Http, public _cache: CacheService) {} + + publicationInfo: PublicationInfo; + + getPublicationInfo (id: string):any { + console.info("getPublicationInfo in service"); + let url = OpenaireProperties. getSearchAPIURLLast() + 'publications/' +id+"?format=json"; + let key = url; + if (this._cache.has(key)) { + return Observable.of(this._cache.get(key)).map(res => this.parsePublicationInfo(res)); + } + return this.http.get(url) + .map(res => res.json()) + .map(res => res['result']['metadata']['oaf:entity']) + .map(res => [res['oaf:result'], + res['oaf:result']['title'], + res['oaf:result']['rels']['rel'], + res['oaf:result']['children'], + res['oaf:result']['pid'], + res['oaf:result']['journal'], + res['oaf:result']['language'], + res['oaf:result']['subject'], + res['oaf:result']['bestlicense'], + res['oaf:result']['collectedfrom'], + (res['extraInfo']!= undefined && res['extraInfo']['citations']!= undefined)? res['extraInfo']['citations']['citation']:null, + res['oaf:result']['context'] + ]) + .do(res => { + this._cache.set(key, res); + }) + .map(res => this.parsePublicationInfo(res)); + } + + private handleError (error: Response) { + // 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'); + } + + parsePublicationInfo (data: any):any { + this.publicationInfo = new PublicationInfo(); + + if(data[0] != null) { + this.publicationInfo.date = data[0].dateofacceptance.substring(0,4); + this.publicationInfo.dateofacceptance = data[0].dateofacceptance; + this.publicationInfo.publisher = data[0].publisher; + if(!Array.isArray(data[0].description)) { + this.publicationInfo.description = data[0].description; + } else { + this.publicationInfo.description = data[0].description[0]; + } + this.publicationInfo.embargoEndDate = data[0].embargoenddate; + } + + this.publicationInfo.title = {"name": "", "url": "", "accessMode": ""}; + if(data[0]['bestlicense'].hasOwnProperty("classid")) { + this.publicationInfo.title.accessMode = data[0]['bestlicense'].classid; + console.info("accessmode by bestlicence = "+data[0]['bestlicense'].classid); + } + if(data[1] != null) { + + if(Array.isArray(data[1])) { + this.publicationInfo.title['name'] = data[1][0].content; + } else { + this.publicationInfo.title['name'] = data[1].content; + } + } + + if(data[2] != null) { + let relation; + let counter = 0; + let length = Array.isArray(data[2]) ? data[2].length : 1; + + for(let i=0; i(); + } + + this.publicationInfo.authors[relation.ranking-1] = {"name": "", "id": ""}; + this.publicationInfo.authors[relation.ranking-1]['name'] = relation.fullname; + this.publicationInfo.authors[relation.ranking-1]['id'] = /*OpenaireProperties.getsearchLinkToPerson() + */relation['to'].content; + } else if(relation['to'].class == "isProducedBy") { + if(this.publicationInfo.fundedByProjects == undefined) { + this.publicationInfo.fundedByProjects = new Array< + { "id": string, "acronym": string, "title": string, + "funderShortname": string, "funderName": string, + "funding": string, "code": string, "inline": boolean + }>(); + } + + counter = this.publicationInfo.fundedByProjects.length; + + this.publicationInfo.fundedByProjects[counter] = { + "id": "", "acronym": "", "title": "", + "funderShortname": "", "funderName": "", + "funding": "", "code": "", "inline": false + } + + if(relation.title != 'unidentified') { + this.publicationInfo.fundedByProjects[counter]['id'] = + /*OpenaireProperties.getsearchLinkToProject() + */relation['to'].content; + this.publicationInfo.fundedByProjects[counter]['acronym'] = relation.acronym; + this.publicationInfo.fundedByProjects[counter]['title'] = relation.title; + this.publicationInfo.fundedByProjects[counter]['code'] = relation.code; + } else { + this.publicationInfo.fundedByProjects[counter]['id'] = ""; + this.publicationInfo.fundedByProjects[counter]['acronym'] = ""; + this.publicationInfo.fundedByProjects[counter]['title'] = ""; + this.publicationInfo.fundedByProjects[counter]['code'] = ""; + } + + if(relation.hasOwnProperty("funding")) { + let length1 = Array.isArray(relation['funding']) ? relation['funding'].length : 1; + + for(let j=0; j(); + } + + if(!this.publicationInfo.relatedResearchResults.has(provenanceAction)) { + this.publicationInfo.relatedResearchResults.set(provenanceAction, + new Array<{ "name": string, "id": string, "date": string, + "trust": string, "class": string}>()); + } + /* + if(this.publicationInfo.relatedResearchResults == undefined) { + this.publicationInfo.relatedResearchResults = new Array<{ + "name": string, "id": string, "date": string, + "trust": string, "class": string}>(); + } + */ + + counter = this.publicationInfo.relatedResearchResults.get(provenanceAction).length; + this.publicationInfo.relatedResearchResults.get(provenanceAction)[counter] = {"name": "", "id": "", "date": "", "trust": "", "class": ""} + + //let url; + if(relation['resulttype'].classname == "publication") { + //url = OpenaireProperties.getsearchLinkToPublication() + relation['to'].content; + this.publicationInfo.relatedResearchResults.get(provenanceAction)[counter]['class'] = "publication"; + } else { + //url = OpenaireProperties.getsearchLinkToDataset() + relation['to'].content; + this.publicationInfo.relatedResearchResults.get(provenanceAction)[counter]['class'] = "dataset"; + } + + this.publicationInfo.relatedResearchResults.get(provenanceAction)[counter]['id'] = relation['to'].content; + //this.publicationInfo.relatedResearchResults[counter]['url'] = url; + let titleName = Array.isArray(relation['title']) ? relation['title'][0].content : relation['title'].content; + this.publicationInfo.relatedResearchResults.get(provenanceAction)[counter]['name'] = titleName; + this.publicationInfo.relatedResearchResults.get(provenanceAction)[counter]['date'] = relation.dateofacceptance.substring(0,4);; + this.publicationInfo.relatedResearchResults.get(provenanceAction)[counter]['trust'] = Math.round(relation.trust*100)+"%"; + + } else if(relation['to'].class == "hasAmongTopNSimilarDocuments") { + if(this.publicationInfo.similarResearchResults == undefined) { + this.publicationInfo.similarResearchResults = new Array<{ + "name": string, "id": string, "date": string, + "trust": string, "class": string}>(); + } + + counter = this.publicationInfo.similarResearchResults.length; + this.publicationInfo.similarResearchResults[counter] = {"name": "", "id": "", "date": "", "trust": "", "class": ""} + + //let url; + if(relation['resulttype'].classname == "publication") { + //url = OpenaireProperties.getsearchLinkToPublication() + relation['to'].content; + this.publicationInfo.similarResearchResults[counter]['class'] = "publication"; + } else { + //url = OpenaireProperties.getsearchLinkToDataset() + relation['to'].content; + this.publicationInfo.similarResearchResults[counter]['class'] = "dataset"; + } + + this.publicationInfo.similarResearchResults[counter]['id'] = relation['to'].content; + //this.publicationInfo.similarResearchResults[counter]['url'] = url; + let titleName = Array.isArray(relation['title']) ? relation['title'][0].content : relation['title'].content; + this.publicationInfo.similarResearchResults[counter]['name'] = titleName; + this.publicationInfo.similarResearchResults[counter]['date'] = relation.dateofacceptance.substring(0,4);; + this.publicationInfo.similarResearchResults[counter]['trust'] = Math.round(relation.trust*100)+"%"; + } else if(relation['to'].class == "hasAuthorInstitution") { + if(this.publicationInfo.organizations == undefined) { + this.publicationInfo.organizations = new Array<{ + "name": string, "shortname": string, + "id": string, "websiteUrl": string, + "country": string, "trust": string}>(); + } + + let organization: { + "name": string, "shortname": string, + "id": string, "websiteUrl": string, + "country": string, "trust": string + } = { + "name": "", "shortname": "", + "id": "", "websiteUrl": "", + "country": "", "trust": "" + }; + + organization.id = relation['to'].content; + organization.name = relation.legalname; + organization.shortname = relation.legalshortname; + organization.websiteUrl = relation.websiteurl; + if(relation.country) { + organization.country = relation.country.classname; + } + if(relation.trust) { + organization.trust = Math.round(relation.trust*100)+"%"; + } + + this.publicationInfo.organizations.push(organization); + } + } + } + + if(this.publicationInfo.authors != undefined) { + this.publicationInfo.authors = this.publicationInfo.authors.filter(function (item) { + return (item != undefined); + }); + } + } + + if(data[3] != null) { + if(data[3].hasOwnProperty("instance")) { + this.publicationInfo.downloadFrom = new Map(); + this.publicationInfo.publishedIn = new Map(); + + this.publicationInfo.types = new Array(); + + let length = Array.isArray(data[3]['instance']) ? data[3]['instance'].length : 1; + + let types = new Set(); + let counter = 0; + let counter1 = 0; + let counter2 = 0; + let instance; + for(let i=0; i(); + } + + this.publicationInfo.downloadFrom.get(key)['url'].push(url); + + if(this.publicationInfo.downloadFrom.get(key)['accessMode'] == null) { + this.publicationInfo.downloadFrom.get(key)['accessMode'] = new Array(); + } + + if(instance.hasOwnProperty("licence")) { + this.publicationInfo.downloadFrom.get(key)['accessMode'].push(instance['licence'].classid); + + switch (this.publicationInfo.downloadFrom.get(key)['bestAccessMode']) { + case null: + this.publicationInfo.downloadFrom.get(key)['bestAccessMode'] = instance['licence'].classid; + break; + case "CLOSED": + if(instance['licence'].classid == "OPEN" || + instance['licence'].classid == "EMBARGO" || + instance['licence'].classid == "RESTRICTED") { + this.publicationInfo.downloadFrom.get(key)['bestAccessMode'] = instance['licence'].classid; + } + break; + case "RESTRICTED": + if(instance['licence'].classid == "OPEN" || + instance['licence'].classid == "EMBARGO") { + this.publicationInfo.downloadFrom.get(key)['bestAccessMode'] = instance['licence'].classid; + } + break; + case "EMBARGO": + if(instance['licence'].classid == "OPEN") { + this.publicationInfo.downloadFrom.get(key)['bestAccessMode'] = instance['licence'].classid; + } + break; + } + } else { + this.publicationInfo.downloadFrom.get(key)['accessMode'].push(""); + } + } else { + if(data[0] != null && data[0].hasOwnProperty("source")) { + let key: string; + if(Array.isArray(data[0].source)) { + if(counter1==data[0].source.length) { + counter1--; + } + key = data[0]['source'][counter1]; + } else { + key = data[0]['source']; + } + if(key != "") { + if(!this.publicationInfo.publishedIn.has(key)) { + this.publicationInfo.publishedIn.set(key, {"url": null, "accessMode": null, "bestAccessMode": null}); + } + + if(this.publicationInfo.publishedIn.get(key)['url'] == null) { + this.publicationInfo.publishedIn.get(key)['url'] = new Array(); + } + + this.publicationInfo.publishedIn.get(key)['url'].push(url); + + if(this.publicationInfo.publishedIn.get(key)['accessMode'] == null) { + this.publicationInfo.publishedIn.get(key)['accessMode'] = new Array(); + } + + if(instance.hasOwnProperty("licence")) { + this.publicationInfo.publishedIn.get(key)['accessMode'].push(instance['licence'].classid); + switch (this.publicationInfo.publishedIn.get(key)['bestAccessMode']) { + case null: + this.publicationInfo.publishedIn.get(key)['bestAccessMode'] = instance['licence'].classid; + break; + case "CLOSED": + if(instance['licence'].classid == "OPEN" || + instance['licence'].classid == "EMBARGO" || + instance['licence'].classid == "RESTRICTED") { + this.publicationInfo.publishedIn.get(key)['bestAccessMode'] = instance['licence'].classid; + } + break; + case "RESTRICTED": + if(instance['licence'].classid == "OPEN" || + instance['licence'].classid == "EMBARGO") { + this.publicationInfo.publishedIn.get(key)['bestAccessMode'] = instance['licence'].classid; + } + break; + case "EMBARGO": + if(instance['licence'].classid == "OPEN") { + this.publicationInfo.publishedIn.get(key)['bestAccessMode'] = instance['licence'].classid; + } + break; + } + } else { + this.publicationInfo.publishedIn.get(key)['accessMode'].push(""); + } + counter1++; + } + } + } + if(this.publicationInfo.title != undefined) { + switch (this.publicationInfo.title['accessMode']) { + case undefined: + this.publicationInfo.title['accessMode'] = instance['licence'].classid; + this.publicationInfo.title['url'] = url; + console.info("accessmode by undefined = "+this.publicationInfo.title.accessMode); + break; + case "CLOSED": + if(instance['licence'].classid == "OPEN" || + instance['licence'].classid == "EMBARGO" || + instance['licence'].classid == "RESTRICTED") { + this.publicationInfo.title['accessMode'] = instance['licence'].classid; + this.publicationInfo.title['url'] = url; + console.info("accessmode by closed = "+this.publicationInfo.title.accessMode); + } + break; + case "RESTRICTED": + if(instance['licence'].classid == "OPEN" || + instance['licence'].classid == "EMBARGO") { + this.publicationInfo.title['accessMode'] = instance['licence'].classid; + this.publicationInfo.title['url'] = url; + console.info("accessmode by restricted = "+this.publicationInfo.title.accessMode); + } + break; + case "EMBARGO": + if(instance['licence'].classid == "OPEN") { + this.publicationInfo.title['accessMode'] = instance['licence'].classid; + this.publicationInfo.title['url'] = url; + console.info("accessmode by embargo= "+this.publicationInfo.title.accessMode); + } + break; + case "OPEN": + if(instance['licence'].classid == "OPEN" && + this.publicationInfo.title['url'] == "") { + this.publicationInfo.title['url'] = url; + console.info("title url by empty = "+this.publicationInfo.title.url); + } + break; + } + } + } + } + } + } + + if(data[3].hasOwnProperty("externalreference")) { + let length = Array.isArray(data[3]['externalreference']) ? data[3]['externalreference'].length : 1; + + let externalreference; + for(let i=0; i>(); + } + + if(!this.publicationInfo.bioentities.has(externalreference.sitename)) { + this.publicationInfo.bioentities.set(externalreference.sitename, new Map()); + } + this.publicationInfo.bioentities.get(externalreference.sitename).set(externalreference.refidentifier, externalreference.url); + + } else if(externalreference['qualifier'].classid == "software") { + + if(this.publicationInfo.software == undefined) { + this.publicationInfo.software = new Array<{"name": string, "url": string}>(); + } + + this.publicationInfo.software.push({"name": externalreference.sitename, "url": externalreference.url}); + } + } + } + } + } + + if(data[4] != null) { + this.publicationInfo.identifiers = new Map(); + + if(data[4].hasOwnProperty("classname") && data[4]['classname'] != "") { + if(data[4].classname == "doi" || data[4].classname == "pmc") { + if(!this.publicationInfo.identifiers.has(data[4].classname)) { + this.publicationInfo.identifiers.set(data[4].classname, new Array()); + } + this.publicationInfo.identifiers.get(data[4].classname).push(data[4].content); + } + } else { + for(let i=0; i()); + } + this.publicationInfo.identifiers.get(data[4][i].classname).push(data[4][i].content); + } + } + } + } + + if(data[5] != null) { + this.publicationInfo.journal = {"journal": "", "issn": "", "lissn": ""} + + this.publicationInfo.journal['journal'] = data[5].content; + this.publicationInfo.journal['issn'] = data[5].issn; + this.publicationInfo.journal['lissn'] = data[5].lissn; + } + + if(data[6] != null) { + this.publicationInfo.languages = new Array(); + + if(data[6].hasOwnProperty("classname")) { + this.publicationInfo.languages[0] = data[6].classname; + } else { + for(let i=0; i(); + } + + if(!this.publicationInfo.classifiedSubjects.has(subject.classname)) { + this.publicationInfo.classifiedSubjects.set(subject.classname, new Array()); + } + + this.publicationInfo.classifiedSubjects.get(subject.classname).push(subject.content); + } else { + if(subject.classid == "keyword") { + if(this.publicationInfo.subjects == undefined) { + this.publicationInfo.subjects = new Array(); + } + + this.publicationInfo.subjects.push(subject.content); + } else { + if(this.publicationInfo.otherSubjects == undefined) { + this.publicationInfo.otherSubjects = new Map(); + } + + if(!this.publicationInfo.otherSubjects.has(subject.classname)) { + this.publicationInfo.otherSubjects.set(subject.classname, new Array()); + } + this.publicationInfo.otherSubjects.get(subject.classname).push(subject.content); + } + } + } + } + } + + if(data[8] != null) { + this.publicationInfo.bestlicense = data[8].classid; + } + + if(data[9] != null) { + this.publicationInfo.collectedFrom = new Array<{"name": string, "id": string}>(); + + let collectedFrom; + let length = Array.isArray(data[9]) ? data[9].length : 1; + for(let i=0; i(); + } + + let key: string; + if(this.publicationInfo.journal != null) { + key = this.publicationInfo.publisher + "/ "+this.publicationInfo.journal['journal']; + } else { + key = this.publicationInfo.publisher; + } + this.publicationInfo.downloadFrom.set(key, {"url": null, "accessMode": null, "bestAccessMode": null}); + + let url = OpenaireProperties.getDoiURL()+this.publicationInfo.identifiers.get("doi")[0]; + + this.publicationInfo.downloadFrom.get(key)['url'] = new Array(); + this.publicationInfo.downloadFrom.get(key)['accessMode'] = new Array(); + + this.publicationInfo.downloadFrom.get(key)['url'][0] = url; + this.publicationInfo.downloadFrom.get(key)['accessMode'][0] = ""; + + if(this.publicationInfo.title != undefined && this.publicationInfo.title['url'] == "") { + this.publicationInfo.title['url'] = url; + console.info("title url: by doi"); + } + } + + if(data[10] != null) { + this.publicationInfo.references = new Array<{"name": string, "url": string}>(); + + let citation; + let length = Array.isArray(data[10]) ? data[10].length : 1; + for(let i=0; i(); + + let position = 0; + let labels = ""; + let context; + let length = Array.isArray(data[11]) ? data[11].length : 1; + for(let i=0; i + There are no projects +
+ +
+ +
+
+ +
+
    +
  • +
    Filter by {{filter.title}}:
    + + + {{value.name}} ({{value.number}}) + +
  • + +
  • Filtered {{fetchProjects.searchUtils.totalResults}} results of {{fetchProjects.totalResults}} total results
  • +
  • +
+ + + +
+ ` +}) + +export class SearchingProjectsTabComponent { + public fetchProjects : FetchProjects; + public organizationId:string = ""; + public page :number = 1; + public size :number = 10; + public linkToSearchProjects; + private filterQuery:string = ""; + private sub: any; + + public routerHelper:RouterHelper = new RouterHelper(); + + constructor (private route: ActivatedRoute, + private _searchProjectsService: SearchProjectsService) { + } + + + ngOnInit() { + this.sub = this.route.queryParams.subscribe(params => { + this.organizationId = params['organizationId']; + + if(this.organizationId) { + this.fetchProjects = new FetchProjects(this._searchProjectsService); + + this.linkToSearchProjects = OpenaireProperties.getLinkToAdvancedSearchProjects();//+"?organization="+this.organizationId+"or=and";; + this.search(true,""); + } + }); + } + + ngOnDestroy() { + this.sub.unsubscribe(); + } + + search(refine:boolean, filterQuery:string){ + var refineFields:string [] = ["funderid"]; + this.fetchProjects.getResultsForOrganizations(this.organizationId, filterQuery, this.page, this.size,(refine)?refineFields:[]); + } + + pageChange($event) { + this.page=$event.value; + this.search(false, this.filterQuery); + } + + filterChange($event) { + console.log("Filter Changed"); + this.updateFilters(); + this.search(true, this.filterQuery); + } + + updateFilters (){ + this.filterQuery = ""; + for (let filter of this.fetchProjects.filters){ + var filterLimits=""; + for (let value of filter.values){ + if(value.selected == true){ + filterLimits+=((filterLimits.length == 0)?'':',') +'"'+ StringUtils.URIEncode(value.id)+'"'; + } + } + if(filterLimits.length > 0){ + this.filterQuery+=' and '+filter.filterId + ' exact '+ filterLimits + ' '; + } + + } + console.log("Filter Changed"+this.filterQuery); + + } +} diff --git a/workingUIKIT/src/app/landingPages/searchingProjectsInTab.module.ts b/workingUIKIT/src/app/landingPages/searchingProjectsInTab.module.ts new file mode 100644 index 00000000..5b9f3917 --- /dev/null +++ b/workingUIKIT/src/app/landingPages/searchingProjectsInTab.module.ts @@ -0,0 +1,30 @@ +/* This module contains all common components for all landing pages */ + +import { NgModule} from '@angular/core'; +import { CommonModule } from '@angular/common'; +import { FormsModule } from '@angular/forms'; +import { RouterModule } from '@angular/router'; + +import { ProjectsServiceModule} from '../services/projectsService.module'; +import { TabResultModule } from '../searchPages/searchUtils/tabResult.module'; +import { SearchingProjectsTabComponent} from './searchingProjectsInTab.component'; + +import {PagingModule } from '../utils/paging.module'; + + +@NgModule({ + imports: [ + RouterModule, CommonModule, FormsModule, + ProjectsServiceModule, TabResultModule, PagingModule + ], + declarations: [ + SearchingProjectsTabComponent + ], + providers:[ + ], + exports: [ + + SearchingProjectsTabComponent + ] +}) +export class SearchingProjectsTabModule { } diff --git a/workingUIKIT/src/app/landingPages/showAuthors.component.ts b/workingUIKIT/src/app/landingPages/showAuthors.component.ts new file mode 100644 index 00000000..454957e2 --- /dev/null +++ b/workingUIKIT/src/app/landingPages/showAuthors.component.ts @@ -0,0 +1,48 @@ +import {Component, Input} from '@angular/core'; + +@Component({ + selector: 'showAuthors', + template: ` + + + + + + {{item['name']}}; + + + ... + + + + + {{item['name']}}; + + + + + + view all {{authors.length}} authors + + + + View less authors + + + + ` + + }) + +export class ShowAuthorsComponent { + @Input() authors: { [key: string]: string }[]; + private showAll: boolean = false; + + constructor () { + } + + ngOnInit() { + } +} diff --git a/workingUIKIT/src/app/landingPages/showIdentifiers.component.ts b/workingUIKIT/src/app/landingPages/showIdentifiers.component.ts new file mode 100644 index 00000000..744c1962 --- /dev/null +++ b/workingUIKIT/src/app/landingPages/showIdentifiers.component.ts @@ -0,0 +1,41 @@ +import {Component, Input} from '@angular/core'; +import {OpenaireProperties} from '../utils/properties/openaireProperties'; + +@Component({ + selector: 'showIdentifiers', + template: ` + +
Identifiers:
+
+ + + , + + + {{key}}: {{item}} + + + {{key}}: {{item}} + + + + +
+
+ + ` + }) + +export class ShowIdentifiersComponent { + @Input() identifiers: Map; + doiURL: string; + pmcURL: string; + + constructor () { + this.doiURL = OpenaireProperties.getDoiURL(); + this.pmcURL = OpenaireProperties.getPmcURL(); + } + + ngOnInit() { + } +} diff --git a/workingUIKIT/src/app/landingPages/showSubjects.component.ts b/workingUIKIT/src/app/landingPages/showSubjects.component.ts new file mode 100644 index 00000000..f5cc25cb --- /dev/null +++ b/workingUIKIT/src/app/landingPages/showSubjects.component.ts @@ -0,0 +1,69 @@ +import {Component, Input} from '@angular/core'; + +@Component({ + selector: 'showSubjects', + template: ` + + +
+ Subjects: +
+
+ Subjects: +
+ +
+
{{subjects}}
+
+
+ {{key}}: {{otherSubjects.get(key)}} +
+
+
+ - +
+
+ +
+ +
+ Show additional classifications + +
+
+ Hide additional classifications + +
+
+ +
+
+ Classified by OpenAIRE into +
+ {{key}}: {{classifiedSubjects.get(key)}} +
+
+
+
+
+ ` + + }) + +export class ShowSubjectsComponent { + @Input() subjects: string[]; + @Input() otherSubjects: Map; + @Input() classifiedSubjects: Map; + private showClassifiedSbj: boolean = false; + + constructor () { + } + + ngOnInit() { + } +} diff --git a/workingUIKIT/src/app/landingPages/showTitle.component.ts b/workingUIKIT/src/app/landingPages/showTitle.component.ts new file mode 100644 index 00000000..33202d15 --- /dev/null +++ b/workingUIKIT/src/app/landingPages/showTitle.component.ts @@ -0,0 +1,51 @@ +import {Component, Input} from '@angular/core'; + + +@Component({ + selector: 'showTitle', + template: ` +

+ + + + + [no title available] + + + + + + [no title available] + +

+ ` + + }) + +export class ShowTitleComponent { + @Input() title: { [key: string]: string }; + + constructor () { + } + + ngOnInit() { + if(this.title['accessMode'] == undefined) { + this.title['accessMode'] = ""; + } + } +} diff --git a/workingUIKIT/src/app/landingPages/tabPaging.component.ts b/workingUIKIT/src/app/landingPages/tabPaging.component.ts new file mode 100644 index 00000000..f0671764 --- /dev/null +++ b/workingUIKIT/src/app/landingPages/tabPaging.component.ts @@ -0,0 +1,24 @@ +import {Component, Input, Output, EventEmitter} from '@angular/core'; + +@Component({ + selector: 'tabPaging', + template: ` + + ` + }) + +export class TabPagingComponent { + @Input() showAll: boolean; + @Input() length: number; + @Output() changeShowAll: EventEmitter = new EventEmitter(); + + constructor () { + } + + ngOnInit() { + } +} diff --git a/workingUIKIT/src/app/landingPages/tabTable.component.ts b/workingUIKIT/src/app/landingPages/tabTable.component.ts new file mode 100644 index 00000000..05be3f1e --- /dev/null +++ b/workingUIKIT/src/app/landingPages/tabTable.component.ts @@ -0,0 +1,72 @@ +import {Component, Input} from '@angular/core'; +import {RouterHelper} from '../utils/routerHelper.class'; +import {OpenaireProperties} from '../utils/properties/openaireProperties'; + +@Component({ + selector: 'tabTable', + template: ` + + + + + + + + + + + + + +
TitleTrust
+ + + + {{item['name']}} + + + + + + {{item['name']}} + + +

{{item['name']}}

+ + ({{item['date']}}) + +
+
+
+ {{item['trust']}} +
+ +
+
+

no trust found

+
+
+ ` + + }) + +export class TabTableComponent { + @Input() info: { "name": string, "url": string, "date": string, "trust": string}[];//Map; + + public routerHelper:RouterHelper = new RouterHelper(); + public searchLinkToPublication: string; + public searchLinkToDataset: string; + + constructor () { + } + + ngOnInit() { + this.searchLinkToPublication = OpenaireProperties.getsearchLinkToPublication(); + this.searchLinkToDataset = OpenaireProperties.getsearchLinkToDataset(); + } +} diff --git a/workingUIKIT/src/app/login/adminLoginGuard.guard.ts b/workingUIKIT/src/app/login/adminLoginGuard.guard.ts new file mode 100644 index 00000000..c35d8eb0 --- /dev/null +++ b/workingUIKIT/src/app/login/adminLoginGuard.guard.ts @@ -0,0 +1,45 @@ +import { Injectable } from '@angular/core'; +import { Router,CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot} from '@angular/router'; +import {Observable} from 'rxjs/Observable'; +import {Session} from './utils/helper.class'; +import {ErrorCodes} from './utils/guardHelper.class'; +@Injectable() +export class AdminLoginGuard implements CanActivate { + + constructor(private router: Router) {} + + canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable | boolean { + var user; + var loggedIn = false; + var isAdmin = false; + var errorCode = ErrorCodes.NOT_LOGGIN; + + if(Session.isLoggedIn()){ + loggedIn = true; + if(!Session.isValidAndRemove()){ + loggedIn = false; + errorCode = ErrorCodes.NOT_VALID; + }else { + isAdmin = Session.isAdminUser(); + if(!isAdmin){ + errorCode = ErrorCodes.NOT_ADMIN; + } + } + }else{ + errorCode =ErrorCodes.NOT_LOGGIN; + } + + if(!loggedIn){ + // this.guardHelper.redirect("/user-info",errorCode,state.url); + this.router.navigate(['/user-info'], { queryParams: { "errorCode": errorCode, "redirectUrl": state.url } }); + + return false; + }else if(!isAdmin){ + // this.guardHelper.redirect("/user-info",errorCode,state.url); + this.router.navigate(['/user-info'], { queryParams: { "errorCode": errorCode, "redirectUrl": state.url } }); + return false; + }else{ + return true; + } + } +} diff --git a/workingUIKIT/src/app/login/freeGuard.guard.ts b/workingUIKIT/src/app/login/freeGuard.guard.ts new file mode 100644 index 00000000..316ff266 --- /dev/null +++ b/workingUIKIT/src/app/login/freeGuard.guard.ts @@ -0,0 +1,36 @@ +import { Injectable } from '@angular/core'; +import { Router,CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot} from '@angular/router'; +import {Observable} from 'rxjs/Observable'; +import {Session} from './utils/helper.class'; +import {ErrorCodes} from './utils/guardHelper.class'; + +@Injectable() +export class FreeGuard implements CanActivate { + + constructor(private router: Router) {} + + canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable | boolean { + var user; + var valid = true; + var loggedIn = false; + var errorCode = ErrorCodes.NOT_LOGGIN; + + if(Session.isLoggedIn()){ + loggedIn = true; + if(!Session.isValidAndRemove()){ + loggedIn = false; + valid = false; + errorCode = ErrorCodes.NOT_VALID; + } + } + + if(!valid){ + // this.guardHelper.redirect("/user-info",errorCode,state.url); + + this.router.navigate(['/user-info'], { queryParams: { "errorCode": errorCode, "redirectUrl": state.url } }); + return false; + } + return true; + + } +} diff --git a/workingUIKIT/src/app/login/login.service.ts b/workingUIKIT/src/app/login/login.service.ts new file mode 100644 index 00000000..76fb2400 --- /dev/null +++ b/workingUIKIT/src/app/login/login.service.ts @@ -0,0 +1,43 @@ +import {Injectable} from '@angular/core'; +import {Http, Response, Headers, RequestOptions, URLSearchParams} from '@angular/http'; +import {Observable} from 'rxjs/Observable'; +import 'rxjs/add/observable/of'; +import 'rxjs/add/operator/do'; +import 'rxjs/add/operator/share'; + +import { CacheService } from '../shared/cache.service'; +import {PersonInfo} from '../utils/entities/personInfo'; +import {OpenaireProperties} from '../utils/properties/openaireProperties'; +import {User,Session,MyJWT} from './utils/helper.class'; + + +@Injectable() +export class LoginService { + + constructor(private http: Http, public _cache: CacheService) {} + + authenticate (username: string, password: string):any { + + + let headers = new Headers({ 'Content-Type': 'application/json' }); + let options = new RequestOptions({ headers: headers }); + let body = JSON.stringify( {"username":username, "password":password} ); + + return this.http.post(OpenaireProperties.getLoginAPIURL(), body,options) + .map(res => res.json()) + .map(res =>this.parse(res['data'])); + + + // let url = OpenaireProperties.getLoginAPIURL()+"?username="+username+"&password="+password; + // let key = url; + // return this.http.get(url) + // .map(res => res.json()) + // .map(res =>this.parse(res['data'])); + + } + + parse(data:any){ + return MyJWT.parseUserInfo(data); + } + +} diff --git a/workingUIKIT/src/app/login/loginGuard.guard.ts b/workingUIKIT/src/app/login/loginGuard.guard.ts new file mode 100644 index 00000000..6e960fd3 --- /dev/null +++ b/workingUIKIT/src/app/login/loginGuard.guard.ts @@ -0,0 +1,34 @@ +import { Injectable } from '@angular/core'; +import { Router,CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot} from '@angular/router'; +import {Observable} from 'rxjs/Observable'; +import {Session} from './utils/helper.class'; +import {ErrorCodes} from './utils/guardHelper.class'; + +@Injectable() +export class LoginGuard implements CanActivate { + + constructor(private router: Router) {} + + canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable | boolean { + var user; + var loggedIn = false; + var errorCode = ErrorCodes.NOT_LOGGIN; + + if(Session.isLoggedIn()){ + loggedIn = true; + if(!Session.isValidAndRemove()){ + loggedIn = false; + errorCode = ErrorCodes.NOT_VALID; + } + }else{ + errorCode = ErrorCodes.NOT_LOGGIN; + } + if(!loggedIn){ + // this.guardHelper.redirect("/user-info",errorCode,state.url); + this.router.navigate(['/user-info'], { queryParams: { "errorCode": errorCode, "redirectUrl": state.url } }); + return false; + }else{ + return true; + } + } +} diff --git a/workingUIKIT/src/app/login/user-routing.module.ts b/workingUIKIT/src/app/login/user-routing.module.ts new file mode 100644 index 00000000..5ec9f8a1 --- /dev/null +++ b/workingUIKIT/src/app/login/user-routing.module.ts @@ -0,0 +1,14 @@ +import { NgModule } from '@angular/core'; +import { RouterModule } from '@angular/router'; + +import { UserComponent } from './user.component'; + +@NgModule({ + imports: [ + RouterModule.forChild([ + { path: '', component: UserComponent}, + + ]) + ] +}) +export class UserRoutingModule { } diff --git a/workingUIKIT/src/app/login/user.component.ts b/workingUIKIT/src/app/login/user.component.ts new file mode 100644 index 00000000..5435c80f --- /dev/null +++ b/workingUIKIT/src/app/login/user.component.ts @@ -0,0 +1,145 @@ +import {Component, ElementRef} from '@angular/core'; +import {Observable} from 'rxjs/Observable'; +import {ActivatedRoute, Router} from '@angular/router'; + +import {LoginService} from './login.service'; +import {User,Session} from './utils/helper.class'; +import {RouterHelper} from '../utils/routerHelper.class'; +@Component({ + selector: 'user', + template: ` + +
+
+ The requested page requires authentication. Please login. +
+
+ You are not authorized to use the requested page +
+
+ The session has expired. Please log in again or continue browsing as a guest. +
+
+
+ Login Form +
+ +
+
+ +
+
+ +
+
+
+ +
{{errorMessage}}
+ +
+
+ Hello {{user.fullname}}! +
+ +
+
+ ` +}) + +export class UserComponent { + public user: User; + public loggedIn: boolean = false; + public server: boolean = true; + public errorMessage: string; + public username: string = ""; + public password: string = ""; + private sub:any;private sublogin:any; + public errorCode: string = ""; + public redirectUrl: string = ""; + public routerHelper:RouterHelper = new RouterHelper(); + + constructor( private router: Router, private _loginService: LoginService, private route: ActivatedRoute ) {} + + ngOnInit() { + if( typeof document !== 'undefined') { + this.server = false; + } + this.loggedIn = Session.isLoggedIn(); + this.user = Session.getUser(); + this.errorMessage = ""; + this.sub = this.route.queryParams.subscribe(params => { + this.errorCode = params["errorCode"]; + this.redirectUrl = params["redirectUrl"]; + this.loggedIn = Session.isLoggedIn(); + this.user = Session.getUser(); + this.errorMessage = ""; + }); + } + ngOnDestroy(){ + this.sub.unsubscribe(); + if(this.sublogin){ + this.sublogin.unsubscribe(); + } + } + logout(){ + if(Session.isLoggedIn()){ + Session.removeUser(); + } + this.loggedIn = false; + this.user = new User(); + this.username = ""; + this.password = ""; + this.redirect(); + + } + redirect(){ + if(this.redirectUrl && this.redirectUrl != null && this.redirectUrl != ""){ + this.redirectUrl = decodeURIComponent(this.redirectUrl); + var baseUrl = this.redirectUrl; + var queryParams = ""; + var paramsArray =[]; + var valuesArray =[]; + if(this.redirectUrl.indexOf('?') != -1){ + baseUrl = this.redirectUrl.split('?')[0]; + queryParams = this.redirectUrl.split('?')[1]; + } + if(queryParams != ""){ + var queryParamsArray = queryParams.split('&'); + for(var i = 0; i < queryParamsArray.length; i++){ + paramsArray.push(queryParamsArray[i].split("=")[0]); + valuesArray.push(queryParamsArray[i].split("=")[1]); + } + this.router.navigate([baseUrl], { queryParams: this.routerHelper.createQueryParams(paramsArray,valuesArray)}); + }else{ + this.router.navigate([baseUrl]); + } + }else{ + this.router.navigate(['/search/find']); + } + } + login() { + this.sublogin =this._loginService.authenticate(/*this.user*/this.username, this.password).subscribe( + data => { + this.user = data; + this.loggedIn = true; + this.username = ""; + this.password = ""; + this.errorCode = ""; + this.redirect(); + + }, + err => { + console.log(err); + if(err.status == "404") { + this.errorMessage = "Wrong username"; + } else if(err.status == "401") { + this.errorMessage = "Wrong password"; + } + this.username = ""; + this.password = ""; + this.errorCode = ""; + + } + ); + } +} diff --git a/workingUIKIT/src/app/login/user.module.ts b/workingUIKIT/src/app/login/user.module.ts new file mode 100644 index 00000000..1913997e --- /dev/null +++ b/workingUIKIT/src/app/login/user.module.ts @@ -0,0 +1,20 @@ +import { NgModule} from '@angular/core'; +import { CommonModule } from '@angular/common'; +import { FormsModule } from '@angular/forms'; + +import {UserComponent } from './user.component'; +import { UserRoutingModule } from './user-routing.module'; +import {LoginService} from './login.service'; +@NgModule({ + imports: [ + CommonModule, FormsModule, + UserRoutingModule + + ], + providers:[LoginService], + declarations: [ +UserComponent + +] +}) +export class UserModule { } diff --git a/workingUIKIT/src/app/login/userMini.component.ts b/workingUIKIT/src/app/login/userMini.component.ts new file mode 100644 index 00000000..f9fb8a74 --- /dev/null +++ b/workingUIKIT/src/app/login/userMini.component.ts @@ -0,0 +1,71 @@ +import {Component, ElementRef} from '@angular/core'; +import {Observable} from 'rxjs/Observable'; +import {ActivatedRoute, Router} from '@angular/router'; +import {Location} from '@angular/common'; +import {LoginService} from './login.service'; +import {User,Session} from './utils/helper.class'; +import {RouterHelper} from '../utils/routerHelper.class'; + +@Component({ + selector: 'user-mini', + template: ` + +
+ Hello {{user.fullname}}! + Hello Guest! + Log in +
+ + ` +}) + +export class UserMiniComponent { + public user: User; + public loggedIn: boolean = false; + public server: boolean = true; + public routerHelper:RouterHelper = new RouterHelper(); + + public redirectUrl: string = ""; + private baseUrl = "user-info"; + sub:any; + constructor( private router: Router, private route: ActivatedRoute, private location: Location) {} + + ngOnInit() { + if( typeof document !== 'undefined') { + this.server = false; + } + this.initialize(); + this.sub = this.route.queryParams.subscribe(params => { + this.initialize(); + }); + } + ngOnDestroy(){ + this.sub.unsubscribe(); + } + initialize(){ + this.redirectUrl = this.location.path(); + if(Session.isLoggedIn()){ + if(Session.isUserValid()){ + this.loggedIn = Session.isLoggedIn(); + this.user = Session.getUser(); + }else{ + Session.removeUser(); + this.loggedIn = false; + this.user = null; + } + }else { + this.loggedIn = false; + this.user = null; + } + + } + gotoUserPage(){ + this.redirectUrl = this.location.path(); + if(this.redirectUrl && this.redirectUrl != null && this.redirectUrl != "" && this.redirectUrl !="user-info"){ + this.router.navigate([this.baseUrl], { queryParams: this.routerHelper.createQueryParam("redirectUrl",this.redirectUrl )}); + }else{ + this.router.navigate([this.baseUrl]); + } + } + +} diff --git a/workingUIKIT/src/app/login/utils/guardHelper.class.ts b/workingUIKIT/src/app/login/utils/guardHelper.class.ts new file mode 100644 index 00000000..0eed04b9 --- /dev/null +++ b/workingUIKIT/src/app/login/utils/guardHelper.class.ts @@ -0,0 +1,18 @@ + +import { Router} from '@angular/router'; + +// export class GuardHelper{ +// constructor(private router: Router) {} +// +// redirect(url:string, errorCode:number, redirectUrl:string){ +// this.router.navigate([url], { queryParams: { "errorCode": errorCode, "redirectUrl": redirectUrl } }); +// +// } +// +// } +export class ErrorCodes { + public static NOT_LOGGIN:number =1; + public static NOT_ADMIN:number =2; + public static NOT_VALID:number =3; + +} diff --git a/workingUIKIT/src/app/login/utils/helper.class.ts b/workingUIKIT/src/app/login/utils/helper.class.ts new file mode 100644 index 00000000..337b49d4 --- /dev/null +++ b/workingUIKIT/src/app/login/utils/helper.class.ts @@ -0,0 +1,126 @@ +export class User { + email:string; + username: string; + id: string; + fullname: string; + expirationDate: number; + role:string; + jwt:string; + +} + +export class Session{ + public static setUser(user:User): User { + + localStorage.setItem("user", JSON.stringify(user)); + + return user; + } + + public static removeUser() { + if(Session.isLoggedIn()){ + localStorage.removeItem("user"); + } + } + public static getUser():User { + if(Session.isLoggedIn()){ + return JSON.parse(localStorage.getItem("user")); + }else{ + return null; + } + } + public static isLoggedIn(): boolean { + var loggedIn:boolean = false; + var user:User = null; + if( typeof localStorage !== 'undefined') { + if(localStorage.getItem("user")) { + user = JSON.parse(localStorage.getItem("user")); + if(user && user.id){ + loggedIn = true; + }else{ + loggedIn = false; + } + }else{ + loggedIn = false; + } + }else{ + loggedIn = false; + } + return loggedIn; + } + public static getUserJwt():string { + if(Session.isLoggedIn()){ + return Session.getUser().jwt; + }else{ + return null; + } + + } + public static getUserEmail():string { + if(Session.isLoggedIn()){ + return Session.getUser().email; + }else{ + return null; + } + + } + public static isAdminUser():boolean { + if(Session.isLoggedIn()){ + return (Session.getUser().role == '2'); + } + + } + public static isUserValid() { + if(Session.isLoggedIn()){ + var expires = Session.getUser().expirationDate; + var now = new Date().getTime() / 1000; + console.log(" is still valid ? "+(now +0 < expires) +" Remaining:"+ (expires - (now+0))+ " now is:"+now + "expires at:"+expires); + return now +0 < expires; + } + return false; + } + public static isValidAndRemove() { + if(Session.isLoggedIn()){ + if(!Session.isUserValid()){ + Session.removeUser(); + return false; + }else{ + return true; + } + }else{ + return false; + } + } + +} +export class MyJWT{ + private static validateJWTFormat(data){ + + if(data == null || (data.indexOf(".") !=-1 && data.split('.').length != 3)){ + return false; + } + return true; + } + private static getPayload(data){ + var payload = data.split('.')[1]; + return atob(payload); + } + public static parseUserInfo(data: any): User { + if(this.validateJWTFormat(data)){ + var info = JSON.parse(this.getPayload(data)); + } + var user: User = new User(); + + user.username = info.sub; + user.email = info.email; + user.id = info.userId; + user.fullname = info.fullname; + user.role = info.role; + user.jwt = data; + user.expirationDate = info.exp; + localStorage.setItem("user", JSON.stringify(user)); + return user; + } + + +} diff --git a/workingUIKIT/src/app/searchPages/advanced/advancedSearchDataProviders-routing.module.ts b/workingUIKIT/src/app/searchPages/advanced/advancedSearchDataProviders-routing.module.ts new file mode 100644 index 00000000..4c3fb074 --- /dev/null +++ b/workingUIKIT/src/app/searchPages/advanced/advancedSearchDataProviders-routing.module.ts @@ -0,0 +1,15 @@ +import { NgModule } from '@angular/core'; +import { RouterModule } from '@angular/router'; + +import{AdvancedSearchDataProvidersComponent} from './advancedSearchDataProviders.component'; +import {FreeGuard} from'../../login/freeGuard.guard'; + +@NgModule({ + imports: [ + RouterModule.forChild([ + { path: '', component: AdvancedSearchDataProvidersComponent, canActivate: [FreeGuard] } + + ]) + ] +}) +export class AdvancedSearchDataProvidersRoutingModule { } diff --git a/workingUIKIT/src/app/searchPages/advanced/advancedSearchDataProviders.component.ts b/workingUIKIT/src/app/searchPages/advanced/advancedSearchDataProviders.component.ts new file mode 100644 index 00000000..a18447f9 --- /dev/null +++ b/workingUIKIT/src/app/searchPages/advanced/advancedSearchDataProviders.component.ts @@ -0,0 +1,118 @@ +import {Component, Input, ViewChild} from '@angular/core'; +import {Observable} from 'rxjs/Observable'; +import { Router, ActivatedRoute} from '@angular/router'; +import {Filter, Value,AdvancedField} from '../searchUtils/searchHelperClasses.class'; +import {SearchDataprovidersService} from '../../services/searchDataproviders.service'; +import {SearchResult} from '../../utils/entities/searchResult'; +import {OpenaireProperties, ErrorCodes} from '../../utils/properties/openaireProperties'; +import {AdvancedSearchPageComponent} from '../searchUtils/advancedSearchPage.component'; +import {SearchFields} from '../../utils/properties/searchFields'; +import {SearchUtilsClass } from '../searchUtils/searchUtils.class'; + + + +@Component({ + selector: 'advanced-search-dataprovider', + template: ` + + + + ` + }) + +export class AdvancedSearchDataProvidersComponent { + public results =[]; + public filters =[]; + public searchUtils:SearchUtilsClass = new SearchUtilsClass(); + public searchFields:SearchFields = new SearchFields(); + + public fieldIds: string[] = this.searchFields.DATASOURCE_ADVANCED_FIELDS; + public fieldIdsMap= this.searchFields.DATASOURCE_FIELDS; + public selectedFields:AdvancedField[] = []; + + @ViewChild (AdvancedSearchPageComponent) searchPage : AdvancedSearchPageComponent ; + public resourcesQuery = "(oaftype exact datasource)"; + public csvParams: string; + + constructor (private route: ActivatedRoute, private _searchDataProvidersService: SearchDataprovidersService ) { + + this.results =[]; + var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status =errorCodes.LOADING; + this.searchUtils.baseUrl = OpenaireProperties.searchLinkToAdvancedDataProviders; + console.info("Con -base url:"+this.searchUtils.baseUrl ); + + } + ngOnInit() { + this.sub = this.route.queryParams.subscribe(params => { + let page = (params['page']=== undefined)?0:+params['page']; + this.searchUtils.page = ( page < 1 ) ? 1 : page; + this.searchPage.fieldIds = this.fieldIds; + this.selectedFields =[]; + this.searchPage.selectedFields = this.selectedFields; + this.searchPage.fieldIdsMap = this.fieldIdsMap; + this.searchPage.getSelectedFiltersFromUrl(params); + this.getResults(this.searchPage.createQueryParameters(), this.searchUtils.page, this.searchUtils.size); + + }); + } + ngOnDestroy() { + this.sub.unsubscribe(); + } + sub: any; + public getResults(parameters:string, page: number, size: number){ + if(parameters!= null && parameters != '' ) { + this.csvParams ="&type=datasources&query=( "+this.resourcesQuery + "and (" + parameters + "))"; + }else{ + this.csvParams ="&type=datasources&query="+this.resourcesQuery; + } + + var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = errorCodes.LOADING; + this.searchPage.openLoading(); + + console.info("Advanced Search Publications: Execute search query "+parameters); + this._searchDataProvidersService.advancedSearchDataproviders(parameters, page, size).subscribe( + data => { + this.searchUtils.totalResults = data[0]; + console.info("Adv Search Data providers total="+this.searchUtils.totalResults); + this.results = data[1]; + this.searchPage.updateBaseUrlWithParameters(); + var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = errorCodes.DONE; + if(this.searchUtils.totalResults == 0 ){ + this.searchUtils.status = errorCodes.NONE; + } + this.searchPage.closeLoading(); + + }, + err => { + console.log(err); + console.info("error"); + //TODO check erros (service not available, bad request) + // if( ){ + // this.searchUtils.status = errorCodes.ERROR; + // } + var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = errorCodes.NOT_AVAILABLE; + this.searchPage.closeLoading(); + + } + ); + } + + public queryChanged($event) { + var parameters = $event.value; + this.getResults(parameters, this.searchUtils.page,this.searchUtils.size); + console.info("queryChanged: Execute search query "+parameters); + + } + + +} diff --git a/workingUIKIT/src/app/searchPages/advanced/advancedSearchDataProviders.module.ts b/workingUIKIT/src/app/searchPages/advanced/advancedSearchDataProviders.module.ts new file mode 100644 index 00000000..b9f00af4 --- /dev/null +++ b/workingUIKIT/src/app/searchPages/advanced/advancedSearchDataProviders.module.ts @@ -0,0 +1,29 @@ +import { NgModule} from '@angular/core'; +import { CommonModule } from '@angular/common'; +import { FormsModule } from '@angular/forms'; + +import{ AdvancedSearchDataProvidersRoutingModule} from './advancedSearchDataProviders-routing.module'; +import{AdvancedSearchDataProvidersComponent} from './advancedSearchDataProviders.component'; + + +import {DataProvidersServiceModule} from '../../services/dataProvidersService.module'; + import {AdvancedSearchPageModule} from '../searchUtils/advancedSearchPage.module'; + import {FreeGuard} from'../../login/freeGuard.guard'; + +@NgModule({ + imports: [ + CommonModule, FormsModule, + DataProvidersServiceModule, + AdvancedSearchDataProvidersRoutingModule, AdvancedSearchPageModule + + ], + declarations: [ + AdvancedSearchDataProvidersComponent + ], + providers:[FreeGuard + ], + exports: [ + AdvancedSearchDataProvidersComponent + ] +}) +export class AdvancedSearchDataProvidersModule { } diff --git a/workingUIKIT/src/app/searchPages/advanced/advancedSearchDatasets-routing.module.ts b/workingUIKIT/src/app/searchPages/advanced/advancedSearchDatasets-routing.module.ts new file mode 100644 index 00000000..700d65f3 --- /dev/null +++ b/workingUIKIT/src/app/searchPages/advanced/advancedSearchDatasets-routing.module.ts @@ -0,0 +1,15 @@ +import { NgModule } from '@angular/core'; +import { RouterModule } from '@angular/router'; + +import{AdvancedSearchDatasetsComponent} from './advancedSearchDatasets.component'; +import {FreeGuard} from'../../login/freeGuard.guard'; + +@NgModule({ + imports: [ + RouterModule.forChild([ + { path: '', component: AdvancedSearchDatasetsComponent, canActivate: [FreeGuard] } + + ]) + ] +}) +export class AdvancedSearchDatasetsRoutingModule { } diff --git a/workingUIKIT/src/app/searchPages/advanced/advancedSearchDatasets.component.ts b/workingUIKIT/src/app/searchPages/advanced/advancedSearchDatasets.component.ts new file mode 100644 index 00000000..dc080ca5 --- /dev/null +++ b/workingUIKIT/src/app/searchPages/advanced/advancedSearchDatasets.component.ts @@ -0,0 +1,126 @@ +import {Component, Input, ViewChild} from '@angular/core'; +import {Observable} from 'rxjs/Observable'; +import { Router, ActivatedRoute} from '@angular/router'; +import {Filter, Value,AdvancedField} from '../searchUtils/searchHelperClasses.class'; +import {SearchDatasetsService} from '../../services/searchDatasets.service'; +import {SearchResult} from '../../utils/entities/searchResult'; +import {OpenaireProperties, ErrorCodes} from '../../utils/properties/openaireProperties'; +import {AdvancedSearchPageComponent} from '../searchUtils/advancedSearchPage.component'; +import {SearchFields} from '../../utils/properties/searchFields'; +import {SearchUtilsClass } from '../searchUtils/searchUtils.class'; + + +@Component({ + selector: 'advanced-search-datasets', + template: ` + + + + ` + }) + +export class AdvancedSearchDatasetsComponent { + public results =[]; + public filters =[]; + + public searchUtils:SearchUtilsClass = new SearchUtilsClass(); + + public searchFields:SearchFields = new SearchFields(); + + + public fieldIds: string[] = this.searchFields.RESULT_ADVANCED_FIELDS; + public fieldIdsMap= this.searchFields.RESULT_FIELDS; + public selectedFields:AdvancedField[] = []; + + @ViewChild (AdvancedSearchPageComponent) searchPage : AdvancedSearchPageComponent ; + public resourcesQuery = "( (oaftype exact result) and (resulttypeid exact dataset) )"; + public csvParams: string; + + constructor (private route: ActivatedRoute, private _searchDatasetsService: SearchDatasetsService ) { + + this.results =[]; + var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status =errorCodes.LOADING; + this.searchUtils.baseUrl = OpenaireProperties.searchLinkToAdvancedDatasets; + + + + } + ngOnInit() { + var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status =errorCodes.LOADING; + this.sub = this.route.queryParams.subscribe(params => { + let page = (params['page']=== undefined)?1:+params['page']; + this.searchUtils.page = ( page <= 0 ) ? 1 : page; + this.searchPage.fieldIds = this.fieldIds; + this.selectedFields =[]; + this.searchPage.selectedFields = this.selectedFields; + this.searchPage.fieldIdsMap = this.fieldIdsMap; + this.searchPage.getSelectedFiltersFromUrl(params); + this.getResults(this.searchPage.createQueryParameters(), this.searchUtils.page, this.searchUtils.size); + + }); + } + ngOnDestroy() { + this.sub.unsubscribe(); + } + sub: any; + public getResults(parameters:string, page: number, size: number){ + if(parameters!= null && parameters != '' ) { + this.csvParams ="&type=datasets&query=( "+this.resourcesQuery + "and (" + parameters + "))"; + }else{ + this.csvParams ="&type=datasets&query="+this.resourcesQuery; + } + + var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = errorCodes.LOADING; + this.searchPage.openLoading(); + + console.info("Advanced Search Datasets: Execute search query "+parameters); + this._searchDatasetsService.advancedSearchDatasets(parameters, page, size).subscribe( + data => { + this.searchUtils.totalResults = data[0]; + console.info("search Datasets total="+this.searchUtils.totalResults); + this.results = data[1]; + this.searchPage.updateBaseUrlWithParameters(); + var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = errorCodes.DONE; + if(this.searchUtils.totalResults == 0 ){ + this.searchUtils.status = errorCodes.NONE; + } + this.searchPage.closeLoading(); + + }, + err => { + console.log(err); + console.info("error"); + //TODO check erros (service not available, bad request) + // if( ){ + // this.searchUtils.status = errorCodes.ERROR; + // } + var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = errorCodes.NOT_AVAILABLE; + this.searchPage.closeLoading(); + + } + ); + } + private setFilters(){ + //TODO set filters from + } + + public queryChanged($event) { + var parameters = $event.value; + this.getResults(parameters, this.searchUtils.page,this.searchUtils.size); + console.info("queryChanged: Execute search query "+parameters); + + } + + +} diff --git a/workingUIKIT/src/app/searchPages/advanced/advancedSearchDatasets.module.ts b/workingUIKIT/src/app/searchPages/advanced/advancedSearchDatasets.module.ts new file mode 100644 index 00000000..5a38795c --- /dev/null +++ b/workingUIKIT/src/app/searchPages/advanced/advancedSearchDatasets.module.ts @@ -0,0 +1,29 @@ +import { NgModule} from '@angular/core'; +import { CommonModule } from '@angular/common'; +import { FormsModule } from '@angular/forms'; + +import{ AdvancedSearchDatasetsRoutingModule} from './advancedSearchDatasets-routing.module'; +import{AdvancedSearchDatasetsComponent} from './advancedSearchDatasets.component'; + + +import {DatasetsServiceModule} from '../../services/datasetsService.module'; + import {AdvancedSearchPageModule} from '../searchUtils/advancedSearchPage.module'; + import {FreeGuard} from'../../login/freeGuard.guard'; + +@NgModule({ + imports: [ + CommonModule, FormsModule, + DatasetsServiceModule, + AdvancedSearchDatasetsRoutingModule, AdvancedSearchPageModule + + ], + declarations: [ + AdvancedSearchDatasetsComponent + ], + providers:[FreeGuard + ], + exports: [ + AdvancedSearchDatasetsComponent + ] +}) +export class AdvancedSearchDatasetsModule { } diff --git a/workingUIKIT/src/app/searchPages/advanced/advancedSearchOrganizations-routing.module.ts b/workingUIKIT/src/app/searchPages/advanced/advancedSearchOrganizations-routing.module.ts new file mode 100644 index 00000000..c04401bc --- /dev/null +++ b/workingUIKIT/src/app/searchPages/advanced/advancedSearchOrganizations-routing.module.ts @@ -0,0 +1,15 @@ +import { NgModule } from '@angular/core'; +import { RouterModule } from '@angular/router'; + +import{AdvancedSearchOrganizationsComponent} from './advancedSearchOrganizations.component'; +import {FreeGuard} from'../../login/freeGuard.guard'; + +@NgModule({ + imports: [ + RouterModule.forChild([ + { path: '', component: AdvancedSearchOrganizationsComponent , canActivate: [FreeGuard]} + + ]) + ] +}) +export class AdvancedSearchOrganizationsRoutingModule { } diff --git a/workingUIKIT/src/app/searchPages/advanced/advancedSearchOrganizations.component.ts b/workingUIKIT/src/app/searchPages/advanced/advancedSearchOrganizations.component.ts new file mode 100644 index 00000000..8eea4a37 --- /dev/null +++ b/workingUIKIT/src/app/searchPages/advanced/advancedSearchOrganizations.component.ts @@ -0,0 +1,124 @@ +import {Component, Input, ViewChild} from '@angular/core'; +import {Observable} from 'rxjs/Observable'; +import { Router, ActivatedRoute} from '@angular/router'; +import {Filter, Value,AdvancedField} from '../searchUtils/searchHelperClasses.class'; +import {SearchOrganizationsService} from '../../services/searchOrganizations.service'; +import {SearchResult} from '../../utils/entities/searchResult'; +import {OpenaireProperties, ErrorCodes} from '../../utils/properties/openaireProperties'; +import {AdvancedSearchPageComponent} from '../searchUtils/advancedSearchPage.component'; +import {SearchFields} from '../../utils/properties/searchFields'; +import {SearchUtilsClass } from '../searchUtils/searchUtils.class'; + + +@Component({ + selector: 'advanced-search-organizations', + template: ` + + + + ` + }) + +export class AdvancedSearchOrganizationsComponent { + public results =[]; + public filters =[]; + public searchUtils:SearchUtilsClass = new SearchUtilsClass(); + public searchFields:SearchFields = new SearchFields(); + + public fieldIds: string[] = this.searchFields.ORGANIZATION_ADVANCED_FIELDS; + public fieldIdsMap = this.searchFields.ORGANIZATION_FIELDS; + public selectedFields:AdvancedField[] = []; + public csvParams: string; + + @ViewChild (AdvancedSearchPageComponent) searchPage : AdvancedSearchPageComponent ; + +public resourcesQuery = "(oaftype exact organization)"; + constructor (private route: ActivatedRoute, private _searchOrganizationsService: SearchOrganizationsService ) { + + this.results =[]; + var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status =errorCodes.LOADING; + this.searchUtils.baseUrl = OpenaireProperties.searchLinkToAdvancedOrganizations; + + + + } + ngOnInit() { + var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status =errorCodes.LOADING; + + this.sub = this.route.queryParams.subscribe(params => { + let page = (params['page']=== undefined)?1:+params['page']; + this.searchUtils.page = ( page <= 0 ) ? 1 : page; + this.searchPage.fieldIds = this.fieldIds; + this.selectedFields =[]; + this.searchPage.selectedFields = this.selectedFields; + this.searchPage.fieldIdsMap = this.fieldIdsMap; + this.searchPage.getSelectedFiltersFromUrl(params); + this.getResults(this.searchPage.createQueryParameters(), this.searchUtils.page, this.searchUtils.size); + + }); + } + ngOnDestroy() { + this.sub.unsubscribe(); + } + sub: any; + public getResults(parameters:string, page: number, size: number){ + if(parameters!= null && parameters != '' ) { + this.csvParams ="&type=organizations&query=( "+this.resourcesQuery + "and (" + parameters + "))"; + }else{ + this.csvParams ="&type=organizations&query="+this.resourcesQuery; + } + + var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = errorCodes.LOADING; + this.searchPage.openLoading(); + + console.info("Advanced Search Organizations: Execute search query "+parameters); + this._searchOrganizationsService.advancedSearchOrganizations(parameters, page, size).subscribe( + data => { + this.searchUtils.totalResults = data[0]; + console.info("search Organizations total="+this.searchUtils.totalResults); + this.results = data[1]; + this.searchPage.updateBaseUrlWithParameters(); + var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = errorCodes.DONE; + if(this.searchUtils.totalResults == 0 ){ + this.searchUtils.status = errorCodes.NONE; + } + this.searchPage.closeLoading(); + + }, + err => { + console.log(err); + console.info("error"); + //TODO check erros (service not available, bad request) + // if( ){ + // this.searchUtils.status = errorCodes.ERROR; + // } + var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = errorCodes.NOT_AVAILABLE; + this.searchPage.closeLoading(); + + } + ); + } + private setFilters(){ + //TODO set filters from + } + + public queryChanged($event) { + var parameters = $event.value; + this.getResults(parameters, this.searchUtils.page,this.searchUtils.size); + console.info("queryChanged: Execute search query "+parameters); + + } + + +} diff --git a/workingUIKIT/src/app/searchPages/advanced/advancedSearchOrganizations.module.ts b/workingUIKIT/src/app/searchPages/advanced/advancedSearchOrganizations.module.ts new file mode 100644 index 00000000..aff4b1c7 --- /dev/null +++ b/workingUIKIT/src/app/searchPages/advanced/advancedSearchOrganizations.module.ts @@ -0,0 +1,29 @@ +import { NgModule} from '@angular/core'; +import { CommonModule } from '@angular/common'; +import { FormsModule } from '@angular/forms'; + +import{ AdvancedSearchOrganizationsRoutingModule} from './advancedSearchOrganizations-routing.module'; +import{AdvancedSearchOrganizationsComponent} from './advancedSearchOrganizations.component'; + + +import {OrganizationsServiceModule} from '../../services/organizationsService.module'; + import {AdvancedSearchPageModule} from '../searchUtils/advancedSearchPage.module'; + import {FreeGuard} from'../../login/freeGuard.guard'; + +@NgModule({ + imports: [ + CommonModule, FormsModule, + OrganizationsServiceModule, + AdvancedSearchOrganizationsRoutingModule, AdvancedSearchPageModule + + ], + declarations: [ + AdvancedSearchOrganizationsComponent + ], + providers:[FreeGuard + ], + exports: [ + AdvancedSearchOrganizationsComponent + ] +}) +export class AdvancedSearchOrganizationsModule { } diff --git a/workingUIKIT/src/app/searchPages/advanced/advancedSearchPeople-routing.module.ts b/workingUIKIT/src/app/searchPages/advanced/advancedSearchPeople-routing.module.ts new file mode 100644 index 00000000..5bd4d9a5 --- /dev/null +++ b/workingUIKIT/src/app/searchPages/advanced/advancedSearchPeople-routing.module.ts @@ -0,0 +1,15 @@ +import { NgModule } from '@angular/core'; +import { RouterModule } from '@angular/router'; + +import{AdvancedSearchPeopleComponent} from './advancedSearchPeople.component'; +import {FreeGuard} from'../../login/freeGuard.guard'; + +@NgModule({ + imports: [ + RouterModule.forChild([ + { path: '', component: AdvancedSearchPeopleComponent, canActivate: [FreeGuard] } + + ]) + ] +}) +export class AdvancedSearchPeopleRoutingModule { } diff --git a/workingUIKIT/src/app/searchPages/advanced/advancedSearchPeople.component.ts b/workingUIKIT/src/app/searchPages/advanced/advancedSearchPeople.component.ts new file mode 100644 index 00000000..7a2325ba --- /dev/null +++ b/workingUIKIT/src/app/searchPages/advanced/advancedSearchPeople.component.ts @@ -0,0 +1,125 @@ +import {Component, Input, ViewChild} from '@angular/core'; +import {Observable} from 'rxjs/Observable'; +import { Router, ActivatedRoute} from '@angular/router'; +import {Filter, Value,AdvancedField} from '../searchUtils/searchHelperClasses.class'; +import {SearchPeopleService} from '../../services/searchPeople.service'; +import {SearchResult} from '../../utils/entities/searchResult'; +import {OpenaireProperties, ErrorCodes} from '../../utils/properties/openaireProperties'; +import {AdvancedSearchPageComponent} from '../searchUtils/advancedSearchPage.component'; +import {SearchFields} from '../../utils/properties/searchFields'; +import {SearchUtilsClass } from '../searchUtils/searchUtils.class'; + + +@Component({ + selector: 'advanced-search-organizations', + template: ` + + + + ` + }) + +export class AdvancedSearchPeopleComponent { + public results =[]; + public filters =[]; + + public searchUtils:SearchUtilsClass = new SearchUtilsClass(); + + public searchFields:SearchFields = new SearchFields(); + + public fieldIds: string[] = this.searchFields.PERSON_ADVANCED_FIELDS; + public fieldIdsMap = this.searchFields.PERSON_FIELDS; + public selectedFields:AdvancedField[] = []; + + @ViewChild (AdvancedSearchPageComponent) searchPage : AdvancedSearchPageComponent ; + public resourcesQuery = "(oaftype exact person)"; + public csvParams: string; + + constructor (private route: ActivatedRoute, private _searchPeopleService: SearchPeopleService ) { + + this.results =[]; + var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status =errorCodes.LOADING; + this.searchUtils.baseUrl = OpenaireProperties.searchLinkToAdvancedPeople; + + + + } + ngOnInit() { + var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status =errorCodes.LOADING; + this.sub = this.route.queryParams.subscribe(params => { + let page = (params['page']=== undefined)?1:+params['page']; + this.searchUtils.page = ( page <= 0 ) ? 1 : page; + this.searchPage.fieldIds = this.fieldIds; + this.selectedFields =[]; + this.searchPage.selectedFields = this.selectedFields; + this.searchPage.fieldIdsMap = this.fieldIdsMap; + this.searchPage.getSelectedFiltersFromUrl(params); + this.getResults(this.searchPage.createQueryParameters(), this.searchUtils.page, this.searchUtils.size); + + }); + } + ngOnDestroy() { + this.sub.unsubscribe(); + } + sub: any; + public getResults(parameters:string, page: number, size: number){ + if(parameters!= null && parameters != '' ) { + this.csvParams ="&type=people&query=( "+this.resourcesQuery + "and (" + parameters + "))"; + }else{ + this.csvParams ="&type=people&query="+this.resourcesQuery; + } + + var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = errorCodes.LOADING; + this.searchPage.openLoading(); + + console.info("Advanced Search People: Execute search query "+parameters); + this._searchPeopleService.advancedSearchPeople(parameters, page, size).subscribe( + data => { + this.searchUtils.totalResults = data[0]; + console.info("search People total="+this.searchUtils.totalResults); + this.results = data[1]; + this.searchPage.updateBaseUrlWithParameters(); + var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = errorCodes.DONE; + if(this.searchUtils.totalResults == 0 ){ + this.searchUtils.status = errorCodes.NONE; + } + this.searchPage.closeLoading(); + + }, + err => { + console.log(err); + console.info("error"); + //TODO check erros (service not available, bad request) + // if( ){ + // this.searchUtils.status = errorCodes.ERROR; + // } + var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = errorCodes.NOT_AVAILABLE; + this.searchPage.closeLoading(); + + } + ); + } + private setFilters(){ + //TODO set filters from + } + + public queryChanged($event) { + var parameters = $event.value; + this.getResults(parameters, this.searchUtils.page,this.searchUtils.size); + console.info("queryChanged: Execute search query "+parameters); + + } + + +} diff --git a/workingUIKIT/src/app/searchPages/advanced/advancedSearchPeople.module.ts b/workingUIKIT/src/app/searchPages/advanced/advancedSearchPeople.module.ts new file mode 100644 index 00000000..7500f792 --- /dev/null +++ b/workingUIKIT/src/app/searchPages/advanced/advancedSearchPeople.module.ts @@ -0,0 +1,29 @@ +import { NgModule} from '@angular/core'; +import { CommonModule } from '@angular/common'; +import { FormsModule } from '@angular/forms'; + +import{ AdvancedSearchPeopleRoutingModule} from './advancedSearchPeople-routing.module'; +import{AdvancedSearchPeopleComponent} from './advancedSearchPeople.component'; + + +import {PeopleServiceModule} from '../../services/peopleService.module'; + import {AdvancedSearchPageModule} from '../searchUtils/advancedSearchPage.module'; + import {FreeGuard} from'../../login/freeGuard.guard'; + +@NgModule({ + imports: [ + CommonModule, FormsModule, + PeopleServiceModule, + AdvancedSearchPeopleRoutingModule, AdvancedSearchPageModule + + ], + declarations: [ + AdvancedSearchPeopleComponent + ], + providers:[FreeGuard + ], + exports: [ + AdvancedSearchPeopleComponent + ] +}) +export class AdvancedSearchPeopleModule { } diff --git a/workingUIKIT/src/app/searchPages/advanced/advancedSearchProjects-routing.module.ts b/workingUIKIT/src/app/searchPages/advanced/advancedSearchProjects-routing.module.ts new file mode 100644 index 00000000..edf916e8 --- /dev/null +++ b/workingUIKIT/src/app/searchPages/advanced/advancedSearchProjects-routing.module.ts @@ -0,0 +1,15 @@ +import { NgModule } from '@angular/core'; +import { RouterModule } from '@angular/router'; + +import{AdvancedSearchProjectsComponent} from './advancedSearchProjects.component'; +import {FreeGuard} from'../../login/freeGuard.guard'; + +@NgModule({ + imports: [ + RouterModule.forChild([ + { path: '', component: AdvancedSearchProjectsComponent, canActivate: [FreeGuard] } + + ]) + ] +}) +export class AdvancedSearchProjectsRoutingModule { } diff --git a/workingUIKIT/src/app/searchPages/advanced/advancedSearchProjects.component.ts b/workingUIKIT/src/app/searchPages/advanced/advancedSearchProjects.component.ts new file mode 100644 index 00000000..d1a0bd92 --- /dev/null +++ b/workingUIKIT/src/app/searchPages/advanced/advancedSearchProjects.component.ts @@ -0,0 +1,124 @@ +import {Component, Input, ViewChild} from '@angular/core'; +import {Observable} from 'rxjs/Observable'; +import { Router, ActivatedRoute} from '@angular/router'; +import {Filter, Value,AdvancedField} from '../searchUtils/searchHelperClasses.class'; +import {SearchProjectsService} from '../../services/searchProjects.service'; +import {SearchResult} from '../../utils/entities/searchResult'; +import {OpenaireProperties, ErrorCodes} from '../../utils/properties/openaireProperties'; +import {AdvancedSearchPageComponent} from '../searchUtils/advancedSearchPage.component'; +import {SearchFields} from '../../utils/properties/searchFields'; +import {SearchUtilsClass } from '../searchUtils/searchUtils.class'; + +@Component({ + selector: 'advanced-search-projects', + template: ` + + + + ` + }) + +export class AdvancedSearchProjectsComponent { + public results =[]; + public filters =[]; + + public searchUtils:SearchUtilsClass = new SearchUtilsClass(); + + public searchFields:SearchFields = new SearchFields(); + + public fieldIds: string[] = this.searchFields.PROJECT_ADVANCED_FIELDS; + public fieldIdsMap = this.searchFields.PROJECT_FIELDS; + public selectedFields:AdvancedField[] = []; + + @ViewChild (AdvancedSearchPageComponent) searchPage : AdvancedSearchPageComponent ; + public resourcesQuery = "(oaftype exact project)"; + public csvParams: string; + + constructor (private route: ActivatedRoute, private _searchProjectsService: SearchProjectsService ) { + + this.results =[]; + var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status =errorCodes.LOADING; + this.searchUtils.baseUrl = OpenaireProperties.searchLinkToAdvancedProjects; + + + + } + ngOnInit() { + var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status =errorCodes.LOADING; + this.sub = this.route.queryParams.subscribe(params => { + let page = (params['page']=== undefined)?1:+params['page']; + this.searchUtils.page = ( page <= 0 ) ? 1 : page; + this.searchPage.fieldIds = this.fieldIds; + this.selectedFields =[]; + this.searchPage.selectedFields = this.selectedFields; + this.searchPage.fieldIdsMap = this.fieldIdsMap; + this.searchPage.getSelectedFiltersFromUrl(params); + this.getResults(this.searchPage.createQueryParameters(), this.searchUtils.page, this.searchUtils.size); + + }); + } + ngOnDestroy() { + this.sub.unsubscribe(); + } + sub: any; + public getResults(parameters:string, page: number, size: number){ + if(parameters!= null && parameters != '' ) { + this.csvParams ="&type=projects&query=( "+this.resourcesQuery + "and (" + parameters + "))"; + }else{ + this.csvParams ="&type=projects&query="+this.resourcesQuery; + } + + var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = errorCodes.LOADING; + this.searchPage.openLoading(); + + console.info("Advanced Search Publications: Execute search query "+parameters); + this._searchProjectsService.advancedSearchProjects(parameters, page, size).subscribe( + data => { + this.searchUtils.totalResults = data[0]; + console.info("Advanced Search Projects total="+this.searchUtils.totalResults); + this.results = data[1]; + this.searchPage.updateBaseUrlWithParameters(); + var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = errorCodes.DONE; + if(this.searchUtils.totalResults == 0 ){ + this.searchUtils.status = errorCodes.NONE; + } + this.searchPage.closeLoading(); + + }, + err => { + console.log(err); + console.info("error"); + //TODO check erros (service not available, bad request) + // if( ){ + // this.searchUtils.status = errorCodes.ERROR; + // } + var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = errorCodes.NOT_AVAILABLE; + this.searchPage.closeLoading(); + + } + ); + } + private setFilters(){ + //TODO set filters from + } + + public queryChanged($event) { + var parameters = $event.value; + this.getResults(parameters, this.searchUtils.page,this.searchUtils.size); + console.info("queryChanged: Execute search query "+parameters); + + } + + +} diff --git a/workingUIKIT/src/app/searchPages/advanced/advancedSearchProjects.module.ts b/workingUIKIT/src/app/searchPages/advanced/advancedSearchProjects.module.ts new file mode 100644 index 00000000..6357286b --- /dev/null +++ b/workingUIKIT/src/app/searchPages/advanced/advancedSearchProjects.module.ts @@ -0,0 +1,29 @@ +import { NgModule} from '@angular/core'; +import { CommonModule } from '@angular/common'; +import { FormsModule } from '@angular/forms'; + +import{ AdvancedSearchProjectsRoutingModule} from './advancedSearchProjects-routing.module'; +import{AdvancedSearchProjectsComponent} from './advancedSearchProjects.component'; + + +import {ProjectsServiceModule} from '../../services/projectsService.module'; + import {AdvancedSearchPageModule} from '../searchUtils/advancedSearchPage.module'; + import {FreeGuard} from'../../login/freeGuard.guard'; + +@NgModule({ + imports: [ + CommonModule, FormsModule, + ProjectsServiceModule, + AdvancedSearchProjectsRoutingModule, AdvancedSearchPageModule + + ], + declarations: [ + AdvancedSearchProjectsComponent + ], + providers:[FreeGuard + ], + exports: [ + AdvancedSearchProjectsComponent + ] +}) +export class AdvancedSearchProjectsModule { } diff --git a/workingUIKIT/src/app/searchPages/advanced/advancedSearchPublications-routing.module.ts b/workingUIKIT/src/app/searchPages/advanced/advancedSearchPublications-routing.module.ts new file mode 100644 index 00000000..f56f4348 --- /dev/null +++ b/workingUIKIT/src/app/searchPages/advanced/advancedSearchPublications-routing.module.ts @@ -0,0 +1,15 @@ +import { NgModule } from '@angular/core'; +import { RouterModule } from '@angular/router'; + +import{AdvancedSearchPublicationsComponent} from './advancedSearchPublications.component'; +import {FreeGuard} from'../../login/freeGuard.guard'; + +@NgModule({ + imports: [ + RouterModule.forChild([ + { path: '', component: AdvancedSearchPublicationsComponent, canActivate: [FreeGuard] } + + ]) + ] +}) +export class AdvancedSearchPublicationsRoutingModule { } diff --git a/workingUIKIT/src/app/searchPages/advanced/advancedSearchPublications.component.ts b/workingUIKIT/src/app/searchPages/advanced/advancedSearchPublications.component.ts new file mode 100644 index 00000000..4b803551 --- /dev/null +++ b/workingUIKIT/src/app/searchPages/advanced/advancedSearchPublications.component.ts @@ -0,0 +1,122 @@ +import {Component, Input, ViewChild} from '@angular/core'; +import {Observable} from 'rxjs/Observable'; +import { Router, ActivatedRoute} from '@angular/router'; +import {Filter, Value,AdvancedField} from '../searchUtils/searchHelperClasses.class'; +import {SearchPublicationsService} from '../../services/searchPublications.service'; +import {SearchResult} from '../../utils/entities/searchResult'; +import {OpenaireProperties, ErrorCodes} from '../../utils/properties/openaireProperties'; +import {AdvancedSearchPageComponent} from '../searchUtils/advancedSearchPage.component'; +import {SearchFields} from '../../utils/properties/searchFields'; +import {SearchUtilsClass } from '../searchUtils/searchUtils.class'; + + +@Component({ + selector: 'advanced-search-publications', + template: ` + + + ` + }) + +export class AdvancedSearchPublicationsComponent { + public results =[]; + public filters =[]; + public searchUtils:SearchUtilsClass = new SearchUtilsClass(); + + public searchFields:SearchFields = new SearchFields(); + + public fieldIds: string[] = this.searchFields.RESULT_ADVANCED_FIELDS; + public fieldIdsMap= this.searchFields.RESULT_FIELDS; + public selectedFields:AdvancedField[] = []; + public resourcesQuery = "((oaftype exact result) and (resulttypeid exact publication))"; + public csvParams: string; + + @ViewChild (AdvancedSearchPageComponent) searchPage : AdvancedSearchPageComponent ; + + + constructor (private route: ActivatedRoute, private _searchPublicationsService: SearchPublicationsService ) { + + this.results =[]; + var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status =errorCodes.LOADING; + this.searchUtils.baseUrl = OpenaireProperties.searchLinkToAdvancedPublications; + + + + } + ngOnInit() { + var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status =errorCodes.LOADING; + this.sub = this.route.queryParams.subscribe(params => { + let page = (params['page']=== undefined)?1:+params['page']; + this.searchUtils.page = ( page <= 0 ) ? 1 : page; + this.searchPage.fieldIds = this.fieldIds; + this.selectedFields =[]; + this.searchPage.selectedFields = this.selectedFields; + this.searchPage.fieldIdsMap = this.fieldIdsMap; + + this.searchPage.getSelectedFiltersFromUrl(params); + this.getResults(this.searchPage.createQueryParameters(), this.searchUtils.page, this.searchUtils.size); + + }); + } + ngOnDestroy() { + this.sub.unsubscribe(); + } + sub: any; + public getResults(parameters:string, page: number, size: number){ + if(parameters!= null && parameters != '' ) { + this.csvParams ="&type=publications&query=("+this.resourcesQuery +" and (" + parameters + "))"; + }else{ + this.csvParams ="&type=publications&query="+this.resourcesQuery; + } + + var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = errorCodes.LOADING; + this.searchPage.openLoading(); + + console.info("Advanced Search Publications: Execute search query "+parameters); + this._searchPublicationsService.advancedSearchPublications(parameters, page, size).subscribe( + data => { + this.searchUtils.totalResults = data[0]; + console.info("searchPubl total="+this.searchUtils.totalResults); + this.results = data[1]; + this.searchPage.updateBaseUrlWithParameters(); + var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = errorCodes.DONE; + if(this.searchUtils.totalResults == 0 ){ + this.searchUtils.status = errorCodes.NONE; + } + this.searchPage.closeLoading(); + + }, + err => { + console.log(err); + console.info("error"); + //TODO check erros (service not available, bad request) + // if( ){ + // this.searchUtils.status = ErrorCodes.ERROR; + // } + var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = errorCodes.NOT_AVAILABLE; + this.searchPage.closeLoading(); + + } + ); + } + + public queryChanged($event) { + var parameters = $event.value; + this.getResults(parameters, this.searchUtils.page,this.searchUtils.size); + console.info("queryChanged: Execute search query "+parameters); + + } + + +} diff --git a/workingUIKIT/src/app/searchPages/advanced/advancedSearchPublications.module.ts b/workingUIKIT/src/app/searchPages/advanced/advancedSearchPublications.module.ts new file mode 100644 index 00000000..35f5ac18 --- /dev/null +++ b/workingUIKIT/src/app/searchPages/advanced/advancedSearchPublications.module.ts @@ -0,0 +1,29 @@ +import { NgModule} from '@angular/core'; +import { CommonModule } from '@angular/common'; +import { FormsModule } from '@angular/forms'; + +import{ AdvancedSearchPublicationsRoutingModule} from './advancedSearchPublications-routing.module'; +import{AdvancedSearchPublicationsComponent} from './advancedSearchPublications.component'; + + +import {PublicationsServiceModule} from '../../services/publicationsService.module'; + import {AdvancedSearchPageModule} from '../searchUtils/advancedSearchPage.module'; + import {FreeGuard} from'../../login/freeGuard.guard'; + +@NgModule({ + imports: [ + CommonModule, FormsModule, + PublicationsServiceModule, + AdvancedSearchPublicationsRoutingModule, AdvancedSearchPageModule + + ], + declarations: [ + AdvancedSearchPublicationsComponent + ], + providers:[FreeGuard + ], + exports: [ + AdvancedSearchPublicationsComponent + ] +}) +export class AdvancedSearchPublicationsModule { } diff --git a/workingUIKIT/src/app/searchPages/dataProviders/compatibleDataProviders-routing.module.ts b/workingUIKIT/src/app/searchPages/dataProviders/compatibleDataProviders-routing.module.ts new file mode 100644 index 00000000..58111a67 --- /dev/null +++ b/workingUIKIT/src/app/searchPages/dataProviders/compatibleDataProviders-routing.module.ts @@ -0,0 +1,15 @@ +import { NgModule } from '@angular/core'; +import { RouterModule } from '@angular/router'; + +import{SearchCompatibleDataprovidersComponent} from './compatibleDataProviders.component'; +import {FreeGuard} from'../../login/freeGuard.guard'; + +@NgModule({ + imports: [ + RouterModule.forChild([ + { path: '', component: SearchCompatibleDataprovidersComponent, canActivate: [FreeGuard] } + + ]) + ] +}) +export class CompatibleDataProvidersRoutingModule { } diff --git a/workingUIKIT/src/app/searchPages/dataProviders/compatibleDataProviders.component.ts b/workingUIKIT/src/app/searchPages/dataProviders/compatibleDataProviders.component.ts new file mode 100644 index 00000000..447da76e --- /dev/null +++ b/workingUIKIT/src/app/searchPages/dataProviders/compatibleDataProviders.component.ts @@ -0,0 +1,192 @@ +import {Component, Input, ViewChild} from '@angular/core'; +import { ActivatedRoute} from '@angular/router'; + +import { Filter, Value} from '../searchUtils/searchHelperClasses.class'; + +import {SearchDataprovidersService} from '../../services/searchDataproviders.service'; +import {SearchResult} from '../../utils/entities/searchResult'; +import {OpenaireProperties, ErrorCodes} from '../../utils/properties/openaireProperties'; +import {SearchFields} from '../../utils/properties/searchFields'; +import {SearchPageComponent } from '../searchUtils/searchPage.component'; +import {SearchUtilsClass } from '../searchUtils/searchUtils.class'; +import {ExportCSVComponent} from '../../utils/exportCSV.class'; + +@Component({ + selector: 'search-dataproviders', + template: ` + + + + + + ` + +}) +export class SearchCompatibleDataprovidersComponent { + public results =[]; + public filters =[]; + public baseUrl:string; + public searchUtils:SearchUtilsClass = new SearchUtilsClass(); + public sub: any; public subResults: any; + public _location:Location; + public searchFields:SearchFields = new SearchFields(); + public refineFields: string[] = this.searchFields.COMPATIBLE_DATAPROVIDER_FIELDS; + public fieldIdsMap= this.searchFields.DATASOURCE_FIELDS; + public _prefixQueryFields: {field:string,opName:string,opValue:string,values:string[]}[] =[{field:"compatibility",opName:"cm",opValue:"not", values:["UNKNOWN","hostedBy","notCompatible"]},{field:"type",opName:"tp",opValue:"not",values: ["other"]}]; + // ["entityregistry","entityregistry::projects","entityregistry::repositories"]}]; + public _prefixQuery: string = ""; + + public CSV: any = { "columnNames": [ "Title", "Type", "Coutries", "Compatibility" ], + "export":[] + }; + public CSVDownloaded = false; + public resourcesQuery = "&query=((oaftype exact datasource) not(datasourcecompatibilityid = UNKNOWN) not(datasourcecompatibilityid = hostedBy) not(datasourcecompatibilityid = notCompatible) not(datasourcetypeuiid = other))"; + public csvParams: string; + + @ViewChild (SearchPageComponent) searchPage : SearchPageComponent ; + + constructor (private route: ActivatedRoute, private _searchDataprovidersService: SearchDataprovidersService ) { + var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status =errorCodes.LOADING; + this.baseUrl = OpenaireProperties.getLinkToSearchCompatibleDataProviders(); + for(var i = 0; i < this._prefixQueryFields.length; i++ ){ + for(var j =0; j < this._prefixQueryFields[i].values.length; j++){ + this._prefixQuery+="&" + this._prefixQueryFields[i].field + "=" + + this._prefixQueryFields[i].values[j] + "&" + + this._prefixQueryFields[i].opName + "=" + this._prefixQueryFields[i].opValue; + } + } + this._prefixQuery+="&"; + } + + public ngOnInit() { + this.searchPage.refineFields = this.refineFields; + this.searchPage.fieldIdsMap = this.fieldIdsMap; + this.sub = this.route.queryParams.subscribe(params => { + this.searchUtils.keyword = (params['keyword']?params['keyword']:''); + this.searchUtils.page = (params['page']=== undefined)?1:+params['page']; + this.filters = this.createFilters(); + var queryParameters = this.searchPage.getIndexQueryParametersFromUrl(params); + this._getResults(queryParameters, false, this.searchUtils.page, this.searchUtils.size); + }); + } + + public ngOnDestroy() { + if(this.sub){ + this.sub.unsubscribe(); + } + if(this.subResults){ + this.subResults.unsubscribe(); + } } + private _getResults(parameters:string,refine:boolean, page: number, size: number){ + this.csvParams = parameters+this.resourcesQuery+"&type=datasources"; + + var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = errorCodes.LOADING; + this.searchPage.openLoading(); + + this.subResults = this._searchDataprovidersService.searchCompatibleDataproviders(parameters,(refine)?this.searchPage.getRefineFieldsQuery():null, page, size, []).subscribe( + data => { + this.searchUtils.totalResults = data[0]; + console.info("search Data Providers: [Parameters:"+parameters+" ] [total results:"+this.searchUtils.totalResults+"]"); + this.results = data[1]; + this.searchPage.checkSelectedFilters(this.filters); + this.searchPage.updateBaseUrlWithParameters(this.filters); + var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = errorCodes.DONE; + if(this.searchUtils.totalResults == 0 ){ + this.searchUtils.status = errorCodes.NONE; + } + this.searchPage.closeLoading(); + + }, + err => { + console.log(err); + //TODO check erros (service not available, bad request) + // if( ){ + // this.searchUtils.status = ErrorCodes.ERROR; + // } + var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = errorCodes.ERROR; + this.searchPage.closeLoading(); + + } + ); + } + private setFilters(){ + //TODO set filters from + } + + public queryChanged($event) { + var parameters = $event.index; + console.info("queryChanged: Execute search query "+parameters); + + this._getResults(parameters, false, this.searchUtils.page, this.searchUtils.size); + } + private createFilters():Filter[] { + var filter_names=["Type","Compatibility Level"]; + var filter_ids=["datasourcetypeuiid","datasourcecompatibilityname"]; + var searchFields = new SearchFields(); + var filter_original_ids = searchFields.COMPATIBLE_DATAPROVIDER_FIELDS; + var value_names=[ + [ + "Institutional Publication Repository","Thematic Publication Repository", "Other Publication Repository", + "Institutional Repositories Aggregators", + "Thematic Repositories Aggregators", "Other Repositories Aggregators", + "Data Repositories", "Data Repositories Aggregators", "Journals", "Journals Aggregators", "CRIS Systems", "Publication Catalogues"], + ["OpenAIRE Basic (DRIVER OA)","OpenAIRE 2.0 (EC funding)", "OpenAIRE 2.0+ (DRIVER OA, EC funding)", "OpenAIRE 3.0 (OA, funding)","OpenAIRE Data (funded, referenced datasets)"]]; + + var value_original_ids=[ + ["pubsrepository::institutional","pubsrepository::thematic", "pubsrepository::unknown", "aggregator::pubsrepository::thematic","aggregator::pubsrepository::institutional","aggregator::pubsrepository::unknown", + "datarepository::unknown", "aggregator::datarepository", "pubsrepository::journal", "aggregator::pubsrepository::journals", "cris", "pubscatalogue::unknown"], + //["driver","openaire2.0", "driver-openaire2.0", "openaire3.0","openaire2.0_data"] + ["OpenAIRE Basic (DRIVER OA)","OpenAIRE 2.0 (EC funding)", "OpenAIRE 2.0+ (DRIVER OA, EC funding)", "OpenAIRE 3.0 (OA, funding)","OpenAIRE Data (funded, referenced datasets)"]]; + var filters: Filter[] =[]; + for(var i =0 ; i < filter_names.length;i++){ + var values:Value[] = []; + for(var j =0 ; j < value_names[i].length;j++){ + var value:Value = {name: value_names[i][j], id: value_original_ids[i][j], number:j, selected:false} + values.push(value); + } + var filter:Filter = {title: filter_names[i], filterId: filter_ids[i], originalFilterId: filter_original_ids[i], values : values, countSelectedValues:0, "filterOperator": 'or' }; + filters.push(filter); + } + return filters; + } + + public downloadClicked($event) { + if(!this.CSVDownloaded) { + this.CSVDownloaded = false; + + var parameters = $event.value; + + //this.getResultsCSV(parameters, false, 1, 1000); + + this._searchDataprovidersService.searchCompatibleDataprovidersCSV(parameters,this.searchPage.getRefineFieldsQuery(), 1, 1000).subscribe( + data => { + this.CSV.export = data; + ExportCSVComponent.downloadCSV(this.CSV, "compatibleDataproviders.csv"); + + var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = errorCodes.DONE; + }, + err => { + console.log(err); + //TODO check erros (service not available, bad request) + // if( ){ + // this.searchUtils.status = ErrorCodes.ERROR; + // } + var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = errorCodes.ERROR; + } + ); + } + } + +} diff --git a/workingUIKIT/src/app/searchPages/dataProviders/compatibleDataProviders.module.ts b/workingUIKIT/src/app/searchPages/dataProviders/compatibleDataProviders.module.ts new file mode 100644 index 00000000..ecf4518f --- /dev/null +++ b/workingUIKIT/src/app/searchPages/dataProviders/compatibleDataProviders.module.ts @@ -0,0 +1,31 @@ +import { NgModule} from '@angular/core'; +import { CommonModule } from '@angular/common'; +import { FormsModule } from '@angular/forms'; + +import{ CompatibleDataProvidersRoutingModule} from './compatibleDataProviders-routing.module'; +import{SearchCompatibleDataprovidersComponent} from './compatibleDataProviders.component'; + +import {SearchResultsModule } from '../searchUtils/searchResults.module'; + +import {DataProvidersServiceModule} from '../../services/dataProvidersService.module'; +import {SearchFormModule} from '../searchUtils/searchForm.module'; +import {SearchPageModule} from '../searchUtils/searchPage.module'; +import {FreeGuard} from'../../login/freeGuard.guard'; + +@NgModule({ + imports: [ + CommonModule, FormsModule, + DataProvidersServiceModule, + SearchFormModule, SearchResultsModule, CompatibleDataProvidersRoutingModule, SearchPageModule + + ], + declarations: [ + SearchCompatibleDataprovidersComponent + ], + providers:[FreeGuard + ], + exports: [ + SearchCompatibleDataprovidersComponent + ] +}) +export class CompatibleDataProvidersModule { } diff --git a/workingUIKIT/src/app/searchPages/dataProviders/datasourceTableView.component.ts b/workingUIKIT/src/app/searchPages/dataProviders/datasourceTableView.component.ts new file mode 100644 index 00000000..af525ec4 --- /dev/null +++ b/workingUIKIT/src/app/searchPages/dataProviders/datasourceTableView.component.ts @@ -0,0 +1,74 @@ +import {Component, Input, ViewChild} from '@angular/core'; + + +@Component({ + selector: 'table-view', + template: ` + + + + + + + + + + + + + + + + + + +
NameTypeCountryInstitutionCompatibility
+ +

+ {{result['title'].name}} +

+

+ {{result['title'].url}} +

+
+
{{result['type']}}.... + + + {{organization.name}} + + + {{organization.name}} + + , + + ....
+ + + ` + +}) +export class DatasourceTableViewComponent { + @Input() datasources =[]; + // private results:{name:string, type:string, organizations:string, countries:string, compatibility:string}[] = []; + constructor () { + + } + + public ngOnInit() { + // // var results:{name:string, type:string, organizations:string, countries:string, compatibility:string}[] = [] + // for(var i =0; i < this.datasources.length; i++){ + // var datasource: {name:string, type:string, organizations:string, countries:string, compatibility:string} = {name:"",type:"",organizations:"", countries:"", compatibility:""}; + // datasource.name = '' + (this.datasources[i]['title'].name)?this.datasources[i]['title'].name:this.datasources[i]['title'].url +''; + // datasource.type = this.datasources[i]['type']; + // this.results.push(datasource); + // } + } + + public ngOnDestroy() { + + } + sort(){ + // objs.sort(function(a,b) {return (a.last_nom > b.last_nom) ? 1 : ((b.last_nom > a.last_nom) ? -1 : 0);} ); + } + +} diff --git a/workingUIKIT/src/app/searchPages/dataProviders/entityRegistries-routing.module.ts b/workingUIKIT/src/app/searchPages/dataProviders/entityRegistries-routing.module.ts new file mode 100644 index 00000000..46ea5b44 --- /dev/null +++ b/workingUIKIT/src/app/searchPages/dataProviders/entityRegistries-routing.module.ts @@ -0,0 +1,15 @@ +import { NgModule } from '@angular/core'; +import { RouterModule } from '@angular/router'; + +import{SearchEntityRegistriesComponent} from './entityRegistries.component'; +import {FreeGuard} from'../../login/freeGuard.guard'; + +@NgModule({ + imports: [ + RouterModule.forChild([ + { path: '', component: SearchEntityRegistriesComponent, canActivate: [FreeGuard] } + + ]) + ] +}) +export class EntityRegistriesRoutingModule { } diff --git a/workingUIKIT/src/app/searchPages/dataProviders/entityRegistries.component.ts b/workingUIKIT/src/app/searchPages/dataProviders/entityRegistries.component.ts new file mode 100644 index 00000000..3ba48242 --- /dev/null +++ b/workingUIKIT/src/app/searchPages/dataProviders/entityRegistries.component.ts @@ -0,0 +1,191 @@ +import {Component, Input, ViewChild} from '@angular/core'; +import { ActivatedRoute} from '@angular/router'; + +import { Filter, Value} from '../searchUtils/searchHelperClasses.class'; + +import {SearchDataprovidersService} from '../../services/searchDataproviders.service'; +import {SearchResult} from '../../utils/entities/searchResult'; +import {OpenaireProperties, ErrorCodes} from '../../utils/properties/openaireProperties'; +import {SearchFields} from '../../utils/properties/searchFields'; +import {SearchPageComponent } from '../searchUtils/searchPage.component'; +import {SearchUtilsClass } from '../searchUtils/searchUtils.class'; +import {ExportCSVComponent} from '../../utils/exportCSV.class'; + +@Component({ + selector: 'search-entity-registries', + template: ` + + + + + ` + +}) +export class SearchEntityRegistriesComponent { + public results =[]; + public filters =[]; + public baseUrl:string; + public searchUtils:SearchUtilsClass = new SearchUtilsClass(); + public sub: any; public subResults: any; + public _location:Location; + public searchFields:SearchFields = new SearchFields(); + public refineFields: string[] = this.searchFields.ENTITY_REGISTRIES_FIELDS; + public fieldIdsMap= this.searchFields.DATASOURCE_FIELDS; + public _prefixQueryFields: {field:string,opName:string,opValue:string,values:string[]}[] =[ + {field:"type",opName:"tp",opValue:"and",values: ["other"]}]; + // ["entityregistry","entityregistry::projects","entityregistry::repositories"]}]; + public _prefixQuery: string = ""; + + public CSV: any = { "columnNames": [ "Title", "Type", "Coutries", "Compatibility" ], + "export":[] + }; + public CSVDownloaded = false; + + @ViewChild (SearchPageComponent) searchPage : SearchPageComponent ; + public resourcesQuery = "&query=((oaftype exact datasource) and(datasourcetypeuiid = other))"; + public csvParams: string; + + constructor (private route: ActivatedRoute, private _searchDataprovidersService: SearchDataprovidersService ) { + var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status =errorCodes.LOADING; + this.baseUrl = OpenaireProperties.getLinkToSearchEntityRegistries(); + for(var i = 0; i < this._prefixQueryFields.length; i++ ){ + for(var j =0; j < this._prefixQueryFields[i].values.length; j++){ + this._prefixQuery+="&" + this._prefixQueryFields[i].field + "=" + + this._prefixQueryFields[i].values[j] + "&" + + this._prefixQueryFields[i].opName + "=" + this._prefixQueryFields[i].opValue; + } + } + this._prefixQuery+="&"; + } + + public ngOnInit() { + this.searchPage.refineFields = this.refineFields; + this.searchPage.fieldIdsMap = this.fieldIdsMap; + this.sub = this.route.queryParams.subscribe(params => { + this.searchUtils.keyword = (params['keyword']?params['keyword']:''); + this.searchUtils.page = (params['page']=== undefined)?1:+params['page']; + this.filters = this.createFilters(); + + var queryParameters = this.searchPage.getIndexQueryParametersFromUrl(params); + this._getResults(queryParameters, false, this.searchUtils.page, this.searchUtils.size); + }); + } + + public ngOnDestroy() { + if(this.sub){ + this.sub.unsubscribe(); + } + if(this.subResults){ + this.subResults.unsubscribe(); + } } + private _getResults(parameters:string,refine:boolean, page: number, size: number){ + this.csvParams = parameters+this.resourcesQuery+"&type=datasources"; + + var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = errorCodes.LOADING; + this.searchPage.openLoading(); + + this.subResults = this._searchDataprovidersService.searchEntityRegistries(parameters,(refine)?this.searchPage.getRefineFieldsQuery():null, page, size, []).subscribe( + data => { + this.searchUtils.totalResults = data[0]; + console.info("search Entity Registries: [Parameters:"+parameters+" ] [total results:"+this.searchUtils.totalResults+"]"); + this.results = data[1]; + this.searchPage.checkSelectedFilters(this.filters); + this.searchPage.updateBaseUrlWithParameters(this.filters); + var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = errorCodes.DONE; + if(this.searchUtils.totalResults == 0 ){ + this.searchUtils.status = errorCodes.NONE; + } + this.searchPage.closeLoading(); + + }, + err => { + console.log(err); + //TODO check erros (service not available, bad request) + // if( ){ + // this.searchUtils.status = ErrorCodes.ERROR; + // } + var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = errorCodes.ERROR; + this.searchPage.closeLoading(); + + } + ); + } + private setFilters(){ + //TODO set filters from + } + + public queryChanged($event) { + var parameters = $event.index; + console.info("queryChanged: Execute search query "+parameters); + this._getResults(parameters, false, this.searchUtils.page, this.searchUtils.size); + } + private createFilters():Filter[] { + var filter_names=["Type","Compatibility Level"]; + var filter_ids=["datasourcetypename","datasourcecompatibilityname"]; + var searchFields = new SearchFields(); + var filter_original_ids = searchFields.ENTITY_REGISTRIES_FIELDS; + var value_names=[ + ["Funder database","Registry of repositories","Scholarly Comm. Infrastructure","Registry","Information Space","Web Source"], + + ["OpenAIRE Basic (DRIVER OA)","OpenAIRE 2.0 (EC funding)", "OpenAIRE 2.0+ (DRIVER OA, EC funding)", "OpenAIRE 3.0 (OA, funding)","OpenAIRE Data (funded, referenced datasets)"]]; + + var value_original_ids=[ + ["Funder database","Registry of repositories","Scholarly Comm. Infrastructure","Registry","Information Space","Web Source"], + //["entityregistry::projects","entityregistry::repositories","scholarcomminfra","entityregistry","infospace","websource"], + //["driver","openaire2.0", "driver-openaire2.0", "openaire3.0","openaire2.0_data"] + ["OpenAIRE Basic (DRIVER OA)","OpenAIRE 2.0 (EC funding)", "OpenAIRE 2.0+ (DRIVER OA, EC funding)", "OpenAIRE 3.0 (OA, funding)","OpenAIRE Data (funded, referenced datasets)"]]; + + var filters: Filter[] =[]; + for(var i =0 ; i < filter_names.length;i++){ + var values:Value[] = []; + for(var j =0 ; j < value_names[i].length;j++){ + var value:Value = {name: value_names[i][j], id: value_original_ids[i][j], number:j, selected:false} + values.push(value); + } + var filter:Filter = {title: filter_names[i], filterId: filter_ids[i], originalFilterId: filter_original_ids[i], values : values, countSelectedValues:0, "filterOperator": 'or' }; + filters.push(filter); + } + return filters; + } + + + + public downloadClicked($event) { + if(!this.CSVDownloaded) { + this.CSVDownloaded = false; + + var parameters = $event.value; + + //this.getResultsCSV(parameters, false, 1, 1000); + + this._searchDataprovidersService.searchEntityRegistriesCSV(parameters, this.searchPage.getRefineFieldsQuery(), 1, 1000).subscribe( + data => { + this.CSV.export = data; + ExportCSVComponent.downloadCSV(this.CSV, "etityRegistries.csv"); + + var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = errorCodes.DONE; + }, + err => { + console.log(err); + //TODO check erros (service not available, bad request) + // if( ){ + // this.searchUtils.status = ErrorCodes.ERROR; + // } + var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = errorCodes.ERROR; + } + ); + } + } +} diff --git a/workingUIKIT/src/app/searchPages/dataProviders/entityRegistries.module.ts b/workingUIKIT/src/app/searchPages/dataProviders/entityRegistries.module.ts new file mode 100644 index 00000000..a05f1dd4 --- /dev/null +++ b/workingUIKIT/src/app/searchPages/dataProviders/entityRegistries.module.ts @@ -0,0 +1,31 @@ +import { NgModule} from '@angular/core'; +import { CommonModule } from '@angular/common'; +import { FormsModule } from '@angular/forms'; + +import{ EntityRegistriesRoutingModule} from './entityRegistries-routing.module'; +import{SearchEntityRegistriesComponent} from './entityRegistries.component'; + +import {SearchResultsModule } from '../searchUtils/searchResults.module'; + +import {DataProvidersServiceModule} from '../../services/dataProvidersService.module'; +import {SearchFormModule} from '../searchUtils/searchForm.module'; +import {SearchPageModule} from '../searchUtils/searchPage.module'; +import {FreeGuard} from'../../login/freeGuard.guard'; + +@NgModule({ + imports: [ + CommonModule, FormsModule, + DataProvidersServiceModule, + SearchFormModule, SearchResultsModule, EntityRegistriesRoutingModule, SearchPageModule + + ], + declarations: [ + SearchEntityRegistriesComponent + ], + providers:[FreeGuard + ], + exports: [ + SearchEntityRegistriesComponent + ] +}) +export class EntityRegistriesModule { } diff --git a/workingUIKIT/src/app/searchPages/find/mainSearch-routing.module.ts b/workingUIKIT/src/app/searchPages/find/mainSearch-routing.module.ts new file mode 100644 index 00000000..ab4c3d22 --- /dev/null +++ b/workingUIKIT/src/app/searchPages/find/mainSearch-routing.module.ts @@ -0,0 +1,15 @@ +import { NgModule } from '@angular/core'; +import { RouterModule } from '@angular/router'; + +import{SearchComponent} from './search.component'; +import {FreeGuard} from'../../login/freeGuard.guard'; + +@NgModule({ + imports: [ + RouterModule.forChild([ + { path: '', component: SearchComponent, canActivate: [FreeGuard] } + + ]) + ] +}) +export class MainSearchRoutingModule { } diff --git a/workingUIKIT/src/app/searchPages/find/mainSearch.module.ts b/workingUIKIT/src/app/searchPages/find/mainSearch.module.ts new file mode 100644 index 00000000..4d63b1b3 --- /dev/null +++ b/workingUIKIT/src/app/searchPages/find/mainSearch.module.ts @@ -0,0 +1,38 @@ +import { NgModule} from '@angular/core'; +import { CommonModule } from '@angular/common'; +import { FormsModule } from '@angular/forms'; +import { RouterModule } from '@angular/router'; + +import{MainSearchRoutingModule} from './mainSearch-routing.module'; +import{SearchComponent} from './search.component'; + +import {SearchResultsModule } from '../searchUtils/searchResults.module'; + +import {DataProvidersServiceModule} from '../../services/dataProvidersService.module'; +import {DatasetsServiceModule} from '../../services/datasetsService.module'; +import {ProjectsServiceModule} from '../../services/projectsService.module'; +import {PublicationsServiceModule} from '../../services/publicationsService.module'; +import {OrganizationsServiceModule} from '../../services/organizationsService.module'; +import {PeopleServiceModule} from '../../services/peopleService.module'; +import {BrowseEntitiesModule} from '../searchUtils/browseEntities.module'; +import {SearchFormModule} from '../searchUtils/searchForm.module'; +import {FreeGuard} from'../../login/freeGuard.guard'; + +@NgModule({ + imports: [ + CommonModule, FormsModule, RouterModule, + DataProvidersServiceModule, DatasetsServiceModule, ProjectsServiceModule, + PublicationsServiceModule, OrganizationsServiceModule, PeopleServiceModule, + BrowseEntitiesModule, SearchFormModule, SearchResultsModule, MainSearchRoutingModule + + ], + declarations: [ + SearchComponent + ], + providers:[FreeGuard + ], + exports: [ + SearchComponent + ] +}) +export class MainSearchModule { } diff --git a/workingUIKIT/src/app/searchPages/find/search.component.ts b/workingUIKIT/src/app/searchPages/find/search.component.ts new file mode 100644 index 00000000..82acb91d --- /dev/null +++ b/workingUIKIT/src/app/searchPages/find/search.component.ts @@ -0,0 +1,466 @@ +import {Component, Input, Output, EventEmitter, ViewChild, ChangeDetectionStrategy, ViewEncapsulation} from '@angular/core'; +import {Observable} from 'rxjs/Observable'; +import {ActivatedRoute, Router} from '@angular/router'; +import {Location} from '@angular/common'; + +import { Meta, MetaDefinition} from '../../../angular2-meta'; + +import { FetchPublications } from '../../utils/fetchEntitiesClasses/fetchPublications.class'; +import { FetchDataproviders } from '../../utils/fetchEntitiesClasses/fetchDataproviders.class'; +import { FetchProjects } from '../../utils/fetchEntitiesClasses/fetchProjects.class'; +import { FetchDatasets } from '../../utils/fetchEntitiesClasses/fetchDatasets.class'; +import { FetchOrganizations } from '../../utils/fetchEntitiesClasses/fetchOrganizations.class'; +import { FetchPeople } from '../../utils/fetchEntitiesClasses/fetchPeople.class'; + +import {SearchPublicationsService} from '../../services/searchPublications.service'; +import {SearchDataprovidersService} from '../../services/searchDataproviders.service'; +import {SearchProjectsService} from '../../services/searchProjects.service'; +import {SearchDatasetsService} from '../../services/searchDatasets.service'; +import {SearchPeopleService} from '../../services/searchPeople.service'; +import {SearchOrganizationsService} from '../../services/searchOrganizations.service'; + +import {OpenaireProperties} from '../../utils/properties/openaireProperties'; +import {SearchFields} from '../../utils/properties/searchFields'; +import {ErrorCodes} from '../../utils/properties/openaireProperties'; +import {RouterHelper} from '../../utils/routerHelper.class'; + +@Component({ + changeDetection: ChangeDetectionStrategy.Default, + encapsulation: ViewEncapsulation.Emulated, + selector: 'search-find', + template: ` +
+ + + ` +}) +export class SearchComponent { + public sub: any; + + public reloadPublications: boolean; + public reloadDatasets: boolean; + public reloadProjects: boolean; + public reloadDataproviders: boolean; + public reloadOrganizations: boolean; + public reloadPeople: boolean; + + + public pageTitle = "Search in OpenAIRE" + public keyword:string = ""; + public publications:string[]; + public datasets:string[]; + public projectsTab:string[]; + public dataproviders:string[]; + public organizations:string[]; + public people:string[]; + + public activeTab = "publications"; + public linkToSearchPublications = ""; + public linkToSearchProjects = ""; + public linkToSearchDataproviders = ""; + public linkToSearchDatasets = ""; + public linkToSearchOrganizations = ""; + public linkToSearchPeople = ""; + + public fetchPublications : FetchPublications; + public fetchDataproviders : FetchDataproviders; + public fetchProjects : FetchProjects; + public fetchDatasets: FetchDatasets; + public fetchOrganizations: FetchOrganizations; + public fetchPeople: FetchPeople; + + public searchFields:SearchFields = new SearchFields(); + public errorCodes:ErrorCodes = new ErrorCodes(); + public routerHelper:RouterHelper = new RouterHelper(); + +public subPub;public subData;public subProjects;public subOrg;public subPeople; public subDataPr; + constructor ( private route: ActivatedRoute, + private _searchPublicationsService: SearchPublicationsService, + private _searchDataprovidersService: SearchDataprovidersService, + private _searchProjectsService: SearchProjectsService, + private _searchDatasetsService: SearchDatasetsService, + private _searchOrganizationsService: SearchOrganizationsService, + private _searchPeopleService: SearchPeopleService, + private location: Location, private _meta: Meta ) { + this.fetchPublications = new FetchPublications(this._searchPublicationsService); + this.fetchDataproviders = new FetchDataproviders(this._searchDataprovidersService); + this.fetchProjects = new FetchProjects(this._searchProjectsService); + this.fetchDatasets = new FetchDatasets( this._searchDatasetsService); + this.fetchOrganizations = new FetchOrganizations( this._searchOrganizationsService); + this.fetchPeople = new FetchPeople(this._searchPeopleService); + var description = "open access, research, scientific publication, European Commission, EC, FP7, ERC, Horizon 2020, H2020, search, projects "; + var title = "Search publications, datasets, projects... | OpenAIRE"; + this._meta.setTitle(title); + this._meta.updateMeta("description", description); + this._meta.updateMeta("og:description", description); + this._meta.updateMeta("og:title", title); + } + + public ngOnInit() { + this.sub = this.route.queryParams.subscribe(params => { + this.keyword = (params['keyword'])?params['keyword']:""; + if(this.keyword !=null && this.keyword.length > 0){ + this.reloadTabs(); + this.searchPublications(); + this.count(); + } + }); + + } + public ngOnDestroy() { + this.sub.unsubscribe(); + if(this.keyword !=null && this.keyword.length > 0){ + if(this.subPub){ + this.subPub.unsubscribe(); + } + if(this.subData){ + this.subData.unsubscribe(); + } + if(this.subProjects){ + this.subProjects.unsubscribe(); + } + if(this.subOrg){ + this.subOrg.unsubscribe(); + } + if(this.subPeople){ + this.subPeople.unsubscribe(); + } + if(this.subDataPr){ + this.subDataPr.unsubscribe(); + } + + } + } + public searchPublications() { + this.activeTab = "publications"; + if(this.reloadPublications) { + this.reloadPublications = false; + this.fetchPublications.getResultsByKeyword(this.keyword, 1, 10); + this.linkToSearchPublications = OpenaireProperties.getLinkToSearchPublications();// + "?keyword=" + this.keyword; + } + } + public searchDatasets() { + this.activeTab = "datasets"; + if(this.reloadDatasets) { + this.reloadDatasets = false; + this.fetchDatasets.getResultsByKeyword(this.keyword, 1, 10); + this.linkToSearchDatasets = OpenaireProperties.getLinkToSearchDatasets();// + "?keyword=" + this.keyword; + } + } + public searchProjects() { + this.activeTab = "projects"; + if(this.reloadProjects) { + this.reloadProjects = false; + this.fetchProjects.getResultsByKeyword(this.keyword, 1, 10); + this.linkToSearchProjects = OpenaireProperties.getLinkToSearchProjects();// + "?keyword=" + this.keyword; + } + } + public searchDataProviders() { + this.activeTab = "dataproviders"; + if(this.reloadDataproviders) { + this.reloadDataproviders = false; + this.fetchDataproviders.getResultsByKeyword(this.keyword, 1, 10); + this.linkToSearchDataproviders = OpenaireProperties.getLinkToSearchDataProviders();// + "?keyword=" + this.keyword; + } + } + public searchOrganizations() { + this.activeTab = "organizations"; + if(this.reloadOrganizations) { + this.reloadOrganizations = false; + this.fetchOrganizations.getResultsByKeyword(this.keyword, 1, 10); + this.linkToSearchOrganizations = OpenaireProperties.getLinkToSearchOrganizations();// + "?keyword=" + this.keyword; + } + } + public searchPeople() { + this.activeTab = "people"; + if(this.reloadPeople) { + this.reloadPeople = false; + this.fetchPeople.getResultsByKeyword(this.keyword, 1, 10); + this.linkToSearchPeople = OpenaireProperties.getLinkToSearchPeople();// + "?keyword=" + this.keyword; + } + } + + public keywordChanged($event){ + this.keyword = $event.value; + console.info("Search Find: search with keyword \"" + this.keyword + "\"" ); + this.location.go(location.pathname,"?keyword=" + this.keyword); + this.reloadTabs(); + if(this.activeTab == "publications") { + this.searchPublications(); + } + if(this.activeTab == "projects") { + this.searchProjects(); + } + if(this.activeTab == "dataproviders") { + this.searchDataProviders(); + } + if(this.activeTab == "datasets") { + this.searchDatasets(); + } + if(this.activeTab == "organizations") { + this.searchOrganizations(); + } + if(this.activeTab == "people") { + this.searchPeople(); + } + this.count(); + } + + private count() { + if(this.activeTab != "publications"){ + this.fetchPublications.searchUtils.status = this.errorCodes.LOADING; + this.subPub = this._searchPublicationsService.numOfSearchPublications(this.keyword).subscribe( + data => { + console.log("Count results: "+data); + this.fetchPublications.searchUtils.totalResults = data; + this.fetchPublications.searchUtils.status = this.errorCodes.DONE; + }, + err => { + console.log(err); + this.fetchPublications.searchUtils.status = this.errorCodes.ERROR; + } + ); + } + if(this.activeTab != "datasets"){ + this.fetchDatasets.searchUtils.status = this.errorCodes.LOADING; + this.subData = this._searchDatasetsService.numOfSearchDatasets(this.keyword).subscribe( + data => { + this.fetchDatasets.searchUtils.totalResults = data; + this.fetchDatasets.searchUtils.status = this.errorCodes.DONE; + }, + err => { + console.log(err); + this.fetchDatasets.searchUtils.status = this.errorCodes.ERROR; + } + ); + } + if(this.activeTab != "projects"){ + this.fetchProjects.searchUtils.status = this.errorCodes.LOADING; + this.subProjects = this._searchProjectsService.numOfSearchProjects(this.keyword).subscribe( + data => { + this.fetchProjects.searchUtils.totalResults = data; + this.fetchProjects.searchUtils.status = this.errorCodes.DONE; + }, + err => { + console.log(err); + this.fetchProjects.searchUtils.status = this.errorCodes.ERROR; + } + ); + } + if(this.activeTab != "dataproviders"){ + this.fetchDataproviders.getNumForSearch(this.keyword); + } + if(this.activeTab != "organizations"){ + this.fetchOrganizations.searchUtils.status = this.errorCodes.LOADING; + this.subOrg = this._searchOrganizationsService.numOfSearchOrganizations(this.keyword).subscribe( + data => { + this.fetchOrganizations.searchUtils.totalResults = data; + this.fetchOrganizations.searchUtils.status = this.errorCodes.DONE; + + }, + err => { + console.log(err); + this.fetchOrganizations.searchUtils.status = this.errorCodes.ERROR; + + } + ); + } + if(this.activeTab != "people"){ + this.fetchPeople.searchUtils.status = this.errorCodes.LOADING; + this.subPeople = this._searchPeopleService.numOfSearchPeople(this.keyword).subscribe( + data => { + this.fetchPeople.searchUtils.totalResults = data; + this.fetchPeople.searchUtils.status = this.errorCodes.DONE; + + }, + err => { + console.log(err); + this.fetchPeople.searchUtils.status = this.errorCodes.ERROR; + + } + ); + } + + } + + private reloadTabs() { + this.reloadPublications = true; + this.reloadDatasets = true; + this.reloadProjects = true; + this.reloadDataproviders = true; + this.reloadOrganizations = true; + this.reloadPeople = true; + } + +} diff --git a/workingUIKIT/src/app/searchPages/searchUtils/advancedSearchForm.component.ts b/workingUIKIT/src/app/searchPages/searchUtils/advancedSearchForm.component.ts new file mode 100644 index 00000000..01b4091c --- /dev/null +++ b/workingUIKIT/src/app/searchPages/searchUtils/advancedSearchForm.component.ts @@ -0,0 +1,150 @@ +import {Component, Input, Output, EventEmitter, ElementRef} from '@angular/core'; +import {Observable} from 'rxjs/Observable'; +import { Subject } from 'rxjs/Subject'; + +import {AdvancedField, OPERATOR} from '../searchUtils/searchHelperClasses.class'; +import {SearchFields} from '../../utils/properties/searchFields'; +import {Dates} from '../../utils/string-utils.class'; + +@Component({ + selector: 'advanced-search-form', + template: ` +
+ + + + + + + + + + + + + + + + +
Search for: + + + + + + + + Yes
+
+ + No
+
+
+ + +
+
+ +
+ +
+ + ` +}) +export class AdvancedSearchFormComponent { + @Input() entityType; + @Input() fieldIds: string[]; + @Input() fieldIdsMap; + @Input() selectedFields:AdvancedField[]; + @Output() queryChange = new EventEmitter(); + newFieldId:string; + newFieldName:string; + fieldList:{[id:string]:any[]} = {}; + public searchFields:SearchFields = new SearchFields(); + + public operators: [{name:string, id:string}] = this.searchFields.ADVANCED_SEARCH_OPERATORS; + constructor () { + } + + ngOnInit() { + for(var i = 0; i < this.fieldIds.length; i++){ + this.fieldList[this.fieldIds[i]]=[]; + } + this.newFieldId = this.fieldIds[0]; + this.newFieldName = this.fieldIdsMap[this.newFieldId].name; + } + + queryChanged() { + this.queryChange.emit({ + // selectedFields: this.selectedFields, + // selectedQuantifiers: this.selectedQuantifiers, + // keywords: this.keywords + }); + } + + addField() { + this.newFieldId = this.fieldIds[0]; + var type = this.fieldIdsMap[this.newFieldId].type; + if(type == "boolean"){ + this.selectedFields.push(new AdvancedField(this.newFieldId,this.fieldIdsMap[this.newFieldId].param, this.fieldIdsMap[this.newFieldId].name, type, "true", "and")); + }else{ + this.selectedFields.push(new AdvancedField(this.newFieldId, this.fieldIdsMap[this.newFieldId].param,this.fieldIdsMap[this.newFieldId].name, type, "", "and")); + } + + } + + removeField(index: number) { + this.selectedFields.splice(index, 1); + + } + + fieldOperatorChanged(index: number, operatorId: string, operatorName: string) { + this.selectedFields[index].operatorId = operatorId; + this.selectedFields[index].operatorName = operatorName; + } + validateDate(index: number, value: string){ + this.selectedFields[index].valid = Dates.isValidYear(value); + } + + fieldIdsChanged(index: number, fieldId:string ) { + console.log("Field index::"+index + " " + this.selectedFields[index].id + " function id:" +fieldId); + + var id= this.fieldIds[0]; + this.selectedFields[index].name = this.fieldIdsMap[id].name; + this.selectedFields[index].type = this.fieldIdsMap[id].type; + this.selectedFields[index].value = ""; + this.selectedFields[index].param = this.fieldIdsMap[id].param; + + var id =fieldId;//this.selectedFields[index].id; + this.selectedFields[index].name = this.fieldIdsMap[id].name; + this.selectedFields[index].type = this.fieldIdsMap[id].type; + this.selectedFields[index].value = ""; + this.selectedFields[index].param = this.fieldIdsMap[id].param; + if(this.fieldIdsMap[id].type == "boolean"){ + this.selectedFields[index].value = "true"; + } + } + valueChanged($event,index:number){ + this.selectedFields[index].value = $event.value; + } + listUpdated($event,fieldId:number){ + this.fieldList[fieldId] = $event.value; + } + +} diff --git a/workingUIKIT/src/app/searchPages/searchUtils/advancedSearchForm.module.ts b/workingUIKIT/src/app/searchPages/searchUtils/advancedSearchForm.module.ts new file mode 100644 index 00000000..1ee2f437 --- /dev/null +++ b/workingUIKIT/src/app/searchPages/searchUtils/advancedSearchForm.module.ts @@ -0,0 +1,26 @@ +import { NgModule} from '@angular/core'; +import { CommonModule } from '@angular/common'; +import { FormsModule } from '@angular/forms'; + +import{AdvancedSearchFormComponent} from './advancedSearchForm.component'; +import {EntitiesAutocompleteModule} from '../../utils/entitiesAutoComplete/entitiesAutoComplete.module'; +import {StaticAutocompleteModule} from '../../utils/staticAutoComplete/staticAutoComplete.module'; +import {DateFilterModule} from './dateFilter.module'; + + +@NgModule({ + imports: [ + CommonModule, FormsModule, EntitiesAutocompleteModule, StaticAutocompleteModule, DateFilterModule + ], + declarations: [ + AdvancedSearchFormComponent, +], + + providers:[ + ], + exports: [ + AdvancedSearchFormComponent + + ] +}) +export class AdvancedSearchFormModule { } diff --git a/workingUIKIT/src/app/searchPages/searchUtils/advancedSearchPage.component.ts b/workingUIKIT/src/app/searchPages/searchUtils/advancedSearchPage.component.ts new file mode 100644 index 00000000..d161b1c5 --- /dev/null +++ b/workingUIKIT/src/app/searchPages/searchUtils/advancedSearchPage.component.ts @@ -0,0 +1,272 @@ +import {Component, Input, ViewChild, Output, EventEmitter} from '@angular/core'; +import {Observable} from 'rxjs/Observable'; +import {Location} from '@angular/common'; +import {Filter, Value,AdvancedField} from '../searchUtils/searchHelperClasses.class'; +import {SearchResult} from '../../utils/entities/searchResult'; +import {SearchFields} from '../../utils/properties/searchFields'; +import {SearchUtilsClass} from './searchUtils.class'; +import {ModalLoading} from '../../utils/modal/loading.component'; +import {StringUtils, Dates} from '../../utils/string-utils.class'; +import { Meta} from '../../../angular2-meta'; + + +@Component({ + selector: 'advanced-search-page', + template: ` + +
+ +
+ Simple search + + + + + +
+ + +
+ +
+
+ + + ` +}) +export class AdvancedSearchPageComponent { + @Input() pageTitle = ""; + @Input() results = []; + @Input() type; + @Input() entityType; + @Input() searchUtils:SearchUtilsClass = new SearchUtilsClass(); + @Input() fieldIds: string[]; + @Input() fieldIdsMap;//:{ [key:string]:{ name:string, operator:string, type:string, indexField:string, equalityOperator:string }} ; + @Input() selectedFields:AdvancedField[]; + @Input() simpleSearchUrl: string; + @ViewChild (ModalLoading) loading : ModalLoading ; + @Input() csvParams: string; + @Input() csvPath: string; + @Input() simpleSearchLink: string = ""; + + + + public parameterNames:string[] =[]; + public parameterValues:string[] =[]; + + public urlParam: string; + public baseURLWithParameters:string = ''; + + @Output() queryChange = new EventEmitter(); + constructor (private location: Location, private _meta: Meta) { + } + + ngOnInit() { + this.updateTitle("Advanced search "+this.pageTitle); + this.updateDescription("Openaire, search, repositories, open access, type, data provider, funder, project, "+ this.pageTitle); + this.searchUtils.baseUrl = "/" + this.searchUtils.baseUrl; + this.updateBaseUrlWithParameters(); + this.defineUrlParam(); + } + updateDescription(description:string){ + this._meta.updateMeta("description", description); + this._meta.updateMeta("og:description", description); + } + updateTitle(title:string){ + var _suffix ="| OpenAIRE"; + var _title = ((title.length> 50 ) ?title.substring(0,50):title) + _suffix; + this._meta.setTitle(_title ); + this._meta.updateMeta("og:title",_title); + } + private defineUrlParam() { + if(this.entityType == "publication") { + this.urlParam = "articleId"; + } else if(this.entityType == "dataset") { + this.urlParam = "datasetId"; + } else if(this.entityType == "project") { + this.urlParam = "projectId"; + } else if(this.entityType == "organization") { + this.urlParam = "organizationId"; + } else if(this.entityType == "person") { + this.urlParam = "personId"; + } else { + this.urlParam = "datasourceId"; + } + } + + public getSelectedFiltersFromUrl(params){ + for(var i=0; i< this.fieldIds.length ; i++){ + + var fieldId = this.fieldIds[i]; + var fieldparam = (this.fieldIdsMap[fieldId])?this.fieldIdsMap[fieldId].param:""; + if(!this.fieldIdsMap[fieldId]){ + + console.error("Field: "+fieldId +" not found in fieldIds map"); + } + + var operatorId = this.getOperatorParameter(fieldparam); + if(params[fieldparam] != undefined && params[operatorId] != undefined) { + var values:string [] = StringUtils.URIDecode(params[fieldparam]).split(/,(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,-1); + var operators:string [] = (StringUtils.URIDecode(params[operatorId])).split(/,(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,-1); + if(values.length == operators.length){ + for(var j=0; j< values.length ; j++){ + if(this.fieldIdsMap[fieldId].type == "date"){ + var value:string =StringUtils.unquote(values[j]); + var validDates:boolean = true; + var dateField:AdvancedField = new AdvancedField(fieldId,fieldparam,this.fieldIdsMap[fieldId].name,this.fieldIdsMap[fieldId].type,value,operators[j]) ; + if(value.indexOf("range") != -1){ + dateField.dateValue.type="range"; + if(value.length < 26 ){ + validDates =false; + }else{ + if(!Dates.isValidDate(value.substring(5,15)) || !Dates.isValidDate(value.substring(16,26))){ + validDates =false; + }else { + dateField.dateValue.from = Dates.getDateFromString(value.substring(5,15)); + dateField.dateValue.to = Dates.getDateFromString(value.substring(16,26)); + } + } + // "rangeYYYY-MM-DD:YYYY-MM-DD" + }else{ + dateField.dateValue.setDatesByType(value); + } + if(validDates){ + this.selectedFields.push(dateField); + } + + }else{ + this.selectedFields.push(new AdvancedField(fieldId,fieldparam,this.fieldIdsMap[fieldId].name,this.fieldIdsMap[fieldId].type,StringUtils.unquote(values[j]),operators[j]) ); + } + } + } + } + } + if(this.selectedFields.length == 0){ + this.selectedFields.push(new AdvancedField(this.fieldIds[0],fieldparam,this.fieldIdsMap[this.fieldIds[0]].name,this.fieldIdsMap[this.fieldIds[0]].type,"","and")); + } + } + private createUrlParameters(includePage:boolean){ + var params=""; + this.parameterNames.splice(0,this.parameterNames.length); + this.parameterValues.splice(0,this.parameterValues.length); + var fields: { [key:string]:{ values:string[], operators:string[] }}={}; + for(var i = 0; i< this.selectedFields.length; i++){ + if(this.fieldIdsMap[this.selectedFields[i].id] != undefined && (this.selectedFields[i].value.length > 0 || this.selectedFields[i].type == "date" )){ + if(!fields[this.selectedFields[i].id]){ + fields[this.selectedFields[i].id] = {values:[], operators:[]}; + fields[this.selectedFields[i].id].values =[]; + fields[this.selectedFields[i].id].operators =[]; + } + if(this.selectedFields[i].type == "date"){ + if(this.selectedFields[i].dateValue.type == "range"){ + fields[this.selectedFields[i].id].values.push(StringUtils.quote(StringUtils.URIEncode("range"+Dates.getDateToString(this.selectedFields[i].dateValue.from)+":"+Dates.getDateToString(this.selectedFields[i].dateValue.to)))); + }else{ + fields[this.selectedFields[i].id].values.push(StringUtils.quote(StringUtils.URIEncode(this.selectedFields[i].dateValue.type))); + } + }else{ + fields[this.selectedFields[i].id].values.push(StringUtils.quote(StringUtils.URIEncode(this.selectedFields[i].value))); + } + fields[this.selectedFields[i].id].operators.push(this.selectedFields[i].operatorId); + + } + } + for(var i = 0; i< this.fieldIds.length; i++){ + if(fields[this.fieldIds[i]]){ + + params+="&"+this.fieldIdsMap[this.fieldIds[i]].param+"="+fields[this.fieldIds[i]].values.join()+ + "&"+this.getOperatorParameter(this.fieldIdsMap[this.fieldIds[i]].param)+"="+fields[this.fieldIds[i]].operators.join() + this.parameterNames.push(this.fieldIdsMap[this.fieldIds[i]].param); + this.parameterValues.push(fields[this.fieldIds[i]].values.join()); + this.parameterNames.push(this.getOperatorParameter(this.fieldIdsMap[this.fieldIds[i]].param)); + this.parameterValues.push(fields[this.fieldIds[i]].operators.join()); + } + } + if(includePage && this.searchUtils.page != 1){ + params += "&page="+this.searchUtils.page; + } + return '?'+params; + } + public createQueryParameters(){ + var params=""; + var countParams = 0; + for(var i = 0; i< this.selectedFields.length; i++){ + if(this.fieldIdsMap[this.selectedFields[i].id] != undefined && (this.selectedFields[i].value != "" ||this.selectedFields[i].type == "date")){ + console.log("createQueryParameters::"+this.selectedFields[i].type); + if(this.selectedFields[i].type == "date"){ + if(this.selectedFields[i].dateValue.type != "any"){ + params += (countParams == 0 ? "" : this.selectedFields[i].operatorId) + " " + this.selectedFields[i].id + this.fieldIdsMap[this.selectedFields[i].id].equalityOperator+ '"' + StringUtils.URIEncode(Dates.getDateToString(this.selectedFields[i].dateValue.from)) + " " + + StringUtils.URIEncode(Dates.getDateToString(this.selectedFields[i].dateValue.to)) + '"' + " "; + } + }else{ + if(this.selectedFields[i].id == "q"){ + var op = ""; + // if() + params += (countParams == 0 ? "" : this.selectedFields[i].operatorId) + " " + '"' + StringUtils.URIEncode(this.selectedFields[i].value) + '"' + " "; + }else if(countParams == 0 && this.selectedFields[i].operatorId == "not"){ + params += " "+ this.selectedFields[i].id + " <> "+'"' + StringUtils.URIEncode(this.selectedFields[i].value) +'"' + " "; + }else{ + params += (countParams == 0 ? "" : this.selectedFields[i].operatorId + " " ) + this.selectedFields[i].id + this.fieldIdsMap[this.selectedFields[i].id].equalityOperator+'"' + encodeURIComponent(this.selectedFields[i].value) +'"' + " "; + + } + } + countParams++; + } + } + + return params; + + } + clearFilters(){ + } + + goTo(page:number = 1){ + this.searchUtils.page = page; + var urlParameters = this.createUrlParameters(true); + var queryParameters = this.createQueryParameters(); + this.location.go(location.pathname,urlParameters); + this.queryChange.emit({ + value: queryParameters + }); + + } + + queryChanged($event) { + + this.goTo(1); + } + pageChanged($event) { + this.searchUtils.page = +$event.value; + this.goTo(this.searchUtils.page); + } + /* + * Update the url with proper parameters. This is used as base url in Paging Component + */ + public updateBaseUrlWithParameters(){ + this.baseURLWithParameters = this.searchUtils.baseUrl + this.createUrlParameters(false); + } + getOperatorParameter(parameter:string):string{ + if(parameter.length > 2){ + return parameter.substring(0,2); + }else if(parameter == "q"){ + return "op"; + }else{ + return parameter+"Op"; + } + } + // for loading + public openLoading(){ + this.loading.open(); + } + public closeLoading(){ + this.loading.close(); + } +} diff --git a/workingUIKIT/src/app/searchPages/searchUtils/advancedSearchPage.module.ts b/workingUIKIT/src/app/searchPages/searchUtils/advancedSearchPage.module.ts new file mode 100644 index 00000000..6d84f1c6 --- /dev/null +++ b/workingUIKIT/src/app/searchPages/searchUtils/advancedSearchPage.module.ts @@ -0,0 +1,29 @@ +import { NgModule} from '@angular/core'; +import { CommonModule } from '@angular/common'; +import { FormsModule } from '@angular/forms'; +import { RouterModule } from '@angular/router'; + +import{AdvancedSearchPageComponent} from './advancedSearchPage.component'; +import{SearchResultsModule} from './searchResults.module'; +import{LoadingModalModule} from '../../utils/modal/loadingModal.module'; +import {ReportsServiceModule} from '../../services/reportsService.module'; +import {SearchDownloadModule} from './searchDownload.module'; +import{SearchPagingModule} from './searchPaging.module'; + +import {AdvancedSearchFormModule} from '../searchUtils/advancedSearchForm.module'; + +@NgModule({ + imports: [ + CommonModule, FormsModule, RouterModule, SearchResultsModule, LoadingModalModule, ReportsServiceModule, SearchPagingModule, AdvancedSearchFormModule, SearchDownloadModule + ], + declarations: [ + AdvancedSearchPageComponent, +], + + providers:[ + ], + exports: [ + AdvancedSearchPageComponent, + ] +}) +export class AdvancedSearchPageModule { } diff --git a/workingUIKIT/src/app/searchPages/searchUtils/browseEntities.component.ts b/workingUIKIT/src/app/searchPages/searchUtils/browseEntities.component.ts new file mode 100644 index 00000000..ca169d83 --- /dev/null +++ b/workingUIKIT/src/app/searchPages/searchUtils/browseEntities.component.ts @@ -0,0 +1,88 @@ +import {Component, Input, ViewChild} from '@angular/core'; +import { ActivatedRoute} from '@angular/router'; +import {Location} from '@angular/common'; + +import { Filter, Value} from '../searchUtils/searchHelperClasses.class'; + +import {RefineFieldResultsService} from '../../services/refineFieldResults.service'; +import {OpenaireProperties, ErrorCodes} from '../../utils/properties/openaireProperties'; +import {SearchFields} from '../../utils/properties/searchFields'; +import {SearchPageComponent } from '../searchUtils/searchPage.component'; +import {SearchUtilsClass} from '../searchUtils/searchUtils.class'; + +@Component({ + selector: 'browse-entities', + template: ` +
+ + + + + +
+
+ +
+
+
+` + +}) +export class BrowseEntitiesComponent { + public searchFields:SearchFields = new SearchFields(); + public filters =[]; + @Input() public baseUrl:string = ""; + @Input() public entityName:string = ""; + @Input() public refineFields: string[] ;//= this.searchFields.RESULT_REFINE_FIELDS; + public sub: any; + public errorCodes:ErrorCodes = new ErrorCodes(); + public status = this.errorCodes.LOADING; + public fieldIdsMap=this.searchFields.RESULT_REFINE_FIELDS; + + constructor ( private _refineFieldsService: RefineFieldResultsService ) { + // this.baseUrl = OpenaireProperties.getLinkToSearchPublications(); + + } + + public ngOnInit() { + for(var i=0; i < this.searchFields.HIDDEN_FIELDS.length; i++){ + var index = this.refineFields.indexOf(this.searchFields.HIDDEN_FIELDS[i]) ; + if(index > -1){ + this.refineFields.splice(index,1); + + } + } + this.getStats(); + } + + public ngOnDestroy() { + if(this.sub){ + this.sub.unsubscribe(); + } + + } + + +private getStats(){ + + this.status = this.errorCodes.LOADING; + this.sub = this._refineFieldsService.getRefineFieldsResultsByEntityName(this.refineFields,this.entityName).subscribe( + data => { + console.info("Get Stats for "+this.entityName+ ": [Total:"+data[0]+" ] [fields: "+data[1].length+"]"); + this.filters = data[1]; + this.status = this.errorCodes.DONE; + if(data[0] == 0 ){ + this.status = this.errorCodes.NONE; + } + }, + err => { + console.log(err); + //TODO check erros (service not available, bad request) + // if( ){ + // this.searchUtils.status = ErrorCodes.ERROR; + // } + this.status = this.errorCodes.ERROR; + } + ); +} +} diff --git a/workingUIKIT/src/app/searchPages/searchUtils/browseEntities.module.ts b/workingUIKIT/src/app/searchPages/searchUtils/browseEntities.module.ts new file mode 100644 index 00000000..163cb7dd --- /dev/null +++ b/workingUIKIT/src/app/searchPages/searchUtils/browseEntities.module.ts @@ -0,0 +1,30 @@ +import { NgModule} from '@angular/core'; +import { CommonModule } from '@angular/common'; +import { FormsModule } from '@angular/forms'; +import { RouterModule } from '@angular/router'; + +import {RefineFieldResultsServiceModule} from '../../services/refineFieldResultsService.module'; + +import {BrowseEntitiesComponent} from './browseEntities.component'; +import {BrowseStatisticComponent} from './browseStatistic.component'; + + +@NgModule({ + imports: [ + CommonModule, FormsModule, + RefineFieldResultsServiceModule, RouterModule + ], + declarations: [ + BrowseEntitiesComponent, + BrowseStatisticComponent + +], + + providers:[ + ], + exports: [ + BrowseEntitiesComponent, + BrowseStatisticComponent + ] +}) +export class BrowseEntitiesModule { } diff --git a/workingUIKIT/src/app/searchPages/searchUtils/browseStatistic.component.ts b/workingUIKIT/src/app/searchPages/searchUtils/browseStatistic.component.ts new file mode 100644 index 00000000..3d5e57c1 --- /dev/null +++ b/workingUIKIT/src/app/searchPages/searchUtils/browseStatistic.component.ts @@ -0,0 +1,66 @@ +import {Component, Input, ViewChild} from '@angular/core'; +import { ActivatedRoute} from '@angular/router'; +import {Location} from '@angular/common'; + +import { Filter, Value} from '../searchUtils/searchHelperClasses.class'; + +import {RefineFieldResultsService} from '../../services/refineFieldResults.service'; +import {OpenaireProperties, ErrorCodes} from '../../utils/properties/openaireProperties'; +import {SearchFields} from '../../utils/properties/searchFields'; +import {SearchPageComponent } from '../searchUtils/searchPage.component'; +import {SearchUtilsClass} from '../searchUtils/searchUtils.class'; +import {RouterHelper} from '../../utils/routerHelper.class'; +@Component({ + selector: 'browse-statistic', + template: ` + + +

{{filter.title}}

+ + + + + ` + +}) +export class BrowseStatisticComponent { + + @Input() public baseUrl:string = ""; + @Input() public filter:any = ""; + private _maxCharacters = 30; + public viewAll = false; + public routerHelper:RouterHelper = new RouterHelper(); + constructor () { + + } + + public ngOnInit() { + + + } + + quote(str:string){ + return '"'+str+'"'; + } + + private _formatName(value){ + return value.name+" ";//(((value.name+" ("+value.number+")").length >this._maxCharacters)?(value.name.substring(0,(this._maxCharacters - (" ("+value.number+")").length - ('...').length))+"..."):value.name) + } + +} diff --git a/workingUIKIT/src/app/searchPages/searchUtils/dateFilter.component.ts b/workingUIKIT/src/app/searchPages/searchUtils/dateFilter.component.ts new file mode 100644 index 00000000..796e447f --- /dev/null +++ b/workingUIKIT/src/app/searchPages/searchUtils/dateFilter.component.ts @@ -0,0 +1,73 @@ +import {Component, Input, Output, EventEmitter} from '@angular/core'; +import {Observable} from 'rxjs/Observable'; + +import { Filter, Value, DateValue} from './searchHelperClasses.class'; +import {IMyOptions, IMyDateModel} from '../../utils/my-date-picker/interfaces/index'; +// import {IMyDateModel} from '../../../utils/my-date-picker/interfaces/my-date-model.interface'; +import {Dates} from '../../utils/string-utils.class'; + +@Component({ + selector: 'date-filter', + template: ` + + +
+ + + + +
+ + From + + To
+
+ ` + +}) + +export class DateFilterComponent { + + @Input() dateValue = new DateValue("any"); + @Input() filterId; + + private myDatePickerOptions: IMyOptions = { + // other options... + dateFormat: 'yyyy-mm-dd', + selectionTxtFontSize: '15px', + height:'28px', + width: '100%', + editableDateField: false, + showClearDateBtn: false + }; + + // Initialized to specific date (09.10.2018). + public from;//: Object = { date: { year: 2018, month: 10, day: 9 } }; + public to;//: Object = { date: { year: 2018, month: 10, day: 9 } }; + +constructor() { + this.updateDefaultRangeDates(this.dateValue.from,this.dateValue.to); +} +updateDefaultRangeDates(df:Date,dt:Date){ + this.from = { date: { year: df.getFullYear(), month: (df.getMonth()+1), day: df.getDate() } }; + this.to = { date: { year: dt.getFullYear(), month: (dt.getMonth()+1), day: dt.getDate() } }; + } +typeChanged(type:string){ + this.dateValue.setDatesByType(type); + this.updateDefaultRangeDates(this.dateValue.from, this.dateValue.to); +} + +onFromDateChanged(event: IMyDateModel) { + this.dateValue.from = Dates.getDateFromString(event.formatted); + +} +onToDateChanged(event: IMyDateModel) { + this.dateValue.to = Dates.getDateFromString(event.formatted); + +}} diff --git a/workingUIKIT/src/app/searchPages/searchUtils/dateFilter.module.ts b/workingUIKIT/src/app/searchPages/searchUtils/dateFilter.module.ts new file mode 100644 index 00000000..0c5dca82 --- /dev/null +++ b/workingUIKIT/src/app/searchPages/searchUtils/dateFilter.module.ts @@ -0,0 +1,20 @@ +import { NgModule} from '@angular/core'; +import { CommonModule } from '@angular/common'; +import { FormsModule } from '@angular/forms'; +import { MyDatePickerModule } from '../../utils/my-date-picker/my-date-picker.module'; +import {DateFilterComponent} from './dateFilter.component'; +@NgModule({ + imports: [ + CommonModule, FormsModule, MyDatePickerModule + ], + declarations: [ + DateFilterComponent +], + + providers:[ + ], + exports: [ + DateFilterComponent + ] +}) +export class DateFilterModule { } diff --git a/workingUIKIT/src/app/searchPages/searchUtils/searchDownload.component.ts b/workingUIKIT/src/app/searchPages/searchUtils/searchDownload.component.ts new file mode 100644 index 00000000..60b7445c --- /dev/null +++ b/workingUIKIT/src/app/searchPages/searchUtils/searchDownload.component.ts @@ -0,0 +1,93 @@ +import {Component, Input, Output, EventEmitter, ViewChild} from '@angular/core'; +import {Observable} from 'rxjs/Observable'; +import {AlertModal} from '../../utils/modal/alert'; +import {OpenaireProperties} from '../../utils/properties/openaireProperties'; +import {ReportsService} from '../../services/reports.service'; +import {ModalLoading} from '../../utils/modal/loading.component'; + +@Component({ + selector: 'search-download', + template: ` +
+

+ + + + Results (CSV) + +

+
+ + + ` +}) + +export class SearchDownloadComponent { + @Input() totalResults:number = 0; + @Input() csvParams: string; + @Input() type: string; + @ViewChild(AlertModal) alertApplyAll; + @Output() downloadClick = new EventEmitter(); + private downloadURLAPI: string; + + @ViewChild (ModalLoading) loading : ModalLoading ; + + constructor ( private _reportsService: ReportsService) {} + + ngOnInit() { + this.downloadURLAPI = OpenaireProperties.getCsvAPIURL(); + } + + confirmClose(data){ + + } + download() { + this.downloadClick.emit({ + value: true + }); + } + + denialOfDownload() { + this.alertApplyAll.isOpen = true; + this.alertApplyAll.cancelButton = true; + this.alertApplyAll.okButton = false; + this.alertApplyAll.alertTitle = "Download Results in CSV"; + this.alertApplyAll.message = "Sorry, but the results are too many! Use the api instead!"; + this.alertApplyAll.cancelButtonText = "Ok"; + + console.info("denial of Download"); + + } + downloadfile(url:string,filename:string){ + console.log("Downloading file: "+ url); + this.openLoading(); + this.setMessageLoading("Downloading CSV file"); + + this._reportsService.downloadCSVFile(url).subscribe( + data => { + this.closeLoading(); + window.open(window.URL.createObjectURL(data),filename+".csv") + }, + error => console.log("Error downloading the file."), + () => console.log('Completed file download.') + ); + } + + + public openLoading(){ + if(this.loading){ + this.loading.open(); + } + } + public closeLoading(){ + if(this.loading){ + this.loading.close(); + } + } + public setMessageLoading(message: string){ + if(this.loading){ + this.loading.message = message; + } + } + +} diff --git a/workingUIKIT/src/app/searchPages/searchUtils/searchDownload.module.ts b/workingUIKIT/src/app/searchPages/searchUtils/searchDownload.module.ts new file mode 100644 index 00000000..2fd947e4 --- /dev/null +++ b/workingUIKIT/src/app/searchPages/searchUtils/searchDownload.module.ts @@ -0,0 +1,23 @@ +import { NgModule} from '@angular/core'; +import { CommonModule } from '@angular/common'; +import { FormsModule } from '@angular/forms'; + +import {SearchDownloadComponent} from './searchDownload.component'; +import{LoadingModalModule} from '../../utils/modal/loadingModal.module'; + +@NgModule({ + imports: [ + CommonModule, FormsModule, LoadingModalModule + ], + declarations: [ + SearchDownloadComponent +], + + providers:[ + ], + exports: [ + SearchDownloadComponent + + ] +}) +export class SearchDownloadModule { } diff --git a/workingUIKIT/src/app/searchPages/searchUtils/searchFilter.component.ts b/workingUIKIT/src/app/searchPages/searchUtils/searchFilter.component.ts new file mode 100644 index 00000000..9ad4012e --- /dev/null +++ b/workingUIKIT/src/app/searchPages/searchUtils/searchFilter.component.ts @@ -0,0 +1,122 @@ +import {Component, Input, Output, EventEmitter} from '@angular/core'; +import {Observable} from 'rxjs/Observable'; + +import { Filter, Value} from './searchHelperClasses.class'; + +@Component({ + selector: 'search-filter', + template: ` + +
+

{{_formatTitle(filter.title,filter.values.length)}} +

+ +
+ + + + ` +}) + +export class SearchFilterComponent { + + @Input() filter:Filter; + @Input() showResultCount:boolean = true; + public showAll:boolean = false; + public _maxCharacters:number =28; + + + constructor () { + } + + ngOnInit() { + + } + public _formatTitle(title,length){ + return (((title+" ("+length+")").length >this._maxCharacters)?(title.substring(0,(this._maxCharacters - (" ("+length+")").length - ('...').length))+"..."):title+" ("+length+")") + } + private _formatName(value){ + return value.name;//(((value.name+" ("+value.number+")").length >this._maxCharacters)?(value.name.substring(0,(this._maxCharacters - (" ("+value.number+")").length - ('...').length))+"..."):value.name) + } + toggleShowAll(){ + this.showAll = !this.showAll; + if(this.showAll == false) { + this.reorderFilterValues(); + } + } + + filterChange(selected:boolean){ + if(selected){ + this.filter.countSelectedValues++; + // this.reorderFilterValues(); + }else{ + this.filter.countSelectedValues--; + // this.reorderFilterValues(); + } + + } + getSelectedValues(filter):any{ + var selected = []; + if(filter.countSelectedValues >0){ + for (var i=0; i < filter.values.length; i++){ + if(filter.values[i].selected){ + selected.push(filter.values[i]); + } + } + } + return selected; + + } + getNotSelectedValues(filter):any{ + var notSselected = []; + if(filter.countSelectedValues >0){ + for (var i=0; i < filter.values.length; i++){ + if(!filter.values[i].selected){ + notSselected.push(filter.values[i]); + } + } + }else { + notSselected = filter.values; + } + return notSselected; + } + reorderFilterValues() { + for(let value of this.filter.values) { + if(value.selected) { + let index: number = this.filter.values.indexOf(value); + let selectedValue:Value = this.filter.values[index]; + + this.filter.values.splice(index, 1); + this.filter.values.splice(0, 0, selectedValue); + } + } + } +// sliceSelected() { +// let values: Value[] = []; +// +// for(let value of this.filter.values) { +// if(value.selected) { +// let index: number = this.filter.values.indexOf(value); +// let selectedValue:Value = this.filter.values[index]; +// +// this.filter.values.splice(index, 1); +// this.filter.values.splice(0, 0, selectedValue); +// } +// } +} diff --git a/workingUIKIT/src/app/searchPages/searchUtils/searchForm.component.ts b/workingUIKIT/src/app/searchPages/searchUtils/searchForm.component.ts new file mode 100644 index 00000000..19a86a49 --- /dev/null +++ b/workingUIKIT/src/app/searchPages/searchUtils/searchForm.component.ts @@ -0,0 +1,32 @@ +import {Component, Input, Output, EventEmitter} from '@angular/core'; +import {Observable} from 'rxjs/Observable'; + +@Component({ + selector: 'search-form', + template: ` +
+ + +
+ ` +}) + +export class SearchFormComponent { + @Input() keyword: string = ''; + + @Output() keywordChange = new EventEmitter(); + + constructor () { + } + + ngOnInit() { + + } + + keywordChanged() { + console.info("inside form: "+this.keyword); + this.keywordChange.emit({ + value: this.keyword + }); + } +} diff --git a/workingUIKIT/src/app/searchPages/searchUtils/searchForm.module.ts b/workingUIKIT/src/app/searchPages/searchUtils/searchForm.module.ts new file mode 100644 index 00000000..e160e86d --- /dev/null +++ b/workingUIKIT/src/app/searchPages/searchUtils/searchForm.module.ts @@ -0,0 +1,22 @@ +import { NgModule} from '@angular/core'; +import { CommonModule } from '@angular/common'; +import { FormsModule } from '@angular/forms'; + +import{SearchFormComponent} from './searchForm.component'; + +@NgModule({ + imports: [ + CommonModule, FormsModule + ], + declarations: [ + SearchFormComponent +], + + providers:[ + ], + exports: [ + SearchFormComponent + + ] +}) +export class SearchFormModule { } diff --git a/workingUIKIT/src/app/searchPages/searchUtils/searchHelperClasses.class.ts b/workingUIKIT/src/app/searchPages/searchUtils/searchHelperClasses.class.ts new file mode 100644 index 00000000..c09b3440 --- /dev/null +++ b/workingUIKIT/src/app/searchPages/searchUtils/searchHelperClasses.class.ts @@ -0,0 +1,89 @@ +import {Dates} from '../../utils/string-utils.class'; +export class Filter{ + public title: string; // eg Type + public filterId: string; // type (name in url parameter) + public originalFilterId: string; // (in index) + public countSelectedValues: number = 0; + public values: Value[] = []; + public filterOperator: string ='or'; + + +} + +export class Value{ + public name: string; //eg Article, Journal + public id: string; //0001 + public selected: boolean = false; + public number: number = 0; + +} +export class AdvancedField{ + public id: string; // + public param:string; + public name: string; // + public type: string = "keyword"; //keyword, static or dynamic + public value: string = ''; + public operatorId: string; + public operatorName: string =""; + public valid: boolean = true; + public dateValue:DateValue = new DateValue("any"); + + constructor(id:string,param:string,name:string, type:string, value:string,operator:string){ + this.id = id; + this.param = param; + this.name = name; + this.type = type; + this.value = value; + this.operatorId = operator; + // this.operatorName = "AND"; + + } +} +export class DateValue{ + public types = ["any","range","1mon","2mon","3mon","6mon","12mon","2year","5year","10year"]; + public typesTitle = ["any","in the specified date range","in the last month","in the last 2 months","in the last 3 months","in the last 6 months","in the last year","in the last 2 years","in the last 5 years","in the last 10 years"]; + public type: string ; + public from:Date = new Date(); + public to:Date = new Date(); + constructor(type:string = "any"){ + this.setDatesByType(type); + } + public setDatesByType(type:string){ + if(this.types.indexOf(type) == -1){ + type=this.types[0]; + } + this.type = type; + this.to = Dates.getDateToday(); + if(this.type == "range" || this.type == "any"){ // for type "any" just to initiate with values + this.from = Dates.getDateXMonthsAgo(1); + }else if(this.type == "1mon"){ + this.from = Dates.getDateXMonthsAgo(1); + }else if(this.type == "2mon"){ + this.from = Dates.getDateXMonthsAgo(2); + }else if(this.type == "3mon"){ + this.from = Dates.getDateXMonthsAgo(3); + }else if(this.type == "6mon"){ + this.from = Dates.getDateXMonthsAgo(6); + }else if(this.type == "12mon"){ + this.from = Dates.getDateXMonthsAgo(12); + }else if(this.type == "2year"){ + this.from = Dates.getDateXYearsAgo(2); + }else if(this.type == "5year"){ + this.from = Dates.getDateXYearsAgo(5); + }else if(this.type == "10year"){ + this.from = Dates.getDateXYearsAgo(10); + } + } + +} +export class OPERATOR{ + public static AND: string ="and"; + public static OR: string ="or"; + public static NOT: string ="not"; + +} + +export class AutoCompleteValue{ + public id: string; + public label: string; +} diff --git a/workingUIKIT/src/app/searchPages/searchUtils/searchPage.component.ts b/workingUIKIT/src/app/searchPages/searchUtils/searchPage.component.ts new file mode 100644 index 00000000..b4745d58 --- /dev/null +++ b/workingUIKIT/src/app/searchPages/searchUtils/searchPage.component.ts @@ -0,0 +1,544 @@ +import {Component, Input, ViewChild, Output, EventEmitter} from '@angular/core'; +import {Observable} from 'rxjs/Observable'; +import {Location} from '@angular/common'; +import { Filter, Value} from './searchHelperClasses.class'; +import {SearchResult} from '../../utils/entities/searchResult'; +import {SearchFields} from '../../utils/properties/searchFields'; +import {SearchUtilsClass} from './searchUtils.class'; +import {DOI, StringUtils} from '../../utils/string-utils.class'; +import {ModalLoading} from '../../utils/modal/loading.component'; +import { Meta} from '../../../angular2-meta'; + +@Component({ + selector: 'search-page', + template: ` + +
+ +
+
+
+ +
+ Keywords:{{searchUtils.keyword}} + + + {{filter.title}}: + {{value.name}} + , + + + + Clear Filters[] +
+ More search options +
+
+
+ +
+ +
+ + + + +
+
+
+ + +
+ + + + + +
+
+
+ + + + ` +}) +export class SearchPageComponent { + @Input() pageTitle = ""; + @Input() results = []; + @Input() filters = []; + @Input() type:string = ""; + @Input() entityType: string = ""; + @Input() searchUtils:SearchUtilsClass = new SearchUtilsClass(); + @Output() queryChange = new EventEmitter(); + @Output() downloadClick = new EventEmitter(); + @Input() baseUrl:string = ''; + @Input() showResultCount:boolean = true; + @Input() showRefine:boolean = true; + @Input() refineFields = []; + @Input() csvParams: string; + @Input() csvPath: string; + @Input() advancedSearchLink: string = ""; + @ViewChild (ModalLoading) loading : ModalLoading ; + public fieldIdsMap;//: { [key:string]:{ name:string, operator:string, type:string, indexField:string, equalityOperator:string }}; + private searchFieldsHelper:SearchFields = new SearchFields(); + private queryParameters: Map = new Map(); + private baseURLWithParameters:string = ''; + private sub: any; + public countFilters= 0; + public urlParam: string; + public parameterNames:string[] =[]; + public parameterValues:string[] =[]; + constructor (private location: Location , private _meta: Meta) { + } + + ngOnInit() { + this.updateBaseUrlWithParameters(this.filters); + this.defineUrlParam(); + this.updateTitle(this.pageTitle); + this.updateDescription("Openaire, search, repositories, open access, type, data provider, funder, project, " + this.type + "," +this.pageTitle); + // console.info(this.entityType + " " + this.urlParam + this.type); + } + ngAfterViewChecked(){ + + } + updateDescription(description:string){ + this._meta.updateMeta("description", description); + this._meta.updateMeta("og:description", description); + } + updateTitle(title:string){ + var _suffix ="| OpenAIRE"; + var _title = ((title.length> 50 ) ?title.substring(0,50):title) + _suffix; + this._meta.setTitle(_title ); + this._meta.updateMeta("og:title",_title); + } + private defineUrlParam() { + if(this.entityType == "publication") { + this.urlParam = "articleId"; + } else if(this.entityType == "dataset") { + this.urlParam = "datasetId"; + } else if(this.entityType == "project") { + this.urlParam = "projectId"; + } else if(this.entityType == "organization") { + this.urlParam = "organizationId"; + } else if(this.entityType == "person") { + this.urlParam = "personId"; + } else { + this.urlParam = "datasourceId"; + } + } + + public getQueryParametersFromUrl(params){ + // var parameters = ""; + var allFqs = ""; + + for(var i=0; i< this.refineFields.length ; i++){ + var filterId = this.refineFields[i]; + + if(params[filterId] != undefined) { + if(this.queryParameters == undefined){ + this.queryParameters = new Map(); + } + this.queryParameters[filterId]=StringUtils.URIDecode(params[filterId]); + let values = (StringUtils.URIDecode(this.queryParameters[filterId])).split(/,(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,-1); + var countvalues = 0; + var fq = ""; + for(let value of values) { + countvalues++; + var paramId = this.fieldIdsMap[filterId].param; + // parameters+='&' + paramId+ '='+ value;//+"&" + this.fieldIdsMap[paramId].operator + "="+((countvalues == 1)?"and":"or"); + fq+=(fq.length > 0 ? " " + "or" + " ":"" ) + filterId +" exact " +value;// StringUtils.quote(value) ; + } + if(countvalues > 0){ + fq="&fq="+fq; + } + allFqs += fq; + } + + + } + var keyword = params['keyword']; + var doiQuery = ""; + var keywordQuery = ""; + if((keyword && keyword.length > 0)){ + if((this.type == 'publications' ||this.type == 'datasets')){ + var DOIs:string[] = DOI.getDOIsFromString(keyword); + var doisParams = ""; + + for(var i =0 ;i < DOIs.length; i++){ + doisParams+=(doisParams.length > 0?"&":"")+'doi="'+ DOIs[i]+'"'; + } + if(doisParams.length > 0){ + doiQuery += "&"+doisParams; + }else { + keywordQuery += "&q="+StringUtils.URIEncode(keyword); + } + }else{ + keywordQuery += "&q="+StringUtils.URIEncode(keyword); + + } + } + return (doiQuery.length > 0 ? doiQuery:keywordQuery) + allFqs; + } + public getIndexQueryParametersFromUrl(params){ + // var parameters = ""; + var allFqs = ""; + + for(var i=0; i< this.refineFields.length ; i++){ + var filterId = this.refineFields[i]; + var fq = ""; + if(params[filterId] != undefined) { + if(this.queryParameters == undefined){ + this.queryParameters = new Map(); + } + this.queryParameters[filterId]=decodeURIComponent(params[filterId]); + let values = (decodeURIComponent(this.queryParameters[filterId])).split(/,(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,-1); + var countvalues = 0 + for(let value of values) { + countvalues++; + // parameters+= ((countvalues == 1)?" and (":" or ")+ filterId+ '='+ value; + fq+=(fq.length > 0 ? " " + "or" + " ":"" ) + filterId + " exact " + value;//StringUtils.quote(value); + } + // parameters+= " ) "; + if(countvalues > 0){ + fq="&fq="+fq; + } + allFqs += fq; + } + + } + var keyword = params['keyword']; + var doiQuery = ""; + var keywordQuery = ""; + if((keyword && keyword.length > 0)){ + if((this.type == 'publications' ||this.type == 'datasets')){ + var DOIs:string[] = DOI.getDOIsFromString(keyword); + var doisParams = ""; + + for(var i =0 ;i < DOIs.length; i++){ + doisParams+=(doisParams.length > 0?"&":"")+'doi="'+ DOIs[i]+'"'; + } + if(doisParams.length > 0){ + doiQuery += "&"+doisParams; + } + }else{ + keywordQuery += "and ("+StringUtils.quote(StringUtils.URIEncode(keyword)) +")"; + + } + } + return (doiQuery.length > 0 ? doiQuery:keywordQuery) + allFqs; + +} + /* + * Mark as check the new filters that are selected, when you get them from search + */ + public checkSelectedFilters(filters:Filter[]){ + this.filters = filters; + for(var i=0; i< filters.length ; i++){ + var filter:Filter = filters[i]; + filter.countSelectedValues = 0; + if(this.queryParameters[filter.filterId] != undefined) { + let values = (decodeURIComponent(this.queryParameters[filter.filterId])).split(/,(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,-1); + for(let filterValue of filter.values) { + if(values.indexOf(StringUtils.quote(filterValue.id)) > -1) { + filterValue.selected = true; + filter.countSelectedValues++; + }else{ + filterValue.selected = false; + + } + } + }else{ + for(let filterValue of filter.values) { + filterValue.selected = false; + } + } + } + + return filters; + } + /* + * Update the url with proper parameters. This is used as base url in Paging Component + */ + public updateBaseUrlWithParameters(filters:Filter[]){ + this.baseURLWithParameters = this.baseUrl + this.createUrlParameters(filters,false); + } + /* + * + */ + private createUrlParameters(filters:Filter[], includePage:boolean){ + var allLimits="";//location.search.slice(1); + this.parameterNames.splice(0,this.parameterNames.length); + this.parameterValues.splice(0,this.parameterValues.length); + + for (let filter of filters){ + var filterLimits=""; + if(filter.countSelectedValues > 0){ + for (let value of filter.values){ + if(value.selected == true){ + filterLimits+=((filterLimits.length == 0)?'':',') +'"'+ StringUtils.URIEncode(value.id)+'"'; + } + } + this.queryParameters[filter.filterId]=filterLimits; + if(filterLimits.length > 0){ + this.parameterNames.push(filter.filterId); + this.parameterValues.push(filterLimits); + } + allLimits+=(allLimits.length==0?"?":"&")+((filterLimits.length == 0 )?'':filter.filterId + '='+ filterLimits) ; + } + } + if(this.searchUtils.keyword.length > 0 ){ + allLimits+=(allLimits.length==0?"?":"&")+'keyword=' + this.searchUtils.keyword; + this.parameterNames.push("keyword"); + this.parameterValues.push(this.searchUtils.keyword); + } + if(this.searchUtils.page != 1 && includePage){ + allLimits+=((allLimits.length == 0)?'?':'&') + 'page=' + this.searchUtils.page; + } + + return allLimits; + } + /* + * + */ + private createSearchQueryParameters(filters:Filter[]){ + var allFqs = ""; + for (let filter of filters){ + if(filter.countSelectedValues > 0){ + var fq = ""; + var count_selected=0; + for (let value of filter.values){ + if(value.selected == true){ + count_selected++; + fq+=(fq.length > 0 ? " " + filter.filterOperator + " ":"" ) + filter.filterId + " exact " + StringUtils.quote(StringUtils.URIEncode(value.id)); + } + } + fq="&fq="+fq; + allFqs += fq; + } + } + var doiQuery = ""; + var keywordQuery = ""; + if((this.searchUtils.keyword && this.searchUtils.keyword.length > 0)){ + if((this.type == 'publications' ||this.type == 'datasets')){ + var DOIs:string[] = DOI.getDOIsFromString(this.searchUtils.keyword); + var doisParams = ""; + + for(var i =0 ;i < DOIs.length; i++){ + doisParams+=(doisParams.length > 0?"&":"")+'doi="'+ DOIs[i]+'"'; + } + if(doisParams.length > 0){ + doiQuery += "&"+doisParams; + }else{ + keywordQuery += "&q="+StringUtils.URIEncode(this.searchUtils.keyword); + } + }else{ + keywordQuery += "&q="+StringUtils.URIEncode(this.searchUtils.keyword); + } + } + + return (doiQuery.length > 0 ? doiQuery:keywordQuery) + allFqs; + + } + private createIndexQueryParameters(filters:Filter[]){ + var allFqs = ""; + for (let filter of filters){ + if(filter.countSelectedValues > 0){ + var count_selected=0; + var fq = ""; + for (let value of filter.values){ + if(value.selected == true){ + count_selected++; + fq+=(fq.length > 0 ? " " + filter.filterOperator + " ":"" ) + filter.filterId + " exact " + StringUtils.quote(StringUtils.URIEncode(value.id)); + } + } + if(count_selected > 0){ + fq="&fq="+fq; + allFqs += fq; + } + } + } + var doiQuery = ""; + var keywordQuery = ""; + if((this.searchUtils.keyword && this.searchUtils.keyword.length > 0)){ + if((this.type == 'publications' ||this.type == 'datasets')){ + var DOIs:string[] = DOI.getDOIsFromString(this.searchUtils.keyword); + var doisParams = ""; + for(var i =0 ;i < DOIs.length; i++){ + doisParams+=(doisParams.length > 0?"&":"")+'doi="'+ DOIs[i]+'"'; + } + if(doisParams.length > 0){ + doiQuery += "&"+doisParams; + } + }else{ + keywordQuery += " and ("+StringUtils.quote(StringUtils.URIEncode(this.searchUtils.keyword)) +")" + + } + } + return (doiQuery.length > 0 ? doiQuery:keywordQuery) + allFqs; + + } + private isFiltered(){ + var filtered=false; + for (let filter of this.filters){ + if(filter.countSelectedValues > 0){ + filtered = true; + break; + } + } + if(this.searchUtils.keyword.length > 0 ){ + filtered = true; + } + return filtered; + } + private clearKeywords(){ + if(this.searchUtils.keyword.length > 0 ){ + this.searchUtils.keyword =''; + } + this.goTo(1); + } + private clearFilters(){ + for (var i =0 ; i < this.filters.length; i++){ + for (var j=0; j < this.filters[i].countSelectedValues; j++){ + if(this.filters[i].values[j].selected){ + this.filters[i].values[j].selected = false; + } + this.filters[i].countSelectedValues = 0; + } + } + this.clearKeywords(); + + } + private removeFilter(value:Value,filter:Filter){ + filter.countSelectedValues--; + if(value.selected == true){ + value.selected = false; + } + this.goTo(1); + + } + goTo(page:number = 1){ + this.searchUtils.page = page; + console.info("searchUtils.page goto = "+this.searchUtils.page); + this.queryParameters = new Map(); + var urlParameters = this.createUrlParameters(this.filters,true); + console.info("urlParams : "+urlParameters); + this.updateBaseUrlWithParameters(this.filters); + var queryParameters = this.createSearchQueryParameters(this.filters); + console.info("queryParams : "+queryParameters); + var indexQuery = this.createIndexQueryParameters(this.filters); + + this.location.go(location.pathname,urlParameters); + + this.queryChange.emit({ + value: queryParameters, + index:indexQuery + + }); + + } + filterChanged($event){ + this.goTo(1); + } + keywordChanged($event) { + this.searchUtils.keyword = $event.value; + this.goTo(1); + } + + downloadClicked($event) { + if($event.value == true) { + var queryParameters = this.createSearchQueryParameters(this.filters); + + this.downloadClick.emit({ + value: queryParameters + }); + } + } + + /* + * Get A sub-array of this.refineFields array, which contains the ids of the selected filters + */ + public getSelectedFilters():string[] { + var selected:string[] = []; + for(var i=0; i < this.filters.length; i++){ + var filter:Filter = this.filters[i]; + if(filter.countSelectedValues > 0){ + selected.push(filter.filterId); + } + } + return selected; + } + /* + * Get A sub-array of this.refineFields array, which contains the ids of the selected parameters + */ + private getSelectedParameters():string[] { + var selected:string[] = []; + var params:string[] = Object.keys(this.queryParameters); + for(var i=0; i < params.length; i++){ + if(this.refineFields.indexOf(params[i]) > -1){ + selected.push(params[i]); + } + } + return selected; + } + /* + * Get A sub-array of this.refineFields array, which hides hidden fields (e.g Funding level 0,1,2,..), and contains those that depend on another fields (e.g Funding level 0 if Funder is selected ) + */ + public getFields():string[] { + var selected_filters:string[] = this.getSelectedFilters(); + if(selected_filters.length == 0){ + selected_filters = this.getSelectedParameters(); + } + var fields:string[] = []; + for(var i =0 ; i < this.refineFields.length;i++){ + var dependentTo = this.searchFieldsHelper.DEPENDENT_FIELDS[this.refineFields[i]]; + + //if filter is not marked as hidden OR it is hidden but it is dependent to a field that it IS selected + if(this.searchFieldsHelper.HIDDEN_FIELDS.indexOf(this.refineFields[i]) == -1 || (selected_filters.indexOf(dependentTo) != -1) ){ + fields.push(this.refineFields[i]); + } + } + return fields; + } + /* + * Get a query string of all fields, that want to get from search (e.g. &fields=funderid&fields=projectstartyear&...)) + */ + public getRefineFieldsQuery():string{ + + var fields:string[] = this.getFields(); + var fieldsStr = "" + for(var i =0 ; i < fields.length ;i++){ + fieldsStr+="&fields="+fields[i]; + } + return "&refine=true"+fieldsStr; + } + + // for loading + public openLoading(){ + if(this.loading){ + this.loading.open(); + } + } + public closeLoading(){ + if(this.loading){ + this.loading.close(); + } + } + getSelectedValues(filter):any{ + var selected = []; + if(filter.countSelectedValues >0){ + for (var i=0; i < filter.values.length; i++){ + if(filter.values[i].selected){ + selected.push(filter.values[i]); + } + } + } + return selected; + + } +} diff --git a/workingUIKIT/src/app/searchPages/searchUtils/searchPage.module.ts b/workingUIKIT/src/app/searchPages/searchUtils/searchPage.module.ts new file mode 100644 index 00000000..93cd4f27 --- /dev/null +++ b/workingUIKIT/src/app/searchPages/searchUtils/searchPage.module.ts @@ -0,0 +1,32 @@ +import { NgModule} from '@angular/core'; +import { CommonModule } from '@angular/common'; +import { FormsModule } from '@angular/forms'; +import { RouterModule } from '@angular/router'; + +import{SearchPageComponent} from './searchPage.component'; +import{SearchFormModule} from './searchForm.module'; +import{SearchResultsModule} from './searchResults.module'; +import{SearchFilterComponent} from './searchFilter.component'; +import{LoadingModalModule} from '../../utils/modal/loadingModal.module'; +import {ReportsServiceModule} from '../../services/reportsService.module'; +import{SearchPagingModule} from './searchPaging.module'; +import {SearchDownloadModule} from './searchDownload.module'; + +@NgModule({ + imports: [ + CommonModule, FormsModule,RouterModule, SearchFormModule, SearchResultsModule, LoadingModalModule, ReportsServiceModule, SearchPagingModule, SearchDownloadModule + ], + declarations: [ + SearchPageComponent, + SearchFilterComponent + , +], + + providers:[ + ], + exports: [ + SearchPageComponent, +SearchFilterComponent + ] +}) +export class SearchPageModule { } diff --git a/workingUIKIT/src/app/searchPages/searchUtils/searchPaging.component.ts b/workingUIKIT/src/app/searchPages/searchUtils/searchPaging.component.ts new file mode 100644 index 00000000..4dfb71ab --- /dev/null +++ b/workingUIKIT/src/app/searchPages/searchUtils/searchPaging.component.ts @@ -0,0 +1,43 @@ +import {Component, Input, Output, EventEmitter} from '@angular/core'; +import {Observable} from 'rxjs/Observable'; + +@Component({ + selector: 'search-paging', + template: ` +
+
+ +
+
+ {{searchUtils.totalResults}} {{type}}, page {{searchUtils.page}} of {{(totalPages())}} +
+
+ ` +}) + +export class SearchPagingComponent { + @Input() searchUtils; + @Input() results; + @Input() baseUrl; + @Input() type; + @Input() parameterNames:string[]; + @Input() parameterValues:string[]; + + // @Input() totalResults:number = 0; + constructor () { + } + + ngOnInit() { + + } + + totalPages(): number { + let totalPages:any = this.searchUtils.totalResults/(this.searchUtils.size); + if(!(Number.isInteger(totalPages))) { + totalPages = (parseInt(totalPages, 10) + 1); + } + return totalPages; + } + + +} diff --git a/workingUIKIT/src/app/searchPages/searchUtils/searchPaging.module.ts b/workingUIKIT/src/app/searchPages/searchUtils/searchPaging.module.ts new file mode 100644 index 00000000..4a403bd1 --- /dev/null +++ b/workingUIKIT/src/app/searchPages/searchUtils/searchPaging.module.ts @@ -0,0 +1,23 @@ +import { NgModule} from '@angular/core'; +import { CommonModule } from '@angular/common'; +import { FormsModule } from '@angular/forms'; + +import{SearchPagingComponent} from './searchPaging.component'; +import{PagingModule} from '../../utils/paging.module'; + +@NgModule({ + imports: [ + CommonModule, FormsModule, PagingModule + ], + declarations: [ + SearchPagingComponent +], + + providers:[ + ], + exports: [ + SearchPagingComponent + + ] +}) +export class SearchPagingModule { } diff --git a/workingUIKIT/src/app/searchPages/searchUtils/searchResult.component.ts b/workingUIKIT/src/app/searchPages/searchUtils/searchResult.component.ts new file mode 100644 index 00000000..15f8b3ed --- /dev/null +++ b/workingUIKIT/src/app/searchPages/searchUtils/searchResult.component.ts @@ -0,0 +1,148 @@ +import {Component, Input} from '@angular/core'; +import {SearchResult} from '../../utils/entities/searchResult'; +import { ErrorCodes} from '../../utils/properties/openaireProperties'; +import {RouterHelper} from '../../utils/routerHelper.class'; + +@Component({ + selector: 'search-result', + template: ` + + ` +}) + +export class SearchResultComponent { + @Input() results: SearchResult[]; + @Input() status: number; + @Input() type: string; + @Input() urlParam: string; + @Input() showLoading: boolean = false; + + public errorCodes:ErrorCodes = new ErrorCodes(); + public routerHelper:RouterHelper = new RouterHelper(); + public errorMessage: string = "No results found"; + + constructor () { + + } + + ngOnInit() {} +} diff --git a/workingUIKIT/src/app/searchPages/searchUtils/searchResults.module.ts b/workingUIKIT/src/app/searchPages/searchUtils/searchResults.module.ts new file mode 100644 index 00000000..9c85670c --- /dev/null +++ b/workingUIKIT/src/app/searchPages/searchUtils/searchResults.module.ts @@ -0,0 +1,27 @@ +import { NgModule} from '@angular/core'; +import { CommonModule } from '@angular/common'; +import { FormsModule } from '@angular/forms'; + +import {SearchResult} from '../../utils/entities/searchResult'; +import {SearchResultComponent} from './searchResult.component'; +import { RouterModule } from '@angular/router'; + +@NgModule({ + imports: [ + CommonModule, FormsModule, + RouterModule + ], + declarations: [ + SearchResultComponent, + +], + + providers:[ + ], + exports: [ + + SearchResultComponent + + ] +}) +export class SearchResultsModule { } diff --git a/workingUIKIT/src/app/searchPages/searchUtils/searchUtils.class.ts b/workingUIKIT/src/app/searchPages/searchUtils/searchUtils.class.ts new file mode 100644 index 00000000..25e50999 --- /dev/null +++ b/workingUIKIT/src/app/searchPages/searchUtils/searchUtils.class.ts @@ -0,0 +1,9 @@ +export class SearchUtilsClass{ + page:number = 1; + size:number = 10; + status:number = 1; + keyword:string = ""; + baseUrl:string = ""; + totalResults = 0; + +} diff --git a/workingUIKIT/src/app/searchPages/searchUtils/tabResult.component.ts b/workingUIKIT/src/app/searchPages/searchUtils/tabResult.component.ts new file mode 100644 index 00000000..5ca842ed --- /dev/null +++ b/workingUIKIT/src/app/searchPages/searchUtils/tabResult.component.ts @@ -0,0 +1,149 @@ +import {Component, Input} from '@angular/core'; +import {SearchResult} from '../../utils/entities/searchResult'; +import {ErrorCodes} from '../../utils/properties/openaireProperties'; +import {RouterHelper} from '../../utils/routerHelper.class'; + +@Component({ + selector: 'tab-result', + template: ` + + ` +}) + +export class TabResultComponent { + @Input() results: SearchResult[]; + @Input() status: number; + @Input() type: string; + @Input() urlParam: string; + @Input() showLoading: boolean = false; + + public errorCodes:ErrorCodes = new ErrorCodes(); + public routerHelper:RouterHelper = new RouterHelper(); + public errorMessage: string = "No results found"; + + constructor () { + + } + + ngOnInit() {} +} diff --git a/workingUIKIT/src/app/searchPages/searchUtils/tabResult.module.ts b/workingUIKIT/src/app/searchPages/searchUtils/tabResult.module.ts new file mode 100644 index 00000000..589b5623 --- /dev/null +++ b/workingUIKIT/src/app/searchPages/searchUtils/tabResult.module.ts @@ -0,0 +1,23 @@ +import { NgModule} from '@angular/core'; +import { CommonModule } from '@angular/common'; +import { FormsModule } from '@angular/forms'; + +import {SearchResult} from '../../utils/entities/searchResult'; +import {TabResultComponent} from './tabResult.component'; +import {RouterModule} from '@angular/router'; + +@NgModule({ + imports: [ + CommonModule, FormsModule, + RouterModule + ], + declarations: [ + TabResultComponent, + ], + providers:[ + ], + exports: [ + TabResultComponent + ] +}) +export class TabResultModule { } diff --git a/workingUIKIT/src/app/searchPages/simple/searchDataProviders-routing.module.ts b/workingUIKIT/src/app/searchPages/simple/searchDataProviders-routing.module.ts new file mode 100644 index 00000000..fefe1cc3 --- /dev/null +++ b/workingUIKIT/src/app/searchPages/simple/searchDataProviders-routing.module.ts @@ -0,0 +1,15 @@ +import { NgModule } from '@angular/core'; +import { RouterModule } from '@angular/router'; + +import{SearchDataprovidersComponent} from './searchDataproviders.component'; +import {FreeGuard} from'../../login/freeGuard.guard'; + +@NgModule({ + imports: [ + RouterModule.forChild([ + { path: '', component: SearchDataprovidersComponent, canActivate: [FreeGuard] } + + ]) + ] +}) +export class SearchDataProvidersRoutingModule { } diff --git a/workingUIKIT/src/app/searchPages/simple/searchDataProviders.module.ts b/workingUIKIT/src/app/searchPages/simple/searchDataProviders.module.ts new file mode 100644 index 00000000..03e24660 --- /dev/null +++ b/workingUIKIT/src/app/searchPages/simple/searchDataProviders.module.ts @@ -0,0 +1,32 @@ +import { NgModule} from '@angular/core'; +import { CommonModule } from '@angular/common'; +import { FormsModule } from '@angular/forms'; + +import{ SearchDataProvidersRoutingModule} from './searchDataProviders-routing.module'; +import{SearchDataprovidersComponent} from './searchDataproviders.component'; + +import {SearchResultsModule } from '../searchUtils/searchResults.module'; + +import {DataProvidersServiceModule} from '../../services/dataProvidersService.module'; +import {SearchFormModule} from '../searchUtils/searchForm.module'; +import {SearchPageModule} from '../searchUtils/searchPage.module'; +import {FreeGuard} from'../../login/freeGuard.guard'; + +@NgModule({ + imports: [ + CommonModule, FormsModule, + + DataProvidersServiceModule, + SearchFormModule, SearchResultsModule, SearchDataProvidersRoutingModule, SearchPageModule + + ], + declarations: [ + SearchDataprovidersComponent + ], + providers:[FreeGuard + ], + exports: [ + SearchDataprovidersComponent + ] +}) +export class SearchDataProvidersModule { } diff --git a/workingUIKIT/src/app/searchPages/simple/searchDataproviders.component.ts b/workingUIKIT/src/app/searchPages/simple/searchDataproviders.component.ts new file mode 100644 index 00000000..51409f83 --- /dev/null +++ b/workingUIKIT/src/app/searchPages/simple/searchDataproviders.component.ts @@ -0,0 +1,323 @@ +import {Component, Input, ViewChild} from '@angular/core'; +import { ActivatedRoute} from '@angular/router'; +import {Location} from '@angular/common'; +import { Filter, Value} from '../searchUtils/searchHelperClasses.class'; +import {SearchDataprovidersService} from '../../services/searchDataproviders.service'; +import {SearchResult} from '../../utils/entities/searchResult'; +import {OpenaireProperties, ErrorCodes} from '../../utils/properties/openaireProperties'; +import {SearchFields} from '../../utils/properties/searchFields'; +import {SearchPageComponent } from '../searchUtils/searchPage.component'; +import {ExportCSVComponent} from '../../utils/exportCSV.class'; +import {SearchUtilsClass } from '../searchUtils/searchUtils.class'; + +@Component({ + selector: 'search-dataproviders', + template: ` + + + + + ` +}) +export class SearchDataprovidersComponent { + public results =[]; + public filters =[]; + public totalResults:number = 0 ; + public baseUrl:string; + public searchUtils:SearchUtilsClass = new SearchUtilsClass(); + public sub: any; public subResults: any; + public _location:Location; + public searchFields:SearchFields = new SearchFields(); + public refineFields: string[] = this.searchFields.DATASOURCE_REFINE_FIELDS; + public fieldIdsMap= this.searchFields.DATASOURCE_FIELDS; + public CSV: any = { "columnNames": [ "Title", "Type", "Coutries", "Compatibility" ], + "export":[] + }; + public CSVDownloaded = false; + public csvParams: string; + + @ViewChild (SearchPageComponent) searchPage : SearchPageComponent ; + + constructor (private route: ActivatedRoute, private _searchDataprovidersService: SearchDataprovidersService ) { + var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status =errorCodes.LOADING; + this.searchUtils.page =1; + this.baseUrl = OpenaireProperties.getLinkToSearchDataProviders(); + } + + public ngOnInit() { + this.searchPage.refineFields = this.refineFields; + this.searchPage.fieldIdsMap = this.fieldIdsMap; + var firstLoad =true; + + this.sub = this.route.queryParams.subscribe(params => { + this.searchUtils.keyword = (params['keyword']?params['keyword']:''); + var refine = true; + if(this.searchUtils.page != ((params['page']=== undefined)?1:+params['page']) && this.filters && !firstLoad){ + refine = false; + + } + firstLoad = false; + this.searchUtils.page = (params['page']=== undefined)?1:+params['page']; + + var queryParameters = this.searchPage.getQueryParametersFromUrl(params); + this._getResults(queryParameters, refine, this.searchUtils.page, this.searchUtils.size); + }); + } + + public ngOnDestroy() { + if(this.sub){ + this.sub.unsubscribe(); + } + if(this.subResults){ + this.subResults.unsubscribe(); + } + } + + public getNumForEntity(entity: string, id:string) { + console.info("getNumForEntity : Dataproviders Component"); + var parameters=""; + + if(entity == "organization") { + parameters = "organizations/"+id+"/datasources/count"; + } + + if(parameters != "") { + + this._searchDataprovidersService.numOfDataproviders(parameters).subscribe( + data => { + this.searchUtils.totalResults = data; + }, + err => { + console.log(err); + //TODO check erros (service not available, bad request) + // if( ){ + // this.searchUtils.status = ErrorCodes.ERROR; + // } + var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = errorCodes.ERROR; + } + ); + } + } + + public getNumForSearch(keyword: string) { + var parameters="datasources/count"; + if(keyword != "") { + parameters += "?q="+keyword; + } + this._searchDataprovidersService.numOfDataproviders(parameters).subscribe( + data => { + this.searchUtils.totalResults = data; + }, + err => { + console.log(err); + //TODO check erros (service not available, bad request) + // if( ){ + // this.searchUtils.status = ErrorCodes.ERROR; + // } + var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = errorCodes.ERROR; + } + ); + } + +public getResultsForDeposit(id:string, type:string, page: number, size: number){ + //var errorCodes:ErrorCodes = new ErrorCodes(); + //this.status = errorCodes.LOADING; + if(id != "") { + + this._searchDataprovidersService.searchDataprovidersForDeposit(id,type, page, size).subscribe( + data => { + this.searchUtils.totalResults = data[0]; + console.info("search Dataproviders forDeposit: [id:"+id+", type:"+type+" ] [total results:"+this.totalResults+"]"); + this.results = data[1]; + + var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = errorCodes.DONE; + if(this.searchUtils.totalResults == 0 ){ + this.searchUtils.status = errorCodes.NONE; + } + }, + err => { + console.log(err); + //TODO check erros (service not available, bad request) + // if( ){ + // this.searchUtils.status = ErrorCodes.ERROR; + // } + var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = errorCodes.ERROR; + } + ); + } +} + public getResultsForEntity(entity:string, id:string, page: number, size: number){ + var parameters = ""; + + if(entity == "organization") { + parameters = "organizations/"+id; + } + + if(parameters != "") { + + this._searchDataprovidersService.searchDataprovidersForEntity(parameters, page, size).subscribe( + data => { + this.searchUtils.totalResults = data[0]; + console.info("search Dataproviders for "+entity+": [Parameters:"+parameters+" ] [total results:"+this.searchUtils.totalResults+"]"); + this.results = data[1]; + + var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = errorCodes.DONE; + if(this.searchUtils.totalResults == 0 ){ + this.searchUtils.status = errorCodes.NONE; + } + }, + err => { + console.log(err); + //TODO check erros (service not available, bad request) + // if( ){ + // this.searchUtils.status = ErrorCodes.ERROR; + // } + var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = errorCodes.ERROR; + } + ); + } + } + + public getResultsForDataproviders(id:string, page: number, size: number){ + + this._searchDataprovidersService.getDataProvidersforEntityRegistry(id, page, size).subscribe( + data => { + this.searchUtils.totalResults = data[0]; + console.info("search Dataproviders for Entity Registry: [Id:"+id+" ] [total results:"+this.searchUtils.totalResults+"]"); + this.results = data[1]; + + var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = errorCodes.DONE; + if(this.searchUtils.totalResults == 0 ){ + this.searchUtils.status = errorCodes.NONE; + } + }, + err => { + console.log(err); + //TODO check erros (service not available, bad request) + // if( ){ + // this.searchUtils.status = ErrorCodes.ERROR; + // } + var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = errorCodes.ERROR; + } + ); + } + + public getResults(keyword:string,refine:boolean, page: number, size: number){ + var parameters = ""; + if(keyword.length > 0){ + parameters = "q="+ keyword; + } + this._getResults(parameters,refine,page,this.searchUtils.size); + } + private _getResults(parameters:string,refine:boolean, page: number, size: number){ + this.csvParams = parameters; + + // if(!refine && !this.searchPage){ + // this.searchPage = new SearchPageComponent(this._location); + // } + var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = errorCodes.LOADING; + + this.searchPage.openLoading(); + + this.subResults = this._searchDataprovidersService.searchDataproviders(parameters,(refine)?this.searchPage.getRefineFieldsQuery():null, page, size, this.searchPage.getFields()).subscribe( + data => { + this.searchUtils.totalResults = data[0]; + console.info("search Data Providers: [Parameters:"+parameters+" ] [total results:"+this.searchUtils.totalResults+"]"); + this.results = data[1]; + if(refine){ + this.filters = data[2]; + } + this.searchPage.checkSelectedFilters(this.filters); + // this.filters = this.searchPage.checkSelectedFilters(data[2]); + this.searchPage.updateBaseUrlWithParameters(this.filters); + var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = errorCodes.DONE; + if(this.searchUtils.totalResults == 0 ){ + this.searchUtils.status = errorCodes.NONE; + } + this.searchPage.closeLoading(); + }, + err => { + console.log(err); + //TODO check erros (service not available, bad request) + // if( ){ + // this.searchUtils.status = ErrorCodes.ERROR; + // } + var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = errorCodes.ERROR; + this.searchPage.closeLoading(); + } + ); + } + + private setFilters(){ + //TODO set filters from + } + + public queryChanged($event) { + var parameters = $event.value; + this._getResults(parameters, true, this.searchUtils.page, this.searchUtils.size); + } + + public downloadClicked($event) { + if(!this.CSVDownloaded) { + this.CSVDownloaded = false; + + var parameters = $event.value; + + //this.getResultsCSV(parameters, false, 1, 1000); + + this._searchDataprovidersService.searchDataprovidersCSV(parameters, this.searchPage.getRefineFieldsQuery(), 1, 1000).subscribe( + data => { + this.CSV.export = data; + ExportCSVComponent.downloadCSV(this.CSV, "dataproviders.csv"); + + var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = errorCodes.DONE; + if(this.searchUtils.totalResults == 0 ){ + this.searchUtils.status = errorCodes.NONE; + } + }, + err => { + console.log(err); + //TODO check erros (service not available, bad request) + // if( ){ + // this.searchUtils.status = ErrorCodes.ERROR; + // } + var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = errorCodes.ERROR; + } + ); + /* + this.CSV.export.push( + [ + this.quote(project.name), + this.quote(project.acronym), + this.quote(project.code), + this.quote(project.funder), + this.quote(project.fundingStream), + this.quote(project.fundingLevel1), + this.quote(project.fundingLevel2), + this.quote(project.sc39), + this.quote(project.startDate), + this.quote(project.endDate) + ]); + }*/ + } + } + +} diff --git a/workingUIKIT/src/app/searchPages/simple/searchDatasets-routing.module.ts b/workingUIKIT/src/app/searchPages/simple/searchDatasets-routing.module.ts new file mode 100644 index 00000000..a3f3e976 --- /dev/null +++ b/workingUIKIT/src/app/searchPages/simple/searchDatasets-routing.module.ts @@ -0,0 +1,15 @@ +import { NgModule } from '@angular/core'; +import { RouterModule } from '@angular/router'; + +import{SearchDatasetsComponent} from './searchDatasets.component'; +import {FreeGuard} from'../../login/freeGuard.guard'; + +@NgModule({ + imports: [ + RouterModule.forChild([ + { path: '', component: SearchDatasetsComponent, canActivate: [FreeGuard] } + + ]) + ] +}) +export class SearchDatasetsRoutingModule { } diff --git a/workingUIKIT/src/app/searchPages/simple/searchDatasets.component.ts b/workingUIKIT/src/app/searchPages/simple/searchDatasets.component.ts new file mode 100644 index 00000000..15d7b32d --- /dev/null +++ b/workingUIKIT/src/app/searchPages/simple/searchDatasets.component.ts @@ -0,0 +1,221 @@ +import {Component, Input, ViewChild} from '@angular/core'; +import { ActivatedRoute} from '@angular/router'; +import {Location} from '@angular/common'; +import { Filter, Value} from '../searchUtils/searchHelperClasses.class'; + +import {SearchDatasetsService} from '../../services/searchDatasets.service'; +import {SearchResult} from '../../utils/entities/searchResult'; +import {OpenaireProperties, ErrorCodes} from '../../utils/properties/openaireProperties'; +import {SearchFields} from '../../utils/properties/searchFields'; +import {SearchPageComponent } from '../searchUtils/searchPage.component'; +import {SearchUtilsClass } from '../searchUtils/searchUtils.class'; +import {DOI} from '../../utils/string-utils.class'; + +@Component({ + selector: 'search-datasets', + template: ` + + + + ` +}) + +export class SearchDatasetsComponent { + public results =[]; + public filters: Filter[] =[]; + // public totalResults:number = 0 ; + public baseUrl:string; + + public searchUtils:SearchUtilsClass = new SearchUtilsClass(); + private sub: any; + private subResults: any; + private searchFields:SearchFields = new SearchFields(); + public refineFields: string[] = this.searchFields.RESULT_REFINE_FIELDS; + public fieldIdsMap=this.searchFields.RESULT_FIELDS; + private urlParams : Map; + private _location:Location; + public csvParams: string; + + @ViewChild (SearchPageComponent) searchPage : SearchPageComponent ; + constructor (private route: ActivatedRoute, private _searchDatasetsService: SearchDatasetsService ) { + + var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status =errorCodes.LOADING; + this.searchUtils.page =1; + this.baseUrl = OpenaireProperties.getLinkToSearchDatasets(); + + } + + public ngOnInit() { + this.searchPage.refineFields = this.refineFields; + this.searchPage.fieldIdsMap = this.fieldIdsMap; + this.searchPage.type = "datasets"; + var firstLoad =true; + this.sub = this.route.queryParams.subscribe(params => { + this.searchUtils.keyword = (params['keyword']?params['keyword']:''); + var refine = true; + if(this.searchUtils.page != ((params['page']=== undefined)?1:+params['page']) && this.filters && !firstLoad){ + refine = false; + } + firstLoad = false; + this.searchUtils.page = (params['page']=== undefined)?1:+params['page']; + + var queryParameters = this.searchPage.getQueryParametersFromUrl(params); + this._getResults(queryParameters, refine, this.searchUtils.page, this.searchUtils.size); + + }); + } + + public ngOnDestroy() { + if(this.sub){ + this.sub.unsubscribe(); + } + if(this.subResults){ + this.subResults.unsubscribe(); + } + } + + +public getResultsForEntity(entity:string, id:string, page: number, size: number){ + var parameters = ""; + + if(entity == "project") { + parameters = "projects/"+id; + } else if(entity == "person") { + parameters = "people/"+id; + } + + if(parameters != "") { + + this._searchDatasetsService.searchDatasetsForEntity(parameters, page, size).subscribe( + data => { + this.searchUtils.totalResults = data[0]; + console.info("search Datasets for "+entity+": [Parameters:"+parameters+" ] [total results:"+this.searchUtils.totalResults+"]"); + this.results = data[1]; + + var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = errorCodes.DONE; + if(this.searchUtils.totalResults == 0 ){ + this.searchUtils.status = errorCodes.NONE; + } + }, + err => { + console.log(err); + //TODO check erros (service not available, bad request) + // if( ){ + // this.searchUtils.status = ErrorCodes.ERROR; + // } + var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = errorCodes.ERROR; + } + ); + } +} + +public getResultsForDataproviders(id:string, resultsFrom:string, page: number, size: number){ + var parameters; + if(resultsFrom == "collectedFrom") { + parameters = "datasets?fq=collectedfromdatasourceid exact "+'"'+id+'"'; + } else if(resultsFrom == "hostedBy") { + parameters = "datasets?fq=resulthostingdatasourceid exact "+'"'+id+'"'; + } + + if(parameters != "") { + + this._searchDatasetsService.searchDatasetsForDataproviders(parameters, page, size).subscribe( + data => { + this.searchUtils.totalResults = data[0]; + console.info("search Datasets for Dataproviders: [Parameters:"+parameters+" ] [total results:"+this.searchUtils.totalResults+"]"); + this.results = data[1]; + + var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = errorCodes.DONE; + if(this.searchUtils.totalResults == 0 ){ + this.searchUtils.status = errorCodes.NONE; + } + }, + err => { + console.log(err); + //TODO check erros (service not available, bad request) + // if( ){ + // this.searchUtils.status = ErrorCodes.ERROR; + // } + var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = errorCodes.ERROR; + } + ); + } +} + +public getResults(keyword:string,refine:boolean, page: number, size: number){ + var parameters = ""; + if(keyword.length > 0){ + var DOIs:string[] = DOI.getDOIsFromString(keyword); + var doisParams = ""; + for(var i =0 ;i < DOIs.length; i++){ + doisParams+=(doisParams.length > 0?"&":"")+'doi="'+ DOIs[i]+'"'; + } + if(doisParams.length > 0){ + parameters += "&"+doisParams; + }else{ + parameters = "q=" + keyword; + } + } + this._getResults(parameters,refine,page,size); +} +private _getResults(parameters:string,refine:boolean, page: number, size: number){ + this.csvParams = parameters; + + // if(!refine && !this.searchPage){ + // this.searchPage = new SearchPageComponent(this._location); + // } + var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = errorCodes.LOADING; + this.searchPage.openLoading(); + + this.subResults = this._searchDatasetsService.searchDatasets(parameters,(refine)?this.searchPage.getRefineFieldsQuery():null, page, size, this.searchPage.getFields()).subscribe( + data => { + this.searchUtils.totalResults = data[0]; + console.info("search Datasets: [Parameters:"+parameters+" ] [total results:"+this.searchUtils.totalResults+"]"); + this.results = data[1]; + if(refine){ + this.filters = data[2]; + } + this.searchPage.checkSelectedFilters(this.filters); + this.searchPage.updateBaseUrlWithParameters(this.filters); + var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = errorCodes.DONE; + if(this.searchUtils.totalResults == 0 ){ + this.searchUtils.status = errorCodes.NONE; + } + this.searchPage.closeLoading(); + }, + err => { + console.log(err); + //TODO check erros (service not available, bad request) + // if( ){ + // this.searchUtils.status = ErrorCodes.ERROR; + // } + var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = errorCodes.ERROR; + this.searchPage.closeLoading(); + } + ); +} + + + + private setFilters(){ + //TODO set filters from + } + + public queryChanged($event) { + var parameters = $event.value; + //this.getResults(parameters, this.searchUtils.page, this.searchUtils.size, "searchPage"); + this._getResults(parameters, true, this.searchUtils.page, this.searchUtils.size); + } +} diff --git a/workingUIKIT/src/app/searchPages/simple/searchDatasets.module.ts b/workingUIKIT/src/app/searchPages/simple/searchDatasets.module.ts new file mode 100644 index 00000000..d686200d --- /dev/null +++ b/workingUIKIT/src/app/searchPages/simple/searchDatasets.module.ts @@ -0,0 +1,32 @@ +import { NgModule} from '@angular/core'; +import { CommonModule } from '@angular/common'; +import { FormsModule } from '@angular/forms'; + +import{ SearchDatasetsRoutingModule} from './searchDatasets-routing.module'; +import{SearchDatasetsComponent} from './searchDatasets.component'; + +import {SearchResultsModule } from '../searchUtils/searchResults.module'; + +import {DatasetsServiceModule} from '../../services/datasetsService.module'; +import {SearchFormModule} from '../searchUtils/searchForm.module'; +import {SearchPageModule} from '../searchUtils/searchPage.module'; +import {FreeGuard} from'../../login/freeGuard.guard'; + +@NgModule({ + imports: [ + CommonModule, FormsModule, + + DatasetsServiceModule, + SearchFormModule, SearchResultsModule, SearchDatasetsRoutingModule, SearchPageModule + + ], + declarations: [ + SearchDatasetsComponent + ], + providers:[FreeGuard + ], + exports: [ + SearchDatasetsComponent + ] +}) +export class SearchDatasetsModule { } diff --git a/workingUIKIT/src/app/searchPages/simple/searchOrganizations-routing.module.ts b/workingUIKIT/src/app/searchPages/simple/searchOrganizations-routing.module.ts new file mode 100644 index 00000000..cb8ff00d --- /dev/null +++ b/workingUIKIT/src/app/searchPages/simple/searchOrganizations-routing.module.ts @@ -0,0 +1,15 @@ +import { NgModule } from '@angular/core'; +import { RouterModule } from '@angular/router'; + +import{SearchOrganizationsComponent} from './searchOrganizations.component'; +import {FreeGuard} from'../../login/freeGuard.guard'; + +@NgModule({ + imports: [ + RouterModule.forChild([ + { path: '', component: SearchOrganizationsComponent, canActivate: [FreeGuard] } + + ]) + ] +}) +export class SearchOrganizationsRoutingModule { } diff --git a/workingUIKIT/src/app/searchPages/simple/searchOrganizations.component.ts b/workingUIKIT/src/app/searchPages/simple/searchOrganizations.component.ts new file mode 100644 index 00000000..4096f835 --- /dev/null +++ b/workingUIKIT/src/app/searchPages/simple/searchOrganizations.component.ts @@ -0,0 +1,133 @@ +import {Component, Input, ViewChild} from '@angular/core'; +import { ActivatedRoute} from '@angular/router'; +import {Location} from '@angular/common'; +import { Filter, Value} from '../searchUtils/searchHelperClasses.class'; +import {SearchOrganizationsService} from '../../services/searchOrganizations.service'; +import {SearchResult} from '../../utils/entities/searchResult'; +import {OpenaireProperties, ErrorCodes} from '../../utils/properties/openaireProperties'; +import {SearchFields} from '../../utils/properties/searchFields'; +import {SearchPageComponent } from '../searchUtils/searchPage.component'; +import {SearchUtilsClass } from '../searchUtils/searchUtils.class'; + +@Component({ + selector: 'search-organizations', + template: ` + + + + + ` + +}) +export class SearchOrganizationsComponent { + public results =[]; + public filters =[]; + public baseUrl:string; + public searchUtils:SearchUtilsClass = new SearchUtilsClass(); + public sub: any; + public subResults: any; + public searchFields:SearchFields = new SearchFields(); + public refineFields: string[] = this.searchFields.ORGANIZATION_REFINE_FIELDS; + public fieldIdsMap = this.searchFields.ORGANIZATION_FIELDS; + public urlParams : Map; + public _location:Location; + public csvParams: string; + + @ViewChild (SearchPageComponent) searchPage : SearchPageComponent ; + + constructor (private route: ActivatedRoute, private _searchOrganizationsService: SearchOrganizationsService ) { + + var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status =errorCodes.LOADING; + this.searchUtils.page =1; + this.baseUrl = OpenaireProperties.getLinkToSearchOrganizations(); + + } + + public ngOnInit() { + this.searchPage.refineFields = this.refineFields; + this.searchPage.fieldIdsMap = this.fieldIdsMap; + var firstLoad = true; + this.sub = this.route.queryParams.subscribe(params => { + this.searchUtils.keyword = (params['keyword']?params['keyword']:''); + var refine = true; + if(this.searchUtils.page != ((params['page']=== undefined)?1:+params['page']) && this.filters && !firstLoad){ + refine = false; + + } + firstLoad = false; + this.searchUtils.page = (params['page']=== undefined)?1:+params['page']; + + var queryParameters = this.searchPage.getQueryParametersFromUrl(params); + this._getResults(queryParameters, refine, this.searchUtils.page, this.searchUtils.size); + }); + } + + public ngOnDestroy() { + if(this.sub){ + this.sub.unsubscribe(); + } + if(this.subResults){ + this.subResults.unsubscribe(); + } + } + + + public getResults(keyword:string,refine:boolean, page: number, size: number){ + var parameters = ""; + if(keyword.length > 0){ + parameters = "q=" + keyword; + } + this._getResults(parameters,refine,page,this.searchUtils.size); + } + private _getResults(parameters:string,refine:boolean, page: number, size: number){ + this.csvParams = parameters; + + // if(!refine && !this.searchPage){ + // this.searchPage = new SearchPageComponent(this._location); + // } + var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = errorCodes.LOADING; + this.searchPage.openLoading(); + + this.subResults = this._searchOrganizationsService.searchOrganizations(parameters,(refine)?this.searchPage.getRefineFieldsQuery():null, page, size, this.searchPage.getFields()).subscribe( + data => { + this.searchUtils.totalResults = data[0]; + console.info("search Organizations: [Parameters:"+parameters+" ] [total results:"+this.searchUtils.totalResults+"]"); + this.results = data[1]; + if(refine){ + this.filters = data[2]; + } + this.searchPage.checkSelectedFilters(this.filters); + this.searchPage.updateBaseUrlWithParameters(this.filters); + var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = errorCodes.DONE; + if(this.searchUtils.totalResults == 0 ){ + this.searchUtils.status = errorCodes.NONE; + } + this.searchPage.closeLoading(); + }, + err => { + console.log(err); + //TODO check erros (service not available, bad request) + // if( ){ + // this.searchUtils.status = ErrorCodes.ERROR; + // } + var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = errorCodes.ERROR; + this.searchPage.closeLoading(); + } + ); + } + + + public queryChanged($event) { + var parameters = $event.value; + console.info("queryChanged: Execute search query "+parameters); + this._getResults(parameters, true, this.searchUtils.page, this.searchUtils.size); + } +} diff --git a/workingUIKIT/src/app/searchPages/simple/searchOrganizations.module.ts b/workingUIKIT/src/app/searchPages/simple/searchOrganizations.module.ts new file mode 100644 index 00000000..4f50fe2a --- /dev/null +++ b/workingUIKIT/src/app/searchPages/simple/searchOrganizations.module.ts @@ -0,0 +1,32 @@ +import { NgModule} from '@angular/core'; +import { CommonModule } from '@angular/common'; +import { FormsModule } from '@angular/forms'; + +import{ SearchOrganizationsRoutingModule} from './searchOrganizations-routing.module'; +import{SearchOrganizationsComponent} from './searchOrganizations.component'; + +import {SearchResultsModule } from '../searchUtils/searchResults.module'; + +import {OrganizationsServiceModule} from '../../services/organizationsService.module'; +import {SearchFormModule} from '../searchUtils/searchForm.module'; +import {SearchPageModule} from '../searchUtils/searchPage.module'; +import {FreeGuard} from'../../login/freeGuard.guard'; + +@NgModule({ + imports: [ + CommonModule, FormsModule, + + OrganizationsServiceModule, + SearchFormModule, SearchResultsModule, SearchOrganizationsRoutingModule, SearchPageModule + + ], + declarations: [ + SearchOrganizationsComponent + ], + providers:[FreeGuard + ], + exports: [ + SearchOrganizationsComponent + ] +}) +export class SearchOrganizationsModule { } diff --git a/workingUIKIT/src/app/searchPages/simple/searchPeople-routing.module.ts b/workingUIKIT/src/app/searchPages/simple/searchPeople-routing.module.ts new file mode 100644 index 00000000..210130c7 --- /dev/null +++ b/workingUIKIT/src/app/searchPages/simple/searchPeople-routing.module.ts @@ -0,0 +1,15 @@ +import { NgModule } from '@angular/core'; +import { RouterModule } from '@angular/router'; + +import{SearchPeopleComponent} from './searchPeople.component'; +import {FreeGuard} from'../../login/freeGuard.guard'; + +@NgModule({ + imports: [ + RouterModule.forChild([ + { path: '', component: SearchPeopleComponent, canActivate: [FreeGuard] } + + ]) + ] +}) +export class SearchPeopleRoutingModule { } diff --git a/workingUIKIT/src/app/searchPages/simple/searchPeople.component.ts b/workingUIKIT/src/app/searchPages/simple/searchPeople.component.ts new file mode 100644 index 00000000..2628f7a6 --- /dev/null +++ b/workingUIKIT/src/app/searchPages/simple/searchPeople.component.ts @@ -0,0 +1,121 @@ +import {Component, Input, ViewChild} from '@angular/core'; +import { ActivatedRoute} from '@angular/router'; +import {Location} from '@angular/common'; + +import { Filter, Value} from '../searchUtils/searchHelperClasses.class'; + +import {SearchPeopleService} from '../../services/searchPeople.service'; +import {SearchResult} from '../../utils/entities/searchResult'; +import {OpenaireProperties, ErrorCodes} from '../../utils/properties/openaireProperties'; +import {SearchFields} from '../../utils/properties/searchFields'; +import {SearchPageComponent } from '../searchUtils/searchPage.component'; +import {SearchUtilsClass } from '../searchUtils/searchUtils.class'; + +@Component({ + selector: 'search-people', + template: ` + + + + + ` + +}) +export class SearchPeopleComponent { + public results =[]; + public filters =[]; + public baseUrl:string; + public searchUtils:SearchUtilsClass = new SearchUtilsClass(); + public sub: any; + public _location:Location; + public searchFields:SearchFields = new SearchFields(); + public refineFields = this.searchFields.PERSON_REFINE_FIELDS; + public csvParams: string; + + @ViewChild (SearchPageComponent) searchPage : SearchPageComponent ; + + constructor (private route: ActivatedRoute, private _searchPeopleService: SearchPeopleService ) { + //this.results =[]; + //this.filters =[]; + var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status =errorCodes.LOADING; + this.baseUrl = OpenaireProperties.getLinkToSearchPeople(); + //get refine field filters from url parameters + // if(!this.searchPage){ + // this.searchPage = new SearchPageComponent(this._location); + // } + } + + public ngOnInit() { + this.searchPage.refineFields = this.refineFields; //TODO make it work as a directive + this.sub = this.route.queryParams.subscribe(params => { + this.searchUtils.keyword = (params['keyword']?params['keyword']:''); + this.searchUtils.page = (params['page']=== undefined)?1:+params['page']; + + this.getResults(this.searchUtils.keyword, false, this.searchUtils.page, this.searchUtils.size); + + + }); + } + + public ngOnDestroy() { + this.sub.unsubscribe(); + } + +public getResults(keyword:string,refine:boolean, page: number, size: number){ + var parameters = ""; + if(keyword.length > 0){ + parameters = "q="+ keyword; + } + this._getResults(parameters,refine,page,this.searchUtils.size); +} +private _getResults(parameters:string,refine:boolean, page: number, size: number){ + this.csvParams = parameters; + + var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = errorCodes.LOADING; + this.searchPage.openLoading(); + + this._searchPeopleService.searchPeople(parameters,(refine)?this.searchPage.getRefineFieldsQuery():null, page, size, this.searchPage.getFields()).subscribe( + data => { + this.searchUtils.totalResults = data[0]; + console.info("search People: [Parameters:"+parameters+" ] [total results:"+this.searchUtils.totalResults+"]"); + this.results = data[1]; + this.filters = this.searchPage.checkSelectedFilters(data[2]); + this.searchPage.updateBaseUrlWithParameters(this.filters); + var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = errorCodes.DONE; + if(this.searchUtils.totalResults == 0 ){ + this.searchUtils.status = errorCodes.NONE; + } + this.searchPage.closeLoading(); + }, + err => { + console.log(err); + //TODO check erros (service not available, bad request) + // if( ){ + // this.searchUtils.status = ErrorCodes.ERROR; + // } + var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = errorCodes.ERROR; + this.searchPage.closeLoading(); + } + ); +} + + private setFilters(){ + //TODO set filters from + } + + public queryChanged($event) { + var parameters = $event.value; + console.info("queryChanged: Execute search query "+parameters); + this._getResults(parameters, true, this.searchUtils.page, this.searchUtils.size); + } + + +} diff --git a/workingUIKIT/src/app/searchPages/simple/searchPeople.module.ts b/workingUIKIT/src/app/searchPages/simple/searchPeople.module.ts new file mode 100644 index 00000000..2cdc30de --- /dev/null +++ b/workingUIKIT/src/app/searchPages/simple/searchPeople.module.ts @@ -0,0 +1,32 @@ +import { NgModule} from '@angular/core'; +import { CommonModule } from '@angular/common'; +import { FormsModule } from '@angular/forms'; + +import{ SearchPeopleRoutingModule} from './searchPeople-routing.module'; +import{SearchPeopleComponent} from './searchPeople.component'; + +import {SearchResultsModule } from '../searchUtils/searchResults.module'; + +import {PeopleServiceModule} from '../../services/peopleService.module'; +import {SearchFormModule} from '../searchUtils/searchForm.module'; +import {SearchPageModule} from '../searchUtils/searchPage.module'; +import {FreeGuard} from'../../login/freeGuard.guard'; + +@NgModule({ + imports: [ + CommonModule, FormsModule, + + PeopleServiceModule, + SearchFormModule, SearchResultsModule, SearchPeopleRoutingModule, SearchPageModule + + ], + declarations: [ + SearchPeopleComponent + ], + providers:[FreeGuard + ], + exports: [ + SearchPeopleComponent + ] +}) +export class SearchPeopleModule { } diff --git a/workingUIKIT/src/app/searchPages/simple/searchProjects-routing.module.ts b/workingUIKIT/src/app/searchPages/simple/searchProjects-routing.module.ts new file mode 100644 index 00000000..11f2e575 --- /dev/null +++ b/workingUIKIT/src/app/searchPages/simple/searchProjects-routing.module.ts @@ -0,0 +1,15 @@ +import { NgModule } from '@angular/core'; +import { RouterModule } from '@angular/router'; + +import{SearchProjectsComponent} from './searchProjects.component'; +import {FreeGuard} from'../../login/freeGuard.guard'; + +@NgModule({ + imports: [ + RouterModule.forChild([ + { path: '', component: SearchProjectsComponent, canActivate: [FreeGuard] } + + ]) + ] +}) +export class SearchProjectsRoutingModule { } diff --git a/workingUIKIT/src/app/searchPages/simple/searchProjects.component.ts b/workingUIKIT/src/app/searchPages/simple/searchProjects.component.ts new file mode 100644 index 00000000..fa865c7c --- /dev/null +++ b/workingUIKIT/src/app/searchPages/simple/searchProjects.component.ts @@ -0,0 +1,165 @@ +import {Component, Input, ViewChild} from '@angular/core'; +import { ActivatedRoute} from '@angular/router'; +import {Location} from '@angular/common'; +import { Filter, Value} from '../searchUtils/searchHelperClasses.class'; +import {SearchProjectsService} from '../../services/searchProjects.service'; +import {SearchResult} from '../../utils/entities/searchResult'; +import {OpenaireProperties, ErrorCodes} from '../../utils/properties/openaireProperties'; +import {SearchFields} from '../../utils/properties/searchFields'; +import {SearchPageComponent } from '../searchUtils/searchPage.component'; +import {SearchUtilsClass } from '../searchUtils/searchUtils.class'; + +@Component({ + selector: 'search-projects', + template: ` + + + + ` + +}) +export class SearchProjectsComponent { + public results =[]; + public filters: Filter[] =[]; + public baseUrl:string; + public searchUtils:SearchUtilsClass = new SearchUtilsClass(); + public sub: any; + public subResults: any; + public searchFields:SearchFields = new SearchFields(); + public refineFields: string[] = this.searchFields.PROJECT_REFINE_FIELDS; + public fieldIdsMap = this.searchFields.PROJECT_FIELDS; + public urlParams : Map; + public _location:Location; + public csvParams: string; + + @ViewChild (SearchPageComponent) searchPage : SearchPageComponent ; + + constructor (private route: ActivatedRoute, private _searchProjectsService: SearchProjectsService) { + console.info(" constructor SearchProjectsComponent "+this.refineFields.length); + + var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status =errorCodes.LOADING; + this.searchUtils.page =1; + this.baseUrl = OpenaireProperties.getLinkToSearchProjects(); + + } + + public ngOnInit() { + this.searchPage.refineFields = this.refineFields; + this.searchPage.fieldIdsMap = this.fieldIdsMap; + console.info(" ngOnInit SearchProjectsComponent "+this.refineFields.length); + //get refine field filters from url parameters + var firstLoad = true; + this.sub = this.route.queryParams.subscribe(params => { + + //get keyword from url parameters + this.searchUtils.keyword = (params['keyword']?params['keyword']:''); + var refine = true; + if(this.searchUtils.page != ((params['page']=== undefined)?1:+params['page']) && this.filters && !firstLoad){ + refine = false; + + } + firstLoad = false; + //get page from url parameters + this.searchUtils.page = (params['page']=== undefined)?1:+params['page']; + var queryParameters = this.searchPage.getQueryParametersFromUrl(params); + this._getResults(queryParameters, refine, this.searchUtils.page, this.searchUtils.size); + }); + } + + public ngOnDestroy() { + if(this.sub){ + this.sub.unsubscribe(); + } + if(this.subResults){ + this.subResults.unsubscribe(); + } + } + + public getResults(keyword:string,refine:boolean, page: number, size: number){ + var parameters = ""; + if(keyword.length > 0){ + parameters = "q="+keyword; + } + this._getResults(parameters,refine,page,this.searchUtils.size); + } + private _getResults(parameters:string,refine:boolean, page: number, size: number){ + this.csvParams = parameters; + + // if(!refine && !this.searchPage){ + // this.searchPage = new SearchPageComponent(this._location); + // } + + var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = errorCodes.LOADING; + this.searchPage.openLoading(); + + this.subResults = this._searchProjectsService.searchProjects(parameters,(refine)?this.searchPage.getRefineFieldsQuery():null, page, size, this.searchPage.getFields()).subscribe( + data => { + this.searchUtils.totalResults = data[0]; + console.info("search Projects: [Parameters:"+parameters+" ] [total results:"+this.searchUtils.totalResults+"]"); + this.results = data[1]; + if(refine){ + this.filters = data[2]; + } + this.searchPage.checkSelectedFilters(this.filters); + // this.filters = this.searchPage.checkSelectedFilters(data[2]); + this.searchPage.updateBaseUrlWithParameters(this.filters); + var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = errorCodes.DONE; + if(this.searchUtils.totalResults == 0 ){ + this.searchUtils.status = errorCodes.NONE; + } + this.searchPage.closeLoading(); + }, + err => { + console.log(err); + //TODO check erros (service not available, bad request) + // if( ){ + // this.searchUtils.status = ErrorCodes.ERROR; + // } + var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = errorCodes.ERROR; + this.searchPage.closeLoading(); + } + ); + } + + public getResultsForDataproviders(id:string, page: number, size: number){ + + this._searchProjectsService.getProjectsforDataProvider(id, page, size).subscribe( + data => { + this.searchUtils.totalResults = data[0]; + console.info("search Projects for Dataproviders: [Id:"+id+" ] [total results:"+this.searchUtils.totalResults+"]"); + this.results = data[1]; + + var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = errorCodes.DONE; + if(this.searchUtils.totalResults == 0 ){ + this.searchUtils.status = errorCodes.NONE; + } + }, + err => { + console.log(err); + //TODO check erros (service not available, bad request) + // if( ){ + // this.searchUtils.status = ErrorCodes.ERROR; + // } + var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = errorCodes.ERROR; + } + ); + } + + + public queryChanged($event) { + this.urlParams = undefined; + var parameters = $event.value; + this._getResults(parameters, true, this.searchUtils.page, this.searchUtils.size); + } + +} diff --git a/workingUIKIT/src/app/searchPages/simple/searchProjects.module.ts b/workingUIKIT/src/app/searchPages/simple/searchProjects.module.ts new file mode 100644 index 00000000..083f430e --- /dev/null +++ b/workingUIKIT/src/app/searchPages/simple/searchProjects.module.ts @@ -0,0 +1,32 @@ +import { NgModule} from '@angular/core'; +import { CommonModule } from '@angular/common'; +import { FormsModule } from '@angular/forms'; + +import{ SearchProjectsRoutingModule} from './searchProjects-routing.module'; +import{SearchProjectsComponent} from './searchProjects.component'; + +import {SearchResultsModule } from '../searchUtils/searchResults.module'; + +import {ProjectsServiceModule} from '../../services/projectsService.module'; +import {SearchFormModule} from '../searchUtils/searchForm.module'; +import {SearchPageModule} from '../searchUtils/searchPage.module'; +import {FreeGuard} from'../../login/freeGuard.guard'; + +@NgModule({ + imports: [ + CommonModule, FormsModule, + + ProjectsServiceModule, + SearchFormModule, SearchResultsModule, SearchProjectsRoutingModule, SearchPageModule + + ], + declarations: [ + SearchProjectsComponent + ], + providers:[FreeGuard + ], + exports: [ + SearchProjectsComponent + ] +}) +export class SearchProjectsModule { } diff --git a/workingUIKIT/src/app/searchPages/simple/searchPublications-routing.module.ts b/workingUIKIT/src/app/searchPages/simple/searchPublications-routing.module.ts new file mode 100644 index 00000000..ace89403 --- /dev/null +++ b/workingUIKIT/src/app/searchPages/simple/searchPublications-routing.module.ts @@ -0,0 +1,15 @@ +import { NgModule } from '@angular/core'; +import { RouterModule } from '@angular/router'; + +import{SearchPublicationsComponent} from './searchPublications.component'; +import {FreeGuard} from'../../login/freeGuard.guard'; + +@NgModule({ + imports: [ + RouterModule.forChild([ + { path: '', component: SearchPublicationsComponent, canActivate: [FreeGuard] } + + ]) + ] +}) +export class SearchPublicationsRoutingModule { } diff --git a/workingUIKIT/src/app/searchPages/simple/searchPublications.component.ts b/workingUIKIT/src/app/searchPages/simple/searchPublications.component.ts new file mode 100644 index 00000000..06202a7a --- /dev/null +++ b/workingUIKIT/src/app/searchPages/simple/searchPublications.component.ts @@ -0,0 +1,281 @@ +import {Component, Input, ViewChild} from '@angular/core'; +import { ActivatedRoute} from '@angular/router'; +import {Location} from '@angular/common'; + +import { Filter, Value} from '../searchUtils/searchHelperClasses.class'; + +import {SearchPublicationsService} from '../../services/searchPublications.service'; +import {SearchResult} from '../../utils/entities/searchResult'; +import {OpenaireProperties, ErrorCodes} from '../../utils/properties/openaireProperties'; +import {SearchFields} from '../../utils/properties/searchFields'; +import {SearchPageComponent } from '../searchUtils/searchPage.component'; +import {SearchUtilsClass} from '../searchUtils/searchUtils.class'; +import {ExportCSVComponent} from '../../utils/exportCSV.class'; +import {DOI} from '../../utils/string-utils.class'; + +@Component({ + selector: 'search-publications', + template: ` + + + + + ` + +}) +export class SearchPublicationsComponent { + public results =[]; + public filters =[]; + public searchUtils:SearchUtilsClass = new SearchUtilsClass(); + public baseUrl:string = ""; + public sub: any; + public subResults: any; + public searchFields:SearchFields = new SearchFields(); + public refineFields: string[] = this.searchFields.RESULT_REFINE_FIELDS; + public fieldIdsMap=this.searchFields.RESULT_FIELDS; + //: { [key:string] :{ name:string, operator:string, type:string, indexField:string, equalityOperator:string }} = this.searchFields.PUBLICATION_FIELDS_MAP; + public urlParams : Map; + @ViewChild (SearchPageComponent) searchPage : SearchPageComponent ; + public _location:Location; + + public CSV: any = { "columnNames": ["Title", "Authors", "Publication Year", "DOI", + /*"Download From", "Publication type", "Journal",*/ + "Funder", "Project Name (GA Number)", "Access"], + "export":[] + }; + public CSVDownloaded = false; + public csvParams: string; + + constructor (private route: ActivatedRoute, private _searchPublicationsService: SearchPublicationsService ) { + var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status =errorCodes.LOADING; + this.searchUtils.page =1; + this.baseUrl = OpenaireProperties.getLinkToSearchPublications(); + + } + + public ngOnInit() { + this.searchPage.refineFields = this.refineFields; + this.searchPage.fieldIdsMap = this.fieldIdsMap; + this.searchPage.type = "publications"; + var firstLoad =true; + this.sub = this.route.queryParams.subscribe(params => { + this.searchUtils.keyword = (params['keyword']?params['keyword']:''); + var refine = true; + if(this.searchUtils.page != ((params['page']=== undefined)?1:+params['page']) && this.filters && !firstLoad){ + refine = false; + + } + firstLoad = false; + this.searchUtils.page = (params['page']=== undefined)?1:+params['page']; + var queryParameters = this.searchPage.getQueryParametersFromUrl(params); + this._getResults(queryParameters, refine, this.searchUtils.page, this.searchUtils.size); + }); + } + + public ngOnDestroy() { + if(this.sub){ + this.sub.unsubscribe(); + } + if(this.subResults){ + this.subResults.unsubscribe(); + } + } + +public getResultsForEntity(entity:string, id:string, page: number, size: number){ + var parameters = ""; + + if(entity == "project") { + parameters = "projects/"+id; + } else if(entity == "person") { + parameters = "people/"+id; + } + + if(parameters != "") { + + this._searchPublicationsService.searchPublicationsForEntity(parameters, page, size).subscribe( + data => { + this.searchUtils.totalResults = data[0]; + console.info("search Publications for "+entity+": [Parameters:"+parameters+" ] [total results:"+this.searchUtils.totalResults+"]"); + this.results = data[1]; + + var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = errorCodes.DONE; + if(this.searchUtils.totalResults == 0 ){ + this.searchUtils.status = errorCodes.NONE; + } + }, + err => { + console.log(err); + //TODO check erros (service not available, bad request) + // if( ){ + // this.searchUtils.status = ErrorCodes.ERROR; + // } + var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = errorCodes.ERROR; + } + ); + } +} + +public getResultsForDataproviders(id:string, resultsFrom:string, page: number, size: number){ + var parameters; + if(resultsFrom == "collectedFrom") { + parameters = "publications?fq=collectedfromdatasourceid exact "+'"'+id+'"'; + } else if(resultsFrom == "hostedBy") { + parameters = "publications?fq=resulthostingdatasourceid exact "+'"'+id+'"'; + } + + if(parameters != "") { + + this._searchPublicationsService.searchPublicationsForDataproviders(parameters, page, size).subscribe( + data => { + this.searchUtils.totalResults = data[0]; + console.info("search Publications for Dataproviders: [Parameters:"+parameters+" ] [total results:"+this.searchUtils.totalResults+"]"); + this.results = data[1]; + + var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = errorCodes.DONE; + if(this.searchUtils.totalResults == 0 ){ + this.searchUtils.status = errorCodes.NONE; + } + }, + err => { + console.log(err); + //TODO check erros (service not available, bad request) + // if( ){ + // this.searchUtils.status = ErrorCodes.ERROR; + // } + var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = errorCodes.ERROR; + } + ); + } +} + +public getResults(keyword:string,refine:boolean, page: number, size: number){ + var parameters = ""; + if(keyword.length > 0){ + var DOIs:string[] = DOI.getDOIsFromString(keyword); + var doisParams = ""; + + for(var i =0 ;i < DOIs.length; i++){ + doisParams+=(doisParams.length > 0?"&":"")+'doi="'+ DOIs[i]+'"'; + } + if(doisParams.length > 0){ + parameters += "&"+doisParams; + }else{ + parameters = "q=" + keyword; + } + } + this._getResults(parameters,refine,page,size); +} + +private _getResults(parameters:string,refine:boolean, page: number, size: number){ + this.csvParams = parameters; + + // if(!refine && !this.searchPage){ + // this.searchPage = new SearchPageComponent(this._location); + // } + + var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = errorCodes.LOADING; + this.searchPage.openLoading(); + + this.subResults = this._searchPublicationsService.searchPublications(parameters,(refine)?this.searchPage.getRefineFieldsQuery():null, page, size, this.searchPage.getFields()).subscribe( + data => { + this.searchUtils.totalResults = data[0]; + console.info("search Publications: [Parameters:"+parameters+" ] [total results:"+this.searchUtils.totalResults+"]"); + this.results = data[1]; + if(refine){ + this.filters = data[2]; + } + this.searchPage.checkSelectedFilters(this.filters); + this.searchPage.updateBaseUrlWithParameters(this.filters); + var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = errorCodes.DONE; + if(this.searchUtils.totalResults == 0 ){ + this.searchUtils.status = errorCodes.NONE; + } + this.searchPage.closeLoading(); + }, + err => { + console.log(err); + //TODO check erros (service not available, bad request) + // if( ){ + // this.searchUtils.status = ErrorCodes.ERROR; + // } + var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = errorCodes.ERROR; + this.searchPage.closeLoading(); + + } + ); +} +/* +public getAggregatorResults(id:string, page: number, size: number){ + this.subResults = this._searchPublicationsService.searchAggregators('&fq=collectedfromdatasourceid exact "'+id+'"',"&refine=true&fields=resulthostingdatasource" , page, size).subscribe( + data => { + this.results = data; + + var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = errorCodes.DONE; + if(this.searchUtils.totalResults == 0 ){ + this.searchUtils.status = errorCodes.NONE; + } + }, + err => { + console.log(err); + //TODO check erros (service not available, bad request) + // if( ){ + // this.searchUtils.status = ErrorCodes.ERROR; + // } + var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = errorCodes.ERROR; + } + ); +}*/ + + public queryChanged($event) { + var parameters = $event.value; + console.info("queryChanged: Execute search query "+parameters); + console.info("Search Pubs::page "+this.searchUtils.page); + this._getResults(parameters, true, this.searchUtils.page, this.searchUtils.size); + } + + public downloadClicked($event) { + if(!this.CSVDownloaded) { + this.CSVDownloaded = false; + + var parameters = $event.value; + + //this.getResultsCSV(parameters, false, 1, 1000); + + this._searchPublicationsService.searchPublicationsCSV(parameters, this.searchPage.getRefineFieldsQuery(), 1, 1000).subscribe( + data => { + this.CSV.export = data; + ExportCSVComponent.downloadCSV(this.CSV, "publications.csv"); + + var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = errorCodes.DONE; + }, + err => { + console.log(err); + //TODO check erros (service not available, bad request) + // if( ){ + // this.searchUtils.status = ErrorCodes.ERROR; + // } + var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = errorCodes.ERROR; + } + ); + + } + } + +} diff --git a/workingUIKIT/src/app/searchPages/simple/searchPublications.module.ts b/workingUIKIT/src/app/searchPages/simple/searchPublications.module.ts new file mode 100644 index 00000000..20ea399e --- /dev/null +++ b/workingUIKIT/src/app/searchPages/simple/searchPublications.module.ts @@ -0,0 +1,32 @@ +import { NgModule} from '@angular/core'; +import { CommonModule } from '@angular/common'; +import { FormsModule } from '@angular/forms'; + +import{ SearchPublicationsRoutingModule} from './searchPublications-routing.module'; +import{SearchPublicationsComponent} from './searchPublications.component'; + +import {SearchResultsModule } from '../searchUtils/searchResults.module'; + +import {PublicationsServiceModule} from '../../services/publicationsService.module'; +import {SearchFormModule} from '../searchUtils/searchForm.module'; +import {SearchPageModule} from '../searchUtils/searchPage.module'; +import {FreeGuard} from'../../login/freeGuard.guard'; + +@NgModule({ + imports: [ + CommonModule, FormsModule, + + PublicationsServiceModule, + SearchFormModule, SearchResultsModule, SearchPublicationsRoutingModule, SearchPageModule + + ], + declarations: [ + SearchPublicationsComponent + ], + providers:[FreeGuard + ], + exports: [ + SearchPublicationsComponent + ] +}) +export class SearchPublicationsModule { } diff --git a/workingUIKIT/src/app/services/dataProvidersService.module.ts b/workingUIKIT/src/app/services/dataProvidersService.module.ts new file mode 100644 index 00000000..88e7b6df --- /dev/null +++ b/workingUIKIT/src/app/services/dataProvidersService.module.ts @@ -0,0 +1,20 @@ +import { NgModule} from '@angular/core'; +import { CommonModule } from '@angular/common'; +import { FormsModule } from '@angular/forms'; + +import {SearchDataprovidersService} from './searchDataproviders.service'; + + +@NgModule({ + imports: [ + CommonModule, FormsModule + ], + declarations: [ + ], + providers:[ + SearchDataprovidersService +], + exports: [ + ] +}) +export class DataProvidersServiceModule { } diff --git a/workingUIKIT/src/app/services/datasetsService.module.ts b/workingUIKIT/src/app/services/datasetsService.module.ts new file mode 100644 index 00000000..e5298338 --- /dev/null +++ b/workingUIKIT/src/app/services/datasetsService.module.ts @@ -0,0 +1,20 @@ +import { NgModule} from '@angular/core'; +import { CommonModule } from '@angular/common'; +import { FormsModule } from '@angular/forms'; + +import {SearchDatasetsService} from './searchDatasets.service'; + + +@NgModule({ + imports: [ + CommonModule, FormsModule + ], + declarations: [ + ], + providers:[ + SearchDatasetsService +], + exports: [ + ] +}) +export class DatasetsServiceModule { } diff --git a/workingUIKIT/src/app/services/metrics.service.ts b/workingUIKIT/src/app/services/metrics.service.ts new file mode 100644 index 00000000..aa3019af --- /dev/null +++ b/workingUIKIT/src/app/services/metrics.service.ts @@ -0,0 +1,88 @@ +import {Injectable} from '@angular/core'; +import {Http, Response} from '@angular/http'; +import {Observable} from 'rxjs/Observable'; +import {Metrics} from '../utils/entities/metrics'; +import {OpenaireProperties} from '../utils/properties/openaireProperties'; +import 'rxjs/add/operator/do'; +import { CacheService } from '../shared/cache.service'; +@Injectable() +export class MetricsService { + metrics: Metrics; + + constructor(private http: Http, public _cache: CacheService) {} + + getMetrics (id: string, entity: string):any { + console.info("getMetrics in service"); + //let url = OpenaireProperties. getSearchAPIURLLast() + 'publications/' +id+"?format=json"; + let url = OpenaireProperties.getMetricsAPIURL()+entity+"/"+id+"/clicks"; + let key = url; + if (this._cache.has(key)) { + return Observable.of(this._cache.get(key)); + } + + return this.http.get(url) + .map(res => res.json()) + .map(res => this.parseMetrics(res["downloads"], res["views"], res["total_downloads"], res["total_views"], + res["total_openaire_views"], res["total_openaire_downloads"], res["pageviews"])) + .do(res => { + this._cache.set(key, res); + }); + } + + + parseMetrics(downloads: any, views: any, totalDownloads: string, totalViews: string, + totalOpenaireViews: string, totalOpenaireDownloads: string, pageViews: string): any { + this.metrics = new Metrics(); + + this.metrics.totalDownloads = totalDownloads; + this.metrics.totalViews = totalViews; + this.metrics.totalOpenaireViews = totalOpenaireViews; + this.metrics.totalOpenaireDownloads = totalOpenaireDownloads; + this.metrics.pageViews = pageViews; + + this.metrics.infos = new Map(); + + for(let i=0; i request.json().response.browseResults.result) + .do(funders => console.log("getFunders : "+funders)) + .catch(this.handleError) + .do(res => { + this._cache.set(key, res); + }); + + } + + searchForProjects(keyword:string, funderId:string):any { + let url = this.searchUrl+'search?action=search&sTransformer=projects_openaire&query='+ + '%28oaftype+exact+project%29+and+%28%28projecttitle+%3D+%22'+keyword+'%22%29+or+%28projectacronym+%3D+%22'+keyword+'%22%29+or+%28projectcode+%3D+%22'+keyword+'%22%29%29+and+%28funderid+exact+'+funderId+'%29&size=10&locale=en_GB&format=json'; + let key = url; + if (this._cache.has(key)) { + return Observable.of(this._cache.get(key)); + } + + return this.http.get( url) + .map(request => (request.json().response.results)?request.json().response.results.result:request.json().response.results) + .do(funders => console.log("getFunders : "+funders)) + .catch(this.handleError) + .do(res => { + this._cache.set(key, res); + }); + + } + searchForProjectsObs(keyword:string, funderId:string):any { + let url = this.searchUrl+'search?action=search&sTransformer=projects_openaire&query='+ + '%28oaftype+exact+project%29+and+%28%28projecttitle+%3D+%22'+keyword+'%22%29+or+%28projectacronym+%3D+%22'+keyword+'%22%29+or+%28projectcode+%3D+%22'+keyword+'%22%29%29+and+%28funderid+exact+'+funderId+'%29&size=10&locale=en_GB&format=json'; + let key = url; + if (this._cache.has(key)) { + return Observable.of(this._cache.get(key)); + } + + return this.http.get(url).toPromise() + .then(request =>{ + + var valid:boolean= this.isJsonString(request); + if(valid==true){ + return (request.json().response.results)?request.json().response.results.result:request.json().response.result; + }else{ + return []; + } + }) + } + + private handleError (error: Response) { + // 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'); + } + private isJsonString(str) { + console.info("Check jsooon"); + if(str instanceof Array || str instanceof Object) { + try { + str.json(); + } catch (e) { + console.info("INValid"); + return false; + } + console.info("valid"); + return true + } + console.info("INValid"); + return false + } +} diff --git a/workingUIKIT/src/app/services/organization.service.ts b/workingUIKIT/src/app/services/organization.service.ts new file mode 100644 index 00000000..e30ab6f6 --- /dev/null +++ b/workingUIKIT/src/app/services/organization.service.ts @@ -0,0 +1,192 @@ +import {Injectable} from '@angular/core'; +import {Http, Response} from '@angular/http'; +import {Observable} from 'rxjs/Observable'; +import {OrganizationInfo} from '../utils/entities/organizationInfo'; +import {OpenaireProperties} from '../utils/properties/openaireProperties'; +import 'rxjs/add/observable/of'; +import 'rxjs/add/operator/do'; +import 'rxjs/add/operator/share'; +import { CacheService } from '../shared/cache.service'; + +@Injectable() +export class OrganizationService { + + constructor(private http: Http, public _cache: CacheService) {} + + organizationInfo: OrganizationInfo; + + getOrganizationInfo (id: string):any { + console.info("getOrganizationInfo in service"); + //let url = OpenaireProperties. getSearchAPIURLLast()+'organizations/'+id+"?format=json"; + let url = OpenaireProperties.getSearchAPIURLLast()+'resources?format=json&query=( (oaftype exact organization) and (reldatasourcecompatibilityid=driver or reldatasourcecompatibilityid=driver-openaire2.0 or reldatasourcecompatibilityid=openaire2.0 or reldatasourcecompatibilityid=openaire3.0 or reldatasourcecompatibilityid=openaire2.0_data or reldatasourcecompatibilityid=hostedBy or relprojectid=*)) and ( objIdentifier ='+id+')'; + //let url = "http://beta.services.openaire.eu:8480/search/rest/v2/api/resources?format=json&query=(%20(oaftype%20exact%20organization)%20and%20(reldatasourcecompatibilityid=driver%20or%20reldatasourcecompatibilityid=driver-openaire2.0%20or%20reldatasourcecompatibilityid=openaire2.0%20or%20reldatasourcecompatibilityid=openaire3.0%20or%20reldatasourcecompatibilityid=openaire2.0_data%20or%20reldatasourcecompatibilityid=hostedBy%20or%20relprojectid=*))%20and%20(%20objIdentifier%20=dedup_wf_001%3A%3Af1e63493def7cedfa5b497cdbea26faa)"; + let key = url; + if (this._cache.has(key)) { + return Observable.of(this._cache.get(key)).map(res => this.parseOrganizationInfo(res)); + } + + return this.http.get(url) + .map(res => res.json()) + .map(res => res['results'][0]) + //.map(res => res[0]['result']['metadata']['oaf:entity']['oaf:organization']) + //.map(res => [res, res['rels']['rel']]) + .do(res => { + this._cache.set(key, res); + }) + .map(res => this.parseOrganizationInfo(res)); + + + } +/* + getMetrics (id: string):any { + console.info("getOrganizationMetrics in service"); + //let url = OpenaireProperties. getSearchAPIURLLast() + 'publications/' +id+"?format=json"; + let url = OpenaireProperties.getMetricsAPIURL()+"organizations/"+id+"/clicks"; + let key = url; + if (this._cache.has(key)) { + return Observable.of(this._cache.get(key)); + } + return this.http.get(url) + .map(res => res.json()) + .map(res => res['views']) + .do(res => { + this._cache.set(key, res); + }); + } +*/ + private handleError (error: Response) { + // 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'); + } + + parseOrganizationInfo (data: any):any { + console.info("parseOrganizationInfo"); + this.organizationInfo = new OrganizationInfo(); + + let organization; + let relations; + + if(data != null) { + organization = data['result']['metadata']['oaf:entity']['oaf:organization']; + relations = data['result']['metadata']['oaf:entity']['oaf:organization']['rels']['rel']; + } else { + return null; + } + + if(organization != null) { + + if(organization.hasOwnProperty("websiteurl")) { + this.organizationInfo.title = {"name": organization.legalshortname, "url": organization.websiteurl}; + } else { + this.organizationInfo.title = {"name": organization.legalshortname, "url": ''}; + } + + this.organizationInfo.name = organization.legalname; + + if(this.organizationInfo.title.name == '') { + this.organizationInfo.title.name = this.organizationInfo.name; + } + + if(organization.hasOwnProperty("country")) { + this.organizationInfo.country = organization['country'].classname; + } + } + +//Comment Parsing Projects info +/* + if(data[1] != null) { + + let counter; + let length = relations.length!=undefined ? relations.length : 1; + + for(let i=0; i(); + } + + if(!this.organizationInfo.projects.has(relation['funding']['funder'].name)) { + this.organizationInfo.projects.set(relation['funding']['funder'].name, + new Array<{ "name": string, "id": string, "code": string, + "acronym": string, "funder": string, "funderId": string, + "fundingStream": string, "fundingLevel1": string, "fundingLevel2": string, + "sc39": string, "startDate": string, "endDate": string }>()); + } + + counter = this.organizationInfo.projects.get(relation['funding']['funder'].name).length; + this.organizationInfo.projects.get(relation['funding']['funder'].name)[counter] = + { "name": "", "id": "", "code": "", + "acronym": "", "funder": "", "funderId": "", + "fundingStream": "", "fundingLevel1": "", "fundingLevel2": "", + "sc39": "", "startDate": "", "endDate": "" }; + + //let url = ""; + if(relation['to'].content != null && relation['to'].content != "") { + this.organizationInfo.projects.get(relation['funding']['funder'].name)[counter]['id'] = relation['to'].content; + //url = OpenaireProperties.getsearchLinkToProject()+relation['to'].content; + } + this.organizationInfo.projects.get(relation['funding']['funder'].name)[counter]['name'] = relation.title; + //this.organizationInfo.projects.get(relation['funding']['funder'].name)[counter]['url'] = url; + this.organizationInfo.projects.get(relation['funding']['funder'].name)[counter]['code'] = relation.code; + this.organizationInfo.projects.get(relation['funding']['funder'].name)[counter]['acronym'] = relation.acronym; + + this.organizationInfo.projects.get(relation['funding']['funder'].name)[counter]['funder'] = relation['funding']['funder'].shortname; + this.organizationInfo.projects.get(relation['funding']['funder'].name)[counter]['funderId'] = relation['funding']['funder'].id; + if(relation['funding'].hasOwnProperty("funding_level_0")) { + this.organizationInfo.projects.get(relation['funding']['funder'].name)[counter]['fundingStream'] = relation['funding']['funding_level_0'].name; + } + if(relation['funding'].hasOwnProperty("funding_level_1")) { + this.organizationInfo.projects.get(relation['funding']['funder'].name)[counter]['fundingLevel1'] = relation['funding']['funding_level_1'].name; + } + if(relation['funding'].hasOwnProperty("funding_level_2")) { + this.organizationInfo.projects.get(relation['funding']['funder'].name)[counter]['fundingLevel2'] = relation['funding']['funding_level_2'].name; + } + //this.organizationInfo.projects.get(relation['funding']['funder'].name)[counter]['sc39'] = + //this.organizationInfo.projects.get(relation['funding']['funder'].name)[counter]['startDate'] = + //this.organizationInfo.projects.get(relation['funding']['funder'].name)[counter]['endDate'] = + } + } + + } + + + } /*else if(relation['to'].class == "isProvidedBy") { + + if(this.organizationInfo.dataProviders == undefined) { + this.organizationInfo.dataProviders = new Array<{ "name": string, "url": string, "type": string, "websiteUrl": string , "organizations": {"name": string, "url": string}[]}>(); + } + + counter = this.organizationInfo.dataProviders.length; + this.organizationInfo.dataProviders[counter] = { "name": "", "url": "", "type": "", "websiteUrl": "", "organizations": [] } + + let url=""; + if(relation['to'].content != null && relation['to'].content != "") { + url = OpenaireProperties.getsearchLinkToDataProvider()+relation['to'].content; + } + this.organizationInfo.dataProviders[counter]['name'] = relation.officialname; + this.organizationInfo.dataProviders[counter]['url'] = url; + if(relation.hasOwnProperty("datasourcetype")) { + this.organizationInfo.dataProviders[counter]['type'] = relation['datasourcetype'].classname; + } + this.organizationInfo.dataProviders[counter]['websiteUrl'] = relation.websiteurl; + }*/ +/* -----> + } + } + } +*/ + return this.organizationInfo; + + } + +} diff --git a/workingUIKIT/src/app/services/organizationService.module.ts b/workingUIKIT/src/app/services/organizationService.module.ts new file mode 100644 index 00000000..ee150c3e --- /dev/null +++ b/workingUIKIT/src/app/services/organizationService.module.ts @@ -0,0 +1,20 @@ +import { NgModule} from '@angular/core'; +import { CommonModule } from '@angular/common'; +import { FormsModule } from '@angular/forms'; + +import {OrganizationService} from './organization.service'; + + +@NgModule({ + imports: [ + CommonModule, FormsModule + ], + declarations: [ + ], + providers:[ + OrganizationService +], + exports: [ + ] +}) +export class OrganizationServiceModule { } diff --git a/workingUIKIT/src/app/services/organizationsService.module.ts b/workingUIKIT/src/app/services/organizationsService.module.ts new file mode 100644 index 00000000..0810f680 --- /dev/null +++ b/workingUIKIT/src/app/services/organizationsService.module.ts @@ -0,0 +1,20 @@ +import { NgModule} from '@angular/core'; +import { CommonModule } from '@angular/common'; +import { FormsModule } from '@angular/forms'; + +import {SearchOrganizationsService} from './searchOrganizations.service'; + + +@NgModule({ + imports: [ + CommonModule, FormsModule + ], + declarations: [ + ], + providers:[ + SearchOrganizationsService +], + exports: [ + ] +}) +export class OrganizationsServiceModule { } diff --git a/workingUIKIT/src/app/services/peopleService.module.ts b/workingUIKIT/src/app/services/peopleService.module.ts new file mode 100644 index 00000000..fa8692da --- /dev/null +++ b/workingUIKIT/src/app/services/peopleService.module.ts @@ -0,0 +1,20 @@ +import { NgModule} from '@angular/core'; +import { CommonModule } from '@angular/common'; +import { FormsModule } from '@angular/forms'; + +import {SearchPeopleService} from './searchPeople.service'; + + +@NgModule({ + imports: [ + CommonModule, FormsModule + ], + declarations: [ + ], + providers:[ + SearchPeopleService +], + exports: [ + ] +}) +export class PeopleServiceModule { } diff --git a/workingUIKIT/src/app/services/project.service.ts b/workingUIKIT/src/app/services/project.service.ts new file mode 100644 index 00000000..3c9ddf04 --- /dev/null +++ b/workingUIKIT/src/app/services/project.service.ts @@ -0,0 +1,200 @@ +import {Injectable} from '@angular/core'; +import {Http, Response} from '@angular/http'; +import {Observable} from 'rxjs/Observable'; +import {ProjectInfo} from '../utils/entities/projectInfo'; +import {OpenaireProperties} from '../utils/properties/openaireProperties'; +import 'rxjs/add/observable/of'; +import 'rxjs/add/operator/do'; +import 'rxjs/add/operator/share'; +import { CacheService } from '../shared/cache.service'; +@Injectable() +export class ProjectService { + + constructor(private http: Http, public _cache: CacheService) {} + + projectInfo: ProjectInfo; + + getProjectInfo (id: string):any { + console.info("getProjectInfo in service"); + + let url = OpenaireProperties. getSearchAPIURLLast() + 'projects/'+id+"?format=json"; + let key = url; + if (this._cache.has(key)) { + return Observable.of(this._cache.get(key)) + .map(res => this.parseProjectInfo(res)); + } + return this.http.get(url) + .map(res => res.json()) + .map(res => res['result']['metadata']['oaf:entity']['oaf:project']) + .map(res => [res, + res['fundingtree'], + res['rels']['rel']]) + .do(res => { + this._cache.set(key, res); + }) + .map(res => this.parseProjectInfo(res)); + + } + + /* + get project strtDate and endDate + */ + getProjectDates (id: string):any { + + let url = OpenaireProperties. getSearchAPIURLLast()+'projects/'+id+"?format=json"; + let key = url+'_projectDates'; + if (this._cache.has(key)) { + return Observable.of(this._cache.get(key)) + .map(res => [res, + res['fundingtree'], + res['rels']['rel']]) + .map(res => this.parseProjectDates(id,res)) + } + return this.http.get(url) + .map(res => res.json()) + .map(res => res['result']['metadata']['oaf:entity']['oaf:project']) + .do(res => { + this._cache.set(key, res); + }) + .map(res => [res, + res['fundingtree'], + res['rels']['rel']]) + .map(res => this.parseProjectDates(id,res)) + + } + + getHTMLInfo(id: string): any { + console.info("getHTMLInfo in service"); + + let url = OpenaireProperties. getSearchAPIURLLast() + 'projects/'+id+"?format=json"; + let key = url; + if (this._cache.has(key)) { + return Observable.of(this._cache.get(key)) + .map(res => this.parseHTMLInfo(res)); + } + return this.http.get(url) + .map(res => res.json()) + .map(res => res['result']['metadata']['oaf:entity']['oaf:project']) + .do(res => { + this._cache.set(key, res); + }) + .map(res => this.parseHTMLInfo(res)); + } + + private handleError (error: Response) { + // 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'); + } + + parseHTMLInfo (data: any):any { + let htmlInfo: {"title": string, "acronym": string, "callIdentifier": string}; + + if(data != null) { + htmlInfo = {"title": data.title, "acronym": data.acronym, "callIdentifier": data.callidentifier}; + } + console.info(htmlInfo); + return htmlInfo; + } + + parseProjectInfo (data: any):any { + this.projectInfo = new ProjectInfo(); + + if(data[0] != null) { + this.projectInfo.acronym = data[0].acronym; + this.projectInfo.title = data[0].title; + this.projectInfo.callIdentifier = data[0].callidentifier; + this.projectInfo.contractNum = data[0].code; + this.projectInfo.startDate = data[0].startdate; + this.projectInfo.endDate = data[0].enddate; + this.projectInfo.openAccessMandate = data[0].oamandatepublications; + this.projectInfo.specialClause39 = data[0].ecsc39; + } + if(data[1] != null) { + if(data[1]['funder'] != null) { + this.projectInfo.funder = data[1]['funder'].shortname; + } + + let funding; + this.projectInfo.funding = ""; + + if(data[1]['funding_level_2'] != null) { + funding = data[1]['funding_level_2'].id; + } else if(data[1]['funding_level_1'] != null) { + funding = data[1]['funding_level_1'].id; + } else if(data[1]['funding_level_0'] != null) { + funding = data[1]['funding_level_0'].id; + } + + if(funding != undefined) { + funding = funding.split("::"); + for(let i=1; i(); + + let name = ""; + let url = ""; + + if(!Array.isArray(data[2])) { + if(data[2].hasOwnProperty("legalshortname")) { + name = data[2].legalshortname; + } else if(data[2].hasOwnProperty("legalname")) { + name = data[2].legalname; + } + + if(data[2].hasOwnProperty("to") && name != "") { + url = OpenaireProperties.getsearchLinkToOrganization()+data[2]['to'].content; + } + if(name != "") { + this.projectInfo.organizations.set(name, url); + } + } else { + for(let i=0; i console.log(res['meta'])).map(res => [res['meta'].total, RefineResultsUtils.parse(res['refineResults'],fields, entityName)]).do(res => console.log(res)); + } + return this.http.get(link) + .map(res => res.json()) + .do(res => { + this._cache.set(key, res); + }) + .map(res => [res['meta'].total, RefineResultsUtils.parse(res['refineResults'],fields, entityName)]); + + } + getRefineFieldResultsByFieldName(fieldName:string, entityName:string):any{ + let link = OpenaireProperties.getSearchAPIURLForEntity(entityName)+"?fields="+fieldName + "&format=json"; + return this.getField(link,fieldName) + + } + + getField (link:string,fieldName:string):any{ + let url = link+"&refine=true&page=1&size=0"; + let key = url; + if (this._cache.has(key)) { + return Observable.of(this._cache.get(key)).map(res => this.parse(res,fieldName)); + } + return this.http.get(url) + .map(res => res.json()) + .map(res => res['refineResults']) + .do(res => { + this._cache.set(key, res); + }) + .map(res => this.parse(res,fieldName)); + + } + parse(data: any,fieldName:string):any { + var values:AutoCompleteValue[] = []; + if(data){ + let field = data[fieldName]; + for(let i=0; i new Blob([res['_body']], { type: 'text/csv' })); + } + getCSVResponse(url: string){ + var headers = new Headers(); + headers.append('responseType', 'arraybuffer'); + return this.http.get(url) + .map(res => res['_body']); + } + downloadHTMLFile(url: string, info: string){ + var headers = new Headers(); + headers.append('responseType', 'arraybuffer'); + return this.http.get(url) + .map(res => this.addInfo(res, info)) + .map(res => new Blob([res['_body']], { type: 'text/html' })) + .do(res => console.log(res)) + } + + addInfo(res:any, info:string) { + /* + var para = res.document.createElement("P"); // Create a

element + var t = res.document.createTextNode("This is a paragraph"); // Create a text node + para.appendChild(t); // Append the text to

+ res.document.body.appendChild(para); + */ + res['_body'] = info+res['_body']; + return res; + } + + private handleError (error: Response) { + // 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'); + } + + +} diff --git a/workingUIKIT/src/app/services/reportsService.module.ts b/workingUIKIT/src/app/services/reportsService.module.ts new file mode 100644 index 00000000..0d637dad --- /dev/null +++ b/workingUIKIT/src/app/services/reportsService.module.ts @@ -0,0 +1,20 @@ +import { NgModule} from '@angular/core'; +import { CommonModule } from '@angular/common'; +import { FormsModule } from '@angular/forms'; + +import {ReportsService} from './reports.service'; + + +@NgModule({ + imports: [ + CommonModule, FormsModule + ], + declarations: [ + ], + providers:[ + ReportsService +], + exports: [ + ] +}) +export class ReportsServiceModule { } diff --git a/workingUIKIT/src/app/services/searchDataproviders.service.ts b/workingUIKIT/src/app/services/searchDataproviders.service.ts new file mode 100644 index 00000000..024fc470 --- /dev/null +++ b/workingUIKIT/src/app/services/searchDataproviders.service.ts @@ -0,0 +1,381 @@ +import {Injectable} from '@angular/core'; +import {Http, Response} from '@angular/http'; +import {Observable} from 'rxjs/Observable'; +import {OpenaireProperties} from '../utils/properties/openaireProperties'; +import {SearchResult} from '../utils/entities/searchResult'; +import {RefineResultsUtils} from './servicesUtils/refineResults.class'; +import 'rxjs/add/observable/of'; +import 'rxjs/add/operator/do'; +import 'rxjs/add/operator/share'; +import { CacheService } from '../shared/cache.service'; +@Injectable() +export class SearchDataprovidersService { + constructor(private http: Http, public _cache: CacheService) {} + + searchDataproviders (params: string, refineParams:string, page: number, size: number, refineFields:string[] ):any { + + let link = OpenaireProperties. getSearchAPIURLLast()+"datasources"; + + let url = link+"?"; + if(params!= null && params != '' ) { + url += params; + } + if(refineParams!= null && refineParams != '' ) { + url += refineParams; + } + url += "&page="+(page-1)+"&size="+size+"&format=json"; + + let key = url; + if (this._cache.has(key)) { + return Observable.of(this._cache.get(key)).map(res => [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields, "datasource")]); + } + return this.http.get(url) + .map(res => res.json()) + //.do(res => console.info(res)) + .do(res => { + this._cache.set(key, res); + }) + .map(res => [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields, "datasource")]); + } + //((oaftype exact datasource) and(collectedfromdatasourceid exact "openaire____::47ce9e9f4fad46e732cff06419ecaabb")) + advancedSearchDataproviders (params: string, page: number, size: number ):any { + let url = OpenaireProperties.getSearchResourcesAPIURL(); + var basicQuery = "(oaftype exact datasource) " + url += "?query="; + if(params!= null && params != '' ) { + url +=" ( "+basicQuery+ " ) " +" and (" + params + ")"; + }else{ + url +=" ( "+basicQuery+ " ) "; + } + + url += "&page="+(page-1)+"&size="+size+"&format=json"; + let key = url; + if (this._cache.has(key)) { + return Observable.of(this._cache.get(key)).map(res => [res['meta'].total, this.parseResults(res['results'])]) + } + return this.http.get(url) + .map(res => res.json()) + //.do(res => console.info(res)) + .do(res => { + this._cache.set(key, res); + }) + .map(res => [res['meta'].total, this.parseResults(res['results'])]) + } + searchCompatibleDataproviders (params: string,refineParams:string, page: number, size: number, refineFields:string[] ):any { + let url = OpenaireProperties.getSearchResourcesAPIURL(); + url += "?query=((oaftype exact datasource) not(datasourcecompatibilityid = UNKNOWN) not(datasourcecompatibilityid = hostedBy) not(datasourcecompatibilityid = notCompatible) not(datasourcetypeuiid = other))" + if(params!= null && params != '' ) { + url += params; + } + if(refineParams!= null && refineParams != '' ) { + url += refineParams; + } + url += "&page="+(page-1)+"&size="+size+"&format=json"; + let key = url; + if (this._cache.has(key)) { + return Observable.of(this._cache.get(key)).map(res => [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields, "datasource")]); + } + return this.http.get(url) + .map(res => res.json()) + //.do(res => console.info(res)) + .do(res => { + this._cache.set(key, res); + }) + .map(res => [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields, "datasource")]); + } + searchEntityRegistries (params: string,refineParams:string, page: number, size: number, refineFields:string[] ):any { + let url = OpenaireProperties.getSearchResourcesAPIURL(); + url += "?query=((oaftype exact datasource) and(datasourcetypeuiid = other))" + if(params!= null && params != '' ) { + url += params; + } + if(refineParams!= null && refineParams != '' ) { + url += refineParams; + } + url += "&page="+(page-1)+"&size="+size+"&format=json"; + let key = url; + if (this._cache.has(key)) { + return Observable.of(this._cache.get(key)).map(res => [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields, "datasource")]); + } + return this.http.get(url) + .map(res => res.json()) + //.do(res => console.info(res)) + .do(res => { + this._cache.set(key, res); + }) + .map(res => [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields, "datasource")]); + } + + searchDataprovidersForDeposit (id: string,type:string, page: number, size: number):any { + let link = OpenaireProperties.getSearchResourcesAPIURL(); + var compatibilities = ""; + if(type == "Datasets"){ + compatibilities = " and (datasourcecompatibilityid = openaire2.0_data)" + }else if(type == "Publications"){ + compatibilities = " and (datasourcecompatibilityid <> UNKNOWN) and (datasourcecompatibilityid <> openaire2.0_data)" + } + let url = link+"?query=(((deletedbyinference = false) AND (oaftype exact datasource)) "+((compatibilities && compatibilities.length > 0)?" "+compatibilities+" ":"")+") and (relorganizationid exact "+id+")"; + url += "&page="+(page-1)+"&size="+size+"&format=json"; + + let key = url; + if (this._cache.has(key)) { + return Observable.of(this._cache.get(key)).map(res => [res['meta'].total, this.parseResults(res['results'])]); + } + return this.http.get(url) + .map(res => res.json()) + .do(res => { + this._cache.set(key, res); + }) + .map(res => [res['meta'].total, this.parseResults(res['results'])]); + } + getDataProvidersforEntityRegistry(datasourceId: string, page: number, size: number ):any { + let url = OpenaireProperties.getSearchResourcesAPIURL(); + var basicQuery = "(oaftype exact datasource) " + url += "?query="; + if(datasourceId!= null && datasourceId != '' ) { + url +=" ( "+basicQuery+ " ) " +" and (collectedfromdatasourceid exact \"" + datasourceId + "\")"; + }else{ + url +=" ( "+basicQuery+ " ) "; + } + + url += "&page="+(page-1)+"&size="+size+"&format=json"; + let key = url; + if (this._cache.has(key)) { + return Observable.of(this._cache.get(key)).map(res => [res['meta'].total, this.parseResults(res['results'])]); + } + return this.http.get(url) + .map(res => res.json()) + .do(res => { + this._cache.set(key, res); + }) + .map(res => [res['meta'].total, this.parseResults(res['results'])]); + } + searchDataprovidersForEntity (params: string, page: number, size: number):any { + let link = OpenaireProperties. getSearchAPIURLLast(); + let url = link+params+"/datasources?format=json"; + let key = url; + if (this._cache.has(key)) { + return Observable.of(this._cache.get(key)).map(res => [res['meta'].total, this.parseResults(res['results'])]); + } + return this.http.get(url) + .map(res => res.json()) + .do(res => { + this._cache.set(key, res); + }) + .map(res => [res['meta'].total, this.parseResults(res['results'])]); + } + + searchDataprovidersCSV (params: string, refineParams:string, page: number, size: number):any { + + let link = OpenaireProperties. getSearchAPIURLLast()+"datasources"; + + let url = link+"?"; + if(params!= null && params != '' ) { + url += params; + } + if(refineParams!= null && refineParams != '' ) { + url += refineParams; + } + url += "&page="+(page-1)+"&size="+size+"&format=json"; + + let key = url; + if (this._cache.has(key)) { + return Observable.of(this._cache.get(key)).map(res => this.parseResultsCSV(res['results'])); + } + return this.http.get(url) + .map(res => res.json()) + //.do(res => console.info(res)) + .do(res => { + this._cache.set(key, res); + }) + .map(res => this.parseResultsCSV(res['results'])); + } + + searchEntityRegistriesCSV (params: string,refineParams:string, page: number, size: number):any { + let url = OpenaireProperties.getSearchResourcesAPIURL(); + url += "?query=((oaftype exact datasource) and(datasourcetypeuiid = other))" + if(params!= null && params != '' ) { + url += params; + } + if(refineParams!= null && refineParams != '' ) { + url += refineParams; + } + url += "&page="+(page - 1)+"&size="+size+"&format=json"; + let key = url; + if (this._cache.has(key)) { + return Observable.of(this._cache.get(key)).map(res => this.parseResultsCSV(res['results'])); + } + return this.http.get(url) + .map(res => res.json()) + //.do(res => console.info(res)) + .do(res => { + this._cache.set(key, res) + }) + .map(res => this.parseResultsCSV(res['results'])); + } + + searchCompatibleDataprovidersCSV (params: string,refineParams:string, page: number, size: number):any { + let url = OpenaireProperties.getSearchResourcesAPIURL(); + url += "?query=((oaftype exact datasource) not(datasourcecompatibilityid = UNKNOWN) not(datasourcecompatibilityid = hostedBy) not(datasourcecompatibilityid = notCompatible) not(datasourcetypeuiid = other))" + if(params!= null && params != '' ) { + url += params; + } + if(refineParams!= null && refineParams != '' ) { + url += refineParams; + } + url += "&page="+(page - 1)+"&size="+size+"&format=json"; + let key = url; + if (this._cache.has(key)) { + return Observable.of(this._cache.get(key)).map(res => this.parseResultsCSV(res['results'])); + } + return this.http.get(url) + .map(res => res.json()) + //.do(res => console.info(res)) + .do(res => { + this._cache.set(key, res); + }) + .map(res => this.parseResultsCSV(res['results'])); + } + + parseResults(data: any): SearchResult[] { + let results: SearchResult[] = []; + + let length = Array.isArray(data) ? data.length : 1; + + for(let i=0; i = new Set(); + + let relLength = Array.isArray(resData['rels']['rel']) ? resData['rels']['rel'].length : 1; + + for(let i=0; i res.json()) + .map(res => res.total) + .do(res => { + this._cache.set(key, res); + }); + } + + private quote(word: any): string { + return '"'+word+'"'; + } +} diff --git a/workingUIKIT/src/app/services/searchDatasets.service.ts b/workingUIKIT/src/app/services/searchDatasets.service.ts new file mode 100644 index 00000000..f83ee433 --- /dev/null +++ b/workingUIKIT/src/app/services/searchDatasets.service.ts @@ -0,0 +1,339 @@ +import {Injectable} from '@angular/core'; +import {Http, Response} from '@angular/http'; +import {Observable} from 'rxjs/Observable'; +import {OpenaireProperties} from '../utils/properties/openaireProperties'; +import {SearchResult} from '../utils/entities/searchResult'; +import {RefineResultsUtils} from './servicesUtils/refineResults.class'; +import 'rxjs/add/observable/of'; +import 'rxjs/add/operator/do'; +import 'rxjs/add/operator/share'; +import { CacheService } from '../shared/cache.service'; +@Injectable() +export class SearchDatasetsService { + private sizeOfDescription: number = 497; + + constructor(private http: Http, public _cache: CacheService) {} + + searchDatasets (params: string, refineParams:string, page: number, size: number, refineFields:string[] ):any { + + let link = OpenaireProperties.getSearchAPIURLLast()+"datasets"; + + let url = link+"?"; + if(params!= null && params != '' ) { + url += params; + } + if(refineParams!= null && refineParams != '' ) { + url += refineParams; + } + url += "&page="+ (page-1) +"&size="+size+"&format=json"; + + let key = url; + if (this._cache.has(key)) { + return Observable.of(this._cache.get(key)).map(res => [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields, "dataset")]); + } + return this.http.get(url) + .map(res => res.json()) + //.do(res => console.info(res)) + .do(res => { + this._cache.set(key, res); + }) + .map(res => [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields, "dataset")]); + } + searchDatasetById (id: string ):any { + + let url = OpenaireProperties.getSearchAPIURLLast()+"datasets/"+id+"?format=json"; + let key = url+"-searchById"; + if (this._cache.has(key)) { + return Observable.of(this._cache.get(key)).map(res => this.parseResults(res)); + } + + return this.http.get(url) + .map(res => res.json()) + .do(res => { + this._cache.set(key, res); + }) + .map(res => this.parseResults(res)); + } + + searchAggregators (id: string, params: string, refineParams:string, page: number, size: number ):any { + + let link = OpenaireProperties.getSearchAPIURLLast()+"datasets"; + + let url = link+"?"+"&format=json"; + if(params!= null && params != '' ) { + url += params; + } + if(refineParams!= null && refineParams != '' ) { + url += refineParams; + } + url += "&page="+(page-1)+"&size="+size; + + let key = url; + if (this._cache.has(key)) { + return Observable.of(this._cache.get(key)).map(res => this.parseRefineResults(id, res['refineResults'])); + } + + return this.http.get(url) + .map(res => res.json()) + .do(res => { + this._cache.set(key, res); + }) + .map(res => this.parseRefineResults(id, res['refineResults'])); + } + + searchDatasetsByDois (DOIs: string[], refineParams:string, page: number, size: number, refineFields:string[] ):any { + let link = OpenaireProperties.getSearchAPIURLLast()+"datasets"; + let url = link+"?"; + var doisParams = ""; + + for(var i =0 ;i < DOIs.length; i++){ + doisParams+=(doisParams.length > 0?"&":"")+'doi="'+ DOIs[i]+'"'; + } + if(doisParams.length > 0){ + url += "&"+doisParams; + + } + if(refineParams!= null && refineParams != '' ) { + url += refineParams; + } + url += "&page="+ (page-1) +"&size="+size+"&format=json"; + + let key = url; + if (this._cache.has(key)) { + return Observable.of(this._cache.get(key)).map(res => [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields, "dataset")]); + } + return this.http.get(url) + .map(res => res.json()) + //.do(res => console.info(res)) + .do(res => { + this._cache.set(key, res); + }) + .map(res => [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields, "dataset")]); + } + advancedSearchDatasets (params: string, page: number, size: number ):any { + let url = OpenaireProperties.getSearchResourcesAPIURL(); + var basicQuery = "(oaftype exact result) and (resulttypeid exact dataset) " + url += "?query="; + if(params!= null && params != '' ) { + url +=" ( "+basicQuery+ " ) " +" and (" + params + ")"; + }else{ + url +=" ( "+basicQuery+ " ) "; + } + + url += "&page="+(page-1)+"&size="+size; + url += "&format=json"; + let key = url; + if (this._cache.has(key)) { + return Observable.of(this._cache.get(key)); + } + return this.http.get(url) + .map(res => res.json()) + //.do(res => console.info(res)) + .map(res => [res['meta'].total, this.parseResults(res['results'])]) + .do(res => { + this._cache.set(key, res); + }); + } + searchDatasetsForEntity (params: string, page: number, size: number):any { + let link = OpenaireProperties.getSearchAPIURLLast(); + let url = link+params+"/datasets"+"?format=json"; + let key = url; + if (this._cache.has(key)) { + return Observable.of(this._cache.get(key)).map(res => [res['meta'].total, this.parseResults(res['results'])]); + } + return this.http.get(url) + .map(res => res.json()) + .do(res => { + this._cache.set(key, res); + }) + .map(res => [res['meta'].total, this.parseResults(res['results'])]); + } + + searchDatasetsForDataproviders(params: string, page: number, size: number):any { + let link = OpenaireProperties.getSearchAPIURLLast(); + let url = link+params+"&format=json"; + let key = url; + if (this._cache.has(key)) { + return Observable.of(this._cache.get(key)).map(res => [res['meta'].total, this.parseResults(res['results'])]); + } + return this.http.get(url) + .map(res => res.json()) + .do(res => { + this._cache.set(key, res); + }) + .map(res => [res['meta'].total, this.parseResults(res['results'])]); + } + + parseResults(data: any): SearchResult[] { + let results: SearchResult[] = []; + + let length = Array.isArray(data) ? data.length : 1; + + for(let i=0; i(); + } + + result['authors'].push({"name": relation.fullname, "id": /*OpenaireProperties.getsearchLinkToPerson()+*/relation['to'].content}); + } else if(relation['to'].class == "isProducedBy") { + if(result['projects'] == undefined) { + result['projects'] = new Array< + { "id": string, "acronym": string, "title": string, + "funderShortname": string, "funderName": string, + "code": string + }>(); + } + + let countProjects = result['projects'].length; + + result['projects'][countProjects] = { + "id": "", "acronym": "", "title": "", + "funderShortname": "", "funderName": "", + "code": "" + } + + if(relation.title != 'unidentified') { + result['projects'][countProjects]['id'] = + /*OpenaireProperties.getsearchLinkToProject() + */relation['to'].content; + result['projects'][countProjects]['acronym'] = relation.acronym; + result['projects'][countProjects]['title'] = relation.title; + result['projects'][countProjects]['code'] = relation.code; + } else { + result['projects'][countProjects]['id'] = ""; + result['projects'][countProjects]['acronym'] = ""; + result['projects'][countProjects]['title'] = ""; + result['projects'][countProjects]['code'] = ""; + } + + if(relation.hasOwnProperty("funding")) { + let fundingLength = Array.isArray(relation['funding']) ? relation['funding'].length : 1; + + for(let z=0; z this.sizeOfDescription) { + result.description = result.description.substring(0, this.sizeOfDescription)+"..."; + } + + result.embargoEndDate = resData.embargoenddate; + + if(!Array.isArray(resData.publisher)) { + result.publisher = resData.publisher; + } else { + for(let i=0; i res.json()) + .map(res => res.total) + .do(res => { + this._cache.set(key, res); + }); + } + + numOfSearchDatasets(params: string):any { + + //OpenaireProperties.getSearchAPIURLLast() + //"http://rudie.di.uoa.gr:8080/dnet-functionality-services-2.0.0-SNAPSHOT/rest/v2/api/" + let url = OpenaireProperties.getSearchAPIURLLast()+"datasets/count?q=" + params + "&format=json"; + let key = url; + if (this._cache.has(key)) { + return Observable.of(this._cache.get(key)); + } + return this.http.get(url) + .map(res => res.json()) + .map(res => res.total) + .do(res => { + this._cache.set(key, res); + }); + } +} diff --git a/workingUIKIT/src/app/services/searchOrganizations.service.ts b/workingUIKIT/src/app/services/searchOrganizations.service.ts new file mode 100644 index 00000000..a5007d77 --- /dev/null +++ b/workingUIKIT/src/app/services/searchOrganizations.service.ts @@ -0,0 +1,210 @@ +import {Injectable} from '@angular/core'; +import {Http, Response} from '@angular/http'; +import {Observable} from 'rxjs/Observable'; +import 'rxjs/add/observable/of'; +import 'rxjs/add/operator/do'; +import 'rxjs/add/operator/share'; +import { CacheService } from '../shared/cache.service'; +import {OpenaireProperties} from '../utils/properties/openaireProperties'; +import {SearchResult} from '../utils/entities/searchResult'; +import {RefineResultsUtils} from './servicesUtils/refineResults.class'; + +@Injectable() +export class SearchOrganizationsService { + + constructor(private http: Http, public _cache: CacheService) {} + + parseResultsForDeposit(data: any): {"name": string, "id": string}[] { + let results: {"name": string, "id": string}[] = []; + + let length = Array.isArray(data) ? data.length : 1; + + for(let i=0; i [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields, "organization")]); + } + return this.http.get(url) + .map(res => res.json()) + //.do(res => console.info(res)) + .do(res => { + this._cache.set(key, res); + }) + .map(res => [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields, "organization")]); + } + advancedSearchOrganizations (params: string, page: number, size: number ):any { + let url = OpenaireProperties.getSearchResourcesAPIURL(); + var basicQuery = "(oaftype exact organization) " + url += "?query="; + if(params!= null && params != '' ) { + url +=" ( "+basicQuery+ " ) " +" and (" + params + ")"; + }else{ + url +=" ( "+basicQuery+ " ) "; + } + + url += "&page="+(page-1)+"&size="+size; + url += "&format=json"; + let key = url; + if (this._cache.has(key)) { + return Observable.of(this._cache.get(key)).map(res => [res['meta'].total, this.parseResults(res['results'])]); + } + return this.http.get(url) + .map(res => res.json()) + //.do(res => console.info(res)) + .do(res => { + this._cache.set(key, res); + }) + .map(res => [res['meta'].total, this.parseResults(res['results'])]); + } + parseResults(data: any): SearchResult[] { + let results: SearchResult[] = []; + + let length = Array.isArray(data) ? data.length : 1; + + for(let i=0; i(); + } + + let countProjects = result['projects'].length; + + result['projects'][countProjects] = { + "id": "", "acronym": "", "title": "", + "funderShortname": "", "funderName": "", + "code": "" + } + + if(relation.title != 'unidentified') { + result['projects'][countProjects]['id'] = + /*OpenaireProperties.getsearchLinkToProject() + */relation['to'].content; + result['projects'][countProjects]['acronym'] = relation.acronym; + result['projects'][countProjects]['title'] = relation.title; + result['projects'][countProjects]['code'] = relation.code; + } else { + result['projects'][countProjects]['id'] = ""; + result['projects'][countProjects]['acronym'] = ""; + result['projects'][countProjects]['title'] = ""; + result['projects'][countProjects]['code'] = ""; + } + + if(relation.hasOwnProperty("funding")) { + let fundingLength = Array.isArray(relation['funding']) ? relation['funding'].length : 1; + + for(let z=0; z res.json()) + .map(res => res.total) + .do(res => { + this._cache.set(key, res); + }); + } + + numOfSearchOrganizations(params: string):any { + + //OpenaireProperties.getSearchAPIURLLast() + //"http://rudie.di.uoa.gr:8080/dnet-functionality-services-2.0.0-SNAPSHOT/rest/v2/api/" + let url = OpenaireProperties.getSearchAPIURLLast()+"organizations/count?q=" + params + "&format=json"; + + let key = url; + if (this._cache.has(key)) { + return Observable.of(this._cache.get(key)); + } + return this.http.get(url) + .map(res => res.json()) + .map(res => res.total) + .do(res => { + this._cache.set(key, res); + }); + } +} diff --git a/workingUIKIT/src/app/services/searchPeople.service.ts b/workingUIKIT/src/app/services/searchPeople.service.ts new file mode 100644 index 00000000..9d2aeac0 --- /dev/null +++ b/workingUIKIT/src/app/services/searchPeople.service.ts @@ -0,0 +1,125 @@ +import {Injectable} from '@angular/core'; +import {Http, Response} from '@angular/http'; +import {Observable} from 'rxjs/Observable'; +import 'rxjs/add/observable/of'; +import 'rxjs/add/operator/do'; +import 'rxjs/add/operator/share'; +import { CacheService } from '../shared/cache.service'; +import {OpenaireProperties} from '../utils/properties/openaireProperties'; +import {SearchResult} from '../utils/entities/searchResult'; +import {RefineResultsUtils} from './servicesUtils/refineResults.class'; + +@Injectable() +export class SearchPeopleService { + + constructor(private http: Http, public _cache: CacheService) {} + + searchPeople (params: string, refineParams:string, page: number, size: number, refineFields:string[] ):any { + + console.info("In searchProjects"); + + let link = OpenaireProperties.getSearchAPIURLLast()+"people"; + + let url = link+"?"; + if(params!= null && params != '' ) { + url += params; + } + if(refineParams!= null && params != '' ) { + url += refineParams; + } + url += "&page="+(page-1)+"&size="+size + "&format=json"; + let key = url; + if (this._cache.has(key)) { + return Observable.of(this._cache.get(key)).map(res => [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields, "person")]); + } + + return this.http.get(url) + .map(res => res.json()) + //.do(res => console.info(res)) + .do(res => { + this._cache.set(key, res); + }) + .map(res => [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields, "person")]); + } + advancedSearchPeople (params: string, page: number, size: number ):any { + let url = OpenaireProperties.getSearchResourcesAPIURL(); + var basicQuery = "(oaftype exact person) " + url += "?query="; + if(params!= null && params != '' ) { + url +=" ( "+basicQuery+ " ) " +" and (" + params + ")"; + }else{ + url +=" ( "+basicQuery+ " ) "; + } + + url += "&page="+(page-1)+"&size="+size; + url += "&format=json"; + let key = url; + if (this._cache.has(key)) { + return Observable.of(this._cache.get(key)).map(res => [res['meta'].total, this.parseResults(res['results'])]); + } + return this.http.get(url) + .map(res => res.json()) + //.do(res => console.info(res)) + .do(res => { + this._cache.set(key, res); + }) + .map(res => [res['meta'].total, this.parseResults(res['results'])]); + } + parseResults(data: any): SearchResult[] { + let results: SearchResult[] = []; + + let length = Array.isArray(data) ? data.length : 1; + + for(let i=0; i res.json()) + .map(res => res.total) + .do(res => { + this._cache.set(key, res); + }); + } + + numOfSearchPeople(params: string):any { + + //OpenaireProperties.getSearchAPIURLLast() + //"http://rudie.di.uoa.gr:8080/dnet-functionality-services-2.0.0-SNAPSHOT/rest/v2/api/" + let url = OpenaireProperties.getSearchAPIURLLast()+"people/count?q=" + params + "&format=json"; + let key = url; + if (this._cache.has(key)) { + return Observable.of(this._cache.get(key)); + } + return this.http.get(url) + .map(res => res.json()) + .map(res => res.total) + .do(res => { + this._cache.set(key, res); + }); + } +} diff --git a/workingUIKIT/src/app/services/searchProjects.service.ts b/workingUIKIT/src/app/services/searchProjects.service.ts new file mode 100644 index 00000000..99a7230b --- /dev/null +++ b/workingUIKIT/src/app/services/searchProjects.service.ts @@ -0,0 +1,279 @@ +import {Injectable} from '@angular/core'; +import {Http, Response} from '@angular/http'; +import {Observable} from 'rxjs/Observable'; +import 'rxjs/add/observable/of'; +import 'rxjs/add/operator/do'; +import 'rxjs/add/operator/share'; +import { CacheService } from '../shared/cache.service'; +import {OpenaireProperties} from '../utils/properties/openaireProperties'; +import {SearchResult} from '../utils/entities/searchResult'; +import {RefineResultsUtils} from './servicesUtils/refineResults.class'; + +@Injectable() +export class SearchProjectsService { + private sizeOfDescription: number = 497; + + constructor(private http: Http, public _cache: CacheService) {} + + searchProjects (params: string, refineParams:string, page: number, size: number, refineFields:string[] ):any { + + console.info("In searchProjects"); + + let link = OpenaireProperties.getSearchAPIURLLast()+"projects"; + + let url = link+"?"; + if(params!= null && params != '' ) { + url += params; + } + if(refineParams!= null && refineParams != '' ) { + url += refineParams; + } + url += "&page="+(page-1)+"&size="+size + "&format=json"; + let key = url; + if (this._cache.has(key)) { + return Observable.of(this._cache.get(key)).map(res => [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields, "project")]); + } + + return this.http.get(url) + .map(res => res.json()) + //.do(res => console.info(res)) + .do(res => { + this._cache.set(key, res); + }) + .map(res => [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields, "project")]); + } + getProjectsforDataProvider (datasourceId: string, page: number, size: number ):any { + let url = OpenaireProperties.getSearchResourcesAPIURL(); + var basicQuery = "(oaftype exact project) " + url += "?query="; + if(datasourceId!= null && datasourceId != '' ) { + url +=" ( "+basicQuery+ " ) " +" and (collectedfromdatasourceid exact \"" + datasourceId + "\")"; + }else{ + url +=" ( "+basicQuery+ " ) "; + } + + url += "&page="+(page-1)+"&size="+size; + url += "&format=json"; + let key = url; + if (this._cache.has(key)) { + return Observable.of(this._cache.get(key)).map(res => [res['meta'].total, this.parseResults(res['results'])]); + } + return this.http.get(url) + .map(res => res.json()) + .do(res => { + this._cache.set(key, res); + }) + .map(res => [res['meta'].total, this.parseResults(res['results'])]); + } + advancedSearchProjects (params: string, page: number, size: number ):any { + let url = OpenaireProperties.getSearchResourcesAPIURL(); + var basicQuery = "(oaftype exact project) " + url += "?query="; + if(params!= null && params != '' ) { + url +=" ( "+basicQuery+ " ) " +" and (" + params + ")"; + }else{ + url +=" ( "+basicQuery+ " ) "; + } + + url += "&page="+(page-1)+"&size="+size; + url += "&format=json"; + let key = url; + if (this._cache.has(key)) { + return Observable.of(this._cache.get(key)).map(res => [res['meta'].total, this.parseResults(res['results'])]); + } + return this.http.get(url) + .map(res => res.json()) + //.do(res => console.info(res)) + .do(res => { + this._cache.set(key, res); + }) + .map(res => [res['meta'].total, this.parseResults(res['results'])]); + } + getProjectsForOrganizations (organizationId: string, filterquery: string, page: number, size: number, refineFields:string[] ):any { + let url = OpenaireProperties.getSearchResourcesAPIURL(); + var basicQuery = "(oaftype exact project) " + url += "?query="; + if(filterquery!= null && filterquery != '' ) { + url +="( ( "+basicQuery+ " ) and (relorganizationid exact \"" + organizationId + "\")"+" " + filterquery + ")"; + }else{ + url +=" (( "+basicQuery+ " ) " +" and (relorganizationid exact \"" + organizationId + "\"))"; + } + if(refineFields!= null && refineFields.length > 0 ) { + url +="&refine=true"; + for(let i=0; i< refineFields.length ; i++ ){ + url +="&fields="+refineFields[i]; + } + } + url += "&page="+(page-1)+"&size="+size; + url += "&format=json"; + let key = url; + if (this._cache.has(key)) { + return Observable.of(this._cache.get(key)).map(res => [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields, "project")]); + } + return this.http.get(url) + .map(res => res.json()) + //.do(res => console.info(res)) + .do(res => { + this._cache.set(key, res); + }) + .map(res => [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields, "project")]); + } + getFunders():any { + let url = OpenaireProperties.getSearchAPIURLLast()+"projects?refine=true&fields=funderid&size=0"+ "&format=json";; + let key = url; + if (this._cache.has(key)) { + return Observable.of(this._cache.get(key)).map(res => [res['meta'].total, res['refineResults']['funderid']]); + } + return this.http.get(url) + .map(res => res.json()) + .do(res => { + this._cache.set(key, res); + }) + .map(res => [res['meta'].total, res['refineResults']['funderid']]); + + + } + + searchForProjectsObs(keyword:string, funderId:string):any { + let url = 'search?action=search&sTransformer=projects_openaire&query='+ + '%28oaftype+exact+project%29+and+%28%28projecttitle+%3D+%22'+keyword+'%22%29+or+%28projectacronym+%3D+%22'+keyword+'%22%29+or+%28projectcode+%3D+%22'+keyword+'%22%29%29+and+%28funderid+exact+'+funderId+'%29&size=10&locale=en_GB&format=json'; + let key = url; + if (this._cache.has(key)) { + return Observable.of(this._cache.get(key)); + } + return this.http.get(url).toPromise() + .then(request =>{ + return (request.json().response.results)?request.json().response.results.result:request.json().response.result; + + }) ; + } + parseResults(data: any): SearchResult[] { + let results: SearchResult[] = []; + + let length = Array.isArray(data) ? data.length : 1; + + for(let i=0; i(); + } + + let countOrganizations = result['organizations'].length; + + result['organizations'][countOrganizations] = { "name": "", "id": "" } + + result['organizations'][countOrganizations]['id'] = + /*OpenaireProperties.getsearchLinkToOrganization() + */relation['to'].content; + result['organizations'][countOrganizations]['name'] = relation.legalname; + } + } + } + } + if(resData.hasOwnProperty("fundingtree")) { + if(result['funders'] == undefined) { + result['funders'] = new Array< + {"funderShortname": string, "funderName": string}>(); + } + + let fundingLength = Array.isArray(resData['fundingtree']) ? resData['fundingtree'].length : 1; + + for(let z=0; z res.json()) + .map(res => res.total) + .do(res => { + this._cache.set(key, res); + }); + } + + numOfSearchProjects(params: string):any { + + //OpenaireProperties.getSearchAPIURLLast() + //"http://rudie.di.uoa.gr:8080/dnet-functionality-services-2.0.0-SNAPSHOT/rest/v2/api/" + let url = OpenaireProperties.getSearchAPIURLLast()+"projects/count?q=" + params + "&format=json"; + let key = url; + if (this._cache.has(key)) { + return Observable.of(this._cache.get(key)); + } + return this.http.get(url) + .map(res => res.json()) + .map(res => res.total) + .do(res => { + this._cache.set(key, res); + }); + } +} diff --git a/workingUIKIT/src/app/services/searchPublications.service.ts b/workingUIKIT/src/app/services/searchPublications.service.ts new file mode 100644 index 00000000..ac0a1c87 --- /dev/null +++ b/workingUIKIT/src/app/services/searchPublications.service.ts @@ -0,0 +1,461 @@ +import {Injectable} from '@angular/core'; +import {Http, Response} from '@angular/http'; +import {Observable} from 'rxjs/Observable'; +import 'rxjs/add/observable/of'; +import 'rxjs/add/operator/do'; +import 'rxjs/add/operator/share'; +import { CacheService } from '../shared/cache.service'; + +import {OpenaireProperties} from '../utils/properties/openaireProperties'; +import {SearchResult} from '../utils/entities/searchResult'; +import {RefineResultsUtils} from './servicesUtils/refineResults.class'; + +@Injectable() +export class SearchPublicationsService { + private sizeOfDescription: number = 497; + + constructor(private http: Http, public _cache: CacheService) {} + + searchPublications (params: string, refineParams:string, page: number, size: number, refineFields:string[] ):any { + + let link = OpenaireProperties.getSearchAPIURLLast()+"publications"; + + let url = link+"?"; + if(params!= null && params != '' ) { + url += params; + } + if(refineParams!= null && refineParams != '' ) { + url += refineParams; + } + url += "&page="+(page-1)+"&size="+size+"&format=json"; + + let key = url; + if (this._cache.has(key)) { + return Observable.of(this._cache.get(key)).map(res => [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields, "publication")]); + } + + return this.http.get(url) + .map(res => res.json()) + // .do(res => console.info(res)) + .do(res => { + this._cache.set(key, res); + }) + .map(res => [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields, "publication")]); + } + searchPublicationById (id: string ):any { + + let url = OpenaireProperties.getSearchAPIURLLast()+"publications/"+id+"?format=json"; + let key =url+"-searchById"; + if (this._cache.has(key)) { + return Observable.of(this._cache.get(key)).map(res => this.parseResults(res)); + } + return this.http.get(url) + .map(res => res.json()) + .do(res => { + this._cache.set(key, res); + }) + .map(res => this.parseResults(res)); + } + + searchAggregators (id: string, params: string, refineParams:string, page: number, size: number ):any { + + let link = OpenaireProperties.getSearchAPIURLLast()+"publications"; + + let url = link+"?"+"&format=json"; + if(params!= null && params != '' ) { + url += params; + } + if(refineParams!= null && refineParams != '' ) { + url += refineParams; + } + url += "&page="+(page-1)+"&size="+size; + + let key = url; + if (this._cache.has(key)) { + return Observable.of(this._cache.get(key)).map(res => this.parseRefineResults(id, res['refineResults'])); + } + + return this.http.get(url) + .map(res => res.json()) + .do(res => { + this._cache.set(key, res); + }) + .map(res => this.parseRefineResults(id, res['refineResults'])); + } + + searchPublicationsByDois (DOIs: string[], refineParams:string, page: number, size: number, refineFields:string[] ):any { + + let link = OpenaireProperties.getSearchAPIURLLast()+"publications"; + + let url = link+"?"+"&format=json&"; + var doisParams = ""; + + for(var i =0 ;i < DOIs.length; i++){ + doisParams+=(doisParams.length > 0?"&":"")+'doi="'+ DOIs[i]+'"'; + } + if(doisParams.length > 0){ + url +="&"+doisParams; + + } + if(refineParams!= null && refineParams != '' ) { + url += refineParams; + } + url += "&page="+(page-1)+"&size="+size; + + let key = url; + if (this._cache.has(key)) { + return Observable.of(this._cache.get(key)).map(res => [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields, "publication")]); + } + + return this.http.get(url) + .map(res => res.json()) + //.do(res => console.info(res)) + .do(res => { + this._cache.set(key, res); + }) + .map(res => [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields, "publication")]); + } + + advancedSearchPublications (params: string, page: number, size: number ):any { + let url = OpenaireProperties.getSearchResourcesAPIURL(); + var basicQuery = "(oaftype exact result) and (resulttypeid exact publication) "; + url += "?query="; + if(params!= null && params != '' ) { + url +=" ( "+basicQuery+ " ) " +" and (" + params + ")"; + }else{ + url +=" ( "+basicQuery+ " ) "; + } + + url += "&page="+(page-1)+"&size="+size; + url += "&format=json"; + let key = url; + if (this._cache.has(key)) { + return Observable.of(this._cache.get(key)).map(res => [res['meta'].total, this.parseResults(res['results'])]); + } + return this.http.get(url) + .map(res => res.json()) + //.do(res => console.info(res)) + .do(res => { + this._cache.set(key, res); + }) + .map(res => [res['meta'].total, this.parseResults(res['results'])]); + } + searchPublicationsForEntity (params: string, page: number, size: number):any { + let link = OpenaireProperties.getSearchAPIURLLast(); + let url = link+params+"/publications"+ "?format=json"; + + let key = url; + if (this._cache.has(key)) { + return Observable.of(this._cache.get(key)).map(res => [res['meta'].total, this.parseResults(res['results'])]); + } + + return this.http.get(url) + .map(res => res.json()) + .do(res => { + this._cache.set(key, res); + }) + .map(res => [res['meta'].total, this.parseResults(res['results'])]); + } + + searchPublicationsForDataproviders(params: string, page: number, size: number):any { + let link = OpenaireProperties.getSearchAPIURLLast(); + let url = link+params+ "&page="+(page-1)+"&size="+size + "&format=json"; + let key = url; + if (this._cache.has(key)) { + return Observable.of(this._cache.get(key)).map(res => [res['meta'].total, this.parseResults(res['results'])]); + } + return this.http.get(url) + .map(res => res.json()) + .do(res => { + this._cache.set(key, res); + }) + .map(res => [res['meta'].total, this.parseResults(res['results'])]); + } + + searchPublicationsCSV (params: string, refineParams:string, page: number, size: number):any { + + let link = OpenaireProperties.getSearchAPIURLLast()+"publications"; + + let url = link+"?"; + if(params!= null && params != '' ) { + url += params; + } + if(refineParams!= null && refineParams != '' ) { + url += refineParams; + } + url += "&page="+(page-1)+"&size="+size+ "&format=json"; + + let key = url; + if (this._cache.has(key)) { + return Observable.of(this._cache.get(key)).map(res => this.parseResultsCSV(res['results'])); + } + + return this.http.get(url) + .map(res => res.json()) + //.do(res => console.info(res)) + .do(res => { + this._cache.set(key, res); + }) + .map(res => this.parseResultsCSV(res['results'])); + } + + + parseResults(data: any): SearchResult[] { + let results: SearchResult[] = []; + + let length = Array.isArray(data) ? data.length : 1; + + for(let i=0; i(); + } + + result['authors'].push({"name": relation.fullname, "id": /*OpenaireProperties.getsearchLinkToPerson()+*/relation['to'].content}); + } else if(relation['to'].class == "isProducedBy") { + if(result['projects'] == undefined) { + result['projects'] = new Array< + { "id": string, "acronym": string, "title": string, + "funderShortname": string, "funderName": string, + "code": string + }>(); + } + + let countProjects = result['projects'].length; + + result['projects'][countProjects] = { + "id": "", "acronym": "", "title": "", + "funderShortname": "", "funderName": "", + "code": "" + } + + if(relation.title != 'unidentified') { + result['projects'][countProjects]['id'] = + /*OpenaireProperties.getsearchLinkToProject() + */relation['to'].content; + result['projects'][countProjects]['acronym'] = relation.acronym; + result['projects'][countProjects]['title'] = relation.title; + result['projects'][countProjects]['code'] = relation.code; + } else { + result['projects'][countProjects]['id'] = ""; + result['projects'][countProjects]['acronym'] = ""; + result['projects'][countProjects]['title'] = ""; + result['projects'][countProjects]['code'] = ""; + } + + if(relation.hasOwnProperty("funding")) { + let fundingLength = Array.isArray(relation['funding']) ? relation['funding'].length : 1; + + for(let z=0; z this.sizeOfDescription) { + result.description = result.description.substring(0, this.sizeOfDescription) + "..."; + } + + + result.embargoEndDate = resData.embargoenddate; + + results.push(result); + } + + return results; + } + + parseResultsCSV(data: any): any { + let results: any = []; + + + let length = Array.isArray(data) ? data.length : 1; + + for(let i=0; i res.json()) + .map(res => res.total) + .do(res => { + this._cache.set(key, res); + }); + } + + numOfSearchPublications(params: string):any { + + //OpenaireProperties.getSearchAPIURLLast() + //"http://rudie.di.uoa.gr:8080/dnet-functionality-services-2.0.0-SNAPSHOT/rest/v2/api/" + let url = OpenaireProperties.getSearchAPIURLLast()+"publications/count?q="+ params +"&format=json"; + let key = url; + if (this._cache.has(key)) { + return Observable.of(this._cache.get(key)); + } + return this.http.get(url) + .map(res => res.json()) + .map(res => res.total).do(res => { + this._cache.set(key, res); + }); + } + + private quote(word: any): string { + return '"'+word+'"'; + } +} diff --git a/workingUIKIT/src/app/services/servicesUtils/refineResults.class.ts b/workingUIKIT/src/app/services/servicesUtils/refineResults.class.ts new file mode 100644 index 00000000..ba4efc88 --- /dev/null +++ b/workingUIKIT/src/app/services/servicesUtils/refineResults.class.ts @@ -0,0 +1,38 @@ + +import { Filter, Value} from '../../searchPages/searchUtils/searchHelperClasses.class'; +import { SearchFields} from '../../utils/properties/searchFields'; + + +export class RefineResultsUtils { + + + public static parse (data, fields:string[], entityType:string):Filter[] { + // var data = this.json.refineReuslts; + + var searchFields:SearchFields = new SearchFields(); + var filters:Filter[] = []; + if(data){ + for(let j=0; j res.json()) + .catch(err => { + console.log('Error: ', err); + return Observable.throw(err); + }); + } + +} diff --git a/workingUIKIT/src/app/shared/cache.service.ts b/workingUIKIT/src/app/shared/cache.service.ts new file mode 100644 index 00000000..15431f3e --- /dev/null +++ b/workingUIKIT/src/app/shared/cache.service.ts @@ -0,0 +1,89 @@ +import { Inject, Injectable, isDevMode } from '@angular/core'; + +@Injectable() +export class CacheService { + static KEY = 'CacheService'; + + constructor(@Inject('LRU') public _cache: Map) { + + } + + /** + * check if there is a value in our store + */ + has(key: string | number): boolean { + let _key = this.normalizeKey(key); + return this._cache.has(_key); + } + + /** + * store our state + */ + set(key: string | number, value: any): void { + let _key = this.normalizeKey(key); + this._cache.set(_key, value); + } + + /** + * get our cached value + */ + get(key: string | number): any { + console.log("Cache get :"+key); + let _key = this.normalizeKey(key); + return this._cache.get(_key); + } + + /** + * release memory refs + */ + clear(): void { + this._cache.clear(); + } + + /** + * convert to json for the client + */ + dehydrate(): any { + let json = {}; + this._cache.forEach((value: any, key: string) => json[key] = value); + return json; + } + + /** + * convert server json into out initial state + */ + rehydrate(json: any): void { + Object.keys(json).forEach((key: string) => { + let _key = this.normalizeKey(key); + let value = json[_key]; + this._cache.set(_key, value); + }); + } + + /** + * allow JSON.stringify to work + */ + toJSON(): any { + return this.dehydrate(); + } + + /** + * convert numbers into strings + */ + normalizeKey(key: string | number): string { + if (isDevMode() && this._isInvalidValue(key)) { + throw new Error('Please provide a valid key to save in the CacheService'); + } + + return key + ''; + } + + _isInvalidValue(key): boolean { + return key === null || + key === undefined || + key === 0 || + key === '' || + typeof key === 'boolean' || + Number.isNaN(key); + } +} diff --git a/workingUIKIT/src/app/shared/model/model.service.ts b/workingUIKIT/src/app/shared/model/model.service.ts new file mode 100644 index 00000000..7d44a2b2 --- /dev/null +++ b/workingUIKIT/src/app/shared/model/model.service.ts @@ -0,0 +1,55 @@ +import { Injectable } from '@angular/core'; +import { Observable } from 'rxjs/Observable'; +import 'rxjs/add/observable/of'; +import 'rxjs/add/operator/do'; +import 'rxjs/add/operator/share'; + +import { CacheService } from '../cache.service'; +import { ApiService } from '../api.service'; + +export function hashCodeString(str: string): string { + let hash = 0; + if (str.length === 0) { + return hash + ''; + } + for (let i = 0; i < str.length; i++) { + let char = str.charCodeAt(i); + hash = ((hash << 5) - hash) + char; + hash = hash & hash; // Convert to 32bit integer + } + return hash + ''; +} + +// domain/feature service +@Injectable() +export class ModelService { + // This is only one example of one Model depending on your domain + constructor(public _api: ApiService, public _cache: CacheService) { + + } + + /** + * whatever domain/feature method name + */ + get(url) { + // you want to return the cache if there is a response in it. + // This would cache the first response so if your API isn't idempotent + // you probably want to remove the item from the cache after you use it. LRU of 10 + // you can use also hashCodeString here + let key = url; + + if (this._cache.has(key)) { + return Observable.of(this._cache.get(key)); + } + // you probably shouldn't .share() and you should write the correct logic + return this._api.get(url) + .do(json => { + this._cache.set(key, json); + }) + .share(); + } + // don't cache here since we're creating + create() { + // TODO + } +} diff --git a/workingUIKIT/src/app/shared/shared.module.ts b/workingUIKIT/src/app/shared/shared.module.ts new file mode 100644 index 00000000..a99fcdea --- /dev/null +++ b/workingUIKIT/src/app/shared/shared.module.ts @@ -0,0 +1,52 @@ +import { NgModule, ModuleWithProviders } from '@angular/core'; +import { CommonModule } from '@angular/common'; +import { RouterModule } from '@angular/router'; +import { FormsModule, ReactiveFormsModule } from '@angular/forms'; +import { ApiService } from './api.service'; +import { ModelService } from './model/model.service'; + +const MODULES = [ + // Do NOT include UniversalModule, HttpModule, or JsonpModule here + CommonModule, + RouterModule, + FormsModule, + ReactiveFormsModule +]; + +const PIPES = [ + // put pipes here +]; + +const COMPONENTS = [ + // put shared components here +]; + +const PROVIDERS = [ + ModelService, + ApiService +] + +@NgModule({ + imports: [ + ...MODULES + ], + declarations: [ + ...PIPES, + ...COMPONENTS + ], + exports: [ + ...MODULES, + ...PIPES, + ...COMPONENTS + ] +}) +export class SharedModule { + static forRoot(): ModuleWithProviders { + return { + ngModule: SharedModule, + providers: [ + ...PROVIDERS + ] + }; + } +} diff --git a/workingUIKIT/src/app/sharedComponents/bottom.component.ts b/workingUIKIT/src/app/sharedComponents/bottom.component.ts new file mode 100644 index 00000000..1293b2e8 --- /dev/null +++ b/workingUIKIT/src/app/sharedComponents/bottom.component.ts @@ -0,0 +1,47 @@ +import { Component } from '@angular/core'; +import 'rxjs/Rx'; + +@Component({ + selector: 'bottom', + template: ` + +

+` +}) +export class BottomComponent { + +} diff --git a/workingUIKIT/src/app/sharedComponents/cookie-law/cookie-law.component.ts b/workingUIKIT/src/app/sharedComponents/cookie-law/cookie-law.component.ts new file mode 100644 index 00000000..27d87037 --- /dev/null +++ b/workingUIKIT/src/app/sharedComponents/cookie-law/cookie-law.component.ts @@ -0,0 +1,148 @@ +/** + * angular2-cookie-law + * + * Copyright 2016-2017, @andreasonny83, All rights reserved. + * + * @author: @andreasonny83 + */ + +import { + Component, + OnInit, + ViewEncapsulation, + HostBinding, + Input, + Output, + EventEmitter, + animate, + state, + trigger, + style, + transition, + AnimationTransitionEvent, +} from '@angular/core'; + +import { + DomSanitizer, + SafeHtml, +} from '@angular/platform-browser'; + +import { + CookieLawService, +} from './cookie-law.service'; + +// import { +// closeIcon, +// } from './icons'; + +export type CookieLawPosition = 'top' | 'bottom'; +export type CookieLawAnimation = 'topIn' | 'bottomIn' | 'topOut' | 'bottomOut'; +export type CookieLawTarget = '_blank' | '_self'; + +@Component({ + selector: 'cookie-law', + // encapsulation: ViewEncapsulation.None, + animations: [ + trigger('state', [ + state('bottomOut', style({ transform: 'translateY(100%)' })), + state('topOut', style({ transform: 'translateY(-100%)' })), + state('*', style({ transform: 'translateY(0)' })), + + transition('void => topIn', [ + style({ transform: 'translateY(-100%)' }), + animate('1000ms ease-in-out'), + ]), + + transition('void => bottomIn', [ + style({ transform: 'translateY(100%)' }), + animate('1000ms ease-in-out'), + ]), + + transition('* => *', animate('1000ms ease-out')), + ]) + ], + styleUrls: [ './cookie-law.css' ], + templateUrl: './cookie-law.html', +}) +export class CookieLawComponent implements OnInit { + public cookieLawSeen: boolean; + + @Input('learnMore') + get learnMore() { return this._learnMore; } + set learnMore(value: string) { + this._learnMore = (value !== null && `${value}` !== 'false') ? value : null; + } + + @Input('target') + get target() { return this._target; } + set target(value: CookieLawTarget) { + this._target = (value !== null && `${value}` !== 'false' && + (`${value}` === '_blank' || `${value}` === '_self') + ) ? value : '_blank'; + } + + @Input('position') + get position() { return this._position; } + set position(value: CookieLawPosition) { + this._position = (value !== null && `${value}` !== 'false' && + (`${value}` === 'top' || `${value}` === 'bottom') + ) ? value : 'bottom'; + } + + @Output('isSeen') + private isSeenEvt: EventEmitter; + + @HostBinding('attr.seen') + public isSeen: boolean; + + private animation: CookieLawAnimation; + private closeSvg: SafeHtml; + private currentStyles: {}; + private _learnMore: string; + private _target: CookieLawTarget; + private _position: CookieLawPosition; + + constructor( + private _service: CookieLawService, + private domSanitizer: DomSanitizer, + ) { + this.isSeenEvt = new EventEmitter(); + this.animation = 'topIn'; + this._position = 'bottom'; + this.cookieLawSeen = this._service.seen(); + } + + ngOnInit(): void { + if (typeof document !== 'undefined') { + this.animation = this.position === 'bottom' ? 'bottomIn' : 'topIn'; + + this.closeSvg = '' ; + + if (this.cookieLawSeen) { + this.isSeen = true; + } + + this.currentStyles = { + 'top': this.position === 'top' ? '0' : null, + 'bottom': this.position === 'top' ? 'initial' : null, + }; + } + } + + afterDismissAnimation(evt: AnimationTransitionEvent) { + if (evt.toState === 'topOut' || + evt.toState === 'bottomOut') { + this.isSeen = true; + this.isSeenEvt.emit(this.isSeen); + } + } + + public dismiss(evt?: MouseEvent): void { + if (evt) { + evt.preventDefault(); + } + + this._service.storeCookie(); + this.animation = this.position === 'top' ? 'topOut' : 'bottomOut'; + } +} diff --git a/workingUIKIT/src/app/sharedComponents/cookie-law/cookie-law.css b/workingUIKIT/src/app/sharedComponents/cookie-law/cookie-law.css new file mode 100644 index 00000000..17e09689 --- /dev/null +++ b/workingUIKIT/src/app/sharedComponents/cookie-law/cookie-law.css @@ -0,0 +1,77 @@ +.cookie-law-wrapper a { + color: #bbb; + -webkit-transition: color .2s; + transition: color .2s; +} +.cookie-law-wrapper a:hover { + color: #fff; +} +.cookie-law-wrapper a:hover svg { + fill: #fff; +} +.cookie-law-wrapper { + background: #333; + color: #bbb; + display: block; + /*font-family: Helvetica Neue,Helvetica,Arial,sans-serif; + font-size: 15px; + font-weight: 200; + line-height: 20px;*/ + position: fixed; + bottom: 0; + left: 0; + width: 100%; + z-index: 999999999; + font-smooth: always; + -webkit-font-smoothing: antialiased; + text-align: center; +} +.dismiss { + display: block; + box-sizing: border-box; + padding: 10px; + position: absolute; + top: 0; + right: 10px; + text-decoration: none; + line-height: 20px; +} +.dismiss svg { + display: block; + fill: #bbb; + width: 20px; + height: 20px; + -webkit-transition: fill .2s; + transition: fill .2s; +} +.copy { + box-sizing: border-box; + padding: 10px 60px 10px 10px; +} +.copy span { + color: #fff; + /*font-weight: 400;*/ +} +.copy a { + text-decoration: underline; +} +.copy a:active, .copy a:hover { + outline: 0; +} + +@media (min-width: 600px) { + /* For bigger devices: */ + .copy { + padding: 20px 60px 20px 20px; + /*font-size: 18px; + line-height: 24px;*/ + } + .dismiss { + top: 10px; + right: 15px; + } + .dismiss svg { + width: 24px; + height: 24px; + } +} diff --git a/workingUIKIT/src/app/sharedComponents/cookie-law/cookie-law.html b/workingUIKIT/src/app/sharedComponents/cookie-law/cookie-law.html new file mode 100644 index 00000000..4033ba13 --- /dev/null +++ b/workingUIKIT/src/app/sharedComponents/cookie-law/cookie-law.html @@ -0,0 +1,21 @@ +