Add altmetrics component

git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-portal/trunk@45554 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
argiro.kokogiannaki 2017-01-24 11:32:15 +00:00
parent 451951a3c0
commit b25855c7fd
5 changed files with 42 additions and 17 deletions

View File

@ -18,10 +18,7 @@ import {SearchFields} from '../utils/properties/searchFields';
@Component({ @Component({
selector: 'test', selector: 'test',
template: ` template: `
<div [innerHTML]="altmetrics | safeHtml">
<script async type='text/javascript' src='assets/altmetrics.js'></script>
</div>
<div>Ready:{{ready}}</div>
<!--div *ngIf="ready"--> <!--div *ngIf="ready"-->
<i-frame [url]=charturl width="30%" height="250"></i-frame> <i-frame [url]=charturl width="30%" height="250"></i-frame>
<!--/div--> <!--/div-->
@ -58,6 +55,7 @@ import {SearchFields} from '../utils/properties/searchFields';
class="btn waves-effect waves-light" class="btn waves-effect waves-light"
type="submit" name="action">DOWNLOAD</button> type="submit" name="action">DOWNLOAD</button>
</div> </div>
<altmetrics id="10.7717/peerj.1150" type="doi"></altmetrics>
` `
@ -74,16 +72,12 @@ export class TestComponent {
// public url = 'https://beta.openaire.eu/stats/chart.php?com=query&persistent=false&data={"query":"projScient","projTitle":"'+this.projectId+'", "table": "result", "fields": [{"fld": "number", "agg": "count", "type": "spline", "yaxis":1, "c":false}], "xaxis":{"name": "result_classifications-type", "agg": "avg"}, "group": "", "color": "", "type": "chart", "size":30, "sort": "xaxis", "xStyle":{"r": "-", "s": "-", "l": "-", "ft": "-", "wt": "-"}, "yaxisheaders": [""], "fieldsheaders": ["Publications"], "in": [], "filters": [{"name": "result_datasources-datasource-name", "values": [" "], "to": "-1"}], "having": [], "incfilters": [], "inchaving": [], "title": "", "subtitle": "", "xaxistitle": ""}'; // public url = 'https://beta.openaire.eu/stats/chart.php?com=query&persistent=false&data={"query":"projScient","projTitle":"'+this.projectId+'", "table": "result", "fields": [{"fld": "number", "agg": "count", "type": "spline", "yaxis":1, "c":false}], "xaxis":{"name": "result_classifications-type", "agg": "avg"}, "group": "", "color": "", "type": "chart", "size":30, "sort": "xaxis", "xStyle":{"r": "-", "s": "-", "l": "-", "ft": "-", "wt": "-"}, "yaxisheaders": [""], "fieldsheaders": ["Publications"], "in": [], "filters": [{"name": "result_datasources-datasource-name", "values": [" "], "to": "-1"}], "having": [], "incfilters": [], "inchaving": [], "title": "", "subtitle": "", "xaxistitle": ""}';
public user:{password:string,email:string} = {password:"",email:""}; public user:{password:string,email:string} = {password:"",email:""};
constructor(private _projectService: OpenaireProjectsService,private _searchProjectsService:SearchProjectsService,private _searchPubService:SearchPublicationsService,private _searchDataService:SearchDatasetsService, private _vocabulariesService: ISVocabulariesService, private _reportsService: ReportsService) { constructor(private _projectService: OpenaireProjectsService,private _searchProjectsService:SearchProjectsService,private _searchPubService:SearchPublicationsService,private _searchDataService:SearchDatasetsService, private _vocabulariesService: ISVocabulariesService, private _reportsService: ReportsService) {
// if (typeof document !== 'undefined') {
// let yourModule = require('../utils/altmetrics.js');
// }
} }
public ready:boolean = false; public ready:boolean = false;
ngAfterContentChecked(){
console.info("ngAfterContentChecked");
}
ngAfterViewChecked(){
this.ready=true;
console.info("ngAfterViewChecked");
}
ngOnInit() { ngOnInit() {
// this.lan = this._vocabulariesService.getLanguages(); // this.lan = this._vocabulariesService.getLanguages();
this.lan = this._vocabulariesService.getVocabularyFromService("dnet:languages.json"); this.lan = this._vocabulariesService.getVocabularyFromService("dnet:languages.json");

View File

@ -0,0 +1,29 @@
import {Component, ElementRef, Input} from '@angular/core';
import {SafeHtmlPipe} from '../utils/pipes/safeHTML.pipe';
//<altmetrics [id]="10.7717/peerj.1150" type="doi"></altmetrics>
@Component({
selector: 'altmetrics',
template: `
<div [innerHTML]="altmetrics | safeHtml"></div>
`
})
export class AltMetricsComponent {
@Input() id ;
@Input() type = 'doi'; // doi or arxiv
// public doi="10.7717/peerj.1150";
public altmetrics:string;
constructor() {
if (typeof document !== 'undefined') {
let yourModule = require('../utils/altmetrics.js');
}
}
ngOnInit() {
if(this.type == "doi"){
this.altmetrics='<div data-badge-popover="right" data-badge-type="donut" data-doi="'+this.id+'" class="altmetric-embed"> </div>';
}else{
this.altmetrics='<div data-badge-popover="right" data-badge-type="donut" data-arxiv-id="'+this.id+'" class="altmetric-embed"> </div>';
}
}
}

View File

@ -0,0 +1 @@
!function(e,t,n){var d="createElement",c="getElementsByTagName",m="setAttribute",n=document.getElementById(e);return n&&n.parentNode&&n.parentNode.removeChild(n),n=document[d+"NS"]&&document.documentElement.namespaceURI,n=n?document[d+"NS"](n,"script"):document[d]("script"),n[m]("id",e),n[m]("src",t),(document[c]("head")[0]||document[c]("body")[0]).appendChild(n),n=new Image,void n[m]("src","https://d1uo4w7k31k5mn.cloudfront.net/donut/0.png")}("altmetric-embed-js","https://d1bxh8uas1mnw7.cloudfront.net/assets/altmetric_badges-8f271adb184c21cc5169a7f67f7fe5ab.js");

View File

@ -13,6 +13,8 @@ import {EntitiesAutocompleteComponent} from './entitiesAutoComplete.component';
import {ShowDataProvidersComponent} from './showDataProviders.component'; import {ShowDataProvidersComponent} from './showDataProviders.component';
import {ExportCSVComponent} from './exportCSV.component'; import {ExportCSVComponent} from './exportCSV.component';
import {IFrameComponent} from './iframe.component'; import {IFrameComponent} from './iframe.component';
import {AltMetricsComponent} from './altmetrics.component';
import {SafeHtmlPipe} from './pipes/safeHTML.pipe'; import {SafeHtmlPipe} from './pipes/safeHTML.pipe';
import {AlertModal} from './modal/alert'; import {AlertModal} from './modal/alert';
@ -32,7 +34,8 @@ import {ModalLoading} from './modal/loading.component';
ShowDataProvidersComponent, ShowDataProvidersComponent,
ExportCSVComponent, ExportCSVComponent,
IFrameComponent, IFrameComponent,
SafeHtmlPipe SafeHtmlPipe,
AltMetricsComponent
], ],
exports: [ exports: [
@ -46,7 +49,8 @@ import {ModalLoading} from './modal/loading.component';
ShowDataProvidersComponent, ShowDataProvidersComponent,
ExportCSVComponent, ExportCSVComponent,
IFrameComponent, IFrameComponent,
SafeHtmlPipe SafeHtmlPipe,
AltMetricsComponent
] ]
}) })

View File

@ -10,7 +10,6 @@
<meta name="author" content="Super User" /> <meta name="author" content="Super User" />
<meta name="description" content="open access infrastructure, research information, open data, scientific publication, scientific information system, European Commission, EC, FP7, ERC, Horizon 2020, H2020, linked data" /> <meta name="description" content="open access infrastructure, research information, open data, scientific publication, scientific information system, European Commission, EC, FP7, ERC, Horizon 2020, H2020, linked data" />
<title>OpenAIRE</title> <title>OpenAIRE</title>
<!--script async type='text/javascript' src='assets/altmetrics.js'></script-->
<script src="assets/jquery/jquery.min.js" type="text/javascript"></script> <script src="assets/jquery/jquery.min.js" type="text/javascript"></script>
<!--uikit--> <!--uikit-->
<script src="assets/uikit-2.27.2/js/uikit.min.js" type="text/javascript"></script> <script src="assets/uikit-2.27.2/js/uikit.min.js" type="text/javascript"></script>
@ -141,8 +140,6 @@
</ul> </ul>
</div> </div>
</div--> </div-->
<div class=" altmetrics" >
<div data-badge-popover="bottom" data-badge-type="medium-donut" data-doi="10.1038/nature.2014.14583" data-hide-no-mentions="true" class="altmetric-embed"></div>
</div>
</body> </body>
</html> </html>