[MonitorDashboard]: Save stakeholder

git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-monitor-portal/trunk/monitor_dashboard@57772 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
Konstantinos Triantafyllou 2019-11-29 14:46:40 +00:00
parent 9d10f6e745
commit 390a205580
5 changed files with 89 additions and 60 deletions

View File

@ -135,6 +135,29 @@
</div>
</a>
</ng-template>
<div>
<div class="md-card clickable" (click)="editStakeholder()">
<div class="md-card-toolbar">
<div class="md-card-toolbar-heading-text"
[class.uk-flex-middle]="!grid"
[class.uk-flex]="!grid"
[class.uk-flex-center]="!grid">
<i *ngIf="!grid" class="material-icons md-36">add</i>
<span>Create a Stakeholder</span>
</div>
</div>
<div *ngIf="grid" class="md-card-content">
<div uk-grid>
<div class="uk-width-1-1">
Create a new Stakeholder by using a default profile base on his type.
</div>
<div class="uk-width-1-1 uk-flex uk-flex-center">
<i class="material-icons md-48">add</i>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>

View File

@ -7,6 +7,7 @@ import {Subscriber, zip} from "rxjs";
import {Option, StakeholderUtils} from "../utils/indicator-utils";
import {FormBuilder, FormGroup, Validators} from "@angular/forms";
import {AlertModal} from "../openaireLibrary/utils/modal/alert";
import {StakeholderCreator} from "../utils/entities/stakeholderCreator";
@Component({
selector: 'home',
@ -145,30 +146,30 @@ export class HomeComponent implements OnInit, OnDestroy {
}
public editStakeholder(stakeholder: Stakeholder = null, isDefault: boolean = false) {
if(isDefault) {
this.index = (stakeholder)?this.defaultStakeholders.findIndex(value => value._id === stakeholder._id):-1;
if (isDefault) {
this.index = (stakeholder) ? this.defaultStakeholders.findIndex(value => value._id === stakeholder._id) : -1;
} else {
this.index = (stakeholder)?this.stakeholders.findIndex(value => value._id === stakeholder._id):-1;
this.index = (stakeholder) ? this.stakeholders.findIndex(value => value._id === stakeholder._id) : -1;
}
if(!stakeholder) {
if (!stakeholder) {
this.stakeholder = new Stakeholder(null, null, null,
null, null, isDefault, null, false, false);
null, null, isDefault, null, false, false, null);
} else {
this.stakeholder = stakeholder;
}
this.stakeholderFb = this.fb.group( {
_id: this.fb.control(stakeholder._id),
index_name: this.fb.control(stakeholder.index_name, Validators.required),
index_id: this.fb.control(stakeholder.index_id, Validators.required),
index_shortName: this.fb.control(stakeholder.index_shortName, Validators.required),
isDefaultProfile: this.fb.control(stakeholder.isDefaultProfile),
alias: this.fb.control(stakeholder.alias, Validators.required),
isPublic: this.fb.control(stakeholder.isPublic),
isActive: this.fb.control(stakeholder.isActive),
type: this.fb.control(stakeholder.type, Validators.required),
topics: this.fb.control(stakeholder.topics)
this.stakeholderFb = this.fb.group({
_id: this.fb.control(this.stakeholder ._id),
index_name: this.fb.control(this.stakeholder .index_name, Validators.required),
index_id: this.fb.control(this.stakeholder .index_id, Validators.required),
index_shortName: this.fb.control(this.stakeholder .index_shortName, Validators.required),
isDefaultProfile: this.fb.control(this.stakeholder .isDefaultProfile),
alias: this.fb.control(this.stakeholder .alias, Validators.required),
isPublic: this.fb.control(this.stakeholder .isPublic),
isActive: this.fb.control(this.stakeholder .isActive),
type: this.fb.control(this.stakeholder .type, Validators.required),
topics: this.fb.control(this.stakeholder .topics)
});
if(this.index !== -1 && this.stakeholderFb.value.type) {
if (this.index !== -1 && this.stakeholderFb.value.type) {
this.stakeholderFb.get('type').disable();
}
this.editStakeholderModal.cancelButtonText = 'Cancel';
@ -179,22 +180,23 @@ export class HomeComponent implements OnInit, OnDestroy {
}
public saveStakeholder() {
if(this.index === -1) {
this.stakeholderService.getDefaultStakeholders(this.properties.monitorServiceAPIURL,
this.stakeholderFb.value.type).subscribe( stakeholders => {
this.stakeholderFb.setControl('topic', this.fb.control(stakeholders[0].topics));
this.stakeholderService.saveElement(this.properties.monitorServiceAPIURL, this.stakeholderFb.value).subscribe(stakeholder => {
if(stakeholder.isDefaultProfile) {
this.defaultStakeholders.push(stakeholder);
} else {
this.stakeholders.push(stakeholder);
}
});
if (this.index === -1) {
// this.stakeholderFb.setValue(this.stakeholderUtils.
// createFunderFromDefaultProfile(this.stakeholderFb.value,
// this.defaultStakeholders.find( value => value.type === this.stakeholderFb.value.type).topics));
this.stakeholderFb.setValue(this.stakeholderUtils.
createFunderFromDefaultProfile(this.stakeholderFb.value, StakeholderCreator.createFunderDefaultProfile().topics));
this.stakeholderService.buildStakeholder(this.properties.monitorServiceAPIURL, this.stakeholderFb.value).subscribe(stakeholder => {
if (stakeholder.isDefaultProfile) {
this.defaultStakeholders.push(stakeholder);
} else {
this.stakeholders.push(stakeholder);
}
});
} else {
this.stakeholderFb.get('type').enable();
this.stakeholderService.saveElement(this.properties.monitorServiceAPIURL, this.stakeholderFb.value).subscribe(stakeholder => {
if(stakeholder.isDefaultProfile) {
if (stakeholder.isDefaultProfile) {
this.defaultStakeholders[this.index] = stakeholder;
} else {
this.stakeholders[this.index] = stakeholder;
@ -204,10 +206,10 @@ export class HomeComponent implements OnInit, OnDestroy {
}
public deleteStakeholderOpen(stakeholder: Stakeholder, isDefault = false) {
if(isDefault) {
this.index = (stakeholder)?this.defaultStakeholders.findIndex(value => value._id === stakeholder._id):-1;
if (isDefault) {
this.index = (stakeholder) ? this.defaultStakeholders.findIndex(value => value._id === stakeholder._id) : -1;
} else {
this.index = (stakeholder)?this.stakeholders.findIndex(value => value._id === stakeholder._id):-1;
this.index = (stakeholder) ? this.stakeholders.findIndex(value => value._id === stakeholder._id) : -1;
}
}

View File

@ -77,19 +77,24 @@ export class MonitorComponent implements OnInit, OnDestroy {
// this.stakeholderService.getStakeholderAsObservable().subscribe(stakeholder => {
let stakeholder:Stakeholder = null;
if(params['stakeholder']=="fwf"){
stakeholder = this.stakeholderUtils.createFunderFromDefaultProfile("fwf","funder","fwf_________::FWF",
"Austrian Science Fund (FWF)","FWF",
false,"fwf",true,true, null, StakeholderCreator.createFunderDefaultProfile());
stakeholder = new Stakeholder("fwf", "funder", "fwf_________::FWF","Austrian Science Fund (FWF)","FWF",
false,"fwf",true,true, null);
stakeholder = this.stakeholderUtils.
createFunderFromDefaultProfile(stakeholder, StakeholderCreator.createFunderDefaultProfile().topics);
stakeholder.logoUrl = "./assets/fwf.png";
}else if(params['stakeholder']=="arc"){
stakeholder = this.stakeholderUtils.createFunderFromDefaultProfile("arc","funder","arc_________::ARC",
stakeholder = new Stakeholder("arc","funder","arc_________::ARC",
"Australian Research Council (ARC)","ARC",
false,"arc",true,true, null, StakeholderCreator.createFunderDefaultProfile());
stakeholder.logoUrl = "./assets/arc1.gif";
false,"arc",true,true, null);
stakeholder = this.stakeholderUtils.
createFunderFromDefaultProfile(stakeholder, StakeholderCreator.createFunderDefaultProfile().topics);
stakeholder.logoUrl = "./assets/arc1.gif";
}else{
stakeholder = this.stakeholderUtils.createFunderFromDefaultProfile("ec","funder","ec__________::EC",
stakeholder = new Stakeholder("ec","funder","ec__________::EC",
"European Commission","EC",
false,"ec",true,true, null, StakeholderCreator.createFunderDefaultProfile());
false,"ec",true,true, null);
stakeholder = this.stakeholderUtils.
createFunderFromDefaultProfile(stakeholder, StakeholderCreator.createFunderDefaultProfile().topics);
stakeholder.logoUrl = "./assets/ec.png";
}

View File

@ -161,7 +161,7 @@ export class Stakeholder {
[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},{"field":"publication.access mode","aggregate":null}],"filters":[{"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":"2000"}}],"chart":{"backgroundColor":"#FFFFFFFF","borderColor":"#335cadff","borderRadius":0,"borderWidth":0,"plotBorderColor":"#ccccccff","plotBorderWidth":0},"title":{"text":"Publications by Access Mode"},"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)]);
pubDefSub.charts.push(c_pubs_access_modes);
// let c_pubs_av_embargo = new Indicator("Average period of embargoed publications",null, "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)]);
// let c_pubs_av_embargo = new Indicator("Average period of embargoed publications",null, "chart","medium",true, true, [new IndicatorPath("line", "image","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)]);
// pubDefSub.charts.push(c_pubs_av_embargo);
let c_pubs_OA_journals = new Indicator("Publications in OA Journals over time",null, "chart","medium",true, true,
@ -177,7 +177,7 @@ export class Stakeholder {
// [new IndicatorPath("column", "stats-tool", "chart?json="+encodeURIComponent('), null)]);
// pubDefSub.charts.push(c_pubs_repo);
// let c_pubs_green_year = new Indicator("How many OA publications have been submitted to repos per year?",null, "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)]);
// let c_pubs_green_year = new Indicator("How many OA publications have been submitted to repos per year?",null, "chart","medium",true, true,[new IndicatorPath("line", "image","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)]);
// pubDefSub.charts.push(c_pubs_green_year);
let c_pubs_datasource_country = new Indicator("What is the percentage of OA pubs by repositories over the years?",null, "chart","medium",true, true,
@ -193,25 +193,25 @@ export class Stakeholder {
encodeURIComponent('{"library":"HighCharts","chartDescription":{"colors":["#42a5f5","#26a69a","#90ed7d","#607d8b","#00838f","#689f38","#e4d354","#2b908f","#546e7a","#01579"],"queries":[{"name":"Data","type":"column","query":{"select":[{"field":"result","aggregate":"count"},{"field":"result.year","aggregate":null}],"filters":[{"groupFilters":[{"field":"result.project.funder","type":"=","values":["'+ChartHelper.prefix+'funder_name'+ChartHelper.suffix+'"]},{"field":"result.type","type":"=","values":["dataset"]},{"field":"result.year","type":">=","values":["2014"]},{"field":"result.year","type":"<=","values":["2019"]}],"op":"AND"}],"entity":"result","profile":"OpenAIRE original","limit":"0"}}],"chart":{"backgroundColor":"#FFFFFFFF","borderColor":"#335cadff","borderRadius":0,"borderWidth":0,"plotBorderColor":"#ccccccff","plotBorderWidth":0},"title":{"text":"'+stakeholder.index_shortName+' research data over time"},"subtitle":{},"yAxis":{"title":{"text":"Research data"}},"xAxis":{"title":{"text":"Year"}},"lang":{"noData":"No Data available for the Query"},"exporting":{"enabled":true},"plotOptions":{"series":{"dataLabels":{"enabled":false}}},"legend":{"enabled":false,"align":"center","verticalAlign":"bottom","layout":"horizontal"},"credits":{"href":null,"enabled":true,"text":"Created by OpenAIRE via HighCharts"}}}'), null)]);
dataDefSub.charts.push(c_data_year);*/
// let c_other_year = new Indicator("How your Open research data are shaped over the years?",null, "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)]);
// let c_other_year = new Indicator("How your Open research data are shaped over the years?",null, "chart","medium",true, true, [new IndicatorPath("line", "image","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)]);
// otherDefSub.charts.push(c_other_year);
//
// let c_datasources_access_modes = new Indicator("What is the number of research data repositories by access mode?",null, "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)]);
// let c_datasources_access_modes = new Indicator("What is the number of research data repositories by access mode?",null, "chart","medium",true, true, [new IndicatorPath("line", "image","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)]);
// pubDefSub.charts.push(c_datasources_access_modes);
//
// let c_pub_nometa_year = new Indicator("How many publications lack of abstract per year?",null, "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)]);
// let c_pub_nometa_year = new Indicator("How many publications lack of abstract per year?",null, "chart","medium",true, true, [new IndicatorPath("line", "image","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)]);
// pubDefSub.charts.push(c_pub_nometa_year);
//
// let c_pub_meta_linked_year = new Indicator("??",null, "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)]);
// let c_pub_meta_linked_year = new Indicator("??",null, "chart","medium",true, true, [new IndicatorPath("line", "image","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)]);
// pubDefSub.charts.push(c_pub_meta_linked_year);
//
// let c_pub_colocated_year = new Indicator("How many publications are submitted to more than one repos per year?",null, "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)]);
// let c_pub_colocated_year = new Indicator("How many publications are submitted to more than one repos per year?",null, "chart","medium",true, true, [new IndicatorPath("line", "image","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)]);
// pubDefSub.charts.push(c_pub_colocated_year);
// let c_pub_pids = new Indicator("What is the most common PIDs by year?",null, "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)]);
// let c_pub_pids = new Indicator("What is the most common PIDs by year?",null, "chart","medium",true, true, [new IndicatorPath("line", "image","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)]);
// pubDefSub.charts.push(c_pub_pids);
//
// let c_oai_pmh_datasources = new Indicator("What is the most common PIDs by year?",null, "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)]);
// let c_oai_pmh_datasources = new Indicator("What is the most common PIDs by year?",null, "chart","medium",true, true, [new IndicatorPath("line", "image","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)]);
// pubDefSub.charts.push(c_oai_pmh_datasources);
return topic;
@ -266,8 +266,8 @@ export class Stakeholder {
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)]);
[new IndicatorPath("line", "image", "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("line", "image", "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);
@ -275,7 +275,7 @@ 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")]))
return topic;
@ -383,7 +383,7 @@ 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, image}
url: string;
safeResourceUrl: SafeResourceUrl; // initialize on front end
jsonPath: string[];

View File

@ -1,4 +1,4 @@
import {ChartHelper, Indicator, IndicatorPath, Stakeholder, SubCategory} from "./entities/stakeholder";
import {ChartHelper, Indicator, IndicatorPath, Stakeholder, SubCategory, Topic} from "./entities/stakeholder";
import {Validators} from "@angular/forms";
export interface Option {
@ -30,20 +30,18 @@ export class StakeholderUtils {
isActiveIcon: string = 'brightness_1';
public createFunderFromDefaultProfile(id: string, type: string, index_id, index_name: string, index_shortName: string,
isDefaultProfile: boolean, alias: string, isActive: boolean, isPublic: boolean,
logoUrl: string, funder: Stakeholder): Stakeholder {
funder.initializeFunder(id, type, index_id, index_name, index_shortName, isDefaultProfile, alias, isActive, isPublic, logoUrl);
public createFunderFromDefaultProfile(funder: Stakeholder, defaultTopics: Topic[]): Stakeholder {
funder.topics = defaultTopics;
for (let topic of funder.topics) {
for (let category of topic.categories) {
let subTokeep: SubCategory[] = [];
for (let subCategory of category.subCategories) {
let chartsTokeep: Indicator[] = [];
if (subCategory.recommendedFor.length == 0 || subCategory.recommendedFor.indexOf(id) != -1) {
if (subCategory.recommendedFor.length == 0 || subCategory.recommendedFor.indexOf(funder.index_id) != -1) {
subTokeep.push(subCategory);
}
for (let indicator of subCategory.charts) {
if (indicator.recommendedFor.length == 0 || indicator.recommendedFor.indexOf(id) != -1) {
if (indicator.recommendedFor.length == 0 || indicator.recommendedFor.indexOf(funder.index_id) != -1) {
chartsTokeep.push(indicator);
}
for (let indicatorPath of indicator.indicatorPaths) {
@ -199,6 +197,7 @@ export class IndicatorUtils {
} else if (source === 'old') {
indicatorPath.url = url.split("data=")[0].split("/stats/")[1] + "data=";
indicatorPath.chartObject = decodeURIComponent(url.split("data=")[1].split("&")[0]);
indicatorPath.type = type;
let chart = JSON.parse(indicatorPath.chartObject);
this.extractOldToolTitle(chart, indicatorPath);
this.extractOldToolXTitle(chart, indicatorPath);