Add check if communityId is null in component.ts and in html and Add error message

git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-connect-portal/trunk@51278 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
sofia.baltzi 2018-03-15 16:14:49 +00:00
parent 2e8e71691b
commit 6a2feeea02
2 changed files with 57 additions and 55 deletions

View File

@ -3,7 +3,7 @@
<div class="uk-container uk-margin-bottom"> <div class="uk-container uk-margin-bottom">
<article class="uk-article "> <article class="uk-article ">
<div *ngIf="communityId == null" class="uk-child-width-1-6@l uk-child-width-1-6@m uk-child-width-1-3@s uk-text-center uk-alert uk-alert-primary"> Empty community id </div>
<subscribe *ngIf="communityId != null" [communityId]="communityId" class=" uk-align-right"></subscribe> <subscribe *ngIf="communityId != null" [communityId]="communityId" class=" uk-align-right"></subscribe>
<div *ngIf="communityId != null && community != null"> <div *ngIf="communityId != null && community != null">
<blockquote> <blockquote>
@ -33,7 +33,7 @@
</p> </p>
</div> </div>
<div class="uk-child-width-1-6@l uk-child-width-1-6@m uk-child-width-1-3@s uk-text-center uk-grid" uk-grid=""> <div *ngIf="communityId != null" class="uk-child-width-1-6@l uk-child-width-1-6@m uk-child-width-1-3@s uk-text-center uk-grid" uk-grid="">
<div class="uk-first-column"> <div class="uk-first-column">
<div class="uk-card uk-card-default uk-card-small uk-card-body"> <div class="uk-card uk-card-default uk-card-small uk-card-body">
<div *ngIf="publicationTotal != null"> <div *ngIf="publicationTotal != null">
@ -84,7 +84,7 @@
</div> </div>
</div> </div>
<div class="uk-grid-small uk-margin-medium uk-grid" uk-grid=""> <div *ngIf="communityId != null" class="uk-grid-small uk-margin-medium uk-grid" uk-grid="">
<div class="uk-width-expand@m uk-first-column"> <div class="uk-width-expand@m uk-first-column">
<h3 class="uk-margin-small uk-h3 uk-heading-line uk-text-primary"> <h3 class="uk-margin-small uk-h3 uk-heading-line uk-text-primary">
<span>Most recent publications</span> <span>Most recent publications</span>

View File

@ -75,68 +75,70 @@ export class CommunityComponent {
this.communityId = communityId['communityId']; this.communityId = communityId['communityId'];
}); });
this._communityService.getCommunity(this.properties.communityAPI+this.communityId).subscribe ( if (this.communityId != null) {
community => { this._communityService.getCommunity(this.properties.communityAPI+this.communityId).subscribe (
this.community = community; community => {
this.params = {community: encodeURIComponent('"'+community.queryId+'"')}; this.community = community;
//console.log(community); this.params = {community: encodeURIComponent('"'+community.queryId+'"')};
}); //console.log(community);
});
// this._communityService.getCommunity('https://dev-openaire.d4science.org/openaire/community/'+this.communityId).subscribe ( // this._communityService.getCommunity('https://dev-openaire.d4science.org/openaire/community/'+this.communityId).subscribe (
// community => { // community => {
// this.community = community; // this.community = community;
// this.params = {community: encodeURIComponent('"'+community.queryId+'"')}; // this.params = {community: encodeURIComponent('"'+community.queryId+'"')};
// //console.log(community); // //console.log(community);
// }); // });
this._searchEntriesService.getTotal(this.properties.searchAPIURLLAst+'publications/count?format=json&fq=communityid='+this.communityId).subscribe( this._searchEntriesService.getTotal(this.properties.searchAPIURLLAst+'publications/count?format=json&fq=communityid='+this.communityId).subscribe(
publicationTotal => { publicationTotal => {
this.publicationTotal = publicationTotal; this.publicationTotal = publicationTotal;
}); });
this._searchEntriesService.getTotal(this.properties.searchAPIURLLAst+'datasets/count?format=json&fq=communityid='+this.communityId).subscribe( this._searchEntriesService.getTotal(this.properties.searchAPIURLLAst+'datasets/count?format=json&fq=communityid='+this.communityId).subscribe(
researchDataTotal => { researchDataTotal => {
this.researchDataTotal = researchDataTotal; this.researchDataTotal = researchDataTotal;
}); });
this._searchEntriesService.getTotal(this.properties.searchAPIURLLAst+'software/count?format=json&fq=communityid='+this.communityId).subscribe( this._searchEntriesService.getTotal(this.properties.searchAPIURLLAst+'software/count?format=json&fq=communityid='+this.communityId).subscribe(
softwareTotal => { softwareTotal => {
this.softwareTotal = softwareTotal; this.softwareTotal = softwareTotal;
}); });
this._searchEntriesService.countTotal(this.properties.communityAPI+this.communityId+'/projects').subscribe( this._searchEntriesService.countTotal(this.properties.communityAPI+this.communityId+'/projects').subscribe(
projectTotal => { projectTotal => {
this.projectTotal = projectTotal; this.projectTotal = projectTotal;
//console.log(projectTotal); //console.log(projectTotal);
}); });
this._searchEntriesService.countTotal(this.properties.communityAPI+this.communityId+'/contentproviders').subscribe( this._searchEntriesService.countTotal(this.properties.communityAPI+this.communityId+'/contentproviders').subscribe(
contentProviderTotal => { contentProviderTotal => {
this.contentProviderTotal = contentProviderTotal; this.contentProviderTotal = contentProviderTotal;
//console.log(contentProviderTotal); //console.log(contentProviderTotal);
}); });
// this._searchEntriesService.countTotal(this.properties.communityAPI+this.communityId+'/organizations').subscribe( // this._searchEntriesService.countTotal(this.properties.communityAPI+this.communityId+'/organizations').subscribe(
// organizationTotal => { // organizationTotal => {
// this.organizationTotal = organizationTotal; // this.organizationTotal = organizationTotal;
// console.log(organizationTotal); // console.log(organizationTotal);
// }); // });
this._searchEntriesService.getResults(this.properties.searchAPIURLLAst+'publications?fq=communityid%20exact%20%22'+this.communityId+'%22&sortBy=resultdateofacceptance,descending&format=json&size=5').subscribe( this._searchEntriesService.getResults(this.properties.searchAPIURLLAst+'publications?fq=communityid%20exact%20%22'+this.communityId+'%22&sortBy=resultdateofacceptance,descending&format=json&size=5').subscribe(
publicationResults => { publicationResults => {
this.publicationResults = publicationResults; this.publicationResults = publicationResults;
//console.log(publicationResults); //console.log(publicationResults);
}); });
this._searchEntriesService.getResults(this.properties.searchAPIURLLAst+'datasets?fq=communityid%20exact%20%22'+this.communityId+'%22&sortBy=resultdateofacceptance,descending&format=json&size=5').subscribe( this._searchEntriesService.getResults(this.properties.searchAPIURLLAst+'datasets?fq=communityid%20exact%20%22'+this.communityId+'%22&sortBy=resultdateofacceptance,descending&format=json&size=5').subscribe(
researchDataResults => { researchDataResults => {
this.researchDataResults = researchDataResults; this.researchDataResults = researchDataResults;
}); });
this._searchEntriesService.getResults(this.properties.searchAPIURLLAst+'software?fq=communityid%20exact%20%22'+this.communityId+'%22&sortBy=resultdateofacceptance,descending&format=json&size=5').subscribe( this._searchEntriesService.getResults(this.properties.searchAPIURLLAst+'software?fq=communityid%20exact%20%22'+this.communityId+'%22&sortBy=resultdateofacceptance,descending&format=json&size=5').subscribe(
softwareResults => { softwareResults => {
this.softwareResults = softwareResults; this.softwareResults = softwareResults;
}); });
}
}); });
} }