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

View File

@ -138,7 +138,7 @@
</ul>
</div>
</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">
<h4 class="uk-text-bold">
Customise your Monitor Dashboard!

View File

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

View File

@ -1,10 +1,12 @@
import {Injectable} from "@angular/core";
import {HttpClient} from "@angular/common/http";
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 {map} from "rxjs/operators";
let maps: string[] = ['parameters', 'filters'];
@Injectable({
providedIn: "root"
})
@ -17,45 +19,61 @@ export class StakeholderService {
}
getStakeholder(url: string, alias:string): Observable<Stakeholder> {
return new BehaviorSubject<Stakeholder>(Stakeholder.createECStakeholder()).asObservable();
// return this.http.get<Stakeholder>(url + '/stakeholder/' + encodeURIComponent(alias)).pipe(map(stakeholder => {
// return this.formalizeStakeholder([stakeholder])[0];
// }));
/*return new BehaviorSubject<Stakeholder>(
StakeholderCreator.createFunderFromDefaultProfile("ec","funder","ec__________::EC",
"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[]> {
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[]> {
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[]> {
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> {
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);
return this.http.post<Indicator>(url + '/' + path.join('/') +
'/indicator/save', indicator);
return this.http.post<any>(url + ((path.length > 0)?'/':'') + path.join('/') +
'/save', element).pipe(map(element => {
return this.formalize(element);
}));
}
deleteElement(url: string, path: string[]): Observable<any> {
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> {
@ -70,29 +88,7 @@ export class StakeholderService {
this.stakeholderSubject.next(stakeholder);
}
private formalizeStakeholder(stakeholders: Stakeholder[]): Stakeholder[] {
stakeholders.forEach( stakeholder => {
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;
private formalize(element: any) {
return HelperFunctions.copy(element);
}
}

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-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">
@ -73,12 +74,12 @@
<div [class.uk-child-width-1-3@m]="grid"
[class.uk-child-width-1-2@s]="grid"
[class.uk-child-width-1-1]="!grid"
[class.list]="!grid" id="numbers"
class="uk-grid-match uk-grid-small"
[class.list]="!grid"
uk-grid>
uk-sortable uk-grid>
<ng-template ngFor [ngForOf]="displayNumbers" let-indicator let-i="index">
<div>
<div class="md-card">
<div *ngIf="indicator" [id]="i">
<div class="md-card" [class.uk-sortable-nodrag]="!canNumbersReorder">
<div class="md-card-toolbar">
<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">
@ -119,19 +120,19 @@
<div [class.uk-child-width-1-3@m]="grid"
[class.uk-child-width-1-2@s]="grid"
[class.uk-child-width-1-1]="!grid"
[class.list]="!grid"
class="uk-grid-match uk-grid-small"
uk-grid>
[class.list]="!grid" id="charts"
class="uk-grid-match uk-grid-small uk-grid"
uk-sortable uk-grid>
<ng-template ngFor [ngForOf]="displayCharts" let-indicator let-i="index">
<div>
<div class="md-card">
<div *ngIf="indicator" [id]="i">
<div class="md-card" [class.uk-sortable-nodrag]="!canChartsReorder">
<div class="md-card-toolbar">
<div class="md-card-toolbar-actions" [class.uk-flex-middle]="!grid" [class.uk-flex]="!grid">
<ng-template [ngIf]="!grid">
<span *ngFor="let indicatorPath of indicator.indicatorPaths"
class="uk-margin-medium-right uk-text-capitalize uk-flex uk-flex-middle">
<i class="material-icons md-24 uk-margin-small-right">
{{indicatorUtils.chartTypes.get(indicatorPath.type)}}
{{indicatorUtils.chartTypesIcons.get(indicatorPath.type)}}
</i>
{{indicatorPath.type + ' Chart'}}
</span>
@ -162,7 +163,7 @@
[ngClass]="'uk-child-width-1-' + indicator.indicatorPaths.length" uk-grid>
<div *ngFor="let indicatorPath of indicator.indicatorPaths">
<i class="material-icons md-24">
{{indicatorUtils.chartTypes.get(indicatorPath.type)}}
{{indicatorUtils.chartTypesIcons.get(indicatorPath.type)}}
</i>
<div class="uk-text-capitalize">{{indicatorPath.type + ' Chart'}}</div>
</div>
@ -185,7 +186,7 @@
</div>
</ng-template>
<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-heading-text"
[class.uk-flex-middle]="!grid"
@ -196,13 +197,13 @@
</div>
</div>
<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">
Use our advance tool to create a custom Indicator that suit the needs of your funding KPI's.
</div>
</div>
<div class="uk-flex uk-flex-center uk-margin-top">
<i class="material-icons md-48">add</i>
<div class="uk-width-1-1 uk-flex uk-flex-center">
<i class="material-icons md-48">add</i>
</div>
</div>
</div>
</div>
@ -214,52 +215,87 @@
(alertOutput)="createIndicator()"
[okDisabled]="indicatorFb && indicatorFb.invalid">
<div *ngIf="indicatorFb" class="uk-form-stacked" [formGroup]="indicatorFb">
<label class="uk-form-label">Name</label>
<div class="uk-form-controls">
<input class="uk-input"
[class.uk-form-danger]="indicatorFb.get('name').invalid && indicatorFb.get('name').dirty"
[formControl]="indicatorFb.get('name')">
</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 dashboard-input class="uk-form-row" [formInput]="indicatorFb.get('name')" label="Title"></div>
<div dashboard-input class="uk-form-row" [formInput]="indicatorFb.get('description')"
label="Description" type="textarea"></div>
<div dashboard-input class="uk-form-row" *ngFor="let chartUrl of urls.controls;"
[formInput]="chartUrl"
label="Chart Url"></div>
</div>
</modal-alert>
<modal-alert #editIndicatorModal
[classBody]="'large-modal'"
(alertOutput)="saveIndicator()"
[okDisabled]="editIndicatorFb && (editIndicatorFb.invalid || !editIndicatorFb.dirty)">
<div *ngIf="editIndicatorFb" class="uk-form-stacked" [formGroup]="editIndicatorFb">
<div class="md-input-wrapper">
<label>Name</label>
<input type="text" class="md-input" (focus)="focus($event)">
<span class="md-input-bar "></span>
[okDisabled]="editIndicatorFb && (editIndicatorFb.invalid ||(!editIndicatorFb.dirty && index !==-1))">
<div *ngIf="editIndicatorFb" class="uk-padding-small" [formGroup]="editIndicatorFb">
<div dashboard-input class="uk-form-row" [formInput]="editIndicatorFb.get('name')" label="Title"></div>
<div dashboard-input class="uk-form-row" [formInput]="editIndicatorFb.get('description')"
label="Description" type="textarea">
</div>
<label class="uk-form-label">Name</label>
<div class="uk-form-controls">
<input class="uk-input"
[class.uk-form-danger]="editIndicatorFb.get('name').status === 'INVALID' && editIndicatorFb.get('name').dirty"
[formControl]="editIndicatorFb.get('name')">
<div class="uk-form-row uk-flex uk-flex-middle">
<div dashboard-input class="uk-width-small" [formInput]="editIndicatorFb.get('isPublic')"
label="Accessibility" [options]="indicatorUtils.isPublic" type="select">
</div>
<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>
<!--<label class="uk-form-label">Description</label>
<div class="uk-form-controls">
<textarea class="uk-textarea" rows="3"
[formControl]="indicatorFb.get('description')"></textarea>
<hr class="uk-margin-large-top uk-margin-large-bottom">
<div formArrayName="indicatorPaths">
<div *ngFor="let indicatorPath of indicatorPaths.controls; let i=index"
[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>
<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>
</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 {Indicator, IndicatorPath, Stakeholder} from "../utils/entities/stakeholder";
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 {StatisticsService} from "../utils/services/statistics.service";
import {HelperFunctions} from "../openaireLibrary/utils/HelperFunctions.class";
import {DomSanitizer} from "@angular/platform-browser";
import {StakeholderService} from "../services/stakeholder.service";
import {EnvProperties} from "../openaireLibrary/utils/properties/env-properties";
declare var UIkit;
@Component({
selector: 'indicators',
@ -14,6 +18,8 @@ import {DomSanitizer} from "@angular/platform-browser";
})
export class IndicatorsComponent implements OnInit, OnChanges {
@Input()
public properties: EnvProperties = null;
@Input()
public topicIndex: number = 0;
@Input()
@ -29,11 +35,7 @@ export class IndicatorsComponent implements OnInit, OnChanges {
* Editable indicator
*/
public indicator: Indicator;
/**
* All charts and numbers
*/
public charts: Indicator[] = [];
public numbers: Indicator[] = [];
public index: number;
/**
* Displayed chart and numbers base on Top filters
*/
@ -55,27 +57,44 @@ export class IndicatorsComponent implements OnInit, OnChanges {
@ViewChild('editIndicatorModal') editIndicatorModal: AlertModal;
constructor(private sideBarService: SideBarService,
private stakeholderService: StakeholderService,
private statisticsService: StatisticsService,
private fb: FormBuilder,
private sanitizer: DomSanitizer) {
}
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 {
if (this.canEdit) {
this.charts = this.stakeholder.topics[this.topicIndex].categories[this.categoryIndex].subCategories[this.subcategoryIndex].charts;
this.displayCharts = this.filterChartType(this.filterPrivacy(
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);
this.filterCharts();
this.filterNumbers();
}
}
@ -91,6 +110,21 @@ export class IndicatorsComponent implements OnInit, OnChanges {
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) {
this.displayCharts = this.filterChartType(this.charts, value);
}
@ -139,14 +173,39 @@ export class IndicatorsComponent implements OnInit, OnChanges {
if (value === null || value === '') {
return indicators;
} 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 {
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() {
return this.stakeholder &&
this.stakeholder.topics[this.topicIndex] &&
@ -158,6 +217,18 @@ export class IndicatorsComponent implements OnInit, OnChanges {
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) {
return this.sanitizer.bypassSecurityTrustResourceUrl(
this.statisticsService.getChartUrl(indicatorPath.source, this.indicatorUtils.getFullUrl(indicatorPath)));
@ -201,33 +272,40 @@ export class IndicatorsComponent implements OnInit, OnChanges {
this.indicator.indicatorPaths.push(
this.indicatorUtils.generateIndicatorByChartUrl(this.statisticsService.getChartSource(url), url));
});
let index = this.charts.push(this.indicator);
this.editIndicatorOpen(index - 1);
this.editIndicatorOpen();
}
public editIndicatorOpen(index: number) {
this.indicator = HelperFunctions.copy(this.charts[index]);
this.indicator.indicatorPaths.forEach(indicatorPath => {
indicatorPath.safeResourceUrl = this.getUrlByStakeHolder(indicatorPath)
console.log(indicatorPath.safeResourceUrl);
});
public editIndicatorOpen(index: number = -1) {
this.index = index;
if (this.index !== -1) {
this.indicator = HelperFunctions.copy(this.charts[index]);
}
let indicatorPaths = this.fb.array([]);
this.indicator.indicatorPaths.forEach(indicatorPath => {
let parameters = this.fb.array([]);
indicatorPath.parameters.forEach((value, key) => {
if (this.indicatorUtils.ignoredParameters.indexOf(key) === -1) {
// TODO add Validators Map
parameters.push(this.fb.group({
key: this.fb.control(key),
value: this.fb.control(value, Validators.required)
}));
}
});
if (indicatorPath.parameters) {
Object.keys(indicatorPath.parameters).forEach(key => {
if (this.indicatorUtils.ignoredParameters.indexOf(key) === -1) {
if (this.indicatorUtils.parametersValidators.has(key)) {
parameters.push(this.fb.group({
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({
parameters: parameters
}));
});
this.editIndicatorFb = this.fb.group({
id: this.fb.control(this.indicator._id),
name: this.fb.control(this.indicator.name, Validators.required),
description: this.fb.control(this.indicator.description),
isPublic: this.fb.control(this.indicator.isPublic),
@ -235,20 +313,62 @@ export class IndicatorsComponent implements OnInit, OnChanges {
indicatorPaths: indicatorPaths,
width: this.fb.control(this.indicator.width, Validators.required),
});
console.log(this.editIndicatorFb.value);
this.editIndicatorModal.alertHeader = false;
this.editIndicatorModal.cancelButtonText = 'Cancel';
this.editIndicatorModal.okButtonText = 'Save Changes';
this.editIndicatorModal.okButtonLeft = false;
this.editIndicatorModal.alertMessage = false;
this.editIndicatorModal.open();
setTimeout(() => {
this.indicator.indicatorPaths.forEach(indicatorPath => {
indicatorPath.safeResourceUrl = this.getUrlByStakeHolder(indicatorPath)
});
}, 500);
}
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) {
event.srcElement.parentElement.className = event.srcElement.parentElement.className + ' md-input-focus';
reorderIndicators(type: string, indicators: Indicator[]) {
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>
<div class="uk-grid-small uk-child-width-1-2" uk-grid>
<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>
<button class="md-btn md-btn-small md-btn-primary uk-float-right"
@ -137,8 +139,8 @@
{{subcategory.name}}
<button class="uk-position-center-right-out uk-margin-right uk-button uk-button-link onHover"
(click)="$event.stopPropagation();editSubCategoryOpen(editSubCategory, j);$event.preventDefault()">
<i class="material-icons">more_horiz</i>
</button>
<i class="material-icons">more_horiz</i>
</button>
</div>
</a>
<div uk-drop="mode: none; offset: -2; delay-hide: 0" #editSubCategory
@ -171,7 +173,9 @@
<hr>
<div class="uk-grid-small uk-child-width-1-2" uk-grid>
<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>
<button class="md-btn md-btn-small md-btn-primary uk-float-right"
@ -287,7 +291,8 @@
</ul>
</div>
</aside>
<indicators [stakeholder]="stakeholder"
<indicators [properties]="properties"
[stakeholder]="stakeholder"
[topicIndex]="topicIndex"
[categoryIndex]="categoryIndex"
[subcategoryIndex]="subCategoryIndex"></indicators>

View File

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

View File

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

View File

@ -1,15 +1,17 @@
import {SafeResourceUrl} from "@angular/platform-browser";
import {IndicatorUtils} from "../indicator-utils";
export const ChartHelper={
prefix : "((__",
suffix : "__))"
export const ChartHelper = {
prefix: "((__",
suffix: "__))"
};
export class Stakeholder {
id: string;
_id: string;
type: string;
index_id;
index_name: string;
index_shortName:string;
index_shortName: string;
alias: string;
isDefaultProfile: boolean;
isActive: boolean;
@ -17,14 +19,16 @@ export class Stakeholder {
creationDate: string;
updateDate: string;
managers: string[];
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);
this.topics =[];
this.managers =[];
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);
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.index_id = index_id;
this.index_name = index_name;
@ -34,76 +38,77 @@ export class Stakeholder {
this.isActive = isActive;
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);
ec.topics.push(ec.createOSTopic(ec));
ec.topics.push(ec.createImpactTopic());
ec.topics.push(ec.createCollaborationTopic());
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);
topic.categories.push(overview);
let overviewDefSub = new SubCategory(null, null,null,true, true);
overview.subCategories.push(overviewDefSub);*/
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);
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);
let pubDefSub = new SubCategory(null, null,null,true, true);
let pubDefSub = new SubCategory(null, null, null, true, true);
pubCategory.subCategories.push(pubDefSub);
/* let pubOpenSub = new SubCategory("Openess","","openness",true,true);
pubCategory.subCategories.push(pubOpenSub);
let pubFundingSub = new SubCategory("Funding","","funding",true,true);
pubCategory.subCategories.push(pubFundingSub);
let pubDatasourceSub = new SubCategory("Content Providers","","content-providers",true,true);
pubCategory.subCategories.push(pubDatasourceSub);
let pubDocTypeSub = new SubCategory("Document Type","","doc-type",true,true);
pubCategory.subCategories.push(pubDocTypeSub);
let pubFindSub = new SubCategory("Findability","","dindability",true,true);
pubCategory.subCategories.push(pubFindSub);*/
/* let pubOpenSub = new SubCategory("Openess","","openness",true,true);
pubCategory.subCategories.push(pubOpenSub);
let pubFundingSub = new SubCategory("Funding","","funding",true,true);
pubCategory.subCategories.push(pubFundingSub);
let pubDatasourceSub = new SubCategory("Content Providers","","content-providers",true,true);
pubCategory.subCategories.push(pubDatasourceSub);
let pubDocTypeSub = new SubCategory("Document Type","","doc-type",true,true);
pubCategory.subCategories.push(pubDocTypeSub);
let pubFindSub = new SubCategory("Findability","","dindability",true,true);
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);
let dataDefSub = new SubCategory(null, null,null,true, true);
let dataDefSub = new SubCategory(null, null, null, true, true);
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);
let softDefSub = new SubCategory(null, null,null,true, true);
let softDefSub = new SubCategory(null, null, null, true, true);
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);
let otherDefSub = new SubCategory(null, null,null,true, true);
let otherDefSub = new SubCategory(null, null, null, true, true);
otherCategory.subCategories.push(otherDefSub);
/* let datasourceCategory:Category = new Category("Content Providers","","content-providers",true,true);
topic.categories.push(datasourceCategory);
let datasourceDefSub = new SubCategory(null, null,null,true, true);
datasourceCategory.subCategories.push(datasourceDefSub);*/
/* let datasourceCategory:Category = new Category("Content Providers","","content-providers",true,true);
topic.categories.push(datasourceCategory);
let datasourceDefSub = new SubCategory(null, null,null,true, true);
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);
let projectDefSub = new SubCategory(null, null,null,true, true);
let projectDefSub = new SubCategory(null, null, null, true, true);
projectCategory.subCategories.push(projectDefSub);
//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_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_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"])]);
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"])]);
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"])]);
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_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",
"/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",
"/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",
"/other/count?fq=" + (encodeURIComponent("relfunderid exact " + stakeholder.index_id)) + "&format=json", null, ["total"])]);
/*overviewDefSub.numbers.push(n_total_pubs);
overviewDefSub.numbers.push(n_open_pubs);
@ -122,9 +127,9 @@ export class Stakeholder {
//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, [
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");
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)]);
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);
//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)]);
pubDefSub.charts.push(c_pubs_funding_scheme);
*/
/* //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,
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);
*/
/* //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,
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);
*/
/* 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)]);
@ -209,57 +214,58 @@ export class Stakeholder {
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);
let pubDefSub = new SubCategory(null, null,null,true, true);
let pubDefSub = new SubCategory(null, null, null, true, true);
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);
let dataDefSub = new SubCategory(null, null,null,true, true);
let dataDefSub = new SubCategory(null, null, null, true, true);
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);
let softDefSub = new SubCategory(null, null,null,true, true);
let softDefSub = new SubCategory(null, null, null, true, true);
softwareCategory.subCategories.push(softDefSub);
/* let otherCategory:Category = new Category("Other research products","","other",true,true);
topic.categories.push(otherCategory);
let otherDefSub = new SubCategory(null, null,null,true, true);
otherCategory.subCategories.push(otherDefSub);*/
/* let otherCategory:Category = new Category("Other research products","","other",true,true);
topic.categories.push(otherCategory);
let otherDefSub = new SubCategory(null, null,null,true, true);
otherCategory.subCategories.push(otherDefSub);*/
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);
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);
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);
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);
let defSub = new SubCategory(null, null,null,true, true);
let defSub = new SubCategory(null, null, null, true, true);
category2.subCategories.push(defSub);
let chart1 = new Indicator(
"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)]);
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)]);
"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)]);
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);
subCat2.charts.push(chart2);
@ -267,15 +273,15 @@ export class Stakeholder {
defSub.charts.push(chart2);
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%";
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";
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;
}
}
export class Topic {
id:string;
_id: string;
name: string;
alias: string;
description: string;
@ -283,9 +289,10 @@ export class Topic {
isPublic: boolean;
isDefault: boolean;
categories: Category[];
constructor(name: string, description: string, alias:string , isActive: boolean, isPublic: boolean) {
this.id = null;
this.name = name;
constructor(name: string, description: string, alias: string, isActive: boolean, isPublic: boolean) {
this._id = null;
this.name = name;
this.description = description;
this.alias = alias;
this.isActive = isActive;
@ -293,8 +300,9 @@ export class Topic {
this.categories = [];
}
}
export class Category {
id:string;
_id: string;
name: string;
alias: string;
description: string;
@ -303,9 +311,10 @@ export class Category {
isOverview: boolean;
isDefault: boolean;
subCategories: SubCategory[];
constructor(name: string, description: string, alias:string , isActive: boolean, isPublic: boolean) {
this.id = null;
this.name = name;
constructor(name: string, description: string, alias: string, isActive: boolean, isPublic: boolean) {
this._id = null;
this.name = name;
this.description = description;
this.alias = alias;
this.isActive = isActive;
@ -315,7 +324,7 @@ export class Category {
}
export class SubCategory {
id:string;
_id: string;
name: string;
alias: string;
description: string;
@ -324,9 +333,10 @@ export class SubCategory {
isDefault: boolean;
charts: Indicator[];
numbers: Indicator[];
constructor(name: string, description: string, alias:string , isActive: boolean, isPublic: boolean) {
this.id = null;
this.name = name;
constructor(name: string, description: string, alias: string, isActive: boolean, isPublic: boolean) {
this._id = null;
this.name = name;
this.description = description;
this.alias = alias;
this.isActive = isActive;
@ -336,22 +346,24 @@ export class SubCategory {
}
}
export class Indicator {
id:string;
_id: string;
name: string;
description: string;
type:string; //number,chart
width:string; //small,medium,large
tags:string[];
type: string; //number,chart
width: string; //small,medium,large
tags: string[];
isActive: boolean;
isPublic: boolean;
isDefault: boolean;
indicatorPaths:IndicatorPath[];
constructor(name: string, description: string, type:string , width:string, isActive: boolean, isPublic: boolean, indicatorPaths:IndicatorPath[]){
this.id = null;
this.name = name;
indicatorPaths: IndicatorPath[];
constructor(name: string, description: string, type: string, width: string, isActive: boolean, isPublic: boolean, indicatorPaths: IndicatorPath[]) {
this._id = null;
this.name = name;
this.description = description;
this.type = type;
this.type = type;
this.width = width;
this.isActive = isActive;
this.isPublic = isPublic;
@ -362,35 +374,37 @@ export class Indicator {
export class IndicatorPath {
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;
safeResourceUrl: SafeResourceUrl; // initialize on front end
jsonPath:string[];
chartObject:string;
parameters:Map<string,string>;
filters:Map<string, string>;
constructor(type: string, source:string, url: string, chartObject:string, jsonPath:string[]){
this.type = type;
jsonPath: string[];
chartObject: string;
parameters: any;
filters: any;
constructor(type: string, source: string, url: string, chartObject: string, jsonPath: string[]) {
this.type = type;
this.url = url;
this.source = source;
this.jsonPath = jsonPath;
this.chartObject =chartObject;
this.parameters = new Map<string, string>();
this.filters = new Map<string, string>();
this.chartObject = chartObject;
this.parameters = {};
this.filters = {};
}
static createParameters(funderName:string=null, title:string=null, chartType:string=null):Map<string, string>{
let parameters = new Map<string, string>();
parameters.set("funder_name",funderName);
parameters.set("title",title);
parameters.set("type",chartType);
return parameters;
static createParameters(funderName: string = null, title: string = null, chartType: string = null): any {
return {
funder_name: funderName,
title: title,
type: chartType
};
}
static createResultFilters(dbType:string=null):Map<string, string>{
let filters = new Map<string, string>();
filters.set("fundingL0",'{"groupFilters":[{"field":"'+dbType+'.project.funding level 0","type":"=","values":["'+ChartHelper.prefix+'fundingL0'+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"}');
return filters;
static createResultFilters(dbType: string = null): any {
return {
fundingL0: '{"groupFilters":[{"field":"' + dbType + '.project.funding level 0","type":"=","values":["' + ChartHelper.prefix + 'fundingL0' + ChartHelper.suffix + '"]}],"op":"AND"}',
start_year: '{"groupFilters":[{"field":"' + dbType + '.year","type":">=","values":["' + ChartHelper.prefix + 'start_year' + ChartHelper.suffix + '"]}],"op":"AND"}',
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 indicatorPath of indicator.indicatorPaths) {
if(indicatorPath.parameters) {
indicatorPath.parameters.forEach((value: string, key: string) => {
if (value.indexOf("_funder_name_")!=-1) {
indicatorPath.parameters.set(key,value.toString().replace("_funder_name_", funder.index_name));
}else if (value.indexOf("_fsn_")!=-1) {
indicatorPath.parameters.set(key,value.toString().replace("_fsn_", funder.index_shortName.toLowerCase()));
Object.keys(indicatorPath.parameters).forEach(key => {
if (indicatorPath.parameters[key].indexOf("_funder_name_")!=-1) {
indicatorPath.parameters[key].replace("_funder_name_", funder.index_name);
} else if (indicatorPath.parameters[key].indexOf("_fsn_")!=-1) {
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",
"/"+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);
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)]);
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.set("end_year","2020");
res_timeline.indicatorPaths[0].parameters["start_year"] = "2008";
res_timeline.indicatorPaths[0].parameters["end_year"] = "2020";
res_timeline.indicatorPaths[0].filters = IndicatorPath.createResultFilters(dbType);
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=",
'{"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.set("id",stakeholder.index_shortName.toLowerCase());
datasource.indicatorPaths[0].parameters["id"] = stakeholder.index_shortName.toLowerCase();
pubDefSub.charts.push(datasource);
if(dbType == "publication") {
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)]);
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);
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)]);
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);
}
if(dbType == "dataset") {
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)]);
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);
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)]);
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);
}
@ -171,7 +171,7 @@ export class StakeholderCreator {
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)]);
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);
pubDefSub.charts.push(pid);
return pubDefSub;
@ -246,7 +246,7 @@ export class StakeholderCreator {
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",
"/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("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 {
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'],
['table', 'table_chart'],
['line', 'show_chart'],
['column', 'bar_chart'],
['bar', 'bar_chart'],
['image', 'perm_media']
['other', 'perm_media']
]);
isPublicIcon: Map<boolean, string> = new Map([
@ -20,38 +53,58 @@ export class IndicatorUtils {
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;
if (indicatorPath.parameters) {
indicatorPath.parameters.forEach((value, key) => {
let replacedValue = value.toString();
if( startDate && key == "start_year" && indicatorPath.filters.get("start_year")){
replacedValue = (replacedValue < startDate)?startDate:replacedValue;
Object.keys(indicatorPath.parameters).forEach(key => {
let replacedValue = indicatorPath.parameters[key];
if (startDate && key == "start_year" && indicatorPath.filters["start_year"]) {
replacedValue = (replacedValue < startDate) ? startDate : replacedValue;
}
if( endDate && key == "end_year" && indicatorPath.filters.get("end_year")){
replacedValue = (replacedValue > endDate)?endDate:replacedValue;
if (endDate && key == "end_year" && indicatorPath.filters["end_year"]) {
replacedValue = (replacedValue > endDate) ? endDate : replacedValue;
}
replacedUrl = replacedUrl.replace(ChartHelper.prefix + key + ChartHelper.suffix, replacedValue);
});
}
if(indicatorPath.chartObject){
if(fundingL0 && indicatorPath.filters.get("fundingL0")){
if (indicatorPath.chartObject) {
if (fundingL0 && indicatorPath.filters["fundingL0"]) {
let newJsonObject = JSON.parse(replacedUrl);
for(let queries of newJsonObject["chartDescription"]["queries"]){
if(!queries["query"]["filters"] || queries["query"]["filters"].length ==0) {
for (let queries of newJsonObject["chartDescription"]["queries"]) {
if (!queries["query"]["filters"] || queries["query"]["filters"].length == 0) {
queries["query"]["filters"] = [];
}
//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);
}
}
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 {
let indicatorPath = new IndicatorPath("", source, "", "", []);
if (source === 'stats-tool') {
@ -67,14 +120,14 @@ export class IndicatorUtils {
this.extractStartYear(chart, indicatorPath);
this.extractEndYear(chart, indicatorPath);
indicatorPath.chartObject = JSON.stringify(chart);
this.addResultFilters(chart,indicatorPath);
this.addResultFilters(chart, indicatorPath);
} else if (source === 'old') {
indicatorPath.url = url.split("data=")[0].split("/stats/")[1] + "data=";
indicatorPath.chartObject = decodeURIComponent(url.split("data=")[1].split("&")[0]);
let chart = JSON.parse(indicatorPath.chartObject);
this.extractOldToolTitle(chart,indicatorPath);
this.extractOldToolXTitle(chart,indicatorPath);
this.extractOldToolYTitle(chart,indicatorPath);
this.extractOldToolTitle(chart, indicatorPath);
this.extractOldToolXTitle(chart, indicatorPath);
this.extractOldToolYTitle(chart, indicatorPath);
indicatorPath.chartObject = JSON.stringify(chart);
} else {
indicatorPath.url = url;
@ -90,7 +143,7 @@ export class IndicatorUtils {
type = defaultTypes [0];
} else {
obj["chartDescription"]["queries"][0]["type"] = ChartHelper.prefix + "type" + ChartHelper.suffix;
indicatorPath.parameters.set("type", type);
indicatorPath.parameters['type'] = type;
}
return type;
}
@ -98,14 +151,14 @@ export class IndicatorUtils {
private extractFunder(obj, indicatorPath: IndicatorPath) {
let funderName;
for (let query of obj["chartDescription"]["queries"]) {
if(!query["query"]["filters"]){
if (!query["query"]["filters"]) {
return;
}
for (let filter of query["query"]["filters"]) {
if (filter["groupFilters"][0]["field"].indexOf(".funder") != -1) {
funderName = filter["groupFilters"][0]["values"][0];
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) {
let start_year;
for (let query of obj["chartDescription"]["queries"]) {
if(!query["query"]["filters"]){
if (!query["query"]["filters"]) {
return;
}
for (let filter of query["query"]["filters"]) {
@ -122,7 +175,7 @@ export class IndicatorUtils {
if (gfilter["field"].indexOf(".year") != -1 && gfilter["type"].indexOf(">") != -1) {
start_year = gfilter["values"][0];
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) {
let end_year;
for (let query of obj["chartDescription"]["queries"]) {
if(!query["query"]["filters"]){
if (!query["query"]["filters"]) {
return;
}
for (let filter of query["query"]["filters"]) {
@ -140,7 +193,7 @@ export class IndicatorUtils {
if (gfilter["field"].indexOf(".year") != -1 && gfilter["type"].indexOf("<") != -1) {
end_year = gfilter["values"][0];
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"]) {
title = obj["chartDescription"]["title"]["text"];
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"]) {
title = obj["chartDescription"]["xAxis"]["title"]["text"];
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"]) {
title = obj["chartDescription"]["yAxis"]["title"]["text"];
obj["chartDescription"]["yAxis"]["title"]["text"] = ChartHelper.prefix + "yAxisTitle" + ChartHelper.suffix;
indicatorPath.parameters.set("yAxisTitle", title);
indicatorPath.parameters["yAxisTitle"] = title;
}
}
private addResultFilters(obj, indicatorPath: IndicatorPath) {
let resultTypes = ["publication","software","dataset","other"];
let index = -1;
let resultTypes = ["publication", "software", "dataset", "other"];
let index = -1;
for (let query of obj["chartDescription"]["queries"]) {
if (!query["query"]["select"]) {
return;
}
for (let select of query["query"]["select"]) {
for (var i=0; i < resultTypes.length; i++) {
if(select.field.startsWith(resultTypes[i]) ) {
for (var i = 0; i < resultTypes.length; i++) {
if (select.field.startsWith(resultTypes[i])) {
index = i;
}
}
}
}
if(index != -1){
if (index != -1) {
indicatorPath.filters = IndicatorPath.createResultFilters(resultTypes[index]);
}
}
@ -201,7 +255,7 @@ export class IndicatorUtils {
if (obj["title"]) {
title = obj["title"];
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"]) {
title = obj["xaxistitle"];
obj["xaxistitle"] = ChartHelper.prefix + "xAxisTitle" + ChartHelper.suffix;
indicatorPath.parameters.set("xAxisTitle", title);
indicatorPath.parameters["xAxisTitle"] = title;
}
}
private extractOldToolYTitle(obj, indicatorPath: IndicatorPath) {
let title = "";
if (obj["fieldsheaders"] ) {
if (obj["fieldsheaders"]) {
title = obj["fieldsheaders"];
obj["fieldsheaders"] = ChartHelper.prefix + "yAxisTitle" + ChartHelper.suffix;
indicatorPath.parameters.set("yAxisTitle", title);
obj["fieldsheaders"] = ChartHelper.prefix + "yAxisTitle" + ChartHelper.suffix;
indicatorPath.parameters["yAxisTitle"] = title;
}
}
}
/*
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

View File

@ -20,7 +20,7 @@ export class StatisticsService {
this.chartSources.set('stats-tool', properties.statisticsFrameNewAPIURL);
this.chartSources.set('old', properties.statisticsFrameAPIURL);
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 {
let source = 'fake';
let source = 'image';
this.chartSources.forEach((value, key) => {
if(value !== '' && url.indexOf(value) !== -1) {
source = key;

View File

@ -22,3 +22,8 @@
--header-height: 70px;
--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 {
cursor: pointer;
cursor: pointer !important;
}
/* On link hover, his items with this class will be displayed*/
@ -146,3 +146,22 @@ body.dashboard {
padding: 0;
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>
if(isHighDensity) {
// enable hires images
altair_helpers.retina_images();
$.getScript( "assets/theme-assets/js/custom/dense.min.js", function(data) {
// enable hires images
altair_helpers.retina_images();
});
}
if(Modernizr.touch) {
// fastClick (touch devices)