[Connect]: Revert check if is Client. Added on UserInfo method.

git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-connect-portal/trunk@57548 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
k.triantafyllou 2019-11-08 12:08:15 +00:00
parent 3b8776b00e
commit 771ab82c7b
5 changed files with 75 additions and 90 deletions

View File

@ -94,15 +94,11 @@ export class AppComponent {
} catch (e) {
}
}
if(this.isClient) {
this.userManagementService.getUserInfo(this.properties.userInfoUrl).subscribe(user => {
this.user = user;
this.init();
});
} else {
this.user = null;
this.userManagementService.getUserInfo(this.properties.userInfoUrl).subscribe(user => {
this.user = user;
this.init();
}
});
this.init();
}, error => {
console.log("App couldn't fetch properties");
console.log(error);

View File

@ -77,7 +77,7 @@ export class CommunityComponent {
searchLinkToDataProviders: string = null;
searchLinkToAdvancedPublications: string = null;
shareInZenodoPage: string = null;
public routerHelper:RouterHelper = new RouterHelper();
public routerHelper: RouterHelper = new RouterHelper();
private user: User;
private loginCheck: boolean = false;
@ -91,7 +91,7 @@ export class CommunityComponent {
private _piwikService: PiwikService,
private config: ConfigurationService,
private _communityService: CommunityService,
private _searchCommunityDataprovidersService:SearchCommunityDataprovidersService,
private _searchCommunityDataprovidersService: SearchCommunityDataprovidersService,
private _searchCommunityProjectsService: SearchCommunityProjectsService,
private _searchResearchResultsService: SearchResearchResultsService,
private _searchZenodoCommunitiesService: SearchZenodoCommunitiesService,
@ -123,15 +123,10 @@ export class CommunityComponent {
this.url = data.envSpecific.baseLink + this._router.url;
this.seoService.createLinkForCanonicalURL(this.url, false);
this._meta.updateTag({content: this.url}, "property='og:url'");
if (typeof document !== 'undefined') {
this.userManagementService.getUserInfo(this.properties.userInfoUrl).subscribe(user => {
this.user = user;
this.loginCheck = true;
});
} else {
this.user = null;
this.userManagementService.getUserInfo(this.properties.userInfoUrl).subscribe(user => {
this.user = user;
this.loginCheck = true;
}
});
if (this.communityId != null && this.communityId != '') {
this._communityService.getCommunity(this.properties, this.properties.communityAPI + this.communityId).subscribe(
community => {
@ -147,7 +142,7 @@ export class CommunityComponent {
this._meta.updateTag({content: community.title}, "property='og:title'");
this._title.setTitle(community.title);
if (this.properties.enablePiwikTrack && (typeof document !== 'undefined')) {
this.piwiksub = this._piwikService.trackView(this.properties, community.title, PiwikHelper.getSiteId(this.communityId,this.properties.environment)).subscribe();
this.piwiksub = this._piwikService.trackView(this.properties, community.title, PiwikHelper.getSiteId(this.communityId, this.properties.environment)).subscribe();
}
if (this.community.zenodoCommunity) {
this._ΖenodoCommunitieService.getZenodoCommunityById(this.properties, this.properties.zenodoCommunities + this.community.zenodoCommunity, null).subscribe(
@ -181,29 +176,29 @@ export class CommunityComponent {
//console.log(community);
});
this.countResearchResults("publication");
this.countResearchResults("dataset");
this.countResearchResults("software");
this.countResearchResults("other");
this.countResearchResults("publication");
this.countResearchResults("dataset");
this.countResearchResults("software");
this.countResearchResults("other");
this._searchCommunityProjectsService.countTotalProjects(this.properties, this.communityId ).subscribe(
projectTotal => {
this.projectTotal = projectTotal;
//console.log(projectTotal);
},
error => {
this.handleError("Error getting number of projects for community with id: " + this.communityId, error);
}
);
this._searchCommunityProjectsService.countTotalProjects(this.properties, this.communityId).subscribe(
projectTotal => {
this.projectTotal = projectTotal;
//console.log(projectTotal);
},
error => {
this.handleError("Error getting number of projects for community with id: " + this.communityId, error);
}
);
this._searchCommunityDataprovidersService.countTotalDataproviders(this.properties, this.communityId ).subscribe(
contentProviderTotal => {
this.contentProviderTotal = contentProviderTotal;
//console.log(contentProviderTotal);
},
error => {
this.handleError("Error getting number of content providers for community with id: " + this.communityId, error);
}
this._searchCommunityDataprovidersService.countTotalDataproviders(this.properties, this.communityId).subscribe(
contentProviderTotal => {
this.contentProviderTotal = contentProviderTotal;
//console.log(contentProviderTotal);
},
error => {
this.handleError("Error getting number of content providers for community with id: " + this.communityId, error);
}
);
// this._searchEntriesService.countTotal(this.properties.communityAPI+this.communityId+'/organizations').subscribe(
@ -228,15 +223,15 @@ export class CommunityComponent {
}
public countResearchResults(resultType: string) {
this._searchResearchResultsService.countTotalResults(resultType, this.properties,"&fq=communityid=" + this.communityId).subscribe(
this._searchResearchResultsService.countTotalResults(resultType, this.properties, "&fq=communityid=" + this.communityId).subscribe(
researchResultsTotal => {
this.setTotal(resultType, researchResultsTotal);
if(resultType == "publication") {
if (resultType == "publication") {
this.searchResearchResults(resultType, this.publicationTotal, this.publicationResults);
}
},
error => {
this.handleError("Error getting number of "+this.getEntityName(resultType, true, true)+" for community with id: " + this.communityId, error);
this.handleError("Error getting number of " + this.getEntityName(resultType, true, true) + " for community with id: " + this.communityId, error);
}
);
}
@ -253,7 +248,7 @@ export class CommunityComponent {
this.showLoading = false;
},
error => {
this.handleError("Error getting "+this.getEntityName(resultType, true, true)+" for community with id: " + this.communityId, error);
this.handleError("Error getting " + this.getEntityName(resultType, true, true) + " for community with id: " + this.communityId, error);
}
);
}
@ -278,7 +273,7 @@ export class CommunityComponent {
}
isManager() {
if(!this.user) {
if (!this.user) {
return false;
}
var email = this.user.email;
@ -327,7 +322,7 @@ export class CommunityComponent {
}
private setActiveTab(entityType: string) {
if(entityType == "other") {
if (entityType == "other") {
this.activeTab = "orp";
} else {
this.activeTab = entityType;
@ -335,37 +330,37 @@ export class CommunityComponent {
}
private setResults(entityType: string, results: Array<any>) {
if(entityType == "publication") {
if (entityType == "publication") {
this.publicationResults = results;
} else if(entityType == "dataset") {
} else if (entityType == "dataset") {
this.researchDataResults = results;
} else if(entityType == "software") {
} else if (entityType == "software") {
this.softwareResults = results;
} else if(entityType == "other") {
} else if (entityType == "other") {
this.orpResults = results;
}
}
private setTotal(entityType: string, total: number) {
if(entityType == "publication") {
if (entityType == "publication") {
this.publicationTotal = total;
} else if(entityType == "dataset") {
} else if (entityType == "dataset") {
this.researchDataTotal = total;
} else if(entityType == "software") {
} else if (entityType == "software") {
this.softwareTotal = total;
} else if(entityType == "other") {
} else if (entityType == "other") {
this.orpTotal = total;
}
}
private getEntityName (entityType:string, plural:boolean, full:boolean): string {
if(entityType == "publication") {
private getEntityName(entityType: string, plural: boolean, full: boolean): string {
if (entityType == "publication") {
return "publication" + (plural ? "s" : "");
} else if(entityType == "dataset") {
} else if (entityType == "dataset") {
return (full ? "research data" : ("dataset" + (plural ? "s" : "")));
} else if(entityType == "software") {
} else if (entityType == "software") {
return "software";
} else if(entityType == "other") {
} else if (entityType == "other") {
return (full ? ("other research product" + (plural ? "s" : "")) : "other");
}
}

View File

@ -76,14 +76,14 @@ export class MyCommunitiesComponent {
if (this.properties.enablePiwikTrack && (typeof document !== 'undefined')) {
this.piwiksub = this._piwikService.trackView(this.properties, "OpenAIRE Connect", this.properties.piwikSiteId).subscribe();
}
if (typeof document !== 'undefined') {
this.userManagementService.getUserInfo(this.properties.userInfoUrl).subscribe(user => {
this.user = user;
this.userManagementService.getUserInfo(this.properties.userInfoUrl).subscribe(user => {
this.user = user;
if(this.user) {
this.getCommunities();
//this.getDivContents();
//this.getPageContents();
});
}
}
//this.getDivContents();
//this.getPageContents();
});
});
}
@ -110,13 +110,14 @@ export class MyCommunitiesComponent {
this._communitiesService.getCommunitiesState().subscribe(
communitiesResults => {
if(!communitiesResults){
if (!communitiesResults) {
return;
}
if(communitiesResults.length == 0) {
if (communitiesResults.length == 0) {
this.status = this.errorCodes.DONE;
return;
};
}
;
this.sort(communitiesResults);
var subscribedLoading = communitiesResults.length;

View File

@ -95,14 +95,11 @@ export class InviteComponent implements OnInit {
this.errorMessage = "";
this.missingCommunityId = "";
this.status = this.errorCodes.LOADING;
if (typeof document !== 'undefined') {
this.userManageService.getUserInfo(this.properties.userInfoUrl).subscribe(user => {
this.user = user;
this.init();
});
} else {
this.userManageService.getUserInfo(this.properties.userInfoUrl).subscribe(user => {
this.user = user;
this.init();
}
});
this.init();
});
}

View File

@ -66,23 +66,19 @@ export class SubscribeComponent {
}
public ngOnInit() {
this.route.data
.subscribe((data: { envSpecific: EnvProperties }) => {
this.properties = data.envSpecific;
if (typeof document !== 'undefined') {
this.userManagementService.getUserInfo(this.properties.userInfoUrl).subscribe(user => {
this.user = user;
this.init();
});
} else {
this.init();
}
this.route.data.subscribe((data: { envSpecific: EnvProperties }) => {
this.properties = data.envSpecific;
this.userManagementService.getUserInfo(this.properties.userInfoUrl).subscribe(user => {
this.user = user;
this.init();
});
});
this.init();
}
private init() {
if (!this.showNumbers) {
let email = (this.user)?this.user.email:null;
let email = (this.user) ? this.user.email : null;
if (email == null) {
this.subscribed = false;
} else {
@ -128,7 +124,7 @@ export class SubscribeComponent {
}
subscribe() {
var email = (this.user)?this.user.email:null;
var email = (this.user) ? this.user.email : null;
if (email == null) {
this.subscribed = false;
// this.showLoginAlert = true;
@ -190,7 +186,7 @@ export class SubscribeComponent {
}
unsubscribe() {
var email = (this.user)?this.user.email:null;
var email = (this.user) ? this.user.email : null;
if (email == null) {
this.subscribed = false;
} else {