[Admin]: Change check of user info from user management.

git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-admin-portal/trunk@57073 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
k.triantafyllou 2019-09-13 09:39:18 +00:00
parent 07b827f6e9
commit 0b46787551
9 changed files with 637 additions and 600 deletions

View File

@ -1,10 +1,10 @@
<navbar *ngIf= "properties && showMenu" portal="connect-admin" logoPath="assets/imgs/" [onlyTop]=false [userMenu]=true <navbar *ngIf= "properties && showMenu && checkLogin" portal="connect-admin" logoPath="assets/imgs/" [onlyTop]=false [userMenu]=true
[homeurl] = false [userMenuItems]=userMenuItems [menuItems]=menuItems [properties]=properties [homeurl] = false [user]="user" [userMenuItems]=userMenuItems [menuItems]=menuItems [properties]=properties
[community]=community class="adminMenu"></navbar> [community]=community class="adminMenu"></navbar>
<div id="wrapper" class="uk-section uk-padding-remove"> <div id="wrapper" class="uk-section uk-padding-remove">
<div class="uk-grid-collapse" uk-height-viewport="expand: true" uk-grid> <div class="uk-grid-collapse" uk-height-viewport="expand: true" uk-grid>
<sidebar *ngIf="showSidebar" [menuItems]="sideMenuItems" class="uk-width-1-5 uk-light sidebar "></sidebar> <sidebar *ngIf="showSidebar && checkLogin" [menuItems]="sideMenuItems" class="uk-width-1-5 uk-light sidebar "></sidebar>
<div class="uk-width-expand uk-overflow-auto" [ngClass]="(!wellcome)?'uk-container uk-container-large uk-padding':''" <div class="uk-width-expand uk-overflow-auto" [ngClass]="(!wellcome)?'uk-container uk-container-large uk-padding':''"
[ngStyle]="{height: (!wellcome)?'85vh':'90vh'}"> [ngStyle]="{height: (!wellcome)?'85vh':'90vh'}">

View File

@ -4,12 +4,13 @@
import {Component, OnInit} from '@angular/core'; import {Component, OnInit} from '@angular/core';
import {MenuItem, RootMenuItem, SideMenuItem} from './openaireLibrary/sharedComponents/menu'; import {MenuItem, RootMenuItem, SideMenuItem} from './openaireLibrary/sharedComponents/menu';
import {ActivatedRoute, NavigationStart, Router, RoutesRecognized} from '@angular/router'; import {ActivatedRoute, NavigationStart, Router} from '@angular/router';
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 {EnvProperties} from './openaireLibrary/utils/properties/env-properties'; import {EnvProperties} from './openaireLibrary/utils/properties/env-properties';
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 {UserManagementService} from './openaireLibrary/services/user-management.service';
declare var UIkit: any; declare var UIkit: any;
@ -34,11 +35,14 @@ export class AppComponent implements OnInit{
showSidebar: boolean; showSidebar: boolean;
wellcome = false; wellcome = false;
showMenu: boolean = false; showMenu: boolean = false;
user: User;
checkLogin: boolean = false;
constructor(private route: ActivatedRoute, constructor(private route: ActivatedRoute,
private propertiesService: EnvironmentSpecificService, private propertiesService: EnvironmentSpecificService,
private _communitiesService: CommunitiesService, private _communitiesService: CommunitiesService,
private router: Router) { private router: Router,
private userManagementService: UserManagementService) {
this.router.events.forEach((event) => { this.router.events.forEach((event) => {
if (event instanceof NavigationStart) { if (event instanceof NavigationStart) {
HelperFunctions.scroll(); HelperFunctions.scroll();
@ -60,12 +64,15 @@ export class AppComponent implements OnInit{
this.logOutUrl = this.properties.logoutUrl; this.logOutUrl = this.properties.logoutUrl;
this.showSidebar = false; this.showSidebar = false;
this.showMenu = false; this.showMenu = false;
if (Session.getUser()) { this.userManagementService.getUserInfo(this.properties.userInfoUrl).subscribe(user => {
localStorage.setItem('user_id', Session.getUser().id); this.user = user;
this.checkLogin = true;
if (this.user) {
localStorage.setItem('user_id', this.user.id);
localStorage.setItem('mining_backend_address', this.properties.miningBackendURL); localStorage.setItem('mining_backend_address', this.properties.miningBackendURL);
localStorage.setItem('isCommunityManager', Session.isCommunityCurator() + ''); localStorage.setItem('isCommunityManager', Session.isCommunityCurator(this.user) + '');
this.isPortalAdministrator = Session.isPortalAdministrator(); this.isPortalAdministrator = Session.isPortalAdministrator(this.user);
} }
this._communitiesService.updateCommunities(this.properties, this.properties.communityAPI + 'communities'); this._communitiesService.updateCommunities(this.properties, this.properties.communityAPI + 'communities');
this.route.queryParams.subscribe(params => { this.route.queryParams.subscribe(params => {
@ -85,11 +92,11 @@ export class AppComponent implements OnInit{
let index_managerOfCommunity = null; let index_managerOfCommunity = null;
for (let i = 0; i < communities.length; i++) { for (let i = 0; i < communities.length; i++) {
const com = communities[i]; const com = communities[i];
if (Session.isPortalAdministrator() || Session.isCommunityCurator()) { if (Session.isPortalAdministrator(this.user) || Session.isCommunityCurator(this.user)) {
this.userMenuItems.push(new MenuItem('manage' + com.communityId, 'Manage ' + ((com.shortTitle) ? com.shortTitle : com.title), '', '/dashboard', false, [], [], {communityId: com.communityId})); this.userMenuItems.push(new MenuItem('manage' + com.communityId, 'Manage ' + ((com.shortTitle) ? com.shortTitle : com.title), '', '/dashboard', false, [], [], {communityId: com.communityId}));
} else { } else {
for (const manager of com.managers) { for (const manager of com.managers) {
if (manager == Session.getUserEmail()) { if (this.user && manager == this.user.email) {
countCommunities++; countCommunities++;
index_managerOfCommunity = i; index_managerOfCommunity = i;
this.userMenuItems.push(new MenuItem('manage' + com.communityId, 'Manage ' + ((com.shortTitle) ? com.shortTitle : com.title), '', '/dashboard', false, [], [], {communityId: com.communityId})); this.userMenuItems.push(new MenuItem('manage' + com.communityId, 'Manage ' + ((com.shortTitle) ? com.shortTitle : com.title), '', '/dashboard', false, [], [], {communityId: com.communityId}));
@ -130,7 +137,7 @@ export class AppComponent implements OnInit{
if (this.communityId) { if (this.communityId) {
this.userMenuItems.push(new MenuItem('manage-user-notifications', 'Manage notification settings', '', '/manage-user-notifications', false, [], [], {communityId: this.communityId})); this.userMenuItems.push(new MenuItem('manage-user-notifications', 'Manage notification settings', '', '/manage-user-notifications', false, [], [], {communityId: this.communityId}));
this.userMenuItems.push(new MenuItem('personal', 'Manage Personal Info', '', '/personal', false, [], [], {communityId: this.communityId})); this.userMenuItems.push(new MenuItem('personal', 'Manage Personal Info', '', '/personal', false, [], [], {communityId: this.communityId}));
this.userMenuItems.push(new MenuItem("","Support","https://openaire-connect.d4science.org/group/openaire-connect-gateway/explore?siteId=172366611","",false,[],[],{})) this.userMenuItems.push(new MenuItem('', 'Support', 'https://openaire-connect.d4science.org/group/openaire-connect-gateway/explore?siteId=172366611', '', false, [], [], {}));
} }
this.showMenu = true; this.showMenu = true;
this.buildSideBar(); this.buildSideBar();
@ -148,6 +155,7 @@ export class AppComponent implements OnInit{
); );
}); });
}); });
});
} }
private buildSideBar() { private buildSideBar() {
@ -366,7 +374,7 @@ export class AppComponent implements OnInit{
rootItem: new MenuItem('personalInfo', 'Personal Info', '/personal', rootItem: new MenuItem('personalInfo', 'Personal Info', '/personal',
'/personal', false, [], [], {communityId: this.communityId}), '/personal', false, [], [], {communityId: this.communityId}),
items: [] items: []
}) });
users.items.push({ users.items.push({
rootItem: new MenuItem('notifications', 'Notification settings', '/manage-user-notifications', rootItem: new MenuItem('notifications', 'Notification settings', '/manage-user-notifications',
'/manage-user-notifications', false, [], [], {communityId: this.communityId}), '/manage-user-notifications', false, [], [], {communityId: this.communityId}),

View File

@ -44,8 +44,7 @@ export class AffiliationsComponent implements OnInit {
private route: ActivatedRoute, private route: ActivatedRoute,
private _router: Router, private _router: Router,
private affiliationService: AffiliationService, private affiliationService: AffiliationService,
private _helpContentService: HelpContentService, private _helpContentService: HelpContentService) {
private utilitiesService: UtilitiesService) {
} }

View File

@ -3,7 +3,7 @@ import {ActivatedRoute, Router} from '@angular/router';
import {EnvProperties} from '../../openaireLibrary/utils/properties/env-properties'; import {EnvProperties} from '../../openaireLibrary/utils/properties/env-properties';
import {Session} from '../../openaireLibrary/login/utils/helper.class'; import {Session, User} from '../../openaireLibrary/login/utils/helper.class';
import {LoginErrorCodes} from '../../openaireLibrary/login/utils/guardHelper.class'; import {LoginErrorCodes} from '../../openaireLibrary/login/utils/guardHelper.class';
import {CuratorService} from '../../openaireLibrary/connect/curators/curator.service'; import {CuratorService} from '../../openaireLibrary/connect/curators/curator.service';
import {Curator} from '../../openaireLibrary/utils/entities/CuratorInfo'; import {Curator} from '../../openaireLibrary/utils/entities/CuratorInfo';
@ -11,6 +11,7 @@ import {HelperFunctions} from '../../openaireLibrary/utils/HelperFunctions.class
import {UtilitiesService} from '../../openaireLibrary/services/utilities.service'; import {UtilitiesService} from '../../openaireLibrary/services/utilities.service';
import {HelpContentService} from '../../services/help-content.service'; import {HelpContentService} from '../../services/help-content.service';
import {AlertModal} from '../../openaireLibrary/utils/modal/alert'; import {AlertModal} from '../../openaireLibrary/utils/modal/alert';
import {UserManagementService} from '../../openaireLibrary/services/user-management.service';
@Component({ @Component({
selector: 'curator', selector: 'curator',
@ -34,6 +35,7 @@ export class CuratorComponent implements OnInit {
public curator: Curator = null; public curator: Curator = null;
public photo: any = null; public photo: any = null;
public properties: EnvProperties = null; public properties: EnvProperties = null;
public user: User;
private file: File = null; private file: File = null;
private maxsize: number = 200 * 1024; private maxsize: number = 200 * 1024;
@ -47,7 +49,8 @@ export class CuratorComponent implements OnInit {
private _router: Router, private _router: Router,
private curatorService: CuratorService, private curatorService: CuratorService,
private utilitiesService: UtilitiesService, private utilitiesService: UtilitiesService,
private helpContentService: HelpContentService) { private helpContentService: HelpContentService,
private userManagementService: UserManagementService) {
} }
@ -63,13 +66,15 @@ export class CuratorComponent implements OnInit {
this.communityId = params['communityId']; this.communityId = params['communityId'];
this.showLoading = true; this.showLoading = true;
this.updateErrorMessage = ''; this.updateErrorMessage = '';
this.curatorId = Session.getUser().id; this.userManagementService.getUserInfo(this.properties.userInfoUrl).subscribe(user => {
this.user = user;
this.curatorId = this.user.id;
this.curatorService.getCurator(this.properties, this.curatorService.getCurator(this.properties,
this.properties.adminToolsAPIURL + 'curator/' + this.curatorId).subscribe( this.properties.adminToolsAPIURL + 'curator/' + this.curatorId).subscribe(
curator => { curator => {
if (curator && Object.keys(curator).length > 0) { if (curator && Object.keys(curator).length > 0) {
this.curator = curator; this.curator = curator;
this.curator.email = Session.getUserEmail(); this.curator.email = this.user.email;
if (this.curator.photo && this.curator.photo !== '') { if (this.curator.photo && this.curator.photo !== '') {
this.photo = this.properties.utilsService + '/download/' + this.curator.photo; this.photo = this.properties.utilsService + '/download/' + this.curator.photo;
} else { } else {
@ -82,8 +87,8 @@ export class CuratorComponent implements OnInit {
this.newCurator = true; this.newCurator = true;
this.curator = new Curator(); this.curator = new Curator();
this.curator._id = this.curatorId; this.curator._id = this.curatorId;
this.curator.email = Session.getUserEmail(); this.curator.email = this.user.email;
this.curator.name = Session.getUserFullName(); this.curator.name = this.user.fullname;
this.curator.affiliations = []; this.curator.affiliations = [];
this.curator.bio = ''; this.curator.bio = '';
this.curator.photo = null; this.curator.photo = null;
@ -95,7 +100,8 @@ export class CuratorComponent implements OnInit {
error => { error => {
} }
); );
}) });
});
} }
}); });
@ -116,7 +122,7 @@ export class CuratorComponent implements OnInit {
curator => { curator => {
if (curator) { if (curator) {
this.curator = curator; this.curator = curator;
this.curator.email = Session.getUserEmail(); this.curator.email = this.user.email;
if (this.curator.photo && this.curator.photo !== '') { if (this.curator.photo && this.curator.photo !== '') {
this.photo = this.properties.utilsService + '/download/' + this.curator.photo; this.photo = this.properties.utilsService + '/download/' + this.curator.photo;
} else { } else {
@ -129,8 +135,8 @@ export class CuratorComponent implements OnInit {
this.newCurator = true; this.newCurator = true;
this.curator = new Curator(); this.curator = new Curator();
this.curator._id = this.curatorId; this.curator._id = this.curatorId;
this.curator.email = Session.getUserEmail(); this.curator.email = this.user.email
this.curator.name = Session.getUserFullName(); this.curator.name = this.user.fullname;
this.curator.affiliations = []; this.curator.affiliations = [];
this.curator.bio = ''; this.curator.bio = '';
this.curator.photo = null; this.curator.photo = null;
@ -152,13 +158,13 @@ export class CuratorComponent implements OnInit {
for (let page of community.pages) { for (let page of community.pages) {
if (page['route'] === '/curators') { if (page['route'] === '/curators') {
this.curatorsEnabled = page['isEnabled']; this.curatorsEnabled = page['isEnabled'];
console.log(this.curatorsEnabled) console.log(this.curatorsEnabled);
return; return;
} }
} }
this.curatorsEnabled = false; this.curatorsEnabled = false;
console.log(this.curatorsEnabled) console.log(this.curatorsEnabled);
}) });
} }
private change() { private change() {
@ -199,7 +205,7 @@ export class CuratorComponent implements OnInit {
this.handleUpdateError('You must choose a file with type: image/png or image/jpeg!', null); this.handleUpdateError('You must choose a file with type: image/png or image/jpeg!', null);
this.file = null; this.file = null;
} else if (this.file.size > this.maxsize) { } else if (this.file.size > this.maxsize) {
this.handleUpdateError("File exceeds size's limit! Maximum resolution is 256x256 pixels.", null); this.handleUpdateError('File exceeds size\'s limit! Maximum resolution is 256x256 pixels.', null);
this.file = null; this.file = null;
} else { } else {
this.updateErrorMessage = ''; this.updateErrorMessage = '';
@ -285,7 +291,7 @@ export class CuratorComponent implements OnInit {
privacy() { privacy() {
this.privacyStatement.cancelButton = false; this.privacyStatement.cancelButton = false;
this.privacyStatement.okButtonText = 'Close'; this.privacyStatement.okButtonText = 'Close';
this.privacyStatement.alertTitle = 'Privacy policy statement' this.privacyStatement.alertTitle = 'Privacy policy statement';
this.privacyStatement.open(); this.privacyStatement.open();
} }
} }

View File

@ -9,6 +9,7 @@ import { EnvProperties } from '../../openaireLibrary/utils/properties/env-proper
import {Session} from '../../openaireLibrary/login/utils/helper.class'; import {Session} from '../../openaireLibrary/login/utils/helper.class';
import {LoginErrorCodes} from '../../openaireLibrary/login/utils/guardHelper.class'; import {LoginErrorCodes} from '../../openaireLibrary/login/utils/guardHelper.class';
import {HelperFunctions} from "../../openaireLibrary/utils/HelperFunctions.class"; import {HelperFunctions} from "../../openaireLibrary/utils/HelperFunctions.class";
import {UserManagementService} from '../../openaireLibrary/services/user-management.service';
@Component({ @Component({
selector: 'entities', selector: 'entities',
@ -55,6 +56,11 @@ export class EntitiesComponent implements OnInit {
public modalErrorMessage = ''; public modalErrorMessage = '';
public isPortalAdministrator = null; public isPortalAdministrator = null;
constructor(private element: ElementRef, private route: ActivatedRoute,
private _router: Router,
private _helpContentService: HelpContentService,
private userManagementService: UserManagementService) {}
ngOnInit() { ngOnInit() {
this.formGroup = this.formComponent.form; this.formGroup = this.formComponent.form;
this.route.data this.route.data
@ -63,18 +69,16 @@ export class EntitiesComponent implements OnInit {
this.route.queryParams.subscribe(params => { this.route.queryParams.subscribe(params => {
HelperFunctions.scroll(); HelperFunctions.scroll();
this.userManagementService.getUserInfo(this.properties.userInfoUrl).subscribe( user => {
this.selectedCommunityPid = params['communityId']; this.selectedCommunityPid = params['communityId'];
this.applyCommunityFilter(this.selectedCommunityPid); this.applyCommunityFilter(this.selectedCommunityPid);
this.isPortalAdministrator = Session.isPortalAdministrator() && !this.selectedCommunityPid; this.isPortalAdministrator = Session.isPortalAdministrator(user) && !this.selectedCommunityPid;
});
}); });
}); });
} }
constructor(private element: ElementRef, private route: ActivatedRoute,
private _router: Router,
private _helpContentService: HelpContentService) {}
getEntities(community_pid: string) { getEntities(community_pid: string) {
if (!Session.isLoggedIn()) { if (!Session.isLoggedIn()) {
this._router.navigate(['/user-info'], this._router.navigate(['/user-info'],

View File

@ -1,18 +1,19 @@
/** /**
* Created by stefania on 7/13/17. * Created by stefania on 7/13/17.
*/ */
import { Component, ViewChild, OnInit, ElementRef } from '@angular/core'; import {Component, ElementRef, OnInit, ViewChild} from '@angular/core';
import { ActivatedRoute, Router } from "@angular/router"; import {ActivatedRoute, Router} from '@angular/router';
import { HelpContentService } from "../../services/help-content.service"; import {HelpContentService} from '../../services/help-content.service';
import { FormGroup } from "@angular/forms"; import {FormGroup} from '@angular/forms';
import { PageFormComponent } from "./page-form.component"; import {PageFormComponent} from './page-form.component';
import { CheckPage, Page } from "../../domain/page"; import {CheckPage, Page} from '../../domain/page';
import { Community } from "../../domain/community"; import {Community} from '../../domain/community';
import { Entity } from "../../domain/entity"; import {Entity} from '../../domain/entity';
import {EnvProperties} from '../../openaireLibrary/utils/properties/env-properties'; import {EnvProperties} from '../../openaireLibrary/utils/properties/env-properties';
import {Session} from '../../openaireLibrary/login/utils/helper.class'; import {Session} from '../../openaireLibrary/login/utils/helper.class';
import {LoginErrorCodes} from '../../openaireLibrary/login/utils/guardHelper.class'; import {LoginErrorCodes} from '../../openaireLibrary/login/utils/guardHelper.class';
import {HelperFunctions} from "../../openaireLibrary/utils/HelperFunctions.class"; import {HelperFunctions} from '../../openaireLibrary/utils/HelperFunctions.class';
import {UserManagementService} from '../../openaireLibrary/services/user-management.service';
@Component({ @Component({
selector: 'pages', selector: 'pages',
@ -39,7 +40,7 @@ export class PagesComponent implements OnInit {
public formGroup: FormGroup; public formGroup: FormGroup;
private searchText: RegExp = new RegExp(''); private searchText: RegExp = new RegExp('');
public keyword: string = ""; public keyword: string = '';
public communities: Community[] = []; public communities: Community[] = [];
@ -54,6 +55,11 @@ export class PagesComponent implements OnInit {
public modalErrorMessage: string = ''; public modalErrorMessage: string = '';
public isPortalAdministrator = null; public isPortalAdministrator = null;
constructor(private element: ElementRef, private route: ActivatedRoute,
private _router: Router, private _helpContentService: HelpContentService,
private userManagementService: UserManagementService) {
}
ngOnInit() { ngOnInit() {
this.formGroup = this.formComponent.form; this.formGroup = this.formComponent.form;
this.route.data this.route.data
@ -63,37 +69,35 @@ export class PagesComponent implements OnInit {
this.route.queryParams.subscribe(params => { this.route.queryParams.subscribe(params => {
HelperFunctions.scroll(); HelperFunctions.scroll();
this.pagesType = ""; this.pagesType = '';
if (params['type']) { if (params['type']) {
this.pagesType = params['type']; this.pagesType = params['type'];
} }
this.keyword = ""; this.keyword = '';
this.userManagementService.getUserInfo(this.properties.userInfoUrl).subscribe( user => {
this.selectedCommunityPid = params['communityId']; this.selectedCommunityPid = params['communityId'];
this.applyCommunityFilter(this.selectedCommunityPid); this.applyCommunityFilter(this.selectedCommunityPid);
this.isPortalAdministrator = Session.isPortalAdministrator() && !this.selectedCommunityPid; this.isPortalAdministrator = Session.isPortalAdministrator(user) && !this.selectedCommunityPid;
});
//this.getCommunities(); //this.getCommunities();
}); });
}); });
} }
constructor(private element: ElementRef, private route: ActivatedRoute, private _router: Router, private _helpContentService: HelpContentService) {}
getPages(community_pid: string) { getPages(community_pid: string) {
if (!Session.isLoggedIn()) { if (!Session.isLoggedIn()) {
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} }); this._router.navigate(['/user-info'], {queryParams: {'errorCode': LoginErrorCodes.NOT_VALID, 'redirectUrl': this._router.url}});
} else { } else {
this.showLoading = true; this.showLoading = true;
this.updateErrorMessage = ""; this.updateErrorMessage = '';
this.errorMessage = ""; this.errorMessage = '';
this.pageWithDivIds = []; this.pageWithDivIds = [];
let parameters = ""; let parameters = '';
if (this.pagesType) { if (this.pagesType) {
parameters = "?page_type="+this.pagesType; parameters = '?page_type=' + this.pagesType;
} }
if (community_pid) { if (community_pid) {
this._helpContentService.getCommunityPages(community_pid, parameters, this.properties.adminToolsAPIURL).subscribe( this._helpContentService.getCommunityPages(community_pid, parameters, this.properties.adminToolsAPIURL).subscribe(
@ -121,7 +125,7 @@ export class PagesComponent implements OnInit {
getPagesWithDivIds(community_pid: string) { getPagesWithDivIds(community_pid: string) {
if (!Session.isLoggedIn()) { if (!Session.isLoggedIn()) {
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} }); this._router.navigate(['/user-info'], {queryParams: {'errorCode': LoginErrorCodes.NOT_VALID, 'redirectUrl': this._router.url}});
} else { } else {
this._helpContentService.getPagesWithDivIds(community_pid, this.properties.adminToolsAPIURL).subscribe( this._helpContentService.getPagesWithDivIds(community_pid, this.properties.adminToolsAPIURL).subscribe(
pages => { pages => {
@ -142,6 +146,7 @@ export class PagesComponent implements OnInit {
}); });
} }
} }
/* /*
getCommunities() { getCommunities() {
this._helpContentService.getCommunities(this.properties.adminToolsAPIURL).subscribe( this._helpContentService.getCommunities(this.properties.adminToolsAPIURL).subscribe(
@ -190,23 +195,23 @@ export class PagesComponent implements OnInit {
private confirmModalOpen() { private confirmModalOpen() {
if (!Session.isLoggedIn()) { if (!Session.isLoggedIn()) {
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} }); this._router.navigate(['/user-info'], {queryParams: {'errorCode': LoginErrorCodes.NOT_VALID, 'redirectUrl': this._router.url}});
} else { } else {
this.alertModalDeletePages.cancelButton = true; this.alertModalDeletePages.cancelButton = true;
this.alertModalDeletePages.okButton = true; this.alertModalDeletePages.okButton = true;
this.alertModalDeletePages.alertTitle = "Delete Confirmation"; this.alertModalDeletePages.alertTitle = 'Delete Confirmation';
this.alertModalDeletePages.message = "Are you sure you want to delete the selected page(s)?"; this.alertModalDeletePages.message = 'Are you sure you want to delete the selected page(s)?';
this.alertModalDeletePages.okButtonText = "Yes"; this.alertModalDeletePages.okButtonText = 'Yes';
this.alertModalDeletePages.open(); this.alertModalDeletePages.open();
} }
} }
public confirmedDeletePages(data: any) { public confirmedDeletePages(data: any) {
if (!Session.isLoggedIn()) { if (!Session.isLoggedIn()) {
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} }); this._router.navigate(['/user-info'], {queryParams: {'errorCode': LoginErrorCodes.NOT_VALID, 'redirectUrl': this._router.url}});
} else { } else {
this.showLoading = true; this.showLoading = true;
this.updateErrorMessage = ""; this.updateErrorMessage = '';
this._helpContentService.deletePages(this.selectedPages, this.properties.adminToolsAPIURL).subscribe( this._helpContentService.deletePages(this.selectedPages, this.properties.adminToolsAPIURL).subscribe(
_ => { _ => {
@ -225,19 +230,19 @@ export class PagesComponent implements OnInit {
//console.info(this.formGroup.value); //console.info(this.formGroup.value);
//this.updateModal.showModal(); //this.updateModal.showModal();
this.modalErrorMessage = ""; this.modalErrorMessage = '';
this.pagesModalOpen(this.alertModalUpdatePage, "Update", "Update Page"); this.pagesModalOpen(this.alertModalUpdatePage, 'Update', 'Update Page');
} }
public newPage() { public newPage() {
this.formComponent.reset(); this.formComponent.reset();
this.modalErrorMessage = ""; this.modalErrorMessage = '';
this.pagesModalOpen(this.alertModalSavePage, "Save", "Add a new Page"); this.pagesModalOpen(this.alertModalSavePage, 'Save', 'Add a new Page');
} }
private pagesModalOpen(modal: any, title: string, yesBtn: string) { private pagesModalOpen(modal: any, title: string, yesBtn: string) {
if (!Session.isLoggedIn()) { if (!Session.isLoggedIn()) {
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} }); this._router.navigate(['/user-info'], {queryParams: {'errorCode': LoginErrorCodes.NOT_VALID, 'redirectUrl': this._router.url}});
} else { } else {
modal.cancelButton = true; modal.cancelButton = true;
modal.okButton = true; modal.okButton = true;
@ -249,18 +254,18 @@ export class PagesComponent implements OnInit {
public pageSaveConfirmed(data: any) { public pageSaveConfirmed(data: any) {
if (!Session.isLoggedIn()) { if (!Session.isLoggedIn()) {
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} }); this._router.navigate(['/user-info'], {queryParams: {'errorCode': LoginErrorCodes.NOT_VALID, 'redirectUrl': this._router.url}});
} else { } else {
if (!this.formGroup.valid) { if (!this.formGroup.valid) {
this.pagesModalOpen(this.alertModalSavePage, "Save", "Add a new Page"); this.pagesModalOpen(this.alertModalSavePage, 'Save', 'Add a new Page');
this.modalErrorMessage = "Please fill in all required fields marked with *"; this.modalErrorMessage = 'Please fill in all required fields marked with *';
} else { } else {
this.modalErrorMessage = ""; this.modalErrorMessage = '';
this._helpContentService.savePage(<Page>this.formGroup.value, this.properties.adminToolsAPIURL).subscribe( this._helpContentService.savePage(<Page>this.formGroup.value, this.properties.adminToolsAPIURL).subscribe(
page => { page => {
this.pageSavedSuccessfully(page); this.pageSavedSuccessfully(page);
}, },
error => this.handleUpdateError("System error creating page", error) error => this.handleUpdateError('System error creating page', error)
); );
} }
} }
@ -268,17 +273,17 @@ export class PagesComponent implements OnInit {
public pageUpdateConfirmed(data: any) { public pageUpdateConfirmed(data: any) {
if (!Session.isLoggedIn()) { if (!Session.isLoggedIn()) {
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} }); this._router.navigate(['/user-info'], {queryParams: {'errorCode': LoginErrorCodes.NOT_VALID, 'redirectUrl': this._router.url}});
} else { } else {
if (!this.formGroup.valid) { if (!this.formGroup.valid) {
this.pagesModalOpen(this.alertModalUpdatePage, "Update", "Update Page"); this.pagesModalOpen(this.alertModalUpdatePage, 'Update', 'Update Page');
this.modalErrorMessage = "Please fill in all required fields marked with *"; this.modalErrorMessage = 'Please fill in all required fields marked with *';
} else { } else {
this._helpContentService.updatePage(<Page>this.formGroup.value, this.properties.adminToolsAPIURL).subscribe( this._helpContentService.updatePage(<Page>this.formGroup.value, this.properties.adminToolsAPIURL).subscribe(
page => { page => {
this.pageUpdatedSuccessfully(page); this.pageUpdatedSuccessfully(page);
}, },
error => this.handleUpdateError("System error updating page", error) error => this.handleUpdateError('System error updating page', error)
); );
} }
} }
@ -344,9 +349,9 @@ export class PagesComponent implements OnInit {
public togglePages(status: boolean, ids: string[]) { public togglePages(status: boolean, ids: string[]) {
if (!Session.isLoggedIn()) { if (!Session.isLoggedIn()) {
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} }); this._router.navigate(['/user-info'], {queryParams: {'errorCode': LoginErrorCodes.NOT_VALID, 'redirectUrl': this._router.url}});
} else { } else {
this.updateErrorMessage = ""; this.updateErrorMessage = '';
this._helpContentService.togglePages(this.selectedCommunityPid, ids, status, this.properties.adminToolsAPIURL).subscribe( this._helpContentService.togglePages(this.selectedCommunityPid, ids, status, this.properties.adminToolsAPIURL).subscribe(
() => { () => {

View File

@ -4,7 +4,7 @@ import {ActivatedRoute, Router} from '@angular/router';
import {EnvProperties} from '../../openaireLibrary/utils/properties/env-properties'; import {EnvProperties} from '../../openaireLibrary/utils/properties/env-properties';
import {Session} from '../../openaireLibrary/login/utils/helper.class'; import {Session, User} from '../../openaireLibrary/login/utils/helper.class';
import {ManageUserNotificationsService} from './manage-user-notifications.service'; import {ManageUserNotificationsService} from './manage-user-notifications.service';
@ -12,7 +12,8 @@ import {UserNotificationsRights} from './userNotificationsRights';
import {MailPrefsComponent} from '../../openaireLibrary/connect/userEmailPreferences/mailPrefs.component'; import {MailPrefsComponent} from '../../openaireLibrary/connect/userEmailPreferences/mailPrefs.component';
import {LoginErrorCodes} from '../../openaireLibrary/login/utils/guardHelper.class'; import {LoginErrorCodes} from '../../openaireLibrary/login/utils/guardHelper.class';
import {HelperFunctions} from "../../openaireLibrary/utils/HelperFunctions.class"; import {HelperFunctions} from '../../openaireLibrary/utils/HelperFunctions.class';
import {UserManagementService} from '../../openaireLibrary/services/user-management.service';
@Component({ @Component({
selector: 'manage-user-notifications', selector: 'manage-user-notifications',
@ -38,11 +39,13 @@ export class ManageUserNotificationsComponent implements OnInit {
public successfulResetMessage = ''; public successfulResetMessage = '';
public hasChanged = false; public hasChanged = false;
public user: User;
@ViewChild(MailPrefsComponent) mailPrefs: MailPrefsComponent; @ViewChild(MailPrefsComponent) mailPrefs: MailPrefsComponent;
constructor(private route: ActivatedRoute, private _router: Router, public _fb: FormBuilder, constructor(private route: ActivatedRoute, private _router: Router, public _fb: FormBuilder,
private _manageUserNotificationsService: ManageUserNotificationsService, private element: ElementRef) { private _manageUserNotificationsService: ManageUserNotificationsService,
private element: ElementRef, private userManagementService: UserManagementService) {
} }
ngOnInit() { ngOnInit() {
@ -51,19 +54,18 @@ export class ManageUserNotificationsComponent implements OnInit {
this.route.queryParams.subscribe( this.route.queryParams.subscribe(
communityId => { communityId => {
HelperFunctions.scroll(); HelperFunctions.scroll();
this.communityId = communityId['communityId']; this.communityId = communityId['communityId'];
if (this.communityId != null && this.communityId !== '') { if (this.communityId != null && this.communityId !== '') {
this.showLoading = true; this.showLoading = true;
this.updateErrorMessage = ''; this.updateErrorMessage = '';
this.errorMessage = ''; this.errorMessage = '';
this.successfulSaveMessage = ''; this.successfulSaveMessage = '';
this.userManagementService.getUserInfo(this.properties.userInfoUrl).subscribe(user => {
if (Session.getUser()) { this.user = user;
this.userEmail = Session.getUserEmail(); if (this.user) {
this.userEmail = this.user.email;
this._manageUserNotificationsService.getUserNotifications( this._manageUserNotificationsService.getUserNotifications(
this.properties.adminToolsAPIURL + 'community/' + this.communityId + '/notifications', this.userEmail). this.properties.adminToolsAPIURL + 'community/' + this.communityId + '/notifications', this.userEmail).subscribe(
subscribe(
userNotifications => { userNotifications => {
this.initialUserNotifications = userNotifications; this.initialUserNotifications = userNotifications;
if (this.initialUserNotifications['notifyForNewManagers'] == null || if (this.initialUserNotifications['notifyForNewManagers'] == null ||
@ -87,6 +89,7 @@ export class ManageUserNotificationsComponent implements OnInit {
} }
); );
} }
});
} }
} }
); );
@ -137,8 +140,8 @@ export class ManageUserNotificationsComponent implements OnInit {
if (this.userNotifications.managerEmail) { if (this.userNotifications.managerEmail) {
userNotifications['managerEmail'] = this.userNotifications.managerEmail; userNotifications['managerEmail'] = this.userNotifications.managerEmail;
} else { } else {
if (Session.getUser()) { if (this.user) {
userNotifications['managerEmail'] = Session.getUserEmail(); userNotifications['managerEmail'] = this.user.email;
} }
} }
return userNotifications; return userNotifications;
@ -147,7 +150,8 @@ export class ManageUserNotificationsComponent implements OnInit {
public resetForm() { public resetForm() {
if (!Session.isLoggedIn()) { if (!Session.isLoggedIn()) {
this._router.navigate(['/user-info'], { this._router.navigate(['/user-info'], {
queryParams: { 'errorCode': LoginErrorCodes.NOT_VALID, 'redirectUrl': this._router.url} }); queryParams: {'errorCode': LoginErrorCodes.NOT_VALID, 'redirectUrl': this._router.url}
});
} else { } else {
this.mailPrefs.restoreNotification(0); this.mailPrefs.restoreNotification(0);
if (this.userNotifications && this.initialUserNotifications) { if (this.userNotifications && this.initialUserNotifications) {
@ -163,7 +167,8 @@ export class ManageUserNotificationsComponent implements OnInit {
public changeValueForNewManagers(notifyForManagers: any) { public changeValueForNewManagers(notifyForManagers: any) {
if (!Session.isLoggedIn()) { if (!Session.isLoggedIn()) {
this._router.navigate(['/user-info'], { this._router.navigate(['/user-info'], {
queryParams: {' "errorCode"': LoginErrorCodes.NOT_VALID, 'redirectUrl': this._router.url} }); queryParams: {' "errorCode"': LoginErrorCodes.NOT_VALID, 'redirectUrl': this._router.url}
});
} else { } else {
this.userNotifications.notifyForNewManagers = !notifyForManagers; this.userNotifications.notifyForNewManagers = !notifyForManagers;
this.change(); this.change();
@ -173,7 +178,8 @@ export class ManageUserNotificationsComponent implements OnInit {
public changeValueForNewSubscribers(notifyForSubscribers: any) { public changeValueForNewSubscribers(notifyForSubscribers: any) {
if (!Session.isLoggedIn()) { if (!Session.isLoggedIn()) {
this._router.navigate(['/user-info'], { this._router.navigate(['/user-info'], {
queryParams: { 'errorCode': LoginErrorCodes.NOT_VALID, 'redirectUrl': this._router.url} }); queryParams: {'errorCode': LoginErrorCodes.NOT_VALID, 'redirectUrl': this._router.url}
});
} else { } else {
this.userNotifications.notifyForNewSubscribers = !notifyForSubscribers; this.userNotifications.notifyForNewSubscribers = !notifyForSubscribers;
this.change(); this.change();
@ -193,7 +199,8 @@ export class ManageUserNotificationsComponent implements OnInit {
public mailPrefsChanged(): boolean { public mailPrefsChanged(): boolean {
if (!Session.isLoggedIn()) { if (!Session.isLoggedIn()) {
this._router.navigate(['/user-info'], { this._router.navigate(['/user-info'], {
queryParams: { 'errorCode': LoginErrorCodes.NOT_VALID, 'redirectUrl': this._router.url} }); queryParams: {'errorCode': LoginErrorCodes.NOT_VALID, 'redirectUrl': this._router.url}
});
} else { } else {
return this.mailPrefs.prefsChanged['0']; return this.mailPrefs.prefsChanged['0'];
} }

View File

@ -1,11 +1,12 @@
import {Component, Input, OnInit} from '@angular/core'; import {Component, Input, OnInit} from '@angular/core';
import {Session} from '../../openaireLibrary/login/utils/helper.class'; import {Session, User} from '../../openaireLibrary/login/utils/helper.class';
import {EnvProperties} from '../../openaireLibrary/utils/properties/env-properties'; import {EnvProperties} from '../../openaireLibrary/utils/properties/env-properties';
import {ActivatedRoute} from '@angular/router'; import {ActivatedRoute} from '@angular/router';
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 {CommunityInfo} from '../../openaireLibrary/connect/community/communityInfo'; import {CommunityInfo} from '../../openaireLibrary/connect/community/communityInfo';
import {HelperFunctions} from '../../openaireLibrary/utils/HelperFunctions.class'; import {HelperFunctions} from '../../openaireLibrary/utils/HelperFunctions.class';
import {UserManagementService} from '../../openaireLibrary/services/user-management.service';
@Component({ @Component({
selector: 'wellcome', selector: 'wellcome',
@ -88,8 +89,10 @@ export class WellcomeComponent implements OnInit {
properties: EnvProperties = null; properties: EnvProperties = null;
public communities: CommunityInfo[] = []; public communities: CommunityInfo[] = [];
showLoading: boolean; showLoading: boolean;
private user: User;
constructor(private route: ActivatedRoute, private propertiesService: EnvironmentSpecificService, private _communitiesService: CommunitiesService) { constructor(private route: ActivatedRoute, private propertiesService: EnvironmentSpecificService, private _communitiesService: CommunitiesService,
private userManagementService: UserManagementService) {
} }
ngOnInit() { ngOnInit() {
@ -98,6 +101,8 @@ export class WellcomeComponent implements OnInit {
this.propertiesService.setEnvProperties(es); this.propertiesService.setEnvProperties(es);
this.properties = this.propertiesService.envSpecific; this.properties = this.propertiesService.envSpecific;
HelperFunctions.scroll(); HelperFunctions.scroll();
this.userManagementService.getUserInfo(this.properties.userInfoUrl).subscribe(user => {
this.user = user;
//this._communitiesService.getCommunities(this.properties, this.properties.communityAPI + 'communities').subscribe( //this._communitiesService.getCommunities(this.properties, this.properties.communityAPI + 'communities').subscribe(
this._communitiesService.getCommunitiesState().subscribe( this._communitiesService.getCommunitiesState().subscribe(
@ -109,11 +114,11 @@ export class WellcomeComponent implements OnInit {
var index_managerOfCommunity = null; var index_managerOfCommunity = null;
for (var i = 0; i < communities.length; i++) { for (var i = 0; i < communities.length; i++) {
var com = communities[i]; var com = communities[i];
if (Session.isPortalAdministrator() || Session.isCommunityCurator()) { if (Session.isPortalAdministrator(this.user) || Session.isCommunityCurator(this.user)) {
this.communities.push(communities[i]); this.communities.push(communities[i]);
} else { } else {
for (var manager of com.managers) { for (var manager of com.managers) {
if (manager == Session.getUserEmail()) { if (this.user && manager == this.user.email) {
countCommunities++; countCommunities++;
index_managerOfCommunity = i; index_managerOfCommunity = i;
this.communities.push(communities[i]); this.communities.push(communities[i]);
@ -125,5 +130,6 @@ export class WellcomeComponent implements OnInit {
this.showLoading = false; this.showLoading = false;
}); });
}); });
});
} }
} }

View File

@ -35,6 +35,8 @@
"piwikBaseUrl" :" https://analytics.openaire.eu/piwik.php?idsite=6", "piwikBaseUrl" :" https://analytics.openaire.eu/piwik.php?idsite=6",
"loginUrl" :"http://scoobydoo.di.uoa.gr:8080/dnet-openaire-users-1.0.0-SNAPSHOT/openid_connect_login", "loginUrl" :"http://scoobydoo.di.uoa.gr:8080/dnet-openaire-users-1.0.0-SNAPSHOT/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=",
"cookieDomain" :".di.uoa.gr", "cookieDomain" :".di.uoa.gr",