[Library | develop]: resultLanding.component.ts: Added ContextsService and call to get public communities, and then filter out contexts (related to communities) of resultLandingInfo if they are hidden.
This commit is contained in:
parent
4e3df67f7e
commit
a53c4e90d0
|
@ -28,6 +28,7 @@ import {NumberUtils} from '../../utils/number-utils.class';
|
||||||
import {FullScreenModalComponent} from "../../utils/modal/full-screen-modal/full-screen-modal.component";
|
import {FullScreenModalComponent} from "../../utils/modal/full-screen-modal/full-screen-modal.component";
|
||||||
import {SdgFosSuggestComponent} from '../landing-utils/sdg-fos-suggest/sdg-fos-suggest.component';
|
import {SdgFosSuggestComponent} from '../landing-utils/sdg-fos-suggest/sdg-fos-suggest.component';
|
||||||
import {LayoutService} from "../../dashboard/sharedComponents/sidebar/layout.service";
|
import {LayoutService} from "../../dashboard/sharedComponents/sidebar/layout.service";
|
||||||
|
import {ContextsService} from "../../claims/claim-utils/service/contexts.service";
|
||||||
|
|
||||||
declare var ResizeObserver;
|
declare var ResizeObserver;
|
||||||
|
|
||||||
|
@ -174,6 +175,8 @@ export class ResultLandingComponent {
|
||||||
@ViewChild('fosFsModal') fosFsModal: FullScreenModalComponent;
|
@ViewChild('fosFsModal') fosFsModal: FullScreenModalComponent;
|
||||||
|
|
||||||
public noCommunities: boolean = false;
|
public noCommunities: boolean = false;
|
||||||
|
private promise: Promise<void> = null;
|
||||||
|
private publicCommunities: string[] = [];
|
||||||
|
|
||||||
public rightSidebarOffcanvasClicked: boolean = false;
|
public rightSidebarOffcanvasClicked: boolean = false;
|
||||||
public egiTransferModalOpen = false;
|
public egiTransferModalOpen = false;
|
||||||
|
@ -192,7 +195,8 @@ export class ResultLandingComponent {
|
||||||
private _location: Location,
|
private _location: Location,
|
||||||
private indexInfoService: IndexInfoService,
|
private indexInfoService: IndexInfoService,
|
||||||
private userManagementService: UserManagementService,
|
private userManagementService: UserManagementService,
|
||||||
private layoutService: LayoutService) {
|
private layoutService: LayoutService,
|
||||||
|
private _contextService: ContextsService) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
@ -256,6 +260,7 @@ export class ResultLandingComponent {
|
||||||
this.type="publication";
|
this.type="publication";
|
||||||
}
|
}
|
||||||
if ((this.id && StringUtils.isOpenAIREID(this.id)) || (this.identifier)) {
|
if ((this.id && StringUtils.isOpenAIREID(this.id)) || (this.identifier)) {
|
||||||
|
this.getPublicCommunities();
|
||||||
this.getVocabulariesAndResultLandingInfo();
|
this.getVocabulariesAndResultLandingInfo();
|
||||||
} else {
|
} else {
|
||||||
this.showLoading = false;
|
this.showLoading = false;
|
||||||
|
@ -496,29 +501,32 @@ export class ResultLandingComponent {
|
||||||
this.resultLandingInfo = null;
|
this.resultLandingInfo = null;
|
||||||
this.hasAltMetrics = false;
|
this.hasAltMetrics = false;
|
||||||
this.subscriptions.push(this._resultLandingService.getResultLandingInfo(this.id, this.identifier, this.type, subjectsVocabulary, this.properties).subscribe(
|
this.subscriptions.push(this._resultLandingService.getResultLandingInfo(this.id, this.identifier, this.type, subjectsVocabulary, this.properties).subscribe(
|
||||||
data => {
|
async data => {
|
||||||
|
let contexts = data.contexts;
|
||||||
|
data.contexts = [];
|
||||||
|
|
||||||
this.resultLandingInfo = data;
|
this.resultLandingInfo = data;
|
||||||
this.id = this.resultLandingInfo.objIdentifier;
|
this.id = this.resultLandingInfo.objIdentifier;
|
||||||
//old
|
//old
|
||||||
// this.viewsFrameUrl = this.properties.framesAPIURL + 'merge.php?com=query&data=[{"query":"resRepoViews", "resTitle":"' + this.id + '", "table":"","fields":[{"fld":"sum","agg":"sum","type":"column","yaxis":1,"c":false}],"xaxis":{"name":"month","agg":"sum"},"group":" ","color":"","type":"chart","size":200,"sort":"xaxis","xStyle":{"r":-30,"s":"6","l":"-","ft":"-","wt":"-"},"title":"","subtitle":"","xaxistitle":"Repository","yaxisheaders":["Monthly views"],"generalxaxis":"","theme":0,"in":[],"filters":[{"name":"","values":[""],"to":"-1"}]}]&info_types=["column"]&stacking=normal&steps=false&fontFamily=Courier&spacing=[5,0,0,0]&style=[{"color":"rgba(0, 0, 0, 1)","size":"18"},{"color":"rgba(0, 0, 0, 1)","size":"18"},{"color":"000000","size":""},{"color":"000000","size":""}]&backgroundColor=rgba(255,255,255,1)&colors[]=rgba(67, 67, 72, 1)&colors[]=rgba(144, 237, 125, 1)&colors[]=rgba(247, 163, 92, 1)&colors[]=rgba(128, 133, 233, 1)&colors[]=rgba(241, 92, 128, 1)&colors[]=rgba(228, 211, 84, 1)&colors[]=rgba(43, 144, 143, 1)&colors[]=rgba(244, 91, 91, 1)&colors[]=rgba(145, 232, 225, 1)&xlinew=0&ylinew=1&legends=true&tooltips=true&persistent=false';
|
// this.viewsFrameUrl = this.properties.framesAPIURL + 'merge.php?com=query&data=[{"query":"resRepoViews", "resTitle":"' + this.id + '", "table":"","fields":[{"fld":"sum","agg":"sum","type":"column","yaxis":1,"c":false}],"xaxis":{"name":"month","agg":"sum"},"group":" ","color":"","type":"chart","size":200,"sort":"xaxis","xStyle":{"r":-30,"s":"6","l":"-","ft":"-","wt":"-"},"title":"","subtitle":"","xaxistitle":"Repository","yaxisheaders":["Monthly views"],"generalxaxis":"","theme":0,"in":[],"filters":[{"name":"","values":[""],"to":"-1"}]}]&info_types=["column"]&stacking=normal&steps=false&fontFamily=Courier&spacing=[5,0,0,0]&style=[{"color":"rgba(0, 0, 0, 1)","size":"18"},{"color":"rgba(0, 0, 0, 1)","size":"18"},{"color":"000000","size":""},{"color":"000000","size":""}]&backgroundColor=rgba(255,255,255,1)&colors[]=rgba(67, 67, 72, 1)&colors[]=rgba(144, 237, 125, 1)&colors[]=rgba(247, 163, 92, 1)&colors[]=rgba(128, 133, 233, 1)&colors[]=rgba(241, 92, 128, 1)&colors[]=rgba(228, 211, 84, 1)&colors[]=rgba(43, 144, 143, 1)&colors[]=rgba(244, 91, 91, 1)&colors[]=rgba(145, 232, 225, 1)&xlinew=0&ylinew=1&legends=true&tooltips=true&persistent=false';
|
||||||
// this.downloadsFrameUrl = this.properties.framesAPIURL + 'merge.php?com=query&data=[{"query":"resRepoDownloads", "resTitle":"' + this.id + '", "table":"","fields":[{"fld":"sum","agg":"sum","type":"column","yaxis":1,"c":false}],"xaxis":{"name":"month","agg":"sum"},"group":" ","color":"","type":"chart","size":200,"sort":"xaxis","xStyle":{"r":-30,"s":"6","l":"-","ft":"-","wt":"-"},"title":"","subtitle":"","xaxistitle":"Repository","yaxisheaders":["Monthly downloads"],"generalxaxis":"","theme":0,"in":[],"filters":[{"name":"","values":[""],"to":"-1"}]}]&info_types=["column"]&stacking=normal&steps=false&fontFamily=Courier&spacing=[5,0,0,0]&style=[{"color":"rgba(0, 0, 0, 1)","size":"18"},{"color":"rgba(0, 0, 0, 1)","size":"18"},{"color":"000000","size":""},{"color":"000000","size":""}]&backgroundColor=rgba(255,255,255,1)&colors[]=rgba(67, 67, 72, 1)&colors[]=rgba(144, 237, 125, 1)&colors[]=rgba(247, 163, 92, 1)&colors[]=rgba(128, 133, 233, 1)&colors[]=rgba(241, 92, 128, 1)&colors[]=rgba(228, 211, 84, 1)&colors[]=rgba(43, 144, 143, 1)&colors[]=rgba(244, 91, 91, 1)&colors[]=rgba(145, 232, 225, 1)&xlinew=0&ylinew=1&legends=true&tooltips=true&persistent=false';
|
// this.downloadsFrameUrl = this.properties.framesAPIURL + 'merge.php?com=query&data=[{"query":"resRepoDownloads", "resTitle":"' + this.id + '", "table":"","fields":[{"fld":"sum","agg":"sum","type":"column","yaxis":1,"c":false}],"xaxis":{"name":"month","agg":"sum"},"group":" ","color":"","type":"chart","size":200,"sort":"xaxis","xStyle":{"r":-30,"s":"6","l":"-","ft":"-","wt":"-"},"title":"","subtitle":"","xaxistitle":"Repository","yaxisheaders":["Monthly downloads"],"generalxaxis":"","theme":0,"in":[],"filters":[{"name":"","values":[""],"to":"-1"}]}]&info_types=["column"]&stacking=normal&steps=false&fontFamily=Courier&spacing=[5,0,0,0]&style=[{"color":"rgba(0, 0, 0, 1)","size":"18"},{"color":"rgba(0, 0, 0, 1)","size":"18"},{"color":"000000","size":""},{"color":"000000","size":""}]&backgroundColor=rgba(255,255,255,1)&colors[]=rgba(67, 67, 72, 1)&colors[]=rgba(144, 237, 125, 1)&colors[]=rgba(247, 163, 92, 1)&colors[]=rgba(128, 133, 233, 1)&colors[]=rgba(241, 92, 128, 1)&colors[]=rgba(228, 211, 84, 1)&colors[]=rgba(43, 144, 143, 1)&colors[]=rgba(244, 91, 91, 1)&colors[]=rgba(145, 232, 225, 1)&xlinew=0&ylinew=1&legends=true&tooltips=true&persistent=false';
|
||||||
//new
|
//new
|
||||||
this.viewsFrameUrl = this.properties.statisticsFrameNewAPIURL + 'chart?json=' + encodeURIComponent('{"library":"HighCharts","chartDescription":{"queries":[{"name":"Monthly views","type":"column","query":{"name":"usagestats.results.views.monthly", "parameters":["' + this.id + '"], "profile":"OpenAIRE All-inclusive" }}],"chart":{"backgroundColor":"#FFFFFFFF","borderColor":"#335cadff","borderRadius":0,"borderWidth":0,"plotBorderColor":"#ccccccff","plotBorderWidth":0},"title":{"text":"Monthly views"},"subtitle":{},"yAxis":{"title":{"text":""}},"xAxis":{"title":{}},"lang":{"noData":"No Data available for the Query"},"exporting":{"enabled":false},"plotOptions":{"series":{"dataLabels":{"enabled":false}}},"legend":{"enabled":false},"credits":{"href":null,"enabled":true,"text":""}}}');
|
this.viewsFrameUrl = this.properties.statisticsFrameNewAPIURL + 'chart?json=' + encodeURIComponent('{"library":"HighCharts","chartDescription":{"queries":[{"name":"Monthly views","type":"column","query":{"name":"usagestats.results.views.monthly", "parameters":["' + this.id + '"], "profile":"OpenAIRE All-inclusive" }}],"chart":{"backgroundColor":"#FFFFFFFF","borderColor":"#335cadff","borderRadius":0,"borderWidth":0,"plotBorderColor":"#ccccccff","plotBorderWidth":0},"title":{"text":"Monthly views"},"subtitle":{},"yAxis":{"title":{"text":""}},"xAxis":{"title":{}},"lang":{"noData":"No Data available for the Query"},"exporting":{"enabled":false},"plotOptions":{"series":{"dataLabels":{"enabled":false}}},"legend":{"enabled":false},"credits":{"href":null,"enabled":true,"text":""}}}');
|
||||||
this.downloadsFrameUrl = this.properties.statisticsFrameNewAPIURL + 'chart?json=' +
|
this.downloadsFrameUrl = this.properties.statisticsFrameNewAPIURL + 'chart?json=' +
|
||||||
encodeURIComponent('{"library":"HighCharts","chartDescription":{"queries":[{"name":"Monthly downloads","type":"column","query":{"name":"usagestats.results.downloads.monthly", "parameters":["' + this.id + '"], "profile":"OpenAIRE All-inclusive" }}],"chart":{"backgroundColor":"#FFFFFFFF","borderColor":"#335cadff","borderRadius":0,"borderWidth":0,"plotBorderColor":"#ccccccff","plotBorderWidth":0},"title":{"text":"Monthly downloads"},"subtitle":{},"yAxis":{"title":{"text":""}},"xAxis":{"title":{}},"lang":{"noData":"No Data available for the Query"},"exporting":{"enabled":false},"plotOptions":{"series":{"dataLabels":{"enabled":false}}},"legend":{"enabled":false},"credits":{"href":null,"enabled":true,"text":""}}}');
|
encodeURIComponent('{"library":"HighCharts","chartDescription":{"queries":[{"name":"Monthly downloads","type":"column","query":{"name":"usagestats.results.downloads.monthly", "parameters":["' + this.id + '"], "profile":"OpenAIRE All-inclusive" }}],"chart":{"backgroundColor":"#FFFFFFFF","borderColor":"#335cadff","borderRadius":0,"borderWidth":0,"plotBorderColor":"#ccccccff","plotBorderWidth":0},"title":{"text":"Monthly downloads"},"subtitle":{},"yAxis":{"title":{"text":""}},"xAxis":{"title":{}},"lang":{"noData":"No Data available for the Query"},"exporting":{"enabled":false},"plotOptions":{"series":{"dataLabels":{"enabled":false}}},"legend":{"enabled":false},"credits":{"href":null,"enabled":true,"text":""}}}');
|
||||||
this.bipFrameUrl = this.properties.bipFrameAPIURL + this.id + (properties.environment == "beta" ? "&src=beta" : "");
|
this.bipFrameUrl = this.properties.bipFrameAPIURL + this.id + (properties.environment == "beta" ? "&src=beta" : "");
|
||||||
let pid:Identifier = Identifier.getPIDFromIdentifiers(this.resultLandingInfo.identifiers);
|
let pid: Identifier = Identifier.getPIDFromIdentifiers(this.resultLandingInfo.identifiers);
|
||||||
if (this.type == "result") { // no type was specified - update URL based this.resultLandingInfo.resultType
|
if (this.type == "result") { // no type was specified - update URL based this.resultLandingInfo.resultType
|
||||||
this.updateUrlWithType(pid);
|
this.updateUrlWithType(pid);
|
||||||
}
|
}
|
||||||
this.canonicalUrl = this.properties.domain+ properties.baseLink + ( pid ? (this.linkToLandingPage.split("?")[0] + "?pid=" + encodeURIComponent(pid.id)):
|
this.canonicalUrl = this.properties.domain + properties.baseLink + (pid ? (this.linkToLandingPage.split("?")[0] + "?pid=" + encodeURIComponent(pid.id)) :
|
||||||
(this.linkToLandingPage + this.resultLandingInfo.relcanId));
|
(this.linkToLandingPage + this.resultLandingInfo.relcanId));
|
||||||
this.seoService.createLinkForCanonicalURL(this.canonicalUrl);
|
this.seoService.createLinkForCanonicalURL(this.canonicalUrl);
|
||||||
this.updateUrl(this.canonicalUrl);
|
this.updateUrl(this.canonicalUrl);
|
||||||
this.addNoIndexFilter();
|
this.addNoIndexFilter();
|
||||||
if (this.resultLandingInfo.title) {
|
if (this.resultLandingInfo.title) {
|
||||||
this.updateTitle(this.resultLandingInfo.title);
|
this.updateTitle(this.resultLandingInfo.title);
|
||||||
this.updateDescription((this.resultLandingInfo.description ? (this.resultLandingInfo.description.substr(0,157) + (this.resultLandingInfo.description.substr(0,157).length == 157?"...":"")) : (this.resultLandingInfo.title)));
|
this.updateDescription((this.resultLandingInfo.description ? (this.resultLandingInfo.description.substr(0, 157) + (this.resultLandingInfo.description.substr(0, 157).length == 157 ? "..." : "")) : (this.resultLandingInfo.title)));
|
||||||
}
|
}
|
||||||
this.subscriptions.push(this._piwikService.trackViewForCustomUrl(this.properties, this.resultLandingInfo.title, this.linkToLandingPage.split("?")[1] + this.id).subscribe());
|
this.subscriptions.push(this._piwikService.trackViewForCustomUrl(this.properties, this.resultLandingInfo.title, this.linkToLandingPage.split("?")[1] + this.id).subscribe());
|
||||||
let bioentitiesNum = 0;
|
let bioentitiesNum = 0;
|
||||||
|
@ -529,9 +537,9 @@ export class ResultLandingComponent {
|
||||||
}
|
}
|
||||||
this.bioentitiesNum = bioentitiesNum;
|
this.bioentitiesNum = bioentitiesNum;
|
||||||
if (typeof document !== 'undefined') {
|
if (typeof document !== 'undefined') {
|
||||||
if(this.resultLandingInfo.identifiers) {
|
if (this.resultLandingInfo.identifiers) {
|
||||||
let pidsArray: string[] = [];
|
let pidsArray: string[] = [];
|
||||||
for(let key of Array.from(this.resultLandingInfo.identifiers.keys())) {
|
for (let key of Array.from(this.resultLandingInfo.identifiers.keys())) {
|
||||||
pidsArray = pidsArray.concat(this.resultLandingInfo.identifiers.get(key));
|
pidsArray = pidsArray.concat(this.resultLandingInfo.identifiers.get(key));
|
||||||
this.pidsArrayString = pidsArray.join();
|
this.pidsArrayString = pidsArray.join();
|
||||||
}
|
}
|
||||||
|
@ -545,14 +553,17 @@ export class ResultLandingComponent {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(this.communityId && this.communityId == "enermaps" && properties.enermapsURL){
|
if (this.communityId && this.communityId == "enermaps" && properties.enermapsURL) {
|
||||||
this.enermapsId = ParsingFunctions.getEnermapsConceptId(this.resultLandingInfo.contexts);
|
this.enermapsId = ParsingFunctions.getEnermapsConceptId(this.resultLandingInfo.contexts);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.relatedClassFilters = [{"label": "All relations", "value": ""}];
|
this.relatedClassFilters = [{"label": "All relations", "value": ""}];
|
||||||
if(this.resultLandingInfo.relatedClassFilters.size > 1) {
|
if (this.resultLandingInfo.relatedClassFilters.size > 1) {
|
||||||
for (let relClass of this.resultLandingInfo.relatedClassFilters) {
|
for (let relClass of this.resultLandingInfo.relatedClassFilters) {
|
||||||
this.relatedClassFilters.push({"label": HelperFunctions.getVocabularyLabel(relClass, this.relationsVocabulary), "value": relClass});
|
this.relatedClassFilters.push({
|
||||||
|
"label": HelperFunctions.getVocabularyLabel(relClass, this.relationsVocabulary),
|
||||||
|
"value": relClass
|
||||||
|
});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.relatedClassFilters.pop();
|
this.relatedClassFilters.pop();
|
||||||
|
@ -562,12 +573,12 @@ export class ResultLandingComponent {
|
||||||
|
|
||||||
this.hasViews = false;
|
this.hasViews = false;
|
||||||
this.hasDownloads = false;
|
this.hasDownloads = false;
|
||||||
if(this.resultLandingInfo.measure && this.resultLandingInfo.measure.counts) {
|
if (this.resultLandingInfo.measure && this.resultLandingInfo.measure.counts) {
|
||||||
this.resultLandingInfo.measure.counts.forEach(measure => {
|
this.resultLandingInfo.measure.counts.forEach(measure => {
|
||||||
if(measure.name == "views" && measure.value > 0) {
|
if (measure.name == "views" && measure.value > 0) {
|
||||||
this.hasViews = true;
|
this.hasViews = true;
|
||||||
}
|
}
|
||||||
if(measure.name == "downloads" && measure.value > 0) {
|
if (measure.name == "downloads" && measure.value > 0) {
|
||||||
this.hasDownloads = true;
|
this.hasDownloads = true;
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -577,6 +588,14 @@ export class ResultLandingComponent {
|
||||||
this.setActiveTab();
|
this.setActiveTab();
|
||||||
|
|
||||||
this.cdr.detectChanges();
|
this.cdr.detectChanges();
|
||||||
|
|
||||||
|
if (contexts) {
|
||||||
|
await this.promise;
|
||||||
|
if(this.publicCommunities && this.publicCommunities.length > 0) {
|
||||||
|
this.resultLandingInfo.contexts = contexts.filter(context => this.publicCommunities.includes(context.idContext));
|
||||||
|
this.cdr.detectChanges();
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
err => {
|
err => {
|
||||||
this.handleError("Error getting " + this.type + " for " + (this.id ? ("id: " + this.id) : ("pid: " + this.identifier.id + " ("+this.identifier.class+")")), err);
|
this.handleError("Error getting " + this.type + " for " + (this.id ? ("id: " + this.id) : ("pid: " + this.identifier.id + " ("+this.identifier.class+")")), err);
|
||||||
|
@ -593,6 +612,21 @@ export class ResultLandingComponent {
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public getPublicCommunities() {
|
||||||
|
this.promise = new Promise<void>(resolve => {
|
||||||
|
this._contextService.getPublicCommunitiesByState().subscribe(
|
||||||
|
data => {
|
||||||
|
this.publicCommunities = data.map(value => value.id);
|
||||||
|
// this.publicCommunities = data;
|
||||||
|
resolve();
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
this.handleError("Error getting communities status", error);
|
||||||
|
resolve();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public metricsResults($event) {
|
public metricsResults($event) {
|
||||||
this.totalViews = $event.totalViews;
|
this.totalViews = $event.totalViews;
|
||||||
this.totalDownloads = $event.totalDownloads;
|
this.totalDownloads = $event.totalDownloads;
|
||||||
|
|
Loading…
Reference in New Issue