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);
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
// server.get('/api/**', (req, res) => { });
// Serve static files from /browser

View File

@ -2,7 +2,7 @@ import {NgModule} from '@angular/core';
import {RouterModule, Routes} from '@angular/router';
import {OpenaireErrorPageComponent} from './error/errorPage.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 = [
// ORCID Pages
@ -40,7 +40,7 @@ const routes: Routes = [
{
path: 'content',
loadChildren: () => import('./content/contentPage.module').then(m => m.ContentPageModule),
data: {hasQuickContact: false}, canActivate: [IsCommunity]
data: {hasQuickContact: false}, canActivate: [CommunityAccessGuard]
},
{
path: 'sdgs',
@ -55,22 +55,22 @@ const routes: Routes = [
{
path: 'organizations',
loadChildren: () => import('./htmlPages/organizations/organizationsPage.module').then(m => m.OrganizationsPageModule),
data: {hasQuickContact: false}, canActivate: [IsCommunity]
data: {hasQuickContact: false}, canActivate: [CommunityAccessGuard]
},
{
path: 'publications',
loadChildren: () => import('./htmlPages/publications/publications-page.module').then(m => m.PublicationsPageModule),
data: {hasQuickContact: false}, canActivate: [IsCommunity]
data: {hasQuickContact: false}, canActivate: [CommunityAccessGuard]
},
{
path: 'projects',
loadChildren: () => import('./htmlPages/projects/projectsPage.module').then(m => m.ProjectsPageModule),
data: {hasQuickContact: false}, canActivate: [IsCommunity]
data: {hasQuickContact: false}, canActivate: [CommunityAccessGuard]
},
{
path: 'national-bulletins',
loadChildren: () => import('./htmlPages/nationalBulletins/nationalBulletinsPage.module').then(m => m.NaionalBulletinPageModule),
data: {hasQuickContact: false}, canActivate: [IsCommunity]
data: {hasQuickContact: false}, canActivate: [CommunityAccessGuard]
},
{
path: 'faqs',
@ -88,24 +88,24 @@ const routes: Routes = [
// {
// path: '',
// loadChildren: () => import('./htmlPages/featured/featuredPage.module').then(m => m.FeaturedPageModule),
// data: {hasQuickContact: false}, canActivateChild: [IsCommunity],
// data: {hasQuickContact: false}, canActivateChild: [CommunityAccessGuard],
// },
// {
// path: '**',
// loadChildren: () => import('./htmlPages/featured/featuredPage.module').then(m => m.FeaturedPageModule),
// data: {hasQuickContact: false}, canActivateChild: [IsCommunity],
// data: {hasQuickContact: false}, canActivateChild: [CommunityAccessGuard],
// },
// ]
// },
{
path: 'curators',
loadChildren: () => import('./openaireLibrary/connect/components/curators/curators.module').then(m => m.CuratorsModule),
data: {hasQuickContact: false}, canActivate: [IsCommunity]
data: {hasQuickContact: false}, canActivate: [CommunityAccessGuard]
},
{
path: 'subjects',
loadChildren: () => import('./subjects/subjects.module').then(m => m.SubjectsModule),
data: {hasQuickContact: false}, canActivate: [IsCommunity]
data: {hasQuickContact: false}, canActivate: [CommunityAccessGuard]
},
{
path: 'myCommunities',
@ -114,7 +114,7 @@ const routes: Routes = [
{
path: 'develop',
loadChildren: () => import('./develop/develop.module').then(m => m.DevelopModule),
data: {hasQuickContact: false}, canActivate: [IsCommunity]
data: {hasQuickContact: false}, canActivate: [CommunityAccessGuard]
},
/** Testing Page for help contents */
{path: 'helper-test', loadChildren: () => import('./helper-test/helper-test.module').then(m => m.HelperTestModule)},
@ -122,41 +122,41 @@ const routes: Routes = [
{
path: 'search/result',
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',
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',
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',
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),
data: {hasQuickContact: false, hasMenuSearchBar: true}, canActivate: [IsCommunity]
data: {hasQuickContact: false, hasMenuSearchBar: true}, canActivate: [CommunityAccessGuard]
},
{
path: 'search/project',
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',
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',
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 */
{path: 'search/find', redirectTo: 'search/find/research-outcomes', pathMatch: 'full'},
@ -168,86 +168,86 @@ const routes: Routes = [
{
path: 'search/find/research-outcomes',
loadChildren: () => import('./searchPages/simple/searchResearchResults.module').then(m => m.OpenaireSearchResearchResultsModule),
data: {hasQuickContact: false}, canActivate: [IsCommunity]
data: {hasQuickContact: false}, canActivate: [CommunityAccessGuard]
},
{
path: 'search/find/publications',
component: PageURLResolverComponent,
data: {hasQuickContact: false},
canActivate: [IsCommunity]
canActivate: [CommunityAccessGuard]
},
{
path: 'search/find/datasets',
component: PageURLResolverComponent,
data: {hasQuickContact: false},
canActivate: [IsCommunity]
canActivate: [CommunityAccessGuard]
},
{
path: 'search/find/software',
component: PageURLResolverComponent,
data: {hasQuickContact: false},
canActivate: [IsCommunity]
canActivate: [CommunityAccessGuard]
},
{
path: 'search/find/other',
component: PageURLResolverComponent,
data: {hasQuickContact: false},
canActivate: [IsCommunity]
canActivate: [CommunityAccessGuard]
},
{
path: 'search/find/projects',
loadChildren: () => import('./searchPages/simple/searchProjects.module').then(m => m.LibSearchProjectsModule),
data: {hasQuickContact: false}, canActivate: [IsCommunity]
data: {hasQuickContact: false}, canActivate: [CommunityAccessGuard]
},
{
path: 'search/find/dataproviders',
loadChildren: () => import('./searchPages/simple/searchDataProviders.module').then(m => m.LibSearchDataProvidersModule),
data: {hasQuickContact: false}, canActivate: [IsCommunity]
data: {hasQuickContact: false}, canActivate: [CommunityAccessGuard]
},
/** Advanced Search Pages */
{
path: 'search/advanced/research-outcomes',
loadChildren: () => import('./searchPages/advanced/searchResearchResults.module').then(m => m.OpenaireAdvancedSearchResearchResultsModule),
data: {hasQuickContact: false}, canActivate: [IsCommunity]
data: {hasQuickContact: false}, canActivate: [CommunityAccessGuard]
},
{
path: 'search/advanced/publications',
component: PageURLResolverComponent,
data: {hasQuickContact: false},
canActivate: [IsCommunity]
canActivate: [CommunityAccessGuard]
},
{
path: 'search/advanced/datasets',
component: PageURLResolverComponent,
data: {hasQuickContact: false},
canActivate: [IsCommunity]
canActivate: [CommunityAccessGuard]
},
{
path: 'search/advanced/software',
component: PageURLResolverComponent,
data: {hasQuickContact: false},
canActivate: [IsCommunity]
canActivate: [CommunityAccessGuard]
},
{
path: 'search/advanced/other',
component: PageURLResolverComponent,
data: {hasQuickContact: false},
canActivate: [IsCommunity]
canActivate: [CommunityAccessGuard]
},
{
path: 'search/advanced/organizations',
loadChildren: () => import('./searchPages/advanced/advancedSearchOrganizations.module').then(m => m.LibAdvancedSearchOrganizationsModule),
data: {hasQuickContact: false}, canActivate: [IsCommunity]
data: {hasQuickContact: false}, canActivate: [CommunityAccessGuard]
},
{
path: 'search/advanced/dataproviders',
loadChildren: () => import('./searchPages/advanced/advancedSearchDataProviders.module').then(m => m.LibAdvancedSearchDataProvidersModule),
data: {hasQuickContact: false}, canActivate: [IsCommunity]
data: {hasQuickContact: false}, canActivate: [CommunityAccessGuard]
},
{
path: 'search/advanced/projects',
loadChildren: () => import('./searchPages/advanced/advancedSearchProjects.module').then(m => m.LibAdvancedSearchProjectsModule),
data: {hasQuickContact: false}, canActivate: [IsCommunity]
data: {hasQuickContact: false}, canActivate: [CommunityAccessGuard]
},
/** Deposit Pages */
{ path: 'participate/deposit-datasets',
@ -271,37 +271,37 @@ const routes: Routes = [
{
path: 'participate/deposit/learn-how',
loadChildren: () => import('./deposit/deposit.module').then(m => m.LibDepositModule),
data: {hasQuickContact: false}, canActivate: [IsCommunity]
data: {hasQuickContact: false}, canActivate: [CommunityAccessGuard]
},
{
path: 'participate/deposit/search',
loadChildren: () => import('./deposit/searchDataprovidersToDeposit.module').then(m => m.LibSearchDataprovidersToDepositModule),
data: {hasQuickContact: false}, canActivate: [IsCommunity]
data: {hasQuickContact: false}, canActivate: [CommunityAccessGuard]
},
{
path: 'participate/deposit/zenodo',
loadChildren: () => import('./deposit/zenodo/shareInZenodo.module').then(m => m.ShareInZenodoModule),
data: {hasQuickContact: false}, canActivate: [IsCommunity]
data: {hasQuickContact: false}, canActivate: [CommunityAccessGuard]
},
/** Linking Pages */
{
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',
loadChildren: () => import('./claims/linking/linkingGeneric.module').then(m => m.LibLinkingGenericModule),
data: {hasQuickContact: false}, canActivate: [IsCommunity]
data: {hasQuickContact: false}, canActivate: [CommunityAccessGuard]
},
{
path: 'participate/direct-claim',
loadChildren: () => import('./claims/directLinking/directLinking.module').then(m => m.LibDirectLinkingModule),
data: {hasQuickContact: false}, canActivate: [IsCommunity]
data: {hasQuickContact: false}, canActivate: [CommunityAccessGuard]
},
{
path: 'preview',
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 */
{

View File

@ -308,11 +308,13 @@ export class AppComponent implements OnInit, OnDestroy {
initAdminToolCommunity(communityId) {
if (communityId) {
this.properties.adminToolsPortalType = "community";
this.properties.adminToolsCommunity = communityId;
if (this.document) {
this.initLayout(communityId);
}
} else {
this.properties.adminToolsPortalType = "connect";
this.properties.adminToolsCommunity = "connect";
if (this.document) {
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)) {
this.communityId = this.community.communityId;
this.initAdminToolCommunity(this.communityId);
this.properties.footerGrantText = ""; //
this.header = {
// url: 'https://' + (this.properties.environment == 'beta' ? 'beta.' : '') + this.community.id + '.openaire.eu',
route: "/",
@ -443,11 +446,14 @@ export class AppComponent implements OnInit, OnDestroy {
this.bottomMenuItems.push(new MenuItem("", "Sources and methodology", "", "/content", false, [], [], {}));
}
if (this.user) {
this.userMenuItems = [ /*new MenuItem("","My profile","","",false,[],[],{}),*/
new MenuItem("", "My ORCID links", "", "/my-orcid-links", false, [], [], {}),
this.userMenuItems = [
new MenuItem("", "My links", "", "/myclaims", false, [], ["/myclaims"], {}),
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) {
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 {DEFAULT_TIMEOUT, TimeoutInterceptor} from "./openaireLibrary/timeout-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 {RoleVerificationModule} from "./openaireLibrary/role-verification/role-verification.module";
import {QuickContactModule} from "./openaireLibrary/sharedComponents/quick-contact/quick-contact.module";
import {AlertModalModule} from "./openaireLibrary/utils/modal/alertModal.module";
import {CustomizationService} from "./openaireLibrary/services/customization.service";
import {CommunityAccessGuard} from "./utils/communityAccess.guard";
@NgModule({
@ -49,7 +49,7 @@ import {CustomizationService} from "./openaireLibrary/services/customization.ser
declarations: [AppComponent, OpenaireErrorPageComponent],
exports: [AppComponent],
providers: [
CommunitiesService, CustomizationService, IsCommunity, SubscribeService,
CommunitiesService, CustomizationService, CommunityAccessGuard, SubscribeService,
{provide: APP_ID, useValue: 'serverApp'},
{
provide: HTTP_INTERCEPTORS,

View File

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