Merge branch 'develop' into plugins-functionality

This commit is contained in:
argirok 2024-03-07 11:25:58 +02:00
commit 0137e57583
8 changed files with 156 additions and 51 deletions

View File

@ -198,6 +198,30 @@ export function app() {
buildCss(req.params.id, req.params.suffix, variables); buildCss(req.params.id, req.params.suffix, variables);
res.status(200).send({code: 200, message: 'CSS build for ' + req.params.id + ' layout was successful'}); res.status(200).send({code: 200, message: 'CSS build for ' + req.params.id + ' layout was successful'});
}); });
server.get('/health-check', async (_req, res, _next) => {
var uptime = process.uptime();
const date = new Date(uptime*1000);
const days = date.getUTCDate() - 1,
hours = date.getUTCHours(),
minutes = date.getUTCMinutes(),
seconds = date.getUTCSeconds(),
milliseconds = date.getUTCMilliseconds();
const healthcheck = {
uptime: days + " days, " + hours + " hours, " + minutes + " minutes, " + seconds + " seconds, " + milliseconds + " milliseconds",
message: 'OK',
timestamp: new Date()
};
try {
res.send(healthcheck);
} catch (error) {
healthcheck.message = error;
res.status(503).send();
}
});
// Example Express Rest API endpoints // Example Express Rest API endpoints
// server.get('/api/**', (req, res) => { }); // server.get('/api/**', (req, res) => { });
// Serve static files from /browser // Serve static files from /browser

View File

@ -2,7 +2,7 @@ import {NgModule} from '@angular/core';
import {RouterModule, Routes} from '@angular/router'; import {RouterModule, Routes} from '@angular/router';
import {OpenaireErrorPageComponent} from './error/errorPage.component'; import {OpenaireErrorPageComponent} from './error/errorPage.component';
import {PageURLResolverComponent} from "./openaireLibrary/utils/pageURLResolver.component"; import {PageURLResolverComponent} from "./openaireLibrary/utils/pageURLResolver.component";
import {IsCommunity} from "./openaireLibrary/connect/communityGuard/isCommunity.guard"; import {CommunityAccessGuard} from "./utils/communityAccess.guard";
const routes: Routes = [ const routes: Routes = [
// ORCID Pages // ORCID Pages
@ -40,7 +40,7 @@ const routes: Routes = [
{ {
path: 'content', path: 'content',
loadChildren: () => import('./content/contentPage.module').then(m => m.ContentPageModule), loadChildren: () => import('./content/contentPage.module').then(m => m.ContentPageModule),
data: {hasQuickContact: false}, canActivate: [IsCommunity] data: {hasQuickContact: false}, canActivate: [CommunityAccessGuard]
}, },
{ {
path: 'sdgs', path: 'sdgs',
@ -55,22 +55,22 @@ const routes: Routes = [
{ {
path: 'organizations', path: 'organizations',
loadChildren: () => import('./htmlPages/organizations/organizationsPage.module').then(m => m.OrganizationsPageModule), loadChildren: () => import('./htmlPages/organizations/organizationsPage.module').then(m => m.OrganizationsPageModule),
data: {hasQuickContact: false}, canActivate: [IsCommunity] data: {hasQuickContact: false}, canActivate: [CommunityAccessGuard]
}, },
{ {
path: 'publications', path: 'publications',
loadChildren: () => import('./htmlPages/publications/publications-page.module').then(m => m.PublicationsPageModule), loadChildren: () => import('./htmlPages/publications/publications-page.module').then(m => m.PublicationsPageModule),
data: {hasQuickContact: false}, canActivate: [IsCommunity] data: {hasQuickContact: false}, canActivate: [CommunityAccessGuard]
}, },
{ {
path: 'projects', path: 'projects',
loadChildren: () => import('./htmlPages/projects/projectsPage.module').then(m => m.ProjectsPageModule), loadChildren: () => import('./htmlPages/projects/projectsPage.module').then(m => m.ProjectsPageModule),
data: {hasQuickContact: false}, canActivate: [IsCommunity] data: {hasQuickContact: false}, canActivate: [CommunityAccessGuard]
}, },
{ {
path: 'national-bulletins', path: 'national-bulletins',
loadChildren: () => import('./htmlPages/nationalBulletins/nationalBulletinsPage.module').then(m => m.NaionalBulletinPageModule), loadChildren: () => import('./htmlPages/nationalBulletins/nationalBulletinsPage.module').then(m => m.NaionalBulletinPageModule),
data: {hasQuickContact: false}, canActivate: [IsCommunity] data: {hasQuickContact: false}, canActivate: [CommunityAccessGuard]
}, },
{ {
path: 'faqs', path: 'faqs',
@ -88,24 +88,24 @@ const routes: Routes = [
// { // {
// path: '', // path: '',
// loadChildren: () => import('./htmlPages/featured/featuredPage.module').then(m => m.FeaturedPageModule), // loadChildren: () => import('./htmlPages/featured/featuredPage.module').then(m => m.FeaturedPageModule),
// data: {hasQuickContact: false}, canActivateChild: [IsCommunity], // data: {hasQuickContact: false}, canActivateChild: [CommunityAccessGuard],
// }, // },
// { // {
// path: '**', // path: '**',
// loadChildren: () => import('./htmlPages/featured/featuredPage.module').then(m => m.FeaturedPageModule), // loadChildren: () => import('./htmlPages/featured/featuredPage.module').then(m => m.FeaturedPageModule),
// data: {hasQuickContact: false}, canActivateChild: [IsCommunity], // data: {hasQuickContact: false}, canActivateChild: [CommunityAccessGuard],
// }, // },
// ] // ]
// }, // },
{ {
path: 'curators', path: 'curators',
loadChildren: () => import('./openaireLibrary/connect/components/curators/curators.module').then(m => m.CuratorsModule), loadChildren: () => import('./openaireLibrary/connect/components/curators/curators.module').then(m => m.CuratorsModule),
data: {hasQuickContact: false}, canActivate: [IsCommunity] data: {hasQuickContact: false}, canActivate: [CommunityAccessGuard]
}, },
{ {
path: 'subjects', path: 'subjects',
loadChildren: () => import('./subjects/subjects.module').then(m => m.SubjectsModule), loadChildren: () => import('./subjects/subjects.module').then(m => m.SubjectsModule),
data: {hasQuickContact: false}, canActivate: [IsCommunity] data: {hasQuickContact: false}, canActivate: [CommunityAccessGuard]
}, },
{ {
path: 'myCommunities', path: 'myCommunities',
@ -114,7 +114,7 @@ const routes: Routes = [
{ {
path: 'develop', path: 'develop',
loadChildren: () => import('./develop/develop.module').then(m => m.DevelopModule), loadChildren: () => import('./develop/develop.module').then(m => m.DevelopModule),
data: {hasQuickContact: false}, canActivate: [IsCommunity] data: {hasQuickContact: false}, canActivate: [CommunityAccessGuard]
}, },
/** Testing Page for help contents */ /** Testing Page for help contents */
{path: 'helper-test', loadChildren: () => import('./helper-test/helper-test.module').then(m => m.HelperTestModule)}, {path: 'helper-test', loadChildren: () => import('./helper-test/helper-test.module').then(m => m.HelperTestModule)},
@ -122,41 +122,41 @@ const routes: Routes = [
{ {
path: 'search/result', path: 'search/result',
loadChildren: () => import('./landingPages/result/libResult.module').then(m => m.LibResultModule), loadChildren: () => import('./landingPages/result/libResult.module').then(m => m.LibResultModule),
data: {hasQuickContact: false, hasMenuSearchBar: true}, canActivate: [IsCommunity] data: {hasQuickContact: false, hasMenuSearchBar: true}, canActivate: [CommunityAccessGuard]
}, },
{ {
path: 'search/publication', path: 'search/publication',
loadChildren: () => import('./landingPages/publication/libPublication.module').then(m => m.LibPublicationModule), loadChildren: () => import('./landingPages/publication/libPublication.module').then(m => m.LibPublicationModule),
data: {hasQuickContact: false, hasMenuSearchBar: true}, canActivate: [IsCommunity] data: {hasQuickContact: false, hasMenuSearchBar: true}, canActivate: [CommunityAccessGuard]
}, },
{ {
path: 'search/dataset', path: 'search/dataset',
loadChildren: () => import('./landingPages/dataset/libDataset.module').then(m => m.LibDatasetModule), loadChildren: () => import('./landingPages/dataset/libDataset.module').then(m => m.LibDatasetModule),
data: {hasQuickContact: false, hasMenuSearchBar: true}, canActivate: [IsCommunity] data: {hasQuickContact: false, hasMenuSearchBar: true}, canActivate: [CommunityAccessGuard]
}, },
{ {
path: 'search/software', path: 'search/software',
loadChildren: () => import('./landingPages/software/libSoftware.module').then(m => m.LibSoftwareModule), loadChildren: () => import('./landingPages/software/libSoftware.module').then(m => m.LibSoftwareModule),
data: {hasQuickContact: false, hasMenuSearchBar: true}, canActivate: [IsCommunity] data: {hasQuickContact: false, hasMenuSearchBar: true}, canActivate: [CommunityAccessGuard]
}, },
{ {
path: 'search/other', loadChildren: () => import('./landingPages/orp/libOrp.module').then(m => m.LibOrpModule), path: 'search/other', loadChildren: () => import('./landingPages/orp/libOrp.module').then(m => m.LibOrpModule),
data: {hasQuickContact: false, hasMenuSearchBar: true}, canActivate: [IsCommunity] data: {hasQuickContact: false, hasMenuSearchBar: true}, canActivate: [CommunityAccessGuard]
}, },
{ {
path: 'search/project', path: 'search/project',
loadChildren: () => import('./landingPages/project/libProject.module').then(m => m.LibProjectModule), loadChildren: () => import('./landingPages/project/libProject.module').then(m => m.LibProjectModule),
data: {hasQuickContact: false, hasMenuSearchBar: true}, canActivate: [IsCommunity] data: {hasQuickContact: false, hasMenuSearchBar: true}, canActivate: [CommunityAccessGuard]
}, },
{ {
path: 'search/dataprovider', path: 'search/dataprovider',
loadChildren: () => import('././landingPages/dataProvider/libDataProvider.module').then(m => m.LibDataProviderModule), loadChildren: () => import('././landingPages/dataProvider/libDataProvider.module').then(m => m.LibDataProviderModule),
data: {hasQuickContact: false, hasMenuSearchBar: true}, canActivate: [IsCommunity] data: {hasQuickContact: false, hasMenuSearchBar: true}, canActivate: [CommunityAccessGuard]
}, },
{ {
path: 'search/organization', path: 'search/organization',
loadChildren: () => import('./landingPages/organization/libOrganization.module').then(m => m.LibOrganizationModule), loadChildren: () => import('./landingPages/organization/libOrganization.module').then(m => m.LibOrganizationModule),
data: {hasQuickContact: false, hasMenuSearchBar: true}, canActivate: [IsCommunity] data: {hasQuickContact: false, hasMenuSearchBar: true}, canActivate: [CommunityAccessGuard]
}, },
/** Search Pages */ /** Search Pages */
{path: 'search/find', redirectTo: 'search/find/research-outcomes', pathMatch: 'full'}, {path: 'search/find', redirectTo: 'search/find/research-outcomes', pathMatch: 'full'},
@ -168,86 +168,86 @@ const routes: Routes = [
{ {
path: 'search/find/research-outcomes', path: 'search/find/research-outcomes',
loadChildren: () => import('./searchPages/simple/searchResearchResults.module').then(m => m.OpenaireSearchResearchResultsModule), loadChildren: () => import('./searchPages/simple/searchResearchResults.module').then(m => m.OpenaireSearchResearchResultsModule),
data: {hasQuickContact: false}, canActivate: [IsCommunity] data: {hasQuickContact: false}, canActivate: [CommunityAccessGuard]
}, },
{ {
path: 'search/find/publications', path: 'search/find/publications',
component: PageURLResolverComponent, component: PageURLResolverComponent,
data: {hasQuickContact: false}, data: {hasQuickContact: false},
canActivate: [IsCommunity] canActivate: [CommunityAccessGuard]
}, },
{ {
path: 'search/find/datasets', path: 'search/find/datasets',
component: PageURLResolverComponent, component: PageURLResolverComponent,
data: {hasQuickContact: false}, data: {hasQuickContact: false},
canActivate: [IsCommunity] canActivate: [CommunityAccessGuard]
}, },
{ {
path: 'search/find/software', path: 'search/find/software',
component: PageURLResolverComponent, component: PageURLResolverComponent,
data: {hasQuickContact: false}, data: {hasQuickContact: false},
canActivate: [IsCommunity] canActivate: [CommunityAccessGuard]
}, },
{ {
path: 'search/find/other', path: 'search/find/other',
component: PageURLResolverComponent, component: PageURLResolverComponent,
data: {hasQuickContact: false}, data: {hasQuickContact: false},
canActivate: [IsCommunity] canActivate: [CommunityAccessGuard]
}, },
{ {
path: 'search/find/projects', path: 'search/find/projects',
loadChildren: () => import('./searchPages/simple/searchProjects.module').then(m => m.LibSearchProjectsModule), loadChildren: () => import('./searchPages/simple/searchProjects.module').then(m => m.LibSearchProjectsModule),
data: {hasQuickContact: false}, canActivate: [IsCommunity] data: {hasQuickContact: false}, canActivate: [CommunityAccessGuard]
}, },
{ {
path: 'search/find/dataproviders', path: 'search/find/dataproviders',
loadChildren: () => import('./searchPages/simple/searchDataProviders.module').then(m => m.LibSearchDataProvidersModule), loadChildren: () => import('./searchPages/simple/searchDataProviders.module').then(m => m.LibSearchDataProvidersModule),
data: {hasQuickContact: false}, canActivate: [IsCommunity] data: {hasQuickContact: false}, canActivate: [CommunityAccessGuard]
}, },
/** Advanced Search Pages */ /** Advanced Search Pages */
{ {
path: 'search/advanced/research-outcomes', path: 'search/advanced/research-outcomes',
loadChildren: () => import('./searchPages/advanced/searchResearchResults.module').then(m => m.OpenaireAdvancedSearchResearchResultsModule), loadChildren: () => import('./searchPages/advanced/searchResearchResults.module').then(m => m.OpenaireAdvancedSearchResearchResultsModule),
data: {hasQuickContact: false}, canActivate: [IsCommunity] data: {hasQuickContact: false}, canActivate: [CommunityAccessGuard]
}, },
{ {
path: 'search/advanced/publications', path: 'search/advanced/publications',
component: PageURLResolverComponent, component: PageURLResolverComponent,
data: {hasQuickContact: false}, data: {hasQuickContact: false},
canActivate: [IsCommunity] canActivate: [CommunityAccessGuard]
}, },
{ {
path: 'search/advanced/datasets', path: 'search/advanced/datasets',
component: PageURLResolverComponent, component: PageURLResolverComponent,
data: {hasQuickContact: false}, data: {hasQuickContact: false},
canActivate: [IsCommunity] canActivate: [CommunityAccessGuard]
}, },
{ {
path: 'search/advanced/software', path: 'search/advanced/software',
component: PageURLResolverComponent, component: PageURLResolverComponent,
data: {hasQuickContact: false}, data: {hasQuickContact: false},
canActivate: [IsCommunity] canActivate: [CommunityAccessGuard]
}, },
{ {
path: 'search/advanced/other', path: 'search/advanced/other',
component: PageURLResolverComponent, component: PageURLResolverComponent,
data: {hasQuickContact: false}, data: {hasQuickContact: false},
canActivate: [IsCommunity] canActivate: [CommunityAccessGuard]
}, },
{ {
path: 'search/advanced/organizations', path: 'search/advanced/organizations',
loadChildren: () => import('./searchPages/advanced/advancedSearchOrganizations.module').then(m => m.LibAdvancedSearchOrganizationsModule), loadChildren: () => import('./searchPages/advanced/advancedSearchOrganizations.module').then(m => m.LibAdvancedSearchOrganizationsModule),
data: {hasQuickContact: false}, canActivate: [IsCommunity] data: {hasQuickContact: false}, canActivate: [CommunityAccessGuard]
}, },
{ {
path: 'search/advanced/dataproviders', path: 'search/advanced/dataproviders',
loadChildren: () => import('./searchPages/advanced/advancedSearchDataProviders.module').then(m => m.LibAdvancedSearchDataProvidersModule), loadChildren: () => import('./searchPages/advanced/advancedSearchDataProviders.module').then(m => m.LibAdvancedSearchDataProvidersModule),
data: {hasQuickContact: false}, canActivate: [IsCommunity] data: {hasQuickContact: false}, canActivate: [CommunityAccessGuard]
}, },
{ {
path: 'search/advanced/projects', path: 'search/advanced/projects',
loadChildren: () => import('./searchPages/advanced/advancedSearchProjects.module').then(m => m.LibAdvancedSearchProjectsModule), loadChildren: () => import('./searchPages/advanced/advancedSearchProjects.module').then(m => m.LibAdvancedSearchProjectsModule),
data: {hasQuickContact: false}, canActivate: [IsCommunity] data: {hasQuickContact: false}, canActivate: [CommunityAccessGuard]
}, },
/** Deposit Pages */ /** Deposit Pages */
{ path: 'participate/deposit-datasets', { path: 'participate/deposit-datasets',
@ -271,37 +271,37 @@ const routes: Routes = [
{ {
path: 'participate/deposit/learn-how', path: 'participate/deposit/learn-how',
loadChildren: () => import('./deposit/deposit.module').then(m => m.LibDepositModule), loadChildren: () => import('./deposit/deposit.module').then(m => m.LibDepositModule),
data: {hasQuickContact: false}, canActivate: [IsCommunity] data: {hasQuickContact: false}, canActivate: [CommunityAccessGuard]
}, },
{ {
path: 'participate/deposit/search', path: 'participate/deposit/search',
loadChildren: () => import('./deposit/searchDataprovidersToDeposit.module').then(m => m.LibSearchDataprovidersToDepositModule), loadChildren: () => import('./deposit/searchDataprovidersToDeposit.module').then(m => m.LibSearchDataprovidersToDepositModule),
data: {hasQuickContact: false}, canActivate: [IsCommunity] data: {hasQuickContact: false}, canActivate: [CommunityAccessGuard]
}, },
{ {
path: 'participate/deposit/zenodo', path: 'participate/deposit/zenodo',
loadChildren: () => import('./deposit/zenodo/shareInZenodo.module').then(m => m.ShareInZenodoModule), loadChildren: () => import('./deposit/zenodo/shareInZenodo.module').then(m => m.ShareInZenodoModule),
data: {hasQuickContact: false}, canActivate: [IsCommunity] data: {hasQuickContact: false}, canActivate: [CommunityAccessGuard]
}, },
/** Linking Pages */ /** Linking Pages */
{ {
path: 'myclaims', loadChildren: () => import('./claims/myClaims/myClaims.module').then(m => m.LibMyClaimsModule), path: 'myclaims', loadChildren: () => import('./claims/myClaims/myClaims.module').then(m => m.LibMyClaimsModule),
data: {hasQuickContact: false}, canActivate: [IsCommunity] data: {hasQuickContact: false}, canActivate: [CommunityAccessGuard]
}, },
{ {
path: 'participate/claim', path: 'participate/claim',
loadChildren: () => import('./claims/linking/linkingGeneric.module').then(m => m.LibLinkingGenericModule), loadChildren: () => import('./claims/linking/linkingGeneric.module').then(m => m.LibLinkingGenericModule),
data: {hasQuickContact: false}, canActivate: [IsCommunity] data: {hasQuickContact: false}, canActivate: [CommunityAccessGuard]
}, },
{ {
path: 'participate/direct-claim', path: 'participate/direct-claim',
loadChildren: () => import('./claims/directLinking/directLinking.module').then(m => m.LibDirectLinkingModule), loadChildren: () => import('./claims/directLinking/directLinking.module').then(m => m.LibDirectLinkingModule),
data: {hasQuickContact: false}, canActivate: [IsCommunity] data: {hasQuickContact: false}, canActivate: [CommunityAccessGuard]
}, },
{ {
path: 'preview', path: 'preview',
loadChildren: () => import('./demo/demo.module').then(m => m.DemoModule), loadChildren: () => import('./demo/demo.module').then(m => m.DemoModule),
data: {hasQuickContact: false}, canActivate: [IsCommunity] data: {hasQuickContact: false}, canActivate: [CommunityAccessGuard]
}, },
/** help pages - do not exist in Admin portal/api/db */ /** help pages - do not exist in Admin portal/api/db */
{ {

View File

@ -308,11 +308,13 @@ export class AppComponent implements OnInit, OnDestroy {
initAdminToolCommunity(communityId) { initAdminToolCommunity(communityId) {
if (communityId) { if (communityId) {
this.properties.adminToolsPortalType = "community"; this.properties.adminToolsPortalType = "community";
this.properties.adminToolsCommunity = communityId;
if (this.document) { if (this.document) {
this.initLayout(communityId); this.initLayout(communityId);
} }
} else { } else {
this.properties.adminToolsPortalType = "connect"; this.properties.adminToolsPortalType = "connect";
this.properties.adminToolsCommunity = "connect";
if (this.document) { if (this.document) {
this.initLayout(this.communityId?this.communityId:'connect'); this.initLayout(this.communityId?this.communityId:'connect');
} }
@ -376,6 +378,7 @@ export class AppComponent implements OnInit, OnDestroy {
if (this.community && !ConnectHelper.isPrivate(this.community, this.user)) { if (this.community && !ConnectHelper.isPrivate(this.community, this.user)) {
this.communityId = this.community.communityId; this.communityId = this.community.communityId;
this.initAdminToolCommunity(this.communityId); this.initAdminToolCommunity(this.communityId);
this.properties.footerGrantText = ""; //
this.header = { this.header = {
// url: 'https://' + (this.properties.environment == 'beta' ? 'beta.' : '') + this.community.id + '.openaire.eu', // url: 'https://' + (this.properties.environment == 'beta' ? 'beta.' : '') + this.community.id + '.openaire.eu',
route: "/", route: "/",
@ -443,11 +446,14 @@ export class AppComponent implements OnInit, OnDestroy {
this.bottomMenuItems.push(new MenuItem("", "Sources and methodology", "", "/content", false, [], [], {})); this.bottomMenuItems.push(new MenuItem("", "Sources and methodology", "", "/content", false, [], [], {}));
} }
if (this.user) { if (this.user) {
this.userMenuItems = [ /*new MenuItem("","My profile","","",false,[],[],{}),*/ this.userMenuItems = [
new MenuItem("", "My ORCID links", "", "/my-orcid-links", false, [], [], {}),
new MenuItem("", "My links", "", "/myclaims", false, [], ["/myclaims"], {}), new MenuItem("", "My links", "", "/myclaims", false, [], ["/myclaims"], {}),
new MenuItem("", "Invite users", "", "/invite", false, [], [], {}), new MenuItem("", "Invite users", "", "/invite", false, [], [], {}),
]; ];
if(properties.environment != 'beta'){
this.userMenuItems = [new MenuItem("", "My ORCID links", "", "/my-orcid-links", false, [], [], {})]
.concat(this.userMenuItems)
}
if (this.isManager) { if (this.isManager) {
this.userMenuItems.push(new MenuItem("", "Support", "https://tools.openaire.eu/group/openaire_rcd", "", false, [], [], {})) this.userMenuItems.push(new MenuItem("", "Support", "https://tools.openaire.eu/group/openaire_rcd", "", false, [], [], {}))
} }

View File

@ -22,12 +22,12 @@ import {PageURLResolverModule} from "./openaireLibrary/utils/pageURLResolver.mod
import {Schema2jsonldModule} from "./openaireLibrary/sharedComponents/schema2jsonld/schema2jsonld.module"; import {Schema2jsonldModule} from "./openaireLibrary/sharedComponents/schema2jsonld/schema2jsonld.module";
import {DEFAULT_TIMEOUT, TimeoutInterceptor} from "./openaireLibrary/timeout-interceptor.service"; import {DEFAULT_TIMEOUT, TimeoutInterceptor} from "./openaireLibrary/timeout-interceptor.service";
import {ErrorInterceptorService} from "./openaireLibrary/error-interceptor.service"; import {ErrorInterceptorService} from "./openaireLibrary/error-interceptor.service";
import {IsCommunity} from "./openaireLibrary/connect/communityGuard/isCommunity.guard";
import {SubscribeService} from "./openaireLibrary/utils/subscribe/subscribe.service"; import {SubscribeService} from "./openaireLibrary/utils/subscribe/subscribe.service";
import {RoleVerificationModule} from "./openaireLibrary/role-verification/role-verification.module"; import {RoleVerificationModule} from "./openaireLibrary/role-verification/role-verification.module";
import {QuickContactModule} from "./openaireLibrary/sharedComponents/quick-contact/quick-contact.module"; import {QuickContactModule} from "./openaireLibrary/sharedComponents/quick-contact/quick-contact.module";
import {AlertModalModule} from "./openaireLibrary/utils/modal/alertModal.module"; import {AlertModalModule} from "./openaireLibrary/utils/modal/alertModal.module";
import {CustomizationService} from "./openaireLibrary/services/customization.service"; import {CustomizationService} from "./openaireLibrary/services/customization.service";
import {CommunityAccessGuard} from "./utils/communityAccess.guard";
@NgModule({ @NgModule({
@ -49,7 +49,7 @@ import {CustomizationService} from "./openaireLibrary/services/customization.ser
declarations: [AppComponent, OpenaireErrorPageComponent], declarations: [AppComponent, OpenaireErrorPageComponent],
exports: [AppComponent], exports: [AppComponent],
providers: [ providers: [
CommunitiesService, CustomizationService, IsCommunity, SubscribeService, CommunitiesService, CustomizationService, CommunityAccessGuard, SubscribeService,
{provide: APP_ID, useValue: 'serverApp'}, {provide: APP_ID, useValue: 'serverApp'},
{ {
provide: HTTP_INTERCEPTORS, provide: HTTP_INTERCEPTORS,

View File

@ -8,13 +8,12 @@ import {properties} from "../../../environments/environment";
@Component({ @Component({
selector: 'openaire-my-claims', selector: 'openaire-my-claims',
template: ` template: `
<my-claims [claimsInfoURL]=claimsInfoURL [userInfoURL]="userInfoURL" [communityId]=communityId></my-claims> <my-claims [claimsInfoURL]="claimsInfoURL" [communityId]=communityId></my-claims>
` `
}) })
export class OpenaireMyClaimsComponent { export class OpenaireMyClaimsComponent {
claimsInfoURL:string; claimsInfoURL:string;
userInfoURL: string;
communityId:string; communityId:string;
sub; sub;
@ -27,8 +26,7 @@ import {properties} from "../../../environments/environment";
} }
public ngOnInit() { public ngOnInit() {
this.claimsInfoURL = properties.claimsInformationLink; this.claimsInfoURL = properties.claimsInformationLink;
this.userInfoURL = properties.userInfoUrl;
this.sub = this.route.queryParams.subscribe( this.sub = this.route.queryParams.subscribe(
communityId => { communityId => {
this.communityId = ConnectHelper.getCommunityFromDomain(properties.domain); this.communityId = ConnectHelper.getCommunityFromDomain(properties.domain);

@ -1 +1 @@
Subproject commit 552edbd0e25e236dc277abcdcc2d953d28bba726 Subproject commit 2bb981c489d3ce1c1fd1b2acded9015d9b3dbe33

View File

@ -97,7 +97,7 @@ export class SearchCommunitiesComponent {
this.searchPage.refineFields = this.refineFields; this.searchPage.refineFields = this.refineFields;
this.searchLink = this.properties.searchLinkToCommunities; this.searchLink = this.properties.searchLinkToCommunities;
this.selectedFields = []; this.selectedFields = [];
this.searchPage.prepareSearchPage(this.fieldIds, this.selectedFields, this.refineFields, [], this.fieldIdsMap, null, params, "community", null); this.searchPage.prepareSearchPage(this.fieldIds, this.selectedFields, this.refineFields, [],[], this.fieldIdsMap, null, params, "community", null);
let queryParams = params; let queryParams = params;
if (typeof document !== 'undefined') { if (typeof document !== 'undefined') {

View File

@ -0,0 +1,77 @@
import {Injectable} from '@angular/core';
import {ActivatedRouteSnapshot, Router, RouterStateSnapshot, UrlTree} from '@angular/router';
import {forkJoin, Observable} from 'rxjs';
import {CommunityService} from "../openaireLibrary/connect/community/community.service";
import {UserManagementService} from "../openaireLibrary/services/user-management.service";
import {ConnectHelper} from "../openaireLibrary/connect/connectHelper";
import {properties} from "../../environments/environment";
import {map, take} from "rxjs/operators";
import {LoginErrorCodes} from "../openaireLibrary/login/utils/guardHelper.class";
import {Session} from "../openaireLibrary/login/utils/helper.class";
@Injectable()
export class CommunityAccessGuard {
constructor(private router: Router,
private communityService: CommunityService, private userManagementService: UserManagementService) {
}
check(path: string): Observable<boolean> | boolean {
let community = ConnectHelper.getCommunityFromDomain(properties.domain);
if (!community) {
this.router.navigate([properties.errorLink], {queryParams: {page: path}});
return false;
}
return forkJoin([
this.userManagementService.getUserInfo().pipe(take(1)),
this.communityService.getCommunity(community).pipe(take(1))
]).pipe(
map(([user, communityInfo]) => {
console.log(user, communityInfo)
if (communityInfo) {
console.log(communityInfo.status)
if (communityInfo.isPublic()) {
return true;
} else if (communityInfo.isPrivate()) {
this.router.navigate([properties.errorLink], {queryParams: {page: path}});
return false;
} else {
if (!user) {
this.router.navigate(['/user-info'], {
queryParams: {
'errorCode': LoginErrorCodes.NOT_LOGIN,
'redirectUrl': path
}
})
return false;
}
if (Session.isPortalAdministrator(user) || Session.isCommunityCurator(user) || Session.isManager('community', community, user) || Session.isSubscribedTo('community', community, user)) {
console.log("user: has access")
return true;
} else {
this.router.navigate(['/user-info'], {
queryParams: {
'errorCode': LoginErrorCodes.NOT_AUTHORIZED,
'redirectUrl': path
}
})
return false;
}
}
}
this.router.navigate([properties.errorLink], {queryParams: {page: path}});
return false;
})
);
}
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree {
return this.check(state.url);
}
canActivateChild(childRoute: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree {
return this.check(state.url);
}
}