First Draft
git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-portal/trunk@42781 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
parent
f52fa060b0
commit
dd3c7c046e
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"watch": [
|
||||
"dist",
|
||||
"src/index.html"
|
||||
],
|
||||
"ext" : "js ts json html"
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
{
|
||||
"name": "uoa-services-portal",
|
||||
"version": "1.0.0",
|
||||
"description": "Open Access Infrastructure for Research in Europe ",
|
||||
"scripts": {
|
||||
"postinstall": "typings install",
|
||||
"watch": "webpack --watch",
|
||||
"prebuild": "rimraf dist",
|
||||
"build": "webpack",
|
||||
"prestart": "npm run build",
|
||||
"server": "nodemon dist/server/bundle.js",
|
||||
"start": "npm run server",
|
||||
"predebug": "npm run build",
|
||||
"debug": "node --debug-brk dist/server/bundle.js"
|
||||
},
|
||||
"license": "UOA",
|
||||
"dependencies": {
|
||||
"@angular/common": "2.0.0-rc.1",
|
||||
"@angular/compiler": "2.0.0-rc.1",
|
||||
"@angular/core": "2.0.0-rc.1",
|
||||
"@angular/http": "2.0.0-rc.1",
|
||||
"@angular/platform-browser": "2.0.0-rc.1",
|
||||
"@angular/platform-browser-dynamic": "2.0.0-rc.1",
|
||||
"@angular/platform-server": "2.0.0-rc.1",
|
||||
"@angular/router-deprecated": "2.0.0-rc.1",
|
||||
"angular2-universal": "~0.101.8",
|
||||
"body-parser": "^1.15.1",
|
||||
"bootstrap": "^3.3.6",
|
||||
"express": "^4.13.4",
|
||||
"preboot": "^2.1.2",
|
||||
"rxjs": "5.0.0-beta.6"
|
||||
},
|
||||
"devDependencies": {
|
||||
"nodemon": "^1.9.2",
|
||||
"rimraf": "^2.5.2",
|
||||
"ts-loader": "^0.8.2",
|
||||
"typescript": "^1.8.9",
|
||||
"typings": "~0.8.1",
|
||||
"webpack": "^1.13.1",
|
||||
"webpack-dev-server": "^1.14.0",
|
||||
"webpack-merge": "^0.13.0"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,114 @@
|
|||
import {Component, Directive, ElementRef, Renderer} from '@angular/core';
|
||||
import {RouteConfig, ROUTER_DIRECTIVES, Router } from '@angular/router-deprecated';
|
||||
import {Http} from '@angular/http';
|
||||
import {SearchComponent} from './search/search.component';
|
||||
import {ClaimComponent} from './claim/claim.component';
|
||||
import {ClaimsComponent} from './claims/claims.component';
|
||||
import {HomeComponent} from './home/home.component';
|
||||
import {LinkingComponent} from './linking/linking.component';
|
||||
|
||||
import 'rxjs/Rx';
|
||||
|
||||
|
||||
|
||||
@Component({
|
||||
selector: 'app',
|
||||
directives: [
|
||||
...ROUTER_DIRECTIVES
|
||||
],
|
||||
styles: [`
|
||||
.router-link-active {
|
||||
background-color: lightgray;
|
||||
}
|
||||
`],
|
||||
template: `
|
||||
<div>
|
||||
<nav class="navbar navbar-default">
|
||||
<div class="container-fluid">
|
||||
<!-- Brand and toggle get grouped for better mobile display -->
|
||||
<div class="navbar-header">
|
||||
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
|
||||
<span class="sr-only">Toggle navigation</span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
</button>
|
||||
<a class="navbar-brand" href="#">OpenAire</a>
|
||||
</div>
|
||||
|
||||
<!-- Collect the nav links, forms, and other content for toggling -->
|
||||
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
|
||||
<ul class="nav navbar-nav">
|
||||
<li class="active"><a [routerLink]=" ['/Search']" >Search <span class="sr-only">(current)</span></a></li>
|
||||
<li><a [routerLink]=" ['/Claims']">Claims</a></li>
|
||||
<li><a [routerLink]=" ['/Linking']">Linking</a></li>
|
||||
<li><a [routerLink]=" ['/Home']">Home</a></li>
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Dropdown <span class="caret"></span></a>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a href="#">Action</a></li>
|
||||
<li><a href="#">Another action</a></li>
|
||||
<li><a href="#">Something else here</a></li>
|
||||
<li role="separator" class="divider"></li>
|
||||
<li><a href="#">Separated link</a></li>
|
||||
<li role="separator" class="divider"></li>
|
||||
<li><a href="#">One more separated link</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
<form class="navbar-form navbar-left" role="search">
|
||||
<div class="form-group">
|
||||
<input type="text" class="form-control" placeholder="Search">
|
||||
</div>
|
||||
<button type="submit" class="btn btn-default">Submit</button>
|
||||
</form>
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li><a href="#">Link</a></li>
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Dropdown <span class="caret"></span></a>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a href="#">Action</a></li>
|
||||
<li><a href="#">Another action</a></li>
|
||||
<li><a href="#">Something else here</a></li>
|
||||
<li role="separator" class="divider"></li>
|
||||
<li><a href="#">Separated link</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</div><!-- /.navbar-collapse -->
|
||||
</div><!-- /.container-fluid -->
|
||||
</nav>
|
||||
|
||||
<main>
|
||||
<router-outlet></router-outlet>
|
||||
</main>
|
||||
|
||||
|
||||
</div>
|
||||
`
|
||||
})
|
||||
@RouteConfig([
|
||||
{ path: '/', component: HomeComponent, name: 'Home', useAsDefault: true },
|
||||
{ path: '/home', component: HomeComponent, name: 'Home' },
|
||||
{ path: '/claims', component: ClaimsComponent, name: 'Claims' },
|
||||
{ path: '/claim', component: ClaimComponent, name: 'Claim' },
|
||||
{ path: '/search', component: SearchComponent, name: 'Search' },
|
||||
{ path: '/linking', component: LinkingComponent, name: 'Linking' }
|
||||
|
||||
])
|
||||
export class App {
|
||||
name: string = 'Angular 2';
|
||||
data = {};
|
||||
server;
|
||||
constructor(public http: Http ) {
|
||||
console.info('App constructor');
|
||||
}
|
||||
ngOnInit() {
|
||||
console.info('App init');
|
||||
setTimeout(() => {
|
||||
this.server = 'Rendered on the Server';
|
||||
}, 10);
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -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,38 @@
|
|||
import {Component} from '@angular/core';
|
||||
import {JSONP_PROVIDERS} from '@angular/http';
|
||||
import {Observable} from 'rxjs/Observable';
|
||||
import { RouteParams, ROUTER_DIRECTIVES} from '@angular/router-deprecated';
|
||||
|
||||
import {ClaimsService} from '../services/claims.service';
|
||||
import {Claim} from '../entities/claim';
|
||||
|
||||
@Component({
|
||||
selector: 'claim',
|
||||
templateUrl: 'src/app/claim/claim.component.html',
|
||||
providers:[ ClaimsService, JSONP_PROVIDERS, ...ROUTER_DIRECTIVES]
|
||||
|
||||
})
|
||||
export class ClaimComponent {
|
||||
constructor (private _claimService: ClaimsService,
|
||||
private _routeParams: RouteParams) {}
|
||||
ngOnInit() {
|
||||
|
||||
this.id = this._routeParams.get('id');
|
||||
if(this.id!=null){
|
||||
this.getClaim(this.id);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
id : string;
|
||||
claim : any;
|
||||
getClaim (id: string) {
|
||||
this._claimService.getClaim(id)
|
||||
.then(data => {
|
||||
this.claim = data;
|
||||
console.log(data);
|
||||
}) ;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,89 @@
|
|||
|
||||
<h1>Claims</h1>
|
||||
<h3>Filter claims by type:</h3>
|
||||
<select [(ngModel)]="fetchBy">
|
||||
<option *ngFor="let type of types" [value]="type">{{type}}</option>
|
||||
</select>
|
||||
|
||||
<input type="text" [(ngModel)]="fetchId" />
|
||||
|
||||
<button (click)="goTo()">Fetch</button>
|
||||
<!--<div class="col-md-4">
|
||||
<input type="text" #listFilter (keyup)="0" />
|
||||
</div>-->
|
||||
<div>
|
||||
<div *ngIf="selected.length>0">
|
||||
<p>You have selected {{selected.length}} claim(s)</p>
|
||||
</div>
|
||||
<button class="btn btn-default" (click)="selectAll()">Select All</button> <button class="btn btn-default" (click)="deselectAll()">Deselect All</button> <button class="btn btn-default" (click)="delete()">Delete</button>
|
||||
</div>
|
||||
<div *ngIf="resultsNum">
|
||||
<paging [currentPage]="page" [totalResults]="resultsNum" [navigateTo]="navigateTo" [size]="size" [params]="getParameters()" > </paging>
|
||||
</div>
|
||||
<p *ngIf="resultsNum == 0" >No entries found.</p>
|
||||
<p *ngIf="resultsNum>0" >Showing {{(size*page - size +1)}} to {{(size*page>resultsNum)?resultsNum:(size*page)}} of {{resultsNum}} entries</p>
|
||||
<p *ngIf="resultsNum>size*page">Show
|
||||
<select [(ngModel)]="size" (ngModelChange)="goTo()">
|
||||
<option *ngIf="resultsNum > 10" [ngValue]="10">10</option>
|
||||
<option *ngIf="resultsNum > 20" [ngValue]="20">20</option>
|
||||
<option *ngIf="resultsNum > 30" [ngValue]="30">30</option>
|
||||
<option *ngIf="resultsNum > 50" [ngValue]="50">50</option>
|
||||
</select>
|
||||
</p>
|
||||
<div>
|
||||
<div class="col-md-2">Filter Results by:</div>
|
||||
<div class="col-md-4">
|
||||
<input type="text" [(ngModel)]="inputkeyword" />
|
||||
<button class="btn btn-primary" (click)="changekeyword()">Filter</button>
|
||||
</div>
|
||||
<div class="col-md-4" >
|
||||
<label>
|
||||
<input [(ngModel)]="projectCB" type="checkbox" (ngModelChange)="changeType()" />
|
||||
Project
|
||||
</label>
|
||||
<label>
|
||||
<input [(ngModel)]="publicationCB" type="checkbox" (ngModelChange)="changeType()" />
|
||||
Publication
|
||||
</label>
|
||||
<label>
|
||||
<input [(ngModel)]="datasetCB" type="checkbox" (ngModelChange)="changeType()" />
|
||||
Dataset
|
||||
</label>
|
||||
<label>
|
||||
<input [(ngModel)]="contextCB" type="checkbox" (ngModelChange)="changeType()" />
|
||||
Context
|
||||
</label>
|
||||
<button class="btn btn-primary" (click)="clearFilters()">Clear filters</button>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="">
|
||||
<table *ngIf="claims" class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th></th>
|
||||
<!--<th>Id</th>
|
||||
<th>Source type</th> -->
|
||||
<th><a (click)="changeOrderby('source')" >Source</a> </th>
|
||||
<!-- <th>Target Type</th> -->
|
||||
<th><a (click)="changeOrderby('target')" >Target</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 | claimTextFilter:textFilter | claimTypeFilter:publicationCB:datasetCB:projectCB:contextCB " >-->
|
||||
<tr *ngFor="let claim of claims " >
|
||||
<td><input [id]="claim.id" type="checkbox" (click)="select(claim,$event)" [ngModel]="selectClaims"/></td>
|
||||
<!--<td><a (click)="goToClaim((claim.id))">{{claim.id}}</a></td>
|
||||
<td>{{claim.sourceType}}</td> -->
|
||||
<td><claim-entity [entity]="claim.source" [type]="claim.sourceType" > </claim-entity></td>
|
||||
<!--<td>{{claim.targetType}}</td> -->
|
||||
<td><claim-entity [entity]="claim.target" [type]="claim.targetType" > </claim-entity></td>
|
||||
<td>{{claim.userMail}}</td>
|
||||
<td>{{claim.date}}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
|
@ -0,0 +1,300 @@
|
|||
import {Component} from '@angular/core';
|
||||
import {JSONP_PROVIDERS} from '@angular/http';
|
||||
import {Observable} from 'rxjs/Observable';
|
||||
import { RouteParams, RouteConfig, ROUTER_DIRECTIVES, Router } from '@angular/router-deprecated';
|
||||
|
||||
import {ClaimsService} from '../services/claims.service';
|
||||
import {Claim} from '../entities/claim';
|
||||
import {ClaimTextFilterPipe} from '../pipes/claimTextFilter.pipe';
|
||||
import {ClaimTypeFilterPipe} from '../pipes/claimTypeFilter.pipe';
|
||||
import {PagingFormatter} from '../common/pagingFormatter.component';
|
||||
import {ClaimEntityFormatter} from '../common/claimEntityFormatter.component';
|
||||
|
||||
@Component({
|
||||
selector: 'claims',
|
||||
directives: [...ROUTER_DIRECTIVES, PagingFormatter, ClaimEntityFormatter],
|
||||
templateUrl: 'src/app/claims/claims.component.html',
|
||||
providers:[ ClaimsService, JSONP_PROVIDERS],
|
||||
pipes: [ClaimTextFilterPipe, ClaimTypeFilterPipe]
|
||||
|
||||
})
|
||||
export class ClaimsComponent {
|
||||
constructor (private _claimService: ClaimsService, private _routeParams: RouteParams, private _router:Router) {}
|
||||
|
||||
ngOnInit() {
|
||||
let page = +this._routeParams.get('page');
|
||||
let size = +this._routeParams.get('size');
|
||||
this.keyword = (this._routeParams.get('keyword')?this._routeParams.get('keyword'):"");
|
||||
this.inputkeyword = this.keyword;
|
||||
this.page = ( page <= 0 ) ? 1 : page;
|
||||
this.size = ( size <= 0 ) ? 10 : size;
|
||||
this.fetchBy = this._routeParams.get('fetchBy');
|
||||
this.fetchBy = (this.types.indexOf(this.fetchBy) != -1)? this.fetchBy:'All';
|
||||
this.fetchId = this._routeParams.get('fetchId');
|
||||
console.info("Fetch by:"+this.fetchBy+"Fetch id:"+this.fetchId);
|
||||
this.fetchId=this.fetchId?this.fetchId:'';
|
||||
this.params= { page: this.page, size: this.size,fetchBy: this.fetchBy, fetchId:this.fetchId };
|
||||
this.entityTypes = (this._routeParams.get('types')?this._routeParams.get('types'):'');
|
||||
this.setTypes(); // check the appropriate checkboxes
|
||||
this.setSortby(this._routeParams.get('sort'));
|
||||
this.getClaims();
|
||||
|
||||
}
|
||||
|
||||
page : number;
|
||||
size:number;
|
||||
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"];
|
||||
fetchBy:string;
|
||||
fetchId:string;
|
||||
|
||||
navigateTo: string = "Claims";
|
||||
resultsNum: number ;
|
||||
claims: string[];
|
||||
|
||||
|
||||
//checkboxes:
|
||||
publicationCB = false;
|
||||
datasetCB = false;
|
||||
contextCB = false;
|
||||
projectCB = false;
|
||||
entityTypes : string ='' ;
|
||||
|
||||
descending = true;
|
||||
sortby = "date";
|
||||
|
||||
selected=[];
|
||||
selectAllClaims:boolean = false;
|
||||
|
||||
//params for pagingFormatter to use when navigate to page
|
||||
params;
|
||||
|
||||
getClaims () {
|
||||
this.selectAllClaims = false;
|
||||
if(this.fetchBy =="Project" ){
|
||||
this._claimService.getClaimsByProject(this.size,this.page,this.fetchId,this.keyword,this.sortby,this.descending, this.entityTypes).subscribe(
|
||||
data => {
|
||||
this.claims = data.data;
|
||||
this.resultsNum= data.total;
|
||||
},
|
||||
err => console.error(err)
|
||||
);
|
||||
}else if(this.fetchBy =="User"){
|
||||
console.info("Fetch by:"+this.fetchBy+"Fetch id:"+this.fetchId);
|
||||
|
||||
this._claimService.getClaimsByUser(this.size,this.page,this.fetchId,this.keyword,this.sortby,this.descending, this.entityTypes).subscribe(
|
||||
data => {
|
||||
this.claims = data.data;
|
||||
this.resultsNum= data.total;
|
||||
},
|
||||
err => console.error(err)
|
||||
);
|
||||
}else if(this.fetchBy =="Result"){
|
||||
this._claimService.getClaimsByResult(this.size,this.page,this.fetchId,this.keyword,this.sortby,this.descending, this.entityTypes).subscribe(
|
||||
data => {
|
||||
this.claims = data.data;
|
||||
this.resultsNum= data.total;
|
||||
},
|
||||
err => console.error(err)
|
||||
);
|
||||
}else if(this.fetchBy =="Context"){
|
||||
this._claimService.getClaimsBycontext(this.size,this.page,this.fetchId,this.keyword,this.sortby,this.descending, this.entityTypes).subscribe(
|
||||
data => {
|
||||
this.claims = data.data;
|
||||
this.resultsNum= null;
|
||||
this.resultsNum= data.total;//data.length; //TODO get the total results num
|
||||
},
|
||||
err => console.error(err)
|
||||
);
|
||||
}else{
|
||||
this._claimService.getClaims(this.size,this.page,this.keyword,this.sortby,this.descending, this.entityTypes).subscribe(
|
||||
data => {
|
||||
this.claims = data.data;
|
||||
this.resultsNum = null;
|
||||
this.resultsNum= data.total;//data.length; //TODO get the total results num
|
||||
},
|
||||
err => console.error(err)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
goToClaim(claimId: number){
|
||||
this._router.navigate( ['Claim', { id: claimId}] );
|
||||
}
|
||||
goTo(){
|
||||
|
||||
this.page = 1;
|
||||
|
||||
// console.info("In goto - params( page:"+params.page+", size: "+params.size+", fetchId:"+params.fetchId);
|
||||
this._router.navigate( [this.navigateTo,this.getParameters()] );
|
||||
}
|
||||
getParameters(){
|
||||
let params={ page: this.page, size: this.size, types: this.entityTypes, fetchBy: this.fetchBy, fetchId:this.fetchId, keyword : this.keyword, sort: this.getSortby() };
|
||||
return params;
|
||||
}
|
||||
changeLength(){
|
||||
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(){
|
||||
console.debug("ChangingType: "+this.entityTypes+" types"+this.publicationCB+ this.datasetCB + this.contextCB + this.projectCB);
|
||||
if(this.publicationCB == true && this.datasetCB == true && this.contextCB == true && this.projectCB == true ){
|
||||
this.entityTypes="";
|
||||
}else{
|
||||
this.entityTypes = "";
|
||||
if(this.publicationCB == true){
|
||||
this.entityTypes = "publication";
|
||||
}
|
||||
if(this.datasetCB == true){
|
||||
this.entityTypes += (this.entityTypes.length > 0?",":"")+"dataset";
|
||||
}
|
||||
if(this.contextCB == true){
|
||||
this.entityTypes += (this.entityTypes.length > 0?",":"")+"context";
|
||||
}
|
||||
if(this.projectCB == true){
|
||||
this.entityTypes += (this.entityTypes.length > 0?",":"")+"project";
|
||||
}
|
||||
}
|
||||
console.debug("Type changed: "+this.entityTypes+" "+this.publicationCB+ this.datasetCB + this.contextCB + this.projectCB);
|
||||
this.goTo();
|
||||
}
|
||||
setTypes(){
|
||||
if(this.entityTypes.length > 0){
|
||||
if(this.entityTypes.indexOf("publication")!=-1){
|
||||
this.publicationCB = true;
|
||||
}
|
||||
if(this.entityTypes.indexOf("dataset")!=-1){
|
||||
this.datasetCB = true;
|
||||
}
|
||||
if(this.entityTypes.indexOf("project")!=-1){
|
||||
this.projectCB = true;
|
||||
}
|
||||
if(this.entityTypes.indexOf("context")!=-1){
|
||||
this.contextCB = true;
|
||||
}
|
||||
}
|
||||
if(this.publicationCB && this.datasetCB && this.contextCB && this.projectCB){
|
||||
this.entityTypes='';
|
||||
}else{
|
||||
if(this.publicationCB){
|
||||
this.entityTypes = "publication";
|
||||
}
|
||||
if(this.datasetCB){
|
||||
this.entityTypes = (this.entityTypes.length > 0?",":"")+"dataset";
|
||||
}
|
||||
if(this.contextCB){
|
||||
this.entityTypes = (this.entityTypes.length > 0?",":"")+"context";
|
||||
}
|
||||
if(this.projectCB){
|
||||
this.entityTypes = (this.entityTypes.length > 0?",":"")+"project";
|
||||
}
|
||||
}
|
||||
}
|
||||
changekeyword(){
|
||||
if(this.inputkeyword.length >= 3 || this.inputkeyword.length == 0 ){
|
||||
this.keyword = this.inputkeyword;
|
||||
this.page = 1;
|
||||
this.goTo();
|
||||
}
|
||||
|
||||
}
|
||||
select(item:any,event){
|
||||
var value = event.currentTarget.checked;
|
||||
console.debug("value:"+value);
|
||||
if(value){
|
||||
this.selectAllClaims = false;
|
||||
this.selected.push(item);
|
||||
console.debug("select one more! with id:"+item.id);
|
||||
}else{
|
||||
|
||||
var index:number =this.selected.indexOf(item);
|
||||
console.info("Try to remove item from :"+this.selected.indexOf(item));
|
||||
if (index > -1) {
|
||||
this.selected.splice(index, 1);
|
||||
}
|
||||
console.info("Item removed "+this.selected.indexOf(item));
|
||||
}
|
||||
}
|
||||
selectAll(){
|
||||
this.selectAllClaims = true;
|
||||
}
|
||||
deselectAll(){
|
||||
this.selectAllClaims = false;
|
||||
}
|
||||
|
||||
delete(){
|
||||
console.warn("Deleting...");
|
||||
for (var i = 0; i < this.selected.length; i++){
|
||||
var id =this.selected[i].id;
|
||||
console.warn("Deleting claim with id:"+id);
|
||||
// this._claimService.deleteClaimById(id);
|
||||
this._claimService.deleteClaimById(id).subscribe(
|
||||
res => {
|
||||
console.info('Delete response'+res.code );
|
||||
var index:number =this.claims.indexOf(this.selected[i]);
|
||||
console.info('Index'+index );
|
||||
this.selected.splice(i, 1);
|
||||
|
||||
if (index > -1) {
|
||||
this.claims.splice(index, 1);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,91 @@
|
|||
import {Component, ElementRef} from '@angular/core';
|
||||
|
||||
|
||||
@Component({
|
||||
selector: 'autocomplete',
|
||||
template: `
|
||||
<div class="container" >
|
||||
<div class="input-field col s12">
|
||||
|
||||
</div>
|
||||
<label for="country">Country</label>
|
||||
<input id="country" type="text" class="validate filter-input" [(ngModel)]=query (keyup)=filter() >
|
||||
|
||||
|
||||
|
||||
<div class="suggestions" *ngIf="filteredList.length > 0">
|
||||
<ul class="list-group" *ngFor=" let item of filteredList" >
|
||||
<li class="list-group-item" >
|
||||
<a (click)="select(item)">{{item}}</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="selections" *ngIf="selectedList.length > 0">
|
||||
<label for="selecteditems">Selected: </label>
|
||||
<ul id ="selecteditems" class="nav nav-pills" *ngFor="let item of selectedList" >
|
||||
<li role="presentation" (click)="remove(item)">{{item}} <span class="badge">X</span>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
`
|
||||
})
|
||||
export class AutocompleteComponent {
|
||||
public query = '';
|
||||
public countries = [ "Albania","Andorra","Armenia","Austria","Azerbaijan","Belarus",
|
||||
"Belgium","Bosnia & Herzegovina","Bulgaria","Croatia","Cyprus",
|
||||
"Czech Republic","Denmark","Estonia","Finland","France","Georgia",
|
||||
"Germany","Greece","Hungary","Iceland","Ireland","Italy","Kosovo",
|
||||
"Latvia","Liechtenstein","Lithuania","Luxembourg","Macedonia","Malta",
|
||||
"Moldova","Monaco","Montenegro","Netherlands","Norway","Poland",
|
||||
"Portugal","Romania","Russia","San Marino","Serbia","Slovakia","Slovenia",
|
||||
"Spain","Sweden","Switzerland","Turkey","Ukraine","United Kingdom","Vatican City"];
|
||||
public filteredList = [];
|
||||
public selectedList = [];
|
||||
public elementRef;
|
||||
|
||||
constructor(myElement: ElementRef) {
|
||||
this.elementRef = myElement;
|
||||
}
|
||||
|
||||
filter() {
|
||||
if (this.query !== ""){
|
||||
this.filteredList = this.countries.filter(function(el){
|
||||
return el.toLowerCase().indexOf(this.query.toLowerCase()) > -1;
|
||||
}.bind(this));
|
||||
}else{
|
||||
this.filteredList = [];
|
||||
}
|
||||
}
|
||||
|
||||
select(item){
|
||||
this.query = "";
|
||||
this.filteredList = [];
|
||||
this.selectedList.push(item);
|
||||
console.info("Select:"+this.selectedList);
|
||||
for (var i = 0; i < this.selectedList.length; i++) {
|
||||
console.log(this.selectedList[i]);
|
||||
}
|
||||
}
|
||||
remove(item){
|
||||
var index:number =this.selectedList.indexOf(item);
|
||||
console.info("Try to remove item from :"+this.selectedList.indexOf(item));
|
||||
if (index > -1) {
|
||||
this.selectedList.splice(index, 1);
|
||||
}
|
||||
console.info("Item removed "+this.selectedList.indexOf(item));
|
||||
}
|
||||
handleClick(event){
|
||||
var clickedComponent = event.target;
|
||||
var inside = false;
|
||||
do {
|
||||
if (clickedComponent === this.elementRef.nativeElement) {
|
||||
inside = true;
|
||||
}
|
||||
clickedComponent = clickedComponent.parentNode;
|
||||
} while (clickedComponent);
|
||||
if(!inside){
|
||||
this.filteredList = [];
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
import {Component, Input} from '@angular/core';
|
||||
import {PublicationTitleFormatter} from './publicationTitleFormatter.component';
|
||||
import {ProjectTitleFormatter} from './projectTitleFormatter.component';
|
||||
|
||||
//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><a target="_blank" >{{entity.title}}</a></h5>
|
||||
</div>
|
||||
`,
|
||||
directives: [PublicationTitleFormatter,ProjectTitleFormatter]
|
||||
})
|
||||
|
||||
export class ClaimEntityFormatter {
|
||||
@Input() entity: string[];
|
||||
@Input() type: string;
|
||||
|
||||
constructor () {}
|
||||
|
||||
ngOnInit() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,85 @@
|
|||
import {Component, Input} from '@angular/core';
|
||||
import {Router, ROUTER_DIRECTIVES} from '@angular/router-deprecated';
|
||||
|
||||
//Usage Example <paging [currentPage]="page" [totalResults]="resultsNum" [navigateTo]="Search" [term]="keyword"> </paging>
|
||||
|
||||
@Component({
|
||||
selector: 'paging',
|
||||
template: `
|
||||
<div *ngIf=" ( getTotalPages() > 0 ) && (getTotalPages() > 1) && ( 0 < currentPage && currentPage <= getTotalPages() ) " >
|
||||
<ul class="pagination">
|
||||
|
||||
<li *ngIf=" currentPage > 1" ><a (click)="onPage((1))" aria-label="Previous">
|
||||
<span aria-hidden="true">«</span></a></li>
|
||||
<!--<li *ngIf=" currentPage > 1"><a (click)="onPage((currentPage -1))">\<</a></li>-->
|
||||
|
||||
<li *ngIf=" currentPage -2 > 0"><a (click)="onPage((currentPage -2))">{{currentPage -2}}</a></li>
|
||||
<li *ngIf=" currentPage -1 > 0 "><a (click)="onPage((currentPage -1))">{{currentPage -1}}</a></li>
|
||||
<li class="active"><a >{{currentPage}}</a></li>
|
||||
<li *ngIf=" currentPage +1 <= getTotalPages() "><a (click)="onPage((currentPage +1))">{{currentPage +1}}</a></li>
|
||||
<li *ngIf=" currentPage +2 <= getTotalPages() "><a (click)="onPage((currentPage +2))">{{currentPage +2}}</a></li>
|
||||
<li *ngIf=" (currentPage -2 <= 0)&&(currentPage +3 <= getTotalPages()) "><a (click)="onPage((currentPage +3))">{{currentPage +3}}</a></li>
|
||||
<li *ngIf=" (currentPage -1 <= 0)&&(currentPage +4 <= getTotalPages()) "><a (click)="onPage((currentPage +4))">{{currentPage +4}}</a></li>
|
||||
|
||||
<!--<li *ngIf=" getTotalPages() > currentPage "><a (click)="onPage((currentPage+1))">\></a></li>-->
|
||||
<li *ngIf="getTotalPages() > currentPage"><a (click)="onPage((getTotalPages()))" aria-label="Next">
|
||||
<span aria-hidden="true">»</span>
|
||||
</a></li>
|
||||
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
`,
|
||||
directives: [
|
||||
...ROUTER_DIRECTIVES
|
||||
]
|
||||
})
|
||||
|
||||
export class PagingFormatter {
|
||||
@Input() currentPage: number = 1;
|
||||
@Input() navigateTo: string;
|
||||
@Input() term: string='';
|
||||
@Input() size: number=10;
|
||||
@Input() totalResults: number = 10;
|
||||
@Input() params;
|
||||
|
||||
constructor ( private _router: Router) {
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
console.info("In paging -- CurrentPage:"+this.currentPage+" "+"total Pages = "+this.getTotalPages() +" Results num:"+this.totalResults);
|
||||
}
|
||||
getTotalPages(){
|
||||
return parseInt(''+(this.totalResults/this.size+1));
|
||||
}
|
||||
onPrev(){
|
||||
if(this.params){
|
||||
let pageparams= this.params;
|
||||
pageparams.page=this.currentPage -1
|
||||
this._router.navigate( [this.navigateTo, pageparams] );
|
||||
}else{
|
||||
this._router.navigate( [this.navigateTo, { keyword: this.term, page: (this.currentPage -1) }] );
|
||||
}
|
||||
}
|
||||
|
||||
onNext(){
|
||||
if(this.params){
|
||||
let pageparams= this.params;
|
||||
pageparams.page=this.currentPage +1;
|
||||
this._router.navigate( [this.navigateTo, pageparams] );
|
||||
}else{
|
||||
this._router.navigate( [this.navigateTo, { keyword: this.term, page: (this.currentPage +1) }] );
|
||||
}
|
||||
}
|
||||
onPage(pageNum: number){
|
||||
if(this.params){
|
||||
let pageparams= this.params;
|
||||
pageparams.page=pageNum;
|
||||
this._router.navigate( [this.navigateTo, pageparams] );
|
||||
}else if(this.term!=''){
|
||||
this._router.navigate( [this.navigateTo, { keyword: this.term, page: pageNum, size: this.size }] );
|
||||
}else{
|
||||
this._router.navigate( [this.navigateTo, { page: pageNum, size: this.size }] );
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,99 @@
|
|||
import {Component, Input, Output, EventEmitter} from '@angular/core';
|
||||
import {Router, ROUTER_DIRECTIVES} from '@angular/router-deprecated';
|
||||
|
||||
//Usage Example <paging [currentPage]="page" [totalResults]="resultsNum" [navigateTo]="Search" [term]="keyword"> </paging>
|
||||
|
||||
@Component({
|
||||
selector: 'paging-no-load',
|
||||
template: `
|
||||
<div *ngIf=" ( getTotalPages() > 0 ) && (getTotalPages() > 1) && ( 0 < currentPage && currentPage <= getTotalPages() ) " >
|
||||
<ul class="pagination">
|
||||
|
||||
<li *ngIf=" currentPage > 1" ><a (click)="onPage((1))" aria-label="Previous">
|
||||
<span aria-hidden="true">«</span></a></li>
|
||||
<!--<li *ngIf=" currentPage > 1"><a (click)="onPage((currentPage -1))">\<</a></li>-->
|
||||
|
||||
<li *ngIf=" currentPage -2 > 0"><a (click)="onPage((currentPage -2))">{{currentPage -2}}</a></li>
|
||||
<li *ngIf=" currentPage -1 > 0 "><a (click)="onPage((currentPage -1))">{{currentPage -1}}</a></li>
|
||||
<li class="active"><a >{{currentPage}}</a></li>
|
||||
<li *ngIf=" currentPage +1 <= getTotalPages() "><a (click)="onPage((currentPage +1))">{{currentPage +1}}</a></li>
|
||||
<li *ngIf=" currentPage +2 <= getTotalPages() "><a (click)="onPage((currentPage +2))">{{currentPage +2}}</a></li>
|
||||
<li *ngIf=" (currentPage -2 <= 0)&&(currentPage +3 <= getTotalPages()) "><a (click)="onPage((currentPage +3))">{{currentPage +3}}</a></li>
|
||||
<li *ngIf=" (currentPage -1 <= 0)&&(currentPage +4 <= getTotalPages()) "><a (click)="onPage((currentPage +4))">{{currentPage +4}}</a></li>
|
||||
|
||||
<!--<li *ngIf=" getTotalPages() > currentPage "><a (click)="onPage((currentPage+1))">\></a></li>-->
|
||||
<li *ngIf="getTotalPages() > currentPage"><a (click)="onPage((getTotalPages()))" aria-label="Next">
|
||||
<span aria-hidden="true">»</span>
|
||||
</a></li>
|
||||
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
`,
|
||||
directives: [
|
||||
...ROUTER_DIRECTIVES
|
||||
]
|
||||
})
|
||||
|
||||
export class pagingFormatterNoLoad {
|
||||
@Input() currentPage: number = 1;
|
||||
@Input() navigateTo: string;
|
||||
@Input() term: string='';
|
||||
@Input() size: number=10;
|
||||
@Input() totalResults: number = 10;
|
||||
@Input() params;
|
||||
|
||||
@Output() pageChange = new EventEmitter();
|
||||
|
||||
constructor ( private _router: Router) {
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
console.debug("In paging -- CurrentPage:"+this.currentPage+" "+"total Pages = "+this.getTotalPages() +" Results num:"+this.totalResults);
|
||||
}
|
||||
getTotalPages(){
|
||||
return parseInt(''+(this.totalResults/this.size+1));
|
||||
}
|
||||
onPrev(){
|
||||
this.currentPage=-1;
|
||||
this.pageChange.emit({
|
||||
value: this.currentPage
|
||||
});
|
||||
// if(this.params){
|
||||
// let pageparams= this.params;
|
||||
// pageparams.page=this.currentPage -1
|
||||
// this._router.navigate( [this.navigateTo, pageparams] );
|
||||
// }else{
|
||||
// this._router.navigate( [this.navigateTo, { keyword: this.term, page: (this.currentPage -1) }] );
|
||||
// }
|
||||
}
|
||||
|
||||
onNext(){
|
||||
// if(this.params){
|
||||
// let pageparams= this.params;
|
||||
// pageparams.page=this.currentPage +1;
|
||||
// this._router.navigate( [this.navigateTo, pageparams] );
|
||||
// }else{
|
||||
// this._router.navigate( [this.navigateTo, { keyword: this.term, page: (this.currentPage +1) }] );
|
||||
// }
|
||||
this.currentPage=+1;
|
||||
this.pageChange.emit({
|
||||
value: this.currentPage
|
||||
});
|
||||
}
|
||||
onPage(pageNum: number){
|
||||
// if(this.params){
|
||||
// let pageparams= this.params;
|
||||
// pageparams.page=pageNum;
|
||||
// this._router.navigate( [this.navigateTo, pageparams] );
|
||||
// }else if(this.term!=''){
|
||||
// this._router.navigate( [this.navigateTo, { keyword: this.term, page: pageNum, size: this.size }] );
|
||||
// }else{
|
||||
// this._router.navigate( [this.navigateTo, { page: pageNum, size: this.size }] );
|
||||
// }
|
||||
this.currentPage=pageNum;
|
||||
this.pageChange.emit({
|
||||
value: this.currentPage
|
||||
});
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
import {Component, Input} from '@angular/core';
|
||||
|
||||
//Usage Example "<project-title [project]="X" > </project-title>"
|
||||
|
||||
@Component({
|
||||
selector: 'project-title',
|
||||
template: `
|
||||
<div class="project-title">
|
||||
<h5>{{project.name}} ( {{project.funderName}} )</h5>
|
||||
</div>
|
||||
`
|
||||
})
|
||||
|
||||
export class ProjectTitleFormatter {
|
||||
@Input() project: string[];
|
||||
|
||||
constructor () {}
|
||||
|
||||
ngOnInit() {}
|
||||
}
|
|
@ -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}}" >{{title}}</a></h5>
|
||||
<h5 *ngIf="!url" >{{title}}</h5>
|
||||
</div>
|
||||
`
|
||||
})
|
||||
|
||||
export class PublicationTitleFormatter {
|
||||
@Input() title: string[];
|
||||
@Input() url: string[];
|
||||
|
||||
constructor () {}
|
||||
|
||||
ngOnInit() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -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,7 @@
|
|||
export class Publication {
|
||||
title: string;
|
||||
publisher: string;
|
||||
DOI: string;
|
||||
source: string;
|
||||
type: string;
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
|
||||
<div class="container">
|
||||
<div class="row ">
|
||||
<input #term type="text" class="form-control col-xs-5" placeholder="Search for...">
|
||||
<span class="input-group-btn col-xs-2">
|
||||
<button class="btn btn-default" type="button" (click)="searchTerm(term.value)" >
|
||||
Go!
|
||||
</button>
|
||||
</span>
|
||||
</div>
|
||||
<autocomplete></autocomplete>
|
||||
|
||||
</div>
|
|
@ -0,0 +1,21 @@
|
|||
import {Component} from '@angular/core';
|
||||
import {RouteConfig, ROUTER_DIRECTIVES, Router} from '@angular/router-deprecated';
|
||||
import {JSONP_PROVIDERS} from '@angular/http';
|
||||
import {Observable} from 'rxjs/Observable';
|
||||
import {SearchComponent} from '../search/search.component';
|
||||
import {AutocompleteComponent} from '../common/autoComplete.component';
|
||||
@Component({
|
||||
selector: 'home',
|
||||
templateUrl: 'src/app/home/home.component.html',
|
||||
directives: [
|
||||
...ROUTER_DIRECTIVES, AutocompleteComponent
|
||||
],
|
||||
})
|
||||
|
||||
export class HomeComponent {
|
||||
constructor ( private _router: Router) {}
|
||||
|
||||
searchTerm(term: string) {
|
||||
this._router.navigate( ['Search', { keyword: term }] );
|
||||
}
|
||||
}
|
|
@ -0,0 +1,153 @@
|
|||
import {Component, Input,Output, ElementRef, EventEmitter} from '@angular/core';
|
||||
import {JSONP_PROVIDERS} from '@angular/http';
|
||||
import {Observable} from 'rxjs/Observable';
|
||||
import { RouteParams, ROUTER_DIRECTIVES} from '@angular/router-deprecated';
|
||||
import {ContextsService} from '../../services/contexts.service';
|
||||
|
||||
|
||||
@Component({
|
||||
selector: 'claim-contexts',
|
||||
template: `
|
||||
<div class="container" >
|
||||
<div class="input-field col s12">
|
||||
|
||||
</div>
|
||||
<h3>Select Community and Category:</h3>
|
||||
<select [(ngModel)]="selectedCommunity" (ngModelChange)="communityChanged()" >
|
||||
<option [ngValue]="'0'">Community:</option>
|
||||
<option *ngIf="communities" [ngValue]="communities.id">{{communities.label}}</option>
|
||||
</select>
|
||||
<select *ngIf="categories" [(ngModel)]="selectedCategory" (ngModelChange)="categoryChanged()" >
|
||||
<option [ngValue]="'0'">Category:</option>
|
||||
<option *ngFor="let category of categories" [ngValue]="category.id">{{category.label}}</option>
|
||||
</select>
|
||||
<h4>Select concepts:</h4>
|
||||
<input id="community" type="text" class="validate filter-input" [(ngModel)]=query (keyup)=filter() >
|
||||
<div class="suggestions" *ngIf="filteredList.length > 0">
|
||||
<ul class="list-group" *ngFor=" let item of filteredList" >
|
||||
<li class="list-group-item" >
|
||||
<a (click)="select(item)">{{item.label}}</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="selections" *ngIf="selectedList.length > 0">
|
||||
<label for="selecteditems">Selected: </label>
|
||||
<ul id ="selecteditems" class="nav nav-pills" *ngFor="let item of selectedList" >
|
||||
<li role="presentation" (click)="remove(item)">{{item.concept.label}} <span class="badge">X</span>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
`,
|
||||
providers:[ ContextsService ]
|
||||
|
||||
})
|
||||
export class ClaimContextComponent {
|
||||
ngOnInit() {
|
||||
this.getCommunities();
|
||||
|
||||
}
|
||||
public query = '';
|
||||
public filteredList = [];
|
||||
@Input() public selectedList ;
|
||||
public elementRef;
|
||||
@Output() contextsChange = new EventEmitter();
|
||||
|
||||
public communities:string[];
|
||||
@Input() public selectedCommunity:string ="0";
|
||||
@Output() cselectedCommunityChange = new EventEmitter();
|
||||
|
||||
public categories:string[];
|
||||
@Input() public selectedCategory:string ="0";
|
||||
@Output() selectedCategoryChange = new EventEmitter();
|
||||
public concepts:string[];
|
||||
|
||||
constructor(private _contextService: ContextsService,myElement: ElementRef) {
|
||||
this.elementRef = myElement;
|
||||
}
|
||||
|
||||
filter() {
|
||||
if (this.query !== ""){
|
||||
this.filteredList = this.concepts.filter(function(el){
|
||||
return el.label.toLowerCase().indexOf(this.query.toLowerCase()) > -1;
|
||||
}.bind(this));
|
||||
}else{
|
||||
this.filteredList = [];
|
||||
}
|
||||
}
|
||||
|
||||
select(item){
|
||||
this.query = "";
|
||||
this.filteredList = [];
|
||||
var index:number =this.selectedList.indexOf(item);
|
||||
if (index == -1) {
|
||||
var context= { community: this.selectedCommunity, category: this.selectedCategory, concept: item };
|
||||
this.selectedList.push(context);
|
||||
this.contextsChange.emit({
|
||||
value: this.selectedList
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
remove(item){
|
||||
var index:number =this.selectedList.indexOf(item);
|
||||
if (index > -1) {
|
||||
this.selectedList.splice(index, 1);
|
||||
}
|
||||
this.contextsChange.emit({
|
||||
value: this.selectedList
|
||||
});
|
||||
}
|
||||
handleClick(event){
|
||||
var clickedComponent = event.target;
|
||||
var inside = false;
|
||||
do {
|
||||
if (clickedComponent === this.elementRef.nativeElement) {
|
||||
inside = true;
|
||||
}
|
||||
clickedComponent = clickedComponent.parentNode;
|
||||
} while (clickedComponent);
|
||||
if(!inside){
|
||||
this.filteredList = [];
|
||||
}
|
||||
}
|
||||
getCommunities () {
|
||||
this._contextService.getCommunities().subscribe(
|
||||
data => {
|
||||
this.communities = data.communities;
|
||||
},
|
||||
err => console.error(err)
|
||||
);
|
||||
}
|
||||
getCategories () {
|
||||
this.categories=[];
|
||||
if(this.selectedCommunity != '0'){
|
||||
this._contextService.getCategories(this.selectedCommunity).subscribe(
|
||||
data => {
|
||||
this.categories = data.category;
|
||||
this.concepts = [];
|
||||
|
||||
},
|
||||
err => console.error(err)
|
||||
);
|
||||
}
|
||||
}
|
||||
getConcepts () {
|
||||
if(this.selectedCategory != '0'){
|
||||
this._contextService.getConcepts(this.selectedCategory, "").subscribe(
|
||||
data => {
|
||||
this.concepts = data.concept;
|
||||
|
||||
},
|
||||
err => console.error(err)
|
||||
);
|
||||
}
|
||||
}
|
||||
communityChanged(){
|
||||
this.getCategories();
|
||||
}
|
||||
categoryChanged(){
|
||||
this.getConcepts();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,112 @@
|
|||
import {Component, Input, Output, EventEmitter} from '@angular/core';
|
||||
import {JSONP_PROVIDERS} from '@angular/http';
|
||||
import {Observable} from 'rxjs/Observable';
|
||||
import { RouteParams, RouteConfig, ROUTER_DIRECTIVES, Router } from '@angular/router-deprecated';
|
||||
import {pagingFormatterNoLoad} from '../../common/pagingFormatterNoLoad.component';
|
||||
import {PublicationTitleFormatter} from '../../common/publicationTitleFormatter.component';
|
||||
import {SearchDataciteService} from '../../services/searchDatacite.service';
|
||||
|
||||
|
||||
@Component({
|
||||
selector: 'claim-dataset',
|
||||
directives: [...ROUTER_DIRECTIVES,pagingFormatterNoLoad, PublicationTitleFormatter],
|
||||
template: `
|
||||
<h3>Selected Results:</h3>
|
||||
<div >
|
||||
<p *ngFor=" let item of selectedDatasets "> <publication-title [title]="item.result.title" [url]="'http://dx.doi.org/'+item.result.doi" > </publication-title> {{item.result.doi}} --{{item.result.publisher}}<button type="button" class="close" (click)="remove(item)" aria-label="Close"> <span aria-hidden="true">×</span></button> </p>
|
||||
</div>
|
||||
<p><i>Fetches from Datacite </i></p>
|
||||
<input #term [(ngModel)]="keyword"/>
|
||||
<button (click)="searchDatacite(term.value,10,1)" type="button" class="btn btn-default">Search</button>
|
||||
<ul class="nav nav-tabs">
|
||||
<li class="active"><a data-toggle="tab" href="#datacite">Datacite ({{resultsNum}})</a></li>
|
||||
<li><a data-toggle="tab" href="#openaire">Openaire</a></li>
|
||||
</ul>
|
||||
<div class="tab-content">
|
||||
<div id="datacite" class="tab-pane fade in active">
|
||||
<div>
|
||||
<div *ngIf="resultsNum != null && resultsNum > 0">
|
||||
<p > {{resultsNum }} Total Results </p>
|
||||
<paging-no-load [currentPage]="page" [totalResults]="resultsNum" [navigateTo]="navigateTo" [term]="keyword" [size]="size" (pageChange)="pageChange($event)"> </paging-no-load>
|
||||
</div>
|
||||
<div >
|
||||
<p *ngFor=" let item of results "> <publication-title [title]="item.title" [url]="'http://dx.doi.org/'+item.doi" > </publication-title> <button (click)="add(item, item.doi,'dataset','datacite',item.title,'http://dx.doi.org/'+item.doi)" type="button" class="btn btn-default">Select</button> </p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="openaire" class="tab-pane fade">
|
||||
<h3>Menu 1</h3>
|
||||
<p>Some content in menu 1.</p>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
`,
|
||||
providers:[JSONP_PROVIDERS, SearchDataciteService]
|
||||
})
|
||||
export class ClaimDatasetComponent {
|
||||
constructor (private _searchDataciteService: SearchDataciteService,
|
||||
private _routeParams: RouteParams) {}
|
||||
ngOnInit() {
|
||||
if(this.keyword !=null && this.keyword.length > 0){
|
||||
this.searchDatacite(this.keyword,this.size,this.page);
|
||||
}
|
||||
}
|
||||
|
||||
page : number = 1;
|
||||
size:number = 10;
|
||||
navigateTo: string = "Search";
|
||||
source: string = "datacite";
|
||||
type : string = "dataset";
|
||||
@Input() public select:boolean = true ;
|
||||
@Input() public keyword:string = '';
|
||||
@Input() public selectedDatasets = [] ;
|
||||
@Output() datasetsChange = new EventEmitter();
|
||||
|
||||
results=[];
|
||||
resultsNum : Observable<number> ;
|
||||
|
||||
searchDatacite (term: string, size : number, page : number) {
|
||||
this.getDataciteResults(term,size,page);
|
||||
console.info('searchDatacite in searchDatacite file');
|
||||
}
|
||||
|
||||
getDataciteResults (term: string, size : number, page : number) {
|
||||
console.info("In getDataciteResults (start) "+term);
|
||||
this._searchDataciteService.searchDataciteResults(term, size, page).subscribe(
|
||||
data => {
|
||||
this.results = data.docs;
|
||||
this.page=page;
|
||||
this.resultsNum = data.numFound;
|
||||
},
|
||||
err => console.error(err)
|
||||
);
|
||||
console.info("In getDataciteResults (end) "+term);
|
||||
}
|
||||
|
||||
add(item, itemId,itemType,itemSource,itemTitle, itemUrl){
|
||||
var result ={id: itemId, type : itemType, source : itemSource, title: itemTitle, url: itemUrl, result: item};
|
||||
this.selectedDatasets.push(result);
|
||||
var index:number =this.results.indexOf(item);
|
||||
if (index > -1) {
|
||||
this.results.splice(index, 1);
|
||||
}
|
||||
this.datasetsChange.emit({
|
||||
value: this.selectedDatasets
|
||||
});
|
||||
}
|
||||
remove(item){
|
||||
var index:number =this.selectedDatasets.indexOf(item);
|
||||
if (index > -1) {
|
||||
this.selectedDatasets.splice(index, 1);
|
||||
this.datasetsChange.emit({
|
||||
value: this.selectedDatasets
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
pageChange($event) {
|
||||
this.page=$event.value;
|
||||
this.results=[];
|
||||
this.searchDatacite(this.keyword,10,this.page);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,66 @@
|
|||
|
||||
<h3>Selected Results:</h3>
|
||||
<div >
|
||||
<p *ngFor=" let item of selectedPublications "> <publication-title [title]="item.result.title" [url]="item.result.URL" > </publication-title> {{item.result.DOI}} --{{item.result.publisher}} <button (click)="remove(item)" type="button" class="btn btn-default">Remove</button></p>
|
||||
</div>
|
||||
<p><i>Fetches from crossref </i></p>
|
||||
<!-- (keyup)="searchCrossref(term.value)" -->
|
||||
<input #term [(ngModel)]="keyword"/>
|
||||
<button (click)="search(term.value,10,1)" type="button" class="btn btn-default">Search</button>
|
||||
<ul class="nav nav-tabs">
|
||||
<li class="active"><a data-toggle="tab" href="#crossref">Crossref ({{crossrefResultsNum}})</a></li>
|
||||
<li><a data-toggle="tab" href="#openaire">Openaire ({{openaireResultsNum}})</a></li>
|
||||
<li><a data-toggle="tab" href="#orcid">Orcid ({{orcidResultsNum}})</a></li>
|
||||
</ul>
|
||||
<div class="tab-content">
|
||||
<div id="crossref" class="tab-pane fade in active">
|
||||
<div>
|
||||
<div *ngIf="crossrefResultsNum != null && crossrefResultsNum > 0">
|
||||
<p > {{crossrefResultsNum }} Total Results </p>
|
||||
<paging-no-load [currentPage]="page" [totalResults]="crossrefResultsNum" [navigateTo]="navigateTo" [term]="keyword" [size]="size" (pageChange)="pageChange($event)"> </paging-no-load>
|
||||
</div>
|
||||
<div >
|
||||
<p *ngFor=" let item of crossrefResults "> <publication-title [title]="item.title" [url]="item.URL" > </publication-title> <button (click)="add(item,'crossref', 'publication', item.URL, item.title)" type="button" class="btn btn-default">Select</button> </p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="openaire" class="tab-pane fade">
|
||||
|
||||
<p>TODO put openaire results here...</p>
|
||||
</div>
|
||||
<div id="orcid" class="tab-pane fade">
|
||||
|
||||
<p *ngIf="orcidResultsNum == null"> No authors found for keyword: {{keyword}} </p>
|
||||
|
||||
<div *ngIf="orcidResultsNum != null">
|
||||
<p> Not the right author? Choose one of these: </p>
|
||||
|
||||
<li class="dropdown">
|
||||
<a href="" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Selected: {{authorGivenName}} {{authorFamilyName}}<span class="caret"></span></a>
|
||||
<ul class="dropdown-menu">
|
||||
<li *ngFor=" let item of authorIds let i = index" (click)="getOrcidResultsById(i)" role="button">
|
||||
{{authorGivenNames[i]}} {{authorFamilyNames[i]}} : {{item}}
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
<div>
|
||||
|
||||
<br/>
|
||||
<h4> {{orcidResultsNum }} Total Results for author
|
||||
<a target="_blank" href="http://orcid.org/{{authorId}}"> {{authorGivenName}} {{authorFamilyName}} : {{authorId}} </a>
|
||||
</h4>
|
||||
<br/>
|
||||
|
||||
<div *ngIf=" ((orcidResultsNum >0) && (totalPages > 1) && ( 0 < page && page <= totalPages )) " >
|
||||
<paging-no-load [currentPage]="page" [totalResults]="orcidResultsNum" [navigateTo]="navigateTo" [term]="keyword" [size]="size" (pageChange)="orcidPageChange($event)"> </paging-no-load>
|
||||
|
||||
</div>
|
||||
|
||||
<div *ngIf=" orcidResultsNum > 0">
|
||||
<p *ngFor=" let item of orcidResultsToShow "> {{item['work-title']['title'].value}} ({{item['publication-date']['year'].value}}) </p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
|
@ -0,0 +1,205 @@
|
|||
import {Component, Input, Output, EventEmitter} from '@angular/core';
|
||||
import {JSONP_PROVIDERS} from '@angular/http';
|
||||
import {Observable} from 'rxjs/Observable';
|
||||
import { RouteParams, RouteConfig, ROUTER_DIRECTIVES, Router } from '@angular/router-deprecated';
|
||||
import {SearchCrossrefService} from '../../services/searchCrossref.service';
|
||||
import {SearchOrcidService} from '../../services/searchOrcid.service';
|
||||
import {Publication} from '../../entities/publication';
|
||||
import {pagingFormatterNoLoad} from '../../common/pagingFormatterNoLoad.component';
|
||||
import {PublicationTitleFormatter} from '../../common/publicationTitleFormatter.component';
|
||||
|
||||
|
||||
@Component({
|
||||
selector: 'claim-publication',
|
||||
directives: [...ROUTER_DIRECTIVES,pagingFormatterNoLoad, PublicationTitleFormatter],
|
||||
templateUrl: 'src/app/linking/claimPublication/claimPublication.component.html',
|
||||
providers:[JSONP_PROVIDERS, SearchCrossrefService, SearchOrcidService]
|
||||
})
|
||||
export class ClaimPublicationComponent {
|
||||
constructor (private _searchCrossrefService: SearchCrossrefService,private _searchOrcidService: SearchOrcidService,
|
||||
private _routeParams: RouteParams) {}
|
||||
ngOnInit() {
|
||||
let page = +this._routeParams.get('page');
|
||||
let size = +this._routeParams.get('size');
|
||||
this.page = ( page <= 0 ) ? 1 : page;
|
||||
this.size = ( size <= 0 ) ? 10 : size;
|
||||
if(this.keyword !=null && this.keyword.length > 0){
|
||||
this.search(this.keyword,this.size,this.page);
|
||||
}
|
||||
}
|
||||
|
||||
page : number = 1;
|
||||
size:number = 10;
|
||||
@Input() public keyword:string = "";
|
||||
navigateTo: string = "Search";
|
||||
source: string = "crossref";
|
||||
type : string = "publication";
|
||||
@Input() public select:boolean = true ;
|
||||
@Input() public selectedPublications = [] ;
|
||||
@Output() publicationsChange = new EventEmitter();
|
||||
|
||||
crossrefResults=[];
|
||||
crossrefResultsNum : Observable<number> ;
|
||||
|
||||
orcidResults: string[];
|
||||
orcidResultsNum: number ;
|
||||
totalPages: number;
|
||||
orcidResultsToShow: string[];
|
||||
|
||||
authorId: string;
|
||||
authorGivenName: string;
|
||||
authorFamilyName: string;
|
||||
|
||||
authorIds: string[];
|
||||
authorGivenNames: string[];
|
||||
authorFamilyNames: string[];
|
||||
|
||||
authorsNum : number ;
|
||||
|
||||
searchOrcid (term: string) {
|
||||
this.authorIds = new Array<string>();
|
||||
this.authorGivenNames = new Array<string>();
|
||||
this.authorFamilyNames = new Array<string>();
|
||||
|
||||
this.getOrcidAuthor(term);
|
||||
|
||||
console.info('searchOrcid in searchOrcid file');
|
||||
}
|
||||
|
||||
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("");
|
||||
}
|
||||
}
|
||||
|
||||
getOrcidAuthor (term: string) {
|
||||
this.orcidResultsNum = null;
|
||||
|
||||
this._searchOrcidService.searchOrcidAuthor(term).subscribe(
|
||||
data => {
|
||||
if(data[2] != null) {
|
||||
this.readData(data);
|
||||
this.getOrcidResultsById(0);
|
||||
}
|
||||
|
||||
},
|
||||
err => this.errorHandler(err, term)
|
||||
);
|
||||
}
|
||||
|
||||
errorHandler(err: any, term: string) {
|
||||
if(err.status == 404){
|
||||
this.getOrcidAuthors(term);
|
||||
} else {
|
||||
console.error(err.status);
|
||||
}
|
||||
}
|
||||
|
||||
getOrcidAuthors (term: string) {
|
||||
this.orcidResultsNum = null;
|
||||
|
||||
this._searchOrcidService.searchOrcidAuthors(term).subscribe(
|
||||
data => {
|
||||
if(data[2] != null) {
|
||||
this.readData(data);
|
||||
this.getOrcidResultsById(0);
|
||||
}
|
||||
},
|
||||
err => console.error(err)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
getOrcidResultsById (index:number) {
|
||||
let id = this.authorIds[index];
|
||||
|
||||
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.page = 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);
|
||||
} else {
|
||||
this.orcidResultsNum = 0;
|
||||
this.totalPages=0;
|
||||
}
|
||||
this.authorGivenName = this.authorGivenNames[index];
|
||||
this.authorFamilyName = this.authorFamilyNames[index];
|
||||
this.authorId = id;
|
||||
},
|
||||
err => console.error(err)
|
||||
);
|
||||
|
||||
console.info("totalPages = " +this.totalPages);
|
||||
}
|
||||
|
||||
search(term: string, size : number, page : number){
|
||||
this.getCrossrefResults(term,size,page);
|
||||
this.searchOrcid(term);
|
||||
|
||||
}
|
||||
|
||||
|
||||
getCrossrefResults (term: string, size : number, page : number) {
|
||||
this._searchCrossrefService.searchCrossrefResults(term, size, page).subscribe(
|
||||
data => {
|
||||
this.crossrefResults = data.items;
|
||||
this.page=page;
|
||||
this.crossrefResultsNum = data['total-results'];
|
||||
},
|
||||
err => console.error(err)
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
|
||||
add(item, itemSource, itemType, itemUrl, itemTitle){
|
||||
var result ={id: item.DOI, type :itemType, source : itemSource, title: itemTitle,url: itemUrl, result: item};
|
||||
console.info("Add result:"+result.id+" "+result.source+" "+item);
|
||||
this.selectedPublications.push(result);
|
||||
var index:number =this.crossrefResults.indexOf(item);
|
||||
if (index > -1) {
|
||||
this.crossrefResults.splice(index, 1);
|
||||
}
|
||||
this.publicationsChange.emit({
|
||||
value: this.selectedPublications
|
||||
});
|
||||
}
|
||||
remove(item){
|
||||
var index:number =this.selectedPublications.indexOf(item);
|
||||
if (index > -1) {
|
||||
this.selectedPublications.splice(index, 1);
|
||||
this.publicationsChange.emit({
|
||||
value: this.selectedPublications
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
pageChange($event) {
|
||||
this.page=$event.value;
|
||||
this.crossrefResults=[];
|
||||
this.getCrossrefResults(this.keyword,this.size,this.page);
|
||||
}
|
||||
orcidPageChange($event) {
|
||||
this.page=$event.value;
|
||||
this.orcidResultsToShow=[];
|
||||
this.orcidResultsToShow = this.orcidResults.slice(($event.value-1)*this.size, $event.value*this.size);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,95 @@
|
|||
import {Component, Input, Output, EventEmitter} from '@angular/core';
|
||||
import {JSONP_PROVIDERS} from '@angular/http';
|
||||
import {Observable} from 'rxjs/Observable';
|
||||
import { RouteParams, RouteConfig, ROUTER_DIRECTIVES, Router } from '@angular/router-deprecated';
|
||||
import {ClaimsService} from '../../services/claims.service';
|
||||
import {PublicationTitleFormatter} from '../../common/publicationTitleFormatter.component';
|
||||
|
||||
|
||||
@Component({
|
||||
selector: 'claim-insert',
|
||||
directives: [...ROUTER_DIRECTIVES],
|
||||
template: `
|
||||
|
||||
<button *ngIf="claiming == false" (click)="insert()">Claim</button>
|
||||
<div *ngIf="error == true"> {{errorMessage}}
|
||||
</div>
|
||||
|
||||
`,
|
||||
providers:[JSONP_PROVIDERS, ClaimsService]
|
||||
})
|
||||
export class ClaimInsertComponent {
|
||||
constructor (private claimService: ClaimsService) {}
|
||||
ngOnInit() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Input() contexts=[];
|
||||
@Input() projects=[];
|
||||
@Input() publications=[];
|
||||
@Input() datasets=[];
|
||||
|
||||
claiming =false;
|
||||
error = false;
|
||||
errorMessage = "";
|
||||
|
||||
/*
|
||||
|
||||
curl -H "Content-Type: application/json" -X POST -d '{ "claimedBy" : "katerina@di.uoa.gr", "sourceId" : "corda_______::2c37878a0cede85dbbd1081bb9b4a2f8", "sourceType" : "project", "sourceCollectedFrom":"openaire", "targetId" : "dedup_wf_001::092c0354ef18384b6fb3e7224bd32b76", "targetType" : "publication", "targetCollectedFrom":"openaire"}'
|
||||
*/
|
||||
insert(){
|
||||
this.claiming = true;
|
||||
var user="argirok@di.uoa.gr"
|
||||
if( this.datasets.length == 0 && this.publications.length == 0){
|
||||
this.errorMessage = "There are no publications or datasets selected.";
|
||||
this.error = true;
|
||||
}else if(this.contexts.length == 0 && this.projects.length == 0){
|
||||
this.errorMessage = "There are no projects or concepts to link.";
|
||||
this.error = true;
|
||||
}else{
|
||||
|
||||
for (var i = 0; i < this.publications.length; i++) {
|
||||
|
||||
var result=this.publications[i];
|
||||
|
||||
for (var j = 0; j < this.contexts.length; j++) {
|
||||
var context=this.contexts[j];
|
||||
|
||||
var claim = { claimedBy : user, sourceId : context.concept.id, sourceType : "context", sourceCollectedFrom:"openaire", targetId : result.id , targetType : result.type,
|
||||
targetCollectedFrom: result.source};
|
||||
console.info("Trying to insert..... " + claim.targetId );
|
||||
/*
|
||||
'{ "claimedBy" : "katerina@di.uoa.gr", "sourceId" : "corda_______::2c37878a0cede85dbbd1081bb9b4a2f8", "sourceType" : "project", "sourceCollectedFrom":"openaire",
|
||||
"targetId" : "dedup_wf_001::092c0354ef18384b6fb3e7224bd32b76", "targetType" : "publication", "targetCollectedFrom":"openaire"}'
|
||||
*/
|
||||
this.claimService.insertClaim(claim).subscribe(
|
||||
data => {
|
||||
},
|
||||
err => console.error(err)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
for (var i = 0; i < this.datasets.length; i++) {
|
||||
|
||||
var result=this.datasets[i];
|
||||
|
||||
for (var j = 0; j < this.contexts.length; j++) {
|
||||
var context=this.contexts[j];
|
||||
|
||||
var claim = { claimedBy : user, sourceId : context.concept.id, sourceType : "context", sourceCollectedFrom:"openaire", targetId : result.id , targetType : result.type, targetCollectedFrom: result.source};
|
||||
this.claimService.insertClaim(claim).subscribe(
|
||||
data => {
|
||||
},
|
||||
err => console.error(err)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
// claimService
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,123 @@
|
|||
import {Component, Input} from '@angular/core';
|
||||
import {JSONP_PROVIDERS} from '@angular/http';
|
||||
import {Observable} from 'rxjs/Observable';
|
||||
import { RouteParams, RouteConfig, ROUTER_DIRECTIVES, Router } from '@angular/router-deprecated';
|
||||
import {ClaimContextComponent} from './claimContext/claimContext.component';
|
||||
import {ClaimPublicationComponent} from './claimPublication/claimPublication.component';
|
||||
import {ClaimDatasetComponent} from './claimDataset/claimDataset.component';
|
||||
import {ClaimSelectedComponent} from './selected/selected.component';
|
||||
import {ClaimInsertComponent} from './insertClaim/insertClaim.component';
|
||||
|
||||
@Component({
|
||||
selector: 'linking',
|
||||
directives: [ROUTER_DIRECTIVES, ClaimContextComponent, ClaimPublicationComponent, ClaimSelectedComponent, ClaimInsertComponent,ClaimDatasetComponent],
|
||||
template: `
|
||||
<h1>Linking...</h1>
|
||||
<div class="row" >
|
||||
<div class="col-sm-6">
|
||||
<div *ngIf=" show=='result' " >
|
||||
<input [(ngModel)]="keyword"/>
|
||||
<button (click)="search()" type="button" class="btn btn-default">Search</button>
|
||||
<div class="resultType">
|
||||
<input #publication name="searchType" type="radio" [checked]="searchType === 'publication'" value="publication" (click)="searchType = publication.value" />Publication
|
||||
<input #dataset name="searchType" [checked]="searchType === 'dataset'" type="radio" value="dataset" (click)="searchType = dataset.value" />Dataset
|
||||
</div>
|
||||
</div>
|
||||
<div *ngIf=" show=='publication' ">
|
||||
<claim-publication [keyword]="keyword" [selectedPublications]="publications" (publicationsCahnge)="publicationsChange($event)" > </claim-publication>
|
||||
</div>
|
||||
<div *ngIf=" show=='dataset' " >
|
||||
<claim-dataset [keyword]="keyword" [selectedDatasets]="datasets" (datasetsCahnge)="datasetsChange($event)" > </claim-dataset>
|
||||
</div>
|
||||
|
||||
|
||||
<div *ngIf=" show == 'context'" >
|
||||
<claim-contexts [selectedList]="contexts" (contextsChange)="contextsChange($event)" > </claim-contexts>
|
||||
</div>
|
||||
<div *ngIf=" show == 'claim'" >
|
||||
<claim-insert [contexts]="contexts" [publications]="publications" [datasets]="datasets" [projects]="projects" ></claim-insert>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-6">
|
||||
<claim-selected [contexts]="contexts" [publications]="publications" [datasets]="datasets" [projects]="projects" > </claim-selected>
|
||||
</div>
|
||||
</div>
|
||||
<button *ngIf="show != 'result'" (click)="prev()">Prev</button>
|
||||
|
||||
<button *ngIf="show != 'claim'" (click)="next()">Next</button>
|
||||
|
||||
`
|
||||
|
||||
})
|
||||
|
||||
export class LinkingComponent {
|
||||
constructor ( private _router: Router ) {
|
||||
}
|
||||
sourceType:string;
|
||||
targetType:string;
|
||||
step:number = 1;
|
||||
contexts=[];
|
||||
projects=[];
|
||||
publications=[];
|
||||
datasets=[];
|
||||
show = "result";
|
||||
searchType="publication";
|
||||
keyword: string = "";
|
||||
ngOnInit() {
|
||||
|
||||
}
|
||||
next(){
|
||||
|
||||
if((this.show == 'result' && this.keyword == '')||(this.show == 'dataset' || this.show == 'publication')){
|
||||
this.show='context';
|
||||
}else if(this.show == 'result' ){
|
||||
if(this.searchType == 'publication' ){
|
||||
this.show="publication";
|
||||
}else{
|
||||
this.show="dataset";
|
||||
}
|
||||
}else if(this.show == 'context'){
|
||||
this.show='claim';
|
||||
}
|
||||
}
|
||||
prev(){
|
||||
if(this.show == 'context'){
|
||||
this.show='result';
|
||||
}else if(this.show == 'dataset' || this.show == 'publication'){
|
||||
this.show='result';
|
||||
} else if(this.show == 'claim'){
|
||||
this.show='context';
|
||||
}
|
||||
}
|
||||
goto(term: string) {
|
||||
this._router.navigate( ['Search', { keyword: term }] );
|
||||
}
|
||||
|
||||
search() {
|
||||
if(this.searchType == 'publication' ){
|
||||
this.show="publication";
|
||||
}else{
|
||||
this.show="dataset";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
sourceTypeChange($event) {
|
||||
this.sourceType=$event.value;
|
||||
console.log($event.value);
|
||||
}
|
||||
targetTypeChange($event) {
|
||||
this.targetType=$event.value;
|
||||
console.log($event.value);
|
||||
}
|
||||
contextsChange($event) {
|
||||
this.contexts=$event.value;
|
||||
console.log($event.value);
|
||||
}
|
||||
publicationsChange($event) {
|
||||
this.publications=$event.value;
|
||||
}
|
||||
datasetsChange($event) {
|
||||
this.datasets=$event.value;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
import {Component, Input,Output} from '@angular/core';
|
||||
import {PublicationTitleFormatter} from '../../common/publicationTitleFormatter.component';
|
||||
@Component({
|
||||
selector: 'claim-selected',
|
||||
template: `
|
||||
<div *ngIf="publications.length > 0 " class="publications" >
|
||||
<h5>Selected Publications:</h5>
|
||||
<i *ngFor="let pub of publications" >Source: {{pub.source}} - Title: <publication-title [title]="pub.title" [url]="pub.url" > </publication-title> </i>
|
||||
</div>
|
||||
<div *ngIf="contexts.length > 0 " class="concepts" >
|
||||
<h5>Selected Concepts:</h5>
|
||||
<i *ngFor="let context of contexts" >Community: {{context.community}} - Category: {{context.category}} </i>
|
||||
</div>
|
||||
<div *ngIf="projects.length > 0 " class="conprojectscepts" >
|
||||
<h5>Selected projects:</h5>
|
||||
<i *ngFor="let projects of projects" >Project: </i>
|
||||
</div>
|
||||
<div *ngIf="datasets.length > 0 " class="datasets" >
|
||||
<h5>Selected datasets:</h5>
|
||||
<i *ngFor="let dataset of datasets" > Datasets: Source: {{dataset.source}} - Title: <publication-title [title]="dataset.title" [url]="dataset.url" > </publication-title> </i>
|
||||
</div>
|
||||
<i>TODO: add more types</i>
|
||||
`,
|
||||
directives: [ PublicationTitleFormatter]
|
||||
|
||||
|
||||
})
|
||||
export class ClaimSelectedComponent {
|
||||
ngOnInit() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Input() contexts=[];
|
||||
@Input() projects=[];
|
||||
@Input() publications=[];
|
||||
@Input() datasets=[];
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
import {Pipe, PipeTransform} from '@angular/core';
|
||||
|
||||
@Pipe({
|
||||
name: 'claimTextFilter'
|
||||
})
|
||||
export class ClaimTextFilterPipe implements PipeTransform {
|
||||
|
||||
transform(value: any, filter: string): any {
|
||||
console.debug('ClaimTextFilterPipe word to filter : '+filter);
|
||||
filter = filter?filter.toLocaleLowerCase():'';
|
||||
return filter ? value.filter(claim=> (
|
||||
claim.sourceType.toLocaleLowerCase().indexOf(filter)!=-1|| //sourceType
|
||||
claim.targetType.toLocaleLowerCase().indexOf(filter)!=-1|| //targetType
|
||||
claim.userMail.toLocaleLowerCase().indexOf(filter)!=-1|| //mail
|
||||
((claim.source.title && claim.source.title.toLocaleLowerCase().indexOf(filter)!=-1)||(claim.source.name && claim.source.name.toLocaleLowerCase().indexOf(filter)!=-1))|| //source title
|
||||
((claim.target.title && claim.target.title.toLocaleLowerCase().indexOf(filter)!=-1)||(claim.target.name && claim.target.name.toLocaleLowerCase().indexOf(filter)!=-1))|| //target title
|
||||
((claim.source.funderName && claim.source.funderName.toLocaleLowerCase().indexOf(filter)!=-1)||(claim.source.funderName && claim.source.funderName.toLocaleLowerCase().indexOf(filter)!=-1))|| //source funder name
|
||||
((claim.target.funderName && claim.target.funderName.toLocaleLowerCase().indexOf(filter)!=-1)||(claim.target.funderName && claim.target.funderName.toLocaleLowerCase().indexOf(filter)!=-1)) //target funder name
|
||||
)) : value;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
|
||||
import {Pipe, PipeTransform} from '@angular/core';
|
||||
|
||||
@Pipe({name: 'claimTypeFilter'})
|
||||
export class ClaimTypeFilterPipe implements PipeTransform {
|
||||
transform(value: any, publication:boolean,dataset:boolean,project:boolean,context:boolean) : any {
|
||||
let filter = publication;
|
||||
console.debug('ClaimTypeFilterPipe types to show : '+(publication?'publication ':' ')+(dataset?'dataset ':' ')+(project?'project ':' ')+(context?'context ':' '));
|
||||
return (value)?value.filter((claim) =>{
|
||||
let filter =publication;
|
||||
if(publication||dataset||project||context) {
|
||||
let filter = publication
|
||||
if(filter && (claim.sourceType.toLocaleLowerCase().indexOf('publication')!=-1 || claim.targetType.toLocaleLowerCase().indexOf('publication')!=-1 )) {
|
||||
return true;
|
||||
}
|
||||
filter = dataset;
|
||||
if(filter && (claim.sourceType.toLocaleLowerCase().indexOf('dataset')!=-1 || claim.targetType.toLocaleLowerCase().indexOf('dataset')!=-1 )) {
|
||||
return true;
|
||||
}
|
||||
filter = project;
|
||||
if(filter && (claim.sourceType.toLocaleLowerCase().indexOf('project')!=-1 || claim.targetType.toLocaleLowerCase().indexOf('project')!=-1 )) {
|
||||
return true;
|
||||
}
|
||||
filter = context;
|
||||
if(filter && (claim.sourceType.toLocaleLowerCase().indexOf('context')!=-1 || claim.targetType.toLocaleLowerCase().indexOf('context')!=-1 )) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}else{
|
||||
return true;
|
||||
}
|
||||
}):value;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,77 @@
|
|||
import {Component} from '@angular/core';
|
||||
import {JSONP_PROVIDERS} from '@angular/http';
|
||||
import {Observable} from 'rxjs/Observable';
|
||||
import { RouteParams, RouteConfig, ROUTER_DIRECTIVES, Router } from '@angular/router-deprecated';
|
||||
import {SearchCrossrefService} from '../services/searchCrossref.service';
|
||||
import {Publication} from '../entities/publication';
|
||||
import {PagingFormatter} from '../common/pagingFormatter.component';
|
||||
import {PublicationTitleFormatter} from '../common/publicationTitleFormatter.component';
|
||||
import {SearchAllComponent} from '../searchAll/searchAll.component';
|
||||
|
||||
@Component({
|
||||
selector: 'search',
|
||||
directives: [...ROUTER_DIRECTIVES,PagingFormatter, PublicationTitleFormatter,SearchAllComponent],
|
||||
template: `
|
||||
<h1>Search Demo</h1>
|
||||
<p><i>Fetches from crossref </i></p>
|
||||
<input #term [(ngModel)]="keyword"/>
|
||||
<button (click)="search(term.value,10,1)" type="button" class="btn btn-default">Click</button>
|
||||
<div>
|
||||
<div *ngIf="resultsNum != null && resultsNum > 0">
|
||||
<p > {{resultsNum }} Total Results </p>
|
||||
<paging [currentPage]="page" [totalResults]="resultsNum" [navigateTo]="navigateTo" [term]="keyword" [size]="size"> </paging>
|
||||
</div>
|
||||
<div >
|
||||
<p *ngFor=" let item of results "> <publication-title [title]="item.title" [url]="item.URL" > </publication-title> {{item.DOI}} --{{item.publisher}} </p>
|
||||
</div>
|
||||
</div>
|
||||
<!--<p>Directive....</p>
|
||||
<search-all [source]="crossref" [type]="true" [claim]="false" ><search-all>-->
|
||||
|
||||
|
||||
`,
|
||||
providers:[JSONP_PROVIDERS, SearchCrossrefService]
|
||||
})
|
||||
export class SearchComponent {
|
||||
constructor (private _searchService: SearchCrossrefService,
|
||||
private _routeParams: RouteParams) {
|
||||
console.info('search constructor');
|
||||
}
|
||||
ngOnInit() {
|
||||
console.info('search init');
|
||||
|
||||
let page = +this._routeParams.get('page');
|
||||
let size = +this._routeParams.get('size');
|
||||
this.page = ( page <= 0 ) ? 1 : page;
|
||||
this.size = ( size <= 0 ) ? 10 : size;
|
||||
this.keyword = this._routeParams.get('keyword');
|
||||
if(this.keyword !=null){
|
||||
this.search(this.keyword,this.size,this.page);
|
||||
}
|
||||
}
|
||||
|
||||
page : number;
|
||||
size:number;
|
||||
keyword:string;
|
||||
navigateTo: string = "Search";
|
||||
|
||||
results : String[];
|
||||
orcidresults : String[];
|
||||
resultsNum : number ;
|
||||
search (term: string, size : number, page : number) {
|
||||
this.getCrossrefResults(term,size,page);
|
||||
}
|
||||
|
||||
|
||||
getCrossrefResults (term: string, size : number, page : number) {
|
||||
this._searchService.searchCrossrefResults(term, size, page).subscribe(
|
||||
data => {
|
||||
this.results = data.items;
|
||||
this.page=page;
|
||||
this.resultsNum = data['total-results'];
|
||||
},
|
||||
err => console.error(err)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,126 @@
|
|||
import {Component, Input, Output, EventEmitter} from '@angular/core';
|
||||
import {JSONP_PROVIDERS} from '@angular/http';
|
||||
import {Observable} from 'rxjs/Observable';
|
||||
import { RouteParams, RouteConfig, ROUTER_DIRECTIVES, Router } from '@angular/router-deprecated';
|
||||
import {SearchCrossrefService} from '../services/searchCrossref.service';
|
||||
import {Publication} from '../entities/publication';
|
||||
import {PagingFormatter} from '../common/pagingFormatter.component';
|
||||
import {PublicationTitleFormatter} from '../common/publicationTitleFormatter.component';
|
||||
|
||||
|
||||
@Component({
|
||||
selector: 'search-all',
|
||||
directives: [...ROUTER_DIRECTIVES,PagingFormatter, PublicationTitleFormatter],
|
||||
template: `
|
||||
|
||||
|
||||
<div *ngIf="claim">
|
||||
<h3>Selected publications:</h3>
|
||||
<p *ngFor=" let item of selected "> <publication-title [title]="item.title" [url]="item.URL" > </publication-title> {{item.DOI}} --{{item.publisher}} <button (click)="remove(item)" type="button" class="btn btn-default">Remove</button></p>
|
||||
</div>
|
||||
|
||||
<h1>Search</h1>
|
||||
<input #term [(ngModel)]="keyword"/>
|
||||
<button (click)="search(term)" type="button" class="btn btn-default">Search</button>
|
||||
|
||||
<div>
|
||||
<div *ngIf="resultsNum != null && resultsNum > 0">
|
||||
<p > {{resultsNum }} Total Results </p>
|
||||
<paging [currentPage]="page" [totalResults]="resultsNum" [navigateTo]="navigateTo" [term]="keyword" [size]="size"> </paging>
|
||||
</div>
|
||||
<div >
|
||||
|
||||
<p *ngFor=" let item of results "> <publication-title [title]="item.title" [url]="item.URL" > </publication-title> {{item.DOI}} --{{item.publisher}} <button *ngIf="claim" (click)="add(item)" type="button" class="btn btn-default">Select</button> </p>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
`,
|
||||
providers:[JSONP_PROVIDERS, SearchCrossrefService]
|
||||
})
|
||||
export class SearchAllComponent {
|
||||
constructor (private _searchService: SearchCrossrefService,
|
||||
private _routeParams: RouteParams) {}
|
||||
ngOnInit() {
|
||||
let page = +this._routeParams.get('page');
|
||||
let size = +this._routeParams.get('size');
|
||||
this.page = ( page <= 0 ) ? 1 : page;
|
||||
this.size = ( size <= 0 ) ? 10 : size;
|
||||
this.keyword = this._routeParams.get('keyword');
|
||||
if(this.keyword !=null){
|
||||
this.searchCrossref(this.keyword,this.size,this.page);
|
||||
}
|
||||
}
|
||||
|
||||
page : number;
|
||||
size:number;
|
||||
keyword:string;
|
||||
navigateTo: string = "Search";
|
||||
|
||||
@Input() public claim:boolean = true ; // add selection for claiming
|
||||
@Input() public publication:boolean = true ; // true for publication/ false for dataset
|
||||
@Input() public source:string = 'openaire' ; // other values : crossref/ datacite/orcid
|
||||
@Input() public selected = [] ;
|
||||
@Output() selectedChange = new EventEmitter();
|
||||
results:string[];
|
||||
resultsNum : Observable<number> ;
|
||||
search(term: string, size : number, page : number) {
|
||||
// if(this.source == 'crossref' && this.publication){
|
||||
this.searchCrossref(term,size,page);
|
||||
// }else if(this.source == 'openaire' && this.publication){
|
||||
//
|
||||
// }else if(this.source == 'openaire' && this.publication){
|
||||
//
|
||||
// }else if(this.source == 'openaire' && !this.publication){
|
||||
//
|
||||
// }else if(this.source == 'orcid' && this.publication){
|
||||
//
|
||||
// }else if(this.source == 'datacite' && !this.publication){
|
||||
//
|
||||
// }
|
||||
}
|
||||
searchCrossref (term: string, size : number, page : number) {
|
||||
this._searchService.searchCrossrefResults(term, size, page).subscribe(
|
||||
data => {
|
||||
this.results = data.items;
|
||||
this.page=page;
|
||||
this.resultsNum = data['total-results'];
|
||||
},
|
||||
err => console.error(err)
|
||||
);
|
||||
}
|
||||
searchOpenaire (term2: string) {
|
||||
//this.items = this._searchService.httpSearchOpenaire(term2);
|
||||
}
|
||||
|
||||
|
||||
|
||||
add(item){
|
||||
this.selected.push(item);
|
||||
console.info("Select:"+this.selected);
|
||||
for (var i = 0; i < this.selected.length; i++) {
|
||||
console.log(this.selected[i]);
|
||||
}
|
||||
|
||||
|
||||
var index:number =this.results.indexOf(item);
|
||||
if (index > -1) {
|
||||
this.results.splice(index, 1);
|
||||
}
|
||||
console.info("Item removed "+this.selected.indexOf(item));
|
||||
this.selectedChange.emit({
|
||||
value: this.selected
|
||||
});
|
||||
}
|
||||
remove(item){
|
||||
var index:number =this.selected.indexOf(item);
|
||||
if (index > -1) {
|
||||
this.selected.splice(index, 1);
|
||||
}
|
||||
this.selectedChange.emit({
|
||||
value: this.selected
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,101 @@
|
|||
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 '../entities/claim';
|
||||
|
||||
@Injectable()
|
||||
export class ClaimsService {
|
||||
// baseUrl='http://rudie.di.uoa.gr:8080/dnet-openaire-connector-service-1.0.0-SNAPSHOT/rest/claimsService/';
|
||||
baseUrl='http://scoobydoo.di.uoa.gr:8181/dnet-openaire-connector-service-1.0.0-SNAPSHOT/rest/claimsService/';
|
||||
constructor(private jsonp: Jsonp, private http: Http) {
|
||||
|
||||
}
|
||||
|
||||
private getClaimRequest(size : number, page : number, url :string):any {
|
||||
console.debug('ClaimsService: Claims request: '+url);
|
||||
return this.http.get( url)
|
||||
.map(request => <any> request.json())
|
||||
.do(request => console.info("Get claims: offset = "+(size*(page-1)) + " limit ="+size ))
|
||||
.catch(this.handleError);
|
||||
}
|
||||
getClaims( size : number, page : number, keyword:string, sortby: string, descending: boolean, types: string):any {
|
||||
console.debug('ClaimsService: getClaims ' );
|
||||
console.debug('ClaimsService: Types : '+types );
|
||||
let url = this.baseUrl +"claims"+"?offset="+(size*(page-1) + "&limit="+size)+"&keyword="+keyword+"&sortby="+sortby+"&descending="+descending+"&types="+types;
|
||||
return this.getClaimRequest(size,page,url);
|
||||
|
||||
}
|
||||
getClaimsByUser( size : number, page : number, user:string, keyword:string, sortby: string, descending: boolean, types: string):any {
|
||||
console.debug('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="+types;
|
||||
return this.getClaimRequest(size,page,url);
|
||||
|
||||
}
|
||||
getClaimsBycontext( size : number, page : number, contextId:string, keyword:string, sortby: string, descending: boolean, types: string):any {
|
||||
console.debug('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="+types;
|
||||
return this.getClaimRequest(size,page,url);
|
||||
|
||||
}
|
||||
getClaimsByResult( size : number, page : number, resultId:string, keyword:string, sortby: string, descending: boolean, types: string):any {
|
||||
console.debug('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="+types;
|
||||
return this.getClaimRequest(size,page,url);
|
||||
|
||||
}
|
||||
getClaimsByProject( size : number, page : number, projectId:string, keyword:string, sortby: string, descending: boolean, types: string):any {
|
||||
console.debug('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="+types;
|
||||
return this.getClaimRequest(size,page,url);
|
||||
}
|
||||
|
||||
deleteClaimById(claimId:string):any{
|
||||
console.warn('Trying to delete claim with id : '+claimId);
|
||||
let url = this.baseUrl +"claims/"+claimId;
|
||||
console.warn('Delete url: '+url);
|
||||
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);
|
||||
|
||||
}
|
||||
insertClaim(claim):any{
|
||||
console.warn('Trying toinsert claim : '+claim);
|
||||
let url = this.baseUrl +"claims";
|
||||
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);
|
||||
|
||||
}
|
||||
|
||||
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.error(error);
|
||||
return Observable.throw(error || 'Server error');
|
||||
}
|
||||
|
||||
getClaim(id:string):any {
|
||||
let url = this.baseUrl+"claims/"+id;
|
||||
return new Promise((resolve, reject) => {
|
||||
this.http.get(url)
|
||||
.map(res => res.json())
|
||||
.subscribe(
|
||||
data => {
|
||||
resolve(data.data);
|
||||
},
|
||||
err => {
|
||||
reject(err);
|
||||
}
|
||||
)
|
||||
;
|
||||
});
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
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 '../entities/claim';
|
||||
|
||||
@Injectable()
|
||||
export class ContextsService {
|
||||
// baseUrl='http://rudie.di.uoa.gr:8080/dnet-openaire-connector-service-1.0.0-SNAPSHOT/rest/claimsService/';
|
||||
baseUrl='http://scoobydoo.di.uoa.gr:8181/dnet-openaire-connector-service-1.0.0-SNAPSHOT/rest/claimsService/';
|
||||
//'http://rudie.di.uoa.gr:8080/dnet-openaire-connector-service-1.0.0-SNAPSHOT/rest/claimsService/communities';
|
||||
//http://rudie.di.uoa.gr:8080/dnet-openaire-connector-service-1.0.0-SNAPSHOT/rest/claimsService/communities/egi/categories
|
||||
//http://rudie.di.uoa.gr:8080/dnet-openaire-connector-service-1.0.0-SNAPSHOT/rest/claimsService/categories/egi::classification/concepts
|
||||
constructor(private http: Http) {
|
||||
|
||||
}
|
||||
|
||||
public getCommunities():any {
|
||||
let url = this.baseUrl + 'communities';
|
||||
console.debug('ContextsService: request communities '+url);
|
||||
return this.http.get( url)
|
||||
.map(request => <any> request.json().data)
|
||||
.do(request => console.info("Get claims: offset = "))
|
||||
.catch(this.handleError);
|
||||
}
|
||||
public getCategories(communityId :string):any {
|
||||
console.debug('ContextsService: request categories for community with id '+communityId);
|
||||
let url= this.baseUrl + 'communities/' + communityId + '/categories';
|
||||
return this.http.get( url)
|
||||
.map(request => <any> request.json().data)
|
||||
.do(request => console.info("Get claims: offset = " ))
|
||||
.catch(this.handleError);
|
||||
}
|
||||
public getConcepts(categoryId :string, keyword: string):any {
|
||||
console.debug('ContextsService: request concept for category with id '+categoryId + ' and keyword '+ keyword);
|
||||
let url= this.baseUrl + 'categories/' + categoryId+ "/concepts";
|
||||
return this.http.get( url)
|
||||
.map(request => <any> request.json().data)
|
||||
.do(request => console.info("Get claims: offset = " ))
|
||||
.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.error(error);
|
||||
return Observable.throw(error || 'Server error');
|
||||
}
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
import {Injectable} from '@angular/core';
|
||||
// import {Http, Response, Headers} from '@angular/http';
|
||||
import {Http, Response} from '@angular/http';
|
||||
import {Observable} from 'rxjs/Observable';
|
||||
// import {Publication} from '../entities/publication';
|
||||
@Injectable()
|
||||
export class SearchCrossrefService {
|
||||
constructor( private http: Http) {}
|
||||
|
||||
|
||||
searchCrossrefResults (term: string, size : number, page : number):any {
|
||||
let url = 'http://api.crossref.org/works?query='+term+'&rows='+size+'&offset='+(size*(page-1));
|
||||
////"&rows=".$size."&offset=".($page-1)*$size
|
||||
return this.http.get( url)
|
||||
.map(request => <any> request.json().message)
|
||||
.do(items => console.log("Crossref Results: total results = "+items['total-results']+" keyword = "+term))
|
||||
.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.error(error);
|
||||
return Observable.throw(error || 'Server error');
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
import {Injectable} from '@angular/core';
|
||||
import {Jsonp, URLSearchParams} from '@angular/http';
|
||||
import {Http, Response} from '@angular/http';
|
||||
import {Observable} from 'rxjs/Observable';
|
||||
|
||||
@Injectable()
|
||||
export class SearchDataciteService {
|
||||
constructor(private jsonp: Jsonp, private http: Http) {}
|
||||
|
||||
searchDataciteResults (term: string, size : number, page : number):any {
|
||||
console.info("In search datacite results "+term);
|
||||
let url = 'http://search.datacite.org/api?q='+term+'&fl=doi,title,creator,publisher&wt=json&rows='+size+'&start='+(size*(page-1));
|
||||
|
||||
return this.http.get( url)
|
||||
.map(request => <any> request.json().response)
|
||||
.do(items => console.log("Datacite Results: total results = "+items['numFound']+" keyword = "+term))
|
||||
.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.error(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,54 @@
|
|||
import {Injectable} from '@angular/core';
|
||||
import {Jsonp, URLSearchParams} from '@angular/http';
|
||||
import {Http, Response} from '@angular/http';
|
||||
import { Headers, RequestOptions } from '@angular/http';
|
||||
import {Observable} from 'rxjs/Observable';
|
||||
|
||||
@Injectable()
|
||||
export class SearchOrcidService {
|
||||
constructor(private jsonp: Jsonp, private http: Http) {}
|
||||
|
||||
searchOrcidAuthor (term: string):any {
|
||||
console.info("In searchOrcidAuthor: "+term);
|
||||
|
||||
var headers = new Headers();
|
||||
headers.append('Accept', 'application/orcid+json');
|
||||
|
||||
let url = 'https://pub.orcid.org/'+term+'/orcid-bio';
|
||||
|
||||
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']]);
|
||||
}
|
||||
|
||||
searchOrcidAuthors (term: string):any {
|
||||
console.info("In search Orcid authors for keyword: "+term);
|
||||
|
||||
var headers = new Headers();
|
||||
headers.append('Accept', 'application/orcid+json');
|
||||
|
||||
let url = 'https://pub.orcid.org/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';
|
||||
|
||||
return this.http.get(url, { headers: headers })
|
||||
.map(res => res.json()['orcid-search-results'])
|
||||
.flatMap(res => res['orcid-search-result'])
|
||||
.map(res => res['orcid-profile'])
|
||||
.map(res => [res['orcid-bio']['personal-details']['given-names'],
|
||||
res['orcid-bio']['personal-details']['family-name'],
|
||||
res['orcid-identifier']]);
|
||||
}
|
||||
|
||||
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 = 'https://pub.orcid.org/'+id+'/orcid-works';
|
||||
|
||||
return this.http.get(url, { headers: headers })
|
||||
.map(res => res.json()['orcid-profile']['orcid-activities']['orcid-works'])
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
import 'angular2-universal/polyfills';
|
||||
|
||||
import {bootstrap, enableProdMode, BROWSER_ROUTER_PROVIDERS, BROWSER_HTTP_PROVIDERS} from 'angular2-universal';
|
||||
|
||||
import {App} from './app/app.component';
|
||||
|
||||
enableProdMode();
|
||||
|
||||
bootstrap(App, [
|
||||
...BROWSER_ROUTER_PROVIDERS,
|
||||
...BROWSER_HTTP_PROVIDERS
|
||||
]);
|
|
@ -0,0 +1,26 @@
|
|||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>OpenAIRE</title>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="description" content="Open Access Infrastructure for Europe ">
|
||||
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
|
||||
<script src="node_modules/bootstrap/dist/js/bootstrap.min.js" ></script>
|
||||
|
||||
<link rel="stylesheet" href="node_modules/bootstrap/dist/css/bootstrap.min.css">
|
||||
<link rel="icon" href="data:;base64,iVBORw0KGgo=">
|
||||
|
||||
<base href="/">
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<app>
|
||||
... Loading ...
|
||||
</app>
|
||||
|
||||
<script defer src="https://code.getmdl.io/1.1.3/material.min.js"></script>
|
||||
<script src="/dist/client/bundle.js"></script>
|
||||
</body>
|
||||
</html>
|
Binary file not shown.
After Width: | Height: | Size: 22 KiB |
|
@ -0,0 +1,79 @@
|
|||
import 'angular2-universal/polyfills';
|
||||
|
||||
import * as path from 'path';
|
||||
import * as express from 'express';
|
||||
import * as bodyParser from 'body-parser';
|
||||
|
||||
// Angular 2 Universal
|
||||
import {
|
||||
provide,
|
||||
enableProdMode,
|
||||
expressEngine,
|
||||
REQUEST_URL,
|
||||
ORIGIN_URL,
|
||||
BASE_URL,
|
||||
NODE_ROUTER_PROVIDERS,
|
||||
NODE_HTTP_PROVIDERS,
|
||||
ExpressEngineConfig
|
||||
} from 'angular2-universal';
|
||||
|
||||
// Application
|
||||
import {App} from './app/app.component';
|
||||
|
||||
const app = express();
|
||||
const ROOT = path.join(path.resolve(__dirname, '..'));
|
||||
|
||||
enableProdMode();
|
||||
|
||||
// Express View
|
||||
app.engine('.html', expressEngine);
|
||||
app.set('views', __dirname);
|
||||
app.set('view engine', 'html');
|
||||
|
||||
app.use(bodyParser.json());
|
||||
|
||||
|
||||
function ngApp(req, res) {
|
||||
let baseUrl = '/';
|
||||
let url = req.originalUrl || '/';
|
||||
|
||||
let config: ExpressEngineConfig = {
|
||||
directives: [ App ],
|
||||
platformProviders: [
|
||||
provide(ORIGIN_URL, {useValue: 'http://localhost:3000'}),
|
||||
provide(BASE_URL, {useValue: baseUrl}),
|
||||
],
|
||||
providers: [
|
||||
provide(REQUEST_URL, {useValue: url}),
|
||||
NODE_ROUTER_PROVIDERS,
|
||||
NODE_HTTP_PROVIDERS,
|
||||
],
|
||||
async: true,
|
||||
preboot: false // { appRoot: 'app' } // your top level app component selector
|
||||
};
|
||||
|
||||
res.render('index', config);
|
||||
}
|
||||
|
||||
function indexFile(req, res) {
|
||||
res.sendFile('/index.html', {root: __dirname});
|
||||
}
|
||||
|
||||
// Serve static files
|
||||
app.use(express.static(ROOT, {index: false}));
|
||||
|
||||
// Our API for demos only
|
||||
app.get('/data.json', (req, res) => {
|
||||
res.json({
|
||||
data: 'This fake data came from the server.'
|
||||
});
|
||||
});
|
||||
|
||||
// Routes with html5pushstate
|
||||
app.use('/', ngApp);
|
||||
app.use('/home', ngApp);
|
||||
app.use('/search', ngApp);
|
||||
// Server
|
||||
app.listen(3000, () => {
|
||||
console.log('Listening on: http://localhost:3000');
|
||||
});
|
|
@ -0,0 +1,74 @@
|
|||
/*
|
||||
* Custom Type Definitions
|
||||
* When including 3rd party modules you also need to include the type definition for the module
|
||||
* if they don't provide one within the module. You can try to install it with typings
|
||||
typings install node --save
|
||||
* If you can't find the type definition in the registry we can make an ambient definition in
|
||||
* this file for now. For example
|
||||
declare module "my-module" {
|
||||
export function doesSomething(value: string): string;
|
||||
}
|
||||
*
|
||||
* If you're prototying and you will fix the types later you can also declare it as type any
|
||||
*
|
||||
declare var assert: any;
|
||||
*
|
||||
* If you're importing a module that uses Node.js modules which are CommonJS you need to import as
|
||||
*
|
||||
import * as _ from 'lodash'
|
||||
* You can include your type definitions in this file until you create one for the typings registry
|
||||
* see https://github.com/typings/registry
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
// Extra variables that live on Global that will be replaced by webpack DefinePlugin
|
||||
declare var ENV: string;
|
||||
declare var HMR: boolean;
|
||||
interface GlobalEnvironment {
|
||||
ENV;
|
||||
HMR;
|
||||
}
|
||||
|
||||
interface WebpackModule {
|
||||
hot: {
|
||||
data?: any,
|
||||
idle: any,
|
||||
accept(dependencies?: string | string[], callback?: (updatedDependencies?: any) => void): void;
|
||||
decline(dependencies?: string | string[]): void;
|
||||
dispose(callback?: (data?: any) => void): void;
|
||||
addDisposeHandler(callback?: (data?: any) => void): void;
|
||||
removeDisposeHandler(callback?: (data?: any) => void): void;
|
||||
check(autoApply?: any, callback?: (err?: Error, outdatedModules?: any[]) => void): void;
|
||||
apply(options?: any, callback?: (err?: Error, outdatedModules?: any[]) => void): void;
|
||||
status(callback?: (status?: string) => void): void | string;
|
||||
removeStatusHandler(callback?: (status?: string) => void): void;
|
||||
};
|
||||
}
|
||||
|
||||
interface WebpackRequire {
|
||||
context(file: string, flag?: boolean, exp?: RegExp): any;
|
||||
}
|
||||
|
||||
|
||||
interface ErrorStackTraceLimit {
|
||||
stackTraceLimit: number;
|
||||
}
|
||||
|
||||
|
||||
// Extend typings
|
||||
interface NodeRequire extends WebpackRequire {}
|
||||
interface ErrorConstructor extends ErrorStackTraceLimit {}
|
||||
interface NodeModule extends WebpackModule {}
|
||||
interface Global extends GlobalEnvironment {}
|
||||
|
||||
|
||||
interface Thenable<T> {
|
||||
then<U>(
|
||||
onFulfilled?: (value: T) => U | Thenable<U>,
|
||||
onRejected?: (error: any) => U | Thenable<U>): Thenable<U>;
|
||||
then<U>(
|
||||
onFulfilled?: (value: T) => U | Thenable<U>,
|
||||
onRejected?: (error: any) => void): Thenable<U>;
|
||||
catch<U>(onRejected?: (error: any) => U | Thenable<U>): Thenable<U>;
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"emitDecoratorMetadata": true,
|
||||
"experimentalDecorators": true,
|
||||
"target": "es5",
|
||||
"module": "commonjs",
|
||||
"removeComments": true,
|
||||
"sourceMap": true
|
||||
},
|
||||
"exclude": [
|
||||
"typings/main.d.ts",
|
||||
"typings/main",
|
||||
"node_modules"
|
||||
],
|
||||
"compileOnSave": false,
|
||||
"buildOnSave": false,
|
||||
"atom": { "rewriteTsconfig": false }
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"ambientDependencies": {
|
||||
"body-parser": "registry:dt/body-parser#0.0.0+20160317120654",
|
||||
"es6-shim": "registry:dt/es6-shim#0.31.2+20160317120654",
|
||||
"express": "registry:dt/express#4.0.0+20160317120654",
|
||||
"express-serve-static-core": "registry:dt/express-serve-static-core#0.0.0+20160322035842",
|
||||
"mime": "registry:dt/mime#0.0.0+20160316155526",
|
||||
"node": "registry:dt/node#4.0.0+20160412142033",
|
||||
"serve-static": "registry:dt/serve-static#0.0.0+20160317120654"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,89 @@
|
|||
var webpack = require('webpack');
|
||||
var path = require('path');
|
||||
|
||||
var commonConfig = {
|
||||
resolve: {
|
||||
extensions: ['', '.ts', '.js']
|
||||
},
|
||||
module: {
|
||||
loaders: [
|
||||
// TypeScript
|
||||
{ test: /\.ts$/, loader: 'ts-loader' }
|
||||
]
|
||||
},
|
||||
plugins: [
|
||||
new webpack.optimize.OccurenceOrderPlugin(true)
|
||||
]
|
||||
};
|
||||
|
||||
|
||||
var clientConfig = {
|
||||
target: 'web',
|
||||
entry: './src/client',
|
||||
output: {
|
||||
path: path.join(__dirname, 'dist', 'client')
|
||||
},
|
||||
node: {
|
||||
global: true,
|
||||
__dirname: true,
|
||||
__filename: true,
|
||||
process: true,
|
||||
Buffer: false
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
var serverConfig = {
|
||||
target: 'node',
|
||||
entry: './src/server',
|
||||
output: {
|
||||
path: path.join(__dirname, 'dist', 'server')
|
||||
},
|
||||
externals: checkNodeImport,
|
||||
node: {
|
||||
global: true,
|
||||
__dirname: true,
|
||||
__filename: true,
|
||||
process: true,
|
||||
Buffer: true
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
// Default config
|
||||
var defaultConfig = {
|
||||
module: {
|
||||
noParse: [
|
||||
path.join(__dirname, 'zone.js', 'dist'),
|
||||
path.join(__dirname, 'angular2', 'bundles')
|
||||
]
|
||||
},
|
||||
context: __dirname,
|
||||
resolve: {
|
||||
root: path.join(__dirname, '/src')
|
||||
},
|
||||
output: {
|
||||
publicPath: path.resolve(__dirname),
|
||||
filename: 'bundle.js'
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
var webpackMerge = require('webpack-merge');
|
||||
module.exports = [
|
||||
// Client
|
||||
webpackMerge({}, defaultConfig, commonConfig, clientConfig),
|
||||
|
||||
// Server
|
||||
webpackMerge({}, defaultConfig, commonConfig, serverConfig)
|
||||
]
|
||||
|
||||
// Helpers
|
||||
function checkNodeImport(context, request, cb) {
|
||||
if (!path.isAbsolute(request) && request.charAt(0) !== '.') {
|
||||
cb(null, 'commonjs ' + request); return;
|
||||
}
|
||||
cb();
|
||||
}
|
Loading…
Reference in New Issue