[Connect]: Change user login check with user management service.
git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-connect-portal/trunk@57061 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
parent
ca08e72dcb
commit
3aaaf93625
|
@ -5,10 +5,11 @@ import {EnvProperties} from './openaireLibrary/utils/properties/env-properties';
|
||||||
import {MenuItem, RootMenuItem} from './openaireLibrary/sharedComponents/menu';
|
import {MenuItem, RootMenuItem} from './openaireLibrary/sharedComponents/menu';
|
||||||
import {EnvironmentSpecificService} from './openaireLibrary/utils/properties/environment-specific.service';
|
import {EnvironmentSpecificService} from './openaireLibrary/utils/properties/environment-specific.service';
|
||||||
import {CommunitiesService} from "./openaireLibrary/connect/communities/communities.service";
|
import {CommunitiesService} from "./openaireLibrary/connect/communities/communities.service";
|
||||||
import {Session} from './openaireLibrary/login/utils/helper.class';
|
import {Session, User} from './openaireLibrary/login/utils/helper.class';
|
||||||
import {ConnectHelper} from './openaireLibrary/connect/connectHelper';
|
import {ConnectHelper} from './openaireLibrary/connect/connectHelper';
|
||||||
import {SubscribeService} from './openaireLibrary/utils/subscribe/subscribe.service';
|
import {SubscribeService} from './openaireLibrary/utils/subscribe/subscribe.service';
|
||||||
import {HelperFunctions} from "./openaireLibrary/utils/HelperFunctions.class";
|
import {HelperFunctions} from "./openaireLibrary/utils/HelperFunctions.class";
|
||||||
|
import {UserManagementService} from "./openaireLibrary/services/user-management.service";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
//changeDetection: ChangeDetectionStrategy.Default,
|
//changeDetection: ChangeDetectionStrategy.Default,
|
||||||
|
@ -18,11 +19,11 @@ import {HelperFunctions} from "./openaireLibrary/utils/HelperFunctions.class";
|
||||||
`],
|
`],
|
||||||
template: `
|
template: `
|
||||||
<div [class]="(community)?(community.id +'App'):'connectApp'">
|
<div [class]="(community)?(community.id +'App'):'connectApp'">
|
||||||
<navbar *ngIf="properties && showMenu && !community" portal="connect" [onlyTop]=false
|
<navbar *ngIf="properties && showMenu && !community && loginCheck" portal="connect" [onlyTop]=false
|
||||||
[userMenuItems]=userMenuItems [menuItems]=menuItems
|
[userMenuItems]=userMenuItems [menuItems]=menuItems [user]="user"
|
||||||
[showMenu]=showMenu [properties]="properties" [showHomeMenuItem]="true"></navbar>
|
[showMenu]=showMenu [properties]="properties" [showHomeMenuItem]="true"></navbar>
|
||||||
<navbar *ngIf="properties && showMenu && community" portal="connect" [onlyTop]=false [communityId]="community.id"
|
<navbar *ngIf="properties && showMenu && community && loginCheck" portal="connect" [onlyTop]=false [communityId]="community.id"
|
||||||
[userMenuItems]=userMenuItems [menuItems]=menuItems
|
[userMenuItems]=userMenuItems [menuItems]=menuItems [user]="user"
|
||||||
[community]=community [showMenu]=showMenu [properties]="properties" [enableSearch]="true"
|
[community]=community [showMenu]=showMenu [properties]="properties" [enableSearch]="true"
|
||||||
[showHomeMenuItem]="true"></navbar>
|
[showHomeMenuItem]="true"></navbar>
|
||||||
<customization *ngIf="properties && community"></customization>
|
<customization *ngIf="properties && community"></customization>
|
||||||
|
@ -66,11 +67,13 @@ export class AppComponent {
|
||||||
communities = null;
|
communities = null;
|
||||||
subscriberOfCommunities = false;
|
subscriberOfCommunities = false;
|
||||||
managerOfCommunities = false;
|
managerOfCommunities = false;
|
||||||
|
user: User;
|
||||||
|
loginCheck: boolean = false;
|
||||||
|
|
||||||
// community: {id:string, name:string, logoUrl:string};
|
// community: {id:string, name:string, logoUrl:string};
|
||||||
constructor(private route: ActivatedRoute, private propertiesService: EnvironmentSpecificService,
|
constructor(private route: ActivatedRoute, private propertiesService: EnvironmentSpecificService,
|
||||||
private _communitiesService: CommunitiesService, private _subscribeService: SubscribeService,
|
private _communitiesService: CommunitiesService, private _subscribeService: SubscribeService,
|
||||||
private router: Router) {
|
private router: Router, private userManagementService: UserManagementService) {
|
||||||
router.events.forEach((event) => {
|
router.events.forEach((event) => {
|
||||||
if (event instanceof NavigationStart) {
|
if (event instanceof NavigationStart) {
|
||||||
HelperFunctions.scroll();
|
HelperFunctions.scroll();
|
||||||
|
@ -84,28 +87,32 @@ export class AppComponent {
|
||||||
this.properties = this.propertiesService.envSpecific;
|
this.properties = this.propertiesService.envSpecific;
|
||||||
var communityId: string = "";
|
var communityId: string = "";
|
||||||
this._communitiesService.updateCommunities(this.properties, this.properties.communitiesAPI);
|
this._communitiesService.updateCommunities(this.properties, this.properties.communitiesAPI);
|
||||||
if (this.properties.environment == "development") {
|
this.userManagementService.getUserInfo(this.properties.userInfoUrl).subscribe( user => {
|
||||||
this.showMenu = false;
|
this.user = user;
|
||||||
this.route.queryParams.subscribe(params => {
|
this.loginCheck = true;
|
||||||
communityId = (params['communityId']) ? params['communityId'] : '';
|
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);
|
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') {
|
||||||
}, error => {
|
try {
|
||||||
console.log("App couldn't fetch properties");
|
this.isClient = true;
|
||||||
console.log(error);
|
} catch (e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, error => {
|
||||||
|
console.log("App couldn't fetch properties");
|
||||||
|
console.log(error);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public buildMenu(communityId: string) {
|
public buildMenu(communityId: string) {
|
||||||
|
@ -125,10 +132,10 @@ export class AppComponent {
|
||||||
this.managerOfCommunities && this.subscriberOfCommunities)) {
|
this.managerOfCommunities && this.subscriberOfCommunities)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (Session.isLoggedIn() && com['status'] != "hidden") {
|
if (this.user && com['status'] != "hidden") {
|
||||||
if (Session.isCommunityCurator() || Session.isPortalAdministrator()) {
|
if (Session.isCommunityCurator(this.user) || Session.isPortalAdministrator(this.user)) {
|
||||||
this.managerOfCommunities = true;
|
this.managerOfCommunities = true;
|
||||||
} else if (com.managers.indexOf(Session.getUserEmail()) != -1) {
|
} else if (com.managers.indexOf(this.user.email) != -1) {
|
||||||
this.managerOfCommunities = true;
|
this.managerOfCommunities = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -137,9 +144,9 @@ export class AppComponent {
|
||||||
if (communityId && communityId != "" && com.communityId == communityId) {
|
if (communityId && communityId != "" && com.communityId == communityId) {
|
||||||
community = com;
|
community = com;
|
||||||
let isCommunityManager: boolean = false;
|
let isCommunityManager: boolean = false;
|
||||||
if (Session.isCommunityCurator() || Session.isPortalAdministrator()) {
|
if (Session.isCommunityCurator(this.user) || Session.isPortalAdministrator(this.user)) {
|
||||||
isCommunityManager = true;
|
isCommunityManager = true;
|
||||||
} else if (com.managers.indexOf(Session.getUserEmail()) != -1) {
|
} else if (com.managers.indexOf(this.user.email) != -1) {
|
||||||
isCommunityManager = true;
|
isCommunityManager = true;
|
||||||
}
|
}
|
||||||
this.community = {
|
this.community = {
|
||||||
|
@ -238,7 +245,7 @@ export class AppComponent {
|
||||||
this.userMenuItems = [
|
this.userMenuItems = [
|
||||||
// new MenuItem("","My links","","/myclaims",false,[],["/myclaims"],(data['communityId'] && typeof document !== 'undefined' && ConnectHelper.isProduction(document.location.hostname))?{}:{communityId:data['communityId']}),
|
// new MenuItem("","My links","","/myclaims",false,[],["/myclaims"],(data['communityId'] && typeof document !== 'undefined' && ConnectHelper.isProduction(document.location.hostname))?{}:{communityId:data['communityId']}),
|
||||||
];
|
];
|
||||||
if (Session.isPortalAdministrator()) {
|
if (Session.isPortalAdministrator(this.user)) {
|
||||||
//((this.properties.environment == "beta") ? "https://beta.admin.connect.openaire.eu" : "https://admin.explore.openaire.eu") + "/dashboard?communityId=openaire"
|
//((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.userMenuItems.push(new MenuItem("", "Manage Helptexts",
|
||||||
((this.properties.environment == "production") ? "https://admin.explore.openaire.eu" : "https://beta.admin.connect.openaire.eu") + "/dashboard?communityId=connect",
|
((this.properties.environment == "production") ? "https://admin.explore.openaire.eu" : "https://beta.admin.connect.openaire.eu") + "/dashboard?communityId=connect",
|
||||||
|
@ -258,7 +265,7 @@ export class AppComponent {
|
||||||
console.error("Error fetching your subscribed communities")
|
console.error("Error fetching your subscribed communities")
|
||||||
});
|
});
|
||||||
}*/
|
}*/
|
||||||
if (Session.isLoggedIn()) {
|
if (this.user) {
|
||||||
this.userMenuItems.push(new MenuItem("my-communities", "My Communities", "",
|
this.userMenuItems.push(new MenuItem("my-communities", "My Communities", "",
|
||||||
"/myCommunities", false, [], [], {}));
|
"/myCommunities", false, [], [], {}));
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,12 +8,13 @@ import {PiwikHelper} from "../../utils/piwikHelper";
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'openaire-my-claims',
|
selector: 'openaire-my-claims',
|
||||||
template: `
|
template: `
|
||||||
<my-claims [claimsInfoURL]=claimsInfoURL [communityId]=communityId [piwikSiteId]="piwikSiteId"></my-claims>
|
<my-claims [claimsInfoURL]=claimsInfoURL [userInfoURL]="userInfoURL" [communityId]=communityId [piwikSiteId]="piwikSiteId"></my-claims>
|
||||||
`
|
`
|
||||||
|
|
||||||
})
|
})
|
||||||
export class OpenaireMyClaimsComponent {
|
export class OpenaireMyClaimsComponent {
|
||||||
claimsInfoURL:string;
|
claimsInfoURL:string;
|
||||||
|
userInfoURL: string;
|
||||||
communityId:string;
|
communityId:string;
|
||||||
public piwikSiteId = null;
|
public piwikSiteId = null;
|
||||||
|
|
||||||
|
@ -23,6 +24,7 @@ import {PiwikHelper} from "../../utils/piwikHelper";
|
||||||
this.route.data
|
this.route.data
|
||||||
.subscribe((data: { envSpecific: EnvProperties }) => {
|
.subscribe((data: { envSpecific: EnvProperties }) => {
|
||||||
this.claimsInfoURL = data.envSpecific.claimsInformationLink;
|
this.claimsInfoURL = data.envSpecific.claimsInformationLink;
|
||||||
|
this.userInfoURL = data.envSpecific.userInfoUrl;
|
||||||
this.route.queryParams.subscribe(
|
this.route.queryParams.subscribe(
|
||||||
communityId => {
|
communityId => {
|
||||||
this.communityId = ConnectHelper.getCommunityFromDomain(data.envSpecific.domain);
|
this.communityId = ConnectHelper.getCommunityFromDomain(data.envSpecific.domain);
|
||||||
|
|
|
@ -9,7 +9,7 @@ import {ConfigurationService} from '../openaireLibrary/utils/configuration/confi
|
||||||
import {PiwikService} from '../openaireLibrary/utils/piwik/piwik.service';
|
import {PiwikService} from '../openaireLibrary/utils/piwik/piwik.service';
|
||||||
import {SearchZenodoCommunitiesService} from '../openaireLibrary/connect/zenodoCommunities/searchZenodoCommunities.service';
|
import {SearchZenodoCommunitiesService} from '../openaireLibrary/connect/zenodoCommunities/searchZenodoCommunities.service';
|
||||||
import {ZenodoCommunitiesService} from '../openaireLibrary/connect/zenodoCommunities/zenodo-communities.service';
|
import {ZenodoCommunitiesService} from '../openaireLibrary/connect/zenodoCommunities/zenodo-communities.service';
|
||||||
import {Session} from '../openaireLibrary/login/utils/helper.class';
|
import {Session, User} from '../openaireLibrary/login/utils/helper.class';
|
||||||
import {StatisticsForDashboardComponent} from '../statistics/statistics.component';
|
import {StatisticsForDashboardComponent} from '../statistics/statistics.component';
|
||||||
import {StringUtils} from '../openaireLibrary/utils/string-utils.class';
|
import {StringUtils} from '../openaireLibrary/utils/string-utils.class';
|
||||||
|
|
||||||
|
@ -20,6 +20,7 @@ import {SearchCommunityProjectsService} from "../openaireLibrary/connect/project
|
||||||
import {SearchResearchResultsService} from "../openaireLibrary/services/searchResearchResults.service";
|
import {SearchResearchResultsService} from "../openaireLibrary/services/searchResearchResults.service";
|
||||||
import {RouterHelper} from "../openaireLibrary/utils/routerHelper.class";
|
import {RouterHelper} from "../openaireLibrary/utils/routerHelper.class";
|
||||||
import {SEOService} from "../openaireLibrary/sharedComponents/SEO/SEO.service";
|
import {SEOService} from "../openaireLibrary/sharedComponents/SEO/SEO.service";
|
||||||
|
import {UserManagementService} from "../openaireLibrary/services/user-management.service";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'community',
|
selector: 'community',
|
||||||
|
@ -77,6 +78,8 @@ export class CommunityComponent {
|
||||||
searchLinkToAdvancedPublications: string = null;
|
searchLinkToAdvancedPublications: string = null;
|
||||||
shareInZenodoPage: string = null;
|
shareInZenodoPage: string = null;
|
||||||
public routerHelper:RouterHelper = new RouterHelper();
|
public routerHelper:RouterHelper = new RouterHelper();
|
||||||
|
private user: User;
|
||||||
|
private loginCheck: boolean = false;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private element: ElementRef,
|
private element: ElementRef,
|
||||||
|
@ -93,7 +96,8 @@ export class CommunityComponent {
|
||||||
private _searchResearchResultsService: SearchResearchResultsService,
|
private _searchResearchResultsService: SearchResearchResultsService,
|
||||||
private _searchZenodoCommunitiesService: SearchZenodoCommunitiesService,
|
private _searchZenodoCommunitiesService: SearchZenodoCommunitiesService,
|
||||||
private _ΖenodoCommunitieService: ZenodoCommunitiesService,
|
private _ΖenodoCommunitieService: ZenodoCommunitiesService,
|
||||||
private seoService: SEOService) {
|
private seoService: SEOService,
|
||||||
|
private userManagementService: UserManagementService) {
|
||||||
|
|
||||||
var description = "OpenAIRE - Connect, Community Dashboard, research community";
|
var description = "OpenAIRE - Connect, Community Dashboard, research community";
|
||||||
var title = "OpenAIRE - Connect";
|
var title = "OpenAIRE - Connect";
|
||||||
|
@ -119,7 +123,10 @@ export class CommunityComponent {
|
||||||
this.url = data.envSpecific.baseLink + this._router.url;
|
this.url = data.envSpecific.baseLink + this._router.url;
|
||||||
this.seoService.createLinkForCanonicalURL(this.url, false);
|
this.seoService.createLinkForCanonicalURL(this.url, false);
|
||||||
this._meta.updateTag({content: this.url}, "property='og:url'");
|
this._meta.updateTag({content: this.url}, "property='og:url'");
|
||||||
|
this.userManagementService.getUserInfo(this.properties.userInfoUrl).subscribe( user => {
|
||||||
|
this.user = user;
|
||||||
|
this.loginCheck = true;
|
||||||
|
})
|
||||||
if (this.communityId != null && this.communityId != '') {
|
if (this.communityId != null && this.communityId != '') {
|
||||||
this._communityService.getCommunity(this.properties, this.properties.communityAPI + this.communityId).subscribe(
|
this._communityService.getCommunity(this.properties, this.properties.communityAPI + this.communityId).subscribe(
|
||||||
community => {
|
community => {
|
||||||
|
@ -327,19 +334,19 @@ export class CommunityComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
showInvite() {
|
showInvite() {
|
||||||
|
return this.loginCheck && this.isManager();
|
||||||
|
|
||||||
return this.isManager();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
isManager() {
|
isManager() {
|
||||||
var email = Session.getUserEmail();
|
if(!this.user) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
var email = this.user.email;
|
||||||
var index = -1;
|
var index = -1;
|
||||||
if (email && this.community != null && this.community.managers != null) {
|
if (email && this.community != null && this.community.managers != null) {
|
||||||
index = this.community.managers.indexOf(email);
|
index = this.community.managers.indexOf(email);
|
||||||
}
|
}
|
||||||
|
return Session.isPortalAdministrator(this.user) || Session.isCommunityCurator(this.user) || index != -1;
|
||||||
return Session.isPortalAdministrator() || Session.isCommunityCurator() || index != -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private handleError(message: string, error) {
|
private handleError(message: string, error) {
|
||||||
|
|
|
@ -11,6 +11,7 @@ import {Session} from '../openaireLibrary/login/utils/helper.class';
|
||||||
import {EnvProperties} from '../openaireLibrary/utils/properties/env-properties';
|
import {EnvProperties} from '../openaireLibrary/utils/properties/env-properties';
|
||||||
import {SubscribeComponent} from '../utils/subscribe/subscribe.component';
|
import {SubscribeComponent} from '../utils/subscribe/subscribe.component';
|
||||||
import {ConnectHelper} from '../openaireLibrary/connect/connectHelper';
|
import {ConnectHelper} from '../openaireLibrary/connect/connectHelper';
|
||||||
|
import {UserManagementService} from "../openaireLibrary/services/user-management.service";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'openaire-user',
|
selector: 'openaire-user',
|
||||||
|
@ -53,14 +54,17 @@ export class OpenaireUserComponent {
|
||||||
public server: boolean = true;
|
public server: boolean = true;
|
||||||
loggedIn:boolean = false;
|
loggedIn:boolean = false;
|
||||||
constructor(private _subscribeService: SubscribeService,
|
constructor(private _subscribeService: SubscribeService,
|
||||||
private _emailService: EmailService, private route: ActivatedRoute){}
|
private _emailService: EmailService, private route: ActivatedRoute,
|
||||||
|
private userManagementService: UserManagementService){}
|
||||||
public ngOnInit() {
|
public ngOnInit() {
|
||||||
if( typeof document !== 'undefined') {
|
|
||||||
this.server = false;
|
|
||||||
this.loggedIn = Session.isLoggedIn();
|
|
||||||
}
|
|
||||||
this.route.data
|
this.route.data
|
||||||
.subscribe((data: { envSpecific: any }) => {
|
.subscribe((data: { envSpecific: any }) => {
|
||||||
|
this.userManagementService.isLoggedIn(data.envSpecific.userInfoUrl).subscribe( isLoggedIn => {
|
||||||
|
if( typeof document !== 'undefined') {
|
||||||
|
this.server = false;
|
||||||
|
this.loggedIn = isLoggedIn;
|
||||||
|
}
|
||||||
|
});
|
||||||
this.route.queryParams.subscribe(
|
this.route.queryParams.subscribe(
|
||||||
communityId => {
|
communityId => {
|
||||||
this.communityId = ConnectHelper.getCommunityFromDomain(data.envSpecific.domain);
|
this.communityId = ConnectHelper.getCommunityFromDomain(data.envSpecific.domain);
|
||||||
|
|
|
@ -7,13 +7,14 @@ import {SubscribeService} from '../openaireLibrary/utils/subscribe/subscribe.ser
|
||||||
import {CommunityInfo} from '../openaireLibrary/connect/community/communityInfo';
|
import {CommunityInfo} from '../openaireLibrary/connect/community/communityInfo';
|
||||||
|
|
||||||
import {PiwikService} from '../openaireLibrary/utils/piwik/piwik.service';
|
import {PiwikService} from '../openaireLibrary/utils/piwik/piwik.service';
|
||||||
import {Session} from '../openaireLibrary/login/utils/helper.class';
|
import {Session, User} from '../openaireLibrary/login/utils/helper.class';
|
||||||
import {StringUtils} from '../openaireLibrary/utils/string-utils.class';
|
import {StringUtils} from '../openaireLibrary/utils/string-utils.class';
|
||||||
|
|
||||||
import {ErrorCodes} from '../openaireLibrary/utils/properties/errorCodes';
|
import {ErrorCodes} from '../openaireLibrary/utils/properties/errorCodes';
|
||||||
import {ErrorMessagesComponent} from '../openaireLibrary/utils/errorMessages.component';
|
import {ErrorMessagesComponent} from '../openaireLibrary/utils/errorMessages.component';
|
||||||
import {HelperService} from "../openaireLibrary/utils/helper/helper.service";
|
import {HelperService} from "../openaireLibrary/utils/helper/helper.service";
|
||||||
import {SEOService} from "../openaireLibrary/sharedComponents/SEO/SEO.service";
|
import {SEOService} from "../openaireLibrary/sharedComponents/SEO/SEO.service";
|
||||||
|
import {UserManagementService} from "../openaireLibrary/services/user-management.service";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'my-communities',
|
selector: 'my-communities',
|
||||||
|
@ -37,6 +38,7 @@ export class MyCommunitiesComponent {
|
||||||
private errorMessages: ErrorMessagesComponent;
|
private errorMessages: ErrorMessagesComponent;
|
||||||
|
|
||||||
properties: EnvProperties;
|
properties: EnvProperties;
|
||||||
|
private user: User;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private route: ActivatedRoute,
|
private route: ActivatedRoute,
|
||||||
|
@ -47,7 +49,8 @@ export class MyCommunitiesComponent {
|
||||||
private _communitiesService: CommunitiesService,
|
private _communitiesService: CommunitiesService,
|
||||||
private _subscribeService: SubscribeService,
|
private _subscribeService: SubscribeService,
|
||||||
private helper: HelperService,
|
private helper: HelperService,
|
||||||
private seoService: SEOService) {
|
private seoService: SEOService,
|
||||||
|
private userManagementService: UserManagementService) {
|
||||||
|
|
||||||
var description = "OpenAIRE - Connect, Community Dashboard, research community " +
|
var description = "OpenAIRE - Connect, Community Dashboard, research community " +
|
||||||
"| My managing and subscribed to Communities";
|
"| My managing and subscribed to Communities";
|
||||||
|
@ -73,9 +76,12 @@ export class MyCommunitiesComponent {
|
||||||
if (this.properties.enablePiwikTrack && (typeof document !== 'undefined')) {
|
if (this.properties.enablePiwikTrack && (typeof document !== 'undefined')) {
|
||||||
this.piwiksub = this._piwikService.trackView(this.properties, "OpenAIRE Connect", this.properties.piwikSiteId).subscribe();
|
this.piwiksub = this._piwikService.trackView(this.properties, "OpenAIRE Connect", this.properties.piwikSiteId).subscribe();
|
||||||
}
|
}
|
||||||
this.getCommunities();
|
this.userManagementService.getUserInfo(this.properties.userInfoUrl).subscribe(user => {
|
||||||
//this.getDivContents();
|
this.user = user;
|
||||||
//this.getPageContents();
|
this.getCommunities();
|
||||||
|
//this.getDivContents();
|
||||||
|
//this.getPageContents();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,7 +118,7 @@ export class MyCommunitiesComponent {
|
||||||
this.sort(communitiesResults);
|
this.sort(communitiesResults);
|
||||||
|
|
||||||
var subscribedLoading = communitiesResults.length;
|
var subscribedLoading = communitiesResults.length;
|
||||||
var mail = Session.getUserEmail();
|
var mail = this.user.email;
|
||||||
communitiesResults.forEach((community, index) => {
|
communitiesResults.forEach((community, index) => {
|
||||||
let showCommunity: boolean = true;
|
let showCommunity: boolean = true;
|
||||||
let isManager: boolean = false;
|
let isManager: boolean = false;
|
||||||
|
@ -123,7 +129,7 @@ export class MyCommunitiesComponent {
|
||||||
} else {
|
} else {
|
||||||
if (mail == null && community['status'] == "manager") { // no user
|
if (mail == null && community['status'] == "manager") { // no user
|
||||||
showCommunity = false;
|
showCommunity = false;
|
||||||
} else if (Session.isCommunityCurator() || Session.isPortalAdministrator()) {
|
} else if (Session.isCommunityCurator(this.user) || Session.isPortalAdministrator(this.user)) {
|
||||||
isManager = true;
|
isManager = true;
|
||||||
} else if (community.managers.indexOf(mail) != -1) {
|
} else if (community.managers.indexOf(mail) != -1) {
|
||||||
isManager = true;
|
isManager = true;
|
||||||
|
|
|
@ -8,11 +8,13 @@ import {ActivatedRoute} from "@angular/router";
|
||||||
import {Filter, Value} from "../../openaireLibrary/searchPages/searchUtils/searchHelperClasses.class";
|
import {Filter, Value} from "../../openaireLibrary/searchPages/searchUtils/searchHelperClasses.class";
|
||||||
import {SearchFields} from "../../openaireLibrary/utils/properties/searchFields";
|
import {SearchFields} from "../../openaireLibrary/utils/properties/searchFields";
|
||||||
import {CommunitiesService} from "../../openaireLibrary/connect/communities/communities.service";
|
import {CommunitiesService} from "../../openaireLibrary/connect/communities/communities.service";
|
||||||
import {Session} from "../../openaireLibrary/login/utils/helper.class";
|
import {Session, User} from "../../openaireLibrary/login/utils/helper.class";
|
||||||
import {CommunityInfo} from "../../openaireLibrary/connect/community/communityInfo";
|
import {CommunityInfo} from "../../openaireLibrary/connect/community/communityInfo";
|
||||||
import {SubscribeService} from "../../openaireLibrary/utils/subscribe/subscribe.service";
|
import {SubscribeService} from "../../openaireLibrary/utils/subscribe/subscribe.service";
|
||||||
import {StringUtils} from "../../openaireLibrary/utils/string-utils.class";
|
import {StringUtils} from "../../openaireLibrary/utils/string-utils.class";
|
||||||
import {HelperFunctions} from "../../openaireLibrary/utils/HelperFunctions.class";
|
import {HelperFunctions} from "../../openaireLibrary/utils/HelperFunctions.class";
|
||||||
|
import {UserManagementService} from "../../openaireLibrary/services/user-management.service";
|
||||||
|
import {url} from "inspector";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'search-communities',
|
selector: 'search-communities',
|
||||||
|
@ -46,10 +48,12 @@ export class SearchCommunitiesComponent {
|
||||||
public showType = false;
|
public showType = false;
|
||||||
properties:EnvProperties;
|
properties:EnvProperties;
|
||||||
@ViewChild (SearchPageComponent) searchPage : SearchPageComponent ;
|
@ViewChild (SearchPageComponent) searchPage : SearchPageComponent ;
|
||||||
|
private user: User;
|
||||||
|
|
||||||
constructor (private route: ActivatedRoute,
|
constructor (private route: ActivatedRoute,
|
||||||
private _communitiesService: CommunitiesService,
|
private _communitiesService: CommunitiesService,
|
||||||
private _subscribeService: SubscribeService) {
|
private _subscribeService: SubscribeService,
|
||||||
|
private userManagementService: UserManagementService) {
|
||||||
this.errorCodes = new ErrorCodes();
|
this.errorCodes = new ErrorCodes();
|
||||||
this.errorMessages = new ErrorMessagesComponent();
|
this.errorMessages = new ErrorMessagesComponent();
|
||||||
this.searchUtils.status = this.errorCodes.LOADING;
|
this.searchUtils.status = this.errorCodes.LOADING;
|
||||||
|
@ -77,8 +81,10 @@ export class SearchCommunitiesComponent {
|
||||||
}
|
}
|
||||||
this.searchPage.refineFields = this.refineFields;
|
this.searchPage.refineFields = this.refineFields;
|
||||||
let queryParams = this.searchPage.getQueryParamsFromUrl(params);
|
let queryParams = this.searchPage.getQueryParamsFromUrl(params);
|
||||||
|
this.userManagementService.getUserInfo(this.properties.userInfoUrl).subscribe(user => {
|
||||||
this.initCommunities(queryParams);
|
this.user = user;
|
||||||
|
this.initCommunities(queryParams);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,12 +112,12 @@ export class SearchCommunitiesComponent {
|
||||||
this.totalResults[i] = data[i];
|
this.totalResults[i] = data[i];
|
||||||
this.totalResults[i].isManager = false;
|
this.totalResults[i].isManager = false;
|
||||||
this.totalResults[i].isSubscribed = false;
|
this.totalResults[i].isSubscribed = false;
|
||||||
if(Session.isLoggedIn()) {
|
if(this.user) {
|
||||||
this.totalResults[i].isManager = this.isCommunityManager(this.totalResults[i]);
|
this.totalResults[i].isManager = this.isCommunityManager(this.totalResults[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(Session.isLoggedIn()) {
|
if(this.user) {
|
||||||
this._subscribeService.getCommunitiesSubscribedTo(this.properties, Session.getUserEmail()).subscribe(
|
this._subscribeService.getCommunitiesSubscribedTo(this.properties, this.user.email).subscribe(
|
||||||
res => {
|
res => {
|
||||||
for (let i = 0; i < this.totalResults.length; i++) {
|
for (let i = 0; i < this.totalResults.length; i++) {
|
||||||
this.totalResults[i].isSubscribed = (res.indexOf(this.totalResults[i].communityId) != -1);
|
this.totalResults[i].isSubscribed = (res.indexOf(this.totalResults[i].communityId) != -1);
|
||||||
|
@ -161,10 +167,10 @@ export class SearchCommunitiesComponent {
|
||||||
if (result.status == 'hidden') {
|
if (result.status == 'hidden') {
|
||||||
continue;
|
continue;
|
||||||
} else if (result.status == "manager") {
|
} else if (result.status == "manager") {
|
||||||
let mail = Session.getUserEmail();
|
let mail = this.user.email;
|
||||||
if (mail == null) { // no user
|
if (mail == null) { // no user
|
||||||
continue;
|
continue;
|
||||||
} else if (Session.isCommunityCurator() || Session.isPortalAdministrator()) {
|
} else if (Session.isCommunityCurator(this.user) || Session.isPortalAdministrator(this.user)) {
|
||||||
ret.push(result);
|
ret.push(result);
|
||||||
} else if (result.managers.indexOf(mail) != -1) {
|
} else if (result.managers.indexOf(mail) != -1) {
|
||||||
ret.push(result);
|
ret.push(result);
|
||||||
|
@ -244,7 +250,7 @@ export class SearchCommunitiesComponent {
|
||||||
let typeResults: CommunityInfo[] = this.applyFilter('type', params);
|
let typeResults: CommunityInfo[] = this.applyFilter('type', params);
|
||||||
let statusResults: CommunityInfo[] = this.results;
|
let statusResults: CommunityInfo[] = this.results;
|
||||||
let roleResults: CommunityInfo[] = this.results;
|
let roleResults: CommunityInfo[] = this.results;
|
||||||
if(Session.isLoggedIn()) {
|
if(this.user) {
|
||||||
statusResults = this.applyFilter('status', params);
|
statusResults = this.applyFilter('status', params);
|
||||||
roleResults = this.applyFilter('role', params);
|
roleResults = this.applyFilter('role', params);
|
||||||
this.resetFilterNumbers('status');
|
this.resetFilterNumbers('status');
|
||||||
|
@ -425,7 +431,7 @@ export class SearchCommunitiesComponent {
|
||||||
|
|
||||||
|
|
||||||
private isCommunityManager(community: CommunityInfo): boolean {
|
private isCommunityManager(community: CommunityInfo): boolean {
|
||||||
return Session.isCommunityCurator() || community.managers.indexOf(Session.getUserEmail()) != -1;
|
return Session.isCommunityCurator(this.user) || community.managers.indexOf(this.user.email) != -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -448,7 +454,7 @@ export class SearchCommunitiesComponent {
|
||||||
} else {
|
} else {
|
||||||
filter_original_ids = searchFields.COMMUNITIES_SEARCH_FIELDS.splice(0, 1);
|
filter_original_ids = searchFields.COMMUNITIES_SEARCH_FIELDS.splice(0, 1);
|
||||||
}
|
}
|
||||||
if(Session.isLoggedIn()) {
|
if(this.user) {
|
||||||
filter_names.push("Status");
|
filter_names.push("Status");
|
||||||
filter_ids.push("status");
|
filter_ids.push("status");
|
||||||
value_names.push([ "Subscribed", "Non-subscribed"]);
|
value_names.push([ "Subscribed", "Non-subscribed"]);
|
||||||
|
|
|
@ -14,13 +14,14 @@ import {EmailService} from '../../../openaireLibrary/utils/email/email.service';
|
||||||
import {CommunityService} from "../../../openaireLibrary/connect/community/community.service";
|
import {CommunityService} from "../../../openaireLibrary/connect/community/community.service";
|
||||||
import {ErrorCodes} from '../../../openaireLibrary/utils/properties/errorCodes';
|
import {ErrorCodes} from '../../../openaireLibrary/utils/properties/errorCodes';
|
||||||
import {ErrorMessagesComponent} from '../../../openaireLibrary/utils/errorMessages.component';
|
import {ErrorMessagesComponent} from '../../../openaireLibrary/utils/errorMessages.component';
|
||||||
import {Session} from '../../../openaireLibrary/login/utils/helper.class';
|
import {Session, User} from '../../../openaireLibrary/login/utils/helper.class';
|
||||||
import {HelperFunctions} from "../../../openaireLibrary/utils/HelperFunctions.class";
|
import {HelperFunctions} from "../../../openaireLibrary/utils/HelperFunctions.class";
|
||||||
import {HelperService} from "../../../openaireLibrary/utils/helper/helper.service";
|
import {HelperService} from "../../../openaireLibrary/utils/helper/helper.service";
|
||||||
import {Meta, Title} from "@angular/platform-browser";
|
import {Meta, Title} from "@angular/platform-browser";
|
||||||
import {SEOService} from "../../../openaireLibrary/sharedComponents/SEO/SEO.service";
|
import {SEOService} from "../../../openaireLibrary/sharedComponents/SEO/SEO.service";
|
||||||
import {PiwikService} from "../../../openaireLibrary/utils/piwik/piwik.service";
|
import {PiwikService} from "../../../openaireLibrary/utils/piwik/piwik.service";
|
||||||
import {PiwikHelper} from "../../piwikHelper";
|
import {PiwikHelper} from "../../piwikHelper";
|
||||||
|
import {UserManagementService} from "../../../openaireLibrary/services/user-management.service";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'invite',
|
selector: 'invite',
|
||||||
|
@ -68,6 +69,7 @@ export class InviteComponent implements OnInit {
|
||||||
public url: string = null;
|
public url: string = null;
|
||||||
public pageTitle: string = "Invite";
|
public pageTitle: string = "Invite";
|
||||||
piwiksub: any;
|
piwiksub: any;
|
||||||
|
private user: User;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private route: ActivatedRoute,
|
private route: ActivatedRoute,
|
||||||
|
@ -79,7 +81,8 @@ export class InviteComponent implements OnInit {
|
||||||
private _meta: Meta,
|
private _meta: Meta,
|
||||||
private _title: Title,
|
private _title: Title,
|
||||||
private seoService: SEOService,
|
private seoService: SEOService,
|
||||||
private _piwikService: PiwikService) {
|
private _piwikService: PiwikService,
|
||||||
|
private userManageService: UserManagementService) {
|
||||||
|
|
||||||
this.errorCodes = new ErrorCodes();
|
this.errorCodes = new ErrorCodes();
|
||||||
this.errorMessages = new ErrorMessagesComponent();
|
this.errorMessages = new ErrorMessagesComponent();
|
||||||
|
@ -92,59 +95,62 @@ export class InviteComponent implements OnInit {
|
||||||
this.errorMessage = "";
|
this.errorMessage = "";
|
||||||
this.missingCommunityId = "";
|
this.missingCommunityId = "";
|
||||||
this.status = this.errorCodes.LOADING;
|
this.status = this.errorCodes.LOADING;
|
||||||
this.route.queryParams.subscribe(
|
this.userManageService.getUserInfo(this.properties.userInfoUrl).subscribe(user => {
|
||||||
communityId => {
|
this.user = user;
|
||||||
//if(!this.communityId && typeof document !== 'undefined'){
|
this.route.queryParams.subscribe(
|
||||||
this.communityId = ConnectHelper.getCommunityFromDomain(this.properties.domain);
|
communityId => {
|
||||||
if (!this.communityId) {
|
//if(!this.communityId && typeof document !== 'undefined'){
|
||||||
this.communityId = communityId['communityId'];
|
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 = Session.getUserFullName();
|
|
||||||
//console.log("Fullname from session " + Session.getUserFullName());
|
|
||||||
|
|
||||||
this.body = Composer.initializeInvitationsBody(this.communityId, this.community.title, this.fullname);
|
if (this.longView) {
|
||||||
this.email = Composer.initializeInvitationsEmail(community.title);
|
if (this.properties.enablePiwikTrack && (typeof document !== 'undefined')) {
|
||||||
this.recipients = "";
|
this.piwiksub = this._piwikService.trackView(this.properties, this.pageTitle, PiwikHelper.getSiteId(this.communityId, this.properties.environment)).subscribe();
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
);
|
this.url = this.properties.baseLink + this._router.url;
|
||||||
} else {
|
this.seoService.createLinkForCanonicalURL(this.url);
|
||||||
this.status = this.errorCodes.DONE;
|
this.updateUrl(this.url);
|
||||||
this.missingCommunityId = "There is no community selected!";
|
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 = "";
|
||||||
|
|
||||||
HelperFunctions.scroll();
|
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();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnDestroy() {
|
ngOnDestroy() {
|
||||||
if(this.piwiksub) {
|
if (this.piwiksub) {
|
||||||
this.piwiksub.unsubscribe();
|
this.piwiksub.unsubscribe();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -277,15 +283,15 @@ export class InviteComponent implements OnInit {
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
allowEdit() {
|
allowEdit() {
|
||||||
var email = Session.getUserEmail();
|
if (!this.user) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
var email = this.user.email;
|
||||||
var index = -1;
|
var index = -1;
|
||||||
if (email && this.community != null && this.community.managers != null) {
|
if (email && this.community != null && this.community.managers != null) {
|
||||||
index = this.community.managers.indexOf(email);
|
index = this.community.managers.indexOf(email);
|
||||||
}
|
}
|
||||||
|
return Session.isPortalAdministrator(this.user) || Session.isCommunityCurator(this.user) || index != -1;
|
||||||
return Session.isPortalAdministrator() || Session.isCommunityCurator() || index != -1;
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private handleError(message: string, error) {
|
private handleError(message: string, error) {
|
||||||
|
|
|
@ -6,221 +6,236 @@ import {AlertModal} from '../../openaireLibrary/utils/modal/alert';
|
||||||
import {CommunityService} from '../../openaireLibrary/connect/community/community.service';
|
import {CommunityService} from '../../openaireLibrary/connect/community/community.service';
|
||||||
import {SubscribeService} from '../../openaireLibrary/utils/subscribe/subscribe.service';
|
import {SubscribeService} from '../../openaireLibrary/utils/subscribe/subscribe.service';
|
||||||
import {EmailService} from "../../openaireLibrary/utils/email/email.service";
|
import {EmailService} from "../../openaireLibrary/utils/email/email.service";
|
||||||
import {Session} from '../../openaireLibrary/login/utils/helper.class';
|
import {Session, User} from '../../openaireLibrary/login/utils/helper.class';
|
||||||
|
|
||||||
import {Email} from "../../openaireLibrary/utils/email/email";
|
import {Email} from "../../openaireLibrary/utils/email/email";
|
||||||
import {Composer} from "../../openaireLibrary/utils/email/composer";
|
import {Composer} from "../../openaireLibrary/utils/email/composer";
|
||||||
import {LoginErrorCodes} from '../../openaireLibrary/login/utils/guardHelper.class';
|
import {LoginErrorCodes} from '../../openaireLibrary/login/utils/guardHelper.class';
|
||||||
|
import {UserManagementService} from "../../openaireLibrary/services/user-management.service";
|
||||||
|
|
||||||
declare var UIkit: any;
|
declare var UIkit: any;
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'subscribe',
|
selector: 'subscribe',
|
||||||
template: `
|
template: `
|
||||||
|
|
||||||
<span *ngIf="subscribed != null && !showNumbers && showTemplate">
|
<span *ngIf="subscribed != null && !showNumbers && showTemplate">
|
||||||
<div *ngIf="!subscribed && showLoginAlert" class="uk-alert-warning uk-animation-slide-bottom" uk-alert="" >
|
<div *ngIf="!subscribed && showLoginAlert" class="uk-alert-warning uk-animation-slide-bottom" uk-alert="">
|
||||||
<a class="uk-alert-close" uk-close></a>
|
<a class="uk-alert-close" uk-close></a>
|
||||||
<p>Please login first to subscribe</p>
|
<p>Please login first to subscribe</p>
|
||||||
</div>
|
</div>
|
||||||
<button *ngIf="!subscribed" [class]="'uk-button uk-button-primary' + (loading ? ' uk-disabled' : '')" (click)="subscribe()"> Subscribe</button>
|
<button *ngIf="!subscribed" [class]="'uk-button uk-button-primary' + (loading ? ' uk-disabled' : '')"
|
||||||
<button *ngIf="subscribed" [class]="'uk-button uk-button-primary' + (loading ? ' uk-disabled' : '')" (click)="confirmOpen()"> Unsubscribe</button>
|
(click)="subscribe()"> Subscribe</button>
|
||||||
|
<button *ngIf="subscribed" [class]="'uk-button uk-button-primary' + (loading ? ' uk-disabled' : '')"
|
||||||
|
(click)="confirmOpen()"> Unsubscribe</button>
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
<span *ngIf="showNumbers && subscribers !=null && subscribers > 0 && showTemplate" >
|
<span *ngIf="showNumbers && subscribers !=null && subscribers > 0 && showTemplate">
|
||||||
<span class="lowOpacityColor"> Members</span> {{subscribers}}
|
<span class="lowOpacityColor"> Members</span> {{subscribers}}
|
||||||
</span>
|
</span>
|
||||||
<modal-alert (alertOutput)="confirmClose($event)">
|
<modal-alert (alertOutput)="confirmClose($event)">
|
||||||
</modal-alert>
|
</modal-alert>
|
||||||
`
|
`
|
||||||
})
|
})
|
||||||
|
|
||||||
export class SubscribeComponent {
|
export class SubscribeComponent {
|
||||||
// @Input() showSubscribe:boolean = true;
|
// @Input() showSubscribe:boolean = true;
|
||||||
@Input() showNumbers:boolean;
|
@Input() showNumbers: boolean;
|
||||||
@Input() communityId:string;
|
@Input() communityId: string;
|
||||||
@Input() showTemplate:boolean = true;
|
@Input() showTemplate: boolean = true;
|
||||||
@Output() subscribeEvent = new EventEmitter();
|
@Output() subscribeEvent = new EventEmitter();
|
||||||
|
|
||||||
public community = null;
|
public community = null;
|
||||||
public emailToInformManagers: Email;
|
public emailToInformManagers: Email;
|
||||||
|
|
||||||
loading: boolean = false;
|
loading: boolean = false;
|
||||||
subscribed:boolean = null;
|
subscribed: boolean = null;
|
||||||
properties:EnvProperties;
|
properties: EnvProperties;
|
||||||
subscribers:number= null;
|
subscribers: number = null;
|
||||||
showLoginAlert:Boolean = false;
|
showLoginAlert: Boolean = false;
|
||||||
@ViewChild(AlertModal) alert;
|
@ViewChild(AlertModal) alert;
|
||||||
constructor (private route: ActivatedRoute,
|
private user: User;
|
||||||
private _subscribeService: SubscribeService,
|
|
||||||
private _emailService: EmailService,
|
|
||||||
private _communityService: CommunityService, private router: Router
|
|
||||||
) {
|
|
||||||
}
|
|
||||||
|
|
||||||
public ngOnInit() {
|
constructor(private route: ActivatedRoute,
|
||||||
this.route.data
|
private _subscribeService: SubscribeService,
|
||||||
.subscribe((data: { envSpecific: EnvProperties }) => {
|
private _emailService: EmailService,
|
||||||
this.properties = data.envSpecific;
|
private _communityService: CommunityService,
|
||||||
if(!this.showNumbers){
|
private router: Router,
|
||||||
let email = Session.getUserEmail();
|
private userManagementService: UserManagementService
|
||||||
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 (
|
public ngOnInit() {
|
||||||
community => {
|
this.route.data
|
||||||
this.community = community;
|
.subscribe((data: { envSpecific: EnvProperties }) => {
|
||||||
},
|
this.properties = data.envSpecific;
|
||||||
error => {
|
this.userManagementService.getUserInfo(this.properties.userInfoUrl).subscribe( user => {
|
||||||
//console.log('System error retrieving community profile', error)
|
this.user = user;
|
||||||
this.handleError("Error getting community with id: "+this.communityId, error);
|
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;
|
||||||
subscribe(){
|
if (this.subscribed) {
|
||||||
var email = Session.getUserEmail();
|
this.subscribeEvent.emit({
|
||||||
if(email == null){
|
value: "ok"
|
||||||
this.subscribed = false;
|
});
|
||||||
// this.showLoginAlert = true;
|
}
|
||||||
this.router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.ACTION_REQUIRES_LOGIN, "redirectUrl": this.router.url } });
|
},
|
||||||
}else{
|
error => {
|
||||||
this.loading = true;
|
this.handleError("Error getting response if email: " + email + " is subscribed to community with id: " + this.communityId, error);
|
||||||
this.showLoginAlert = false;
|
});
|
||||||
this._subscribeService.subscribeToCommunity(this.communityId, email, this.properties.adminToolsAPIURL).subscribe (
|
}
|
||||||
res => {
|
|
||||||
this.loading = false;
|
|
||||||
if(res.status && res.status != 200) {
|
|
||||||
this.subscribeEvent.emit({
|
|
||||||
value: "error"
|
|
||||||
});
|
|
||||||
UIkit.notification({
|
|
||||||
message : '<strong>An error occured. Please try again!<strong>',
|
|
||||||
status : 'warning',
|
|
||||||
timeout : 3000,
|
|
||||||
pos : 'top-center'
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
if(!this.subscribed){
|
|
||||||
this.subscribed = true;
|
|
||||||
this.subscribeEvent.emit({
|
|
||||||
value: "ok"
|
|
||||||
});
|
|
||||||
this._emailService.sendEmail(this.properties.adminToolsAPIURL + "/notifyForNewSubscribers/" + this.communityId, Composer.composeEmailToInformManagers(this.community.title, this.communityId, this.community.managers, email)).subscribe(
|
|
||||||
res => {
|
|
||||||
//console.log("The email has been sent successfully!")
|
|
||||||
},
|
|
||||||
error => {
|
|
||||||
//console.log(error)
|
|
||||||
this.handleError("Error notifying managers about new subscribers for community with id: "+this.communityId, error);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
} else {
|
||||||
error => {
|
if (this.communityId) {
|
||||||
this.loading = false;
|
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) {
|
||||||
|
this.subscribed = false;
|
||||||
|
// this.showLoginAlert = true;
|
||||||
|
this.router.navigate(['/user-info'], {
|
||||||
|
queryParams: {
|
||||||
|
"errorCode": LoginErrorCodes.ACTION_REQUIRES_LOGIN,
|
||||||
|
"redirectUrl": this.router.url
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
this.loading = true;
|
||||||
|
this.showLoginAlert = false;
|
||||||
|
this._subscribeService.subscribeToCommunity(this.communityId, email, this.properties.adminToolsAPIURL).subscribe(
|
||||||
|
res => {
|
||||||
|
this.loading = false;
|
||||||
|
if (res.status && res.status != 200) {
|
||||||
this.subscribeEvent.emit({
|
this.subscribeEvent.emit({
|
||||||
value: "error"
|
value: "error"
|
||||||
});
|
});
|
||||||
UIkit.notification({
|
UIkit.notification({
|
||||||
message : '<strong>An error occured. Please try again!<strong>',
|
message: '<strong>An error occured. Please try again!<strong>',
|
||||||
status : 'warning',
|
status: 'warning',
|
||||||
timeout : 3000,
|
timeout: 3000,
|
||||||
pos : 'top-center'
|
pos: 'top-center'
|
||||||
});
|
});
|
||||||
//console.log(error)
|
} else {
|
||||||
this.handleError("Error subscribing email: "+email+" to community with id: "+this.communityId, error);
|
if (!this.subscribed) {
|
||||||
});
|
this.subscribed = true;
|
||||||
}
|
this.subscribeEvent.emit({
|
||||||
}
|
value: "ok"
|
||||||
|
|
||||||
unsubscribe(){
|
|
||||||
var email = Session.getUserEmail();
|
|
||||||
if(email == null){
|
|
||||||
this.subscribed = false;
|
|
||||||
}else{
|
|
||||||
this.loading = true;
|
|
||||||
//this.properties.adminToolsAPIURL
|
|
||||||
this._subscribeService.unSubscribeToCommunity(this.communityId, email,this.properties.adminToolsAPIURL).subscribe (
|
|
||||||
res => {
|
|
||||||
this.loading = false;
|
|
||||||
if(res.status && res.status != 200) {
|
|
||||||
UIkit.notification({
|
|
||||||
message : '<strong>An error occured. Please try again!<strong>',
|
|
||||||
status : 'warning',
|
|
||||||
timeout : 3000,
|
|
||||||
pos : 'top-center'
|
|
||||||
});
|
});
|
||||||
} else {
|
this._emailService.sendEmail(this.properties.adminToolsAPIURL + "/notifyForNewSubscribers/" + this.communityId, Composer.composeEmailToInformManagers(this.community.title, this.communityId, this.community.managers, email)).subscribe(
|
||||||
//console.log(res);
|
res => {
|
||||||
if(this.subscribed){
|
//console.log("The email has been sent successfully!")
|
||||||
this.subscribed = false;
|
},
|
||||||
}
|
error => {
|
||||||
}
|
//console.log(error)
|
||||||
},
|
this.handleError("Error notifying managers about new subscribers for community with id: " + this.communityId, error);
|
||||||
error => {
|
}
|
||||||
this.loading = false;
|
);
|
||||||
UIkit.notification({
|
}
|
||||||
message : '<strong>An error occured. Please try again!<strong>',
|
}
|
||||||
status : 'warning',
|
},
|
||||||
timeout : 3000,
|
error => {
|
||||||
pos : 'top-center'
|
this.loading = false;
|
||||||
});
|
this.subscribeEvent.emit({
|
||||||
//console.log(error)
|
value: "error"
|
||||||
this.handleError("Error unsubscribing email: "+email+" from community with id: "+this.communityId, error);
|
|
||||||
});
|
});
|
||||||
}
|
UIkit.notification({
|
||||||
|
message: '<strong>An error occured. Please try again!<strong>',
|
||||||
|
status: 'warning',
|
||||||
|
timeout: 3000,
|
||||||
|
pos: 'top-center'
|
||||||
|
});
|
||||||
|
//console.log(error)
|
||||||
|
this.handleError("Error subscribing email: " + email + " to community with id: " + this.communityId, error);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
confirmOpen(){
|
unsubscribe() {
|
||||||
|
var email = (this.user)?this.user.email:null;
|
||||||
|
if (email == null) {
|
||||||
|
this.subscribed = false;
|
||||||
|
} else {
|
||||||
|
this.loading = true;
|
||||||
|
//this.properties.adminToolsAPIURL
|
||||||
|
this._subscribeService.unSubscribeToCommunity(this.communityId, email, this.properties.adminToolsAPIURL).subscribe(
|
||||||
|
res => {
|
||||||
|
this.loading = false;
|
||||||
|
if (res.status && res.status != 200) {
|
||||||
|
UIkit.notification({
|
||||||
|
message: '<strong>An error occured. Please try again!<strong>',
|
||||||
|
status: 'warning',
|
||||||
|
timeout: 3000,
|
||||||
|
pos: 'top-center'
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
//console.log(res);
|
||||||
|
if (this.subscribed) {
|
||||||
|
console.log('here')
|
||||||
|
this.subscribed = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
this.loading = false;
|
||||||
|
UIkit.notification({
|
||||||
|
message: '<strong>An error occured. Please try again!<strong>',
|
||||||
|
status: 'warning',
|
||||||
|
timeout: 3000,
|
||||||
|
pos: 'top-center'
|
||||||
|
});
|
||||||
|
//console.log(error)
|
||||||
|
this.handleError("Error unsubscribing email: " + email + " from community with id: " + this.communityId, error);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
this.alert.cancelButton = true;
|
confirmOpen() {
|
||||||
this.alert.okButton = true;
|
|
||||||
this.alert.alertTitle = "Unsubscribe community ";
|
|
||||||
this.alert.message = "Do you want to proceed? ";
|
|
||||||
this.alert.okButtonText = "Yes";
|
|
||||||
this.alert.cancelButtonText = "No";
|
|
||||||
this.alert.open();
|
|
||||||
}
|
|
||||||
confirmClose(data){
|
|
||||||
this.unsubscribe();
|
|
||||||
}
|
|
||||||
|
|
||||||
private handleError(message: string, error) {
|
this.alert.cancelButton = true;
|
||||||
console.error("Subscribe (component): "+message, error);
|
this.alert.okButton = true;
|
||||||
}
|
this.alert.alertTitle = "Unsubscribe community ";
|
||||||
|
this.alert.message = "Do you want to proceed? ";
|
||||||
|
this.alert.okButtonText = "Yes";
|
||||||
|
this.alert.cancelButtonText = "No";
|
||||||
|
this.alert.open();
|
||||||
|
}
|
||||||
|
|
||||||
|
confirmClose(data) {
|
||||||
|
this.unsubscribe();
|
||||||
|
}
|
||||||
|
|
||||||
|
private handleError(message: string, error) {
|
||||||
|
console.error("Subscribe (component): " + message, error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,9 @@
|
||||||
|
|
||||||
"piwikBaseUrl" :"https://analytics.openaire.eu/piwik.php?idsite=",
|
"piwikBaseUrl" :"https://analytics.openaire.eu/piwik.php?idsite=",
|
||||||
"piwikSiteId" : "80",
|
"piwikSiteId" : "80",
|
||||||
"loginUrl" :"http://scoobydoo.di.uoa.gr:8080/dnet-openaire-users-1.0.0-SNAPSHOT/openid_connect_login",
|
"loginUrl" :"http://rudie.di.uoa.gr:8280/dnet-login/openid_connect_login",
|
||||||
|
|
||||||
|
"userInfoUrl" : "http://rudie.di.uoa.gr:8280/dnet-openaire-users-1.0.0-SNAPSHOT/api/users/getUserInfo?accessToken=",
|
||||||
|
|
||||||
"logoutUrl" :"https://aai.openaire.eu/proxy/saml2/idp/SingleLogoutService.php?ReturnTo=",
|
"logoutUrl" :"https://aai.openaire.eu/proxy/saml2/idp/SingleLogoutService.php?ReturnTo=",
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue