Comit a folder for working new template - UIKIT3
git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-portal/trunk@47043 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
parent
e7f4859e84
commit
2f431db0b2
|
@ -0,0 +1,150 @@
|
|||
|
||||
<p align="center">
|
||||
|
||||
<img src="https://cloud.githubusercontent.com/assets/1016365/10639063/138338bc-7806-11e5-8057-d34c75f3cafc.png" alt="Universal Angular 2" height="320"/>
|
||||
|
||||
</p>
|
||||
|
||||
# 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 `<img src="">` 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)
|
|
@ -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"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
module.exports = {
|
||||
NgProbeToken: {},
|
||||
_createConditionalRootRenderer: function(rootRenderer, extraTokens, coreTokens) {
|
||||
return rootRenderer;
|
||||
},
|
||||
__platform_browser_private__: {}
|
||||
};
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"watch": [
|
||||
"dist",
|
||||
"src/index.html"
|
||||
],
|
||||
"ext" : "js ts json html"
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -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 <hello@angularclass.com>",
|
||||
"PatrickJS <patrick@angularclass.com>",
|
||||
"Jeff Whelpley <jeff@gethuman.com>",
|
||||
"Jeff Cross <crossj@google.com>",
|
||||
"Mark Pieszak <mpieszak84@gmail.com>"
|
||||
],
|
||||
"dependencies": {
|
||||
"@angular/common": "~2.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"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,81 @@
|
|||
{
|
||||
"name": "universal-starter",
|
||||
"version": "2.0.0",
|
||||
"description": "Angular 2 Universal starter kit by @AngularClass",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/angular/universal-starter.git"
|
||||
},
|
||||
"scripts": {
|
||||
"watch": "webpack --watch",
|
||||
"prebuild": "rimraf dist",
|
||||
"build": "webpack",
|
||||
"build:prod": "webpack --progress -p",
|
||||
"prestart": "npm run build",
|
||||
"server": "nodemon dist/server/index.js",
|
||||
"debug:server": "node-nightly --inspect --debug-brk dist/server/index.js",
|
||||
"start": "npm run server",
|
||||
"debug:start": "npm run build && npm run debug:server",
|
||||
"predebug": "npm run build",
|
||||
"debug:build": "node-nightly --inspect --debug-brk node_modules/webpack/bin/webpack.js",
|
||||
"debug": "node --debug-brk dist/server/index.js"
|
||||
},
|
||||
"license": "MIT",
|
||||
"contributors": [
|
||||
"AngularClass <hello@angularclass.com>",
|
||||
"PatrickJS <patrick@angularclass.com>",
|
||||
"Jeff Whelpley <jeff@gethuman.com>",
|
||||
"Jeff Cross <crossj@google.com>",
|
||||
"Mark Pieszak <mpieszak84@gmail.com>"
|
||||
],
|
||||
"dependencies": {
|
||||
"@angular/common": "2.0.0",
|
||||
"@angular/compiler": "2.0.0",
|
||||
"@angular/core": "2.0.0",
|
||||
"@angular/forms": "2.0.0",
|
||||
"@angular/http": "2.0.0",
|
||||
"@angular/platform-browser": "2.0.0",
|
||||
"@angular/platform-browser-dynamic": "2.0.0",
|
||||
"@angular/platform-server": "2.0.0",
|
||||
"@angular/router": "3.0.0",
|
||||
"@ng-bootstrap/ng-bootstrap": "^1.0.0-alpha.6",
|
||||
"angular2-express-engine": "~2.0.11",
|
||||
"angular2-platform-node": "~2.0.11",
|
||||
"angular2-universal": "~2.0.11",
|
||||
"angular2-universal-polyfills": "~2.0.11",
|
||||
"body-parser": "^1.15.2",
|
||||
"bootstrap": "^4.0.0-alpha.4",
|
||||
"express": "^4.14.0",
|
||||
"methods": "~1.1.2",
|
||||
"ng2-webstorage": "^1.2.2",
|
||||
"rxjs": "5.0.0-beta.12",
|
||||
"zone.js": "0.6.23"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@angularclass/resolve-angular-routes": "^1.0.9",
|
||||
"@types/body-parser": "0.0.29",
|
||||
"@types/compression": "0.0.29",
|
||||
"@types/cookie-parser": "^1.3.29",
|
||||
"@types/express": "^4.0.32",
|
||||
"@types/express-serve-static-core": "^4.0.33",
|
||||
"@types/hammerjs": "^2.0.32",
|
||||
"@types/mime": "0.0.28",
|
||||
"@types/node": "^6.0.38",
|
||||
"@types/serve-static": "^1.7.27",
|
||||
"angular2-template-loader": "^0.4.0",
|
||||
"cookie-parser": "^1.4.3",
|
||||
"imports-loader": "^0.6.5",
|
||||
"json-loader": "^0.5.4",
|
||||
"nodemon": "^1.10.0",
|
||||
"raw-loader": "^0.5.1",
|
||||
"rimraf": "^2.5.4",
|
||||
"string-replace-loader": "github:gdi2290/string-replace-loader",
|
||||
"ts-loader": "^0.8.2",
|
||||
"ts-node": "^1.3.0",
|
||||
"typescript": "2.0.0",
|
||||
"webpack": "2.1.0-beta.22",
|
||||
"webpack-dev-middleware": "^1.6.1",
|
||||
"webpack-dev-server": "^2.1.0-beta.0",
|
||||
"webpack-merge": "^0.13.0"
|
||||
}
|
||||
}
|
|
@ -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
|
||||
}
|
||||
}
|
|
@ -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
|
|
@ -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<MetaDefinition|MetaDefinition[]>): HTMLMetaElement[] {
|
||||
const presentTags = this._flattenArray(tags);
|
||||
if (presentTags.length === 0) return [];
|
||||
return presentTags.map((tag: MetaDefinition) => this._addInternal(tag));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the meta tag by the given selector. Returns element or null
|
||||
* if there's no such meta element.
|
||||
*
|
||||
* ### Example
|
||||
*
|
||||
* ```ts
|
||||
* const meta: HTMLMetaElement = this.meta.getTag('name=description');
|
||||
* const twitterMeta: HTMLMetaElement = this.meta.getTag('name="twitter:title"');
|
||||
* const fbMeta: HTMLMetaElement = this.meta.getTag('property="fb:app_id"');
|
||||
* ```
|
||||
*
|
||||
* @param selector
|
||||
* @returns {HTMLMetaElement}
|
||||
*/
|
||||
getTag(selector: string): HTMLMetaElement {
|
||||
if (!selector) return null;
|
||||
return this._dom.query(`meta[${selector}]`);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the meta tag with the given selector.
|
||||
*
|
||||
* * ### Example
|
||||
*
|
||||
* ```ts
|
||||
* const meta: HTMLMetaElement = this.meta.updateTag('name=description', {name: 'description',
|
||||
* content: 'New description'});
|
||||
* console.log(meta.content); // 'New description'
|
||||
* ```
|
||||
*
|
||||
* @param selector
|
||||
* @param tag updated tag definition
|
||||
* @returns {HTMLMetaElement}
|
||||
*/
|
||||
updateTag(selector: string, tag: MetaDefinition): HTMLMetaElement {
|
||||
const meta: HTMLMetaElement = this.getTag(selector);
|
||||
if (!meta) {
|
||||
// create element if it doesn't exist
|
||||
return this._addInternal(tag);
|
||||
}
|
||||
return this._prepareMetaElement(tag, meta);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
|
@ -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 { }
|
|
@ -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: `
|
||||
<navbar></navbar>
|
||||
|
||||
|
||||
|
||||
<div id="tm-main" class="tm-middle custom-main-content" uk-height-viewport="mode: expand">
|
||||
<div class="uk-container uk-container-center">
|
||||
<div class="uk-grid" uk-grid>
|
||||
<div class="tm-main uk-width-small-1-1 uk-width-medium-1-1 uk-width-large-1-1 uk-row-first ">
|
||||
|
||||
<main>
|
||||
<router-outlet></router-outlet>
|
||||
</main>
|
||||
</div>
|
||||
<!-- Sidebar -->
|
||||
<!--div id="tm-sidebar" class="tm-sidebar uk-width-medium-1-4 uk-hidden-small">
|
||||
<div class="uk-child-width-1-1" uk-grid>
|
||||
something in sidebar
|
||||
|
||||
<login></login>
|
||||
</div>
|
||||
</div-->
|
||||
<!-- end of sidebar -->
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<cookie-law position="bottom">
|
||||
OpenAIRE uses cookies in order to function properly.<br>
|
||||
Cookies are small pieces of data that websites store in your browser to allow us to give you the best browsing experience possible.
|
||||
By using the OpenAIRE portal you accept our use of cookies. <a href="//ec.europa.eu/ipg/basics/legal/cookies/index_en.htm" target="_blank"> Read more <i class="uk-icon-angle-double-right"></i></a>
|
||||
</cookie-law>
|
||||
<bottom></bottom>
|
||||
|
||||
`
|
||||
|
||||
})
|
||||
export class AppComponent {
|
||||
title = 'ftw';
|
||||
}
|
|
@ -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';
|
|
@ -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{
|
||||
|
||||
}
|
|
@ -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: `
|
||||
|
||||
<div class="uk-form uk-animation uk-panel uk-panel-box uk-panel-box-default " >
|
||||
<div>Search for Communities:</div>
|
||||
<table>
|
||||
<tr>
|
||||
<td >
|
||||
<select class="custom-select-mini" name="select_funder" >
|
||||
<option value="0" (click)="communityChanged('0','Community:')">Select Community:</option>
|
||||
<option *ngIf="communities" (click)="communityChanged(communities.id, communities.label)" [value]="communities.id" >{{communities.label}}</option>
|
||||
</select>
|
||||
</td>
|
||||
<td *ngIf="selectedCommunityId != '0' && categories.length > 0"><select class="custom-select-mini" name="select_funder" >
|
||||
<option value="0" (click)="categoryChanged('0','Category:')">Select Category:</option>
|
||||
<option *ngFor="let category of categories" (click)="categoryChanged(category.id, category.label)" [value]="category.id" >{{category.label}}</option>
|
||||
</select>
|
||||
</td><td >
|
||||
<static-autocomplete [(list)] = concepts [allowDuplicates]=true [showSelected]=false [placeHolderMessage] = "'Type keywords...'" title = "Concepts:" [multipleSelections]=true (addItem) = "select($event)" > </static-autocomplete>
|
||||
</td></tr>
|
||||
|
||||
</table>
|
||||
<div *ngIf="loading" class="uk-alert uk-alert-info" role="alert">Loading communities information...</div>
|
||||
<div *ngIf="warningMessage.length > 0" class="uk-alert uk-alert-warning" role="alert">{{warningMessage}}</div>
|
||||
<div *ngIf="infoMessage.length > 0" class="uk-alert uk-alert-info" role="alert">{{infoMessage}}</div>
|
||||
</div>
|
||||
|
||||
`
|
||||
|
||||
})
|
||||
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 } });
|
||||
}
|
||||
}
|
|
@ -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 { }
|
|
@ -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;
|
||||
|
||||
}
|
|
@ -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: `
|
||||
<div>
|
||||
<form class="uk-form uk-animation uk-panel uk-panel-box uk-panel-box-default " >
|
||||
<table ><tr>
|
||||
<td >
|
||||
Search for projects:
|
||||
</td></tr>
|
||||
<tr><td >
|
||||
<select class="custom-select-mini" [(ngModel)]="selectedFunderId" name="select_funder" >
|
||||
<option value="0" (click)="funderChanged('0','Select funder:')">Select funder:</option>
|
||||
<option *ngFor="let funder of funders" [value]="funder.id" (click)="funderChanged(funder.id,funder.name)">{{funder.name}}</option>
|
||||
</select></td><td >
|
||||
<entities-autocomplete entityType="project" [funderId]="selectedFunderId" [allowDuplicates]=true [showSelected]=false [placeHolderMessage] = "'Type Keywords..'" title = "Projects:" [multipleSelections]=true (addItem) = "select($event)" ></entities-autocomplete>
|
||||
</td></tr></table>
|
||||
</form>
|
||||
<modal-loading [message]= "'Loading...'"></modal-loading>
|
||||
<!--div *ngIf="warningMessage.length > 0" class="alert alert-warning" role="alert">{{warningMessage}}</div>
|
||||
<div *ngIf="infoMessage.length > 0" class="alert alert-info" role="alert">{{infoMessage}}</div-->
|
||||
|
||||
</div>
|
||||
`
|
||||
|
||||
})
|
||||
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<string>();
|
||||
// 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 );
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -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 { }
|
|
@ -0,0 +1,182 @@
|
|||
<form class="uk-form uk-panel uk-margin-top uk-panel-box uk-panel-box-default uk-animation">
|
||||
Search for research results:
|
||||
<div class="input-group">
|
||||
<input class=" form-control" [(ngModel)]="keyword" name="keyword" placeholder="Type keywords..."/>
|
||||
<span class="input-group-btn">
|
||||
<button (click)="search()" type="submit" class="uk-button">Search</button>
|
||||
</span>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<div *ngIf="showSearchResults" class="uk-margin-top uk-animation">
|
||||
<ul class="uk-tab" data-uk-switcher="{connect:'#claimsearchtabs'}">
|
||||
<li class="active"><a data-toggle="tab" >Crossref ({{(crossrefResultsNum)?crossrefResultsNum:0}})</a></li>
|
||||
<li><a data-toggle="tab" >Openaire Publications({{ (openairePubsNum)?openairePubsNum:0 }})</a></li>
|
||||
<li><a data-toggle="tab" >Orcid ({{ (orcidResultsNum)?orcidResultsNum:0}})</a></li>
|
||||
<li class="active"><a data-toggle="tab" >Datacite ({{(dataciteResultsNum==null)?'0':dataciteResultsNum}})</a></li>
|
||||
<li><a data-toggle="tab" >Openaire Datasets({{(openaireDataNum==null)?'0':openaireDataNum}})</a></li>
|
||||
</ul>
|
||||
<ul id="claimsearchtabs" class="uk-switcher">
|
||||
<li id="crossref" >
|
||||
<div class="uk-margin-top" >
|
||||
<div *ngIf="crossrefStatus == errorCodes.LOADING" class="uk-alert uk-alert-info" role="alert">Loading...</div>
|
||||
<div *ngIf="crossrefStatus != errorCodes.LOADING && crossrefResults.length == 0" class="uk-alert uk-alert-info" role="alert">No Results found</div>
|
||||
<div *ngIf="crossrefStatus == errorCodes.ERROR" class="uk-alert uk-alert-warning" role="alert">An Error Occured</div>
|
||||
<div *ngIf="crossrefStatus == errorCodes.NOT_AVAILABLE" class="uk-alert uk-alert-danger" role="alert">Service not available</div>
|
||||
<div *ngIf="crossrefResultsNum != null && crossrefResultsNum > 0" class="uk-clearfix">
|
||||
<div class="uk-float-right">
|
||||
<paging-no-load [currentPage]="crossrefPage" [totalResults]="crossrefResultsNum" [navigateTo]="navigateTo" [term]="keyword" [size]="size" (pageChange)="crossrefPageChange($event)"> </paging-no-load>
|
||||
</div>
|
||||
</div>
|
||||
<div >
|
||||
<ul *ngIf="crossrefResults.length > 0 " class="uk-list uk-list-line">
|
||||
<li *ngFor=" let item of crossrefResults " [class]="(isSelected(item.DOI))?'uk-block-muted':''">
|
||||
<div >
|
||||
<a *ngIf="item.URL" target="_blank" href="{{item.URL}}" ><span class="uk-icon-external-link" ></span> {{item.title}}</a>
|
||||
<span *ngIf="!item.URL" >{{item.title}}</span>
|
||||
<button class="uk-button uk-align-right" *ngIf="!isSelected(item.DOI)" (click)="add(item, item.DOI, 'crossref', 'publication', item.URL, item.title, item.created['date-time'],'OPEN')"><i aria-hidden="true" class= "uk-icon-plus clickable"></i></button>
|
||||
</div>
|
||||
<span *ngIf="item.publisher" class="uk-article-meta">Publisher: {{item.publisher}}</span><span class="uk-article-meta" *ngIf="(item['published-print'] && item['published-print']['date-parts'] && item['published-print']['date-parts'][0])">({{(item['published-print']['date-parts'][0][0])?item['published-print']['date-parts'][0][0]:item['published-print']['date-parts'][0]}})</span>
|
||||
<div *ngIf="item.author && item.author.length > 0" class="uk-article-meta">Authors: <span *ngFor="let author of item.author.slice(0,10) let i = index">{{author.family}} {{author.given}}{{(i < (item.author.slice(0,10).length-1))?"; ":""}}{{(i == item.author.slice(0,10).length-1 && item.author.length > 10)?"...":""}}</span></div>
|
||||
<div *ngIf="item.editor && item.editor.length > 0" class="uk-article-meta">Editors: <span *ngFor="let author of item.editor.slice(0,10) let i = index">{{author.family}} {{author.given}}{{(i < (item.editor.slice(0,10).length-1))?"; ":""}}{{(i == item.editor.slice(0,10).length-1 && item.editor.length > 10)?"...":""}}</span></div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li id="openairePubs" >
|
||||
<div class = "uk-margin-top">
|
||||
<div *ngIf="openairePubsStatus == errorCodes.LOADING" class="uk-alert uk-alert-info" role="alert">Loading...</div>
|
||||
<div *ngIf="openairePubsStatus == errorCodes.NONE" class="uk-alert uk-alert-info" role="alert">No Results found</div>
|
||||
<div *ngIf="openairePubsStatus == errorCodes.ERROR" class="uk-alert uk-alert-warning" role="alert">An Error Occured</div>
|
||||
<div *ngIf="openairePubsStatus == errorCodes.NOT_AVAILABLE" class="uk-alert uk-alert-danger" role="alert">Service not available</div>
|
||||
<div *ngIf="openairePubsNum != null && openairePubsNum > 0" class="uk-clearfix">
|
||||
<div class="uk-float-right">
|
||||
<paging-no-load [currentPage]="openairePubsPage" [totalResults]="openairePubsNum" [navigateTo]="navigateTo" [term]="keyword" [size]="size" (pageChange)="openairePubsPageChange($event)"> </paging-no-load>
|
||||
</div>
|
||||
</div>
|
||||
<div >
|
||||
<ul *ngIf="openairePubs.length > 0 " class="uk-list uk-list-line">
|
||||
<li *ngFor=" let result of openairePubs " [class]="(isSelected(result.id))?'uk-block-muted':''">
|
||||
<div >
|
||||
<a *ngIf="result['title'].url" target="_blank" [href]="result['title'].url" >{{result['title'].name}}</a>
|
||||
<span *ngIf="!result['title'].url" >{{result['title'].name}}</span>
|
||||
<button *ngIf="!isSelected(result.id)" (click)="add(result, result.id, 'openaire', 'publication', result['title'].url, result['title'].name, result.year,result['title'].accessMode)" class="uk-button uk-align-right"><i aria-hidden="true" class= "uk-icon-plus clickable"></i></button>
|
||||
</div>
|
||||
<span *ngIf="result.publisher" class="uk-article-meta">Publisher: {{result.publisher}}</span><span class="uk-article-meta" *ngIf="(result.year)">({{result.year}})</span>
|
||||
<div *ngIf="result.authors && result.authors.length >0 " class="uk-article-meta">Authors: <span *ngFor="let author of result.authors.slice(0,10) let i = index">{{author.name}}{{(i < (result.authors.slice(0,10).length-1))?"; ":""}}{{(i == result.authors.slice(0,10).length-1 && result.authors.length > 10)?"...":""}}</span></div>
|
||||
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li id="orcid" class="tab-pane fade">
|
||||
<div class="uk-margin-top" >
|
||||
<div *ngIf="orcidStatus == errorCodes.LOADING" class="uk-alert uk-alert-info" role="alert">Loading...</div>
|
||||
<div *ngIf="orcidStatus == errorCodes.ERROR" class="uk-alert uk-alert-warning" role="alert">An Error Occured</div>
|
||||
<div *ngIf="orcidStatus == errorCodes.NOT_AVAILABLE" class="uk-alert uk-alert-danger" role="alert">Service not available</div>
|
||||
<div *ngIf="orcidStatus == errorCodes.NONE && (!authorIds ||authorIds.length == 0)" class = "uk-alert uk-alert-info " > No results found </div>
|
||||
|
||||
<div *ngIf="orcidResultsNum != null" class="panel-body">
|
||||
<div class = "uk-alert uk-alert-warning " > Not the right author? Choose one of these:
|
||||
|
||||
<span class="dropdown">
|
||||
|
||||
<select [(ngModel)]="authorId" name="select_author" (ngModelChange)="getOrcidResultsById(authorId)" >authorIds
|
||||
<option *ngFor=" let item of authorIds let i = index" [value]="authorIds[i]">{{authorGivenNames[i]}} {{authorFamilyNames[i]}} : {{item}} </option> <!-- (click)="getOrcidResultsById(i)" -->
|
||||
</select>
|
||||
</span>
|
||||
|
||||
|
||||
</div>
|
||||
<span>Results for
|
||||
<a target="_blank" href="http://orcid.org/{{authorId}}"><span class="uk-icon-external-link" ></span> {{authorGivenName}} {{authorFamilyName}} - {{authorId}} </a> :
|
||||
</span>
|
||||
|
||||
<div *ngIf=" ((orcidResultsNum >0) && (totalPages > 1) && ( 0 < page && page <= totalPages )) " class="uk-clearfix">
|
||||
<div class="uk-float-right">
|
||||
<paging-no-load [currentPage]="orcidPage" [totalResults]="orcidResultsNum" [navigateTo]="navigateTo" [term]="keyword" [size]="size" (pageChange)="orcidPageChange($event)"> </paging-no-load>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div >
|
||||
<ul *ngIf="orcidResultsNum >0 && orcidResultsToShow.length > 0 " class="uk-list uk-list-line">
|
||||
<li *ngFor=" let item of orcidResultsToShow " [class]="(isSelected(authorId+'-'+item['put-code']))?'uk-block-muted':''">
|
||||
<div>
|
||||
<span *ngIf="!item.URL" >{{item['work-title']['title'].value}}</span>
|
||||
<button class="uk-button uk-align-right" *ngIf="!isSelected(authorId+item['put-code'])" (click)="add(item,authorId+'-'+item['put-code'],'orcid', 'publication', '', item['work-title']['title'].value, item['publication-date']?item['publication-date'].year.value :null,'OPEN')"><i aria-hidden="true" class= " uk-icon-plus clickable"></i></button>
|
||||
</div>
|
||||
<span *ngIf="item['journal-title'] && item['journal-title'].value " class="uk-article-meta">Journal: {{item['journal-title'].value}}</span><span class="uk-article-meta" *ngIf="(item['publication-date']&&item['publication-date'].year&&item['publication-date'].year.value)"> ({{item['publication-date'].year.value}})</span>
|
||||
<div *ngIf="item.contributors && item.contributors.length > 0" class="uk-article-meta">Authors: <span *ngFor="let author of item.contributors.slice(0,10) let i = index">{{author}}{{(i < (item.contributors.slice(0,10).length-1))?"; ":""}}{{(i == item.contributors.slice(0,10).length-1 && item.contributors.length > 10)?"...":""}}</span></div>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
<div *ngIf="orcidResultsNum == 0" class = "uk-alert uk-alert-info " > No results found </div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li id="datacite" class="tab-pane fade in active">
|
||||
<div *ngIf="dataciteStatus == errorCodes.LOADING" class="uk-alert uk-alert-info" role="alert">Loading...</div>
|
||||
<div *ngIf="dataciteStatus == errorCodes.NONE" class="uk-alert uk-alert-info" role="alert">No Results found</div>
|
||||
<div *ngIf="dataciteStatus == errorCodes.ERROR" class="uk-alert uk-alert-warning" role="alert">An Error Occured</div>
|
||||
<div *ngIf="dataciteStatus == errorCodes.NOT_AVAILABLE" class="uk-alert uk-alert-danger" role="alert">Service not available</div>
|
||||
<div class = "uk-margin-top">
|
||||
<div *ngIf="dataciteResultsNum != null && dataciteResultsNum > 0" class="uk-clearfix">
|
||||
<div class="uk-float-right">
|
||||
<paging-no-load [currentPage]="datacitePage" [totalResults]="dataciteResultsNum" [navigateTo]="navigateTo" [term]="keyword" [size]="size" (pageChange)="datacitePageChange($event)"> </paging-no-load>
|
||||
</div>
|
||||
</div>
|
||||
<div >
|
||||
<ul *ngIf="dataciteResults.length > 0 " class="uk-list uk-list-line">
|
||||
<li *ngFor=" let item of dataciteResults " [class]="(isSelected(item.doi))?'uk-block-muted':''" >
|
||||
<div >
|
||||
<a *ngIf="item.doi" target="_blank" href="{{'http://dx.doi.org/'+item.doi}}" ><span class="uk-icon-external-link" ></span> {{item.title}}</a>
|
||||
<span *ngIf="!item.doi" >{{item.title}}</span>
|
||||
<button class="uk-button uk-align-right" *ngIf="!isSelected(item.doi)" (click)="add(item, item.doi,'datacite','dataset', 'http://dx.doi.org/'+item.doi, item.title, null,'OPEN')"><i aria-hidden="true" class= "uk-icon-plus clickable"></i></button>
|
||||
|
||||
</div>
|
||||
<span *ngIf="item.publisher" class="uk-article-meta">Publisher: {{item.publisher}}</span>
|
||||
<div *ngIf="item.creator && item.creator.length > 0" class="uk-article-meta">Authors: <span *ngFor="let author of item.creator.slice(0,10) let i = index">{{author}}{{(i < (item.creator.slice(0,10).length-1))?"; ":""}}{{(i == item.creator.slice(0,10).length-1 && item.creator.length > 10)?"...":""}}</span></div>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li id="openaireData" class="tab-pane fade">
|
||||
<div *ngIf="openaireDataStatus == errorCodes.LOADING" class="uk-alert uk-alert-info" role="alert">Loading...</div>
|
||||
<div *ngIf="openaireDataStatus == errorCodes.NONE" class="uk-alert uk-alert-info" role="alert">No Results found</div>
|
||||
<div *ngIf="openaireDataStatus == errorCodes.ERROR" class="uk-alert uk-alert-warning" role="alert">An Error Occured</div>
|
||||
<div *ngIf="openaireDataStatus == errorCodes.NOT_AVAILABLE" class="uk-alert uk-alert-danger" role="alert">Service not available</div>
|
||||
<div class = "uk-margin-top">
|
||||
<div *ngIf="openaireDataNum != null && openaireDataNum > 0" class="uk-clearfix">
|
||||
<div class="uk-float-right">
|
||||
<paging-no-load [currentPage]="openaireDataPage" [totalResults]="openaireDataNum" [navigateTo]="navigateTo" [term]="keyword" [size]="size" (pageChange)="openaireDataPageChange($event)"> </paging-no-load>
|
||||
</div>
|
||||
</div>
|
||||
<div >
|
||||
<ul *ngIf="openaireData.length > 0 " class="uk-list uk-list-line">
|
||||
<li *ngFor=" let result of openaireData " [class]="(isSelected(result.id))?'uk-block-muted':''">
|
||||
<div >
|
||||
<a *ngIf="result['title'].url" target="_blank" [href]="result['title'].url" >{{result['title'].name}}</a>
|
||||
<span *ngIf="!result['title'].url" >{{result['title'].name}}</span>
|
||||
|
||||
|
||||
<button class="uk-button uk-align-right" *ngIf="!isSelected(result.id)"
|
||||
(click)="add(result, result.id, 'openaire','dataset', result['title'].url, result['title'].name, result.year, result['title'].accessMode)"> <i aria-hidden="true" class= "uk-icon-plus clickable"></i></button>
|
||||
</div>
|
||||
<span *ngIf="result.publisher" class="uk-article-meta">Publisher: {{result.publisher}}</span><span *ngIf="(result.year)" class="uk-article-meta">({{result.year}})</span>
|
||||
<div *ngIf="result.authors && result.authors.length >0 " class="uk-article-meta">Authors: <span *ngFor="let author of result.authors.slice(0,10) let i = index">{{author.name}}{{(i < (result.authors.slice(0,10).length-1))?"; ":""}}{{(i == result.authors.slice(0,10).length-1 && result.authors.length > 10)?"...":""}}</span></div>
|
||||
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
|
@ -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<number> = 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<string>();
|
||||
this.authorGivenNames = new Array<string>();
|
||||
this.authorFamilyNames = new Array<string>();
|
||||
|
||||
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";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -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 { }
|
|
@ -0,0 +1,89 @@
|
|||
|
||||
<form class="uk-form">
|
||||
|
||||
|
||||
<div class="uk-form-row">
|
||||
<span class="uk-text-bold">Filter By:</span>
|
||||
<input type="text" class="form-control" placeholder="Type keywords..." aria-describedby="sizing-addon2" [(ngModel)]="inputkeyword" (keyup)="changekeyword()" name="claims-keyword" ></div>
|
||||
<div class="uk-form-row">
|
||||
<label> <input [(ngModel)]="projectCB" type="checkbox" (ngModelChange)="changeType()" name="project" /> Project </label>
|
||||
<label> <input [(ngModel)]="publicationCB" type="checkbox" (ngModelChange)="changeType()" name="publication" /> Publication </label>
|
||||
<label> <input [(ngModel)]="datasetCB" type="checkbox" (ngModelChange)="changeType()" name="dataset" /> Dataset </label>
|
||||
<label> <input [(ngModel)]="contextCB" type="checkbox" (ngModelChange)="changeType()" name="context" /> Context </label>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
<div class="searchPaging uk-panel uk-margin-top" data-uk-grid-margin="">
|
||||
|
||||
<div *ngIf="resultsNum" class="uk-float-right">
|
||||
<paging-no-load [currentPage]="page" [totalResults]="resultsNum" [navigateTo]="navigateTo" [params]="getParameters()" [size]="size" (pageChange)="pageChange($event)"> </paging-no-load>
|
||||
</div>
|
||||
|
||||
<div *ngIf="resultsNum>0" class="">
|
||||
<span > Show
|
||||
<select *ngIf="resultsNum>10" [(ngModel)]="size" name="select_size" (ngModelChange)="changeSize(size)" >
|
||||
<option *ngFor="let size of sizes" [value]="size">{{size}}</option>
|
||||
</select>
|
||||
</span>
|
||||
<span >Showing {{(size*page - size +1)}} to {{(size*page>resultsNum)?resultsNum:(size*page)}} of {{resultsNum}} claims </span>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div *ngIf="showErrorMessage " class = "uk-alert uk-alert-danger " >
|
||||
An Error occured.
|
||||
</div>
|
||||
<div *ngIf="userValidMessage.length > 0 " class = "uk-alert uk-alert-danger " >
|
||||
User session is not valid. Please login again.
|
||||
</div>
|
||||
|
||||
|
||||
<!-- Buttons for selecting and Delete Claims -->
|
||||
<div *ngIf="enableDelete">
|
||||
<div *ngIf="selected.length>0 && resultsNum > 0 ">
|
||||
<div class = "uk-alert uk-alert-info " >
|
||||
You have selected {{selected.length}} claim(s)
|
||||
</div>
|
||||
</div>
|
||||
<div *ngIf="deleteMessage.length>0 " class = "uk-alert uk-alert-info " [innerHTML]="deleteMessage">
|
||||
|
||||
</div>
|
||||
<button class="uk-button" (click)="selectAll()">Select All</button> <button class="uk-button" (click)="deselectAll()">Deselect All</button> <button class="uk-button" (click)="confirmOpen()">Delete</button>
|
||||
</div>
|
||||
<br>
|
||||
|
||||
|
||||
<div *ngIf=" claims && claims.length == 0" >
|
||||
<div class = "uk-alert uk-alert-info " >No entries found.</div>
|
||||
</div>
|
||||
|
||||
<div class="">
|
||||
<table *ngIf="claims && claims.length > 0" class="uk-table uk-table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th *ngIf="enableDelete"></th>
|
||||
<!--<th>Id</th>
|
||||
<!-- <th>Target Type</th> -->
|
||||
<th><a (click)="changeOrderby('target')" >Research Result</a> </th>
|
||||
<!--<th>Source type</th> -->
|
||||
<th><a (click)="changeOrderby('source')" >Link to</a> </th>
|
||||
|
||||
<th><a (click)="changeOrderby('user')" >Claimed by</a> </th>
|
||||
<th><a (click)="changeOrderby('date')"> Claimed Date</a></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr *ngFor="let claim of claims " >
|
||||
<td *ngIf="enableDelete"><input [id]="claim.id" type="checkbox" (click)="select(claim,$event)" [ngModel]="isSelected(claim.id)"/></td>
|
||||
|
||||
<td><claim-entity [entity]="claim.target" [type]="claim.targetType" > </claim-entity></td>
|
||||
<td><claim-entity [entity]="claim.source" [type]="claim.sourceType" > </claim-entity></td>
|
||||
<td>{{claim.userMail}}</td>
|
||||
<td>{{claim.date}}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<modal-alert (alertOutput)="confirmClose($event)">
|
||||
</modal-alert>
|
||||
<modal-loading [message]= "'Please wait...'"></modal-loading>
|
|
@ -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+'<div class = "alert alert-success " >'+res.deletedIds.length+' claim(s) successfully deleted.</div>';
|
||||
}
|
||||
if(res.notFoundIds.length>0){
|
||||
this.deleteMessage=this.deleteMessage+'<div class = "alert alert-warning " >'+res.notFoundIds.length+' claim(s) couldn\'t be deleted.</div>';
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
pageChange($event) {
|
||||
var page:number = +$event.value
|
||||
this.goTo(page);
|
||||
}
|
||||
}
|
|
@ -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 { }
|
|
@ -0,0 +1,36 @@
|
|||
import {Component, Input} from '@angular/core';
|
||||
|
||||
//Usage Example "<claim-entity [entity]="" [type]="" > </claim-entity>"
|
||||
|
||||
//externalUrl
|
||||
@Component({
|
||||
selector: 'claim-entity',
|
||||
template: `
|
||||
|
||||
<div *ngIf="type == 'publication' || type == 'dataset'">
|
||||
<i>({{type}}) </i>
|
||||
<publication-title [title]="entity.title" [url]="entity.externalUrl" ></publication-title>
|
||||
</div>
|
||||
<div *ngIf="type == 'project' ">
|
||||
<i>(Project)</i>
|
||||
<project-title [project]="entity"></project-title>
|
||||
</div>
|
||||
<div *ngIf="type == 'context' ">
|
||||
<i>(Context)</i>
|
||||
<h5>{{entity.title}}</h5>
|
||||
</div>
|
||||
`
|
||||
})
|
||||
|
||||
export class ClaimEntityFormatter {
|
||||
@Input() entity: string[];
|
||||
@Input() type: string;
|
||||
|
||||
constructor () {}
|
||||
|
||||
ngOnInit() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -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 { }
|
|
@ -0,0 +1,25 @@
|
|||
import {Component, Input} from '@angular/core';
|
||||
import {OpenaireProperties} from '../../../utils/properties/openaireProperties';
|
||||
import {RouterHelper} from '../../../utils/routerHelper.class';
|
||||
|
||||
//Usage Example "<project-title [project]="X" > </project-title>"
|
||||
|
||||
@Component({
|
||||
selector: 'project-title',
|
||||
template: `
|
||||
<div class="project-title">
|
||||
<h5 ><a [queryParams]="routerHelper.createQueryParam('projectId',project['openaireId'])" routerLinkActive="router-link-active" routerLink="/search/project" >{{project['name']}} ({{project['funderName']}})</a></h5>
|
||||
</div>
|
||||
`
|
||||
})
|
||||
|
||||
export class ProjectTitleFormatter {
|
||||
@Input() project: string[];
|
||||
public url:string;
|
||||
public routerHelper:RouterHelper = new RouterHelper();
|
||||
constructor () {}
|
||||
|
||||
ngOnInit() {
|
||||
this.url = OpenaireProperties.getsearchLinkToProject() + "?projectId=" + this.project["openaireId"];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
import {Component, Input} from '@angular/core';
|
||||
|
||||
//Usage Example "<publication-title [title]="X" [url]="X" > </publication-title>"
|
||||
|
||||
@Component({
|
||||
selector: 'publication-title',
|
||||
template: `
|
||||
<div class="publication-title">
|
||||
<h5 *ngIf="url" ><a target="_blank" href="{{url}}" ><span class="uk-icon-external-link custom-icon" ></span> {{title}}</a></h5>
|
||||
<h5 *ngIf="!url" >{{title}}</h5>
|
||||
</div>
|
||||
`
|
||||
})
|
||||
|
||||
export class PublicationTitleFormatter {
|
||||
@Input() title: string[];
|
||||
@Input() url: string[];
|
||||
|
||||
constructor () {}
|
||||
|
||||
ngOnInit() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -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 => <any> 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 => <any> 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 => <any> 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);
|
||||
}
|
||||
)
|
||||
;
|
||||
});
|
||||
}
|
||||
|
||||
}
|
|
@ -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 { }
|
|
@ -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 => <any> 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 => <any> 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 => <any> 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');
|
||||
}
|
||||
}
|
|
@ -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 { }
|
|
@ -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');
|
||||
}
|
||||
|
||||
}
|
|
@ -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 => <any> 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 => <any> 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<dois.length; i++){
|
||||
url=url+(url.length==0?'':',')+'doi:'+dois[i];
|
||||
}
|
||||
url = OpenaireProperties.getSearchCrossrefAPIURL()+'?filter='+url;
|
||||
let key = url;
|
||||
if (this._cache.has(key)) {
|
||||
return Observable.of(this._cache.get(key));
|
||||
}
|
||||
|
||||
return this.http.get( url)
|
||||
.map(request => <any> 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');
|
||||
}
|
||||
|
||||
}
|
|
@ -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 { }
|
|
@ -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 => <any> 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 || { };
|
||||
}
|
||||
}
|
|
@ -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; i<length; i++) {
|
||||
mydata = data.length!=undefined ? data[i] : data;
|
||||
|
||||
if(mydata.hasOwnProperty("orcid-profile")) {
|
||||
if(mydata['orcid-profile'].hasOwnProperty("orcid-identifier")) {
|
||||
authorIds.push(mydata['orcid-profile']['orcid-identifier'].path);
|
||||
|
||||
if(mydata['orcid-profile'].hasOwnProperty("orcid-bio")) {
|
||||
if(mydata['orcid-profile']['orcid-bio'].hasOwnProperty("personal-details")) {
|
||||
if(mydata['orcid-profile']['orcid-bio']['personal-details'].hasOwnProperty("given-names")) {
|
||||
authorGivenNames.push(mydata['orcid-profile']['orcid-bio']['personal-details']['given-names'].value);
|
||||
} else {
|
||||
authorGivenNames.push("");
|
||||
}
|
||||
|
||||
if(mydata['orcid-profile']['orcid-bio']['personal-details'].hasOwnProperty("family-name")) {
|
||||
authorFamilyNames.push(mydata['orcid-profile']['orcid-bio']['personal-details']['family-name'].value);
|
||||
} else {
|
||||
authorFamilyNames.push("");
|
||||
}
|
||||
}
|
||||
}
|
||||
ret = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
import {Component, Input, Output, EventEmitter} from '@angular/core';
|
||||
|
||||
import {ClaimResult} from '../claim-utils/claimEntities.class';
|
||||
|
||||
@Component({
|
||||
selector: 'start-over',
|
||||
template: `<button (click)="startOver()" class="uk-button uk-button-danger uk-align-right" >Start Over</button>`,
|
||||
|
||||
})
|
||||
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 );
|
||||
}
|
||||
|
||||
}
|
|
@ -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 { }
|
|
@ -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 { }
|
|
@ -0,0 +1,10 @@
|
|||
<div *ngIf="id">
|
||||
<p>Here is the claim with id : {{id}}</p>
|
||||
<div *ngIf="claim">
|
||||
{{claim.id }} || {{claim.userMail }} ||
|
||||
{{claim | json}} {{claim | json}}
|
||||
</div>
|
||||
</div>
|
||||
<div *ngIf="!id">
|
||||
<p>No proper id...</p>
|
||||
</div>
|
|
@ -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);
|
||||
}) ;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -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 { }
|
|
@ -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: `
|
||||
<div class="container">
|
||||
<div class="page-header">
|
||||
<h1> Claims Administrator </h1>
|
||||
</div>
|
||||
<div>
|
||||
<div class="uk-text-right"><a routerLink="/participate/claim">Add more Links?</a></div>
|
||||
<displayClaims [enableDelete]=true [myClaims]=false [isAdmin]=true></displayClaims>
|
||||
</div>
|
||||
</div>
|
||||
`,
|
||||
|
||||
})
|
||||
export class ClaimsAdminComponent {
|
||||
constructor ( ) {
|
||||
|
||||
}
|
||||
ngOnInit() {
|
||||
}
|
||||
}
|
|
@ -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 { }
|
|
@ -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 { }
|
|
@ -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: `
|
||||
|
||||
<!--div class="page-header">
|
||||
<h1> Claims Manager </h1>
|
||||
</div-->
|
||||
|
||||
<!--div *ngIf="accessStatus=='empty'" class="uk-margin-top uk-width-medium-2-3 uk-container-center">
|
||||
<div class="uk-block uk-block-primary uk-block-large uk-contrast uk-text-center">
|
||||
<p class="uk-text-large">Please enter your email and then press 'See Claims' button.</p>
|
||||
<form class="uk-form">
|
||||
<fieldset data-uk-margin>
|
||||
<input type="text" placeholder="example@email.com" name="email" [(ngModel)]="email">
|
||||
<button (click)="validateJWTandToken()" class="uk-button">See Claims</button>
|
||||
</fieldset>
|
||||
</form>
|
||||
</div>
|
||||
</div-->
|
||||
|
||||
<div *ngIf="accessStatus=='invalid'" class="uk-margin-top uk-width-medium-2-3 uk-container-center">
|
||||
<div class="uk-block uk-block-primary uk-block-large uk-contrast uk-text-center">
|
||||
<!--p class="uk-text-large">Oops! There is no entry for you! Please retry with another email or for another project.</p-->
|
||||
<!--button (click)="accessStatus='empty'" class="uk-button">Retry</button-->
|
||||
<p class="uk-text-large">Oops! Your email does not give you the authority to view claims for the selected project. Please contact the administrators.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div *ngIf="accessStatus=='valid'">
|
||||
<h1> Pending Claims for project:
|
||||
<a [queryParams]="routerHelper.createQueryParam('projectId',project['openaireId'])"
|
||||
routerLinkActive="router-link-active"
|
||||
routerLink="/search/project" >
|
||||
{{project['name']}} ({{project['funderName']}})
|
||||
</a>
|
||||
</h1>
|
||||
|
||||
<div *ngIf=" pending_claims && pending_claims.length == 0" >
|
||||
<div class = "uk-alert uk-alert-info " >No pending claims found.</div>
|
||||
</div>
|
||||
|
||||
<div class="uk-overflow-container">
|
||||
<table *ngIf="pending_claims && pending_claims.length > 0" class="uk-table uk-table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Research Result</th>
|
||||
<!--th>Link to</th-->
|
||||
<th class="uk-text-center">Claimed by</th>
|
||||
<th class="uk-text-center">Claimed Date</th>
|
||||
<th class="uk-text-center">Approve</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr class="uk-table-middle" *ngFor="let claim of pending_claims ">
|
||||
<td class="uk-width-2-6" *ngIf="claim.targetType != 'project'"><claim-entity [entity]="claim.target" [type]="claim.targetType" > </claim-entity></td>
|
||||
<td class="uk-width-1-6 uk-text-center" *ngIf="claim.sourceType != 'project'"><claim-entity [entity]="claim.source" [type]="claim.sourceType" > </claim-entity></td>
|
||||
<td class="uk-width-1-6 uk-text-center">{{claim.userMail}}</td>
|
||||
<td class="uk-width-1-6 uk-text-center">{{claim.date}}</td>
|
||||
<!--td>
|
||||
<label>
|
||||
Yes <input [id]="claim.id" type="checkbox" (click)="selectApprove(claim.id,$event)" [ngModel]="isSelectedRight(claim.id)"/>
|
||||
</label>
|
||||
<label>
|
||||
No <input [id]="claim.id" type="checkbox" (click)="selectDisapprove(claim.id,$event)" [ngModel]="isSelectedWrong(claim.id)"/>
|
||||
</label>
|
||||
</td-->
|
||||
<td class="uk-width-1-6 uk-text-center">
|
||||
|
||||
<label>
|
||||
Yes <input [id]="claim.id" type="checkbox" (click)="selectApprove(claim.id,$event)" [ngModel]="isSelectedRight(claim.id)"/>
|
||||
</label>
|
||||
<label>
|
||||
No <input [id]="claim.id" type="checkbox" (click)="selectDisapprove(claim.id,$event)" [ngModel]="isSelectedWrong(claim.id)"/>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<h1> Already Curated Claims </h1>
|
||||
|
||||
<div *ngIf=" curated_claims && curated_claims.length == 0" >
|
||||
<div class = "uk-alert uk-alert-info " >No curated claims found.</div>
|
||||
</div>
|
||||
|
||||
<div class="uk-overflow-container">
|
||||
<table *ngIf="curated_claims && curated_claims.length > 0" class="uk-table uk-table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Research Result</th>
|
||||
<!--th>Link to</th-->
|
||||
<th class="uk-text-center">Claimed by</th>
|
||||
<th class="uk-text-center">Claimed Date</th>
|
||||
<th class="uk-text-center">Curated by</th>
|
||||
<th class="uk-text-center">Curation Date</th>
|
||||
<th class="uk-text-center">Approved</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr class="uk-table-middle" *ngFor="let claim of curated_claims let i=index">
|
||||
<td class="uk-width-1-6" *ngIf="claim.targetType != 'project'"><claim-entity [entity]="claim.target" [type]="claim.targetType" > </claim-entity></td>
|
||||
<td class="uk-width-1-6" *ngIf="claim.sourceType != 'project'"><claim-entity [entity]="claim.source" [type]="claim.sourceType" > </claim-entity></td>
|
||||
<td class="uk-width-1-6 uk-text-center">{{claim.userMail}}</td>
|
||||
<td class="uk-width-1-6 uk-text-center">{{claim.date}}</td>
|
||||
<td class="uk-width-1-6 uk-text-center">{{claim.curatedBy}}</td>
|
||||
<td class="uk-width-1-6 uk-text-center">{{claim.curationDate}}</td>
|
||||
<td class="uk-width-1-6 uk-text-center">
|
||||
|
||||
<label>
|
||||
Yes <input [id]="claim.id" type="checkbox" [disabled]="!editable.has(i)" [ngModel]="isRight(claim)"/>
|
||||
</label>
|
||||
|
||||
<label>
|
||||
No <input [id]="claim.id" type="checkbox" [disabled]="!editable.has(i)" [ngModel]="isWrong(claim)"/>
|
||||
</label>
|
||||
|
||||
</td>
|
||||
<!--td><input [id]="claim.id" type="checkbox" [disabled]="!editable.has(i)" (click)="selectDisapprove(claim.id,$event)" [ngModel]="isWrong(claim)"/></td-->
|
||||
<!--td><button class="uk-button" (click)="editable.add(i)">Edit</button></td-->
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
<div class="uk-text-small uk-text-right">*Note that claims you did not approved or disapproved are considered as right (but not curated)</div>
|
||||
<button class="uk-button uk-button-success uk-float-right" type="button" (click)="saveChanges()">Save Changes</button>
|
||||
|
||||
<!--modal-select (alertOutput)="curatorSelected($event)"></modal-select-->
|
||||
<modal-loading [message]= "'Loading...'"></modal-loading>
|
||||
</div>
|
||||
`,
|
||||
|
||||
})
|
||||
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<string>;
|
||||
public selectedWrong: Set<string>;
|
||||
public editable: Set<string>;
|
||||
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<string>();
|
||||
this.selectedWrong = new Set<string>();
|
||||
this.editable = new Set<string>();
|
||||
//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;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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 { }
|
|
@ -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 => <any> res.text())
|
||||
.map(request => <any> 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<string>, selectedWrong: Set<string>) {
|
||||
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');
|
||||
}
|
||||
}
|
|
@ -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 { }
|
|
@ -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: `
|
||||
<div class="container uk-margin-top">
|
||||
<div class="page-header">
|
||||
<h1>Linking</h1>
|
||||
</div>
|
||||
<div *ngIf="validInput != null && !validInput" class="uk-alert uk-alert-warning" role="alert">No valid arguments provided in order to start linking openAIRE entities. </div>
|
||||
<div *ngIf="validInput != null && validInput">
|
||||
<div class="uk-text-large">
|
||||
Link {{(type=="project")?'Project':' Research result'}}:
|
||||
</div>
|
||||
<div class="uk-clearfix">
|
||||
<start-over [results]="results" [contexts]="contexts" [projects]="projects" [linkTo]="linkTo" [type]="type" ></start-over>
|
||||
</div>
|
||||
<!-- inline result -->
|
||||
<div *ngIf="displayedResult != null && (type =='publication' || type =='dataset' )" class="uk-panel uk-panel-box uk-panel-box-default">
|
||||
<div class="uk-width-1-1" >
|
||||
<div>
|
||||
<a *ngIf="displayedResult.url" target="_blank" href="{{displayedResult.url}}" ><span class="uk-icon-external-link" ></span> {{displayedResult.title}}</a>
|
||||
<span *ngIf="!displayedResult.url" >{{displayedResult.title}}</span>
|
||||
</div>
|
||||
<div *ngIf="displayedResult.result.authors && displayedResult.result.authors.length >0 " class="uk-article-meta">Authors: <span *ngFor="let author of displayedResult.result.authors.slice(0,10) let i = index">{{author.name}}{{(i < (displayedResult.result.authors.slice(0,10).length-1))?"; ":""}}{{(i == displayedResult.result.authors.slice(0,10).length-1 && displayedResult.result.authors.length > 10)?"...":""}}</span></div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<!-- inline project -->
|
||||
<div *ngIf=" type == 'project' && projects.length > 0 " class="uk-panel uk-panel-box uk-panel-box-default">
|
||||
{{projects[0].funderName}} | {{projects[0].projectName}} {{(projects[0].projectAcronym)?'('+projects[0].projectAcronym+')':''}}
|
||||
|
||||
</div>
|
||||
<!-- search for entity -->
|
||||
|
||||
<div class = "uk-margin-top">
|
||||
|
||||
<div *ngIf=" linkTo =='context' " >
|
||||
<claim-selected-contexts title="with Communities" [contexts]="contexts" [projects]="projects" [results]="results" [inlineEntity] = "inlineResult" [show]="show" [linkType]=linkType
|
||||
(showChange)="showChange($event)" > </claim-selected-contexts>
|
||||
</div>
|
||||
<div *ngIf=" linkTo =='project' " >
|
||||
<claim-selected-projects title="with Projects" [projects]="projects" [show]="show" [linkType]=linkType
|
||||
(showChange)="showChange($event)" > </claim-selected-projects>
|
||||
</div>
|
||||
<claim-selected-results *ngIf=" linkTo =='result' " title="with other Research Results" [results]="results" [showSearch]="show=='claim'? false: true" [showAccessRights]="show=='claim'? true: false"
|
||||
[bulkMode]=false>
|
||||
</claim-selected-results>
|
||||
|
||||
</div>
|
||||
<div *ngIf=" show == 'claim' " class="uk-width-small-1-1 uk-width-medium-1-1 uk-width-large-1-1 uk-grid">
|
||||
<div class="uk-width-1-1 ">
|
||||
<claim-insert [contexts]="contexts" [results]="results" [projects]="projects" [inlineEntity] = "inlineResult" [show] = "show"
|
||||
(showChange)="showChange($event)" ></claim-insert>
|
||||
</div>
|
||||
</div>
|
||||
<ul *ngIf="linkTo == 'result'" class="uk-pagination">
|
||||
<li class="uk-pagination-previous" *ngIf="show == 'claim'" (click)="show='result';"><a><i class="uk-icon-angle-left"></i> Previous</a></li>
|
||||
<li class="uk-pagination-next" *ngIf="show != 'claim'"(click)="show='claim';"><a>Next <i class="uk-icon-angle-right"></i></a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
`
|
||||
|
||||
})
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -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 { }
|
|
@ -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: `
|
||||
<div class="uk-animation uk-margin-top">
|
||||
<form class="uk-form uk-panel uk-panel-box uk-panel-box-default ">
|
||||
<div for="exampleInputFile">Upload a DOI csv file:</div>
|
||||
<label for="exampleInputFile">Select a file</label>
|
||||
<input id="exampleInputFile" type="file" (change)="fileChangeEvent($event)" placeholder="Upload file..." />
|
||||
<button class="uk-button uk-button-success" [class.disabled]="!enableUpload" type="button" (click)="upload()">Upload</button>
|
||||
<button class="uk-button uk-button-primary" data-uk-toggle="{target:'#uploadInfo', animation:'uk-animation-fade, uk-animation-fade'}"><i class="uk-icon-info-circle"></i> </button>
|
||||
<div *ngIf="showReport" class="uk-alert uk-alert-info" role="alert" >
|
||||
<div>Uploaded file contains {{allIds.length}} rows. {{foundIds.length}} results were sucefully fetched from CrossRef.</div>
|
||||
<div *ngIf ="duplicateIds.length > 0" >{{duplicateIds.length}} duplicate DOIs.</div>
|
||||
<div *ngIf = "notFoundIds.length > 0" >Couldn't be fetched from crossref:
|
||||
<ul class="">
|
||||
<li *ngFor="let id of notFoundIds">"{{id}}"</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div *ngIf = "noValidIds.length > 0" >No valid DOIs:
|
||||
<ul class="">
|
||||
<li *ngFor="let id of noValidIds">"{{id}}"</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div *ngIf = "allIds.length == 0 || foundIds.length == 0" > Please make sure you are using the right format for the csv file... </div>
|
||||
|
||||
</div>
|
||||
<div *ngIf="errorMessage.length > 0 " class="uk-alert uk-alert-danger" role="alert">{{errorMessage}}</div>
|
||||
<modal-loading [message]= "'Uploading, reading and fetching results from your document. Please give us a moment..'"></modal-loading>
|
||||
</form>
|
||||
|
||||
|
||||
<div id="uploadInfo" class="uk-hidden uk-panel uk-panel-box uk-margin-top uk-margin-bottom">
|
||||
<div class="uk-panel-badge uk-badge"><i class="uk-icon-info-circle"></i></div>
|
||||
<div class="uk-text-bold">Upload information:</div>
|
||||
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.
|
||||
|
||||
<div class="uk-article-meta">
|
||||
CSV format:
|
||||
<ul class="uk-list">
|
||||
<li>The format of CSV file should be "DOI","ACCESS_MODE","DATE".</li>
|
||||
<li>The value "DOI" is required </li>
|
||||
<li>Access mode column should have values: "OPEN","CLOSED" or "EMBARGO".</li>
|
||||
<li>Date column valid format is YYYY-MM-DD and is required when access mode has value EMBARGO.</li>
|
||||
<li>In case access mode is not available default value is "OPEN".</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
`
|
||||
|
||||
})
|
||||
//[(ngModel)]="date"
|
||||
export class BulkClaimComponent {
|
||||
filesToUpload: Array<File>;
|
||||
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<rows.length;i++){
|
||||
if(rows[i] && rows[i] != null ){
|
||||
var values = rows[i].split(',');
|
||||
|
||||
var id=this.removeDoubleQuotes(values[0]);
|
||||
if(DOI.isValidDOI(id)){
|
||||
var accessMode = (values[1] != undefined) ? this.removeDoubleQuotes(values[1]):"OPEN";
|
||||
accessMode = (this.validateAccessMode(accessMode)?accessMode:"OPEN");
|
||||
var embargoDate =(values[2] != undefined) ? this.removeDoubleQuotes(values[2]):Dates.getDateToday();
|
||||
embargoDate = (Dates.isValidDate(embargoDate)?embargoDate:Dates.getDateToday());
|
||||
if(this.allIds.indexOf(id)>-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 = <Array<File>> fileInput.target.files;
|
||||
}
|
||||
|
||||
makeFileRequest(url: string, params: Array<string>, files: Array<File>) {
|
||||
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();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -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 { }
|
|
@ -0,0 +1,16 @@
|
|||
// import {Component, Input} from '@angular/core';
|
||||
// import {Observable} from 'rxjs/Observable';
|
||||
//
|
||||
// @Component({
|
||||
// selector: 'bulk-linking',
|
||||
// //providers: [MdRadioDispatcher],
|
||||
// template: `
|
||||
// <linking-generic [bulkMode]=true> </linking-generic>
|
||||
// `
|
||||
//
|
||||
// })
|
||||
// //[(ngModel)]="date"
|
||||
// export class BulkLinkingComponent {
|
||||
// constructor () {
|
||||
// }
|
||||
// }
|
|
@ -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 { }
|
|
@ -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: `
|
||||
<div *ngIf="errorMessage.length > 0">
|
||||
<div class="uk-alert uk-alert-danger" role="alert" [innerHTML]="errorMessage"></div>
|
||||
</div>
|
||||
<div *ngIf="warningMessage.length > 0">
|
||||
<div class="uk-alert uk-alert-warning" role="alert">{{warningMessage}}</div>
|
||||
</div>
|
||||
|
||||
|
||||
<modal-loading [message]= "'Please wait...'"></modal-loading>
|
||||
<modal-alert (alertOutput)="confirmClose($event)">
|
||||
</modal-alert>
|
||||
<button *ngIf="!claiming && showButton" (click)="validateInsertions()" class="uk-button uk-button-primary uk-align-right" >Finish</button>
|
||||
`
|
||||
})
|
||||
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+="<div>The following records couldn't automatically inserted to the Openaire Info space: <ul>";
|
||||
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+="<li>"+this.results[i].title+" from "+this.results[i].source+"</li>";
|
||||
}
|
||||
}
|
||||
}
|
||||
text+="</ul></div>";
|
||||
|
||||
}
|
||||
if(this.errorInClaims.length > 0){
|
||||
text+="<div>The following links couldn't be saved: <ul>";
|
||||
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+="<li>"+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+") </li>";
|
||||
|
||||
}
|
||||
text+="</ul></div>";
|
||||
}
|
||||
this.errorMessage+="<div>An error occured:</div>"+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();
|
||||
}
|
||||
}
|
|
@ -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 { }
|
|
@ -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 { }
|
|
@ -0,0 +1,16 @@
|
|||
// import {Component, Input} from '@angular/core';
|
||||
// import {Observable} from 'rxjs/Observable';
|
||||
// import {LinkingGenericComponent} from './linkingGeneric.component';
|
||||
//
|
||||
// @Component({
|
||||
// selector: 'linking',
|
||||
// template: `
|
||||
// <linking-generic [bulkMode]=false> </linking-generic>
|
||||
// `
|
||||
//
|
||||
// })
|
||||
// export class LinkingComponent {
|
||||
// constructor () {
|
||||
// }
|
||||
//
|
||||
// }
|
|
@ -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 { }
|
|
@ -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: `
|
||||
<div class="container uk-margin-top">
|
||||
<div class="page-header">
|
||||
<h1>Linking</h1>
|
||||
</div>
|
||||
<start-over [results]="results" [contexts]="contexts" [projects]="projects" ></start-over>
|
||||
<ul class="uk-pagination">
|
||||
<li class="uk-pagination-previous" *ngIf="show != 'result' " (click)="prev()"><a><i class="uk-icon-angle-left"></i> Previous</a></li>
|
||||
<li class="uk-pagination-next" *ngIf="show != 'claim' " (click)="next()"><a>Next <i class="uk-icon-angle-right"></i></a></li>
|
||||
<li class="uk-pagination-next" *ngIf="show == 'claim' " (click)="next()">
|
||||
<claim-insert [contexts]="contexts" [results]="results" [projects]="projects" [show] = "show"
|
||||
(showChange)="showChange($event)" ></claim-insert>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
<!-- link with Projects & Contexts -->
|
||||
<div class="uk-width-small-1-1 uk-width-medium-1-1 uk-width-large-1-1 uk-grid">
|
||||
<div class="uk-width-small-1-1 uk-width-medium-1-2 uk-width-large-1-2 uk-width-xlarge-1-2 ">
|
||||
<claim-selected-contexts title="link Communities" [contexts]="contexts" [projects]="projects" [results]="results" [inlineEntity] = "inlineResult" [show]="show" [linkType]=linkType
|
||||
(showChange)="showChange($event)" > </claim-selected-contexts>
|
||||
</div>
|
||||
<div class="uk-width-small-1-1 uk-width-medium-1-2 uk-width-large-1-2 uk-width-xlarge-1-2 ">
|
||||
<claim-selected-projects title="link Projects" [projects]="projects" [show]="show" [linkType]=linkType
|
||||
(showChange)="showChange($event)" > </claim-selected-projects>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Research Results -->
|
||||
<div class="uk-width-small-1-1 uk-width-medium-1-1 uk-width-large-1-1">
|
||||
<claim-selected-results title= "with Research Results" [results]="results" [bulkMode]="bulkMode" [showSearch]="show=='claim'|| bulkMode? false: true" [showAccessRights]="show=='claim' || bulkMode? true: false">
|
||||
</claim-selected-results>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<ul class="uk-pagination">
|
||||
<li class="uk-pagination-previous" *ngIf="show != 'result' " (click)="prev()"><a><i class="uk-icon-angle-left"></i> Previous</a></li>
|
||||
<li class="uk-pagination-next" *ngIf="show != 'claim' " (click)="next()"><a>Next <i class="uk-icon-angle-right"></i></a></li>
|
||||
<li class="uk-pagination-next" *ngIf="show == 'claim' " (click)="next()">
|
||||
<claim-insert [contexts]="contexts" [results]="results" [projects]="projects" [show] = "show"
|
||||
(showChange)="showChange($event)" ></claim-insert>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
||||
`
|
||||
|
||||
})
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -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 { }
|
|
@ -0,0 +1,57 @@
|
|||
// import {Component, Output, EventEmitter, Input} from '@angular/core';
|
||||
// import {Observable} from 'rxjs/Observable';
|
||||
//
|
||||
// @Component({
|
||||
// selector: 'linking-home',
|
||||
// template: `
|
||||
//
|
||||
//
|
||||
// <div class="uk-grid">
|
||||
// <div class="uk-width-1-2"> <div class="uk-panel uk-panel-box uk-text-center uk-margin-top ">
|
||||
// <a (click)="select('project')"><span class="uk-text-large">Link with project</span></a>
|
||||
// <p class="card-text">Link your research result with funded projects.</p>
|
||||
// </div></div>
|
||||
//
|
||||
// <div class="uk-width-1-2"> <div class="uk-panel uk-panel-box uk-text-center uk-margin-top ">
|
||||
// <a (click)="select('context')" ><span class="uk-text-large">Link with Community</span> </a>
|
||||
// <p class="card-text">Link your research result with research communities.</p>
|
||||
// </div> </div>
|
||||
// <!--div class="uk-width-1-2"> <div class="uk-panel uk-panel-box uk-text-center uk-margin-top ">
|
||||
// <a (click)="select('software')" >
|
||||
// <h4 class="card-title">Link with Software</h4>
|
||||
// <p class="card-text">Link your research result with software.</p>
|
||||
// </a>
|
||||
// </div> </div-->
|
||||
// <div class="uk-width-1-2" *ngIf=" !bulkMode ">
|
||||
// <div class="uk-panel uk-panel-box uk-text-center uk-margin-top ">
|
||||
// <a href="/participate/bulk-claim" > <span class="uk-text-large"><i class="uk-icon-upload"> </i> Bulk mode linking</span></a>
|
||||
// <p class="card-text">Link Research Results to projects & communities, providing a CSV file with research results' DOIs</p>
|
||||
//
|
||||
// </div>
|
||||
// </div>
|
||||
// <div class="uk-width-1-2" *ngIf=" bulkMode ">
|
||||
// <div class="uk-panel uk-panel-box uk-text-center uk-margin-top ">
|
||||
// <a href="/participate/claim" > <span class="uk-text-large"><i class="uk-icon-search"></i>Linking</span></a>
|
||||
// <p class="card-text">Search for Research Results and link them to projects & communities</p>
|
||||
//
|
||||
// </div>
|
||||
// </div>
|
||||
//
|
||||
// </div>
|
||||
//
|
||||
// `
|
||||
//
|
||||
// })
|
||||
//
|
||||
// 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
|
||||
// });
|
||||
// }
|
||||
//
|
||||
// }
|
|
@ -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: `
|
||||
|
||||
<!-- Contexts -->
|
||||
|
||||
<div class="uk-accordion" data-uk-accordion="{showfirst:true}">
|
||||
<h3 class="uk-accordion-title"><i class="uk-icon-caret-square-o-right"></i> {{title}} ({{(contexts.length)}})</h3>
|
||||
<div class="uk-accordion-content" ><!--(contextSelected)="contextSelected($event)"-->
|
||||
<div class="uk-clearfix"><button *ngIf=" !showsearch " (click)="showsearch = true;" class="uk-button uk-animation uk-float-right">Add more <i class="uk-icon-plus"></i></button></div>
|
||||
<claim-contexts-search-form *ngIf=" showsearch " [selectedList]="contexts" [projects]="projects" [results]="results" [inlineEntity]="inlineEntity" > </claim-contexts-search-form>
|
||||
<ul class="uk-list uk-list-line">
|
||||
<li class="list-group-item" *ngFor="let context of contexts" >
|
||||
<span *ngIf="context.community != context.concept.label">{{context.community }} > {{context.category}} ></span><span> {{context.concept.label}} </span>
|
||||
<span (click)="removeContext(context)" aria-hidden="true" class="uk-button "><i class="uk-icon-remove"></i></span>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
<div *ngIf="contexts.length == 0 " class="uk-alert uk-alert-primary">There are no communities</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
`
|
||||
})
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
|
@ -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 { }
|
|
@ -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: `
|
||||
|
||||
<div class="uk-accordion" data-uk-accordion="{showfirst:true}">
|
||||
<h3 class="uk-accordion-title"><i class="uk-icon-caret-square-o-right"></i> {{title}} ({{(projects.length)}})
|
||||
|
||||
</h3>
|
||||
|
||||
<div class="uk-accordion-content">
|
||||
<div class="uk-clearfix"><button *ngIf=" !showsearch " (click)="showsearch = true;" class="uk-button uk-float-right uk-animation ">Add more <i class="uk-icon-plus"></i></button></div>
|
||||
<claim-projects-search-form *ngIf=" showsearch " [selectedProjects]="projects" (projectSelected)="projectSelected($event)" > </claim-projects-search-form>
|
||||
<ul class="uk-list uk-list-line">
|
||||
<li class="list-group-item" *ngFor="let project of projects">
|
||||
<a [queryParams]="routerHelper.createQueryParam('projectId',project.projectId)" routerLinkActive="router-link-active" routerLink="/search/project" >{{project.funderName}} | {{project.projectName}} {{(project.projectAcronym)?'('+project.projectAcronym+')':''}} <!--[{{project.startDate}} - {{project.endDate}}]--></a>
|
||||
<span (click)="removeProject(project)" aria-hidden="true" class="uk-button "><i class="uk-icon-remove"></i></span>
|
||||
</li>
|
||||
</ul>
|
||||
<div *ngIf="projects.length == 0 " class="uk-alert uk-alert-primary">There are no projects</div>
|
||||
</div>
|
||||
</div>
|
||||
<!--div *ngIf="this.linkType != 'project'" class="uk-accordion" data-uk-accordion="{showfirst:false}">
|
||||
<h3 class="uk-accordion-title"><i class="uk-icon-caret-square-o-right"></i> {{title}} ({{(projects.length)}})
|
||||
|
||||
</h3>
|
||||
|
||||
<div class="uk-accordion-content">
|
||||
<button *ngIf=" !showsearch " (click)="showsearch = true;" class="uk-button ">Add more <i class="uk-icon-plus"></i></button>
|
||||
<claim-projects-search-form *ngIf=" showsearch " [selectedProjects]="projects" (projectSelected)="projectSelected($event)" > </claim-projects-search-form>
|
||||
<ul class="uk-list uk-list-line">
|
||||
<li class="list-group-item" *ngFor="let project of projects">
|
||||
<a [queryParams]="routerHelper.createQueryParam('projectId',project.projectId)" routerLinkActive="router-link-active" routerLink="/search/project" >{{project.funderName}} | {{project.projectName}} {{(project.projectAcronym)?'('+project.projectAcronym+')':''}} </a>
|
||||
<span (click)="removeProject(project)" aria-hidden="true" class="uk-button "><i class="uk-icon-remove"></i></span>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
</div-->
|
||||
|
||||
`
|
||||
})
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -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 { }
|
|
@ -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: `
|
||||
|
||||
|
||||
<div class="uk-accordion " data-uk-accordion="{showfirst:true}" >
|
||||
<h3 class="uk-accordion-title" ><i class="uk-icon-caret-square-o-right"></i> {{title}} ({{results.length}}) </h3>
|
||||
<div class="uk-accordion-content uk-grid uk-width-1-1" >
|
||||
|
||||
<div *ngIf="showSearch " class="uk-width-1-2 ">
|
||||
<div class="uk-clearfix"><button (click)="bulkMode = !bulkMode;" class="uk-button uk-animation uk-float-right">
|
||||
<span *ngIf="!bulkMode">Bulk mode <i class="uk-icon-upload"></i></span>
|
||||
<span *ngIf="bulkMode">Search mode <i class="uk-icon-search"></i></span>
|
||||
</button></div><!-- (resultsChange)="resultsChanged($event)" -->
|
||||
<claim-result-search-form *ngIf="!bulkMode" [selectedResults]="results" > </claim-result-search-form>
|
||||
<bulk-claim *ngIf="bulkMode" [publications]="results" > </bulk-claim>
|
||||
</div>
|
||||
<div [ngClass]="showAccessRights && !showSearch?'uk-width-1-1':'uk-width-1-2'">
|
||||
<!--div class="uk-clearfix"><button *ngIf=" !showSearch " (click)="showSearch = true;" class="uk-button uk-float-right uk-animation ">Add more <i class="uk-icon-plus"></i></button></div-->
|
||||
<div *ngIf="results.length == 0 " class="uk-alert uk-alert-primary">There are no research results</div>
|
||||
|
||||
<ul *ngIf="results.length > 0 " class="uk-list uk-list-line">
|
||||
<li *ngFor="let pub of results" >
|
||||
<div class="uk-grid">
|
||||
<div [ngClass]="showAccessRights?'uk-width-7-10':'uk-width-1-1'" >
|
||||
<div>
|
||||
<span *ngIf="showAccessRights" (click)="removePublication(pub)" aria-hidden="true" class="uk-button"><i class="uk-icon-remove"></i></span>
|
||||
<a *ngIf="pub.url" target="_blank" href="{{pub.url}}" ><span class="uk-icon-external-link" ></span> {{pub.title}}</a>
|
||||
<span *ngIf="!pub.url" >{{pub.title}}</span>
|
||||
<span *ngIf="!showAccessRights" (click)="removePublication(pub)" aria-hidden="true" class="uk-button "><i class="uk-icon-remove"></i></span>
|
||||
</div>
|
||||
<!-- Crossref -->
|
||||
<span *ngIf="pub.result.publisher" class="uk-article-meta">Publisher: {{pub.result.publisher}}</span><span *ngIf="pub.date" class="uk-article-meta" >({{pub.date.substring(0,4)}})</span>
|
||||
<div *ngIf="pub.result.author && pub.result.author.length > 0" class="uk-article-meta">Authors: <span *ngFor="let author of pub.result.author.slice(0,10) let i = index">{{author.family}} {{author.given}}{{(i < (pub.result.author.slice(0,10).length-1))?"; ":""}}{{(i == pub.result.author.slice(0,10).length-1 && pub.result.author.length > 10)?"...":""}}</span></div>
|
||||
<div *ngIf="pub.result.editor && pub.result.editor.length > 0" class="uk-article-meta">Editors: <span *ngFor="let author of pub.result.editor.slice(0,10) let i = index">{{author.family}} {{author.given}}{{(i < (pub.result.editor.slice(0,10).length-1))?"; ":""}}{{(i == pub.result.editor.slice(0,10).length-1 && pub.result.editor.length > 10)?"...":""}}</span></div>
|
||||
|
||||
<!-- Openaire -->
|
||||
<div *ngIf="pub.result.authors && pub.result.authors.length >0 " class="uk-article-meta">Authors: <span *ngFor="let author of pub.result.authors.slice(0,10) let i = index">{{author.name}}{{(i < (pub.result.authors.slice(0,10).length-1))?"; ":""}}{{(i == pub.result.authors.slice(0,10).length-1 && pub.result.authors.length > 10)?"...":""}}</span></div>
|
||||
|
||||
<!-- Orcid -->
|
||||
<span *ngIf="pub.result['journal-title'] && pub.result['journal-title'].value " class="uk-article-meta">Journal: {{pub.result['journal-title'].value}}</span>
|
||||
<div *ngIf="pub.result.contributors && pub.result.contributors.length > 0" class="uk-article-meta">Authors: <span *ngFor="let author of pub.result.contributors.slice(0,10) let i = index">{{author}}{{(i < (pub.result.contributors.slice(0,10).length-1))?"; ":""}}{{(i == pub.result.contributors.slice(0,10).length-1 && pub.result.contributors.length > 10)?"...":""}}</span></div>
|
||||
<!-- Datacite -->
|
||||
<div *ngIf="pub.result.creator && pub.result.creator.length > 0" class="uk-article-meta">Authors: <span *ngFor="let author of pub.result.creator.slice(0,10) let i = index">{{author}}{{(i < (pub.result.creator.slice(0,10).length-1))?"; ":""}}{{(i == pub.result.creator.slice(0,10).length-1 && pub.result.creator.length > 10)?"...":""}}</span></div>
|
||||
</div>
|
||||
<div *ngIf="showAccessRights && pub.source != 'openaire' " class = "uk-width-3-10">
|
||||
<span *ngIf="showAccessRights && pub.source != 'openaire' " class="dropdown">
|
||||
<select [(ngModel)]="pub.accessRights" name="{{'select_rights_'+pub.id}}" >
|
||||
<option *ngFor="let type of accessTypes" [value]="type" (click)="accessRightsTypeChanged(type,pub)">{{type}}</option>
|
||||
</select>
|
||||
<!--input *ngIf="pub.accessRights== 'EMBARGO'" class="uk-form-width-small" id="{{'date'+pub.id}}" type="text" data-uk-datepicker="{format:'YYYY-MM-DD'}"-->
|
||||
<my-date-picker *ngIf="pub.accessRights== 'EMBARGO'" name="{{'date'+pub.id}}" [options]="myDatePickerOptions"
|
||||
[(ngModel)]="nextDate" (dateChanged)="onDateChanged($event,pub)" ></my-date-picker>
|
||||
|
||||
<select [(ngModel)]="pub.type" name="{{'select_type_'+pub.id}}" >
|
||||
<option [value]="'publication'" >Publication</option>
|
||||
<option [value]="'dataset'" >Dataset</option>
|
||||
</select>
|
||||
</span>
|
||||
|
||||
</div>
|
||||
<div *ngIf="showAccessRights && pub.source == 'openaire' " class = "uk-width-3-10">
|
||||
<span >
|
||||
<button class="uk-button disabled " type="button" >
|
||||
{{pub.accessRights}}
|
||||
</button>
|
||||
<button class="uk-button disabled " type="button" >
|
||||
{{pub.type}}
|
||||
</button>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
<modal-alert (alertOutput)="confirmClose($event)">
|
||||
</modal-alert>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
`
|
||||
|
||||
})
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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 { }
|
|
@ -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 { }
|
|
@ -0,0 +1,29 @@
|
|||
import {Component, Input} from '@angular/core';
|
||||
import {Observable} from 'rxjs/Observable';
|
||||
|
||||
|
||||
|
||||
@Component({
|
||||
selector: 'my-claims',
|
||||
template: `
|
||||
<div class="container uk-margin-top">
|
||||
<div class="page-header">
|
||||
<h1> My Linked research resutls</h1>
|
||||
</div>
|
||||
<div>
|
||||
<div class="uk-text-right"><a routerLink="/participate/claim">Add more Links?</a></div>
|
||||
<displayClaims [enableDelete]=true [myClaims]=true [isAdmin]=false ></displayClaims>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
`
|
||||
|
||||
})
|
||||
export class MyClaimsComponent {
|
||||
constructor () {
|
||||
}
|
||||
ngOnInit() {
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -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 { }
|
|
@ -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: `
|
||||
// <div *ngIf="user" class="container">
|
||||
// <div class="page-header">
|
||||
// <h1> My Claims Demo</h1>
|
||||
// </div>
|
||||
// <div>
|
||||
// <div class=""><a routerLink="/Linking">Linking</a></div>
|
||||
// <div class=""><a routerLink]="/MyClaims">MyClaims</a></div>
|
||||
// <div class=""><a routerLink="/Claims">Claims Admin</a></div>
|
||||
// <p> Extra parameters for claims admin</p>
|
||||
// <div class=""><a href="claims?fetchBy=User&fetchId=amelie.baecker@uni-bielefeld.de">Claims By user</a></div>
|
||||
// <div class=""><a href="claims?fetchBy=Project&fetchId=corda_______::2c37878a0cede85dbbd1081bb9b4a2f8">Claims By project</a></div>
|
||||
// <div class=""><a href="claims?fetchBy=Context&fetchId=egi::country::gr">Claims By context</a></div>
|
||||
//
|
||||
// <!-- <p>Orcid
|
||||
// <p>N.M.
|
||||
// 0000-0002-3477-3082
|
||||
// </p>
|
||||
// </p> -->
|
||||
// <div class=""><a href="publication?articleId=od_______908::3a5b2885656a91307156325644e73b92" >Publication od_______908::3a5b2885656a91307156325644e73b92</a></div>
|
||||
// <!--<div class=""><a href="publication?articleId=od_______908::3a5b2885656a91307156325644e73b92" >Publication od_______908::3a5b2885656a91307156325644e73b92</a></div>
|
||||
// <div class=""><a href="publication?articleId=od_______908::3a5b2885656a91307156325644e73b92" >Publication od_______908::3a5b2885656a91307156325644e73b92</a></div>-->
|
||||
// </div>
|
||||
// </div>
|
||||
//
|
||||
//
|
||||
//
|
||||
// `
|
||||
// //(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}] );
|
||||
// }
|
||||
// }
|
|
@ -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 { }
|
|
@ -0,0 +1,12 @@
|
|||
import {Component} from '@angular/core';
|
||||
|
||||
@Component({
|
||||
selector: 'deposit-datasets',
|
||||
template: `
|
||||
<deposit [compatibility]="'openaire____::21f8a223b9925c2f87c404096080b046||Registry of Research Data Repository'" [requestFor]="'Research Data'"></deposit>
|
||||
`
|
||||
})
|
||||
|
||||
export class DepositDatasetsComponent {
|
||||
|
||||
}
|
|
@ -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 { }
|
|
@ -0,0 +1,12 @@
|
|||
import {Component} from '@angular/core';
|
||||
|
||||
@Component({
|
||||
selector: 'deposit-datasets-result',
|
||||
template: `
|
||||
<deposit-result [compatibility]="'openaire____::21f8a223b9925c2f87c404096080b046||Registry of Research Data Repository'" [requestFor]="'Research Data'"></deposit-result>
|
||||
`
|
||||
})
|
||||
|
||||
export class DepositDatasetsResultComponent {
|
||||
|
||||
}
|
|
@ -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 { }
|
|
@ -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 { }
|
|
@ -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: `
|
||||
<div class="container uk-margin-top">
|
||||
<div class="page-header" >
|
||||
<h2>Deposit {{requestFor}}</h2>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<p>
|
||||
<i>
|
||||
Are you a grant recipient from the following: H2020; FP7 with SC39; or ERC?
|
||||
</i>
|
||||
Then you are required to publish in
|
||||
<a href="{{openAccess}}" target="_blank">open access (<i class="uk-icon-external-link"></i>)</a>.
|
||||
One way to do this is to deposit your {{requestFor}} into an
|
||||
<a href="{{openAccessRepo}}" target="_blank">open access repository (<i class="uk-icon-external-link"></i>)</a>.
|
||||
</p>
|
||||
<p>
|
||||
Click the following to find more information:
|
||||
<a href="{{fp7Guidlines}}" target="_blank">FP7 guidelines (<i class="uk-icon-external-link"></i>)</a>,
|
||||
<a href="{{h2020Guidlines}}" target="_blank">H2020 guidelines (<i class="uk-icon-external-link"></i>)</a>,
|
||||
<a href="{{ercGuidlines}}" target="_blank">ERC guidelines (<i class="uk-icon-external-link"></i>)</a> OR
|
||||
<a href="{{helpdesk}}" target="_blank">ask a question (<i class="uk-icon-external-link"></i>)</a> to OpenAIRE’s national representative.
|
||||
</p>
|
||||
|
||||
<h3>Locate data provider via your institution</h3>
|
||||
|
||||
<form class= "uk-form uk-form-row">
|
||||
<entities-autocomplete fieldId="organization" (click)="warningMessage = ''" [entityType]="'organization'" [depositType]=compatibility [selectedValue]=selectedId [showSelected]=true
|
||||
[placeHolderMessage] = "'Search for Organizations'" [title] = "'Organizations'" [multipleSelections]=false
|
||||
(selectedValueChanged)="valueChanged($event)">
|
||||
</entities-autocomplete>
|
||||
<button class="uk-button" type="submit" (click)="organizationSelected(selectedId)" >
|
||||
Locate
|
||||
</button>
|
||||
<div *ngIf="warningMessage.length > 0" class="uk-alert uk-alert-warning uk-animation-fade" role="alert">{{warningMessage}}</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
`
|
||||
})
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
|
@ -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 { }
|
|
@ -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: `
|
||||
<div class="container uk-margin-top">
|
||||
<div class="page-header" >
|
||||
<h2>Deposit {{requestFor}}</h2>
|
||||
</div>
|
||||
|
||||
|
||||
<div *ngIf="status == errorCodes.LOADING || (status == errorCodes.LOADING && fetchDataproviders.searchUtils.status == errorCodes.LOADING)"
|
||||
class="uk-alert uk-alert-primary" role="alert">
|
||||
Loading...
|
||||
</div>
|
||||
|
||||
|
||||
<div *ngIf="fetchDataproviders.searchUtils.totalResults > 0">
|
||||
<h2 *ngIf="organization != undefined">
|
||||
<span>Data providers for institution: </span>
|
||||
<a *ngIf="organization['url']!=''" href="{{organization.url}}" target="_blank">
|
||||
<span>{{organization['name']}} (<i class="uk-icon-external-link"></i>)</span>
|
||||
</a>
|
||||
<span *ngIf="organization['url']==''">{{organization['name']}}</span>
|
||||
</h2>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div *ngIf="fetchDataproviders.searchUtils.totalResults > 0">
|
||||
<p>Please use the information/contacts shown below to deposit your {{requestFor}}.</p>
|
||||
<!--showDataProviders [dataProviders]=dataProviders></showDataProviders-->
|
||||
<div class = "uk-text-right" *ngIf = "fetchDataproviders.searchUtils.totalResults > 10">
|
||||
<!--a [href] = "linkToSearchDataproviders">
|
||||
View all {{fetchDataproviders.searchUtils.totalResults}} results <i class="uk-icon-angle-double-right"></i>
|
||||
</a-->
|
||||
|
||||
<a [queryParams]="routerHelper.createQueryParams(['organizationId', 'or'], [organizationId, 'and'])"
|
||||
routerLinkActive="router-link-active" [routerLink]="linkToSearchDataproviders">
|
||||
View all {{fetchDataproviders.searchUtils.totalResults}} results <i class="uk-icon-angle-double-right"></i>
|
||||
</a>
|
||||
</div>
|
||||
<search-result [(results)]="fetchDataproviders.results"
|
||||
[(status)]= "fetchDataproviders.searchUtils.status"
|
||||
type="dataprovider" urlParam="datasourceId">
|
||||
</search-result>
|
||||
</div>
|
||||
|
||||
|
||||
<div *ngIf="(fetchDataproviders.searchUtils.totalResults == 0 && status == errorCodes.DONE)
|
||||
|| status == errorCodes.NONE || status == errorCodes.ERROR" class = "alert alert-warning">
|
||||
<div *ngIf="organization != undefined">
|
||||
<span *ngIf="fetchDataproviders.searchUtils.status == errorCodes.ERROR">
|
||||
An error occured.
|
||||
</span>
|
||||
No data providers found for institution:
|
||||
<a *ngIf="organization['url']!=''" target="_blank" href="{{organization.url}}">
|
||||
<span>{{organization['name']}}</span>
|
||||
</a>
|
||||
<span *ngIf="organization['url']==''">{{organization['name']}}</span>
|
||||
.
|
||||
</div>
|
||||
<div *ngIf="status == errorCodes.NONE && organizationId != ''">
|
||||
No organization with ID: {{organizationId}} found.
|
||||
</div>
|
||||
<div *ngIf="status == errorCodes.ERROR && organizationId != ''">
|
||||
An error occured.
|
||||
</div>
|
||||
<div *ngIf="organizationId == ''">
|
||||
No ID for organization.
|
||||
</div>
|
||||
|
||||
You can still deposit your {{requestFor}} in
|
||||
<a href="{{zenodo}}" target="_blank">OpenAIRE's Zenodo catch-all repository (<i class="uk-icon-external-link"></i>)</a>
|
||||
hosted by CERN.
|
||||
</div>
|
||||
|
||||
<button class="uk-button" type="submit" (click)="goToDeposit()">
|
||||
<i class="uk-icon-arrow-circle-left"></i> Back
|
||||
</button>
|
||||
</div>
|
||||
`
|
||||
})
|
||||
|
||||
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'] );
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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 { }
|
|
@ -0,0 +1,16 @@
|
|||
import {Component} from '@angular/core';
|
||||
|
||||
@Component({
|
||||
selector: 'deposit-publications',
|
||||
template: `
|
||||
<deposit [compatibility]="'openaire____::47ce9e9f4fad46e732cff06419ecaabb||OpenDOAR'" [requestFor]="'Publications'"></deposit>
|
||||
<h3>Or locate data provider in map</h3>
|
||||
<div class="uk-margin-top">
|
||||
<i-frame [url]="mapUrl"width="100%" height="900"></i-frame>
|
||||
</div>
|
||||
`
|
||||
})
|
||||
|
||||
export class DepositPublicationsComponent {
|
||||
public mapUrl ="https://beta.openaire.eu/stats/markers-demo.html";
|
||||
}
|
|
@ -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 { }
|
|
@ -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 { }
|
|
@ -0,0 +1,12 @@
|
|||
import {Component} from '@angular/core';
|
||||
|
||||
@Component({
|
||||
selector: 'deposit-publications-result',
|
||||
template: `
|
||||
<deposit-result [compatibility]="'openaire____::47ce9e9f4fad46e732cff06419ecaabb||OpenDOAR'" [requestFor]="'Publications'"></deposit-result>
|
||||
`
|
||||
})
|
||||
|
||||
export class DepositPublicationsResultComponent {
|
||||
|
||||
}
|
|
@ -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 { }
|
|
@ -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 { }
|
|
@ -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 { }
|
|
@ -0,0 +1,35 @@
|
|||
import { Component, Input } from '@angular/core';
|
||||
import { Location } from '@angular/common';
|
||||
|
||||
@Component({
|
||||
selector: 'error',
|
||||
template: `
|
||||
<div class="container">
|
||||
<h1>
|
||||
Bad karma: we can't find that page!
|
||||
</h1>
|
||||
<br>
|
||||
|
||||
<p>
|
||||
You asked for {{page}}, but despite our computers looking very hard, we could not find it. What happened ?
|
||||
</p>
|
||||
|
||||
<ul>
|
||||
<li>the link you clicked to arrive here has a typo in it</li>
|
||||
<li>or somehow we removed that page, or gave it another name</li>
|
||||
<li>or, quite unlikely for sure, maybe you typed it yourself and there was a little mistake ?</li>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
`
|
||||
})
|
||||
|
||||
export class ErrorPageComponent {
|
||||
public page: string;
|
||||
|
||||
constructor (private _location: Location) {
|
||||
this.page = _location.path(true);
|
||||
//this.page = _router.url;
|
||||
//this.page = location.href;
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
|
||||
//<addThis ></addThis>
|
||||
@Component({
|
||||
selector: 'addThis',
|
||||
template: `
|
||||
<div class="addthis_inline_share_toolbox"></div>
|
||||
`
|
||||
})
|
||||
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) {
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -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 { }
|
|
@ -0,0 +1,165 @@
|
|||
<div class="uk-container uk-margin-top datasource">
|
||||
<div *ngIf="warningMessage.length > 0" class="uk-alert uk-alert-warning" role="alert">{{warningMessage}}</div>
|
||||
<div *ngIf="errorMessage.length > 0" class="uk-alert uk-alert-danger" role="alert">{{errorMessage}}</div>
|
||||
|
||||
<div *ngIf="dataProviderInfo != null" class="uk-grid">
|
||||
|
||||
<div class="uk-width-7-10">
|
||||
<!--h3 *ngIf="dataProviderInfo.title != null">
|
||||
<a *ngIf="dataProviderInfo.title['url'] != undefined && dataProviderInfo.title['url'] != null"
|
||||
href="{{dataProviderInfo.title['url']}}" target="_blank" class="uk-icon-external-link">
|
||||
{{dataProviderInfo.title['name']}}
|
||||
</a>
|
||||
<p *ngIf="dataProviderInfo.title['url'] == undefined || dataProviderInfo.title['url'] == null">
|
||||
{{dataProviderInfo.title['name']}}
|
||||
</p>
|
||||
</h3-->
|
||||
<showTitle [title]="dataProviderInfo.title"></showTitle>
|
||||
|
||||
<dl class="uk-description-list-horizontal custom-description-list-horizontal">
|
||||
<dt *ngIf="dataProviderInfo.type != undefined && dataProviderInfo.type != ''">Type: </dt>
|
||||
<dd *ngIf="dataProviderInfo.type != undefined && dataProviderInfo.type != ''">{{dataProviderInfo.type}}</dd>
|
||||
<dt *ngIf="dataProviderInfo.compatibility != undefined && dataProviderInfo.compatibility != ''">Compatibility: </dt>
|
||||
<dd *ngIf="dataProviderInfo.compatibility != undefined && dataProviderInfo.compatibility != ''">{{dataProviderInfo.compatibility}}</dd>
|
||||
<dt *ngIf="dataProviderInfo.oaiPmhURL != undefined && dataProviderInfo.oaiPmhURL != ''">OAI-PMH: </dt>
|
||||
<dd *ngIf="dataProviderInfo.oaiPmhURL != undefined && dataProviderInfo.oaiPmhURL != ''">
|
||||
<span class="uk-icon-external-link custom-icon">
|
||||
<a href="{{dataProviderInfo.oaiPmhURL}}" target="_blank">
|
||||
{{dataProviderInfo.oaiPmhURL}}
|
||||
</a>
|
||||
</span>
|
||||
</dd>
|
||||
<dt *ngIf="dataProviderInfo.countries != undefined && dataProviderInfo.countries.length > 0">Countries: </dt>
|
||||
<dd *ngIf="dataProviderInfo.countries != undefined">{{dataProviderInfo.countries}}</dd>
|
||||
</dl>
|
||||
|
||||
<!--tabs [id] = "datasourceId"
|
||||
[name] = "dataProviderInfo.title['name']"
|
||||
[resultsBy] = "dataProviderInfo.resultsBy"
|
||||
[tabs]="dataProviderInfo.tabs"
|
||||
[statistics]="dataProviderInfo.statistics"
|
||||
[organizations]="dataProviderInfo.organizations"
|
||||
[_dataproviderService]="_dataproviderService">
|
||||
</tabs-->
|
||||
<div *ngIf="showTabs">
|
||||
<ul class="uk-tab" data-uk-switcher="{connect:'#tab-content'}">
|
||||
<li *ngFor="let tab of dataProviderInfo.tabs; let i=index" id="{{dataProviderInfo.tabs[i].content}}">
|
||||
<a
|
||||
(click)="search(tab.content, 1, 10)">
|
||||
{{tab.name}}
|
||||
<i *ngIf="tab.content == 'metricsTab'" class="uk-icon-line-chart"></i>
|
||||
<i *ngIf="tab.content == 'statisticsTab'" class="uk-icon-pie-chart"></i>
|
||||
|
||||
<span class="uk-badge uk-badge-notification" *ngIf="tab.content=='publicationsTab'">
|
||||
{{fetchPublications.searchUtils.totalResults}}
|
||||
</span>
|
||||
<span class="uk-badge uk-badge-notification" *ngIf="tab.content=='datasetsTab'">
|
||||
{{fetchDatasets.searchUtils.totalResults}}
|
||||
</span>
|
||||
<span class="uk-badge uk-badge-notification" *ngIf="tab.content=='projectsTab'">
|
||||
{{fetchProjects.searchUtils.totalResults}}
|
||||
</span>
|
||||
<span class="uk-badge uk-badge-notification" *ngIf="tab.content=='datasourcesTab'">
|
||||
{{fetchDataproviders.searchUtils.totalResults}}
|
||||
</span>
|
||||
<span class="uk-badge uk-badge-notification" *ngIf="tab.content=='organizationsTab'">
|
||||
{{dataProviderInfo.organizations.length}}
|
||||
</span>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<ul *ngIf="dataProviderInfo.tabs != undefined" id="tab-content" class="uk-switcher uk-margin custom-tab-content">
|
||||
|
||||
<li class="uk-animation-fade" *ngFor="let tab of dataProviderInfo.tabs; let i=index">
|
||||
<publicationsTab *ngIf=" tab.content=='publicationsTab'"
|
||||
[paramsForSearchLink]="paramsForSearchLink"
|
||||
[fetchPublications] = "fetchPublications">
|
||||
</publicationsTab>
|
||||
<datasetsTab *ngIf=" tab.content=='datasetsTab'"
|
||||
[paramsForSearchLink]="paramsForSearchLink"
|
||||
[fetchDatasets]="fetchDatasets">
|
||||
</datasetsTab>
|
||||
|
||||
<projectsTab *ngIf=" tab.content=='projectsTab'"
|
||||
[paramsForSearchLink]="paramsForSearchLink"
|
||||
[fetchProjects]="fetchProjects">
|
||||
</projectsTab>
|
||||
<datasourcesTab *ngIf=" tab.content=='datasourcesTab'"
|
||||
[paramsForSearchLink]="paramsForSearchLink"
|
||||
[fetchDataproviders]="fetchDataproviders">
|
||||
</datasourcesTab>
|
||||
<organizationsTab *ngIf=" tab.content=='organizationsTab'"
|
||||
[organizations]="dataProviderInfo.organizations">
|
||||
</organizationsTab>
|
||||
<relatedDatasourcesTab *ngIf=" tab.content=='relatedDatasourcesTab'"
|
||||
[dataproviderId]="id"
|
||||
[fetchResults]="fetchResultsAggregators"
|
||||
[type]="relatedDataprovidersResultsType">
|
||||
</relatedDatasourcesTab>
|
||||
|
||||
<div *ngIf=" tab.content=='statisticsTab' && statsClicked">
|
||||
<div *ngIf="fetchPublications.searchUtils.totalResults == 0 && fetchDatasets.searchUtils.totalResults == 0" class = "uk-alert">
|
||||
There are no statistics
|
||||
</div>
|
||||
<div *ngIf="(fetchPublications.searchUtils.totalResults != 0 || fetchDatasets.searchUtils.totalResults != 0)">
|
||||
<p class="uk-text-bold">Latest Documents Timeline</p>
|
||||
<i-frame [url]=docsTimelineUrl width="800" height="350"></i-frame>
|
||||
<p class="uk-text-bold">Documents Types</p>
|
||||
<i-frame [url]=docsTypesUrl width="800" height="350"></i-frame>
|
||||
</div>
|
||||
|
||||
|
||||
<div *ngIf="(fetchPublications.searchUtils.totalResults > 0)">
|
||||
<div>
|
||||
<p class="uk-text-bold">Funders in Data Providers Publications</p>
|
||||
<i-frame [url]=pubsFunderUrl width="800" height="350"></i-frame>
|
||||
<p class="uk-text-bold">Projects with most Publications</p>
|
||||
<i-frame [url]=pubsProjectsUrl width="800" height="350"></i-frame>
|
||||
|
||||
</div>
|
||||
<div *ngIf="(fetchDatasets.searchUtils.totalResults > 0)">
|
||||
<div>
|
||||
<p class="uk-text-bold">Projects with most Research Data</p>
|
||||
<i-frame [url]=dataProjectsUrl width="800" height="350"></i-frame>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<metrics *ngIf=" tab.content=='metricsTab'"
|
||||
[id]="datasourceId" [type]="'datasources'" [name]="dataProviderInfo.title['name']" (metricsResults)="metricsResults($event)">
|
||||
</metrics>
|
||||
<i-frame *ngIf=" tab.content=='metricsTab' && metricsClicked && totalViews > 0"
|
||||
[url]=viewsFrameUrl width="100%" height="250">
|
||||
</i-frame>
|
||||
<i-frame *ngIf=" tab.content=='metricsTab' && metricsClicked && totalDownloads > 0"
|
||||
[url]=downloadsFrameUrl width="100%" height="250">
|
||||
</i-frame>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="uk-width-3-10">
|
||||
<ul class="uk-list uk-list-striped">
|
||||
<li>
|
||||
<dl class="uk-description-list-line">
|
||||
<dt >Share - Bookmark
|
||||
</dt>
|
||||
<dd>
|
||||
<addThis ></addThis>
|
||||
</dd>
|
||||
</dl>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<dl class="uk-description-list-line">
|
||||
<dt>Page Views: {{pageViews}}</dt>
|
||||
</dl>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
|
@ -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.dataProviderInfo.tabs.length; i++) {
|
||||
let content: string = this.dataProviderInfo.tabs[i].content;
|
||||
if(content=='publicationsTab') {
|
||||
this.countPublications(page, size);
|
||||
} else if(content=='datasetsTab') {
|
||||
this.countDatasets(page, size);
|
||||
} else if(content=='projectsTab') {
|
||||
this.countProjects(page, size);
|
||||
} else if(content=='datasourcesTab') {
|
||||
this.countDatasources(page, size);
|
||||
}// else if(content=='relatedDatasourcesTab') {
|
||||
// this.countRelatedDatasources(page, size);
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
private search(content: string, page: number, size: number) {
|
||||
console.info(content);
|
||||
if(content=='publicationsTab') {
|
||||
this.searchPublications(page, size);
|
||||
} else if(content=='datasetsTab') {
|
||||
this.searchDatasets(page, size);
|
||||
} else if(content=='projectsTab') {
|
||||
this.searchProjects(page, size);
|
||||
} else if(content=='datasourcesTab') {
|
||||
this.searchDatasources(page, size);
|
||||
} else if(content=='relatedDatasourcesTab') {
|
||||
this.searchRelatedDatasources(1, 0);
|
||||
} else if(content=='metricsTab') {
|
||||
this.metricsClicked = true;
|
||||
} else if(content=='statisticsTab') {
|
||||
this.statsClicked = true;
|
||||
}
|
||||
}
|
||||
|
||||
private searchPublications(page: number, size: number) {
|
||||
console.info("Search publications???");
|
||||
if(this.reloadPublications) {
|
||||
console.info("Search publications!");
|
||||
|
||||
this.fetchPublications.getResultsForDataproviders(this.datasourceId, this.dataProviderInfo.resultsBy, page, size);
|
||||
}
|
||||
this.reloadPublications = false;
|
||||
}
|
||||
|
||||
private countPublications(page: number, size: number) {
|
||||
this.fetchPublications.getResultsForDataproviders(this.datasourceId, this.dataProviderInfo.resultsBy, page, size);
|
||||
}
|
||||
|
||||
private searchDatasets(page: number, size: number) {
|
||||
if(this.reloadDatasets) {
|
||||
this.fetchDatasets.getResultsForDataproviders(this.datasourceId, this.dataProviderInfo.resultsBy, page, size);
|
||||
}
|
||||
this.reloadDatasets = false;
|
||||
}
|
||||
|
||||
private countDatasets(page: number, size: number) {
|
||||
this.fetchDatasets.getResultsForDataproviders(this.datasourceId, this.dataProviderInfo.resultsBy, page, size);
|
||||
}
|
||||
|
||||
private searchProjects(page: number, size: number) {
|
||||
if(this.reloadProjects) {
|
||||
this.fetchProjects.getResultsForDataproviders(this.datasourceId, page, size);
|
||||
}
|
||||
this.reloadProjects = false;
|
||||
}
|
||||
|
||||
private countProjects(page: number, size: number) {
|
||||
this.fetchProjects.getResultsForDataproviders(this.datasourceId, page, size);
|
||||
}
|
||||
|
||||
private searchDatasources(page: number, size: number) {
|
||||
console.info("search intro");
|
||||
if(this.reloadDataproviders) {
|
||||
|
||||
this.fetchDataproviders.getResultsForDataproviders(this.datasourceId, page, size);
|
||||
|
||||
}
|
||||
this.reloadDataproviders = false;
|
||||
}
|
||||
|
||||
private countDatasources(page: number, size: number) {
|
||||
this.fetchDataproviders.getResultsForDataproviders(this.datasourceId, page, size);
|
||||
}
|
||||
|
||||
private searchRelatedDatasources(page: number, size: number) {
|
||||
if(this.reloadRelatedDatasources) {
|
||||
console.info("my id is: "+this.datasourceId);
|
||||
this.fetchResultsAggregators.getAggregatorResults(this.datasourceId, page, size);
|
||||
}
|
||||
this.reloadRelatedDatasources = false;
|
||||
}
|
||||
|
||||
private countRelatedDatasources(page: number, size: number) {
|
||||
this.fetchResultsAggregators.getAggregatorResults(this.datasourceId, page, size);
|
||||
}
|
||||
|
||||
public metricsResults($event) {
|
||||
this.totalViews = $event.totalViews;
|
||||
this.totalDownloads = $event.totalDownloads;
|
||||
this.pageViews = $event.pageViews;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
import { NgModule} from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
import { RouterModule } from '@angular/router';
|
||||
|
||||
import {IFrameModule} from '../../utils/iframe.module';
|
||||
// import { ResultLandingModule } from '../resultLanding.module';
|
||||
import {TabResultModule } from '../../searchPages/searchUtils/tabResult.module';
|
||||
import {MetricsModule} from '../metrics.module';
|
||||
import { LandingModule } from '../landing.module';
|
||||
|
||||
import {PublicationsTabComponent} from './publicationsTab.component';
|
||||
import {DatasetsTabComponent} from './datasetsTab.component';
|
||||
import {StatisticsTabComponent} from './statisticsTab.component';
|
||||
import {ProjectsTabComponent} from './projectsTab.component';
|
||||
import {DatasourcesTabComponent} from './datasourcesTab.component';
|
||||
import {OrganizationsTabComponent} from './organizationsTab.component';
|
||||
import {RelatedDatasourcesTabComponent} from './relatedDatasourcesTab.component';
|
||||
// import {TabsComponent} from './tabs.component';
|
||||
|
||||
import {DataProviderComponent} from './dataProvider.component';
|
||||
import { DataProviderService} from './dataProvider.service';
|
||||
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 { DataProviderRoutingModule } from './dataProvider-routing.module';
|
||||
import {FreeGuard} from'../../login/freeGuard.guard';
|
||||
|
||||
@NgModule({
|
||||
imports:
|
||||
[CommonModule, FormsModule, RouterModule,DataProviderRoutingModule,
|
||||
TabResultModule, IFrameModule, MetricsModule, LandingModule, DataProvidersServiceModule, DatasetsServiceModule, ProjectsServiceModule, PublicationsServiceModule],
|
||||
declarations:
|
||||
[PublicationsTabComponent, DatasetsTabComponent, StatisticsTabComponent, ProjectsTabComponent, DatasourcesTabComponent, OrganizationsTabComponent,
|
||||
RelatedDatasourcesTabComponent, DataProviderComponent
|
||||
],
|
||||
providers:[
|
||||
DataProviderService, FreeGuard
|
||||
],
|
||||
exports: [
|
||||
DataProviderComponent
|
||||
]
|
||||
|
||||
})
|
||||
export class DataProviderModule { }
|
|
@ -0,0 +1,165 @@
|
|||
import {Injectable} from '@angular/core';
|
||||
import {Http, Response} from '@angular/http';
|
||||
import {Observable} from 'rxjs/Observable';
|
||||
import {DataProviderInfo} from '../../utils/entities/dataProviderInfo';
|
||||
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 DataProviderService {
|
||||
|
||||
constructor(private http: Http, public _cache: CacheService) {}
|
||||
|
||||
dataProviderInfo: DataProviderInfo;
|
||||
|
||||
getDataproviderInfo (id: string):any {
|
||||
console.info("getDataProviderInfo in service");
|
||||
let url = OpenaireProperties.getSearchAPIURLLast() + 'datasources/' +id +"?format=json";
|
||||
let key = url;
|
||||
if (this._cache.has(key)) {
|
||||
return Observable.of(this._cache.get(key)).map(res => this.parseDataProviderInfo(res));
|
||||
}
|
||||
return this.http.get(url)
|
||||
.map(res => <any> 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<string>;
|
||||
let length = data[4].length!=undefined ? data[4].length : 1;
|
||||
|
||||
for(let i=0; i<length; i++) {
|
||||
mydata = data[4].length!=undefined ? data[4][i] : data[4];
|
||||
if(mydata.hasOwnProperty("to")) {
|
||||
if(mydata['to'].class == "provides" && mydata['to'].type == "organization") {
|
||||
//if(this.dataProviderInfo.organizations == undefined) {
|
||||
if(this.dataProviderInfo.organizations.length == 0) {
|
||||
//this.dataProviderInfo.organizations = new Array<{"name": string, "url": string}>();
|
||||
this.dataProviderInfo.countries = new Array<string>();
|
||||
countriesSet = new Set<string>();
|
||||
}
|
||||
|
||||
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() {
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -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: `
|
||||
<div *ngIf="fetchDatasets.searchUtils.totalResults == 0" class = "uk-alert">
|
||||
There are no datasets
|
||||
</div>
|
||||
|
||||
<div *ngIf="fetchDatasets.searchUtils.totalResults > 0">
|
||||
<div class = "uk-text-right" *ngIf = "fetchDatasets.searchUtils.totalResults > 10" >
|
||||
<a [queryParams]="paramsForSearchLink"
|
||||
routerLinkActive="router-link-active" [routerLink]="linkToSearchDatasets">
|
||||
View all {{fetchDatasets.searchUtils.totalResults}} results
|
||||
</a>
|
||||
</div>
|
||||
<tab-result [(results)]="fetchDatasets.results"
|
||||
[(status)]= "fetchDatasets.searchUtils.status"
|
||||
type="dataset" urlParam="datasetId">
|
||||
</tab-result>
|
||||
</div>
|
||||
`
|
||||
})
|
||||
|
||||
export class DatasetsTabComponent {
|
||||
@Input() paramsForSearchLink = {};
|
||||
@Input() fetchDatasets : FetchDatasets;
|
||||
public linkToSearchDatasets = "";
|
||||
|
||||
constructor () {}
|
||||
|
||||
ngOnInit() {
|
||||
this.linkToSearchDatasets = OpenaireProperties.getLinkToAdvancedSearchDatasets();
|
||||
}
|
||||
|
||||
ngOnDestroy() {}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue