[Monitor Dashboard]: Complete indicator save and reorder.

git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-monitor-portal/trunk/monitor_dashboard@57673 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
Konstantinos Triantafyllou 2019-11-24 16:30:04 +00:00
parent 7ed0964b38
commit 14c32e0f4c
20 changed files with 775 additions and 400 deletions

View File

@ -8,13 +8,13 @@ import {UserManagementService} from "./openaireLibrary/services/user-management.
import {SideBarService} from "./library/sharedComponents/sidebar/sideBar.service"; import {SideBarService} from "./library/sharedComponents/sidebar/sideBar.service";
import {StakeholderService} from "./services/stakeholder.service"; import {StakeholderService} from "./services/stakeholder.service";
import {Subscriber} from "rxjs"; import {Subscriber} from "rxjs";
import {StakeholderCreator} from "./utils/entities/stakeholderCreator";
@Component({ @Component({
selector: 'app-root', selector: 'app-root',
templateUrl: './app.component.html' templateUrl: './app.component.html'
}) })
export class AppComponent implements OnInit, OnDestroy{ export class AppComponent implements OnInit, OnDestroy {
properties: EnvProperties; properties: EnvProperties;
user: User; user: User;
loginCheck: boolean = false; loginCheck: boolean = false;
@ -41,15 +41,14 @@ export class AppComponent implements OnInit, OnDestroy{
r = r.firstChild; r = r.firstChild;
} }
r.params.subscribe(params => { r.params.subscribe(params => {
if(params['stakeholder']) { if (params['stakeholder']) {
if(!this.stakeholderService.stakeholder || if (!this.stakeholderService.stakeholder ||
this.stakeholderService.stakeholder.alias !== params['stakeholder']) { this.stakeholderService.stakeholder.alias !== params['stakeholder']) {
// this.stakeholderService.getStakeholder(this.properties.monitorServiceAPIURL, params['stakeholder']).subscribe(stakeholder => { this.stakeholderService.getStakeholder(this.properties.monitorServiceAPIURL, params['stakeholder']).subscribe(stakeholder => {
// stakeholder = Stakeholder.createECStakeholder(); this.stakeholderService.setStakeholder(stakeholder);
let stakeHolder = StakeholderCreator.createFunderFromDefaultProfile("ec","funder","ec__________::EC","European Commission","EC",false,"ec",true,true); console.log(stakeholder);
this.stakeholderService.setStakeholder(stakeHolder);
this.sidebarService.setOpen(true); this.sidebarService.setOpen(true);
// }); });
} }
} else { } else {
this.stakeholderService.setStakeholder(null); this.stakeholderService.setStakeholder(null);
@ -72,8 +71,8 @@ export class AppComponent implements OnInit, OnDestroy{
} }
public ngOnDestroy() { public ngOnDestroy() {
this.subscriptions.forEach( value => { this.subscriptions.forEach(value => {
if(value instanceof Subscriber) { if (value instanceof Subscriber) {
value.unsubscribe(); value.unsubscribe();
} }
}); });
@ -84,9 +83,9 @@ export class AppComponent implements OnInit, OnDestroy{
} }
public toggleOpen(event = null) { public toggleOpen(event = null) {
if(!event) { if (!event) {
this.sidebarService.setOpen(!this.open); this.sidebarService.setOpen(!this.open);
} else if(event && event['value'] === true) { } else if (event && event['value'] === true) {
this.sidebarService.setOpen(false); this.sidebarService.setOpen(false);
} }
} }

View File

@ -138,7 +138,7 @@
</ul> </ul>
</div> </div>
</aside> </aside>
<div id="page_content" click-outside-or-esc targetId="page_content" (clickOutside)="toggleOpen($event)"> <div id="page_content" click-outside-or-esc targetId="page_content" [escClose]="false" (clickOutside)="toggleOpen($event)">
<div id="page_content_inner"> <div id="page_content_inner">
<h4 class="uk-text-bold"> <h4 class="uk-text-bold">
Customise your Monitor Dashboard! Customise your Monitor Dashboard!

View File

@ -58,8 +58,8 @@ export class HomeComponent implements OnInit, OnDestroy {
} }
public ngOnDestroy() { public ngOnDestroy() {
this.subscriptions.forEach( value => { this.subscriptions.forEach(value => {
if(value instanceof Subscriber) { if (value instanceof Subscriber) {
value.unsubscribe(); value.unsubscribe();
} }
}); });
@ -87,7 +87,7 @@ export class HomeComponent implements OnInit, OnDestroy {
} }
public saveTopicOpen(element, index = -1) { public saveTopicOpen(element, index = -1) {
if(element.className.indexOf('uk-open') !== -1) { if (element.className.indexOf('uk-open') !== -1) {
this.hide(element); this.hide(element);
} else { } else {
if (index === -1) { if (index === -1) {
@ -100,16 +100,14 @@ export class HomeComponent implements OnInit, OnDestroy {
} }
public saveTopic(element, index = -1) { public saveTopic(element, index = -1) {
if(this.copyTopic.name && this.copyTopic.name !== '') { if (this.copyTopic.name && this.copyTopic.name !== '') {
if(!this.copyTopic.alias) { if (!this.copyTopic.alias) {
this.copyTopic.alias = this.copyTopic.name.toLowerCase().trim(); this.copyTopic.alias = this.copyTopic.name.toLowerCase().trim();
} }
if(index === -1) { if (index === -1) {
this.stakeholder.topics.push(this.copyTopic);
this.save('Topic has been successfully created', element); this.save('Topic has been successfully created', element);
} else { } else {
this.stakeholder.topics[index] = HelperFunctions.copy(this.copyTopic); this.save('Topic has been successfully saved', element, index);
this.save('Topic has been successfully saved', element);
} }
} else { } else {
this.valid = false; this.valid = false;
@ -126,9 +124,15 @@ export class HomeComponent implements OnInit, OnDestroy {
this.deleteTopicModal.open(); this.deleteTopicModal.open();
} }
private save(message: string, element) { private save(message: string, element, index: number = -1) {
this.stakeholderService.saveStakeholder(this.properties.monitorServiceAPIURL, this.stakeholder).subscribe(stakeholder => { let path = [this.stakeholder._id];
this.stakeholderService.setStakeholder(stakeholder); this.stakeholderService.saveElement(this.properties.monitorServiceAPIURL, this.copyTopic, path).subscribe(topic => {
if (index === -1) {
this.stakeholder.topics.push(topic);
} else {
this.stakeholder.topics[index] = topic;
}
this.stakeholderService.setStakeholder(this.stakeholder);
UIkit.notification(message, { UIkit.notification(message, {
status: 'success', status: 'success',
timeout: 3000, timeout: 3000,
@ -147,11 +151,12 @@ export class HomeComponent implements OnInit, OnDestroy {
deleteTopic() { deleteTopic() {
let path = [ let path = [
this.stakeholder.alias, this.stakeholder._id,
this.stakeholder.topics[this.index].alias this.stakeholder.topics[this.index]._id
]; ];
this.stakeholderService.deleteElement(this.properties.monitorServiceAPIURL, path).subscribe(stakeholder => { this.stakeholderService.deleteElement(this.properties.monitorServiceAPIURL, path).subscribe(() => {
this.stakeholderService.setStakeholder(stakeholder); this.stakeholder.topics.splice(this.index, 1);
this.stakeholderService.setStakeholder(this.stakeholder);
UIkit.notification('Topic has been successfully deleted', { UIkit.notification('Topic has been successfully deleted', {
status: 'success', status: 'success',
timeout: 3000, timeout: 3000,

View File

@ -0,0 +1,22 @@
import {Directive, HostListener, Input} from "@angular/core";
@Directive({
selector: '[focus-directive]',
})
export class FocusDirective {
@Input('formInput') formControl: any;
constructor() { }
@HostListener
('focus', ['$event.target'])
onFocus(target) {
this.formControl.markAsTouched({onlySelf: true});
}
@HostListener('blur', ['$event.target'])
onBlur(target) {
this.formControl.markAsUntouched({onlySelf: true});
}
}

View File

@ -0,0 +1,45 @@
import {Component, Input, OnDestroy, OnInit} from "@angular/core";
import {Option} from "../../../utils/indicator-utils";
@Component({
selector: '[dashboard-input]',
template: `
<div class="md-input-wrapper"
[class.md-input-filled]="formControl.value !== ''"
[class.md-input-focus]="formControl.touched"
[class.md-input-wrapper-danger]="formControl.invalid && formControl.dirty">
<label>{{label}}</label>
<input *ngIf="type === 'text' || type === 'number'" [type]="type" class="md-input"
focus-directive [formInput]="formControl"
[formControl]="formControl"
[class.md-input-danger]="formControl.invalid && formControl.dirty">
<textarea *ngIf="type === 'textarea'" type="text" class="md-input no_autosize"
focus-directive [formInput]="formControl"
[rows]="rows" [formControl]="formControl"></textarea>
<span class="md-input-bar"></span>
<select *ngIf="type === 'select'" class="md-input uk-select"
focus-directive [formInput]="formControl"
[formControl]="formControl"
[class.md-input-danger]="formControl.invalid && formControl.dirty">
<option [value]="option.value" *ngFor="let option of options">
{{option.label}}
</option>
</select>
</div>`
})
export class InputComponent implements OnInit, OnDestroy {
@Input('formInput') formControl: any;
@Input('type') type: string = 'text';
@Input('label') label: string;
@Input('rows') rows: number = 3;
@Input('options') options: Option[];
constructor() {
}
ngOnInit(): void {
}
ngOnDestroy(): void {
}
}

View File

@ -0,0 +1,21 @@
import {NgModule} from '@angular/core';
import {CommonModule} from '@angular/common';
import {FocusDirective} from "./focus.directive";
import {InputComponent} from "./input.component";
import {SharedModule} from "../../../shared/shared.module";
@NgModule({
imports: [
CommonModule,
SharedModule,
],
exports: [
InputComponent
],
declarations: [
FocusDirective,
InputComponent
]
})
export class InputModule {
}

View File

@ -25,7 +25,7 @@
</div> </div>
<dashboard-sidebar *ngIf="sideBar && stakeholder" [items]="sideBar.items" [name]="stakeholder.index_name"></dashboard-sidebar> <dashboard-sidebar *ngIf="sideBar && stakeholder" [items]="sideBar.items" [name]="stakeholder.index_name"></dashboard-sidebar>
<div *ngIf="activeSubCategory" <div *ngIf="activeSubCategory"
id="page_content" click-outside-or-esc targetId="page_content" (clickOutside)="toggleOpen($event)"> id="page_content" click-outside-or-esc targetId="page_content" [escClose]="false" (clickOutside)="toggleOpen($event)">
<div id="page_content_inner"> <div id="page_content_inner">
<!-- <div> <!-- <div>
Filters Filters

View File

@ -1,10 +1,12 @@
import {Injectable} from "@angular/core"; import {Injectable} from "@angular/core";
import {HttpClient} from "@angular/common/http"; import {HttpClient} from "@angular/common/http";
import {BehaviorSubject, Observable} from "rxjs"; import {BehaviorSubject, Observable} from "rxjs";
import {Indicator, Stakeholder} from "../utils/entities/stakeholder"; import {Indicator, IndicatorPath, Stakeholder} from "../utils/entities/stakeholder";
import {HelperFunctions} from "../openaireLibrary/utils/HelperFunctions.class"; import {HelperFunctions} from "../openaireLibrary/utils/HelperFunctions.class";
import {map} from "rxjs/operators"; import {map} from "rxjs/operators";
let maps: string[] = ['parameters', 'filters'];
@Injectable({ @Injectable({
providedIn: "root" providedIn: "root"
}) })
@ -17,45 +19,61 @@ export class StakeholderService {
} }
getStakeholder(url: string, alias:string): Observable<Stakeholder> { getStakeholder(url: string, alias:string): Observable<Stakeholder> {
return new BehaviorSubject<Stakeholder>(Stakeholder.createECStakeholder()).asObservable(); /*return new BehaviorSubject<Stakeholder>(
// return this.http.get<Stakeholder>(url + '/stakeholder/' + encodeURIComponent(alias)).pipe(map(stakeholder => { StakeholderCreator.createFunderFromDefaultProfile("ec","funder","ec__________::EC",
// return this.formalizeStakeholder([stakeholder])[0]; "European Commission","EC",
// })); false,"ec",true,true)).asObservable();*/
return this.http.get<Stakeholder>(url + '/stakeholder/' + encodeURIComponent(alias)).pipe(map(stakeholder => {
return this.formalize(stakeholder);
}));
} }
getAllStakeholders(url: string, type: string = null): Observable<Stakeholder[]> { getAllStakeholders(url: string, type: string = null): Observable<Stakeholder[]> {
return this.http.get<Stakeholder[]>(url + '/stakeholder/all' + (type)?('?type=' + type):'').pipe(map(stakeholders => { return this.http.get<Stakeholder[]>(url + '/stakeholder/all' + (type)?('?type=' + type):'').pipe(map(stakeholders => {
return this.formalizeStakeholder(stakeholders); return this.formalize(stakeholders);
})); }));
} }
getStakeholders(url: string, type: string = null): Observable<Stakeholder[]> { getStakeholders(url: string, type: string = null): Observable<Stakeholder[]> {
return this.http.get<Stakeholder[]>(url + '/stakeholder' + (type)?('?type=' + type):'').pipe(map(stakeholders => { return this.http.get<Stakeholder[]>(url + '/stakeholder' + (type)?('?type=' + type):'').pipe(map(stakeholders => {
return this.formalizeStakeholder(stakeholders); return this.formalize(stakeholders);
})); }));
} }
getDefaultStakeholders(url: string, type: string = null): Observable<Stakeholder[]> { getDefaultStakeholders(url: string, type: string = null): Observable<Stakeholder[]> {
return this.http.get<Stakeholder[]>(url + '/stakeholder/default' + (type)?('?type=' + type):'').pipe(map(stakeholders => { return this.http.get<Stakeholder[]>(url + '/stakeholder/default' + (type)?('?type=' + type):'').pipe(map(stakeholders => {
return this.formalizeStakeholder(stakeholders); return this.formalize(stakeholders);
}));
}
buildStakeholder(url: string, stakeholder: Stakeholder): Observable<Stakeholder> {
return this.http.post<Stakeholder>(url + '/build-stakeholder', stakeholder).pipe(map(stakeholder => {
return this.formalize(stakeholder);
})); }));
} }
saveStakeholder(url: string, stakeholder: Stakeholder): Observable<Stakeholder> { saveStakeholder(url: string, stakeholder: Stakeholder): Observable<Stakeholder> {
return this.http.post<Stakeholder>(url + '/stakeholder/save', stakeholder).pipe(map(stakeholder => { return this.http.post<Stakeholder>(url + '/stakeholder/save', stakeholder).pipe(map(stakeholder => {
return this.formalizeStakeholder([stakeholder])[0]; return this.formalize(stakeholder);
})); }));
} }
saveIndicator(url: string, path: string[], indicator: Indicator): Observable<Indicator> { saveElement(url: string, element: any, path: string[] = []): Observable<any> {
path = HelperFunctions.encodeArray(path); path = HelperFunctions.encodeArray(path);
return this.http.post<Indicator>(url + '/' + path.join('/') + return this.http.post<any>(url + ((path.length > 0)?'/':'') + path.join('/') +
'/indicator/save', indicator); '/save', element).pipe(map(element => {
return this.formalize(element);
}));
} }
deleteElement(url: string, path: string[]): Observable<any> { deleteElement(url: string, path: string[]): Observable<any> {
path = HelperFunctions.encodeArray(path); path = HelperFunctions.encodeArray(path);
return this.http.delete<any>(url + '/' + path.join('/')) return this.http.delete<any>(url + '/' + path.join('/') + '/delete');
}
reorderIndicators(url: string, path: string[], indicators: Indicator[], type: string = 'chart'): Observable<boolean> {
path = HelperFunctions.encodeArray(path);
return this.http.post<boolean>(url + '/' + path.join('/') + '/' + type + '/reorder', indicators);
} }
getStakeholderAsObservable(): Observable<Stakeholder> { getStakeholderAsObservable(): Observable<Stakeholder> {
@ -70,29 +88,7 @@ export class StakeholderService {
this.stakeholderSubject.next(stakeholder); this.stakeholderSubject.next(stakeholder);
} }
private formalizeStakeholder(stakeholders: Stakeholder[]): Stakeholder[] { private formalize(element: any) {
stakeholders.forEach( stakeholder => { return HelperFunctions.copy(element);
stakeholder.topics.forEach( topic => {
topic.categories.forEach( category => {
category.subCategories.forEach(subcategory => {
subcategory.charts.forEach(indicator => {
indicator.indicatorPaths.forEach(indicatorPath => {
if(indicatorPath.parameters) {
indicatorPath.parameters = new Map<string, string>(Object.entries(indicatorPath.parameters));
}
if(indicatorPath.filters) {
// let filters = new Map<string, Map<string, string>>();
// Object.entries(indicatorPath.filters).forEach(([key, value]) => {
// filters.set(key, new Map<string, string>(Object.entries(value)));
// });
indicatorPath.filters = new Map<string, string>(Object.entries(indicatorPath.filters));
}
});
});
});
});
});
});
return stakeholders;
} }
} }

View File

@ -1,4 +1,5 @@
<div id="page_content" click-outside-or-esc targetId="page_content" (clickOutside)="toggleOpen($event)"> <div id="page_content" click-outside-or-esc targetId="page_content" [escClose]="false"
(clickOutside)="toggleOpen($event)">
<div class="uk-padding-small md-bg-white" uk-grid> <div class="uk-padding-small md-bg-white" uk-grid>
<div class="uk-width-2-3@m uk-width-1-1 uk-child-width-1-3@m uk-child-width-1-1" uk-grid> <div class="uk-width-2-3@m uk-width-1-1 uk-child-width-1-3@m uk-child-width-1-1" uk-grid>
<div class="uk-flex uk-flex-middle"> <div class="uk-flex uk-flex-middle">
@ -73,12 +74,12 @@
<div [class.uk-child-width-1-3@m]="grid" <div [class.uk-child-width-1-3@m]="grid"
[class.uk-child-width-1-2@s]="grid" [class.uk-child-width-1-2@s]="grid"
[class.uk-child-width-1-1]="!grid" [class.uk-child-width-1-1]="!grid"
[class.list]="!grid" id="numbers"
class="uk-grid-match uk-grid-small" class="uk-grid-match uk-grid-small"
[class.list]="!grid" uk-sortable uk-grid>
uk-grid>
<ng-template ngFor [ngForOf]="displayNumbers" let-indicator let-i="index"> <ng-template ngFor [ngForOf]="displayNumbers" let-indicator let-i="index">
<div> <div *ngIf="indicator" [id]="i">
<div class="md-card"> <div class="md-card" [class.uk-sortable-nodrag]="!canNumbersReorder">
<div class="md-card-toolbar"> <div class="md-card-toolbar">
<div class="md-card-toolbar-actions" [class.uk-flex-middle]="!grid" [class.uk-flex]="!grid"> <div class="md-card-toolbar-actions" [class.uk-flex-middle]="!grid" [class.uk-flex]="!grid">
<span *ngIf="!grid" class="uk-margin-medium-right uk-flex uk-flex-middle"> <span *ngIf="!grid" class="uk-margin-medium-right uk-flex uk-flex-middle">
@ -119,19 +120,19 @@
<div [class.uk-child-width-1-3@m]="grid" <div [class.uk-child-width-1-3@m]="grid"
[class.uk-child-width-1-2@s]="grid" [class.uk-child-width-1-2@s]="grid"
[class.uk-child-width-1-1]="!grid" [class.uk-child-width-1-1]="!grid"
[class.list]="!grid" [class.list]="!grid" id="charts"
class="uk-grid-match uk-grid-small" class="uk-grid-match uk-grid-small uk-grid"
uk-grid> uk-sortable uk-grid>
<ng-template ngFor [ngForOf]="displayCharts" let-indicator let-i="index"> <ng-template ngFor [ngForOf]="displayCharts" let-indicator let-i="index">
<div> <div *ngIf="indicator" [id]="i">
<div class="md-card"> <div class="md-card" [class.uk-sortable-nodrag]="!canChartsReorder">
<div class="md-card-toolbar"> <div class="md-card-toolbar">
<div class="md-card-toolbar-actions" [class.uk-flex-middle]="!grid" [class.uk-flex]="!grid"> <div class="md-card-toolbar-actions" [class.uk-flex-middle]="!grid" [class.uk-flex]="!grid">
<ng-template [ngIf]="!grid"> <ng-template [ngIf]="!grid">
<span *ngFor="let indicatorPath of indicator.indicatorPaths" <span *ngFor="let indicatorPath of indicator.indicatorPaths"
class="uk-margin-medium-right uk-text-capitalize uk-flex uk-flex-middle"> class="uk-margin-medium-right uk-text-capitalize uk-flex uk-flex-middle">
<i class="material-icons md-24 uk-margin-small-right"> <i class="material-icons md-24 uk-margin-small-right">
{{indicatorUtils.chartTypes.get(indicatorPath.type)}} {{indicatorUtils.chartTypesIcons.get(indicatorPath.type)}}
</i> </i>
{{indicatorPath.type + ' Chart'}} {{indicatorPath.type + ' Chart'}}
</span> </span>
@ -162,7 +163,7 @@
[ngClass]="'uk-child-width-1-' + indicator.indicatorPaths.length" uk-grid> [ngClass]="'uk-child-width-1-' + indicator.indicatorPaths.length" uk-grid>
<div *ngFor="let indicatorPath of indicator.indicatorPaths"> <div *ngFor="let indicatorPath of indicator.indicatorPaths">
<i class="material-icons md-24"> <i class="material-icons md-24">
{{indicatorUtils.chartTypes.get(indicatorPath.type)}} {{indicatorUtils.chartTypesIcons.get(indicatorPath.type)}}
</i> </i>
<div class="uk-text-capitalize">{{indicatorPath.type + ' Chart'}}</div> <div class="uk-text-capitalize">{{indicatorPath.type + ' Chart'}}</div>
</div> </div>
@ -185,7 +186,7 @@
</div> </div>
</ng-template> </ng-template>
<div> <div>
<div class="md-card clickable" (click)="createIndicatorOpen()"> <div class="md-card clickable uk-sortable-nodrag" (click)="createIndicatorOpen()">
<div class="md-card-toolbar"> <div class="md-card-toolbar">
<div class="md-card-toolbar-heading-text" <div class="md-card-toolbar-heading-text"
[class.uk-flex-middle]="!grid" [class.uk-flex-middle]="!grid"
@ -196,13 +197,13 @@
</div> </div>
</div> </div>
<div *ngIf="grid" class="md-card-content"> <div *ngIf="grid" class="md-card-content">
<div class="uk-flex uk-flex-center" uk-grid> <div uk-grid>
<div class="uk-width-1-1"> <div class="uk-width-1-1">
Use our advance tool to create a custom Indicator that suit the needs of your funding KPI's. Use our advance tool to create a custom Indicator that suit the needs of your funding KPI's.
</div> </div>
</div> <div class="uk-width-1-1 uk-flex uk-flex-center">
<div class="uk-flex uk-flex-center uk-margin-top"> <i class="material-icons md-48">add</i>
<i class="material-icons md-48">add</i> </div>
</div> </div>
</div> </div>
</div> </div>
@ -214,52 +215,87 @@
(alertOutput)="createIndicator()" (alertOutput)="createIndicator()"
[okDisabled]="indicatorFb && indicatorFb.invalid"> [okDisabled]="indicatorFb && indicatorFb.invalid">
<div *ngIf="indicatorFb" class="uk-form-stacked" [formGroup]="indicatorFb"> <div *ngIf="indicatorFb" class="uk-form-stacked" [formGroup]="indicatorFb">
<label class="uk-form-label">Name</label> <div dashboard-input class="uk-form-row" [formInput]="indicatorFb.get('name')" label="Title"></div>
<div class="uk-form-controls"> <div dashboard-input class="uk-form-row" [formInput]="indicatorFb.get('description')"
<input class="uk-input" label="Description" type="textarea"></div>
[class.uk-form-danger]="indicatorFb.get('name').invalid && indicatorFb.get('name').dirty" <div dashboard-input class="uk-form-row" *ngFor="let chartUrl of urls.controls;"
[formControl]="indicatorFb.get('name')"> [formInput]="chartUrl"
</div> label="Chart Url"></div>
<label class="uk-form-label">Description</label>
<div class="uk-form-controls">
<textarea class="uk-textarea" rows="3"
[formControl]="indicatorFb.get('description')"></textarea>
</div>
<label class="uk-form-label">Chart url</label>
<div class="uk-form-controls" formArrayName="urls">
<input class="uk-input"
[class.uk-form-danger]="chartUrl.invalid && chartUrl.dirty"
*ngFor="let chartUrl of urls.controls;"
[formControl]="chartUrl">
</div>
</div> </div>
</modal-alert> </modal-alert>
<modal-alert #editIndicatorModal <modal-alert #editIndicatorModal
[classBody]="'large-modal'"
(alertOutput)="saveIndicator()" (alertOutput)="saveIndicator()"
[okDisabled]="editIndicatorFb && (editIndicatorFb.invalid || !editIndicatorFb.dirty)"> [okDisabled]="editIndicatorFb && (editIndicatorFb.invalid ||(!editIndicatorFb.dirty && index !==-1))">
<div *ngIf="editIndicatorFb" class="uk-form-stacked" [formGroup]="editIndicatorFb"> <div *ngIf="editIndicatorFb" class="uk-padding-small" [formGroup]="editIndicatorFb">
<div class="md-input-wrapper"> <div dashboard-input class="uk-form-row" [formInput]="editIndicatorFb.get('name')" label="Title"></div>
<label>Name</label> <div dashboard-input class="uk-form-row" [formInput]="editIndicatorFb.get('description')"
<input type="text" class="md-input" (focus)="focus($event)"> label="Description" type="textarea">
<span class="md-input-bar "></span>
</div> </div>
<label class="uk-form-label">Name</label> <div class="uk-form-row uk-flex uk-flex-middle">
<div class="uk-form-controls"> <div dashboard-input class="uk-width-small" [formInput]="editIndicatorFb.get('isPublic')"
<input class="uk-input" label="Accessibility" [options]="indicatorUtils.isPublic" type="select">
[class.uk-form-danger]="editIndicatorFb.get('name').status === 'INVALID' && editIndicatorFb.get('name').dirty" </div>
[formControl]="editIndicatorFb.get('name')"> <div dashboard-input class="uk-margin-small-left uk-width-small" [formInput]="editIndicatorFb.get('isActive')"
label="Visibility" [options]="indicatorUtils.isActive" type="select">
</div>
<div dashboard-input class="uk-margin-small-left uk-width-small" [formInput]="editIndicatorFb.get('width')"
type="select" [options]="indicatorUtils.chartSizes"
label="Chart Size">
</div>
</div> </div>
<!--<label class="uk-form-label">Description</label> <hr class="uk-margin-large-top uk-margin-large-bottom">
<div class="uk-form-controls"> <div formArrayName="indicatorPaths">
<textarea class="uk-textarea" rows="3" <div *ngFor="let indicatorPath of indicatorPaths.controls; let i=index"
[formControl]="indicatorFb.get('description')"></textarea> [formGroup]="indicatorPath">
<div formArrayName="parameters">
<div *ngIf="getParameter(i, 'title')" class="uk-form-row">
<div dashboard-input
[formInput]="getParameter(i, 'title').get('value')"
label="Chart Title"></div>
</div>
<div class="uk-grid-medium uk-form-row" uk-grid>
<div *ngIf="getParameter(i, 'type')" class="uk-width-1-3@s">
<div dashboard-input [formInput]="getParameter(i, 'type').get('value')"
type="select" [options]="indicatorUtils.chartTypes"
label="Chart Type"></div>
</div>
<div *ngIf="getParameter(i, 'xAxisTitle')" class="uk-width-1-3@s">
<div dashboard-input [formInput]="getParameter(i, 'xAxisTitle').get('value')"
label="X-Axis Title"></div>
</div>
<div *ngIf="getParameter(i, 'yAxisTitle')" class="uk-width-1-3@s">
<div dashboard-input [formInput]="getParameter(i, 'yAxisTitle').get('value')"
label="Y-Axis Title"></div>
</div>
<div *ngIf="getParameter(i, 'start_year')" class="uk-width-1-3@s">
<div dashboard-input [formInput]="getParameter(i, 'start_year').get('value')"
label="Year (From)"></div>
</div>
<div *ngIf="getParameter(i, 'end_year')" class="uk-width-1-3@s">
<div dashboard-input [formInput]="getParameter(i, 'end_year').get('value')"
label="Year (To)"></div>
</div>
</div>
</div>
<div *ngIf="indicator.indicatorPaths[i].safeResourceUrl" class="uk-margin-medium-top uk-position-relative">
<div *ngIf="!indicatorPath.pristine && !indicatorPath.invalid"
class="uk-width-1-1 uk-height-medium refresh-iframe">
<div class="uk-position-relative uk-height-1-1">
<div class="uk-position-center md-color-white uk-text-center clickable" (click)="refreshIndicator(i)">
<div><i class="material-icons md-color-white">refresh</i></div>
<span>Click to refresh the graph view</span>
</div>
</div>
</div>
<iframe *ngIf="indicator.indicatorPaths[i].source !== 'image'"
[src]="indicator.indicatorPaths[i].safeResourceUrl"
class="uk-width-1-1 uk-height-medium"></iframe>
<div *ngIf="indicator.indicatorPaths[i].source === 'image'">
<img class="uk-width-1-1 uk-height-medium" [src]="indicator.indicatorPaths[i].url">
</div>
</div>
</div>
</div> </div>
<label class="uk-form-label">Chart url</label>
<div class="uk-form-controls" formArrayName="urls">
<input class="uk-input"
[class.uk-form-danger]="chartUrl.status === 'INVALID' && chartUrl.dirty"
*ngFor="let chartUrl of urls.controls;"
[formControl]="chartUrl">
</div>-->
</div> </div>
</modal-alert> </modal-alert>

View File

@ -1,12 +1,16 @@
import {ChangeDetectorRef, Component, Input, OnChanges, OnInit, SimpleChanges, ViewChild} from "@angular/core"; import {AfterViewInit, Component, Input, OnChanges, OnInit, SimpleChanges, ViewChild} from "@angular/core";
import {SideBarService} from "../library/sharedComponents/sidebar/sideBar.service"; import {SideBarService} from "../library/sharedComponents/sidebar/sideBar.service";
import {Indicator, IndicatorPath, Stakeholder} from "../utils/entities/stakeholder"; import {Indicator, IndicatorPath, Stakeholder} from "../utils/entities/stakeholder";
import {IndicatorUtils} from "../utils/indicator-utils"; import {IndicatorUtils} from "../utils/indicator-utils";
import {FormArray, FormBuilder, FormGroup, Validators} from "@angular/forms"; import {FormArray, FormBuilder, FormControl, FormGroup, Validators} from "@angular/forms";
import {AlertModal} from "../openaireLibrary/utils/modal/alert"; import {AlertModal} from "../openaireLibrary/utils/modal/alert";
import {StatisticsService} from "../utils/services/statistics.service"; import {StatisticsService} from "../utils/services/statistics.service";
import {HelperFunctions} from "../openaireLibrary/utils/HelperFunctions.class"; import {HelperFunctions} from "../openaireLibrary/utils/HelperFunctions.class";
import {DomSanitizer} from "@angular/platform-browser"; import {DomSanitizer} from "@angular/platform-browser";
import {StakeholderService} from "../services/stakeholder.service";
import {EnvProperties} from "../openaireLibrary/utils/properties/env-properties";
declare var UIkit;
@Component({ @Component({
selector: 'indicators', selector: 'indicators',
@ -14,6 +18,8 @@ import {DomSanitizer} from "@angular/platform-browser";
}) })
export class IndicatorsComponent implements OnInit, OnChanges { export class IndicatorsComponent implements OnInit, OnChanges {
@Input()
public properties: EnvProperties = null;
@Input() @Input()
public topicIndex: number = 0; public topicIndex: number = 0;
@Input() @Input()
@ -29,11 +35,7 @@ export class IndicatorsComponent implements OnInit, OnChanges {
* Editable indicator * Editable indicator
*/ */
public indicator: Indicator; public indicator: Indicator;
/** public index: number;
* All charts and numbers
*/
public charts: Indicator[] = [];
public numbers: Indicator[] = [];
/** /**
* Displayed chart and numbers base on Top filters * Displayed chart and numbers base on Top filters
*/ */
@ -55,27 +57,44 @@ export class IndicatorsComponent implements OnInit, OnChanges {
@ViewChild('editIndicatorModal') editIndicatorModal: AlertModal; @ViewChild('editIndicatorModal') editIndicatorModal: AlertModal;
constructor(private sideBarService: SideBarService, constructor(private sideBarService: SideBarService,
private stakeholderService: StakeholderService,
private statisticsService: StatisticsService, private statisticsService: StatisticsService,
private fb: FormBuilder, private fb: FormBuilder,
private sanitizer: DomSanitizer) { private sanitizer: DomSanitizer) {
} }
ngOnInit(): void { ngOnInit(): void {
if (document !== undefined) {
let callback = (list): void => {
let items: HTMLCollection = list.current.children;
let reordered = [];
let indicators = [];
for (let i = 0; i < items.length; i++) {
if (items.item(i).id) {
reordered.push(+items.item(i).id);
}
}
if(list.current.id === 'charts') {
reordered.forEach((id, index) => {
indicators[index] = HelperFunctions.copy(this.charts[id]);
});
this.reorderIndicators('chart', indicators);
} else if(list.current.id === 'numbers') {
reordered.forEach((id, index) => {
indicators[index] = HelperFunctions.copy(this.numbers[id]);
});
this.reorderIndicators('number', indicators);
}
};
UIkit.util.on(document, 'moved', '#charts', callback);
UIkit.util.on(document, 'moved', '#numbers', callback);
}
} }
ngOnChanges(changes: SimpleChanges): void { ngOnChanges(changes: SimpleChanges): void {
if (this.canEdit) { if (this.canEdit) {
this.charts = this.stakeholder.topics[this.topicIndex].categories[this.categoryIndex].subCategories[this.subcategoryIndex].charts; this.filterCharts();
this.displayCharts = this.filterChartType(this.filterPrivacy( this.filterNumbers();
this.filterStatus(this.filterByKeyword(this.charts, this.keyword), this.status),
this.privacy),
this.chartType
);
this.numbers = this.stakeholder.topics[this.topicIndex].categories[this.categoryIndex].subCategories[this.subcategoryIndex].numbers;
this.displayNumbers = this.filterPrivacy(this.filterStatus(
this.filterByKeyword(this.numbers, this.keyword),
this.status),
this.privacy);
} }
} }
@ -91,6 +110,21 @@ export class IndicatorsComponent implements OnInit, OnChanges {
this.grid = value; this.grid = value;
} }
filterCharts() {
this.displayCharts = this.filterChartType(this.filterPrivacy(
this.filterStatus(this.filterByKeyword(this.charts, this.keyword), this.status),
this.privacy),
this.chartType
);
}
filterNumbers() {
this.displayNumbers = this.filterPrivacy(this.filterStatus(
this.filterByKeyword(this.numbers, this.keyword),
this.status),
this.privacy);
}
onChartTypeChange(value) { onChartTypeChange(value) {
this.displayCharts = this.filterChartType(this.charts, value); this.displayCharts = this.filterChartType(this.charts, value);
} }
@ -139,14 +173,39 @@ export class IndicatorsComponent implements OnInit, OnChanges {
if (value === null || value === '') { if (value === null || value === '') {
return indicators; return indicators;
} else { } else {
return indicators.filter(indicator => indicator.name.includes(value) || indicator.description.includes(value)); return indicators.filter(indicator => (indicator.name && indicator.name.includes(value))
|| (indicator.description && indicator.description.includes(value)));
} }
} }
get charts(): Indicator[] {
return this.stakeholder.topics[this.topicIndex].categories[this.categoryIndex].subCategories[this.subcategoryIndex].charts;
}
set charts(indicators: Indicator[]) {
this.stakeholder.topics[this.topicIndex].categories[this.categoryIndex].subCategories[this.subcategoryIndex].charts = indicators;
}
get numbers(): Indicator[] {
return this.stakeholder.topics[this.topicIndex].categories[this.categoryIndex].subCategories[this.subcategoryIndex].numbers;
}
set numbers(indicators: Indicator[]) {
this.stakeholder.topics[this.topicIndex].categories[this.categoryIndex].subCategories[this.subcategoryIndex].numbers = indicators;
}
get open(): boolean { get open(): boolean {
return this.sideBarService.open; return this.sideBarService.open;
} }
get canNumbersReorder(): boolean {
return this.displayNumbers.length === this.numbers.length;
}
get canChartsReorder(): boolean {
return this.displayCharts.length === this.charts.length;
}
get canEdit() { get canEdit() {
return this.stakeholder && return this.stakeholder &&
this.stakeholder.topics[this.topicIndex] && this.stakeholder.topics[this.topicIndex] &&
@ -158,6 +217,18 @@ export class IndicatorsComponent implements OnInit, OnChanges {
return this.indicatorFb.get('urls') as FormArray; return this.indicatorFb.get('urls') as FormArray;
} }
public get indicatorPaths(): FormArray {
return this.editIndicatorFb.get('indicatorPaths') as FormArray;
}
public getParameters(index: number): FormArray {
return this.indicatorPaths.at(index).get('parameters') as FormArray;
}
public getParameter(index: number, key: string): FormControl {
return this.getParameters(index).controls.filter(control => control.value.key === key)[0] as FormControl;
}
private getUrlByStakeHolder(indicatorPath: IndicatorPath) { private getUrlByStakeHolder(indicatorPath: IndicatorPath) {
return this.sanitizer.bypassSecurityTrustResourceUrl( return this.sanitizer.bypassSecurityTrustResourceUrl(
this.statisticsService.getChartUrl(indicatorPath.source, this.indicatorUtils.getFullUrl(indicatorPath))); this.statisticsService.getChartUrl(indicatorPath.source, this.indicatorUtils.getFullUrl(indicatorPath)));
@ -201,33 +272,40 @@ export class IndicatorsComponent implements OnInit, OnChanges {
this.indicator.indicatorPaths.push( this.indicator.indicatorPaths.push(
this.indicatorUtils.generateIndicatorByChartUrl(this.statisticsService.getChartSource(url), url)); this.indicatorUtils.generateIndicatorByChartUrl(this.statisticsService.getChartSource(url), url));
}); });
let index = this.charts.push(this.indicator); this.editIndicatorOpen();
this.editIndicatorOpen(index - 1);
} }
public editIndicatorOpen(index: number) { public editIndicatorOpen(index: number = -1) {
this.indicator = HelperFunctions.copy(this.charts[index]); this.index = index;
this.indicator.indicatorPaths.forEach(indicatorPath => { if (this.index !== -1) {
indicatorPath.safeResourceUrl = this.getUrlByStakeHolder(indicatorPath) this.indicator = HelperFunctions.copy(this.charts[index]);
console.log(indicatorPath.safeResourceUrl); }
});
let indicatorPaths = this.fb.array([]); let indicatorPaths = this.fb.array([]);
this.indicator.indicatorPaths.forEach(indicatorPath => { this.indicator.indicatorPaths.forEach(indicatorPath => {
let parameters = this.fb.array([]); let parameters = this.fb.array([]);
indicatorPath.parameters.forEach((value, key) => { if (indicatorPath.parameters) {
if (this.indicatorUtils.ignoredParameters.indexOf(key) === -1) { Object.keys(indicatorPath.parameters).forEach(key => {
// TODO add Validators Map if (this.indicatorUtils.ignoredParameters.indexOf(key) === -1) {
parameters.push(this.fb.group({ if (this.indicatorUtils.parametersValidators.has(key)) {
key: this.fb.control(key), parameters.push(this.fb.group({
value: this.fb.control(value, Validators.required) key: this.fb.control(key),
})); value: this.fb.control(indicatorPath.parameters[key], this.indicatorUtils.parametersValidators.get(key))
} }));
}); } else {
parameters.push(this.fb.group({
key: this.fb.control(key),
value: this.fb.control(indicatorPath.parameters[key], Validators.required)
}));
}
}
});
}
indicatorPaths.push(this.fb.group({ indicatorPaths.push(this.fb.group({
parameters: parameters parameters: parameters
})); }));
}); });
this.editIndicatorFb = this.fb.group({ this.editIndicatorFb = this.fb.group({
id: this.fb.control(this.indicator._id),
name: this.fb.control(this.indicator.name, Validators.required), name: this.fb.control(this.indicator.name, Validators.required),
description: this.fb.control(this.indicator.description), description: this.fb.control(this.indicator.description),
isPublic: this.fb.control(this.indicator.isPublic), isPublic: this.fb.control(this.indicator.isPublic),
@ -235,20 +313,62 @@ export class IndicatorsComponent implements OnInit, OnChanges {
indicatorPaths: indicatorPaths, indicatorPaths: indicatorPaths,
width: this.fb.control(this.indicator.width, Validators.required), width: this.fb.control(this.indicator.width, Validators.required),
}); });
console.log(this.editIndicatorFb.value);
this.editIndicatorModal.alertHeader = false;
this.editIndicatorModal.cancelButtonText = 'Cancel'; this.editIndicatorModal.cancelButtonText = 'Cancel';
this.editIndicatorModal.okButtonText = 'Save Changes'; this.editIndicatorModal.okButtonText = 'Save Changes';
this.editIndicatorModal.okButtonLeft = false; this.editIndicatorModal.okButtonLeft = false;
this.editIndicatorModal.alertMessage = false; this.editIndicatorModal.alertMessage = false;
this.editIndicatorModal.open(); this.editIndicatorModal.open();
setTimeout(() => {
this.indicator.indicatorPaths.forEach(indicatorPath => {
indicatorPath.safeResourceUrl = this.getUrlByStakeHolder(indicatorPath)
});
}, 500);
} }
saveIndicator() { saveIndicator() {
this.indicator = this.indicatorUtils.generateIndicatorByForm(this.editIndicatorFb.value, this.indicator.indicatorPaths);
let path = [
this.stakeholder._id,
this.stakeholder.topics[this.topicIndex]._id,
this.stakeholder.topics[this.topicIndex].categories[this.categoryIndex]._id,
this.stakeholder.topics[this.topicIndex].categories[this.categoryIndex].subCategories[this.subcategoryIndex]._id
];
this.stakeholderService.saveElement(this.properties.monitorServiceAPIURL, this.indicator, path).subscribe(indicator => {
if (this.index !== -1) {
this.charts[this.index] = indicator;
} else {
this.charts.push(indicator);
}
this.filterCharts();
this.stakeholderService.setStakeholder(this.stakeholder);
});
} }
focus(event: FocusEvent) { reorderIndicators(type: string, indicators: Indicator[]) {
event.srcElement.parentElement.className = event.srcElement.parentElement.className + ' md-input-focus'; let path = [
this.stakeholder._id,
this.stakeholder.topics[this.topicIndex]._id,
this.stakeholder.topics[this.topicIndex].categories[this.categoryIndex]._id,
this.stakeholder.topics[this.topicIndex].categories[this.categoryIndex].subCategories[this.subcategoryIndex]._id
];
this.stakeholderService.reorderIndicators(this.properties.monitorServiceAPIURL, path, indicators, type).
subscribe(() => {
if(type === 'chart') {
this.charts = indicators;
this.filterCharts();
} else {
this.numbers = indicators;
this.filterNumbers();
}
this.stakeholderService.setStakeholder(this.stakeholder);
});
}
refreshIndicator(index: number) {
this.indicator = this.indicatorUtils.generateIndicatorByForm(this.editIndicatorFb.value, this.indicator.indicatorPaths);
this.indicator.indicatorPaths.forEach(indicatorPath => {
indicatorPath.safeResourceUrl = this.getUrlByStakeHolder(indicatorPath)
});
this.indicatorPaths.at(index).markAsPristine({onlySelf: true});
} }
} }

View File

@ -114,7 +114,9 @@
<hr> <hr>
<div class="uk-grid-small uk-child-width-1-2" uk-grid> <div class="uk-grid-small uk-child-width-1-2" uk-grid>
<div> <div>
<button class="md-btn md-btn-small" (click)="deleteCategoryOpen(copyCategory.name, editCategory, i)">Delete</button> <button class="md-btn md-btn-small"
(click)="deleteCategoryOpen(copyCategory.name, editCategory, i)">Delete
</button>
</div> </div>
<div> <div>
<button class="md-btn md-btn-small md-btn-primary uk-float-right" <button class="md-btn md-btn-small md-btn-primary uk-float-right"
@ -137,8 +139,8 @@
{{subcategory.name}} {{subcategory.name}}
<button class="uk-position-center-right-out uk-margin-right uk-button uk-button-link onHover" <button class="uk-position-center-right-out uk-margin-right uk-button uk-button-link onHover"
(click)="$event.stopPropagation();editSubCategoryOpen(editSubCategory, j);$event.preventDefault()"> (click)="$event.stopPropagation();editSubCategoryOpen(editSubCategory, j);$event.preventDefault()">
<i class="material-icons">more_horiz</i> <i class="material-icons">more_horiz</i>
</button> </button>
</div> </div>
</a> </a>
<div uk-drop="mode: none; offset: -2; delay-hide: 0" #editSubCategory <div uk-drop="mode: none; offset: -2; delay-hide: 0" #editSubCategory
@ -171,7 +173,9 @@
<hr> <hr>
<div class="uk-grid-small uk-child-width-1-2" uk-grid> <div class="uk-grid-small uk-child-width-1-2" uk-grid>
<div> <div>
<button class="md-btn md-btn-small" (click)="deleteSubcategoryOpen(copySubCategory.name, editSubCategory, j)">Delete</button> <button class="md-btn md-btn-small"
(click)="deleteSubcategoryOpen(copySubCategory.name, editSubCategory, j)">Delete
</button>
</div> </div>
<div> <div>
<button class="md-btn md-btn-small md-btn-primary uk-float-right" <button class="md-btn md-btn-small md-btn-primary uk-float-right"
@ -287,7 +291,8 @@
</ul> </ul>
</div> </div>
</aside> </aside>
<indicators [stakeholder]="stakeholder" <indicators [properties]="properties"
[stakeholder]="stakeholder"
[topicIndex]="topicIndex" [topicIndex]="topicIndex"
[categoryIndex]="categoryIndex" [categoryIndex]="categoryIndex"
[subcategoryIndex]="subCategoryIndex"></indicators> [subcategoryIndex]="subCategoryIndex"></indicators>

View File

@ -112,8 +112,12 @@ export class TopicComponent implements OnInit, OnDestroy {
if(!this.topic.alias) { if(!this.topic.alias) {
this.topic.alias = this.topic.name.toLowerCase().trim(); this.topic.alias = this.topic.name.toLowerCase().trim();
} }
this.stakeholder.topics[this.topicIndex] = HelperFunctions.copy(this.topic); let path = [this.stakeholder._id];
this.save('Topic has been successfully saved', element, true); let callback = (topic: Topic): void => {
this.stakeholder.topics[this.topicIndex] = topic;
this.stakeholderService.setStakeholder(this.stakeholder);
};
this.save('Topic has been successfully saved', element, path, this.topic, callback,true);
} else { } else {
this.valid = false; this.valid = false;
} }
@ -125,10 +129,14 @@ export class TopicComponent implements OnInit, OnDestroy {
public deleteTopic() { public deleteTopic() {
let path: string[] = [ let path: string[] = [
this.stakeholder.alias, this.stakeholder._id,
this.stakeholder.topics[this.topicIndex].alias this.stakeholder.topics[this.topicIndex]._id
]; ];
this.delete('Topic has been successfully be deleted', path, true); let callback = (): void => {
this.stakeholder.topics.splice(this.topicIndex, 1);
this.stakeholderService.setStakeholder(this.stakeholder);
};
this.delete('Topic has been successfully be deleted', path, callback, true);
} }
public toggleCategory(index: number) { public toggleCategory(index: number) {
@ -158,19 +166,19 @@ export class TopicComponent implements OnInit, OnDestroy {
if(!this.copyCategory.alias) { if(!this.copyCategory.alias) {
this.copyCategory.alias = this.copyCategory.name.toLowerCase(); this.copyCategory.alias = this.copyCategory.name.toLowerCase();
} }
let path = [this.stakeholder._id, this.stakeholder.topics[this.topicIndex]._id];
let callback = (category: Category): void => {
if(index === -1) {
this.stakeholder.topics[this.topicIndex].categories.push(category);
} else {
this.stakeholder.topics[this.topicIndex].categories[index] = HelperFunctions.copy(category);
}
this.stakeholderService.setStakeholder(this.stakeholder);
};
if(index === -1) { if(index === -1) {
this.copyCategory.subCategories.push( this.save('Category has been successfully created', element, path, this.copyCategory, callback);
new SubCategory(this.copyCategory.name,
this.copyCategory.description,
this.copyCategory.alias,
this.copyCategory.isPublic,
this.copyCategory.isActive)
);
this.stakeholder.topics[this.topicIndex].categories.push(this.copyCategory);
this.save('Category has been successfully created', element);
} else { } else {
this.stakeholder.topics[this.topicIndex].categories[index] = HelperFunctions.copy(this.copyCategory); this.save('Category has been successfully saved', element, path, this.copyCategory, callback);
this.save('Category has been successfully saved', element);
} }
} else { } else {
this.valid = false; this.valid = false;
@ -183,11 +191,15 @@ export class TopicComponent implements OnInit, OnDestroy {
public deleteCategory() { public deleteCategory() {
let path: string[] = [ let path: string[] = [
this.stakeholder.alias, this.stakeholder._id,
this.stakeholder.topics[this.topicIndex].alias, this.stakeholder.topics[this.topicIndex]._id,
this.stakeholder.topics[this.topicIndex].categories[this.index].alias this.stakeholder.topics[this.topicIndex].categories[this.index]._id
]; ];
this.delete('Category has been successfully be deleted', path); let callback = (): void => {
this.stakeholder.topics[this.topicIndex].categories.splice(this.index, 1);
this.stakeholderService.setStakeholder(this.stakeholder);
};
this.delete('Category has been successfully be deleted', path, callback);
} }
public editSubCategoryOpen(element, index:number = -1) { public editSubCategoryOpen(element, index:number = -1) {
@ -209,14 +221,25 @@ export class TopicComponent implements OnInit, OnDestroy {
if(!this.copySubCategory.alias) { if(!this.copySubCategory.alias) {
this.copySubCategory.alias = this.copySubCategory.name.toLowerCase(); this.copySubCategory.alias = this.copySubCategory.name.toLowerCase();
} }
let path: string[] = [
this.stakeholder._id,
this.stakeholder.topics[this.topicIndex]._id,
this.stakeholder.topics[this.topicIndex].categories[this.selectedCategoryIndex]._id,
];
let callback = (subCategory: SubCategory): void => {
if(index === -1) {
this.stakeholder.topics[this.topicIndex].
categories[this.selectedCategoryIndex].subCategories.push(subCategory);
} else {
this.stakeholder.topics[this.topicIndex].
categories[this.selectedCategoryIndex].subCategories[index] = subCategory;
}
this.stakeholderService.setStakeholder(this.stakeholder);
};
if(index === -1) { if(index === -1) {
this.stakeholder.topics[this.topicIndex].categories[this.selectedCategoryIndex]. this.save('Subcategory has been successfully created', element, path, this.copySubCategory, callback);
subCategories.push(this.copySubCategory);
this.save('Subcategory has been successfully created', element);
} else { } else {
this.stakeholder.topics[this.topicIndex].categories[this.selectedCategoryIndex]. this.save('Subcategory has been successfully saved', element, path, this.copySubCategory, callback);
subCategories[index] = HelperFunctions.copy(this.copySubCategory);
this.save('Subcategory has been successfully saved', element);
} }
this.hide(element); this.hide(element);
} else { } else {
@ -230,12 +253,17 @@ export class TopicComponent implements OnInit, OnDestroy {
public deleteSubcategory() { public deleteSubcategory() {
let path: string[] = [ let path: string[] = [
this.stakeholder.alias, this.stakeholder._id,
this.stakeholder.topics[this.topicIndex].alias, this.stakeholder.topics[this.topicIndex]._id,
this.stakeholder.topics[this.topicIndex].categories[this.selectedCategoryIndex].alias, this.stakeholder.topics[this.topicIndex].categories[this.selectedCategoryIndex]._id,
this.stakeholder.topics[this.topicIndex].categories[this.selectedCategoryIndex].subCategories[this.index].alias this.stakeholder.topics[this.topicIndex].categories[this.selectedCategoryIndex].subCategories[this.index]._id
]; ];
this.delete('Subcategory has been successfully be deleted', path); let callback = (): void => {
this.stakeholder.topics[this.topicIndex].
categories[this.selectedCategoryIndex].subCategories.splice(this.index, 1);
this.stakeholderService.setStakeholder(this.stakeholder);
};
this.delete('Subcategory has been successfully be deleted', path, callback);
} }
private navigateToError() { private navigateToError() {
@ -252,16 +280,16 @@ export class TopicComponent implements OnInit, OnDestroy {
modal.open(); modal.open();
} }
private save(message: string, element, redirect = false) { private save(message: string, element, path: string[], saveElement: any, callback: Function, redirect = false) {
this.stakeholderService.saveStakeholder(this.properties.monitorServiceAPIURL, this.stakeholder).subscribe(stakeholder => { this.stakeholderService.saveElement(this.properties.monitorServiceAPIURL, saveElement, path).subscribe(saveElement => {
this.stakeholderService.setStakeholder(stakeholder); callback(saveElement);
UIkit.notification(message, { UIkit.notification(message, {
status: 'success', status: 'success',
timeout: 3000, timeout: 3000,
pos: 'top-left' pos: 'top-left'
}); });
if(redirect) { if(redirect) {
this.router.navigate(['../' + this.topic.alias], { this.router.navigate(['../' + saveElement.alias], {
relativeTo: this.route relativeTo: this.route
}); });
} }
@ -276,9 +304,9 @@ export class TopicComponent implements OnInit, OnDestroy {
}); });
} }
private delete(message: string, path: string[], redirect = false) { private delete(message: string, path: string[], callback: Function, redirect = false) {
this.stakeholderService.deleteElement(this.properties.monitorServiceAPIURL, path).subscribe(stakeholder => { this.stakeholderService.deleteElement(this.properties.monitorServiceAPIURL, path).subscribe(() => {
this.stakeholderService.setStakeholder(stakeholder); callback();
UIkit.notification(message, { UIkit.notification(message, {
status: 'success', status: 'success',
timeout: 3000, timeout: 3000,

View File

@ -12,10 +12,13 @@ import {RouterModule} from "@angular/router";
import {FormsModule, ReactiveFormsModule} from "@angular/forms"; import {FormsModule, ReactiveFormsModule} from "@angular/forms";
import {IndicatorsComponent} from "./indicators.component"; import {IndicatorsComponent} from "./indicators.component";
import {AlertModalModule} from "../openaireLibrary/utils/modal/alertModal.module"; import {AlertModalModule} from "../openaireLibrary/utils/modal/alertModal.module";
import {InputModule} from "../library/sharedComponents/input/input.module";
import {DragDropModule} from "@angular/cdk/drag-drop";
@NgModule({ @NgModule({
imports: [ imports: [
CommonModule, TopicRoutingModule, ModalModule, RouterModule, FormsModule, AlertModalModule, ReactiveFormsModule CommonModule, TopicRoutingModule, ModalModule, RouterModule, FormsModule, AlertModalModule,
ReactiveFormsModule, InputModule, DragDropModule
], ],
declarations: [ declarations: [
TopicComponent, IndicatorsComponent TopicComponent, IndicatorsComponent

View File

@ -1,15 +1,17 @@
import {SafeResourceUrl} from "@angular/platform-browser"; import {SafeResourceUrl} from "@angular/platform-browser";
import {IndicatorUtils} from "../indicator-utils"; import {IndicatorUtils} from "../indicator-utils";
export const ChartHelper={
prefix : "((__", export const ChartHelper = {
suffix : "__))" prefix: "((__",
suffix: "__))"
}; };
export class Stakeholder { export class Stakeholder {
id: string; _id: string;
type: string; type: string;
index_id; index_id;
index_name: string; index_name: string;
index_shortName:string; index_shortName: string;
alias: string; alias: string;
isDefaultProfile: boolean; isDefaultProfile: boolean;
isActive: boolean; isActive: boolean;
@ -17,14 +19,16 @@ export class Stakeholder {
creationDate: string; creationDate: string;
updateDate: string; updateDate: string;
managers: string[]; managers: string[];
topics:Topic[]; topics: Topic[];
constructor( id: string, type: string, index_id, index_name: string, index_shortName:string , isDefaultProfile: boolean, alias:string , isActive: boolean, isPublic: boolean){
this.initializeFunder(id,type, index_id, index_name, index_shortName, isDefaultProfile, alias, isActive, isPublic); constructor(id: string, type: string, index_id, index_name: string, index_shortName: string, isDefaultProfile: boolean, alias: string, isActive: boolean, isPublic: boolean) {
this.topics =[]; this.initializeFunder(id, type, index_id, index_name, index_shortName, isDefaultProfile, alias, isActive, isPublic);
this.managers =[]; this.topics = [];
this.managers = [];
} }
initializeFunder( id: string, type: string, index_id, index_name: string, index_shortName:string , isDefaultProfile: boolean, alias:string , isActive: boolean, isPublic: boolean){
this.id = id; initializeFunder(id: string, type: string, index_id, index_name: string, index_shortName: string, isDefaultProfile: boolean, alias: string, isActive: boolean, isPublic: boolean) {
this._id = id;
this.type = type; this.type = type;
this.index_id = index_id; this.index_id = index_id;
this.index_name = index_name; this.index_name = index_name;
@ -34,76 +38,77 @@ export class Stakeholder {
this.isActive = isActive; this.isActive = isActive;
this.isPublic = isPublic; this.isPublic = isPublic;
} }
static createECStakeholder():Stakeholder{
let ec:Stakeholder = new Stakeholder("ec","funder","ec__________::EC","European Commission","EC",false,"ec",true,true); static createECStakeholder(): Stakeholder {
let ec: Stakeholder = new Stakeholder("ec", "funder", "ec__________::EC", "European Commission", "EC", false, "ec", true, true);
// new Stakeholder('wt','funder','wt__________::WT','Wellcome Trust','WT',false, 'wt',true,true); // new Stakeholder('wt','funder','wt__________::WT','Wellcome Trust','WT',false, 'wt',true,true);
ec.topics.push(ec.createOSTopic(ec)); ec.topics.push(ec.createOSTopic(ec));
ec.topics.push(ec.createImpactTopic()); ec.topics.push(ec.createImpactTopic());
ec.topics.push(ec.createCollaborationTopic()); ec.topics.push(ec.createCollaborationTopic());
return ec; return ec;
} }
createOSTopic(stakeholder:Stakeholder):Topic{
let topic = new Topic("OpenScience","Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do...","open-science",true,true);
/* let overview:Category = new Category("Overview","","overview",true,true); createOSTopic(stakeholder: Stakeholder): Topic {
topic.categories.push(overview); let topic = new Topic("OpenScience", "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do...", "open-science", true, true);
let overviewDefSub = new SubCategory(null, null,null,true, true);
overview.subCategories.push(overviewDefSub);*/ /* let overview:Category = new Category("Overview","","overview",true,true);
topic.categories.push(overview);
let overviewDefSub = new SubCategory(null, null,null,true, true);
overview.subCategories.push(overviewDefSub);*/
let pubCategory: Category = new Category("Publications", "", "publications", true, true);
let pubCategory:Category = new Category("Publications","","publications",true,true);
topic.categories.push(pubCategory); topic.categories.push(pubCategory);
let pubDefSub = new SubCategory(null, null,null,true, true); let pubDefSub = new SubCategory(null, null, null, true, true);
pubCategory.subCategories.push(pubDefSub); pubCategory.subCategories.push(pubDefSub);
/* let pubOpenSub = new SubCategory("Openess","","openness",true,true); /* let pubOpenSub = new SubCategory("Openess","","openness",true,true);
pubCategory.subCategories.push(pubOpenSub); pubCategory.subCategories.push(pubOpenSub);
let pubFundingSub = new SubCategory("Funding","","funding",true,true); let pubFundingSub = new SubCategory("Funding","","funding",true,true);
pubCategory.subCategories.push(pubFundingSub); pubCategory.subCategories.push(pubFundingSub);
let pubDatasourceSub = new SubCategory("Content Providers","","content-providers",true,true); let pubDatasourceSub = new SubCategory("Content Providers","","content-providers",true,true);
pubCategory.subCategories.push(pubDatasourceSub); pubCategory.subCategories.push(pubDatasourceSub);
let pubDocTypeSub = new SubCategory("Document Type","","doc-type",true,true); let pubDocTypeSub = new SubCategory("Document Type","","doc-type",true,true);
pubCategory.subCategories.push(pubDocTypeSub); pubCategory.subCategories.push(pubDocTypeSub);
let pubFindSub = new SubCategory("Findability","","dindability",true,true); let pubFindSub = new SubCategory("Findability","","dindability",true,true);
pubCategory.subCategories.push(pubFindSub);*/ pubCategory.subCategories.push(pubFindSub);*/
let dataCategory:Category = new Category("Research data","","data",true,true); let dataCategory: Category = new Category("Research data", "", "data", true, true);
topic.categories.push(dataCategory); topic.categories.push(dataCategory);
let dataDefSub = new SubCategory(null, null,null,true, true); let dataDefSub = new SubCategory(null, null, null, true, true);
dataCategory.subCategories.push(dataDefSub); dataCategory.subCategories.push(dataDefSub);
let softwareCategory:Category = new Category("Software","","software",true,true); let softwareCategory: Category = new Category("Software", "", "software", true, true);
topic.categories.push(softwareCategory); topic.categories.push(softwareCategory);
let softDefSub = new SubCategory(null, null,null,true, true); let softDefSub = new SubCategory(null, null, null, true, true);
softwareCategory.subCategories.push(softDefSub); softwareCategory.subCategories.push(softDefSub);
let otherCategory:Category = new Category("Other research products","","other",true,true); let otherCategory: Category = new Category("Other research products", "", "other", true, true);
topic.categories.push(otherCategory); topic.categories.push(otherCategory);
let otherDefSub = new SubCategory(null, null,null,true, true); let otherDefSub = new SubCategory(null, null, null, true, true);
otherCategory.subCategories.push(otherDefSub); otherCategory.subCategories.push(otherDefSub);
/* let datasourceCategory:Category = new Category("Content Providers","","content-providers",true,true); /* let datasourceCategory:Category = new Category("Content Providers","","content-providers",true,true);
topic.categories.push(datasourceCategory); topic.categories.push(datasourceCategory);
let datasourceDefSub = new SubCategory(null, null,null,true, true); let datasourceDefSub = new SubCategory(null, null,null,true, true);
datasourceCategory.subCategories.push(datasourceDefSub);*/ datasourceCategory.subCategories.push(datasourceDefSub);*/
let projectCategory:Category = new Category("Projects","","projects",true,true); let projectCategory: Category = new Category("Projects", "", "projects", true, true);
topic.categories.push(projectCategory); topic.categories.push(projectCategory);
let projectDefSub = new SubCategory(null, null,null,true, true); let projectDefSub = new SubCategory(null, null, null, true, true);
projectCategory.subCategories.push(projectDefSub); projectCategory.subCategories.push(projectDefSub);
//Numbers //Numbers
let n_total_pubs = new Indicator("Publications",'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do...', "number","small",true, true, [new IndicatorPath(null, "statistics","/funders/"+stakeholder.id, null, ["statistics","publications"])]); let n_total_pubs = new Indicator("Publications", 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do...', "number", "small", true, true, [new IndicatorPath(null, "statistics", "/funders/" + stakeholder._id, null, ["statistics", "publications"])]);
let n_open_pubs = new Indicator("OA Publications",'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do...', "number","small",true, true, [new IndicatorPath(null, "statistics","/funders/"+stakeholder.id, null,["statistics","open_access"])]); let n_open_pubs = new Indicator("OA Publications", 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do...', "number", "small", true, true, [new IndicatorPath(null, "statistics", "/funders/" + stakeholder._id, null, ["statistics", "open_access"])]);
let n_total_projects = new Indicator("Projects",null, "number","small",true, true, [new IndicatorPath(null, "statistics","/funders/"+stakeholder.id, null, ["statistics","total_projects"])]); let n_total_projects = new Indicator("Projects", null, "number", "small", true, true, [new IndicatorPath(null, "statistics", "/funders/" + stakeholder._id, null, ["statistics", "total_projects"])]);
let n_total_data = new Indicator("Reserach data",null, "number","small",true, true, [new IndicatorPath(null, "search", let n_total_data = new Indicator("Reserach data", null, "number", "small", true, true, [new IndicatorPath(null, "search",
"/datasets/count?fq="+(encodeURIComponent("relfunderid exact "+stakeholder.index_id))+"&format=json", null, ["total"])]); "/datasets/count?fq=" + (encodeURIComponent("relfunderid exact " + stakeholder.index_id)) + "&format=json", null, ["total"])]);
let n_total_soft = new Indicator("Software",null, "number","small",true, true, [new IndicatorPath(null, "search", let n_total_soft = new Indicator("Software", null, "number", "small", true, true, [new IndicatorPath(null, "search",
"/software/count?fq="+(encodeURIComponent("relfunderid exact "+stakeholder.index_id))+"&format=json", null,["total"])]); "/software/count?fq=" + (encodeURIComponent("relfunderid exact " + stakeholder.index_id)) + "&format=json", null, ["total"])]);
let n_total_other = new Indicator("Other research products",null, "number","small",true, true, [new IndicatorPath(null, "search", let n_total_other = new Indicator("Other research products", null, "number", "small", true, true, [new IndicatorPath(null, "search",
"/other/count?fq="+(encodeURIComponent("relfunderid exact "+stakeholder.index_id))+"&format=json", null,["total"])]); "/other/count?fq=" + (encodeURIComponent("relfunderid exact " + stakeholder.index_id)) + "&format=json", null, ["total"])]);
/*overviewDefSub.numbers.push(n_total_pubs); /*overviewDefSub.numbers.push(n_total_pubs);
overviewDefSub.numbers.push(n_open_pubs); overviewDefSub.numbers.push(n_open_pubs);
@ -122,9 +127,9 @@ export class Stakeholder {
//Charts //Charts
let c_pubs_per_project = new Indicator("Which are the top "+stakeholder.index_shortName+" projects?",'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do...', "chart","large",true, true, [ let c_pubs_per_project = new Indicator("Which are the top " + stakeholder.index_shortName + " projects?", 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do...', "chart", "large", true, true, [
new IndicatorPath("bar", "old","chart.php?com=query&data=",'{"table":"result","fields":[{"fld":"number","agg":"count","type":"'+ChartHelper.prefix+'type'+ChartHelper.suffix+'","yaxis":1,"c":false}],"xaxis":{"name":"result_projects-project-acronym","agg":"avg"},"group":"","color":"","type":"chart","size":30,"sort":"count-number","yaxisheaders":[""],"fieldsheaders":["publications"],"in":[],"filters":[{"name":"result_projects-project-funder","values":["'+ChartHelper.prefix+'funder_name'+ChartHelper.suffix+'"],"to":"-1"},{"name":"type","values":["publication"],"to":"-1"}],"having":[],"xStyle":{"r":"-","s":"-","l":"-","ft":"-","wt":"-"},"title":"'+ChartHelper.prefix+'title'+ChartHelper.suffix+'","subtitle":"","xaxistitle":"project","order":"d"}', null )]); new IndicatorPath("bar", "old", "chart.php?com=query&data=", '{"table":"result","fields":[{"fld":"number","agg":"count","type":"' + ChartHelper.prefix + 'type' + ChartHelper.suffix + '","yaxis":1,"c":false}],"xaxis":{"name":"result_projects-project-acronym","agg":"avg"},"group":"","color":"","type":"chart","size":30,"sort":"count-number","yaxisheaders":[""],"fieldsheaders":["publications"],"in":[],"filters":[{"name":"result_projects-project-funder","values":["' + ChartHelper.prefix + 'funder_name' + ChartHelper.suffix + '"],"to":"-1"},{"name":"type","values":["publication"],"to":"-1"}],"having":[],"xStyle":{"r":"-","s":"-","l":"-","ft":"-","wt":"-"},"title":"' + ChartHelper.prefix + 'title' + ChartHelper.suffix + '","subtitle":"","xaxistitle":"project","order":"d"}', null)]);
c_pubs_per_project.indicatorPaths[0].parameters = IndicatorPath.createParameters(stakeholder.index_name,"Publications per project (top 30)","bar"); c_pubs_per_project.indicatorPaths[0].parameters = IndicatorPath.createParameters(stakeholder.index_name, "Publications per project (top 30)", "bar");
pubDefSub.charts.push(c_pubs_per_project); pubDefSub.charts.push(c_pubs_per_project);
//TO check //TO check
@ -140,11 +145,11 @@ export class Stakeholder {
true, [new IndicatorPath("bar", "stats-tool", "chart?json="+encodeURIComponent('{"library":"HighCharts","chartDescription":{"colors":["#42a5f5","#26a69a","#90ed7d","#607d8b","#00838f","#689f38","#e4d354","#2b908f","#546e7a","#01579"],"queries":[{"name":"Open Access","type":"bar","query":{"select":[{"field":"result","aggregate":"count"},{"field":"result.project.funding level 1","aggregate":null}],"filters":[{"groupFilters":[{"field":"result.project.funder","type":"=","values":["'+ChartHelper.prefix+'funder_name'+ChartHelper.suffix+'"]},{"field":"result.project.funding level 0","type":"=","values":["H2020"]},{"field":"result.type","type":"=","values":["publication"]},{"field":"result.access mode","type":"=","values":["Open Access"]}],"op":"AND"}],"entity":"result","profile":"OpenAIRE original","limit":"0"}},{"name":"Total","type":"bar","query":{"select":[{"field":"result","aggregate":"count"},{"field":"result.project.funding level 1","aggregate":null}],"filters":[{"groupFilters":[{"field":"result.project.funder","type":"=","values":["'+ChartHelper.prefix+'funder_name'+ChartHelper.suffix+'"]},{"field":"result.type","type":"=","values":["publication"]}],"op":"AND"}],"entity":"result","profile":"OpenAIRE original","limit":"0"}}],"chart":{"backgroundColor":"#FFFFFFFF","borderColor":"#335cadff","borderRadius":0,"borderWidth":0,"plotBorderColor":"#ccccccff","plotBorderWidth":0},"title":{"text":"Publications"},"subtitle":{"text":"by funding scheme"},"yAxis":{"title":{"text":"Publications"}},"xAxis":{"title":{"text":"Funding scheme"}},"lang":{"noData":"No Data available for the Query"},"exporting":{"enabled":true},"plotOptions":{"series":{"dataLabels":{"enabled":false}}},"legend":{"enabled":true,"align":"center","verticalAlign":"bottom","layout":"horizontal"},"credits":{"href":null,"enabled":true,"text":"Created by OpenAIRE via HighCharts"}}}'), null)]); true, [new IndicatorPath("bar", "stats-tool", "chart?json="+encodeURIComponent('{"library":"HighCharts","chartDescription":{"colors":["#42a5f5","#26a69a","#90ed7d","#607d8b","#00838f","#689f38","#e4d354","#2b908f","#546e7a","#01579"],"queries":[{"name":"Open Access","type":"bar","query":{"select":[{"field":"result","aggregate":"count"},{"field":"result.project.funding level 1","aggregate":null}],"filters":[{"groupFilters":[{"field":"result.project.funder","type":"=","values":["'+ChartHelper.prefix+'funder_name'+ChartHelper.suffix+'"]},{"field":"result.project.funding level 0","type":"=","values":["H2020"]},{"field":"result.type","type":"=","values":["publication"]},{"field":"result.access mode","type":"=","values":["Open Access"]}],"op":"AND"}],"entity":"result","profile":"OpenAIRE original","limit":"0"}},{"name":"Total","type":"bar","query":{"select":[{"field":"result","aggregate":"count"},{"field":"result.project.funding level 1","aggregate":null}],"filters":[{"groupFilters":[{"field":"result.project.funder","type":"=","values":["'+ChartHelper.prefix+'funder_name'+ChartHelper.suffix+'"]},{"field":"result.type","type":"=","values":["publication"]}],"op":"AND"}],"entity":"result","profile":"OpenAIRE original","limit":"0"}}],"chart":{"backgroundColor":"#FFFFFFFF","borderColor":"#335cadff","borderRadius":0,"borderWidth":0,"plotBorderColor":"#ccccccff","plotBorderWidth":0},"title":{"text":"Publications"},"subtitle":{"text":"by funding scheme"},"yAxis":{"title":{"text":"Publications"}},"xAxis":{"title":{"text":"Funding scheme"}},"lang":{"noData":"No Data available for the Query"},"exporting":{"enabled":true},"plotOptions":{"series":{"dataLabels":{"enabled":false}}},"legend":{"enabled":true,"align":"center","verticalAlign":"bottom","layout":"horizontal"},"credits":{"href":null,"enabled":true,"text":"Created by OpenAIRE via HighCharts"}}}'), null)]);
pubDefSub.charts.push(c_pubs_funding_scheme); pubDefSub.charts.push(c_pubs_funding_scheme);
*/ */
/* //TODO check why doesn't load /* //TODO check why doesn't load
let c_pubs_gg_funding_scheme = new Indicator("What is the percentage of green and gold publications by funding scheme / programme?",null, "chart","medium",true, let c_pubs_gg_funding_scheme = new Indicator("What is the percentage of green and gold publications by funding scheme / programme?",null, "chart","medium",true,
true, [new IndicatorPath("bar", "stats-tool", "chart?json="+encodeURIComponent('{"library":"HighCharts","chartDescription":{"colors":["#42a5f5","#26a69a","#90ed7d","#607d8b","#00838f","#689f38","#e4d354","#2b908f","#546e7a","#01579"],"queries":[{"name":"Gold","color":"#f8b500","type":"bar","query":{"select":[{"field":"result","aggregate":"count"},{"field":"result.project.funding level 1","aggregate":null}],"filters":[{"groupFilters":[{"field":"result.project.funder","type":"=","values":["'+ChartHelper.prefix+'funder_name'+ChartHelper.suffix+'"]},,{"field":"result.type","type":"=","values":["publication"]},{"field":"result.access mode","type":"=","values":["Open Access"]}],"op":"AND"},{"groupFilters":[{"field":"result.datasource.type","type":"=","values":["Journal"]},{"field":"result.datasource.type","type":"=","values":["Journal Aggregator/Publisher"]}],"op":"OR"}],"entity":"result","profile":"OpenAIRE original","limit":"0"}},{"name":"Green","color":"#239d60","type":"bar","query":{"select":[{"field":"result","aggregate":"count"},{"field":"result.project.funding level 1","aggregate":null}],"filters":[{"groupFilters":[{"field":"result.project.funder","type":"=","values":["'+ChartHelper.prefix+'funder_name'+ChartHelper.suffix+'"]},{"field":"result.project.funding level 0","type":"=","values":["H2020"]},{"field":"result.type","type":"=","values":["publication"]},{"field":"result.access mode","type":"=","values":["Open Access"]}],"op":"AND"},{"groupFilters":[{"field":"result.datasource.type","type":"=","values":["Institutional Repository"]},{"field":"result.datasource.type","type":"=","values":["Thematic Repository"]}],"op":"OR"}],"entity":"result","profile":"OpenAIRE original","limit":"0"}}],"chart":{"backgroundColor":"#FFFFFFFF","borderColor":"#335cadff","borderRadius":0,"borderWidth":0,"plotBorderColor":"#ccccccff","plotBorderWidth":0},"title":{"text":"H2020 green and gold publications"},"subtitle":{"text":"by funding scheme"},"yAxis":{"title":{"text":"Publications"}},"xAxis":{"title":{"text":"Funding scheme"}},"lang":{"noData":"No Data available for the Query"},"exporting":{"enabled":true},"plotOptions":{"series":{"dataLabels":{"enabled":false}}},"legend":{"enabled":true,"align":"center","verticalAlign":"bottom","layout":"horizontal"},"credits":{"href":null,"enabled":true,"text":"Created by OpenAIRE via HighCharts"}}}'), null)]); true, [new IndicatorPath("bar", "stats-tool", "chart?json="+encodeURIComponent('{"library":"HighCharts","chartDescription":{"colors":["#42a5f5","#26a69a","#90ed7d","#607d8b","#00838f","#689f38","#e4d354","#2b908f","#546e7a","#01579"],"queries":[{"name":"Gold","color":"#f8b500","type":"bar","query":{"select":[{"field":"result","aggregate":"count"},{"field":"result.project.funding level 1","aggregate":null}],"filters":[{"groupFilters":[{"field":"result.project.funder","type":"=","values":["'+ChartHelper.prefix+'funder_name'+ChartHelper.suffix+'"]},,{"field":"result.type","type":"=","values":["publication"]},{"field":"result.access mode","type":"=","values":["Open Access"]}],"op":"AND"},{"groupFilters":[{"field":"result.datasource.type","type":"=","values":["Journal"]},{"field":"result.datasource.type","type":"=","values":["Journal Aggregator/Publisher"]}],"op":"OR"}],"entity":"result","profile":"OpenAIRE original","limit":"0"}},{"name":"Green","color":"#239d60","type":"bar","query":{"select":[{"field":"result","aggregate":"count"},{"field":"result.project.funding level 1","aggregate":null}],"filters":[{"groupFilters":[{"field":"result.project.funder","type":"=","values":["'+ChartHelper.prefix+'funder_name'+ChartHelper.suffix+'"]},{"field":"result.project.funding level 0","type":"=","values":["H2020"]},{"field":"result.type","type":"=","values":["publication"]},{"field":"result.access mode","type":"=","values":["Open Access"]}],"op":"AND"},{"groupFilters":[{"field":"result.datasource.type","type":"=","values":["Institutional Repository"]},{"field":"result.datasource.type","type":"=","values":["Thematic Repository"]}],"op":"OR"}],"entity":"result","profile":"OpenAIRE original","limit":"0"}}],"chart":{"backgroundColor":"#FFFFFFFF","borderColor":"#335cadff","borderRadius":0,"borderWidth":0,"plotBorderColor":"#ccccccff","plotBorderWidth":0},"title":{"text":"H2020 green and gold publications"},"subtitle":{"text":"by funding scheme"},"yAxis":{"title":{"text":"Publications"}},"xAxis":{"title":{"text":"Funding scheme"}},"lang":{"noData":"No Data available for the Query"},"exporting":{"enabled":true},"plotOptions":{"series":{"dataLabels":{"enabled":false}}},"legend":{"enabled":true,"align":"center","verticalAlign":"bottom","layout":"horizontal"},"credits":{"href":null,"enabled":true,"text":"Created by OpenAIRE via HighCharts"}}}'), null)]);
//pubDefSub.charts.push(c_pubs_gg_funding_scheme); //pubDefSub.charts.push(c_pubs_gg_funding_scheme);
*/ */
/* let c_pubs_open = new Indicator("Open Access publications timeline",null, "chart","small",true, true, /* let c_pubs_open = new Indicator("Open Access publications timeline",null, "chart","small",true, true,
[new IndicatorPath("column", "stats-tool", "chart?json="+encodeURIComponent('{"library":"HighCharts","chartDescription":{"queries":[{"name":"OA publications","type":"column","query":{"select":[{"field":"publication","aggregate":"count"},{"field":"publication.year","aggregate":null}],"filters":[{"groupFilters":[{"field":"publication.access mode","type":"=","values":["Open Access"]}],"op":"AND"},{"groupFilters":[{"field":"publication.year","type":">=","values":["2000"]},{"field":"publication.year","type":"<=","values":["2019"]}],"op":"AND"},{"groupFilters":[{"field":"publication.project.funder","type":"=","values":["'+ChartHelper.prefix+'funder_name'+ChartHelper.suffix+'"]}],"op":"AND"}],"entity":"publication","profile":"OpenAIRE All-inclusive","limit":"30"}}],"chart":{"backgroundColor":"#FFFFFFFF","borderColor":"#335cadff","borderRadius":0,"borderWidth":0,"plotBorderColor":"#ccccccff","plotBorderWidth":0},"title":{"text":"Open Access Publications"},"subtitle":{},"yAxis":{"title":{"text":"publications"}},"xAxis":{"title":{"text":"year"}},"lang":{"noData":"No Data available for the Query"},"exporting":{"enabled":false},"plotOptions":{"series":{"dataLabels":{"enabled":false}}},"legend":{"enabled":true,"align":"center","verticalAlign":"bottom","layout":"horizontal"},"credits":{"href":null,"enabled":true,"text":"Created by OpenAIRE via HighCharts"}}}'), null)]); [new IndicatorPath("column", "stats-tool", "chart?json="+encodeURIComponent('{"library":"HighCharts","chartDescription":{"queries":[{"name":"OA publications","type":"column","query":{"select":[{"field":"publication","aggregate":"count"},{"field":"publication.year","aggregate":null}],"filters":[{"groupFilters":[{"field":"publication.access mode","type":"=","values":["Open Access"]}],"op":"AND"},{"groupFilters":[{"field":"publication.year","type":">=","values":["2000"]},{"field":"publication.year","type":"<=","values":["2019"]}],"op":"AND"},{"groupFilters":[{"field":"publication.project.funder","type":"=","values":["'+ChartHelper.prefix+'funder_name'+ChartHelper.suffix+'"]}],"op":"AND"}],"entity":"publication","profile":"OpenAIRE All-inclusive","limit":"30"}}],"chart":{"backgroundColor":"#FFFFFFFF","borderColor":"#335cadff","borderRadius":0,"borderWidth":0,"plotBorderColor":"#ccccccff","plotBorderWidth":0},"title":{"text":"Open Access Publications"},"subtitle":{},"yAxis":{"title":{"text":"publications"}},"xAxis":{"title":{"text":"year"}},"lang":{"noData":"No Data available for the Query"},"exporting":{"enabled":false},"plotOptions":{"series":{"dataLabels":{"enabled":false}}},"legend":{"enabled":true,"align":"center","verticalAlign":"bottom","layout":"horizontal"},"credits":{"href":null,"enabled":true,"text":"Created by OpenAIRE via HighCharts"}}}'), null)]);
@ -209,57 +214,58 @@ export class Stakeholder {
return topic; return topic;
} }
createImpactTopic():Topic{
let topic = new Topic("Impact/Correlation","Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do...","impact",true,true);
let pubCategory:Category = new Category("Publications","","publications",true,true); createImpactTopic(): Topic {
let topic = new Topic("Impact/Correlation", "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do...", "impact", true, true);
let pubCategory: Category = new Category("Publications", "", "publications", true, true);
topic.categories.push(pubCategory); topic.categories.push(pubCategory);
let pubDefSub = new SubCategory(null, null,null,true, true); let pubDefSub = new SubCategory(null, null, null, true, true);
pubCategory.subCategories.push(pubDefSub); pubCategory.subCategories.push(pubDefSub);
let dataCategory:Category = new Category("Research data","","data",true,true); let dataCategory: Category = new Category("Research data", "", "data", true, true);
topic.categories.push(dataCategory); topic.categories.push(dataCategory);
let dataDefSub = new SubCategory(null, null,null,true, true); let dataDefSub = new SubCategory(null, null, null, true, true);
dataCategory.subCategories.push(dataDefSub); dataCategory.subCategories.push(dataDefSub);
let softwareCategory:Category = new Category("Software","","software",true,true); let softwareCategory: Category = new Category("Software", "", "software", true, true);
topic.categories.push(softwareCategory); topic.categories.push(softwareCategory);
let softDefSub = new SubCategory(null, null,null,true, true); let softDefSub = new SubCategory(null, null, null, true, true);
softwareCategory.subCategories.push(softDefSub); softwareCategory.subCategories.push(softDefSub);
/* let otherCategory:Category = new Category("Other research products","","other",true,true); /* let otherCategory:Category = new Category("Other research products","","other",true,true);
topic.categories.push(otherCategory); topic.categories.push(otherCategory);
let otherDefSub = new SubCategory(null, null,null,true, true); let otherDefSub = new SubCategory(null, null,null,true, true);
otherCategory.subCategories.push(otherDefSub);*/ otherCategory.subCategories.push(otherDefSub);*/
return topic; return topic;
} }
createCollaborationTopic():Topic{
let topic = new Topic("Demo Topic","This is a demo topic","demo-topic",true,true);
let category1:Category = new Category("Category 1","This is ","cat-1",true,true); createCollaborationTopic(): Topic {
let topic = new Topic("Demo Topic", "This is a demo topic", "demo-topic", true, true);
let category1: Category = new Category("Category 1", "This is ", "cat-1", true, true);
topic.categories.push(category1); topic.categories.push(category1);
let subCat1 = new SubCategory("Sub-category 1","","sub-cat-1",true,true); let subCat1 = new SubCategory("Sub-category 1", "", "sub-cat-1", true, true);
category1.subCategories.push(subCat1); category1.subCategories.push(subCat1);
let subCat2 = new SubCategory("Sub-category 2","","sub-cat-2",true,true); let subCat2 = new SubCategory("Sub-category 2", "", "sub-cat-2", true, true);
category1.subCategories.push(subCat2); category1.subCategories.push(subCat2);
let category2: Category = new Category("Category 2 - no subcategories", "", "cat-2", true, true);
let category2:Category = new Category("Category 2 - no subcategories","","cat-2",true,true);
topic.categories.push(category2); topic.categories.push(category2);
let defSub = new SubCategory(null, null,null,true, true); let defSub = new SubCategory(null, null, null, true, true);
category2.subCategories.push(defSub); category2.subCategories.push(defSub);
let chart1 = new Indicator( let chart1 = new Indicator(
"Chart title goes here","Chart description goes here", "chart","medium",true, true, "Chart title goes here", "Chart description goes here", "chart", "medium", true, true,
[new IndicatorPath("?", "fake","https://visme.co/blog/wp-content/uploads/2017/03/Dogs-vs-Cats-How-much-they-miss-you-relative-to-the-time-you-are-gone.png", null, null)]); [new IndicatorPath("?", "fake", "https://visme.co/blog/wp-content/uploads/2017/03/Dogs-vs-Cats-How-much-they-miss-you-relative-to-the-time-you-are-gone.png", null, null)]);
let chart2 = new Indicator("Chart title goes here","Chart description goes here", "chart","medium",true, true, [new IndicatorPath("?", "fake","https://static.boredpanda.com/blog/wp-content/uuuploads/funny-graphs-2/funny-graphs-legs.jpg", null, null)]); let chart2 = new Indicator("Chart title goes here", "Chart description goes here", "chart", "medium", true, true, [new IndicatorPath("?", "fake", "https://static.boredpanda.com/blog/wp-content/uuuploads/funny-graphs-2/funny-graphs-legs.jpg", null, null)]);
subCat1.charts.push(chart1); subCat1.charts.push(chart1);
subCat2.charts.push(chart2); subCat2.charts.push(chart2);
@ -267,15 +273,15 @@ export class Stakeholder {
defSub.charts.push(chart2); defSub.charts.push(chart2);
let utils = new IndicatorUtils(); let utils = new IndicatorUtils();
let url = "https://beta.openaire.eu/stats/chart.php?com=query&data={%22table%22:%22result%22,%22fields%22:[{%22fld%22:%22number%22,%22agg%22:%22count%22,%22type%22:%22bar%22,%22yaxis%22:1,%22c%22:false}],%22xaxis%22:{%22name%22:%22result_datasources-datasource-name%22,%22agg%22:%22avg%22},%22group%22:%22%22,%22color%22:%22%22,%22type%22:%22chart%22,%22size%22:%2220%22,%22sort%22:%22count-number%22,%22yaxisheaders%22:[%22%22],%22fieldsheaders%22:[%22publications%22],%22in%22:[],%22filters%22:[{%22name%22:%22result_projects-project-funding_lvl0%22,%22values%22:[%22H2020%22],%22to%22:%22-1%22},{%22name%22:%22type%22,%22values%22:[%22publication%22],%22to%22:%22-1%22},{%22name%22:%22result_datasources-datasource-type%22,%22exvalues%22:[%22Publication%20Catalogue%22]}],%22having%22:[],%22xStyle%22:{%22r%22:%22-%22,%22s%22:%22-%22,%22l%22:%22-%22,%22ft%22:%22-%22,%22wt%22:%22-%22},%22title%22:%22H2020%20Publications%20by%20datasource%20%28top%2020%29%22,%22subtitle%22:%22%22,%22xaxistitle%22:%22datasource%22,%22order%22:%22d%22}&w=90%"; let url = "https://beta.openaire.eu/stats/chart.php?com=query&data={%22table%22:%22result%22,%22fields%22:[{%22fld%22:%22number%22,%22agg%22:%22count%22,%22type%22:%22bar%22,%22yaxis%22:1,%22c%22:false}],%22xaxis%22:{%22name%22:%22result_datasources-datasource-name%22,%22agg%22:%22avg%22},%22group%22:%22%22,%22color%22:%22%22,%22type%22:%22chart%22,%22size%22:%2220%22,%22sort%22:%22count-number%22,%22yaxisheaders%22:[%22%22],%22fieldsheaders%22:[%22publications%22],%22in%22:[],%22filters%22:[{%22name%22:%22result_projects-project-funding_lvl0%22,%22values%22:[%22H2020%22],%22to%22:%22-1%22},{%22name%22:%22type%22,%22values%22:[%22publication%22],%22to%22:%22-1%22},{%22name%22:%22result_datasources-datasource-type%22,%22exvalues%22:[%22Publication%20Catalogue%22]}],%22having%22:[],%22xStyle%22:{%22r%22:%22-%22,%22s%22:%22-%22,%22l%22:%22-%22,%22ft%22:%22-%22,%22wt%22:%22-%22},%22title%22:%22H2020%20Publications%20by%20datasource%20%28top%2020%29%22,%22subtitle%22:%22%22,%22xaxistitle%22:%22datasource%22,%22order%22:%22d%22}&w=90%";
defSub.charts.push(new Indicator("Old tool graph","","chart","large",true,true,[utils.generateIndicatorByChartUrl("old",url,"bar")])) defSub.charts.push(new Indicator("Old tool graph", "", "chart", "large", true, true, [utils.generateIndicatorByChartUrl("old", url, "bar")]))
url = "http://88.197.53.71:8080/stats-api/chart?json=%7B%22library%22%3A%22HighCharts%22%2C%22chartDescription%22%3A%7B%22queries%22%3A%5B%7B%22name%22%3A%22Research%20data%22%2C%22type%22%3A%22column%22%2C%22query%22%3A%7B%22select%22%3A%5B%7B%22field%22%3A%22dataset%22%2C%22aggregate%22%3A%22count%22%7D%2C%7B%22field%22%3A%22dataset.year%22%2C%22aggregate%22%3Anull%7D%5D%2C%22filters%22%3A%5B%7B%22groupFilters%22%3A%5B%7B%22field%22%3A%22dataset.project.funder%22%2C%22type%22%3A%22%3D%22%2C%22values%22%3A%5B%22European%20Commission%22%5D%7D%5D%2C%22op%22%3A%22AND%22%7D%2C%7B%22groupFilters%22%3A%5B%7B%22field%22%3A%22dataset.year%22%2C%22type%22%3A%22%3E%3D%22%2C%22values%22%3A%5B%222008%22%5D%7D%2C%7B%22field%22%3A%22dataset.year%22%2C%22type%22%3A%22%3C%3D%22%2C%22values%22%3A%5B%222020%22%5D%7D%5D%2C%22op%22%3A%22AND%22%7D%5D%2C%22entity%22%3A%22dataset%22%2C%22profile%22%3A%22OpenAIRE%20All-inclusive%22%2C%22limit%22%3A%220%22%7D%7D%5D%2C%22chart%22%3A%7B%22backgroundColor%22%3A%22%23FFFFFFFF%22%2C%22borderColor%22%3A%22%23335cadff%22%2C%22borderRadius%22%3A0%2C%22borderWidth%22%3A0%2C%22plotBorderColor%22%3A%22%23ccccccff%22%2C%22plotBorderWidth%22%3A0%7D%2C%22title%22%3A%7B%22text%22%3A%22Research%20data%20timeline%22%7D%2C%22subtitle%22%3A%7B%7D%2C%22yAxis%22%3A%7B%22title%22%3A%7B%22text%22%3A%22Research%20data%22%7D%7D%2C%22xAxis%22%3A%7B%22title%22%3A%7B%22text%22%3A%22Year%22%7D%7D%2C%22lang%22%3A%7B%22noData%22%3A%22No%20Data%20available%20for%20the%20Query%22%7D%2C%22exporting%22%3A%7B%22enabled%22%3Atrue%7D%2C%22plotOptions%22%3A%7B%22series%22%3A%7B%22dataLabels%22%3A%7B%22enabled%22%3Afalse%7D%7D%7D%2C%22legend%22%3A%7B%22enabled%22%3Atrue%2C%22align%22%3A%22center%22%2C%22verticalAlign%22%3A%22bottom%22%2C%22layout%22%3A%22horizontal%22%7D%2C%22credits%22%3A%7B%22href%22%3Anull%2C%22enabled%22%3Atrue%2C%22text%22%3A%22Created%20by%20OpenAIRE%20via%20HighCharts%22%7D%7D%7D"; url = "http://88.197.53.71:8080/stats-api/chart?json=%7B%22library%22%3A%22HighCharts%22%2C%22chartDescription%22%3A%7B%22queries%22%3A%5B%7B%22name%22%3A%22Research%20data%22%2C%22type%22%3A%22column%22%2C%22query%22%3A%7B%22select%22%3A%5B%7B%22field%22%3A%22dataset%22%2C%22aggregate%22%3A%22count%22%7D%2C%7B%22field%22%3A%22dataset.year%22%2C%22aggregate%22%3Anull%7D%5D%2C%22filters%22%3A%5B%7B%22groupFilters%22%3A%5B%7B%22field%22%3A%22dataset.project.funder%22%2C%22type%22%3A%22%3D%22%2C%22values%22%3A%5B%22European%20Commission%22%5D%7D%5D%2C%22op%22%3A%22AND%22%7D%2C%7B%22groupFilters%22%3A%5B%7B%22field%22%3A%22dataset.year%22%2C%22type%22%3A%22%3E%3D%22%2C%22values%22%3A%5B%222008%22%5D%7D%2C%7B%22field%22%3A%22dataset.year%22%2C%22type%22%3A%22%3C%3D%22%2C%22values%22%3A%5B%222020%22%5D%7D%5D%2C%22op%22%3A%22AND%22%7D%5D%2C%22entity%22%3A%22dataset%22%2C%22profile%22%3A%22OpenAIRE%20All-inclusive%22%2C%22limit%22%3A%220%22%7D%7D%5D%2C%22chart%22%3A%7B%22backgroundColor%22%3A%22%23FFFFFFFF%22%2C%22borderColor%22%3A%22%23335cadff%22%2C%22borderRadius%22%3A0%2C%22borderWidth%22%3A0%2C%22plotBorderColor%22%3A%22%23ccccccff%22%2C%22plotBorderWidth%22%3A0%7D%2C%22title%22%3A%7B%22text%22%3A%22Research%20data%20timeline%22%7D%2C%22subtitle%22%3A%7B%7D%2C%22yAxis%22%3A%7B%22title%22%3A%7B%22text%22%3A%22Research%20data%22%7D%7D%2C%22xAxis%22%3A%7B%22title%22%3A%7B%22text%22%3A%22Year%22%7D%7D%2C%22lang%22%3A%7B%22noData%22%3A%22No%20Data%20available%20for%20the%20Query%22%7D%2C%22exporting%22%3A%7B%22enabled%22%3Atrue%7D%2C%22plotOptions%22%3A%7B%22series%22%3A%7B%22dataLabels%22%3A%7B%22enabled%22%3Afalse%7D%7D%7D%2C%22legend%22%3A%7B%22enabled%22%3Atrue%2C%22align%22%3A%22center%22%2C%22verticalAlign%22%3A%22bottom%22%2C%22layout%22%3A%22horizontal%22%7D%2C%22credits%22%3A%7B%22href%22%3Anull%2C%22enabled%22%3Atrue%2C%22text%22%3A%22Created%20by%20OpenAIRE%20via%20HighCharts%22%7D%7D%7D";
defSub.charts.push(new Indicator("","","chart","large",true,true,[utils.generateIndicatorByChartUrl("stats-tool",url,"bar")])) defSub.charts.push(new Indicator("", "", "chart", "large", true, true, [utils.generateIndicatorByChartUrl("stats-tool", url, "bar")]))
return topic; return topic;
} }
} }
export class Topic { export class Topic {
id:string; _id: string;
name: string; name: string;
alias: string; alias: string;
description: string; description: string;
@ -283,9 +289,10 @@ export class Topic {
isPublic: boolean; isPublic: boolean;
isDefault: boolean; isDefault: boolean;
categories: Category[]; categories: Category[];
constructor(name: string, description: string, alias:string , isActive: boolean, isPublic: boolean) {
this.id = null; constructor(name: string, description: string, alias: string, isActive: boolean, isPublic: boolean) {
this.name = name; this._id = null;
this.name = name;
this.description = description; this.description = description;
this.alias = alias; this.alias = alias;
this.isActive = isActive; this.isActive = isActive;
@ -293,8 +300,9 @@ export class Topic {
this.categories = []; this.categories = [];
} }
} }
export class Category { export class Category {
id:string; _id: string;
name: string; name: string;
alias: string; alias: string;
description: string; description: string;
@ -303,9 +311,10 @@ export class Category {
isOverview: boolean; isOverview: boolean;
isDefault: boolean; isDefault: boolean;
subCategories: SubCategory[]; subCategories: SubCategory[];
constructor(name: string, description: string, alias:string , isActive: boolean, isPublic: boolean) {
this.id = null; constructor(name: string, description: string, alias: string, isActive: boolean, isPublic: boolean) {
this.name = name; this._id = null;
this.name = name;
this.description = description; this.description = description;
this.alias = alias; this.alias = alias;
this.isActive = isActive; this.isActive = isActive;
@ -315,7 +324,7 @@ export class Category {
} }
export class SubCategory { export class SubCategory {
id:string; _id: string;
name: string; name: string;
alias: string; alias: string;
description: string; description: string;
@ -324,9 +333,10 @@ export class SubCategory {
isDefault: boolean; isDefault: boolean;
charts: Indicator[]; charts: Indicator[];
numbers: Indicator[]; numbers: Indicator[];
constructor(name: string, description: string, alias:string , isActive: boolean, isPublic: boolean) {
this.id = null; constructor(name: string, description: string, alias: string, isActive: boolean, isPublic: boolean) {
this.name = name; this._id = null;
this.name = name;
this.description = description; this.description = description;
this.alias = alias; this.alias = alias;
this.isActive = isActive; this.isActive = isActive;
@ -336,22 +346,24 @@ export class SubCategory {
} }
} }
export class Indicator { export class Indicator {
id:string; _id: string;
name: string; name: string;
description: string; description: string;
type:string; //number,chart type: string; //number,chart
width:string; //small,medium,large width: string; //small,medium,large
tags:string[]; tags: string[];
isActive: boolean; isActive: boolean;
isPublic: boolean; isPublic: boolean;
isDefault: boolean; isDefault: boolean;
indicatorPaths:IndicatorPath[]; indicatorPaths: IndicatorPath[];
constructor(name: string, description: string, type:string , width:string, isActive: boolean, isPublic: boolean, indicatorPaths:IndicatorPath[]){
this.id = null; constructor(name: string, description: string, type: string, width: string, isActive: boolean, isPublic: boolean, indicatorPaths: IndicatorPath[]) {
this.name = name; this._id = null;
this.name = name;
this.description = description; this.description = description;
this.type = type; this.type = type;
this.width = width; this.width = width;
this.isActive = isActive; this.isActive = isActive;
this.isPublic = isPublic; this.isPublic = isPublic;
@ -362,35 +374,37 @@ export class Indicator {
export class IndicatorPath { export class IndicatorPath {
type: string; // for charts is type of chart {table, bar, column, etc} type: string; // for charts is type of chart {table, bar, column, etc}
source:string;// for numbers is the service {statistics, search, metrics} for charts is the tool {stats-tool,old,metrics, fake} source: string;// for numbers is the service {statistics, search, metrics} for charts is the tool {stats-tool,old,metrics, fake}
url: string; url: string;
safeResourceUrl: SafeResourceUrl; // initialize on front end safeResourceUrl: SafeResourceUrl; // initialize on front end
jsonPath:string[]; jsonPath: string[];
chartObject:string; chartObject: string;
parameters:Map<string,string>; parameters: any;
filters:Map<string, string>; filters: any;
constructor(type: string, source:string, url: string, chartObject:string, jsonPath:string[]){
this.type = type; constructor(type: string, source: string, url: string, chartObject: string, jsonPath: string[]) {
this.type = type;
this.url = url; this.url = url;
this.source = source; this.source = source;
this.jsonPath = jsonPath; this.jsonPath = jsonPath;
this.chartObject =chartObject; this.chartObject = chartObject;
this.parameters = new Map<string, string>(); this.parameters = {};
this.filters = new Map<string, string>(); this.filters = {};
} }
static createParameters(funderName:string=null, title:string=null, chartType:string=null):Map<string, string>{ static createParameters(funderName: string = null, title: string = null, chartType: string = null): any {
let parameters = new Map<string, string>(); return {
parameters.set("funder_name",funderName); funder_name: funderName,
parameters.set("title",title); title: title,
parameters.set("type",chartType); type: chartType
return parameters; };
} }
static createResultFilters(dbType:string=null):Map<string, string>{
let filters = new Map<string, string>(); static createResultFilters(dbType: string = null): any {
filters.set("fundingL0",'{"groupFilters":[{"field":"'+dbType+'.project.funding level 0","type":"=","values":["'+ChartHelper.prefix+'fundingL0'+ChartHelper.suffix+'"]}],"op":"AND"}'); return {
filters.set("start_year",'{"groupFilters":[{"field":"'+dbType+'.year","type":">=","values":["'+ChartHelper.prefix+'start_year'+ChartHelper.suffix+'"]}],"op":"AND"}'); fundingL0: '{"groupFilters":[{"field":"' + dbType + '.project.funding level 0","type":"=","values":["' + ChartHelper.prefix + 'fundingL0' + ChartHelper.suffix + '"]}],"op":"AND"}',
filters.set("end_year",'{"groupFilters":[{"field":"'+dbType+'.year","type":"<=","values":["'+ChartHelper.prefix+'end_year'+ChartHelper.suffix+'"]}],"op":"AND"}'); start_year: '{"groupFilters":[{"field":"' + dbType + '.year","type":">=","values":["' + ChartHelper.prefix + 'start_year' + ChartHelper.suffix + '"]}],"op":"AND"}',
return filters; end_year: '{"groupFilters":[{"field":"' + dbType + '.year","type":"<=","values":["' + ChartHelper.prefix + 'end_year' + ChartHelper.suffix + '"]}],"op":"AND"}'
};
} }
} }

View File

@ -21,11 +21,11 @@ export class StakeholderCreator {
for (let indicator of subCategory.charts) { for (let indicator of subCategory.charts) {
for (let indicatorPath of indicator.indicatorPaths) { for (let indicatorPath of indicator.indicatorPaths) {
if(indicatorPath.parameters) { if(indicatorPath.parameters) {
indicatorPath.parameters.forEach((value: string, key: string) => { Object.keys(indicatorPath.parameters).forEach(key => {
if (value.indexOf("_funder_name_")!=-1) { if (indicatorPath.parameters[key].indexOf("_funder_name_")!=-1) {
indicatorPath.parameters.set(key,value.toString().replace("_funder_name_", funder.index_name)); indicatorPath.parameters[key].replace("_funder_name_", funder.index_name);
}else if (value.indexOf("_fsn_")!=-1) { } else if (indicatorPath.parameters[key].indexOf("_fsn_")!=-1) {
indicatorPath.parameters.set(key,value.toString().replace("_fsn_", funder.index_shortName.toLowerCase())); indicatorPath.parameters[key].toString().replace("_fsn_", funder.index_shortName.toLowerCase());
} }
}); });
} }
@ -87,7 +87,7 @@ export class StakeholderCreator {
let n_total = new Indicator("Total "+typePlural,null, "number","small",true, true, [new IndicatorPath(null, "search", let n_total = new Indicator("Total "+typePlural,null, "number","small",true, true, [new IndicatorPath(null, "search",
"/"+dbTypePlural+"/count?fq="+(encodeURIComponent("relfunderid exact "+stakeholder.index_id))+"&format=json", null,["total"])]); "/"+dbTypePlural+"/count?fq="+(encodeURIComponent("relfunderid exact "+stakeholder.index_id))+"&format=json", null,["total"])]);
n_total.indicatorPaths[0].filters.set("fundingL0","&fq=relfundinglevel0_name exact "+ChartHelper.prefix+'fundingL0'+ChartHelper.suffix); n_total.indicatorPaths[0].filters["fundingL0"] = "&fq=relfundinglevel0_name exact "+ChartHelper.prefix+'fundingL0'+ChartHelper.suffix;
pubDefSub.numbers.push(n_total); pubDefSub.numbers.push(n_total);
if( dbType != "publication") { if( dbType != "publication") {
@ -100,8 +100,8 @@ export class StakeholderCreator {
let res_timeline = new Indicator("",null, "chart","small",true, true,[new IndicatorPath("column", "stats-tool", "chart?json=", '{"library":"HighCharts","chartDescription":{"queries":[{"name":"'+typePlural+'","type":"'+ChartHelper.prefix+'type'+ChartHelper.suffix+'","query":{"select":[{"field":"'+dbType+'","aggregate":"count"},{"field":"'+dbType+'.year","aggregate":null}],"filters":[{"groupFilters":[{"field":"'+dbType+'.project.funder","type":"=","values":["'+ChartHelper.prefix+'funder_name'+ChartHelper.suffix+'"]}],"op":"AND"},{"groupFilters":[{"field":"'+dbType+'.year","type":">=","values":["'+ChartHelper.prefix+'start_year'+ChartHelper.suffix+'"]},{"field":"'+dbType+'.year","type":"<=","values":["'+ChartHelper.prefix+'end_year'+ChartHelper.suffix+'"]}],"op":"AND"}],"entity":"'+dbType+'","profile":"OpenAIRE All-inclusive","limit":"0"}}],"chart":{"backgroundColor":"#FFFFFFFF","borderColor":"#335cadff","borderRadius":0,"borderWidth":0,"plotBorderColor":"#ccccccff","plotBorderWidth":0},"title":{"text":"'+ChartHelper.prefix+'title'+ChartHelper.suffix+'"},"subtitle":{},"yAxis":{"title":{"text":"'+typePlural+'"}},"xAxis":{"title":{"text":"Year"}},"lang":{"noData":"No Data available for the Query"},"exporting":{"enabled":true},"plotOptions":{"series":{"dataLabels":{"enabled":false}}},"legend":{"enabled":true,"align":"center","verticalAlign":"bottom","layout":"horizontal"},"credits":{"href":null,"enabled":true,"text":"Created by OpenAIRE via HighCharts"}}}', null)]); let res_timeline = new Indicator("",null, "chart","small",true, true,[new IndicatorPath("column", "stats-tool", "chart?json=", '{"library":"HighCharts","chartDescription":{"queries":[{"name":"'+typePlural+'","type":"'+ChartHelper.prefix+'type'+ChartHelper.suffix+'","query":{"select":[{"field":"'+dbType+'","aggregate":"count"},{"field":"'+dbType+'.year","aggregate":null}],"filters":[{"groupFilters":[{"field":"'+dbType+'.project.funder","type":"=","values":["'+ChartHelper.prefix+'funder_name'+ChartHelper.suffix+'"]}],"op":"AND"},{"groupFilters":[{"field":"'+dbType+'.year","type":">=","values":["'+ChartHelper.prefix+'start_year'+ChartHelper.suffix+'"]},{"field":"'+dbType+'.year","type":"<=","values":["'+ChartHelper.prefix+'end_year'+ChartHelper.suffix+'"]}],"op":"AND"}],"entity":"'+dbType+'","profile":"OpenAIRE All-inclusive","limit":"0"}}],"chart":{"backgroundColor":"#FFFFFFFF","borderColor":"#335cadff","borderRadius":0,"borderWidth":0,"plotBorderColor":"#ccccccff","plotBorderWidth":0},"title":{"text":"'+ChartHelper.prefix+'title'+ChartHelper.suffix+'"},"subtitle":{},"yAxis":{"title":{"text":"'+typePlural+'"}},"xAxis":{"title":{"text":"Year"}},"lang":{"noData":"No Data available for the Query"},"exporting":{"enabled":true},"plotOptions":{"series":{"dataLabels":{"enabled":false}}},"legend":{"enabled":true,"align":"center","verticalAlign":"bottom","layout":"horizontal"},"credits":{"href":null,"enabled":true,"text":"Created by OpenAIRE via HighCharts"}}}', null)]);
res_timeline.indicatorPaths[0].parameters = IndicatorPath.createParameters(stakeholder.index_name,typePlural+" timeline","column"); res_timeline.indicatorPaths[0].parameters = IndicatorPath.createParameters(stakeholder.index_name,typePlural+" timeline","column");
res_timeline.indicatorPaths[0].parameters.set("start_year","2008"); res_timeline.indicatorPaths[0].parameters["start_year"] = "2008";
res_timeline.indicatorPaths[0].parameters.set("end_year","2020"); res_timeline.indicatorPaths[0].parameters["end_year"] = "2020";
res_timeline.indicatorPaths[0].filters = IndicatorPath.createResultFilters(dbType); res_timeline.indicatorPaths[0].filters = IndicatorPath.createResultFilters(dbType);
pubDefSub.charts.push(res_timeline); pubDefSub.charts.push(res_timeline);
@ -138,32 +138,32 @@ export class StakeholderCreator {
let datasource = new Indicator("",null, "chart","small",true, true,[new IndicatorPath("bar", "stats-tool", "chart?json=", let datasource = new Indicator("",null, "chart","small",true, true,[new IndicatorPath("bar", "stats-tool", "chart?json=",
'{"library":"HighCharts","chartDescription":{"queries":[{"name":"'+typePlural+'","type":"'+ChartHelper.prefix+'type'+ChartHelper.suffix+'","query":{"name":"monitor.'+ChartHelper.prefix+'id'+ChartHelper.suffix+'.'+dbTypePlural+'.datasources"}}],"chart":{"backgroundColor":"#FFFFFFFF","borderColor":"#335cadff","borderRadius":0,"borderWidth":0,"plotBorderColor":"#ccccccff","plotBorderWidth":0},"title":{"text":"'+ChartHelper.prefix+'title'+ChartHelper.suffix+'"},"subtitle":{},"yAxis":{"title":{"text":"'+typePlural+'"}},"xAxis":{"title":{"text":"Content provider"}},"lang":{"noData":"No Data available for the Query"},"exporting":{"enabled":true},"plotOptions":{"series":{"dataLabels":{"enabled":false}}},"legend":{"enabled":true,"align":"center","verticalAlign":"bottom","layout":"horizontal"},"credits":{"href":null,"enabled":true,"text":"Created by OpenAIRE via HighCharts"}}}', null)]); '{"library":"HighCharts","chartDescription":{"queries":[{"name":"'+typePlural+'","type":"'+ChartHelper.prefix+'type'+ChartHelper.suffix+'","query":{"name":"monitor.'+ChartHelper.prefix+'id'+ChartHelper.suffix+'.'+dbTypePlural+'.datasources"}}],"chart":{"backgroundColor":"#FFFFFFFF","borderColor":"#335cadff","borderRadius":0,"borderWidth":0,"plotBorderColor":"#ccccccff","plotBorderWidth":0},"title":{"text":"'+ChartHelper.prefix+'title'+ChartHelper.suffix+'"},"subtitle":{},"yAxis":{"title":{"text":"'+typePlural+'"}},"xAxis":{"title":{"text":"Content provider"}},"lang":{"noData":"No Data available for the Query"},"exporting":{"enabled":true},"plotOptions":{"series":{"dataLabels":{"enabled":false}}},"legend":{"enabled":true,"align":"center","verticalAlign":"bottom","layout":"horizontal"},"credits":{"href":null,"enabled":true,"text":"Created by OpenAIRE via HighCharts"}}}', null)]);
datasource.indicatorPaths[0].parameters = IndicatorPath.createParameters(stakeholder.index_name,typeSingl+" content provider","bar"); datasource.indicatorPaths[0].parameters = IndicatorPath.createParameters(stakeholder.index_name,typeSingl+" content provider","bar");
datasource.indicatorPaths[0].parameters.set("id",stakeholder.index_shortName.toLowerCase()); datasource.indicatorPaths[0].parameters["id"] = stakeholder.index_shortName.toLowerCase();
pubDefSub.charts.push(datasource); pubDefSub.charts.push(datasource);
if(dbType == "publication") { if(dbType == "publication") {
let journal = new Indicator("", null, "chart", "small", true, true, [new IndicatorPath("bar", "stats-tool", "chart?json=", let journal = new Indicator("", null, "chart", "small", true, true, [new IndicatorPath("bar", "stats-tool", "chart?json=",
'{"library":"HighCharts","chartDescription":{"queries":[{"name":"' + typePlural + '","type":"' + ChartHelper.prefix + 'type' + ChartHelper.suffix + '","query":{"name":"monitor.' + ChartHelper.prefix + 'id' + ChartHelper.suffix + '.' + dbTypePlural + '.journals"}}],"chart":{"backgroundColor":"#FFFFFFFF","borderColor":"#335cadff","borderRadius":0,"borderWidth":0,"plotBorderColor":"#ccccccff","plotBorderWidth":0},"title":{"text":"' + ChartHelper.prefix + 'title' + ChartHelper.suffix + '"},"subtitle":{},"yAxis":{"title":{"text":"' + typePlural + '"}},"xAxis":{"title":{"text":"Journal"}},"lang":{"noData":"No Data available for the Query"},"exporting":{"enabled":true},"plotOptions":{"series":{"dataLabels":{"enabled":false}}},"legend":{"enabled":true,"align":"center","verticalAlign":"bottom","layout":"horizontal"},"credits":{"href":null,"enabled":true,"text":"Created by OpenAIRE via HighCharts"}}}', null)]); '{"library":"HighCharts","chartDescription":{"queries":[{"name":"' + typePlural + '","type":"' + ChartHelper.prefix + 'type' + ChartHelper.suffix + '","query":{"name":"monitor.' + ChartHelper.prefix + 'id' + ChartHelper.suffix + '.' + dbTypePlural + '.journals"}}],"chart":{"backgroundColor":"#FFFFFFFF","borderColor":"#335cadff","borderRadius":0,"borderWidth":0,"plotBorderColor":"#ccccccff","plotBorderWidth":0},"title":{"text":"' + ChartHelper.prefix + 'title' + ChartHelper.suffix + '"},"subtitle":{},"yAxis":{"title":{"text":"' + typePlural + '"}},"xAxis":{"title":{"text":"Journal"}},"lang":{"noData":"No Data available for the Query"},"exporting":{"enabled":true},"plotOptions":{"series":{"dataLabels":{"enabled":false}}},"legend":{"enabled":true,"align":"center","verticalAlign":"bottom","layout":"horizontal"},"credits":{"href":null,"enabled":true,"text":"Created by OpenAIRE via HighCharts"}}}', null)]);
journal.indicatorPaths[0].parameters = IndicatorPath.createParameters(stakeholder.index_name, typeSingl + " journal", "bar"); journal.indicatorPaths[0].parameters = IndicatorPath.createParameters(stakeholder.index_name, typeSingl + " journal", "bar");
journal.indicatorPaths[0].parameters.set("id", stakeholder.index_shortName.toLowerCase()); journal.indicatorPaths[0].parameters["id"] = stakeholder.index_shortName.toLowerCase();
pubDefSub.charts.push(journal); pubDefSub.charts.push(journal);
let repo = new Indicator("", null, "chart", "small", true, true, [new IndicatorPath("bar", "stats-tool", "chart?json=", let repo = new Indicator("", null, "chart", "small", true, true, [new IndicatorPath("bar", "stats-tool", "chart?json=",
'{"library":"HighCharts","chartDescription":{"queries":[{"name":"' + typePlural + '","type":"' + ChartHelper.prefix + 'type' + ChartHelper.suffix + '","query":{"name":"monitor.' + ChartHelper.prefix + 'id' + ChartHelper.suffix + '.' + dbTypePlural + '.repositories"}}],"chart":{"backgroundColor":"#FFFFFFFF","borderColor":"#335cadff","borderRadius":0,"borderWidth":0,"plotBorderColor":"#ccccccff","plotBorderWidth":0},"title":{"text":"' + ChartHelper.prefix + 'title' + ChartHelper.suffix + '"},"subtitle":{},"yAxis":{"title":{"text":"' + typePlural + '"}},"xAxis":{"title":{"text":"Repositories"}},"lang":{"noData":"No Data available for the Query"},"exporting":{"enabled":true},"plotOptions":{"series":{"dataLabels":{"enabled":false}}},"legend":{"enabled":true,"align":"center","verticalAlign":"bottom","layout":"horizontal"},"credits":{"href":null,"enabled":true,"text":"Created by OpenAIRE via HighCharts"}}}', null)]); '{"library":"HighCharts","chartDescription":{"queries":[{"name":"' + typePlural + '","type":"' + ChartHelper.prefix + 'type' + ChartHelper.suffix + '","query":{"name":"monitor.' + ChartHelper.prefix + 'id' + ChartHelper.suffix + '.' + dbTypePlural + '.repositories"}}],"chart":{"backgroundColor":"#FFFFFFFF","borderColor":"#335cadff","borderRadius":0,"borderWidth":0,"plotBorderColor":"#ccccccff","plotBorderWidth":0},"title":{"text":"' + ChartHelper.prefix + 'title' + ChartHelper.suffix + '"},"subtitle":{},"yAxis":{"title":{"text":"' + typePlural + '"}},"xAxis":{"title":{"text":"Repositories"}},"lang":{"noData":"No Data available for the Query"},"exporting":{"enabled":true},"plotOptions":{"series":{"dataLabels":{"enabled":false}}},"legend":{"enabled":true,"align":"center","verticalAlign":"bottom","layout":"horizontal"},"credits":{"href":null,"enabled":true,"text":"Created by OpenAIRE via HighCharts"}}}', null)]);
repo.indicatorPaths[0].parameters = IndicatorPath.createParameters(stakeholder.index_name, typeSingl + " repositories", "bar"); repo.indicatorPaths[0].parameters = IndicatorPath.createParameters(stakeholder.index_name, typeSingl + " repositories", "bar");
repo.indicatorPaths[0].parameters.set("id", stakeholder.index_shortName.toLowerCase()); repo.indicatorPaths[0].parameters["id"] = stakeholder.index_shortName.toLowerCase();
pubDefSub.charts.push(repo); pubDefSub.charts.push(repo);
} }
if(dbType == "dataset") { if(dbType == "dataset") {
let repo = new Indicator("", null, "chart", "small", true, true, [new IndicatorPath("bar", "stats-tool", "chart?json=", let repo = new Indicator("", null, "chart", "small", true, true, [new IndicatorPath("bar", "stats-tool", "chart?json=",
'{"library":"HighCharts","chartDescription":{"queries":[{"name":"' + typePlural + '","type":"' + ChartHelper.prefix + 'type' + ChartHelper.suffix + '","query":{"name":"monitor.' + ChartHelper.prefix + 'id' + ChartHelper.suffix + '.' + dbTypePlural + '.drepositories"}}],"chart":{"backgroundColor":"#FFFFFFFF","borderColor":"#335cadff","borderRadius":0,"borderWidth":0,"plotBorderColor":"#ccccccff","plotBorderWidth":0},"title":{"text":"' + ChartHelper.prefix + 'title' + ChartHelper.suffix + '"},"subtitle":{},"yAxis":{"title":{"text":"' + typePlural + '"}},"xAxis":{"title":{"text":"Data Repositories"}},"lang":{"noData":"No Data available for the Query"},"exporting":{"enabled":true},"plotOptions":{"series":{"dataLabels":{"enabled":false}}},"legend":{"enabled":true,"align":"center","verticalAlign":"bottom","layout":"horizontal"},"credits":{"href":null,"enabled":true,"text":"Created by OpenAIRE via HighCharts"}}}', null)]); '{"library":"HighCharts","chartDescription":{"queries":[{"name":"' + typePlural + '","type":"' + ChartHelper.prefix + 'type' + ChartHelper.suffix + '","query":{"name":"monitor.' + ChartHelper.prefix + 'id' + ChartHelper.suffix + '.' + dbTypePlural + '.drepositories"}}],"chart":{"backgroundColor":"#FFFFFFFF","borderColor":"#335cadff","borderRadius":0,"borderWidth":0,"plotBorderColor":"#ccccccff","plotBorderWidth":0},"title":{"text":"' + ChartHelper.prefix + 'title' + ChartHelper.suffix + '"},"subtitle":{},"yAxis":{"title":{"text":"' + typePlural + '"}},"xAxis":{"title":{"text":"Data Repositories"}},"lang":{"noData":"No Data available for the Query"},"exporting":{"enabled":true},"plotOptions":{"series":{"dataLabels":{"enabled":false}}},"legend":{"enabled":true,"align":"center","verticalAlign":"bottom","layout":"horizontal"},"credits":{"href":null,"enabled":true,"text":"Created by OpenAIRE via HighCharts"}}}', null)]);
repo.indicatorPaths[0].parameters = IndicatorPath.createParameters(stakeholder.index_name, typeSingl + " repositories", "bar"); repo.indicatorPaths[0].parameters = IndicatorPath.createParameters(stakeholder.index_name, typeSingl + " repositories", "bar");
repo.indicatorPaths[0].parameters.set("id", stakeholder.index_shortName.toLowerCase()); repo.indicatorPaths[0].parameters["id"] = stakeholder.index_shortName.toLowerCase();
pubDefSub.charts.push(repo); pubDefSub.charts.push(repo);
let irepo = new Indicator("", null, "chart", "small", true, true, [new IndicatorPath("bar", "stats-tool", "chart?json=", let irepo = new Indicator("", null, "chart", "small", true, true, [new IndicatorPath("bar", "stats-tool", "chart?json=",
'{"library":"HighCharts","chartDescription":{"queries":[{"name":"' + typePlural + '","type":"' + ChartHelper.prefix + 'type' + ChartHelper.suffix + '","query":{"name":"monitor.' + ChartHelper.prefix + 'id' + ChartHelper.suffix + '.' + dbTypePlural + '.irepositories"}}],"chart":{"backgroundColor":"#FFFFFFFF","borderColor":"#335cadff","borderRadius":0,"borderWidth":0,"plotBorderColor":"#ccccccff","plotBorderWidth":0},"title":{"text":"' + ChartHelper.prefix + 'title' + ChartHelper.suffix + '"},"subtitle":{},"yAxis":{"title":{"text":"' + typePlural + '"}},"xAxis":{"title":{"text":"Institutional repositories"}},"lang":{"noData":"No Data available for the Query"},"exporting":{"enabled":true},"plotOptions":{"series":{"dataLabels":{"enabled":false}}},"legend":{"enabled":true,"align":"center","verticalAlign":"bottom","layout":"horizontal"},"credits":{"href":null,"enabled":true,"text":"Created by OpenAIRE via HighCharts"}}}', null)]); '{"library":"HighCharts","chartDescription":{"queries":[{"name":"' + typePlural + '","type":"' + ChartHelper.prefix + 'type' + ChartHelper.suffix + '","query":{"name":"monitor.' + ChartHelper.prefix + 'id' + ChartHelper.suffix + '.' + dbTypePlural + '.irepositories"}}],"chart":{"backgroundColor":"#FFFFFFFF","borderColor":"#335cadff","borderRadius":0,"borderWidth":0,"plotBorderColor":"#ccccccff","plotBorderWidth":0},"title":{"text":"' + ChartHelper.prefix + 'title' + ChartHelper.suffix + '"},"subtitle":{},"yAxis":{"title":{"text":"' + typePlural + '"}},"xAxis":{"title":{"text":"Institutional repositories"}},"lang":{"noData":"No Data available for the Query"},"exporting":{"enabled":true},"plotOptions":{"series":{"dataLabels":{"enabled":false}}},"legend":{"enabled":true,"align":"center","verticalAlign":"bottom","layout":"horizontal"},"credits":{"href":null,"enabled":true,"text":"Created by OpenAIRE via HighCharts"}}}', null)]);
irepo.indicatorPaths[0].parameters = IndicatorPath.createParameters(stakeholder.index_name, typeSingl + " institutional repositories", "bar"); irepo.indicatorPaths[0].parameters = IndicatorPath.createParameters(stakeholder.index_name, typeSingl + " institutional repositories", "bar");
irepo.indicatorPaths[0].parameters.set("id", stakeholder.index_shortName.toLowerCase()); irepo.indicatorPaths[0].parameters["id"] = stakeholder.index_shortName.toLowerCase();
pubDefSub.charts.push(irepo); pubDefSub.charts.push(irepo);
} }
@ -171,7 +171,7 @@ export class StakeholderCreator {
let pid = new Indicator("",null, "chart","small",true, true,[new IndicatorPath("pie", "stats-tool", "chart?json=", let pid = new Indicator("",null, "chart","small",true, true,[new IndicatorPath("pie", "stats-tool", "chart?json=",
'{"library":"HighCharts","chartDescription":{"queries":[{"name":"'+typePlural+'","type":"'+ChartHelper.prefix+'type'+ChartHelper.suffix+'","query":{"name":"monitor.'+ChartHelper.prefix+'id'+ChartHelper.suffix+'.'+dbTypePlural+'.pidtypes"}}],"chart":{"backgroundColor":"#FFFFFFFF","borderColor":"#335cadff","borderRadius":0,"borderWidth":0,"plotBorderColor":"#ccccccff","plotBorderWidth":0},"title":{"text":"'+ChartHelper.prefix+'title'+ChartHelper.suffix+'"},"subtitle":{},"lang":{"noData":"No Data available for the Query"},"exporting":{"enabled":true},"plotOptions":{"series":{"dataLabels":{"enabled":false}}},"legend":{"enabled":true,"align":"center","verticalAlign":"bottom","layout":"horizontal"},"credits":{"href":null,"enabled":true,"text":"Created by OpenAIRE via HighCharts"}}}', null)]); '{"library":"HighCharts","chartDescription":{"queries":[{"name":"'+typePlural+'","type":"'+ChartHelper.prefix+'type'+ChartHelper.suffix+'","query":{"name":"monitor.'+ChartHelper.prefix+'id'+ChartHelper.suffix+'.'+dbTypePlural+'.pidtypes"}}],"chart":{"backgroundColor":"#FFFFFFFF","borderColor":"#335cadff","borderRadius":0,"borderWidth":0,"plotBorderColor":"#ccccccff","plotBorderWidth":0},"title":{"text":"'+ChartHelper.prefix+'title'+ChartHelper.suffix+'"},"subtitle":{},"lang":{"noData":"No Data available for the Query"},"exporting":{"enabled":true},"plotOptions":{"series":{"dataLabels":{"enabled":false}}},"legend":{"enabled":true,"align":"center","verticalAlign":"bottom","layout":"horizontal"},"credits":{"href":null,"enabled":true,"text":"Created by OpenAIRE via HighCharts"}}}', null)]);
pid.indicatorPaths[0].parameters = IndicatorPath.createParameters(stakeholder.index_name,typeSingl+" PIDs","pie"); pid.indicatorPaths[0].parameters = IndicatorPath.createParameters(stakeholder.index_name,typeSingl+" PIDs","pie");
pid.indicatorPaths[0].parameters.set("id",stakeholder.index_shortName.toLowerCase()); pid.indicatorPaths[0].parameters["id"] = stakeholder.index_shortName.toLowerCase();
pid.indicatorPaths[0].filters = IndicatorPath.createResultFilters(dbType); pid.indicatorPaths[0].filters = IndicatorPath.createResultFilters(dbType);
pubDefSub.charts.push(pid); pubDefSub.charts.push(pid);
return pubDefSub; return pubDefSub;
@ -246,7 +246,7 @@ export class StakeholderCreator {
static createLinkToIndicator(stakeholder:Stakeholder,typePlural, typeSingl, dbType, linkedToName,linkedToType ):Indicator { static createLinkToIndicator(stakeholder:Stakeholder,typePlural, typeSingl, dbType, linkedToName,linkedToType ):Indicator {
let n_linkedPubs = new Indicator(typePlural+" linked to "+linkedToName, null, "number", "small", true, true, [new IndicatorPath(null, "search", let n_linkedPubs = new Indicator(typePlural+" linked to "+linkedToName, null, "number", "small", true, true, [new IndicatorPath(null, "search",
"/resources?query=" + encodeURIComponent(" ( (oaftype exact result) and (resulttypeid exact " + dbType + ") and (relresulttype="+linkedToType+") )") + "&fq=" + (encodeURIComponent("relfunderid exact " + stakeholder.index_id)) + "&page=0&size=0&format=json", null, ["meta", "total"])]); "/resources?query=" + encodeURIComponent(" ( (oaftype exact result) and (resulttypeid exact " + dbType + ") and (relresulttype="+linkedToType+") )") + "&fq=" + (encodeURIComponent("relfunderid exact " + stakeholder.index_id)) + "&page=0&size=0&format=json", null, ["meta", "total"])]);
n_linkedPubs.indicatorPaths[0].filters.set("fundingL0","&fq=relfundinglevel0_name exact "+ChartHelper.prefix+'fundingL0'+ChartHelper.suffix); n_linkedPubs.indicatorPaths[0].filters["fundingL0"] = "&fq=relfundinglevel0_name exact "+ChartHelper.prefix+'fundingL0'+ChartHelper.suffix;
/* /*
filters.set("start_year",'{"groupFilters":[{"field":"'+dbType+'.year","type":">=","values":["'+ChartHelper.prefix+'start_year'+ChartHelper.suffix+'"]}],"op":"AND"}'); filters.set("start_year",'{"groupFilters":[{"field":"'+dbType+'.year","type":">=","values":["'+ChartHelper.prefix+'start_year'+ChartHelper.suffix+'"]}],"op":"AND"}');
filters.set("end_year",'{"groupFilters":[{"field":"'+dbType+'.year","type":"<=","values":["'+ChartHelper.prefix+'end_year'+ChartHelper.suffix+'"]}],"op":"AND"}'); filters.set("end_year",'{"groupFilters":[{"field":"'+dbType+'.year","type":"<=","values":["'+ChartHelper.prefix+'end_year'+ChartHelper.suffix+'"]}],"op":"AND"}');

View File

@ -1,14 +1,47 @@
import {ChartHelper, IndicatorPath, Stakeholder} from "./entities/stakeholder"; import {ChartHelper, Indicator, IndicatorPath} from "./entities/stakeholder";
import {Validators} from "@angular/forms";
export interface Option {
icon?: string,
iconClass?: string,
value: any,
label: string
}
export class IndicatorUtils { export class IndicatorUtils {
chartTypes: Map<string, string> = new Map([ chartTypes: Option[] = [
{value: 'pie', label: 'Pie'},
{value: 'table', label: 'Table'},
{value: 'line', label: 'Line'},
{value: 'column', label: 'Column'},
{value: 'bar', label: 'Bar'},
{value: 'other', label: 'Other'}
];
chartSizes: Option[] = [
{value: 'small', label: 'Small'},
{value: 'medium', label: 'Medium'},
{value: 'large', label: 'Large'}
];
isPublic: Option[] = [
{icon: 'public', value: true, label: 'Public'},
{icon: 'lock', value: false, label: 'Private'},
];
isActive: Option[] = [
{icon: 'brightness_1', iconClass: '', value: true, label: 'Active'},
{icon: 'brightness_1', value: false, label: 'Inactive'},
];
chartTypesIcons: Map<string, string> = new Map([
['pie', 'pie_chart'], ['pie', 'pie_chart'],
['table', 'table_chart'], ['table', 'table_chart'],
['line', 'show_chart'], ['line', 'show_chart'],
['column', 'bar_chart'], ['column', 'bar_chart'],
['bar', 'bar_chart'], ['bar', 'bar_chart'],
['image', 'perm_media'] ['other', 'perm_media']
]); ]);
isPublicIcon: Map<boolean, string> = new Map([ isPublicIcon: Map<boolean, string> = new Map([
@ -20,38 +53,58 @@ export class IndicatorUtils {
ignoredParameters = ['funder_name']; ignoredParameters = ['funder_name'];
public getFullUrl(indicatorPath: IndicatorPath, fundingL0:string = null, startDate:string = null, endDate:string = null):string{ parametersValidators: Map<string, any> = new Map<string, any>([
['start_year', [Validators.required, Validators.pattern('^\\d+$')]],
['end_year', [Validators.required, Validators.pattern('^\\d+$')]]
]);
public getFullUrl(indicatorPath: IndicatorPath, fundingL0: string = null, startDate: string = null, endDate: string = null): string {
let replacedUrl = indicatorPath.chartObject; let replacedUrl = indicatorPath.chartObject;
if (indicatorPath.parameters) { if (indicatorPath.parameters) {
indicatorPath.parameters.forEach((value, key) => { Object.keys(indicatorPath.parameters).forEach(key => {
let replacedValue = value.toString(); let replacedValue = indicatorPath.parameters[key];
if( startDate && key == "start_year" && indicatorPath.filters.get("start_year")){ if (startDate && key == "start_year" && indicatorPath.filters["start_year"]) {
replacedValue = (replacedValue < startDate)?startDate:replacedValue; replacedValue = (replacedValue < startDate) ? startDate : replacedValue;
} }
if( endDate && key == "end_year" && indicatorPath.filters.get("end_year")){ if (endDate && key == "end_year" && indicatorPath.filters["end_year"]) {
replacedValue = (replacedValue > endDate)?endDate:replacedValue; replacedValue = (replacedValue > endDate) ? endDate : replacedValue;
} }
replacedUrl = replacedUrl.replace(ChartHelper.prefix + key + ChartHelper.suffix, replacedValue); replacedUrl = replacedUrl.replace(ChartHelper.prefix + key + ChartHelper.suffix, replacedValue);
}); });
} }
if(indicatorPath.chartObject){ if (indicatorPath.chartObject) {
if(fundingL0 && indicatorPath.filters.get("fundingL0")){ if (fundingL0 && indicatorPath.filters["fundingL0"]) {
let newJsonObject = JSON.parse(replacedUrl); let newJsonObject = JSON.parse(replacedUrl);
for(let queries of newJsonObject["chartDescription"]["queries"]){ for (let queries of newJsonObject["chartDescription"]["queries"]) {
if(!queries["query"]["filters"] || queries["query"]["filters"].length ==0) { if (!queries["query"]["filters"] || queries["query"]["filters"].length == 0) {
queries["query"]["filters"] = []; queries["query"]["filters"] = [];
} }
//TODO check how it works if the query already has a filter //TODO check how it works if the query already has a filter
queries["query"]["filters"].push(JSON.parse(indicatorPath.filters.get("fundingL0").replace(ChartHelper.prefix + "fundingL0" + ChartHelper.suffix,fundingL0))); queries["query"]["filters"].push(JSON.parse(indicatorPath.filters["fundingL0"].
replace(ChartHelper.prefix + "fundingL0" + ChartHelper.suffix, fundingL0)));
} }
replacedUrl = JSON.stringify(newJsonObject); replacedUrl = JSON.stringify(newJsonObject);
} }
} }
return indicatorPath.url + encodeURIComponent(replacedUrl); return indicatorPath.url + encodeURIComponent(replacedUrl);
} }
generateIndicatorByForm(form: any, indicatorPaths: IndicatorPath[]): Indicator {
let indicator: Indicator = new Indicator(form.name, form.description, 'chart',
form.width, form.isActive, form.isPublic, indicatorPaths);
indicator._id = form.id;
form.indicatorPaths.forEach((indicatorPath, index) => {
indicatorPath.parameters.forEach(parameter => {
indicator.indicatorPaths[index].parameters[parameter.key] = parameter.value;
if(parameter.key === 'type') {
indicator.indicatorPaths[index].type = parameter.value;
}
});
});
return indicator;
}
generateIndicatorByChartUrl(source: string, url: string, type: string = null): IndicatorPath { generateIndicatorByChartUrl(source: string, url: string, type: string = null): IndicatorPath {
let indicatorPath = new IndicatorPath("", source, "", "", []); let indicatorPath = new IndicatorPath("", source, "", "", []);
if (source === 'stats-tool') { if (source === 'stats-tool') {
@ -67,14 +120,14 @@ export class IndicatorUtils {
this.extractStartYear(chart, indicatorPath); this.extractStartYear(chart, indicatorPath);
this.extractEndYear(chart, indicatorPath); this.extractEndYear(chart, indicatorPath);
indicatorPath.chartObject = JSON.stringify(chart); indicatorPath.chartObject = JSON.stringify(chart);
this.addResultFilters(chart,indicatorPath); this.addResultFilters(chart, indicatorPath);
} else if (source === 'old') { } else if (source === 'old') {
indicatorPath.url = url.split("data=")[0].split("/stats/")[1] + "data="; indicatorPath.url = url.split("data=")[0].split("/stats/")[1] + "data=";
indicatorPath.chartObject = decodeURIComponent(url.split("data=")[1].split("&")[0]); indicatorPath.chartObject = decodeURIComponent(url.split("data=")[1].split("&")[0]);
let chart = JSON.parse(indicatorPath.chartObject); let chart = JSON.parse(indicatorPath.chartObject);
this.extractOldToolTitle(chart,indicatorPath); this.extractOldToolTitle(chart, indicatorPath);
this.extractOldToolXTitle(chart,indicatorPath); this.extractOldToolXTitle(chart, indicatorPath);
this.extractOldToolYTitle(chart,indicatorPath); this.extractOldToolYTitle(chart, indicatorPath);
indicatorPath.chartObject = JSON.stringify(chart); indicatorPath.chartObject = JSON.stringify(chart);
} else { } else {
indicatorPath.url = url; indicatorPath.url = url;
@ -90,7 +143,7 @@ export class IndicatorUtils {
type = defaultTypes [0]; type = defaultTypes [0];
} else { } else {
obj["chartDescription"]["queries"][0]["type"] = ChartHelper.prefix + "type" + ChartHelper.suffix; obj["chartDescription"]["queries"][0]["type"] = ChartHelper.prefix + "type" + ChartHelper.suffix;
indicatorPath.parameters.set("type", type); indicatorPath.parameters['type'] = type;
} }
return type; return type;
} }
@ -98,14 +151,14 @@ export class IndicatorUtils {
private extractFunder(obj, indicatorPath: IndicatorPath) { private extractFunder(obj, indicatorPath: IndicatorPath) {
let funderName; let funderName;
for (let query of obj["chartDescription"]["queries"]) { for (let query of obj["chartDescription"]["queries"]) {
if(!query["query"]["filters"]){ if (!query["query"]["filters"]) {
return; return;
} }
for (let filter of query["query"]["filters"]) { for (let filter of query["query"]["filters"]) {
if (filter["groupFilters"][0]["field"].indexOf(".funder") != -1) { if (filter["groupFilters"][0]["field"].indexOf(".funder") != -1) {
funderName = filter["groupFilters"][0]["values"][0]; funderName = filter["groupFilters"][0]["values"][0];
filter["groupFilters"][0]["values"][0] = ChartHelper.prefix + "funder_name" + ChartHelper.suffix; filter["groupFilters"][0]["values"][0] = ChartHelper.prefix + "funder_name" + ChartHelper.suffix;
indicatorPath.parameters.set("funder_name", funderName); indicatorPath.parameters["funder_name"] = funderName;
} }
} }
} }
@ -114,7 +167,7 @@ export class IndicatorUtils {
private extractStartYear(obj, indicatorPath: IndicatorPath) { private extractStartYear(obj, indicatorPath: IndicatorPath) {
let start_year; let start_year;
for (let query of obj["chartDescription"]["queries"]) { for (let query of obj["chartDescription"]["queries"]) {
if(!query["query"]["filters"]){ if (!query["query"]["filters"]) {
return; return;
} }
for (let filter of query["query"]["filters"]) { for (let filter of query["query"]["filters"]) {
@ -122,7 +175,7 @@ export class IndicatorUtils {
if (gfilter["field"].indexOf(".year") != -1 && gfilter["type"].indexOf(">") != -1) { if (gfilter["field"].indexOf(".year") != -1 && gfilter["type"].indexOf(">") != -1) {
start_year = gfilter["values"][0]; start_year = gfilter["values"][0];
gfilter["values"][0] = ChartHelper.prefix + "start_year" + ChartHelper.suffix; gfilter["values"][0] = ChartHelper.prefix + "start_year" + ChartHelper.suffix;
indicatorPath.parameters.set("start_year", start_year); indicatorPath.parameters["start_year"] = start_year;
} }
} }
} }
@ -132,7 +185,7 @@ export class IndicatorUtils {
private extractEndYear(obj, indicatorPath: IndicatorPath) { private extractEndYear(obj, indicatorPath: IndicatorPath) {
let end_year; let end_year;
for (let query of obj["chartDescription"]["queries"]) { for (let query of obj["chartDescription"]["queries"]) {
if(!query["query"]["filters"]){ if (!query["query"]["filters"]) {
return; return;
} }
for (let filter of query["query"]["filters"]) { for (let filter of query["query"]["filters"]) {
@ -140,7 +193,7 @@ export class IndicatorUtils {
if (gfilter["field"].indexOf(".year") != -1 && gfilter["type"].indexOf("<") != -1) { if (gfilter["field"].indexOf(".year") != -1 && gfilter["type"].indexOf("<") != -1) {
end_year = gfilter["values"][0]; end_year = gfilter["values"][0];
gfilter["values"][0] = ChartHelper.prefix + "end_year" + ChartHelper.suffix; gfilter["values"][0] = ChartHelper.prefix + "end_year" + ChartHelper.suffix;
indicatorPath.parameters.set("end_year", end_year); indicatorPath.parameters["end_year"] = end_year;
} }
} }
} }
@ -152,7 +205,7 @@ export class IndicatorUtils {
if (obj["chartDescription"]["title"]) { if (obj["chartDescription"]["title"]) {
title = obj["chartDescription"]["title"]["text"]; title = obj["chartDescription"]["title"]["text"];
obj["chartDescription"]["title"]["text"] = ChartHelper.prefix + "title" + ChartHelper.suffix; obj["chartDescription"]["title"]["text"] = ChartHelper.prefix + "title" + ChartHelper.suffix;
indicatorPath.parameters.set("title", title); indicatorPath.parameters["title"] = title;
} }
} }
@ -162,7 +215,7 @@ export class IndicatorUtils {
if (obj["chartDescription"]["xAxis"]["title"]) { if (obj["chartDescription"]["xAxis"]["title"]) {
title = obj["chartDescription"]["xAxis"]["title"]["text"]; title = obj["chartDescription"]["xAxis"]["title"]["text"];
obj["chartDescription"]["xAxis"]["title"]["text"] = ChartHelper.prefix + "xAxisTitle" + ChartHelper.suffix; obj["chartDescription"]["xAxis"]["title"]["text"] = ChartHelper.prefix + "xAxisTitle" + ChartHelper.suffix;
indicatorPath.parameters.set("xAxisTitle", title); indicatorPath.parameters["xAxisTitle"] = title;
} }
} }
@ -171,26 +224,27 @@ export class IndicatorUtils {
if (obj["chartDescription"]["yAxis"]["title"]) { if (obj["chartDescription"]["yAxis"]["title"]) {
title = obj["chartDescription"]["yAxis"]["title"]["text"]; title = obj["chartDescription"]["yAxis"]["title"]["text"];
obj["chartDescription"]["yAxis"]["title"]["text"] = ChartHelper.prefix + "yAxisTitle" + ChartHelper.suffix; obj["chartDescription"]["yAxis"]["title"]["text"] = ChartHelper.prefix + "yAxisTitle" + ChartHelper.suffix;
indicatorPath.parameters.set("yAxisTitle", title); indicatorPath.parameters["yAxisTitle"] = title;
} }
} }
private addResultFilters(obj, indicatorPath: IndicatorPath) { private addResultFilters(obj, indicatorPath: IndicatorPath) {
let resultTypes = ["publication","software","dataset","other"]; let resultTypes = ["publication", "software", "dataset", "other"];
let index = -1; let index = -1;
for (let query of obj["chartDescription"]["queries"]) { for (let query of obj["chartDescription"]["queries"]) {
if (!query["query"]["select"]) { if (!query["query"]["select"]) {
return; return;
} }
for (let select of query["query"]["select"]) { for (let select of query["query"]["select"]) {
for (var i=0; i < resultTypes.length; i++) { for (var i = 0; i < resultTypes.length; i++) {
if(select.field.startsWith(resultTypes[i]) ) { if (select.field.startsWith(resultTypes[i])) {
index = i; index = i;
} }
} }
} }
} }
if(index != -1){ if (index != -1) {
indicatorPath.filters = IndicatorPath.createResultFilters(resultTypes[index]); indicatorPath.filters = IndicatorPath.createResultFilters(resultTypes[index]);
} }
} }
@ -201,7 +255,7 @@ export class IndicatorUtils {
if (obj["title"]) { if (obj["title"]) {
title = obj["title"]; title = obj["title"];
obj["title"] = ChartHelper.prefix + "title" + ChartHelper.suffix; obj["title"] = ChartHelper.prefix + "title" + ChartHelper.suffix;
indicatorPath.parameters.set("title", title); indicatorPath.parameters["title"] = title;
} }
} }
@ -211,20 +265,21 @@ export class IndicatorUtils {
if (obj["xaxistitle"]) { if (obj["xaxistitle"]) {
title = obj["xaxistitle"]; title = obj["xaxistitle"];
obj["xaxistitle"] = ChartHelper.prefix + "xAxisTitle" + ChartHelper.suffix; obj["xaxistitle"] = ChartHelper.prefix + "xAxisTitle" + ChartHelper.suffix;
indicatorPath.parameters.set("xAxisTitle", title); indicatorPath.parameters["xAxisTitle"] = title;
} }
} }
private extractOldToolYTitle(obj, indicatorPath: IndicatorPath) { private extractOldToolYTitle(obj, indicatorPath: IndicatorPath) {
let title = ""; let title = "";
if (obj["fieldsheaders"] ) { if (obj["fieldsheaders"]) {
title = obj["fieldsheaders"]; title = obj["fieldsheaders"];
obj["fieldsheaders"] = ChartHelper.prefix + "yAxisTitle" + ChartHelper.suffix; obj["fieldsheaders"] = ChartHelper.prefix + "yAxisTitle" + ChartHelper.suffix;
indicatorPath.parameters.set("yAxisTitle", title); indicatorPath.parameters["yAxisTitle"] = title;
} }
} }
} }
/* /*
custom query custom query
http://88.197.53.71:8080/stats-api/chart?json=%7B%22library%22%3A%22HighCharts%22%2C%22chartDescription%22%3A%7B%22queries%22%3A%5B%7B%22name%22%3A%22Publications%22%2C%22type%22%3A%22bar%22%2C%22query%22%3A%7B%22name%22%3A%22monitor.ec.publications.datasources%22%7D%7D%5D%2C%22chart%22%3A%7B%22backgroundColor%22%3A%22%23FFFFFFFF%22%2C%22borderColor%22%3A%22%23335cadff%22%2C%22borderRadius%22%3A0%2C%22borderWidth%22%3A0%2C%22plotBorderColor%22%3A%22%23ccccccff%22%2C%22plotBorderWidth%22%3A0%7D%2C%22title%22%3A%7B%22text%22%3A%22Publication%20content%20provider%22%7D%2C%22subtitle%22%3A%7B%7D%2C%22yAxis%22%3A%7B%22title%22%3A%7B%22text%22%3A%22Publications%22%7D%7D%2C%22xAxis%22%3A%7B%22title%22%3A%7B%22text%22%3A%22Content%20provider%22%7D%7D%2C%22lang%22%3A%7B%22noData%22%3A%22No%20Data%20available%20for%20the%20Query%22%7D%2C%22exporting%22%3A%7B%22enabled%22%3Atrue%7D%2C%22plotOptions%22%3A%7B%22series%22%3A%7B%22dataLabels%22%3A%7B%22enabled%22%3Afalse%7D%7D%7D%2C%22legend%22%3A%7B%22enabled%22%3Atrue%2C%22align%22%3A%22center%22%2C%22verticalAlign%22%3A%22bottom%22%2C%22layout%22%3A%22horizontal%22%7D%2C%22credits%22%3A%7B%22href%22%3Anull%2C%22enabled%22%3Atrue%2C%22text%22%3A%22Created%20by%20OpenAIRE%20via%20HighCharts%22%7D%7D%7D http://88.197.53.71:8080/stats-api/chart?json=%7B%22library%22%3A%22HighCharts%22%2C%22chartDescription%22%3A%7B%22queries%22%3A%5B%7B%22name%22%3A%22Publications%22%2C%22type%22%3A%22bar%22%2C%22query%22%3A%7B%22name%22%3A%22monitor.ec.publications.datasources%22%7D%7D%5D%2C%22chart%22%3A%7B%22backgroundColor%22%3A%22%23FFFFFFFF%22%2C%22borderColor%22%3A%22%23335cadff%22%2C%22borderRadius%22%3A0%2C%22borderWidth%22%3A0%2C%22plotBorderColor%22%3A%22%23ccccccff%22%2C%22plotBorderWidth%22%3A0%7D%2C%22title%22%3A%7B%22text%22%3A%22Publication%20content%20provider%22%7D%2C%22subtitle%22%3A%7B%7D%2C%22yAxis%22%3A%7B%22title%22%3A%7B%22text%22%3A%22Publications%22%7D%7D%2C%22xAxis%22%3A%7B%22title%22%3A%7B%22text%22%3A%22Content%20provider%22%7D%7D%2C%22lang%22%3A%7B%22noData%22%3A%22No%20Data%20available%20for%20the%20Query%22%7D%2C%22exporting%22%3A%7B%22enabled%22%3Atrue%7D%2C%22plotOptions%22%3A%7B%22series%22%3A%7B%22dataLabels%22%3A%7B%22enabled%22%3Afalse%7D%7D%7D%2C%22legend%22%3A%7B%22enabled%22%3Atrue%2C%22align%22%3A%22center%22%2C%22verticalAlign%22%3A%22bottom%22%2C%22layout%22%3A%22horizontal%22%7D%2C%22credits%22%3A%7B%22href%22%3Anull%2C%22enabled%22%3Atrue%2C%22text%22%3A%22Created%20by%20OpenAIRE%20via%20HighCharts%22%7D%7D%7D

View File

@ -20,7 +20,7 @@ export class StatisticsService {
this.chartSources.set('stats-tool', properties.statisticsFrameNewAPIURL); this.chartSources.set('stats-tool', properties.statisticsFrameNewAPIURL);
this.chartSources.set('old', properties.statisticsFrameAPIURL); this.chartSources.set('old', properties.statisticsFrameAPIURL);
this.chartSources.set('metrics', properties.metricsAPIURL); this.chartSources.set('metrics', properties.metricsAPIURL);
this.chartSources.set('fake', ''); this.chartSources.set('image', '');
}) })
} }
@ -33,7 +33,7 @@ export class StatisticsService {
} }
getChartSource(url: string): string { getChartSource(url: string): string {
let source = 'fake'; let source = 'image';
this.chartSources.forEach((value, key) => { this.chartSources.forEach((value, key) => {
if(value !== '' && url.indexOf(value) !== -1) { if(value !== '' && url.indexOf(value) !== -1) {
source = key; source = key;

View File

@ -22,3 +22,8 @@
--header-height: 70px; --header-height: 70px;
--list-card-max-width: 1220px; --list-card-max-width: 1220px;
} }
.refresh-iframe {
background-color: rgba(0, 0, 0, 0.50);
position: absolute;
}

View File

@ -16,7 +16,7 @@ html .dashboard {
} }
.dashboard .clickable { .dashboard .clickable {
cursor: pointer; cursor: pointer !important;
} }
/* On link hover, his items with this class will be displayed*/ /* On link hover, his items with this class will be displayed*/
@ -146,3 +146,22 @@ body.dashboard {
padding: 0; padding: 0;
margin-top: 5px; margin-top: 5px;
} }
.dashboard .md-input {
color: black;
}
/* Modal*/
.dashboard .uk-modal .large-modal {
width: 800px;
}
/* Sortable*/
.dashboard .uk-sortable > * {
cursor: move;
}
.dashboard .uk-sortable .uk-sortable-nodrag {
cursor: default;
}

View File

@ -72,8 +72,10 @@
<!-- <script src="assets/theme-assets/js/uikit_custom.min.js"></script>--> <!-- <script src="assets/theme-assets/js/uikit_custom.min.js"></script>-->
<script> <script>
if(isHighDensity) { if(isHighDensity) {
// enable hires images $.getScript( "assets/theme-assets/js/custom/dense.min.js", function(data) {
altair_helpers.retina_images(); // enable hires images
altair_helpers.retina_images();
});
} }
if(Modernizr.touch) { if(Modernizr.touch) {
// fastClick (touch devices) // fastClick (touch devices)