[Library|Trunk]

Rush commit for:
Fixing issues with private/hidden communities
Fixing showing the verification code modal


git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-connect-portal/trunk@61006 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
argiro.kokogiannaki 2021-05-17 10:10:27 +00:00
parent 9ef3d0317f
commit df1d14502e
7 changed files with 142 additions and 122 deletions

View File

@ -1,5 +1,5 @@
import {Component} from '@angular/core';
import {ActivatedRoute, NavigationStart, Router} from '@angular/router';
import {ActivatedRoute, Router} from '@angular/router';
import {EnvProperties} from './openaireLibrary/utils/properties/env-properties';
import {MenuItem, RootMenuItem} from './openaireLibrary/sharedComponents/menu';
@ -7,7 +7,6 @@ import {EnvironmentSpecificService} from './openaireLibrary/utils/properties/env
import {CommunitiesService} from "./openaireLibrary/connect/communities/communities.service";
import {Session, User} from './openaireLibrary/login/utils/helper.class';
import {ConnectHelper} from './openaireLibrary/connect/connectHelper';
import {HelperFunctions} from "./openaireLibrary/utils/HelperFunctions.class";
import {UserManagementService} from "./openaireLibrary/services/user-management.service";
import {ConfigurationService} from "./openaireLibrary/utils/configuration/configuration.service";
import {properties} from '../environments/environment';
@ -20,6 +19,7 @@ import {CustomizationOptions} from "./openaireLibrary/connect/community/Customiz
import {LayoutService} from "./openaireLibrary/services/layout.service";
import {SmoothScroll} from "./openaireLibrary/utils/smooth-scroll";
import {Meta} from "@angular/platform-browser";
import {CommunityInfo} from "./openaireLibrary/connect/community/communityInfo";
@Component({
//changeDetection: ChangeDetectionStrategy.Default,
@ -28,12 +28,12 @@ import {Meta} from "@angular/platform-browser";
styles: [`
`],
template: `
<div [class]="(community)?(community.id +'App communityApp'):'connectApp'">
<div [class]="(community)?(community.communityId +'App communityApp'):'connectApp'">
<navbar *ngIf="properties && showMenu && !community && header" [portal]="properties.dashboard" [onlyTop]=false
[userMenuItems]=userMenuItems [menuItems]=menuItems [user]="user" [header]="header"
[showMenu]=showMenu [properties]="properties" [showHomeMenuItem]="false" communityId="connect"></navbar>
<navbar *ngIf="properties && showMenu && community && header" [portal]="community.id" [onlyTop]=false
[communityId]="community.id" [header]="header"
<navbar *ngIf="properties && showMenu && community && header" [portal]="community.communityId" [onlyTop]=false
[communityId]="community.communityId" [header]="header"
[userMenuItems]=userMenuItems [menuItems]=menuItems [user]="user"
[showMenu]=showMenu [properties]="properties" [enableSearch]="false"
searchRoute="/search/find/research-outcomes"
@ -50,15 +50,15 @@ import {Meta} from "@angular/platform-browser";
<schema2jsonld *ngIf="properties && showMenu && communityId && communityId.length > 0 && community"
[URL]="properties.domain + properties.baseLink"
[logoURL]="community.logoUrl" type="home" [searchActionRoute]="properties.searchLinkToResults"
[name]="community.name" [description]="community.description">
[name]="(community.shortTitle) ? community.shortTitle : community.title" [description]="community.description">
</schema2jsonld>
<div class="custom-main-content">
<main>
<router-outlet></router-outlet>
</main>
</div>
<div id="subscribeAndInviteBtn" *ngIf="isClient && community">
<subscribe [communityId]="community.id"></subscribe>
<div id="subscribeAndInviteBtn" *ngIf="isClient && communityId && community">
<subscribe [communityId]="community.communityId"></subscribe>
<invite *ngIf="isManager" [longView]="false"></invite>
</div>
<!--feedback *ngIf= "isClient && properties" portalName="Connect" [feedbackQuestionaire]=properties.feedbackQuestionaire></feedback-->
@ -77,10 +77,10 @@ import {Meta} from "@angular/platform-browser";
[properties]="properties"></bottom>
<bottom *ngIf="properties && isClient && showMenu && community" class=" communityPanelBackground "
[showSocialButtons]="true" [showMenuItems]="true" [grantAdvance]="false" [showOpenaire]="true"
[communityId]="community.id" [menuItems]=bottomMenuItems [properties]="properties"
[communityId]="community.communityId" [menuItems]=bottomMenuItems [properties]="properties"
[darkBackground]="true" [centered]="true"></bottom>
<role-verification *ngIf="community" service="connect"
[id]="community.id" [name]="community.name" [type]="'community'"></role-verification>
[id]="community.communityId" [name]="community.title" [type]="'community'"></role-verification>
</div>
`
@ -90,7 +90,7 @@ export class AppComponent {
userMenuItems: MenuItem[] = [];
menuItems: RootMenuItem [] = [];
bottomMenuItems: MenuItem[] = [];
public community = null;
public community:CommunityInfo = null;
properties: EnvProperties = properties;
showMenu: boolean = false;
communities = null;
@ -120,6 +120,7 @@ export class AppComponent {
}
ngOnInit() {
console.log("aaap init")
if (this.properties.environment == "production" || this.properties.environment == "development") {
this.subscriptions.push(this.route.queryParams.subscribe(data => {
this._meta.updateTag({content: 'all', name: 'robots'});
@ -134,21 +135,27 @@ export class AppComponent {
}
this.subscriptions.push(this.userManagementService.getUserInfo().subscribe(user => {
this.user = user;
console.log(user, "call init")
this.init();
}, error => this.init()));
}, error => {
console.log(" user error call init")
this.init()}));
}
get isManager() {
return Session.isCommunityCurator(this.user) || Session.isPortalAdministrator(this.user) || (this.communityId && Session.isManager('community', this.communityId, this.user))
}
get isPrivate() {
return this.community && !ConnectHelper.isPrivate(this.community, this.user)
}
private init() {
let communityId: string = ConnectHelper.getCommunityFromDomain(this.properties.domain);
this.showMenu = false;
this.initAdminToolCommunity(communityId);
this.buildMenu(communityId);
this.communityId = communityId;
// this.communityId = communityId;
if (this.communityId === null) {
this.userManagementService.fixRedirectURL = properties.afterLoginRedirectLink;
} else {
@ -184,21 +191,43 @@ export class AppComponent {
}
public buildMenu(communityId: string) {
if (communityId) {
if (!this.community || this.community.communityId !== communityId) {
console.log(communityId)
if (!this.community || this.communityId !== communityId) {
console.log("new")
this.subscriptions.push(this._communityService.getCommunity(communityId).subscribe(community => {
if (community && !this.isPrivate(community)) {
this.community = {
if (community) {
/* this.community = {
id: community.communityId,
name: (community.shortTitle) ? community.shortTitle : community.title,
logoUrl: (community.isUpload) ? (properties.utilsService + '/download/' + community.logoUrl) : (StringUtils.urlPrefix(community.logoUrl) + community.logoUrl),
description: community.description
};
description: community.description,
status: community.status
};*/
this.community = community;
}else{
this.community = null;
this.communityId = null;
}
this.buildCommunityMenu();
}));
} else {
console.log("same")
this.buildCommunityMenu();
}
} else {
this.buildConnectMenu();
}
}
buildCommunityMenu(){
if (this.community && !ConnectHelper.isPrivate(this.community, this.user)) {
this.communityId = this.community.communityId;
this.header = {
// url: 'https://' + (this.properties.environment == 'beta' ? 'beta.' : '') + this.community.id + '.openaire.eu',
route: "/",
title: this.community.name,
logoUrl: this.community.logoUrl,
logoSmallUrl: this.community.logoUrl,
title: (this.community.shortTitle) ? this.community.shortTitle : this.community.title,
logoUrl: (this.community.isUpload) ? (properties.utilsService + '/download/' + this.community.logoUrl) : (StringUtils.urlPrefix(this.community.logoUrl) + this.community.logoUrl),
logoSmallUrl: (this.community.isUpload) ? (properties.utilsService + '/download/' + this.community.logoUrl) : (StringUtils.urlPrefix(this.community.logoUrl) + this.community.logoUrl),
position: 'left',
badge: true
};
@ -239,7 +268,7 @@ export class AppComponent {
if (this.isManager) {
this.menuItems.push(
{
rootItem: new MenuItem("manage", "Manage", this.properties.adminPortalURL + '/' + community.communityId, "", false, [], [], {}),
rootItem: new MenuItem("manage", "Manage", this.properties.adminPortalURL + '/' + this.community.communityId, "", false, [], [], {}),
items: []
});
}
@ -261,44 +290,31 @@ export class AppComponent {
}
this.showMenu = true;
} else {
this.showPrivateOrNoCommunity(community ? community.status : null);
}
}));
} else {
this.showMenu = true;
}
} else {
this.buildConnectMenu();
}
}
isPrivate(community) {
return community && (community.status == "hidden" || (community.status == "manager" && !(Session.isCommunityCurator(this.user) || Session.isManager("community", community.communityId, this.user))))
}
showPrivateOrNoCommunity(restrictedData: string) {
console.log(this.community && this.community.status?this.community.status:"no community");
this.communityId = null;
this.community = null;
this.properties.adminToolsPortalType = "connect";
this.configurationService.initCommunityInformation(this.properties, "connect");
this.initAdminToolCommunity(null);
this.buildConnectMenu(true);
if (restrictedData == "manager") {
if (this.community && this.community.status == "manager") {
if (!this.user && typeof location !== 'undefined') {
console.log("no user")
this.router.navigate(['/user-info'], {
queryParams: {
"errorCode": LoginErrorCodes.NOT_LOGIN,
"redirectUrl": location.pathname+ location.search + location.hash
}
}, queryParamsHandling: "merge"
});
} else {
this.router.navigate(['/error'], {queryParams: {'page': -1}});
this.router.navigate(['/'], { queryParamsHandling: "merge" });
}
}else if (this.community && this.community.status == "hidden") {
this.router.navigate(['/error']);
}else{
this.router.navigate(['/'], this.community && this.community.status ? { queryParamsHandling: "merge" } : {});
}
} else {
this.router.navigate(['/error'], restrictedData ? {queryParams: {'page': -1}} : {});
}
}
buildConnectMenu(restrictedData: boolean = false) {
let url = "https://" + (properties.environment != "production" ? "beta." : "") + "connect.openaire.eu";
this.header = {

View File

@ -62,7 +62,7 @@ import {RoleVerificationModule} from "./openaireLibrary/role-verification/role-v
multi: true
},
[{provide: HTTP_INTERCEPTORS, useClass: TimeoutInterceptor, multi: true}],
[{provide: DEFAULT_TIMEOUT, useValue: 5000}]
[{provide: DEFAULT_TIMEOUT, useValue: 10000}]
],
bootstrap: [AppComponent]
})

View File

@ -27,6 +27,7 @@ import {FetchResearchResults} from "../openaireLibrary/utils/fetchEntitiesClasse
import {ErrorCodes} from "../openaireLibrary/utils/properties/errorCodes";
import {Subscription} from "rxjs";
import {properties} from "../../environments/environment";
import {ConnectHelper} from "../openaireLibrary/connect/connectHelper";
@Component({
selector: 'community',
@ -145,11 +146,14 @@ export class CommunityComponent {
this._meta.updateTag({content: this.url}, "property='og:url'");
this.subs.push(this.userManagementService.getUserInfo().subscribe(user => {
this.user = user;
if(this.community && ConnectHelper.isPrivate(this.community, this.user)){
this.community = null;
}
}));
this.customFilter = new SearchCustomFilter("Community", "communityId", this.communityId, "");
this.subs.push(this._communityService.getCommunityAsObservable().subscribe(
community => {
if(community) {
if(community && !ConnectHelper.isPrivate(community, this.user)) {
this.community = community;
if (community.description != null && (community.description.length - this.thresholdDescription <= this.descriptionDiff)) {
this.thresholdDescription = community.description.length;

View File

@ -49,7 +49,7 @@ export class DemoComponent implements OnInit{
this.resultLanding.subjects = ["Subject 1", "Subject 2"];
this.resultLanding.contexts = [{ "labelContext": "Research Community", "idContext": "",
"labelCategory":"", "idCategory": "",
"labelConcept": "", "idConcept": "", "inline" :true }]
"labelConcept": "", "idConcept": "" }];
this.resultLanding.objIdentifier ="re3data_____::db814dc656a911b556dba42a331cebe9";

View File

@ -1,12 +1,12 @@
import { Component } from '@angular/core';
import {Component, Input} from '@angular/core';
@Component({
selector: 'openaire-error',
template: `
<error></error>
<error [page]="page"></error>
`
})
export class OpenaireErrorPageComponent {
@Input() public page: string;
}

View File

@ -21,7 +21,7 @@ export class PiwikHelper{
"rural-digital-europe":319,
"enermaps":318,
"galaxy":453,
"gotriple":null,
"gotriple":490,
"neanias-underwater":474
};
public static getSiteId(communityId:string, environment:string){

View File

@ -57,9 +57,9 @@ export let properties: EnvProperties = {
piwikBaseUrl: 'https://analytics.openaire.eu/piwik.php?idsite=',
piwikSiteId: '80',
registryUrl: 'http://mpagasas.di.uoa.gr:8080/dnet-openaire-users-1.0.0-SNAPSHOT/api/registry/',
loginUrl: "http://dl170.madgik.di.uoa.gr:8180/dnet-login/openid_connect_login",
userInfoUrl: "http://dl170.madgik.di.uoa.gr:8180/dnet-openaire-users-1.0.0-SNAPSHOT/api/users/getUserInfo?accessToken=",
logoutUrl: 'http://dl170.madgik.di.uoa.gr:8180/dnet-login/openid_logout',
loginUrl: "http://mpagasas.di.uoa.gr:8080/dnet-openaire-users-1.0.0-SNAPSHOT/openid_connect_login",
userInfoUrl: "http://mpagasas.di.uoa.gr:8080/dnet-openaire-users-1.0.0-SNAPSHOT/api/users/getUserInfo?accessToken=",
logoutUrl: 'http://mpagasas.di.uoa.gr:8080/dnet-openaire-users-1.0.0-SNAPSHOT/openid_logout',
cookieDomain: '.di.uoa.gr',
feedbackmail: 'openaire.test@gmail.com',
cacheUrl: 'http://dl170.madgik.di.uoa.gr:3000/get?url=',