[Connect]: Add check if isClient to getUserInfo
git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-connect-portal/trunk@57546 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
parent
624cf9b11b
commit
3b8776b00e
|
@ -22,11 +22,13 @@ import {UserManagementService} from "./openaireLibrary/services/user-management.
|
|||
<navbar *ngIf="properties && showMenu && !community && loginCheck" [portal]="properties.dashboard" [onlyTop]=false
|
||||
[userMenuItems]=userMenuItems [menuItems]=menuItems [user]="user"
|
||||
[showMenu]=showMenu [properties]="properties" [showHomeMenuItem]="true"></navbar>
|
||||
<navbar *ngIf="properties && showMenu && community && loginCheck" [portal]="properties.dashboard" [onlyTop]=false [communityId]="community.id"
|
||||
<navbar *ngIf="properties && showMenu && community && loginCheck" [portal]="properties.dashboard" [onlyTop]=false
|
||||
[communityId]="community.id"
|
||||
[userMenuItems]=userMenuItems [menuItems]=menuItems [user]="user"
|
||||
[community]=community [showMenu]=showMenu [properties]="properties" [enableSearch]="true"
|
||||
[showHomeMenuItem]="true"></navbar>
|
||||
<customization *ngIf="properties && community" [properties]="properties" [communityId]="community.id"></customization>
|
||||
<customization *ngIf="properties && community" [properties]="properties"
|
||||
[communityId]="community.id"></customization>
|
||||
<div class="custom-main-content">
|
||||
<main>
|
||||
<router-outlet></router-outlet>
|
||||
|
@ -85,34 +87,43 @@ export class AppComponent {
|
|||
this.propertiesService.loadEnvironment()
|
||||
.then(es => {
|
||||
this.properties = this.propertiesService.envSpecific;
|
||||
var communityId: string = "";
|
||||
this._communitiesService.updateCommunities(this.properties, this.properties.communitiesAPI);
|
||||
this.userManagementService.getUserInfo(this.properties.userInfoUrl).subscribe( user => {
|
||||
this.user = user;
|
||||
this.loginCheck = true;
|
||||
if (this.properties.environment == "development") {
|
||||
this.showMenu = false;
|
||||
this.route.queryParams.subscribe(params => {
|
||||
communityId = (params['communityId']) ? params['communityId'] : '';
|
||||
this.buildMenu(communityId);
|
||||
})
|
||||
} else {
|
||||
this.showMenu = false;
|
||||
communityId = ConnectHelper.getCommunityFromDomain(this.properties.domain);
|
||||
this.buildMenu(communityId);
|
||||
if (typeof document !== 'undefined') {
|
||||
try {
|
||||
this.isClient = true;
|
||||
} catch (e) {
|
||||
}
|
||||
if (typeof document !== 'undefined') {
|
||||
try {
|
||||
this.isClient = true;
|
||||
} catch (e) {
|
||||
}
|
||||
}
|
||||
}, error => {
|
||||
console.log("App couldn't fetch properties");
|
||||
console.log(error);
|
||||
}
|
||||
if(this.isClient) {
|
||||
this.userManagementService.getUserInfo(this.properties.userInfoUrl).subscribe(user => {
|
||||
this.user = user;
|
||||
this.init();
|
||||
});
|
||||
} else {
|
||||
this.user = null;
|
||||
this.init();
|
||||
}
|
||||
}, error => {
|
||||
console.log("App couldn't fetch properties");
|
||||
console.log(error);
|
||||
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
private init() {
|
||||
let communityId: string = "";
|
||||
this.loginCheck = true;
|
||||
if (this.properties.environment == "development") {
|
||||
this.showMenu = false;
|
||||
this.route.queryParams.subscribe(params => {
|
||||
communityId = (params['communityId']) ? params['communityId'] : '';
|
||||
this.buildMenu(communityId);
|
||||
})
|
||||
} else {
|
||||
this.showMenu = false;
|
||||
communityId = ConnectHelper.getCommunityFromDomain(this.properties.domain);
|
||||
this.buildMenu(communityId);
|
||||
}
|
||||
}
|
||||
|
||||
public buildMenu(communityId: string) {
|
||||
|
@ -170,13 +181,7 @@ export class AppComponent {
|
|||
|
||||
this.menuItems.push({
|
||||
rootItem: new MenuItem("deposit", "Deposit", "", "/participate/deposit/learn-how", false, [], ["/participate/deposit/learn-how"], this.properties.environment != "development" ? {} : {communityId: community.communityId}),
|
||||
items: [
|
||||
/*
|
||||
new MenuItem("","Zenodo Communities","","/participate/share-zenodo",false,[],["/participate/share-zenodo"],this.properties.environment!="development"?{}:{communityId:community.communityId}),
|
||||
new MenuItem("","Publications","","/participate/deposit-publications",false,["publication"],["/participate/deposit-publications"],this.properties.environment!="development"?{}:{communityId:community.communityId}),
|
||||
new MenuItem("","Research Data","","/participate/deposit-datasets",false,["dataset"],["/participate/deposit-datasets"],this.properties.environment!="development"?{}:{communityId:community.communityId})
|
||||
*/
|
||||
]
|
||||
items: []
|
||||
});
|
||||
this.menuItems.push(
|
||||
{
|
||||
|
@ -203,21 +208,6 @@ export class AppComponent {
|
|||
rootItem: new MenuItem("about", "About", "", "/about/learn-how", false, [], null, {}),
|
||||
items: []
|
||||
});
|
||||
var myCommunities = [];
|
||||
/*if(this.managerOfCommunities){
|
||||
myCommunities.push( new MenuItem("","Managing communities","","/search/find/communities",false,[],[],{role:"%22manager%22"}))
|
||||
}
|
||||
if(Session.isLoggedIn()){
|
||||
this._subscribeService.getCommunitiesSubscribedTo(this.properties, Session.getUserEmail()).subscribe (
|
||||
pids => {
|
||||
if(pids.length > 0 ) {
|
||||
myCommunities.push( new MenuItem("","Subscribed to communities","","/search/find/communities",false,[],[],{status:"%22subscribed%22"}))
|
||||
}
|
||||
},
|
||||
error => {
|
||||
console.error("Error fetching your subscribed communities")
|
||||
});
|
||||
}*/
|
||||
this.menuItems.push({
|
||||
rootItem: new MenuItem("communities", "Communities", "", "/search/find/communities", false, [], null, {}),
|
||||
items: []
|
||||
|
@ -226,52 +216,24 @@ export class AppComponent {
|
|||
rootItem: new MenuItem("join", "Join", "", "/contact-us", false, [], null, {}),
|
||||
items: []
|
||||
});
|
||||
/*if(this.managerOfCommunities || this.subscriberOfCommunities){
|
||||
let myCommunitiesMenu = new MenuItem("myCommunities","My Communities","","",false,[],[],{});
|
||||
myCommunitiesMenu.setMarkAsActive(false);
|
||||
this.menuItems.push({rootItem: myCommunitiesMenu, items: myCommunities});
|
||||
}*/
|
||||
|
||||
|
||||
this.bottomMenuItems = [
|
||||
new MenuItem("", "About", "https://beta.openaire.eu/project-factsheets", "", false, [], [], {}),
|
||||
new MenuItem("", "News - Events", "https://beta.openaire.eu/news-events", "", false, [], [], {}),
|
||||
new MenuItem("", "Blog", "https://blogs.openaire.eu/", "", false, [], [], {}),
|
||||
new MenuItem("", "Contact us", "https://beta.openaire.eu/contact-us", "", false, [], [], {})
|
||||
];
|
||||
// if(this.properties.showContent){
|
||||
// this.bottomMenuItems.push(new MenuItem("","Content Policy","","/content",false,[],[],{}));
|
||||
// }
|
||||
this.userMenuItems = [
|
||||
// new MenuItem("","My links","","/myclaims",false,[],["/myclaims"],(data['communityId'] && typeof document !== 'undefined' && ConnectHelper.isProduction(document.location.hostname))?{}:{communityId:data['communityId']}),
|
||||
];
|
||||
this.userMenuItems = [];
|
||||
if (Session.isPortalAdministrator(this.user)) {
|
||||
//((this.properties.environment == "beta") ? "https://beta.admin.connect.openaire.eu" : "https://admin.explore.openaire.eu") + "/dashboard?communityId=openaire"
|
||||
this.userMenuItems.push(new MenuItem("", "Manage Helptexts",
|
||||
((this.properties.environment == "production") ? "https://admin.explore.openaire.eu" : "https://beta.admin.connect.openaire.eu") + "/dashboard?communityId=connect",
|
||||
"", false, [], [], {}))
|
||||
}
|
||||
/*if(this.managerOfCommunities){
|
||||
this.userMenuItems.push( new MenuItem("","Managing communities","","/search/find/communities",false,[],[],{role:"%22manager%22"}))
|
||||
}
|
||||
if(Session.isLoggedIn()){
|
||||
this._subscribeService.getCommunitiesSubscribedTo(this.properties, Session.getUserEmail()).subscribe (
|
||||
pids => {
|
||||
if(pids.length > 0 ) {
|
||||
this.userMenuItems.push( new MenuItem("","Subscribed to communities","","/search/find/communities",false,[],[],{status:"%22subscribed%22"}))
|
||||
}
|
||||
},
|
||||
error => {
|
||||
console.error("Error fetching your subscribed communities")
|
||||
});
|
||||
}*/
|
||||
if (this.user) {
|
||||
this.userMenuItems.push(new MenuItem("my-communities", "My Communities", "",
|
||||
"/myCommunities", false, [], [], {}));
|
||||
}
|
||||
} else {
|
||||
this.bottomMenuItems = [
|
||||
// new MenuItem("","About","","/about",false,[],["/about"],this.properties.environment!="development"?{}:{communityId:community.communityId}),
|
||||
new MenuItem("", "Organizations", "", "/organizations", false, [], ["/organizations"], this.properties.environment != "development" ? {} : {communityId: community.communityId})
|
||||
];
|
||||
if (this.properties.showContent) {
|
||||
|
|
|
@ -123,10 +123,15 @@ 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'");
|
||||
this.userManagementService.getUserInfo(this.properties.userInfoUrl).subscribe( user => {
|
||||
this.user = user;
|
||||
if (typeof document !== 'undefined') {
|
||||
this.userManagementService.getUserInfo(this.properties.userInfoUrl).subscribe(user => {
|
||||
this.user = user;
|
||||
this.loginCheck = true;
|
||||
});
|
||||
} else {
|
||||
this.user = null;
|
||||
this.loginCheck = true;
|
||||
})
|
||||
}
|
||||
if (this.communityId != null && this.communityId != '') {
|
||||
this._communityService.getCommunity(this.properties, this.properties.communityAPI + this.communityId).subscribe(
|
||||
community => {
|
||||
|
|
|
@ -76,12 +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();
|
||||
}
|
||||
this.userManagementService.getUserInfo(this.properties.userInfoUrl).subscribe(user => {
|
||||
this.user = user;
|
||||
this.getCommunities();
|
||||
//this.getDivContents();
|
||||
//this.getPageContents();
|
||||
});
|
||||
if (typeof document !== 'undefined') {
|
||||
this.userManagementService.getUserInfo(this.properties.userInfoUrl).subscribe(user => {
|
||||
this.user = user;
|
||||
this.getCommunities();
|
||||
//this.getDivContents();
|
||||
//this.getPageContents();
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -81,10 +81,14 @@ export class SearchCommunitiesComponent {
|
|||
}
|
||||
this.searchPage.refineFields = this.refineFields;
|
||||
let queryParams = this.searchPage.getQueryParamsFromUrl(params);
|
||||
this.userManagementService.getUserInfo(this.properties.userInfoUrl).subscribe(user => {
|
||||
this.user = user;
|
||||
if(typeof document !== 'undefined') {
|
||||
this.userManagementService.getUserInfo(this.properties.userInfoUrl).subscribe(user => {
|
||||
this.user = user;
|
||||
this.initCommunities(queryParams);
|
||||
});
|
||||
} else {
|
||||
this.initCommunities(queryParams);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -95,57 +95,14 @@ export class InviteComponent implements OnInit {
|
|||
this.errorMessage = "";
|
||||
this.missingCommunityId = "";
|
||||
this.status = this.errorCodes.LOADING;
|
||||
this.userManageService.getUserInfo(this.properties.userInfoUrl).subscribe(user => {
|
||||
this.user = user;
|
||||
this.route.queryParams.subscribe(
|
||||
communityId => {
|
||||
//if(!this.communityId && typeof document !== 'undefined'){
|
||||
this.communityId = ConnectHelper.getCommunityFromDomain(this.properties.domain);
|
||||
if (!this.communityId) {
|
||||
this.communityId = communityId['communityId'];
|
||||
}
|
||||
|
||||
if (this.longView) {
|
||||
if (this.properties.enablePiwikTrack && (typeof document !== 'undefined')) {
|
||||
this.piwiksub = this._piwikService.trackView(this.properties, this.pageTitle, PiwikHelper.getSiteId(this.communityId, this.properties.environment)).subscribe();
|
||||
}
|
||||
this.url = this.properties.baseLink + this._router.url;
|
||||
this.seoService.createLinkForCanonicalURL(this.url);
|
||||
this.updateUrl(this.url);
|
||||
this.updateTitle(this.pageTitle);
|
||||
this.updateDescription("OpenAIRE - Connect, Community Gateway, research community, invite");
|
||||
}
|
||||
this.communityIdParam = (this.properties.environment != "development") ? {} : {communityId: this.communityId};
|
||||
if (this.communityId != null && this.communityId != '') {
|
||||
//this.getDivContents();
|
||||
this.getPageContents();
|
||||
this._communityService.getCommunity(this.properties, this.properties.communityAPI + this.communityId).subscribe(
|
||||
community => {
|
||||
this.community = community;
|
||||
this.fullname = this.user.fullname;
|
||||
//console.log("Fullname from session " + Session.getUserFullName());
|
||||
|
||||
this.body = Composer.initializeInvitationsBody(this.communityId, this.community.title, this.fullname);
|
||||
this.email = Composer.initializeInvitationsEmail(community.title);
|
||||
this.recipients = "";
|
||||
|
||||
this.status = this.errorCodes.DONE;
|
||||
},
|
||||
error => {
|
||||
//this.handleError(error)
|
||||
this.handleError("Error getting community with id: " + this.communityId, error);
|
||||
this.status = this.errorMessages.getErrorCode(error.status);
|
||||
}
|
||||
);
|
||||
} else {
|
||||
this.status = this.errorCodes.DONE;
|
||||
this.missingCommunityId = "There is no community selected!";
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
HelperFunctions.scroll();
|
||||
});
|
||||
if (typeof document !== 'undefined') {
|
||||
this.userManageService.getUserInfo(this.properties.userInfoUrl).subscribe(user => {
|
||||
this.user = user;
|
||||
this.init();
|
||||
});
|
||||
} else {
|
||||
this.init();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -155,6 +112,56 @@ export class InviteComponent implements OnInit {
|
|||
}
|
||||
}
|
||||
|
||||
private init() {
|
||||
this.route.queryParams.subscribe(
|
||||
communityId => {
|
||||
//if(!this.communityId && typeof document !== 'undefined'){
|
||||
this.communityId = ConnectHelper.getCommunityFromDomain(this.properties.domain);
|
||||
if (!this.communityId) {
|
||||
this.communityId = communityId['communityId'];
|
||||
}
|
||||
|
||||
if (this.longView) {
|
||||
if (this.properties.enablePiwikTrack && (typeof document !== 'undefined')) {
|
||||
this.piwiksub = this._piwikService.trackView(this.properties, this.pageTitle, PiwikHelper.getSiteId(this.communityId, this.properties.environment)).subscribe();
|
||||
}
|
||||
this.url = this.properties.baseLink + this._router.url;
|
||||
this.seoService.createLinkForCanonicalURL(this.url);
|
||||
this.updateUrl(this.url);
|
||||
this.updateTitle(this.pageTitle);
|
||||
this.updateDescription("OpenAIRE - Connect, Community Gateway, research community, invite");
|
||||
}
|
||||
this.communityIdParam = (this.properties.environment != "development") ? {} : {communityId: this.communityId};
|
||||
if (this.communityId != null && this.communityId != '') {
|
||||
//this.getDivContents();
|
||||
this.getPageContents();
|
||||
this._communityService.getCommunity(this.properties, this.properties.communityAPI + this.communityId).subscribe(
|
||||
community => {
|
||||
this.community = community;
|
||||
this.fullname = (this.user) ? this.user.fullname : null;
|
||||
//console.log("Fullname from session " + Session.getUserFullName());
|
||||
|
||||
this.body = Composer.initializeInvitationsBody(this.communityId, this.community.title, this.fullname);
|
||||
this.email = Composer.initializeInvitationsEmail(community.title);
|
||||
this.recipients = "";
|
||||
|
||||
this.status = this.errorCodes.DONE;
|
||||
},
|
||||
error => {
|
||||
//this.handleError(error)
|
||||
this.handleError("Error getting community with id: " + this.communityId, error);
|
||||
this.status = this.errorMessages.getErrorCode(error.status);
|
||||
}
|
||||
);
|
||||
} else {
|
||||
this.status = this.errorCodes.DONE;
|
||||
this.missingCommunityId = "There is no community selected!";
|
||||
}
|
||||
|
||||
});
|
||||
HelperFunctions.scroll();
|
||||
}
|
||||
|
||||
private getPageContents() {
|
||||
this.helper.getPageHelpContents(this._router.url, this.properties, this.communityId).subscribe(contents => {
|
||||
this.pageContents = contents;
|
||||
|
|
|
@ -69,56 +69,64 @@ export class SubscribeComponent {
|
|||
this.route.data
|
||||
.subscribe((data: { envSpecific: EnvProperties }) => {
|
||||
this.properties = data.envSpecific;
|
||||
this.userManagementService.getUserInfo(this.properties.userInfoUrl).subscribe( user => {
|
||||
this.user = user;
|
||||
if (!this.showNumbers) {
|
||||
let email = (this.user)?this.user.email:null;
|
||||
if (email == null) {
|
||||
this.subscribed = false;
|
||||
} else {
|
||||
if (this.communityId) {
|
||||
this._subscribeService.isSubscribedToCommunity(this.properties, this.communityId, email).subscribe(
|
||||
res => {
|
||||
this.subscribed = res;
|
||||
if (this.subscribed) {
|
||||
this.subscribeEvent.emit({
|
||||
value: "ok"
|
||||
});
|
||||
}
|
||||
},
|
||||
error => {
|
||||
this.handleError("Error getting response if email: " + email + " is subscribed to community with id: " + this.communityId, error);
|
||||
});
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (this.communityId) {
|
||||
this._subscribeService.getCommunitySubscribers(this.properties, this.communityId).subscribe(
|
||||
res => {
|
||||
this.subscribers = (res && res.subscribers && res.subscribers.length) ? res.subscribers.length : 0;
|
||||
},
|
||||
error => {
|
||||
this.handleError("Error getting community subscribers for community with id: " + this.communityId, error);
|
||||
});
|
||||
}
|
||||
}
|
||||
if (this.communityId) {
|
||||
this.emailToInformManagers = {body: "", subject: "", recipients: []};
|
||||
|
||||
this._communityService.getCommunity(this.properties, this.properties.communityAPI + this.communityId).subscribe(
|
||||
community => {
|
||||
this.community = community;
|
||||
},
|
||||
error => {
|
||||
//console.log('System error retrieving community profile', error)
|
||||
this.handleError("Error getting community with id: " + this.communityId, error);
|
||||
}
|
||||
);
|
||||
}
|
||||
});
|
||||
if (typeof document !== 'undefined') {
|
||||
this.userManagementService.getUserInfo(this.properties.userInfoUrl).subscribe(user => {
|
||||
this.user = user;
|
||||
this.init();
|
||||
});
|
||||
} else {
|
||||
this.init();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private init() {
|
||||
if (!this.showNumbers) {
|
||||
let email = (this.user)?this.user.email:null;
|
||||
if (email == null) {
|
||||
this.subscribed = false;
|
||||
} else {
|
||||
if (this.communityId) {
|
||||
this._subscribeService.isSubscribedToCommunity(this.properties, this.communityId, email).subscribe(
|
||||
res => {
|
||||
this.subscribed = res;
|
||||
if (this.subscribed) {
|
||||
this.subscribeEvent.emit({
|
||||
value: "ok"
|
||||
});
|
||||
}
|
||||
},
|
||||
error => {
|
||||
this.handleError("Error getting response if email: " + email + " is subscribed to community with id: " + this.communityId, error);
|
||||
});
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (this.communityId) {
|
||||
this._subscribeService.getCommunitySubscribers(this.properties, this.communityId).subscribe(
|
||||
res => {
|
||||
this.subscribers = (res && res.subscribers && res.subscribers.length) ? res.subscribers.length : 0;
|
||||
},
|
||||
error => {
|
||||
this.handleError("Error getting community subscribers for community with id: " + this.communityId, error);
|
||||
});
|
||||
}
|
||||
}
|
||||
if (this.communityId) {
|
||||
this.emailToInformManagers = {body: "", subject: "", recipients: []};
|
||||
|
||||
this._communityService.getCommunity(this.properties, this.properties.communityAPI + this.communityId).subscribe(
|
||||
community => {
|
||||
this.community = community;
|
||||
},
|
||||
error => {
|
||||
//console.log('System error retrieving community profile', error)
|
||||
this.handleError("Error getting community with id: " + this.communityId, error);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
subscribe() {
|
||||
var email = (this.user)?this.user.email:null;
|
||||
if (email == null) {
|
||||
|
|
Loading…
Reference in New Issue