Merge remote-tracking branch 'origin/new-theme' into new-theme

This commit is contained in:
argirok 2022-07-05 16:43:32 +03:00
commit 803dc0a2d9
39 changed files with 1105 additions and 1203 deletions

View File

@ -15,6 +15,7 @@ import {ConnectHelper} from './openaireLibrary/connect/connectHelper';
import {ConfigurationService} from './openaireLibrary/utils/configuration/configuration.service'; import {ConfigurationService} from './openaireLibrary/utils/configuration/configuration.service';
import {StringUtils} from "./openaireLibrary/utils/string-utils.class"; import {StringUtils} from "./openaireLibrary/utils/string-utils.class";
import {OpenaireEntities} from "./openaireLibrary/utils/properties/searchFields"; import {OpenaireEntities} from "./openaireLibrary/utils/properties/searchFields";
import {mining} from "./openaireLibrary/utils/icons/icons";
@Component({ @Component({
selector: 'app-root', selector: 'app-root',
@ -215,7 +216,7 @@ export class AppComponent implements OnInit {
this.sideBarItems.push(new MenuItem("admin-tools", "Pages & Entities", "", "/" + this.community.communityId + "/admin-tools/pages", false, [], [], {}, {name: 'description'}, null, null, "/" + this.community.communityId + "/admin-tools")); this.sideBarItems.push(new MenuItem("admin-tools", "Pages & Entities", "", "/" + this.community.communityId + "/admin-tools/pages", false, [], [], {}, {name: 'description'}, null, null, "/" + this.community.communityId + "/admin-tools"));
this.sideBarItems.push(new MenuItem("customization", "Customization", "", "/" + this.community.communityId + "/customize-layout", false, [], [], {}, {name: 'brush'})); this.sideBarItems.push(new MenuItem("customization", "Customization", "", "/" + this.community.communityId + "/customize-layout", false, [], [], {}, {name: 'brush'}));
if (this.community.type === 'ri') { if (this.community.type === 'ri') {
this.sideBarItems.push(new MenuItem("mining", "Mining", "", "/" + this.community.communityId + "/mining/manage-profiles", false, [], [], {}, {name: 'architecture'}, null, null, "/" + this.community.communityId + "/mining")); this.sideBarItems.push(new MenuItem("mining", "Mining", "", "/" + this.community.communityId + "/mining/manage-profiles", false, [], [], {}, {svg: mining.data}, null, null, "/" + this.community.communityId + "/mining"));
} }
this.specialSideBarMenuItem = new MenuItem("back", "Manage communities", "", "/", false, [], null, {}, {name: 'search', class: 'uk-text-secondary'}); this.specialSideBarMenuItem = new MenuItem("back", "Manage communities", "", "/", false, [], null, {}, {name: 'search', class: 'uk-text-secondary'});

View File

@ -11,7 +11,6 @@ import {IsCommunity} from './openaireLibrary/connect/communityGuard/isCommunity.
import {AdminErrorPageComponent} from './pages/error/errorPage.component'; import {AdminErrorPageComponent} from './pages/error/errorPage.component';
import {ErrorModule} from './openaireLibrary/error/error.module'; import {ErrorModule} from './openaireLibrary/error/error.module';
import {TitleCasePipe} from '@angular/common'; import {TitleCasePipe} from '@angular/common';
import {CommunityService} from './openaireLibrary/connect/community/community.service';
import {SubscribeService} from './openaireLibrary/utils/subscribe/subscribe.service'; import {SubscribeService} from './openaireLibrary/utils/subscribe/subscribe.service';
import {ConnectRIGuard} from './openaireLibrary/connect/communityGuard/connectRIGuard.guard'; import {ConnectRIGuard} from './openaireLibrary/connect/communityGuard/connectRIGuard.guard';
import {BrowserAnimationsModule} from '@angular/platform-browser/animations'; import {BrowserAnimationsModule} from '@angular/platform-browser/animations';

@ -1 +1 @@
Subproject commit e61d4495aee212f7e991f0ad9c54c0429cf01757 Subproject commit f08c63d3849e966bcfe916f0ca48788e0b401306

View File

@ -40,8 +40,8 @@
<div class="uk-card uk-card-default"> <div class="uk-card uk-card-default">
<div class="uk-card-body"> <div class="uk-card-body">
<div class="uk-flex uk-flex-middle uk-flex-column"> <div class="uk-flex uk-flex-middle uk-flex-column">
<div class="uk-flex uk-flex-center"> <div class="uk-flex uk-flex-center uk-height-xsmall">
<img class="uk-height-xsmall uk-blend-multiply" [src]="affiliation.logo_url | urlPrefix"> <img class="uk-height-max-xsmall uk-blend-multiply" [src]="affiliation.logo_url | urlPrefix">
</div> </div>
<h5>{{affiliation.name}}</h5> <h5>{{affiliation.name}}</h5>
<div class="uk-text-truncate uk-text-small"> <div class="uk-text-truncate uk-text-small">
@ -87,7 +87,7 @@
</div> </div>
</div> </div>
</div> </div>
<modal-alert #affiliationModal [okDisabled]="affiliationFb && affiliationFb.invalid" (alertOutput)="editAffiliation()"> <modal-alert #affiliationModal [okDisabled]="affiliationFb && affiliationFb.invalid" (alertOutput)="editAffiliation()" classTitle="uk-background-primary uk-light">
<form *ngIf="affiliationFb" [formGroup]="affiliationFb"> <form *ngIf="affiliationFb" [formGroup]="affiliationFb">
<div class="uk-grid uk-child-width-1-1" uk-grid> <div class="uk-grid uk-child-width-1-1" uk-grid>
<div input placeholder="Name" [formInput]="affiliationFb.get('name')"></div> <div input placeholder="Name" [formInput]="affiliationFb.get('name')"></div>
@ -96,5 +96,5 @@
</div> </div>
</form> </form>
</modal-alert> </modal-alert>
<modal-alert #removeAffiliationModal [overflowBody]="false" (alertOutput)="removeAffiliation()"> <modal-alert #removeAffiliationModal [overflowBody]="false" (alertOutput)="removeAffiliation()" classTitle="uk-background-primary uk-light">
</modal-alert> </modal-alert>

View File

@ -15,6 +15,7 @@ import {Subscription} from "rxjs";
import {CommunityService} from "../../openaireLibrary/connect/community/community.service"; import {CommunityService} from "../../openaireLibrary/connect/community/community.service";
import {CommunityInfo} from "../../openaireLibrary/connect/community/communityInfo"; import {CommunityInfo} from "../../openaireLibrary/connect/community/communityInfo";
import {NotificationHandler} from "../../openaireLibrary/utils/notification-handler"; import {NotificationHandler} from "../../openaireLibrary/utils/notification-handler";
import {HelperFunctions} from "../../openaireLibrary/utils/HelperFunctions.class";
@Component({ @Component({
selector: 'affiliations', selector: 'affiliations',
@ -67,8 +68,7 @@ export class AffiliationsComponent implements OnInit, OnDestroy {
getAffiliations() { getAffiliations() {
this.loading = true; this.loading = true;
this.affiliationService.initAffiliations(this.community.communityId); this.affiliationService.getAffiliations(this.community.communityId).subscribe(
this.affiliationService.affiliations.subscribe(
affiliations => { affiliations => {
this.affiliations = affiliations; this.affiliations = affiliations;
this.loading = false; this.loading = false;
@ -133,6 +133,7 @@ export class AffiliationsComponent implements OnInit, OnDestroy {
} }
public updatePage(event) { public updatePage(event) {
HelperFunctions.scroll();
this.page = event.value; this.page = event.value;
} }

View File

@ -13,8 +13,6 @@ import {InputModule} from "../../openaireLibrary/sharedComponents/input/input.mo
import {PageContentModule} from "../../openaireLibrary/dashboard/sharedComponents/page-content/page-content.module"; import {PageContentModule} from "../../openaireLibrary/dashboard/sharedComponents/page-content/page-content.module";
import {CommunityInfoModule} from "../community-info/community-info.module"; import {CommunityInfoModule} from "../community-info/community-info.module";
import {IconsModule} from "../../openaireLibrary/utils/icons/icons.module"; import {IconsModule} from "../../openaireLibrary/utils/icons/icons.module";
import {IconsService} from "../../openaireLibrary/utils/icons/icons.service";
import {add, edit, preview, remove} from "../../openaireLibrary/utils/icons/icons";
import {NoLoadPaging} from "../../openaireLibrary/searchPages/searchUtils/no-load-paging.module"; import {NoLoadPaging} from "../../openaireLibrary/searchPages/searchUtils/no-load-paging.module";
import {LoadingModule} from "../../openaireLibrary/utils/loading/loading.module"; import {LoadingModule} from "../../openaireLibrary/utils/loading/loading.module";
import {UrlPrefixModule} from "../../openaireLibrary/utils/pipes/url-prefix.module"; import {UrlPrefixModule} from "../../openaireLibrary/utils/pipes/url-prefix.module";
@ -38,8 +36,4 @@ import {PagingModule} from "../../openaireLibrary/utils/paging.module";
}) })
export class AffiliationsModule { export class AffiliationsModule {
constructor(private iconsService: IconsService) {
this.iconsService.registerIcons([add, preview, remove])
}
} }

View File

@ -10,7 +10,6 @@ import {ConnectCommunityGuard} from "../../openaireLibrary/connect/communityGuar
{path: 'organizations', loadChildren: () => import('../affiliations/affiliations.module').then(m => m.AffiliationsModule)}, {path: 'organizations', loadChildren: () => import('../affiliations/affiliations.module').then(m => m.AffiliationsModule)},
{path: 'projects', loadChildren: () => import('../projects/communityProjects.module').then(m => m.CommunityProjectsModule)}, {path: 'projects', loadChildren: () => import('../projects/communityProjects.module').then(m => m.CommunityProjectsModule)},
{path: 'content-providers', loadChildren: () => import('../content-providers/communityContentProviders.module').then(m => m.CommunityContentProvidersModule)}, {path: 'content-providers', loadChildren: () => import('../content-providers/communityContentProviders.module').then(m => m.CommunityContentProvidersModule)},
{path: 'content-providers/:provider', loadChildren: () => import('../content-providers/criteria/criteria.module').then(m => m.CriteriaModule)},
{path: 'zenodo-communities', loadChildren: () => import('../zenodo-communities/zenodo-communities.module').then(m => m.ZenodoCommunitiesModule)}, {path: 'zenodo-communities', loadChildren: () => import('../zenodo-communities/zenodo-communities.module').then(m => m.ZenodoCommunitiesModule)},
{path: 'subjects', canActivateChild: [ConnectCommunityGuard], loadChildren: () => import('../subjects/subjects-edit-form/subjects-edit-form.module').then(m => m.SubjectsEditFormModule)}, {path: 'subjects', canActivateChild: [ConnectCommunityGuard], loadChildren: () => import('../subjects/subjects-edit-form/subjects-edit-form.module').then(m => m.SubjectsEditFormModule)},
]) ])

View File

@ -2,17 +2,18 @@ import {Component, Input, OnInit} from '@angular/core';
import {CommunityInfo} from '../../openaireLibrary/connect/community/communityInfo'; import {CommunityInfo} from '../../openaireLibrary/connect/community/communityInfo';
import {CommunityService} from '../../openaireLibrary/connect/community/community.service'; import {CommunityService} from '../../openaireLibrary/connect/community/community.service';
import {Subscription} from 'rxjs'; import {Subscription} from 'rxjs';
import {OpenaireEntities} from "../../openaireLibrary/utils/properties/searchFields";
@Component({ @Component({
selector: 'community-info', selector: 'community-info',
template: ` template: `
<ul *ngIf="community" class="uk-tab customTabs admin uk-flex uk-flex-center uk-flex-left@m" uk-tab> <ul *ngIf="community" class="uk-tab uk-flex uk-flex-center uk-flex-left@m" uk-tab>
<li [class.uk-active]="tab === 'profile'"><a routerLink="../profile"><span class="title">Profile</span></a></li> <li [class.uk-active]="tab === 'profile'"><a routerLink="../profile">Profile</a></li>
<li [class.uk-active]="tab === 'organizations'"><a routerLink="../organizations"><span class="title">Organizations</span></a></li> <li [class.uk-active]="tab === 'organizations'"><a routerLink="../organizations">Organizations</a></li>
<li [class.uk-active]="tab === 'projects'"><a routerLink="../projects"><span class="title">Projects</span></a></li> <li [class.uk-active]="tab === 'projects'"><a routerLink="../projects">{{openAIREEntities.PROJECTS}}</a></li>
<li [class.uk-active]="tab === 'content-providers'"><a routerLink="../content-providers"><span class="title">Content Providers</span></a></li> <li [class.uk-active]="tab === 'content-providers'"><a routerLink="../content-providers">{{openAIREEntities.DATASOURCES}}</a></li>
<li *ngIf="community.type !='ri'" [class.uk-active]="tab === 'subjects'"><a routerLink="../subjects"><span class="title">Subjects</span></a></li> <li *ngIf="community.type !='ri'" [class.uk-active]="tab === 'subjects'"><a routerLink="../subjects">Subjects</a></li>
<li [class.uk-active]="tab === 'zenodo-communities'"><a routerLink="../zenodo-communities"><span class="title">Zenodo Communities</span></a></li> <li [class.uk-active]="tab === 'zenodo-communities'"><a routerLink="../zenodo-communities">Zenodo Communities</a></li>
</ul> </ul>
` `
}) })
@ -22,6 +23,7 @@ export class CommunityInfoComponent implements OnInit {
@Input() @Input()
public tab: "profile"| "organizations" | "projects" | "content-providers" | "subjects" | "zenodo-communities" = 'profile'; public tab: "profile"| "organizations" | "projects" | "content-providers" | "subjects" | "zenodo-communities" = 'profile';
public community: CommunityInfo; public community: CommunityInfo;
public openAIREEntities = OpenaireEntities;
private sub; private sub;
constructor(private communityService: CommunityService) { constructor(private communityService: CommunityService) {

View File

@ -2,7 +2,7 @@
<div class="uk-width-auto uk-margin-right"> <div class="uk-width-auto uk-margin-right">
<a uk-icon="icon: info; ratio: 1.3"></a> <a uk-icon="icon: info; ratio: 1.3"></a>
<div *ngIf="community" class="uk-dropdown uk-padding-small uk-width-medium" uk-dropdown="mode: hover"> <div *ngIf="community" class="uk-dropdown uk-padding-small uk-width-medium" uk-dropdown="mode: hover">
If you cannot find a content provider relevant to your community, probably it is not OpenAIRE compliant. If you cannot find a <span class="uk-text-lowercase">{{openAIREEntities.DATASOURCE}}</span> relevant to your community, probably it is not OpenAIRE compliant.
Feel free to contact us Feel free to contact us
(<a (<a
[href]="'mailto:' + properties.feedbackmailForMissingEntities +'?Subject=[OpenAIRE Connect - '+ community.shortTitle + '] report missing Funder' + '&body=' + body" [href]="'mailto:' + properties.feedbackmailForMissingEntities +'?Subject=[OpenAIRE Connect - '+ community.shortTitle + '] report missing Funder' + '&body=' + body"
@ -11,7 +11,7 @@
</div> </div>
</div> </div>
<div search-input class="uk-width-xlarge@l uk-width-large" [searchControl]="filterForm.get('keyword')" searchInputClass="outer" <div search-input class="uk-width-xlarge@l uk-width-large" [searchControl]="filterForm.get('keyword')" searchInputClass="outer"
placeholder="Search Content Providers" [disabled]="loading"></div> [placeholder]="'Search ' + openAIREEntities.DATASOURCES" [disabled]="loading"></div>
</div> </div>
<div class="uk-section uk-section-small uk-position-relative"> <div class="uk-section uk-section-small uk-position-relative">
<div *ngIf="openaireSearchUtils.status == errorCodes.LOADING" class="uk-position-center"> <div *ngIf="openaireSearchUtils.status == errorCodes.LOADING" class="uk-position-center">
@ -20,10 +20,10 @@
<div *ngIf="openaireSearchUtils.status !== errorCodes.LOADING"> <div *ngIf="openaireSearchUtils.status !== errorCodes.LOADING">
<div *ngIf="openaireSearchUtils.totalResults == 0" <div *ngIf="openaireSearchUtils.totalResults == 0"
class="uk-card uk-card-default uk-padding-large uk-text-center uk-margin-bottom uk-text-bold"> class="uk-card uk-card-default uk-padding-large uk-text-center uk-margin-bottom uk-text-bold">
<div>No content providers found</div> <div>No <span class="uk-text-lowercase">{{openAIREEntities.DATASOURCE}}</span> found</div>
</div> </div>
<ng-container *ngIf="openaireSearchUtils.totalResults > 0"> <ng-container *ngIf="openaireSearchUtils.totalResults > 0">
<no-load-paging [type]="'content Providers'" <no-load-paging [type]="openaireContentProviders.length === 1?openAIREEntities.DATASOURCE:openAIREEntities.DATASOURCES"
[page]="openaireSearchUtils.page" [pageSize]="resultsPerPage" (pageChange)="goTo($event.value)" [page]="openaireSearchUtils.page" [pageSize]="resultsPerPage" (pageChange)="goTo($event.value)"
[totalResults]="openaireSearchUtils.totalResults"> [totalResults]="openaireSearchUtils.totalResults">
</no-load-paging> </no-load-paging>

View File

@ -18,6 +18,9 @@ import {debounceTime, distinctUntilChanged} from "rxjs/operators";
import {ResultPreview} from "../../openaireLibrary/utils/result-preview/result-preview"; import {ResultPreview} from "../../openaireLibrary/utils/result-preview/result-preview";
import {NotificationHandler} from "../../openaireLibrary/utils/notification-handler"; import {NotificationHandler} from "../../openaireLibrary/utils/notification-handler";
import {CommunityInfo} from "../../openaireLibrary/connect/community/communityInfo"; import {CommunityInfo} from "../../openaireLibrary/connect/community/communityInfo";
import {ContentProvider} from "../../openaireLibrary/utils/entities/contentProvider";
import {OpenaireEntities} from "../../openaireLibrary/utils/properties/searchFields";
import {HelperFunctions} from "../../openaireLibrary/utils/HelperFunctions.class";
@Component({ @Component({
selector: 'add-content-providers', selector: 'add-content-providers',
@ -32,8 +35,9 @@ export class AddContentProvidersComponent implements OnInit {
public errorCodes: ErrorCodes; public errorCodes: ErrorCodes;
public openaireSearchUtils: SearchUtilsClass = new SearchUtilsClass(); public openaireSearchUtils: SearchUtilsClass = new SearchUtilsClass();
@Output() communityContentProvidersChanged = new EventEmitter(); @Output() communityContentProvidersChanged = new EventEmitter();
@Input() communityContentProviders = []; @Input() communityContentProviders: ContentProvider[] = [];
public openaireContentProviders = []; public openaireContentProviders: SearchResult[] = [];
public openAIREEntities = OpenaireEntities;
public queryParameters: string = ""; public queryParameters: string = "";
public resultsPerPage: number = properties.resultsPerPage; public resultsPerPage: number = properties.resultsPerPage;
filterForm: FormGroup; filterForm: FormGroup;
@ -183,6 +187,7 @@ export class AddContentProvidersComponent implements OnInit {
} }
goTo(page: number = 1) { goTo(page: number = 1) {
HelperFunctions.scroll();
this.openaireSearchUtils.page = page; this.openaireSearchUtils.page = page;
this.openaireSearchUtils.status = this.errorCodes.LOADING; this.openaireSearchUtils.status = this.errorCodes.LOADING;
this._getOpenaireContentProviders(this.queryParameters, page, this.resultsPerPage); this._getOpenaireContentProviders(this.queryParameters, page, this.resultsPerPage);

View File

@ -17,15 +17,18 @@ import {NoLoadPaging} from "../../openaireLibrary/searchPages/searchUtils/no-loa
import {LoadingModule} from "../../openaireLibrary/utils/loading/loading.module"; import {LoadingModule} from "../../openaireLibrary/utils/loading/loading.module";
import {IconsModule} from "../../openaireLibrary/utils/icons/icons.module"; import {IconsModule} from "../../openaireLibrary/utils/icons/icons.module";
import {IconsService} from "../../openaireLibrary/utils/icons/icons.service"; import {IconsService} from "../../openaireLibrary/utils/icons/icons.service";
import {add, arrow_left, close, edit, filters, remove_circle_outline} from "../../openaireLibrary/utils/icons/icons"; import {filters} from "../../openaireLibrary/utils/icons/icons";
import {FullScreenModalModule} from "../../openaireLibrary/utils/modal/full-screen-modal/full-screen-modal.module"; import {FullScreenModalModule} from "../../openaireLibrary/utils/modal/full-screen-modal/full-screen-modal.module";
import {ResultPreviewModule} from "../../openaireLibrary/utils/result-preview/result-preview.module"; import {ResultPreviewModule} from "../../openaireLibrary/utils/result-preview/result-preview.module";
import {SearchDataprovidersServiceModule} from "../../openaireLibrary/connect/contentProviders/searchDataprovidersService.module"; import {
SearchDataprovidersServiceModule
} from "../../openaireLibrary/connect/contentProviders/searchDataprovidersService.module";
import {ManageContentProvidersComponent} from "./manage-content-providers.component"; import {ManageContentProvidersComponent} from "./manage-content-providers.component";
import {RemoveContentProvidersComponent} from "./remove-content-providers.component"; import {RemoveContentProvidersComponent} from "./remove-content-providers.component";
import {AddContentProvidersComponent} from "./add-content-providers.component"; import {AddContentProvidersComponent} from "./add-content-providers.component";
import {ManageCommunityContentProvidersService} from "../../services/manageContentProviders.service"; import {ManageCommunityContentProvidersService} from "../../services/manageContentProviders.service";
import {SearchDataprovidersService} from "../../openaireLibrary/services/searchDataproviders.service"; import {SearchDataprovidersService} from "../../openaireLibrary/services/searchDataproviders.service";
import {CriteriaModule} from "./criteria/criteria.module";
@NgModule({ @NgModule({
imports: [ imports: [
@ -47,7 +50,7 @@ import {SearchDataprovidersService} from "../../openaireLibrary/services/searchD
path: '', component: ManageContentProvidersComponent path: '', component: ManageContentProvidersComponent
} }
]), ]),
NoLoadPaging, LoadingModule, IconsModule, FullScreenModalModule, ResultPreviewModule NoLoadPaging, LoadingModule, IconsModule, FullScreenModalModule, ResultPreviewModule, CriteriaModule
], ],
declarations: [ declarations: [
ManageContentProvidersComponent, ManageContentProvidersComponent,

View File

@ -1,13 +0,0 @@
import {NgModule} from '@angular/core';
import {RouterModule} from '@angular/router';
import {CriteriaComponent} from './criteria.component';
@NgModule({
imports: [
RouterModule.forChild([
{path: '', component: CriteriaComponent}
])
]
})
export class CriteriaRoutingModule {
}

View File

@ -1,6 +0,0 @@
.criterion {
border: rgba(26,26,26,0.5) solid 1px;
border-radius: 4px;
max-height: 400px;
overflow: auto;
}

View File

@ -1,54 +1,34 @@
<div page-content> <div class="uk-section uk-position-relative" style="min-height: 60vh">
<div header> <div *ngIf="loading" class="uk-position-center">
<div class="uk-margin-top"> <loading></loading>
<a routerLink="../" class="uk-text-secondary uk-text-uppercase uk-text-bold uk-text-small"> </div>
<span class="uk-icon-button uk-icon small uk-button-secondary"> <ng-container *ngIf="!loading">
<icon name="arrow_left"></icon> <div class="uk-flex uk-flex-center uk-margin-medium-bottom">
</span> <a (click)="addCriteria()" class="uk-flex uk-flex-middle uk-button uk-button-primary"
<span class="space"> uk-tooltip="<div>Add filter to limit research results.<br>Results which satisfy any of the selected filters will be included in your community.</div>">
Go back to Content Providers <icon name="add" [flex]="true"></icon>
</span> <span class="uk-margin-small-left">Add filter</span>
</a> </a>
</div> </div>
</div> <div *ngIf="criteria.length == 0" class="uk-card uk-card-default uk-padding-large uk-text-center uk-margin-bottom uk-text-bold">
<div inner> <div *ngIf="dataProvider">No filters for {{dataProvider.officialname}}.</div>
<div class="uk-card-header"> <div>If no filters are specified, all research results of this content provider will be included in your
<div class="uk-flex uk-flex-middle uk-child-width-1-1 uk-child-width-1-2@m uk-grid" uk-grid> community.
<div>
<div class="uk-text-small uk-text-muted">Filters for</div>
<div>
<span *ngIf="dataProvider" class="uk-text-bold">{{dataProvider.officialname}}</span>
<span *ngIf="dirty"> (unsaved changes)</span>
</div>
</div>
<div class=" uk-flex uk-flex-right">
<button (click)="reset()" [disabled]="loading || !dirty"
class="uk-button uk-button-secondary outlined uk-margin-small-right">Reset
</button>
<button (click)="save()" class="uk-button uk-button-secondary uk-margin-small-right"
[disabled]="loading || !dirty || selectionCriteria.invalid ">Save
</button>
</div>
</div> </div>
</div> </div>
<div class="uk-card uk-card-default uk-position-relative" style="min-height: 60vh"> <form *ngIf="criteria.length > 0" [formGroup]="selectionCriteria">
<div *ngIf="!loading" class="uk-padding-large uk-padding-remove-bottom uk-overflow-auto" <div formArrayName="criteria" class="uk-margin-bottom">
style="max-height: 60vh;"> <no-load-paging (pageChange)="updatePage($event)" [page]="page" [totalResults]="criteria.length"
<div *ngIf="criteria.length == 0" class="uk-padding-large uk-text-center uk-text-bold"> [pageSize]="pageSize" [type]="'filter' + (criteria.length > 1?'s':'')">
<div *ngIf="dataProvider">No filters for {{dataProvider.officialname}}.</div> </no-load-paging>
<div>If no filters are specified, all research results of this content provider will be included in your <ul class="uk-list uk-list-xlarge uk-margin-top uk-margin-bottom">
community. <li *ngFor="let criterion of currentPage; let i=index">
</div> <div [formGroupName]="getIndex(i).toString()" class="uk-flex">
</div> <h3 class="uk-padding uk-margin-remove-bottom uk-margin-top">
<form *ngIf="criteria.length > 0" [formGroup]="selectionCriteria"> {{getIndex(i) + 1}}
<div formArrayName="criteria" class="uk-margin-bottom"> </h3>
<no-load-paging (pageChange)="page = $event.value" [page]="page" [totalResults]="criteria.length" [pageSize]="pageSize" [type]="'filter' + (criteria.length > 1?'s':'')"> <div class="uk-width-expand uk-padding-small criterion" formArrayName="constraint">
</no-load-paging> <div class="uk-flex-middle uk-grid uk-margin-small-bottom uk-visible@l" uk-grid>
<div class="uk-margin-top" *ngFor="let criterion of currentPage; let i=index" [formGroupName]="getIndex(i).toString()">
<h6 class="uk-text-bold uk-form-label uk-margin-small-bottom">Filter {{getIndex(i) + 1}}</h6>
<div class="uk-padding criterion" formArrayName="constraint">
<div class="uk-flex uk-flex-middle uk-grid-small uk-margin-small-bottom uk-visible@l" uk-grid>
<div style="width: 50px"></div>
<div class="uk-width-1-4"> <div class="uk-width-1-4">
<label class="uk-text-uppercase uk-text-bold">Field</label> <label class="uk-text-uppercase uk-text-bold">Field</label>
</div> </div>
@ -64,25 +44,22 @@
</div> </div>
<div *ngFor="let constraint of getConstraint(getIndex(i)).controls; let j=index" [formGroupName]="j.toString()" <div *ngFor="let constraint of getConstraint(getIndex(i)).controls; let j=index" [formGroupName]="j.toString()"
class="uk-margin-bottom uk-hidden@l"> class="uk-margin-bottom uk-hidden@l">
<div class="uk-flex uk-flex-middle uk-grid-small uk-margin-medium-bottom" uk-grid> <div class="uk-flex-middle uk-grid-small uk-margin-medium-bottom" uk-grid>
<div class="uk-flex uk-flex-center uk-width-1-1">
<span *ngIf="j > 0">AND</span>
</div>
<div class="uk-flex uk-flex-right uk-width-1-1"> <div class="uk-flex uk-flex-right uk-width-1-1">
<a class="uk-link-heading" (click)="removeConstraint(getIndex(i), j)"> <a class="uk-close" (click)="removeConstraint(getIndex(i), j)">
<icon name="close" <icon name="close" ratio="1.5" [flex]="true"
[attr.uk-tooltip]="(getConstraint(getIndex(i)).length === 1?'By removing this constraint, the filter will be removed too':null)"></icon> [attr.uk-tooltip]="(getConstraint(getIndex(i)).length === 1?'By removing this constraint, the filter will be removed too':null)"></icon>
</a> </a>
</div> </div>
<div class="uk-width-1-1" dashboard-input type="select" placeholder="Select a field" <div class="uk-width-1-1" input type="select" inputClass="border-bottom" [placeholder]="{static: true, label: 'Choose a field'}"
[options]="fields" [formInput]="constraint.get('field')"> [options]="fields" [formInput]="constraint.get('field')">
<label class="uk-text-uppercase uk-text-bold uk-width-1-3 uk-text-truncate">Field:</label> <label class="uk-text-uppercase uk-text-bold uk-width-1-3 uk-text-truncate">Field:</label>
</div> </div>
<div class="uk-width-1-1" dashboard-input type="select" placeholder="Select an operator" <div class="uk-width-1-1" input type="select" inputClass="border-bottom"
[options]="verbs" [formInput]="constraint.get('verb')"> [options]="verbs" [formInput]="constraint.get('verb')">
<label class="uk-text-uppercase uk-text-bold uk-width-1-3 uk-text-truncate">Operator:</label> <label class="uk-text-uppercase uk-text-bold uk-width-1-3 uk-text-truncate">Operator:</label>
</div> </div>
<div class="uk-width-1-1" dashboard-input placeholder="Write a term" <div class="uk-width-1-1" input [placeholder]="{static: true, label: 'Type a keyword'}"
[formInput]="constraint.get('value')"> [formInput]="constraint.get('value')">
<label class="uk-text-uppercase uk-text-bold uk-width-1-3 uk-text-truncate">Term:</label> <label class="uk-text-uppercase uk-text-bold uk-width-1-3 uk-text-truncate">Term:</label>
</div> </div>
@ -92,7 +69,7 @@
<div class="uk-width-expand"> <div class="uk-width-expand">
<mat-slide-toggle [checked]="constraint.get('verb_suffix').value === ''" <mat-slide-toggle [checked]="constraint.get('verb_suffix').value === ''"
[attr.uk-tooltip]="(constraint.get('verb_suffix').value === ''?('Only \'\'' + constraint.get('value').value + '\'\' matches'): [attr.uk-tooltip]="(constraint.get('verb_suffix').value === ''?('Only \'\'' + constraint.get('value').value + '\'\' matches'):
('Both \'\'' + constraint.get('value').value.toUpperCase() + '\'\' and \'\'' + constraint.get('value').value.toLowerCase() + '\'\' match'))" ('Both \'\'' + constraint.get('value').value.toUpperCase() + '\'\' and \'\'' + constraint.get('value').value.toLowerCase() + '\'\' match'))"
(change)="caseSensitive($event, constraint)"></mat-slide-toggle> (change)="caseSensitive($event, constraint)"></mat-slide-toggle>
</div> </div>
</div> </div>
@ -101,70 +78,43 @@
</div> </div>
<div *ngFor="let constraint of getConstraint(getIndex(i)).controls; let j=index" <div *ngFor="let constraint of getConstraint(getIndex(i)).controls; let j=index"
[formGroupName]="j.toString()" class="uk-margin-bottom uk-visible@l"> [formGroupName]="j.toString()" class="uk-margin-bottom uk-visible@l">
<div class="uk-flex uk-flex-middle uk-grid-small" uk-grid> <div class="uk-flex uk-flex-middle uk-grid" uk-grid>
<div class="uk-flex uk-flex-center" style="width: 50px"> <div class="uk-width-1-4" input type="select" inputClass="border-bottom" [placeholder]="{static: true, label: 'Choose a field'}"
<span *ngIf="j > 0">AND</span>
</div>
<div class="uk-width-1-4" dashboard-input type="select" placeholder="Select a field"
[options]="fields" [formInput]="constraint.get('field')"></div> [options]="fields" [formInput]="constraint.get('field')"></div>
<div class="uk-width-1-4" dashboard-input type="select" placeholder="Select an operator" <div class="uk-width-1-4" input type="select" inputClass="border-bottom"
[options]="verbs" [formInput]="constraint.get('verb')"></div> [options]="verbs" [formInput]="constraint.get('verb')"></div>
<div class="uk-width-1-4" dashboard-input placeholder="Write a term" <div class="uk-width-1-4" input [placeholder]="{static: true, label: 'Type a keyword'}"
[formInput]="constraint.get('value')"></div> [formInput]="constraint.get('value')"></div>
<div class="uk-width-expand"> <div class="uk-width-expand">
<mat-slide-toggle [checked]="constraint.get('verb_suffix').value === ''" class="uk-margin-left" <mat-slide-toggle [checked]="constraint.get('verb_suffix').value === ''" class="uk-margin-left"
[attr.uk-tooltip]="(constraint.get('verb_suffix').value === ''?('Only \'\'' + constraint.get('value').value + '\'\' matches'): [attr.uk-tooltip]="(constraint.get('verb_suffix').value === ''?('Only \'\'' + constraint.get('value').value + '\'\' matches'):
('Both \'\'' + constraint.get('value').value.toUpperCase() + '\'\' and \'\'' + constraint.get('value').value.toLowerCase() + '\'\' match'))" ('Both \'\'' + constraint.get('value').value.toUpperCase() + '\'\' and \'\'' + constraint.get('value').value.toLowerCase() + '\'\' match'))"
(change)="caseSensitive($event, constraint)"></mat-slide-toggle> (change)="caseSensitive($event, constraint)"></mat-slide-toggle>
</div> </div>
<div class="uk-flex uk-flex-center"> <div class="uk-flex uk-flex-center">
<a class="uk-link-heading" (click)="removeConstraint(getIndex(i), j)"> <a class="uk-close" (click)="removeConstraint(getIndex(i), j)">
<icon name="close" <icon name="close" ratio="1.5" [flex]="true"
[attr.uk-tooltip]="(getConstraint(getIndex(i)).length === 1?'By removing this constraint, the filter will be removed too':null)"></icon> [attr.uk-tooltip]="(getConstraint(getIndex(i)).length === 1?'By removing this constraint, the filter will be removed too':null)"></icon>
</a> </a>
</div> </div>
</div> </div>
</div> </div>
<div class="uk-margin-top uk-width-1-1 uk-flex uk-flex-center uk-hidden@l"> <div class="uk-margin-top uk-width-1-1 uk-flex uk-flex-center uk-flex-left@l">
<a (click)="addConstraint(getIndex(i))" class="uk-flex uk-flex-middle uk-text-uppercase"> <a (click)="addConstraint(getIndex(i))" class="uk-flex uk-flex-middle uk-button uk-button-link">
<button class="large uk-icon-button uk-button-secondary"> <icon name="add" [flex]="true"></icon>
<icon name="add"></icon> <span class="uk-margin-small-left">Add Constraint</span>
</button>
<button class="uk-button uk-button-link uk-margin-small-left uk-text-secondary">
Add Constraint
</button>
</a>
</div>
<div class="uk-flex uk-flex-middle uk-grid-small uk-visible@l" uk-grid>
<div style="width: 50px"></div>
<a (click)="addConstraint(getIndex(i))" class="uk-flex uk-flex-middle uk-text-uppercase">
<button class="large uk-icon-button uk-button-secondary">
<icon name="add"></icon>
</button>
<button class="uk-button uk-button-link uk-margin-small-left uk-text-secondary">
Add Constraint
</button>
</a> </a>
</div> </div>
</div> </div>
</div> </div>
</div> </li>
</form> </ul>
<div class="uk-flex uk-flex-center uk-margin-large-bottom"> <div class="uk-margin-small-top">
<a (click)="addCriteria()" class="uk-flex uk-flex-middle uk-text-uppercase" <paging-no-load [currentPage]="page" [totalResults]="criteria.length" [size]="pageSize"
uk-tooltip="<div class='uk-padding-small'>Add filter to limit research results.<br>Results which satisfy any of the selected filters will be included in your community.</div>"> (pageChange)="updatePage($event)" customClasses="uk-flex-right@m uk-flex-center">
<button class="large uk-icon-button uk-button-secondary"> </paging-no-load>
<icon name="add"></icon>
</button>
<button class="uk-button uk-button-link uk-margin-small-left uk-text-secondary">
Add filter
</button>
</a>
</div> </div>
</div> </div>
<div *ngIf="loading" class="uk-position-center"> </form>
<loading></loading> </ng-container>
</div>
</div>
</div>
</div> </div>

View File

@ -0,0 +1,8 @@
@import (reference) "~src/assets/openaire-theme/less/_import-variables.less";
.criterion {
border: @global-border solid @global-border-width;
border-radius: @global-border-radius;
max-height: 400px;
overflow: auto;
}

View File

@ -1,6 +1,4 @@
import {ChangeDetectorRef, Component, OnDestroy, OnInit} from '@angular/core'; import {ChangeDetectorRef, Component, Input, OnInit} from '@angular/core';
import {ActivatedRoute, Router} from '@angular/router';
import {SearchCommunityDataprovidersService} from '../../../openaireLibrary/connect/contentProviders/searchDataproviders.service';
import {EnvProperties} from '../../../openaireLibrary/utils/properties/env-properties'; import {EnvProperties} from '../../../openaireLibrary/utils/properties/env-properties';
import { import {
Constraint, Constraint,
@ -10,25 +8,21 @@ import {
} from '../../../openaireLibrary/utils/entities/contentProvider'; } from '../../../openaireLibrary/utils/entities/contentProvider';
import {AbstractControl, FormArray, FormBuilder, FormGroup, Validators} from '@angular/forms'; import {AbstractControl, FormArray, FormBuilder, FormGroup, Validators} from '@angular/forms';
import {ManageCommunityContentProvidersService} from '../../../services/manageContentProviders.service'; import {ManageCommunityContentProvidersService} from '../../../services/manageContentProviders.service';
import {Title} from '@angular/platform-browser';
import {properties} from "../../../../environments/environment"; import {properties} from "../../../../environments/environment";
import {Subscription} from "rxjs";
import {Option} from "../../../openaireLibrary/sharedComponents/input/input.component"; import {Option} from "../../../openaireLibrary/sharedComponents/input/input.component";
import {MatSlideToggleChange} from "@angular/material/slide-toggle"; import {MatSlideToggleChange} from "@angular/material/slide-toggle";
import {HelperFunctions} from "../../../openaireLibrary/utils/HelperFunctions.class"; import {HelperFunctions} from "../../../openaireLibrary/utils/HelperFunctions.class";
import {CriteriaUtils} from "../criteria-utils"; import {CriteriaUtils} from "../criteria-utils";
import {NotificationHandler} from "../../../openaireLibrary/utils/notification-handler";
declare var UIkit;
@Component({ @Component({
selector: 'criteria', selector: 'criteria',
templateUrl: './criteria.component.html', templateUrl: 'criteria.component.html',
styleUrls: ['criteria.component.css'], styleUrls: ['criteria.component.less']
}) })
export class CriteriaComponent implements OnInit, OnDestroy { export class CriteriaComponent implements OnInit {
public community: string = ''; @Input()
public openaireId: string = ''; public dataProvider: ContentProvider;
public dataProvider: ContentProvider = null;
public selectionCriteria: FormGroup; public selectionCriteria: FormGroup;
public properties: EnvProperties = properties; public properties: EnvProperties = properties;
public fields: Option[] = CriteriaUtils.fields; public fields: Option[] = CriteriaUtils.fields;
@ -37,51 +31,15 @@ export class CriteriaComponent implements OnInit, OnDestroy {
/** Paging */ /** Paging */
public page: number = 1; public page: number = 1;
public pageSize: number = 5; public pageSize: number = 5;
private subs: any[] = [];
constructor(private route: ActivatedRoute, private router: Router, constructor(private manageCommunityContentProvidersService: ManageCommunityContentProvidersService,
private title: Title,
private searchCommunityDataprovidersService: SearchCommunityDataprovidersService,
private manageCommunityContentProvidersService: ManageCommunityContentProvidersService,
private cdr: ChangeDetectorRef, private cdr: ChangeDetectorRef,
private fb: FormBuilder) { private fb: FormBuilder) {
} }
ngOnInit() { ngOnInit() {
this.subs.push(this.route.params.subscribe(params => { this.reset();
this.community = params['community']; this.loading = false;
this.route.params.subscribe(params => {
if (params['provider']) {
this.openaireId = params['provider'];
}
this.searchCommunityDataprovidersService.searchDataproviders(this.properties, this.community).subscribe(dataProviders => {
dataProviders.forEach(dataProvider => {
if (dataProvider.openaireId == this.openaireId) {
this.dataProvider = dataProvider;
this.title.setTitle(this.community.toUpperCase() + ' | Criteria for ' + this.dataProvider.officialname);
}
});
if (!this.dataProvider) {
this.navigateToError();
} else {
this.reset();
this.loading = false;
}
});
});
}));
}
public ngOnDestroy() {
this.subs.forEach(subscription => {
if (subscription instanceof Subscription) {
subscription.unsubscribe();
}
})
}
private navigateToError() {
this.router.navigate(['/error'], {queryParams: {'page': this.properties.baseLink + this.router.url}});
} }
reset() { reset() {
@ -110,6 +68,10 @@ export class CriteriaComponent implements OnInit, OnDestroy {
} }
} }
get disabled() {
return this.loading || !this.dirty || this.selectionCriteria.invalid;
}
get currentPage(): AbstractControl[] { get currentPage(): AbstractControl[] {
if (this.criteria) { if (this.criteria) {
return this.criteria.controls.slice((this.page - 1) * this.pageSize, this.page * this.pageSize); return this.criteria.controls.slice((this.page - 1) * this.pageSize, this.page * this.pageSize);
@ -162,8 +124,8 @@ export class CriteriaComponent implements OnInit, OnDestroy {
constraintArray.removeAt(j); constraintArray.removeAt(j);
if (constraintArray.length === 0) { if (constraintArray.length === 0) {
this.criteria.removeAt(i); this.criteria.removeAt(i);
if (this.currentPage.length === 0) { while(this.currentPage.length === 0 && this.page > 0) {
this.page = 1; this.page--;
} }
} }
this.cdr.detectChanges(); this.cdr.detectChanges();
@ -192,34 +154,31 @@ export class CriteriaComponent implements OnInit, OnDestroy {
} }
} }
save() { save(callback: Function = null) {
if (this.selectionCriteria.valid) { if (this.selectionCriteria.valid) {
this.loading = true; this.loading = true;
this.dataProvider.selectioncriteria = this.parseForm(this.selectionCriteria.value); this.dataProvider.selectioncriteria = this.parseForm(this.selectionCriteria.value);
this.manageCommunityContentProvidersService.saveContentProvider(this.properties, this.dataProvider).subscribe(() => { this.manageCommunityContentProvidersService.saveContentProvider(this.properties, this.dataProvider).subscribe(() => {
this.reset(); this.reset();
if(callback) {
callback();
}
this.loading = false; this.loading = false;
UIkit.notification('Filters has been <b>successfully updated</b>', { NotificationHandler.rise('Filters have been <b>successfully updated</b>');
status: 'success',
timeout: 6000,
pos: 'bottom-right'
});
}, error => { }, error => {
UIkit.notification('An error has been occurred. Try again later!', { this.loading = false;
status: 'danger', this.handeError('An error has been occurred. Try again later!', error);
timeout: 6000,
pos: 'bottom-right'
});
}); });
} else { } else {
UIkit.notification('An error has been occurred. Try again later!', { this.handeError('An error has been occurred. Try again later!');
status: 'danger',
timeout: 6000,
pos: 'bottom-right'
});
} }
} }
handeError(message, error = null) {
console.error(error);
NotificationHandler.rise(message, 'danger');
}
caseSensitive(event: MatSlideToggleChange, constraint: AbstractControl) { caseSensitive(event: MatSlideToggleChange, constraint: AbstractControl) {
if(event.checked) { if(event.checked) {
constraint.get('verb_suffix').setValue(''); constraint.get('verb_suffix').setValue('');
@ -254,4 +213,9 @@ export class CriteriaComponent implements OnInit, OnDestroy {
}) })
return selectionCriteria; return selectionCriteria;
} }
public updatePage(event) {
this.page = event.value;
HelperFunctions.scroll();
}
} }

View File

@ -1,25 +1,24 @@
import {NgModule} from '@angular/core'; import {NgModule} from '@angular/core';
import {CommonModule} from '@angular/common'; import {CommonModule} from '@angular/common';
import {CriteriaComponent} from './criteria.component'; import {CriteriaComponent} from './criteria.component';
import {CriteriaRoutingModule} from './criteria-routing.module'; import {
import {SearchCommunityDataprovidersService} from '../../../openaireLibrary/connect/contentProviders/searchDataproviders.service'; SearchCommunityDataprovidersService
} from '../../../openaireLibrary/connect/contentProviders/searchDataproviders.service';
import {RouterModule} from '@angular/router'; import {RouterModule} from '@angular/router';
import {FormsModule, ReactiveFormsModule} from '@angular/forms'; import {FormsModule, ReactiveFormsModule} from '@angular/forms';
import {ManageCommunityContentProvidersService} from '../../../services/manageContentProviders.service'; import {ManageCommunityContentProvidersService} from '../../../services/manageContentProviders.service';
import {PageContentModule} from "../../../openaireLibrary/dashboard/sharedComponents/page-content/page-content.module"; import {PageContentModule} from "../../../openaireLibrary/dashboard/sharedComponents/page-content/page-content.module";
import {IconsModule} from "../../../openaireLibrary/utils/icons/icons.module"; import {IconsModule} from "../../../openaireLibrary/utils/icons/icons.module";
import {IconsService} from "../../../openaireLibrary/utils/icons/icons.service";
import {add, arrow_left, close} from "../../../openaireLibrary/utils/icons/icons";
import {LoadingModule} from "../../../openaireLibrary/utils/loading/loading.module"; import {LoadingModule} from "../../../openaireLibrary/utils/loading/loading.module";
import {InputModule} from "../../../openaireLibrary/sharedComponents/input/input.module"; import {InputModule} from "../../../openaireLibrary/sharedComponents/input/input.module";
import {MatSlideToggleModule} from "@angular/material/slide-toggle"; import {MatSlideToggleModule} from "@angular/material/slide-toggle";
import {ScrollingModule} from "@angular/cdk/scrolling"; import {ScrollingModule} from "@angular/cdk/scrolling";
import {NoLoadPaging} from "../../../openaireLibrary/searchPages/searchUtils/no-load-paging.module"; import {NoLoadPaging} from "../../../openaireLibrary/searchPages/searchUtils/no-load-paging.module";
import {PagingModule} from "../../../openaireLibrary/utils/paging.module";
@NgModule({ @NgModule({
imports: [ imports: [
CommonModule, CommonModule,
CriteriaRoutingModule,
RouterModule, RouterModule,
FormsModule, FormsModule,
ReactiveFormsModule, ReactiveFormsModule,
@ -30,6 +29,7 @@ import {NoLoadPaging} from "../../../openaireLibrary/searchPages/searchUtils/no-
MatSlideToggleModule, MatSlideToggleModule,
ScrollingModule, ScrollingModule,
NoLoadPaging, NoLoadPaging,
PagingModule,
], ],
declarations: [ declarations: [
CriteriaComponent CriteriaComponent
@ -41,8 +41,4 @@ import {NoLoadPaging} from "../../../openaireLibrary/searchPages/searchUtils/no-
exports: [CriteriaComponent] exports: [CriteriaComponent]
}) })
export class CriteriaModule { export class CriteriaModule {}
constructor(private iconsService: IconsService) {
this.iconsService.registerIcons([arrow_left, add, close])
}
}

View File

@ -1,5 +1,4 @@
import {Component, ElementRef, Input, OnInit, ViewChild} from '@angular/core'; import {Component, OnInit, ViewChild} from '@angular/core';
import {Router} from "@angular/router";
import {RemoveContentProvidersComponent} from './remove-content-providers.component'; import {RemoveContentProvidersComponent} from './remove-content-providers.component';
import {Title} from '@angular/platform-browser'; import {Title} from '@angular/platform-browser';
import { import {
@ -11,41 +10,53 @@ import {properties} from "../../../environments/environment";
import {Subscriber} from "rxjs"; import {Subscriber} from "rxjs";
import {CommunityInfo} from "../../openaireLibrary/connect/community/communityInfo"; import {CommunityInfo} from "../../openaireLibrary/connect/community/communityInfo";
import {CommunityService} from "../../openaireLibrary/connect/community/community.service"; import {CommunityService} from "../../openaireLibrary/connect/community/community.service";
import {ContentProvider} from "../../openaireLibrary/utils/entities/contentProvider";
import {OpenaireEntities} from "../../openaireLibrary/utils/properties/searchFields";
import {CriteriaComponent} from "./criteria/criteria.component";
@Component({ @Component({
selector: 'manage-content-providers', selector: 'manage-content-providers',
template: ` template: `
<remove-content-providers #removeContentProvidersComponent (addContentProviders)="openAddContentProviders()" [communityContentProviders]="communityContentProviders" <remove-content-providers #removeContentProviders (addContentProviders)="openAddContentProviders()"
[communityContentProviders]="communityContentProviders"
[loading]="showLoadingInRemove" [community]="community" [disableAdd]="add.loading" [loading]="showLoadingInRemove" [community]="community" [disableAdd]="add.loading"
(editCriteria)="openCriteria($event)"
(communityContentProvidersChanged)="communityContentProvidersChanged($event)"> (communityContentProvidersChanged)="communityContentProvidersChanged($event)">
</remove-content-providers> </remove-content-providers>
<fs-modal #fsModal> <fs-modal #addContentProvidersModal>
<add-content-providers #add [communityContentProviders]="communityContentProviders" [community]="community" <add-content-providers #add [communityContentProviders]="communityContentProviders" [community]="community"
(communityContentProvidersChanged)="communityContentProvidersChanged($event)"></add-content-providers> (communityContentProvidersChanged)="communityContentProvidersChanged($event)"></add-content-providers>
</fs-modal> </fs-modal>
<fs-modal #filtersModal (okEmitter)="saveCriteria()" (cancelEmitter)="criteria.reset()" [okButtonDisabled]="criteria && criteria.disabled">
<div class="uk-container">
<criteria #criteria *ngIf="contentProvider" [dataProvider]="contentProvider"></criteria>
</div>
</fs-modal>
` `
}) })
export class ManageContentProvidersComponent implements OnInit { export class ManageContentProvidersComponent implements OnInit {
@Input() communityContentProviders = []; communityContentProviders: ContentProvider[] = [];
@ViewChild(RemoveContentProvidersComponent) removeContentProvidersComponent: RemoveContentProvidersComponent; @ViewChild(RemoveContentProvidersComponent) removeContentProvidersComponent: RemoveContentProvidersComponent;
@ViewChild('fsModal', { static: true }) fullscreen: FullScreenModalComponent; @ViewChild('criteria') criteria: CriteriaComponent;
@ViewChild('addContentProvidersModal', { static: true }) addContentProvidersModal: FullScreenModalComponent;
@ViewChild('filtersModal', { static: true }) filtersModal: FullScreenModalComponent;
private subscriptions: any[] = []; private subscriptions: any[] = [];
public showLoadingInRemove: boolean = true; public showLoadingInRemove: boolean = true;
public body: string = "Send from page"; public body: string = "Send from page";
public properties: EnvProperties = properties; public properties: EnvProperties = properties;
public community: CommunityInfo; public community: CommunityInfo;
public contentProvider: ContentProvider;
constructor(private element: ElementRef, constructor(private title: Title,
private title: Title, private communityService: CommunityService) {
private communityService: CommunityService, private _router: Router) {
} }
ngOnInit() { ngOnInit() {
this.subscriptions.push(this.communityService.getCommunityAsObservable().subscribe(community => { this.subscriptions.push(this.communityService.getCommunityAsObservable().subscribe(community => {
this.community = community; this.community = community;
if (this.community) { if (this.community) {
this.title.setTitle(this.community.shortTitle.toUpperCase() + ' | Content Providers'); this.title.setTitle(this.community.shortTitle.toUpperCase() + ' | ' + OpenaireEntities.DATASOURCES);
this.body = "[Please write your message here]"; this.body = "[Please write your message here]";
this.body = StringUtils.URIEncode(this.body); this.body = StringUtils.URIEncode(this.body);
} }
@ -61,18 +72,34 @@ export class ManageContentProvidersComponent implements OnInit {
} }
public openAddContentProviders() { public openAddContentProviders() {
this.fullscreen.title = "Search and Add Content Providers"; this.addContentProvidersModal.title = "Search and Add " + OpenaireEntities.DATASOURCES;
this.fullscreen.okButtonText = "Done"; this.addContentProvidersModal.okButtonText = "Done";
this.fullscreen.back = true; this.addContentProvidersModal.back = true;
this.fullscreen.okButton = true; this.addContentProvidersModal.okButton = true;
this.fullscreen.open(); this.addContentProvidersModal.open();
}
public openCriteria(contentProvider: ContentProvider) {
this.contentProvider = contentProvider;
this.filtersModal.title = 'Filters';
this.filtersModal.okButtonText = "Save";
this.filtersModal.back = true;
this.filtersModal.okButton = true;
this.filtersModal.open();
}
public saveCriteria() {
let callback: Function = () => {
this.removeContentProvidersComponent.getCommunityContentProviders();
}
this.removeContentProvidersComponent.loading = true;
this.criteria.save(callback);
} }
public communityContentProvidersChanged($event) { public communityContentProvidersChanged($event) {
this.communityContentProviders = $event.value; this.communityContentProviders = $event.value;
this.showLoadingInRemove = false; this.showLoadingInRemove = false;
if (this.addContentProvidersModal.isOpen) {
if (this.fullscreen.isOpen) {
this.removeContentProvidersComponent.applyFilters(); this.removeContentProvidersComponent.applyFilters();
} }
} }

View File

@ -2,7 +2,7 @@
<div header> <div header>
<div class="uk-flex uk-flex-middle uk-margin-top info" [class.uk-active]="stickyPageHeader"> <div class="uk-flex uk-flex-middle uk-margin-top info" [class.uk-active]="stickyPageHeader">
<div> <div>
<div class="uk-margin-remove uk-text-background uk-text-bold uk-h6">Admin Dashboard - Manage Content Providers <div class="uk-margin-remove uk-text-background uk-text-bold uk-h6">Admin Dashboard - Manage <span class="uk-text-capitalize">{{openAIREEntities.DATASOURCES}}</span>
</div> </div>
<h1 class="uk-h4 uk-margin-remove">{{community.shortTitle}}</h1> <h1 class="uk-h4 uk-margin-remove">{{community.shortTitle}}</h1>
</div> </div>
@ -12,15 +12,14 @@
<div inner> <div inner>
<div class="uk-flex uk-flex-right@m uk-flex-center uk-flex-middle uk-grid uk-margin-top" uk-grid> <div class="uk-flex uk-flex-right@m uk-flex-center uk-flex-middle uk-grid uk-margin-top" uk-grid>
<div search-input [expandable]="true" [searchControl]="filterForm.get('keyword')" searchInputClass="outer" <div search-input [expandable]="true" [searchControl]="filterForm.get('keyword')" searchInputClass="outer"
placeholder="Search Content Providers" [disabled]="loading" [placeholder]="'Search ' + openAIREEntities.DATASOURCES" [disabled]="loading"
class="uk-width-1-3@xl uk-width-2-5@l uk-width-1-2@m uk-width-1-1"></div> class="uk-width-1-3@xl uk-width-2-5@l uk-width-1-2@m uk-width-1-1"></div>
<div> <div>
<button class="uk-button uk-button-default uk-flex uk-flex-middle" (click)="addNew()" <button class="uk-button uk-button-default uk-flex uk-flex-middle" (click)="addNew()"
[attr.uk-tooltip]="(toggle? 'cls: uk-invisible; ' : 'cls: uk-active; ') + [attr.uk-tooltip]="'<div><div class=\'uk-margin-bottom uk-text-bold\'> Search and add more <span class=\'uk-text-lowercase\'>' + openAIREEntities.DATASOURCES + '<span></span></div><div>The research results collected from the <span class=\'uk-text-lowercase\'>' + openAIREEntities.DATASOURCES + '</span> specified here will be automatically linked to your community dashboard.</div></div>'"
'title: <div><div class=\'uk-margin-bottom uk-text-bold\'> Search and add more Content Providers</div><div>The research results collected from the content providers specified here will be automatically linked to your community dashboard.</div></div>'"
[disabled]="loading || disableAdd" [class.uk-disabled]="loading || disableAdd"> [disabled]="loading || disableAdd" [class.uk-disabled]="loading || disableAdd">
<icon name="add" [flex]="true"></icon> <icon name="add" [flex]="true"></icon>
<span class="uk-margin-small-left uk-text-bold uk-text-uppercase">New content provider</span> <span class="uk-margin-small-left uk-text-bold uk-text-uppercase">New {{openAIREEntities.DATASOURCE}}</span>
</button> </button>
</div> </div>
</div> </div>
@ -31,10 +30,10 @@
<div *ngIf="!loading"> <div *ngIf="!loading">
<div *ngIf="previewCommunityContentProviders.length == 0" <div *ngIf="previewCommunityContentProviders.length == 0"
class="uk-card uk-card-default uk-padding-large uk-text-center uk-margin-bottom uk-text-bold"> class="uk-card uk-card-default uk-padding-large uk-text-center uk-margin-bottom uk-text-bold">
<div>No content providers found</div> <div>No <span class="uk-text-lowercase">{{openAIREEntities.DATASOURCES}}</span> found</div>
</div> </div>
<div *ngIf="previewCommunityContentProviders.length > 0"> <div *ngIf="previewCommunityContentProviders.length > 0">
<no-load-paging [type]="'content providers'" <no-load-paging [type]="previewCommunityContentProviders.length === 1?openAIREEntities.DATASOURCE:openAIREEntities.DATASOURCES"
(pageChange)="updatePage($event)" (pageChange)="updatePage($event)"
[page]="page" [pageSize]="resultsPerPage" [page]="page" [pageSize]="resultsPerPage"
[totalResults]="previewCommunityContentProviders.length"> [totalResults]="previewCommunityContentProviders.length">
@ -62,7 +61,7 @@
<div class="uk-text-meta uk-margin-small-bottom">Filters</div> <div class="uk-text-meta uk-margin-small-bottom">Filters</div>
<div [innerHTML]="getFiltersAsText(item.selectioncriteria.criteria)"></div> <div [innerHTML]="getFiltersAsText(item.selectioncriteria.criteria)"></div>
<div *ngIf="item.selectioncriteria.criteria.length > 3" class="uk-margin-small-top"> <div *ngIf="item.selectioncriteria.criteria.length > 3" class="uk-margin-small-top">
<a class="uk-link view-more-less-link" [routerLink]="'./' + item.openaireId">View all {{item.selectioncriteria.criteria.length}} filters</a> <a class="uk-link view-more-less-link" (click)="openCriteria(item)">View all {{item.selectioncriteria.criteria.length}} filters</a>
</div> </div>
</div> </div>
</div> </div>
@ -70,7 +69,7 @@
<div class="uk-grid uk-grid-small uk-flex-nowrap uk-grid-divider uk-flex-right" uk-grid> <div class="uk-grid uk-grid-small uk-flex-nowrap uk-grid-divider uk-flex-right" uk-grid>
<div> <div>
<div class="uk-padding-small uk-padding-remove-horizontal"> <div class="uk-padding-small uk-padding-remove-horizontal">
<a (click)="goToCriteria(item.openaireId)" class="uk-button uk-button-link uk-flex uk-flex-middle"> <a (click)="openCriteria(item)" class="uk-button uk-button-link uk-flex uk-flex-middle">
<icon name="filters" [flex]="true"></icon> <icon name="filters" [flex]="true"></icon>
<span *ngIf="item.selectioncriteria?.criteria?.length > 0" class="uk-margin-small-left" <span *ngIf="item.selectioncriteria?.criteria?.length > 0" class="uk-margin-small-left"
uk-tooltip="<div>Edit filters to limit research results.<br>Results which satisfy any of the selected filters will be included in your community.</div>"> uk-tooltip="<div>Edit filters to limit research results.<br>Results which satisfy any of the selected filters will be included in your community.</div>">
@ -108,4 +107,4 @@
</div> </div>
</div> </div>
</div> </div>
<modal-alert #deleteModal [overflowBody]="false" (alertOutput)="confirmedDeleteContentProvider()"></modal-alert> <modal-alert #deleteModal [overflowBody]="false" (alertOutput)="confirmedDeleteContentProvider()" classTitle="uk-background-primary uk-light"></modal-alert>

View File

@ -9,7 +9,7 @@ import {
SearchCommunityDataprovidersService SearchCommunityDataprovidersService
} from '../../openaireLibrary/connect/contentProviders/searchDataproviders.service'; } from '../../openaireLibrary/connect/contentProviders/searchDataproviders.service';
import {RouterHelper} from '../../openaireLibrary/utils/routerHelper.class'; import {RouterHelper} from '../../openaireLibrary/utils/routerHelper.class';
import {Criteria} from '../../openaireLibrary/utils/entities/contentProvider'; import {ContentProvider, Criteria} from '../../openaireLibrary/utils/entities/contentProvider';
import {properties} from "../../../environments/environment"; import {properties} from "../../../environments/environment";
import {SearchInputComponent} from "../../openaireLibrary/sharedComponents/search-input/search-input.component"; import {SearchInputComponent} from "../../openaireLibrary/sharedComponents/search-input/search-input.component";
import {FormBuilder, FormGroup} from "@angular/forms"; import {FormBuilder, FormGroup} from "@angular/forms";
@ -17,6 +17,8 @@ import {CriteriaUtils} from "./criteria-utils";
import {CommunityInfo} from "../../openaireLibrary/connect/community/communityInfo"; import {CommunityInfo} from "../../openaireLibrary/connect/community/communityInfo";
import {NotificationHandler} from "../../openaireLibrary/utils/notification-handler"; import {NotificationHandler} from "../../openaireLibrary/utils/notification-handler";
import {AlertModal} from "../../openaireLibrary/utils/modal/alert"; import {AlertModal} from "../../openaireLibrary/utils/modal/alert";
import {OpenaireEntities} from "../../openaireLibrary/utils/properties/searchFields";
import {HelperFunctions} from "../../openaireLibrary/utils/HelperFunctions.class";
@Component({ @Component({
selector: 'remove-content-providers', selector: 'remove-content-providers',
@ -25,12 +27,13 @@ import {AlertModal} from "../../openaireLibrary/utils/modal/alert";
export class RemoveContentProvidersComponent implements OnInit { export class RemoveContentProvidersComponent implements OnInit {
public routerHelper: RouterHelper = new RouterHelper(); public routerHelper: RouterHelper = new RouterHelper();
public contentProviderUrl = "https://" + ((properties.environment == "beta" || properties.environment == "development") ? "beta." : "") + "explore.openaire.eu" + properties.searchLinkToDataProvider; public contentProviderUrl = "https://" + ((properties.environment == "beta" || properties.environment == "development") ? "beta." : "") + "explore.openaire.eu" + properties.searchLinkToDataProvider;
public previewCommunityContentProviders = []; public previewCommunityContentProviders: ContentProvider[] = [];
public errorCodes: ErrorCodes; public errorCodes: ErrorCodes;
public openAIREEntities = OpenaireEntities;
@Input() public loading: boolean = true; @Input() public loading: boolean = true;
@Input() public disableAdd: boolean = false; @Input() public disableAdd: boolean = false;
@Input() public community: CommunityInfo; @Input() public community: CommunityInfo;
@Input() public communityContentProviders = []; @Input() public communityContentProviders: ContentProvider[] = [];
@Output() communityContentProvidersChanged = new EventEmitter(); @Output() communityContentProvidersChanged = new EventEmitter();
private properties: EnvProperties = properties; private properties: EnvProperties = properties;
private subscriptions: any[] = []; private subscriptions: any[] = [];
@ -49,7 +52,7 @@ export class RemoveContentProvidersComponent implements OnInit {
private searchText: RegExp = new RegExp(''); private searchText: RegExp = new RegExp('');
public keyword: string = ''; public keyword: string = '';
@Output() addContentProviders: EventEmitter<void> = new EventEmitter(); @Output() addContentProviders: EventEmitter<void> = new EventEmitter();
@Input() public toggle: boolean = true; @Output() editCriteria: EventEmitter<ContentProvider> = new EventEmitter<ContentProvider>();
constructor(private route: ActivatedRoute, private _router: Router, constructor(private route: ActivatedRoute, private _router: Router,
private _fb: FormBuilder, private _fb: FormBuilder,
@ -100,7 +103,7 @@ export class RemoveContentProvidersComponent implements OnInit {
let index = this.communityContentProviders.indexOf(this.selectedCommunityContentProvider); let index = this.communityContentProviders.indexOf(this.selectedCommunityContentProvider);
this.communityContentProviders.splice(index, 1); this.communityContentProviders.splice(index, 1);
this.applyFilters(); this.applyFilters();
this.handleSuccess('Content Provider successfully removed!') this.handleSuccess(this.openAIREEntities.DATASOURCE + ' successfully removed!')
this.communityContentProvidersChanged.emit({ this.communityContentProvidersChanged.emit({
value: this.communityContentProviders, value: this.communityContentProviders,
}); });
@ -114,7 +117,7 @@ export class RemoveContentProvidersComponent implements OnInit {
public removeContentProvider(communityContentProvider: any) { public removeContentProvider(communityContentProvider: any) {
this.selectedCommunityContentProvider = communityContentProvider; this.selectedCommunityContentProvider = communityContentProvider;
this.deleteModal.alertTitle = "Remove content provider"; this.deleteModal.alertTitle = "Remove " + this.openAIREEntities.DATASOURCE;
let title = ""; let title = "";
if (communityContentProvider.name) { if (communityContentProvider.name) {
title = communityContentProvider.name; title = communityContentProvider.name;
@ -128,7 +131,7 @@ export class RemoveContentProvidersComponent implements OnInit {
if (communityContentProvider.name && communityContentProvider.acronym) { if (communityContentProvider.name && communityContentProvider.acronym) {
title += ")"; title += ")";
} }
this.deleteModal.message = "Content Provider"; this.deleteModal.message = this.openAIREEntities.DATASOURCE;
if (title) { if (title) {
this.deleteModal.message += " '" + title + "' "; this.deleteModal.message += " '" + title + "' ";
} }
@ -140,6 +143,7 @@ export class RemoveContentProvidersComponent implements OnInit {
public getCommunityContentProviders() { public getCommunityContentProviders() {
this.communityContentProviders = []; this.communityContentProviders = [];
this.loading = true;
this.subscriptions.push(this._searchCommunityContentProvidersService.searchDataproviders(this.properties, this.community.communityId).subscribe( this.subscriptions.push(this._searchCommunityContentProvidersService.searchDataproviders(this.properties, this.community.communityId).subscribe(
data => { data => {
this.communityContentProviders = data; this.communityContentProviders = data;
@ -157,10 +161,11 @@ export class RemoveContentProvidersComponent implements OnInit {
} }
public updatePage($event) { public updatePage($event) {
HelperFunctions.scroll();
this.page = $event.value; this.page = $event.value;
} }
get currentPage(): any[] { get currentPage(): ContentProvider[] {
return this.previewCommunityContentProviders.slice((this.page - 1)*this.resultsPerPage, this.page*this.resultsPerPage); return this.previewCommunityContentProviders.slice((this.page - 1)*this.resultsPerPage, this.page*this.resultsPerPage);
} }
@ -190,13 +195,7 @@ export class RemoveContentProvidersComponent implements OnInit {
NotificationHandler.rise(message, 'danger'); NotificationHandler.rise(message, 'danger');
} }
goToCriteria(openaireId: string) { openCriteria(contentProvider: ContentProvider) {
this._router.navigate([openaireId], { this.editCriteria.emit(contentProvider);
queryParams: {
// community: this.portal,
// provider: openaireId
},
relativeTo: this.route
})
} }
} }

View File

@ -24,6 +24,6 @@ import {SearchInputModule} from '../../openaireLibrary/sharedComponents/search-i
}) })
export class ManageCommunitiesModule { export class ManageCommunitiesModule {
constructor(private iconsService: IconsService) { constructor(private iconsService: IconsService) {
this.iconsService.registerIcons([group, lock, earth]); this.iconsService.registerIcons([earth]);
} }
} }

View File

@ -8,7 +8,7 @@ import {Subscription} from "rxjs";
template: ` template: `
<div page-content> <div page-content>
<div inner> <div inner>
<div class="mining"> <div class="mining uk-section">
<router-outlet></router-outlet> <router-outlet></router-outlet>
</div> </div>
</div> </div>

View File

@ -1,110 +1,152 @@
<div [class]="'uk-width-1-1 uk-flex uk-flex-middle uk-grid uk-margin-medium-bottom ' + (allOptions.length > 0 ? '' : 'uk-flex-right@m')" uk-grid> <ng-template #selected_filters_pills>
<div *ngIf="allOptions?.length > 0" <h1>
class="uk-width-1-2@m uk-width-1-1"> <div class="uk-width-1-1" uk-slider="finite: true">
<div class="uk-grid uk-flex uk-flex-middle uk-flex-wrap uk-flex-center uk-flex-right@m uk-width-1-1"> <div [class.uk-invisible]="list.children.length === 0" class="uk-position-relative">
<span class="">Filter by: </span> <div class="uk-slider-container" style="height: 40px">
<div class="uk-width-expand uk-padding-remove uk-margin-small-left" dashboard-input <ul #list class="uk-slider-items uk-grid uk-grid-small uk-margin-small-right uk-flex-nowrap">
[formInput]="filterForm.get('funder')" <ng-container *ngIf="funders && funders.countSelectedValues > 0">
placeholder="Search by funder" <ng-container *ngFor="let value of getSelectedValues(funders); let i = index; let end = last; ">
type="autocomplete" [options]="allOptions" [showOptionsOnEmpty]="false"> <li>
<span class="uk-label uk-label-primary uk-flex uk-flex-middle">
<span
class="uk-margin-small-right uk-width-expand uk-text-truncate">
<span *ngIf="funders.type && funders.type == 'boolean' else noboolean">{{funders.title}}:
{{value.name=='true'?'Yes':'No'}}
</span>
<ng-template #noboolean>
{{value.name}}
</ng-template></span>
<button class="uk-close uk-icon" [class.uk-disabled]="disabled" [disabled]="disabled" (click)="removeFilter(value, funders)">
<icon name="close" flex="true" ratio="0.7"></icon>
</button>
</span>
</li>
</ng-container>
</ng-container>
</ul>
</div>
<div class="">
<a class="uk-position-center-left blur-background" uk-slider-item="previous"><span uk-icon="chevron-left"></span></a>
<a class="uk-position-center-right blur-background" uk-slider-item="next"><span uk-icon="chevron-right"></span></a>
</div>
</div> </div>
</div> </div>
</h1>
</ng-template>
<ng-template #filters_column>
<!-- [class.filterLoading]="disabled"-->
<div >
<div class="uk-flex uk-flex-middle">
<h4 class="uk-margin-right uk-margin-remove-bottom">Filters</h4>
<a *ngIf="selectedFunderId" (click)="clearFilters()"
class="uk-text-small" [class.uk-disabled]="disabled" [class.uk-link-muted]="disabled">
Clear All
</a>
</div>
<!-- <div *ngIf="openaireSearchUtils.refineStatus == errorCodes.LOADING"-->
<!-- class="uk-margin-top" role="alert">-->
<!-- <loading></loading>-->
<!-- </div>-->
<div *ngIf="openaireSearchUtils.refineStatus != errorCodes.LOADING && openaireSearchUtils.refineStatus != errorCodes.DONE && openaireProjects.length > 0"
class="uk-margin-top uk-text-meta">
<span *ngIf="openaireSearchUtils.refineStatus == errorCodes.NONE">No filters available</span>
<span *ngIf="openaireSearchUtils.refineStatus != errorCodes.NONE" class="uk-text-warning">Filters temporarily unavailable. Please try again later.</span>
</div>
<ul class="uk-list uk-list-xlarge">
<li *ngIf="funders && funders.values && funders.values.length > 0">
<search-filter [showMoreInline]="true"
[filter]="funders" [showResultCount]="true"
[actionRoute]="false" (onFilterChange)="funderChanged(funders)"
[isDisabled]="disabled">
</search-filter>
</li>
</ul>
</div> </div>
<div class="uk-flex uk-flex-wrap uk-flex-center uk-flex-right@m uk-width-1-1 uk-width-1-2@m"> </ng-template>
<div class="uk-width-1-1 uk-width-expand@m">
<div #searchInputComponent search-input [control]="filterForm.controls.keyword" [showSearch]="false" <div class="uk-section uk-flex uk-flex-center uk-flex uk-flex-middle">
placeholder="Search Projects" <div class="uk-width-auto uk-margin-right">
[selected]="openaireSearchUtils.keyword" (closeEmitter)="onSearchClose()" (resetEmitter)="resetInput()" <a uk-icon="icon: info; ratio: 1.3"></a>
[bordered]="true" colorClass="uk-text-secondary"></div> <div *ngIf="community" class="uk-dropdown uk-padding-small uk-width-medium" uk-dropdown="mode: hover">
If you cannot find a funder that is relevant for your community, please contact us
(<a
[href]="'mailto:' + properties.feedbackmailForMissingEntities +'?Subject=[OpenAIRE Connect - '+ community.shortTitle + '] report missing Funder' + '&body=' + body"
target="_top">{{properties.feedbackmailForMissingEntities}}</a>)
and we will try to get the funder on board!
</div> </div>
</div> </div>
<div search-input class="uk-width-xlarge@l uk-width-large" [searchControl]="filterForm.get('keyword')" searchInputClass="outer"
[placeholder]="'Search '+openaireEntities.PROJECTS" [disabled]="loading"></div>
</div> </div>
<div class="uk-section uk-section-small uk-position-relative">
<div id="manage-projects"> <div class="uk-grid" uk-grid>
<div *ngIf="openaireSearchUtils.status == errorCodes.LOADING" class="uk-position-large-top"> <div class="uk-width-1-4@m search-filters uk-visible@m">
<loading></loading> <ng-container *ngTemplateOutlet="filters_column; context: {}"></ng-container>
</div>
<div *ngIf="openaireSearchUtils.totalResults == 0"
class="uk-card uk-card-default uk-padding-large uk-text-center uk-margin-bottom uk-text-bold">
<div>
<div *ngIf="openaireSearchUtils.status == errorCodes.NONE">No OpenAIRE projects available</div>
<div *ngIf="openaireSearchUtils.status == errorCodes.NONE" class="uk-margin-top">
If you wish to suggest a new funder to include or report a missing project, please contact us via
<a target="_top"
[href]="'mailto:' + properties.feedbackmailForMissingEntities +'?Subject=[OpenAIRE Connect - '+ community + '] report missing project' + '&body=' + body">
feedback@openaire.eu</a>.
</div>
<div *ngIf="openaireSearchUtils.status == errorCodes.ERROR">An Error Occurred. No OpenAIRE projects found</div>
<div *ngIf="openaireSearchUtils.status == errorCodes.NOT_AVAILABLE">Service temporarily unavailable. Please try again later.</div>
<div *ngIf="openaireSearchUtils.status == errorCodes.NOT_FOUND">No OpenAIRE projects found</div>
<!-- <div *ngIf="openaireSearchUtils.status == errorCodes.OUT_OF_BOUND">Requested page out of bounds</div>-->
</div> </div>
</div> <div class="uk-width-expand@m uk-with-1-1@s">
<!-- <errorMessages [status]="[openaireSearchUtils.status]" [type]="'OpenAIRE projects'"></errorMessages>--> <div *ngIf="(selectedFunderId && openaireSearchUtils.status !== errorCodes.LOADING)">
<!-- <div *ngIf="openaireSearchUtils.status == errorCodes.NONE" class="uk-alert uk-alert-primary">--> <ng-container *ngTemplateOutlet="selected_filters_pills;"></ng-container>
<!-- <span class="uk-margin-small-right uk-icon" uk-icon="warning"></span>--> </div>
<!-- If you wish to suggest a new funder to include or report a missing project, please contact us via--> <div>
<!-- <a--> <div *ngIf="openaireSearchUtils.status == errorCodes.LOADING" class="uk-position-center">
<!-- [href]="'mailto:' + properties.feedbackmailForMissingEntities +'?Subject=[OpenAIRE Connect - '+ community + '] report missing project' + '&body=' + body"--> <loading></loading>
<!-- target="_top">feedback@openaire.eu</a>.--> </div>
<!-- </div>--> <div *ngIf="openaireSearchUtils.status !== errorCodes.LOADING">
<div *ngIf="openaireSearchUtils.totalResults == 0"
<ng-container *ngIf="openaireSearchUtils.totalResults > 0"> class="uk-card uk-card-default uk-padding-large uk-text-center uk-margin-bottom uk-text-bold">
<no-load-paging [type]="'Projects'" <div>No {{openaireEntities.PROJECTS | lowercase}} found</div>
[page]="openaireSearchUtils.page" [pageSize]="resultsPerPage" (pageChange)="goTo($event.value)" </div>
[totalResults]="openaireSearchUtils.totalResults"> <ng-container *ngIf="openaireSearchUtils.totalResults > 0">
</no-load-paging> <no-load-paging [type]="openaireEntities.PROJECTS"
[page]="openaireSearchUtils.page" [pageSize]="resultsPerPage" (pageChange)="goTo($event.value, false)"
<ul class="uk-list search-results uk-margin-medium-top uk-margin-medium-bottom"> [totalResults]="openaireSearchUtils.totalResults">
<li *ngFor="let result of openaireProjects" class="uk-animation-fade"> </no-load-paging>
<div class="uk-card uk-card-default uk-card-hover uk-text-small uk-margin-bottom"> <div class="uk-grid uk-child-width-1-1 uk-margin-medium-top uk-margin-bottom" uk-grid>
<div class="uk-grid uk-grid-divider uk-padding-small" uk-grid> <div *ngFor="let result of openaireProjects">
<div class="uk-width-expand@m uk-width-1-1"> <div class="uk-card uk-card-default">
<result-preview [properties]="properties" [showOrganizations]="true" <div class="uk-card-body">
[showSubjects]="true" [result]="getResultPreview(result)" <result-preview [properties]="properties" [showOrganizations]="true"
[externalUrl]="projectUrl"> [showSubjects]="true" [result]="getResultPreview(result)"
</result-preview> [externalUrl]="projectUrl">
</div> </result-preview>
<div class="uk-width-auto@m uk-width-1-1">
<div class="uk-flex uk-flex-middle uk-flex-center uk-flex-column uk-height-1-1">
<div class="uk-padding-small uk-padding-remove-horizontal">
<div [class.hide-element]="!getCommunityProject(result)">
<a (click)="removeProject(result)" class="uk-button action uk-flex uk-flex-middle">
<icon name="remove_circle_outline"></icon>
<span class="uk-margin-small-left">Remove project</span>
</a>
</div> </div>
<div class="uk-card-footer uk-padding-remove-vertical">
<div [class.hide-element]="getCommunityProject(result)"> <div class="uk-grid uk-grid-small uk-flex-nowrap uk-grid-divider uk-flex-right" uk-grid>
<a (click)="addProject(result)" class="uk-button action uk-flex uk-flex-middle" <div *ngIf="!getCommunityProject(result)">
uk-tooltip="title:<div class='uk-padding-small'><div class='uk-margin-bottom uk-text-bold'>Add new project </div><div>Newly added projects will be linked to your community on the next run of our algorithms.</div></div>"> <div class="uk-padding-small uk-padding-remove-horizontal">
<div class="uk-text-success"> <a (click)="addProject(result)" class="uk-button uk-button-link uk-flex uk-flex-middle">
<icon name="add"></icon> <icon name="add" [flex]="true"></icon>
<span class="uk-margin-small-left">
Add
</span>
</a>
</div>
</div> </div>
<span class="uk-margin-small-left">Add project</span> <div *ngIf="getCommunityProject(result)">
</a> <div class="uk-padding-small uk-padding-remove-horizontal">
<a (click)="removeProject(result)"
class="uk-button uk-button-link uk-flex uk-flex-middle">
<icon name="remove" [flex]="true"></icon>
<span class="uk-margin-small-left">Remove</span>
</a>
</div>
</div>
</div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> <div class="uk-margin-small-top">
<no-load-paging [type]="openaireEntities.PROJECTS"
[page]="openaireSearchUtils.page" [pageSize]="resultsPerPage" (pageChange)="goTo($event.value, false)"
[totalResults]="openaireSearchUtils.totalResults">
</no-load-paging>
</div>
</ng-container>
</div> </div>
</li> </div>
</ul>
<!-- <div [class]="openaireSearchUtils.page > pagingLimit ? 'search-results' : ''"--> </div>
<!-- *ngIf="(openaireSearchUtils.page >= pagingLimit) && (openaireSearchUtils.totalResults > resultsPerPage*pagingLimit)">--> </div>
<!-- <div class="uk-card uk-card-default uk-padding-large uk-text-center uk-margin-bottom uk-text-bold">--> </div>
<!-- For more results please try a new, more specific query-->
<!-- </div>-->
<!-- </div>-->
<no-load-paging [type]="'Projects'"
[page]="openaireSearchUtils.page" [pageSize]="resultsPerPage" (pageChange)="goTo($event.value)"
[totalResults]="openaireSearchUtils.totalResults">
</no-load-paging>
</ng-container>
</div>

View File

@ -9,15 +9,16 @@ import {RouterHelper} from '../../openaireLibrary/utils/routerHelper.class';
import {StringUtils} from '../../openaireLibrary/utils/string-utils.class'; import {StringUtils} from '../../openaireLibrary/utils/string-utils.class';
import {ManageCommunityProjectsService} from '../../services/manageProjects.service'; import {ManageCommunityProjectsService} from '../../services/manageProjects.service';
import {Session} from '../../openaireLibrary/login/utils/helper.class';
import {LoginErrorCodes} from '../../openaireLibrary/login/utils/guardHelper.class';
import {properties} from "../../../environments/environment"; import {properties} from "../../../environments/environment";
import {Subscriber} from "rxjs"; import {Subscriber} from "rxjs";
import {FormBuilder, FormGroup} from "@angular/forms"; import {FormBuilder, FormGroup} from "@angular/forms";
import {Option} from "../../openaireLibrary/sharedComponents/input/input.component";
import {debounceTime, distinctUntilChanged} from "rxjs/operators"; import {debounceTime, distinctUntilChanged} from "rxjs/operators";
import {ResultPreview} from "../../openaireLibrary/utils/result-preview/result-preview"; import {ResultPreview} from "../../openaireLibrary/utils/result-preview/result-preview";
import {SearchInputComponent} from "../../openaireLibrary/sharedComponents/search-input/search-input.component"; import {SearchInputComponent} from "../../openaireLibrary/sharedComponents/search-input/search-input.component";
import {CommunityInfo} from "../../openaireLibrary/connect/community/communityInfo";
import {OpenaireEntities} from "../../openaireLibrary/utils/properties/searchFields";
import {Filter, Value} from "../../openaireLibrary/searchPages/searchUtils/searchHelperClasses.class";
import {HelperFunctions} from "../../openaireLibrary/utils/HelperFunctions.class";
declare var UIkit; declare var UIkit;
@ -30,7 +31,7 @@ export class AddProjectsComponent implements OnInit {
private subscriptions: any[] = []; private subscriptions: any[] = [];
public subResults: any; public subResults: any;
private community: string = ''; @Input() community: CommunityInfo = null;
public routerHelper: RouterHelper = new RouterHelper(); public routerHelper: RouterHelper = new RouterHelper();
public properties: EnvProperties = properties; public properties: EnvProperties = properties;
@ -46,35 +47,30 @@ export class AddProjectsComponent implements OnInit {
public selectedFunderId: string = ""; public selectedFunderId: string = "";
filterForm: FormGroup; filterForm: FormGroup;
allOptions: Option[] = []; funders: Filter = null;
@ViewChild('searchInputComponent') searchInputComponent: SearchInputComponent; @ViewChild('searchInputComponent') searchInputComponent: SearchInputComponent;
private projectUrl: string = "https://" + ((properties.environment == "beta" || properties.environment == "development") ? "beta." : "") + "explore.openaire.eu" + properties.searchLinkToProject; private projectUrl: string = "https://" + ((properties.environment == "beta" || properties.environment == "development") ? "beta." : "") + "explore.openaire.eu" + properties.searchLinkToProject;
public body: string = "Send from page"; public body: string = "Send from page";
@Output() toggleView: EventEmitter<any> = new EventEmitter(); openaireEntities = OpenaireEntities;
constructor(private route: ActivatedRoute, private _router: Router, private _searchProjectsService: SearchProjectsService, constructor(private route: ActivatedRoute, private _router: Router, private _searchProjectsService: SearchProjectsService,
private _manageCommunityProjectsService: ManageCommunityProjectsService, private _manageCommunityProjectsService: ManageCommunityProjectsService,
private _fb: FormBuilder) { private _fb: FormBuilder) {
this.errorCodes = new ErrorCodes(); this.errorCodes = new ErrorCodes();
this.openaireSearchUtils.status = this.errorCodes.LOADING; this.openaireSearchUtils.status = this.errorCodes.LOADING;
this.openaireSearchUtils.refineStatus = this.errorCodes.LOADING;
} }
ngOnInit() { ngOnInit() {
this.subscriptions.push(this.route.params.subscribe(params => { this.openaireSearchUtils.status = this.errorCodes.LOADING;
this.openaireSearchUtils.status = this.errorCodes.LOADING; this.openaireSearchUtils.refineStatus = this.errorCodes.LOADING;
this.getFunders();
this._getOpenaireProjects("", 1, this.resultsPerPage);
this.community = params['community']; this.body = "[Please write your message here]";
// this.projectUrl = "https://" + ((this.properties.environment == "beta" || this.properties.environment == "development") ? "beta." : "") this.body = StringUtils.URIEncode(this.body);
// + this.community + ".openaire.eu" + this.properties.searchLinkToProject;
this.getFunders();
this._getOpenaireProjects("", 1, this.resultsPerPage);
this.body = "[Please write your message here]";
this.body = StringUtils.URIEncode(this.body);
}));
this.openaireSearchUtils.keyword = ""; this.openaireSearchUtils.keyword = "";
@ -88,19 +84,6 @@ export class AddProjectsComponent implements OnInit {
.subscribe(value => { .subscribe(value => {
this.keywordChanged(value); this.keywordChanged(value);
})); }));
this.subscriptions.push(this.filterForm.get('funder').valueChanges
.pipe(debounceTime(1000), distinctUntilChanged())
.subscribe(value => {
// console.log("value: ",value);
if (value == null) {
// console.log("will be called funder changed: null");
this.funderChanged("", "");
} else if (value && value.id != undefined && value.id != this.selectedFunderId) {
// console.log("will be called funder changed: name="+value.label+", id="+value.id);
this.funderChanged(value.id, value.label);
}
}));
} }
public ngOnDestroy() { public ngOnDestroy() {
@ -115,65 +98,55 @@ export class AddProjectsComponent implements OnInit {
} }
} }
get loading() {
return this.openaireSearchUtils.status == this.errorCodes.LOADING
}
get disabled() {
return this.openaireSearchUtils.status == this.errorCodes.LOADING || this.openaireSearchUtils.refineStatus == this.errorCodes.LOADING;
}
public addProject(project: SearchResult) { public addProject(project: SearchResult) {
if (!Session.isLoggedIn()) { this.subscriptions.push(this._manageCommunityProjectsService.addProject(this.properties, this.community.communityId, project).subscribe(
this._router.navigate(['/user-info'], { data => {
queryParams: { this.communityProjects.push(data);
"errorCode": LoginErrorCodes.NOT_VALID, UIkit.notification('Project successfully added!', {
"redirectUrl": this._router.url status: 'success',
} timeout: 6000,
}); pos: 'bottom-right'
} else { });
this.subscriptions.push(this._manageCommunityProjectsService.addProject(this.properties, this.community, project).subscribe( this.communityProjectsChanged.emit({
data => { value: this.communityProjects,
this.communityProjects.push(data); });
UIkit.notification('Project successfully added!', { },
status: 'success', err => {
timeout: 6000, this.handleError('An error has been occurred. Try again later!');
pos: 'bottom-right' console.error(err.status);
}); }
this.communityProjectsChanged.emit({ ));
value: this.communityProjects,
});
},
err => {
this.handleError('An error has been occurred. Try again later!');
console.error(err.status);
}
));
}
} }
public removeProject(project: any) { public removeProject(project: any) {
if (!Session.isLoggedIn()) { let communityProject = this.getCommunityProject(project);
this._router.navigate(['/user-info'], { let projectId: string = communityProject['id'];
queryParams: { this.subscriptions.push(this._manageCommunityProjectsService.removeProject(this.properties, this.community.communityId, projectId).subscribe(
"errorCode": LoginErrorCodes.NOT_VALID, data => {
"redirectUrl": this._router.url let index = this.communityProjects.indexOf(communityProject);
} this.communityProjects.splice(index, 1);
}); UIkit.notification('Project successfully removed!', {
} else { status: 'success',
let communityProject = this.getCommunityProject(project); timeout: 6000,
let projectId: string = communityProject['id']; pos: 'bottom-right'
this.subscriptions.push(this._manageCommunityProjectsService.removeProject(this.properties, this.community, projectId).subscribe( });
data => { this.communityProjectsChanged.emit({
let index = this.communityProjects.indexOf(communityProject); value: this.communityProjects,
this.communityProjects.splice(index, 1); });
UIkit.notification('Project successfully removed!', { },
status: 'success', err => {
timeout: 6000, this.handleError('An error has been occurred. Try again later!');
pos: 'bottom-right' console.error(err);
}); }
this.communityProjectsChanged.emit({ ));
value: this.communityProjects,
});
},
err => {
this.handleError('An error has been occurred. Try again later!');
console.error(err);
}
));
}
} }
public getCommunityProject(project: any): string { public getCommunityProject(project: any): string {
@ -189,29 +162,27 @@ export class AddProjectsComponent implements OnInit {
} }
getFunders() { getFunders() {
if (!Session.isLoggedIn()) { this.openaireSearchUtils.refineStatus = this.errorCodes.LOADING;
this._router.navigate(['/user-info'], { this.subscriptions.push(this._searchProjectsService.getFunders(this.queryParameters, this.properties).subscribe(
queryParams: { data => {
"errorCode": LoginErrorCodes.NOT_VALID, this.funders = data[1][0];
"redirectUrl": this._router.url this.funders.values.map((value) => {
} if(value.id == this.selectedFunderId) {
}); value.selected = true;
} else { this.funders.countSelectedValues++;
this.subscriptions.push(this._searchProjectsService.getFunders(this.properties).subscribe(
data => {
let funders = data[1];
this.allOptions = [];
let i;
for (i = 0; i < funders.length; i++) {
let funder = funders[i];
if (funder && funder['id']) {
this.allOptions.push({label: funder['name'], value: {id: funder['id'], label: funder['name']}});
}
} }
}, })
err => console.error("Server error fetching funders: ", err) if(this.funders.values && this.funders.values.length == 0) {
)); this.openaireSearchUtils.refineStatus = this.errorCodes.NONE;
} } else {
this.openaireSearchUtils.refineStatus = this.errorCodes.DONE;
}
},
err => {
this.openaireSearchUtils.refineStatus = this.errorCodes.ERROR;
console.error("Server error fetching funders: ", err)
}
));
} }
public getResultPreview(result: SearchResult): ResultPreview { public getResultPreview(result: SearchResult): ResultPreview {
@ -219,63 +190,37 @@ export class AddProjectsComponent implements OnInit {
} }
private _getOpenaireProjects(parameters: string, page: number, size: number) { private _getOpenaireProjects(parameters: string, page: number, size: number) {
if (!Session.isLoggedIn()) { if (this.openaireSearchUtils.status == this.errorCodes.LOADING) {
this._router.navigate(['/user-info'], { this.openaireSearchUtils.status = this.errorCodes.LOADING;
queryParams: {
"errorCode": LoginErrorCodes.NOT_VALID,
"redirectUrl": this._router.url
}
});
} else {
// if (page > this.pagingLimit) {
// size = 0;
// }
if (this.openaireSearchUtils.status == this.errorCodes.LOADING) { this.openaireProjects = [];
this.openaireSearchUtils.status = this.errorCodes.LOADING; this.openaireSearchUtils.totalResults = 0;
this.openaireProjects = []; if (this.subResults) {
this.openaireSearchUtils.totalResults = 0; this.subResults.unsubscribe();
if (this.subResults) {
this.subResults.unsubscribe();
}
this.subResults = this._searchProjectsService.searchProjects(parameters, null, page, size, [], this.properties).subscribe(
data => {
this.openaireSearchUtils.totalResults = data[0];
this.openaireProjects = data[1];
//this.searchPage.checkSelectedFilters(this.filters);
this.openaireSearchUtils.status = this.errorCodes.DONE;
if (this.openaireSearchUtils.totalResults == 0) {
this.openaireSearchUtils.status = this.errorCodes.NONE;
}
// if (this.openaireSearchUtils.status == this.errorCodes.DONE) {
// // Page out of limit!!!
// let totalPages: any = this.openaireSearchUtils.totalResults / (this.openaireSearchUtils.size);
// if (!(Number.isInteger(totalPages))) {
// totalPages = (parseInt(totalPages, 10) + 1);
// }
// if (totalPages < page) {
// this.openaireSearchUtils.totalResults = 0;
// this.openaireSearchUtils.status = this.errorCodes.OUT_OF_BOUND;
// }
// }
},
err => {
console.error(err);
//TODO check erros (service not available, bad request)
if (err.status == '404') {
this.openaireSearchUtils.status = this.errorCodes.NOT_FOUND;
} else if (err.status == '500') {
this.openaireSearchUtils.status = this.errorCodes.ERROR;
} else {
this.openaireSearchUtils.status = this.errorCodes.NOT_AVAILABLE;
}
}
);
} }
this.subResults = this._searchProjectsService.searchProjects(parameters, null, page, size, [], this.properties).subscribe(
data => {
this.openaireSearchUtils.totalResults = data[0];
this.openaireProjects = data[1];
this.openaireSearchUtils.status = this.errorCodes.DONE;
if (this.openaireSearchUtils.totalResults == 0) {
this.openaireSearchUtils.status = this.errorCodes.NONE;
}
},
err => {
console.error(err);
//TODO check erros (service not available, bad request)
if (err.status == '404') {
this.openaireSearchUtils.status = this.errorCodes.NOT_FOUND;
} else if (err.status == '500') {
this.openaireSearchUtils.status = this.errorCodes.ERROR;
} else {
this.openaireSearchUtils.status = this.errorCodes.NOT_AVAILABLE;
}
}
);
} }
} }
@ -293,9 +238,8 @@ export class AddProjectsComponent implements OnInit {
this.goTo(1); this.goTo(1);
} }
funderChanged(funderId: string, funderName: string) { funderChanged(filter: Filter) {
this.selectedFunderId = funderId; this.getSelectedValues(filter);
this.buildQueryParameters(); this.buildQueryParameters();
this.goTo(1); this.goTo(1);
} }
@ -313,16 +257,17 @@ export class AddProjectsComponent implements OnInit {
} }
} }
goTo(page: number = 1) { goTo(page: number = 1, refineQuery: boolean = true) {
HelperFunctions.scroll();
this.openaireSearchUtils.page = page; this.openaireSearchUtils.page = page;
this.openaireSearchUtils.status = this.errorCodes.LOADING; this.openaireSearchUtils.status = this.errorCodes.LOADING;
if(refineQuery) {
this.openaireSearchUtils.refineStatus = this.errorCodes.LOADING;
this.getFunders();
}
this._getOpenaireProjects(this.queryParameters, page, this.resultsPerPage); this._getOpenaireProjects(this.queryParameters, page, this.resultsPerPage);
} }
back() {
this.toggleView.emit(null);
}
public onSearchClose() { public onSearchClose() {
this.openaireSearchUtils.keyword = this.filterForm.get('keyword').value; this.openaireSearchUtils.keyword = this.filterForm.get('keyword').value;
} }
@ -339,4 +284,40 @@ export class AddProjectsComponent implements OnInit {
pos: 'bottom-right' pos: 'bottom-right'
}); });
} }
getSelectedValues(filter): any {
var selected = [];
this.selectedFunderId = "";
if (filter.countSelectedValues > 0) {
for (var i = 0; i < filter.values.length; i++) {
if (filter.values[i].selected) {
selected.push(filter.values[i]);
this.selectedFunderId = filter.values[i].id;
}
}
}
return selected;
}
clearFilters() {
for (var j = 0; j < this.funders.countSelectedValues; j++) {
if (this.funders.values[j].selected) {
this.removeFilter(this.funders.values[j], this.funders);
break;
}
}
}
public removeFilter(value: Value, filter: Filter) {
this.selectedFunderId = "";
filter.countSelectedValues--;
if (value.selected == true) {
value.selected = false;
}
if (filter.filterType == "radio") {
filter.radioValue = "";
}
this.buildQueryParameters();
this.goTo(1);
}
} }

View File

@ -20,11 +20,11 @@ import {SearchInputModule} from "../../openaireLibrary/sharedComponents/search-i
import {NoLoadPaging} from "../../openaireLibrary/searchPages/searchUtils/no-load-paging.module"; import {NoLoadPaging} from "../../openaireLibrary/searchPages/searchUtils/no-load-paging.module";
import {LoadingModule} from "../../openaireLibrary/utils/loading/loading.module"; import {LoadingModule} from "../../openaireLibrary/utils/loading/loading.module";
import {IconsModule} from "../../openaireLibrary/utils/icons/icons.module"; import {IconsModule} from "../../openaireLibrary/utils/icons/icons.module";
import {IconsService} from "../../openaireLibrary/utils/icons/icons.service";
import {add, arrow_left, close, remove_circle_outline} from "../../openaireLibrary/utils/icons/icons";
import {FullScreenModalModule} from "../../openaireLibrary/utils/modal/full-screen-modal/full-screen-modal.module"; import {FullScreenModalModule} from "../../openaireLibrary/utils/modal/full-screen-modal/full-screen-modal.module";
import {ResultPreviewModule} from "../../openaireLibrary/utils/result-preview/result-preview.module"; import {ResultPreviewModule} from "../../openaireLibrary/utils/result-preview/result-preview.module";
import {ErrorMessagesModule} from "../../openaireLibrary/utils/errorMessages.module"; import {ErrorMessagesModule} from "../../openaireLibrary/utils/errorMessages.module";
import {DropdownFilterModule} from "../../openaireLibrary/utils/dropdown-filter/dropdown-filter.module";
import {SearchFilterModule} from "../../openaireLibrary/searchPages/searchUtils/searchFilter.module";
@NgModule({ @NgModule({
imports: [ imports: [
@ -46,7 +46,7 @@ import {ErrorMessagesModule} from "../../openaireLibrary/utils/errorMessages.mod
path: '', component: ManageProjectsComponent path: '', component: ManageProjectsComponent
} }
]), ]),
NoLoadPaging, LoadingModule, IconsModule, FullScreenModalModule, ResultPreviewModule NoLoadPaging, LoadingModule, IconsModule, FullScreenModalModule, ResultPreviewModule, DropdownFilterModule, SearchFilterModule
], ],
declarations: [ declarations: [
ManageProjectsComponent, ManageProjectsComponent,
@ -60,7 +60,5 @@ import {ErrorMessagesModule} from "../../openaireLibrary/utils/errorMessages.mod
exports: [ManageProjectsComponent] exports: [ManageProjectsComponent]
}) })
export class CommunityProjectsModule { export class CommunityProjectsModule {
constructor(private iconsService: IconsService) { constructor() {}
this.iconsService.registerIcons([remove_circle_outline, add, close, arrow_left]);
}
} }

View File

@ -3,39 +3,26 @@ import {ActivatedRoute, Router} from "@angular/router";
import {RemoveProjectsComponent} from './remove-projects.component'; import {RemoveProjectsComponent} from './remove-projects.component';
import {Session} from '../../openaireLibrary/login/utils/helper.class';
import {LoginErrorCodes} from '../../openaireLibrary/login/utils/guardHelper.class';
import {HelperFunctions} from "../../openaireLibrary/utils/HelperFunctions.class";
import {Title} from '@angular/platform-browser'; import {Title} from '@angular/platform-browser';
import {FullScreenModalComponent} from "../../openaireLibrary/utils/modal/full-screen-modal/full-screen-modal.component"; import {FullScreenModalComponent} from "../../openaireLibrary/utils/modal/full-screen-modal/full-screen-modal.component";
import {StringUtils} from "../../openaireLibrary/utils/string-utils.class"; import {StringUtils} from "../../openaireLibrary/utils/string-utils.class";
import {EnvProperties} from "../../openaireLibrary/utils/properties/env-properties"; import {EnvProperties} from "../../openaireLibrary/utils/properties/env-properties";
import {properties} from "../../../environments/environment"; import {properties} from "../../../environments/environment";
import {Subscriber} from "rxjs"; import {Subscriber} from "rxjs";
import {CommunityInfo} from "../../openaireLibrary/connect/community/communityInfo";
import {OpenaireEntities} from "../../openaireLibrary/utils/properties/searchFields";
import {CommunityService} from "../../openaireLibrary/connect/community/community.service";
@Component({ @Component({
selector: 'manage-projects', selector: 'manage-projects',
template: ` template: `
<remove-projects (toggleView)="toggleAction()" [communityProjects]="communityProjects" <remove-projects #removeProjectsComponent (addProjects)="openAddProjects()" [communityProjects]="communityProjects"
[showLoading]="showLoadingInRemove" [loading]="showLoadingInRemove" [community]="community" [disableAdd]="add.loading"
(communityProjectsChanged)="communityProjectsChanged($event)" [toggle]="toggle"> (communityProjectsChanged)="communityProjectsChanged($event)">
</remove-projects> </remove-projects>
<fs-modal #fsModal (cancelEmitter)="toggleAction()"> <fs-modal #fsModal>
<div actions class="uk-flex uk-flex-middle uk-height-1-1"> <add-projects #add [communityProjects]="communityProjects" [community]="community"
<span class="uk-button uk-text-secondary" uk-icon="icon: info; ratio: 1.3"></span> (communityProjectsChanged)="communityProjectsChanged($event)"></add-projects>
<div *ngIf="communityId" uk-drop="mode: hover">
<div class="uk-card uk-card-body uk-card-default">
If you cannot find a funder that is relevant for your community, please contact us
(<a
[href]="'mailto:' + properties.feedbackmailForMissingEntities +'?Subject=[OpenAIRE Connect - '+ communityId + '] report missing Funder' + '&body=' + body"
target="_top">{{properties.feedbackmailForMissingEntities}}</a>)
and we will try to get the funder on board!
</div>
</div>
</div>
<add-projects [communityProjects]="communityProjects"
(communityProjectsChanged)="communityProjectsChanged($event)"></add-projects>
</fs-modal> </fs-modal>
` `
}) })
@ -44,34 +31,27 @@ export class ManageProjectsComponent implements OnInit {
@Input() communityProjects = []; @Input() communityProjects = [];
@ViewChild(RemoveProjectsComponent) removeProjectsComponent: RemoveProjectsComponent; @ViewChild(RemoveProjectsComponent) removeProjectsComponent: RemoveProjectsComponent;
@ViewChild('fsModal', { static: true }) fullscreen: FullScreenModalComponent; @ViewChild('fsModal', { static: true }) fullscreen: FullScreenModalComponent;
public toggle: boolean = false;
private subscriptions: any[] = []; private subscriptions: any[] = [];
public showLoadingInRemove: boolean = true; public showLoadingInRemove: boolean = true;
public body: string = "Send from page"; public body: string = "Send from page";
public properties: EnvProperties = properties; public properties: EnvProperties = properties;
public communityId: string = ""; public community: CommunityInfo = null;
constructor(private element: ElementRef, constructor(private element: ElementRef,
private title: Title, private title: Title,
private route: ActivatedRoute, private _router: Router) { private route: ActivatedRoute, private _router: Router,
private communityService: CommunityService) {
} }
ngOnInit() { ngOnInit() {
this.subscriptions.push(this.route.params.subscribe(params => { this.subscriptions.push(this.communityService.getCommunityAsObservable().subscribe(community => {
this.communityId = params['community']; this.community = community;
if (this.community) {
if (this.communityId) { this.title.setTitle(this.community.shortTitle.toUpperCase() + ' | ' + OpenaireEntities.PROJECTS);
this.title.setTitle(this.communityId.toUpperCase() + ' | Projects');
this.body = "[Please write your message here]"; this.body = "[Please write your message here]";
this.body = StringUtils.URIEncode(this.body); this.body = StringUtils.URIEncode(this.body);
} }
this.fullscreen.title = "Search and Add Projects";
this.fullscreen.okButtonText = "Done";
this.fullscreen.okButton = true;
})); }));
} }
@ -83,26 +63,19 @@ export class ManageProjectsComponent implements OnInit {
}); });
} }
public toggleAction() { public openAddProjects() {
if (!Session.isLoggedIn()) { this.fullscreen.title = "Search and Add "+OpenaireEntities.PROJECTS;
this._router.navigate(['/user-info'], { this.fullscreen.okButtonText = "Done";
queryParams: {'errorCode': LoginErrorCodes.NOT_VALID, 'redirectUrl': this._router.url} this.fullscreen.back = true;
}); this.fullscreen.okButton = true;
} else { this.fullscreen.open();
HelperFunctions.scroll();
this.toggle = !this.toggle;
if (this.toggle) {
this.fullscreen.open();
}
}
} }
public communityProjectsChanged($event) { public communityProjectsChanged($event) {
this.communityProjects = $event.value; this.communityProjects = $event.value;
this.showLoadingInRemove = false; this.showLoadingInRemove = false;
if (this.toggle) { if (this.fullscreen.isOpen) {
this.removeProjectsComponent.applyFilters(); this.removeProjectsComponent.applyFilters();
this.removeProjectsComponent.createFunderFilter(); this.removeProjectsComponent.createFunderFilter();
} }

View File

@ -1,116 +1,141 @@
<div page-content> <div page-content (stickyEmitter)="stickyPageHeader = $event">
<div header> <div header>
<community-info tab="projects"></community-info> <div class="uk-flex uk-flex-middle uk-margin-top info" [class.uk-active]="stickyPageHeader">
<div [class.uk-invisible]="showLoading" <div>
class="uk-width-1-1 uk-flex uk-flex-right@m uk-flex-center uk-flex-wrap uk-flex-middle uk-grid" uk-grid> <div class="uk-margin-remove uk-text-background uk-text-bold uk-h6">Admin Dashboard - Manage {{openaireEntiites.PROJECTS}}
<div class="uk-flex-last@m"> </div>
<a class="uk-text-uppercase uk-flex uk-flex-middle" (click)="addNew()" <h1 class="uk-h4 uk-margin-remove">{{community.shortTitle}}</h1>
[attr.uk-tooltip]="(toggle? 'cls: uk-invisible; ' : 'cls: uk-active; ') +
'title: <div class=\'uk-padding-small\'><div class=\'uk-margin-bottom uk-text-bold\'> Search and add more Projects</div><div>The research results linked to the projects specified here will be automatically linked to your community dashboard.</div></div>'">
<button class="uk-icon-button large uk-button-secondary">
<icon name="add"></icon>
</button>
<button class="uk-button uk-button-link uk-margin-small-left uk-text-secondary">Add new project</button>
</a>
</div> </div>
<div #searchInputComponent search-input [control]="filterForm.controls.keyword" [showSearch]="false"
placeholder="Search Projects"
[selected]="communitySearchUtils.keyword" (closeEmitter)="onSearchClose()" (resetEmitter)="resetInput()"
[bordered]="true" colorClass="uk-text-secondary"
class="uk-width-1-3@xl uk-width-2-5@l uk-width-1-2@m uk-width-1-1"></div>
</div> </div>
<community-info tab="projects"></community-info>
</div> </div>
<div inner> <div inner>
<div *ngIf="showLoading" class="uk-margin-large-top"> <div class="uk-flex uk-flex-middle uk-margin-top">
<loading></loading> <div class="uk-width-expand@m uk-width-1-1 uk-grid uk-flex-middle uk-flex-right@m uk-flex-center uk-margin-remove-left" uk-grid>
<div search-input [expandable]="true" [searchControl]="filterForm.get('keyword')" searchInputClass="outer"
placeholder="Search project" [disabled]="loading"
class="uk-width-1-3@xl uk-width-2-5@l uk-width-1-2@m uk-width-1-1"></div>
<div>
<button class="uk-button uk-button-default uk-flex uk-flex-middle"
(click)="addNew()"
[attr.uk-tooltip]="('cls: uk-active; ') +
'title: <div class=\'uk-margin-bottom uk-text-bold\'> Search and add more '+openaireEntiites.PROJECTS+'</div>' +
'<div>The research results linked to the <span class=\'uk-text-lowercase\'>'+openaireEntiites.PROJECTS +
'</span> specified here will be automatically linked to your <span class=\'uk-text-lowercase\'>'+openaireEntiites.COMMUNITY+'</span> dashboard.</div>'"
[disabled]="loading || disableAdd" [class.uk-disabled]="loading || disableAdd">
<icon name="add" [flex]="true"></icon>
<span class="uk-margin-small-left">New {{openaireEntiites.PROJECT}}</span>
</button>
</div>
</div>
</div>
<div class="uk-margin-top">
<results-and-pages [type]="openaireEntiites.PROJECTS | lowercase" [page]="page" [pageSize]="resultsPerPage"
[totalResults]="previewCommunityProjects.length"></results-and-pages>
</div> </div>
<div *ngIf="!showLoading"> <div class="uk-grid uk-flex-middle uk-margin-medium-top" uk-grid>
<div *ngIf="allOptions.length > 0">
<dropdown-filter #dropdownFilter dropdownClass="uk-width-medium uk-padding-small"
name="Filter by Funder" [count]="filterForm.get('funder').value.length">
<h6 class="uk-margin-remove-bottom" title="Filter by Funder">Funder</h6>
<ul class="uk-list uk-margin-remove-bottom">
<li *ngFor="let option of allOptions">
<a class="uk-link-text">
<label (click)="select(option.value, $event, dropdownFilter)" class="uk-flex uk-flex-middle">
<input class="uk-checkbox"
type="checkbox" [checked]="isSelected(option.value)">
<span class="uk-margin-small-left">{{option.label}}</span>
</label>
</a>
</li>
</ul>
</dropdown-filter>
</div>
<div> <div>
<div class="uk-grid uk-flex uk-flex-middle uk-margin-medium-bottom" uk-grid> <div input inputClass="flat x-small" placeholder="Sort by"
<div *ngIf="allOptions.length > 0" [disabled]="previewCommunityProjects.length == 0"
class="uk-grid uk-flex-middle uk-flex-left@m uk-flex-center uk-width-1-3@xl uk-width-2-5@l uk-width-1-2@m uk-width-1-1 uk-first-column"> [formInput]="filterForm.get('sort')"
<span class="">Filter by: </span> type="select" [options]="sortOptions"
<div class="uk-width-expand uk-padding-remove uk-margin-small-left" dashboard-input class="uk-width-small">
[formInput]="filterForm.get('funder')"
placeholder="Search by funders"
type="chips" [options]="allOptions" chipLabel="label">
</div>
</div>
<div *ngIf="previewCommunityProjects.length > 0"
class="uk-width-expand@m uk-width-1-1">
<div class="uk-flex-middle uk-flex-right@m uk-flex-center uk-grid">
<span class="">Sort by: </span>
<div class="uk-width-medium uk-padding-remove uk-margin-small-left" dashboard-input
[formInput]="filterForm.get('sort')"
type="select"
[options]="sortOptions">
</div>
</div>
</div>
</div> </div>
<no-load-paging *ngIf="previewCommunityProjects.length > 0" [type]="'projects'" </div>
(pageChange)="updatePage($event)" <!-- </div>-->
[page]="page" [pageSize]="resultsPerPage" <div class="uk-width-expand@l uk-width-1-1 uk-flex uk-flex-right@m uk-flex-center">
[totalResults]="previewCommunityProjects.length"> <paging-no-load *ngIf="previewCommunityProjects.length > 0"
</no-load-paging> (pageChange)="updatePage($event)" [size]="resultsPerPage"
<div class="uk-margin-medium-top uk-margin-medium-bottom"> [totalResults]="previewCommunityProjects.length" customClasses="uk-flex-right">
<div *ngIf="previewCommunityProjects.length == 0" </paging-no-load>
class="uk-card uk-card-default uk-padding-large uk-text-center uk-margin-bottom uk-text-bold">
<div>No projects for {{name}}</div>
</div>
<div class="uk-card uk-card-default uk-text-small uk-margin-bottom"
*ngFor="let item of previewCommunityProjects.slice((page - 1)*resultsPerPage, page*resultsPerPage)">
<div class="uk-grid uk-grid-divider uk-padding" uk-grid>
<div class="uk-width-expand@m uk-width-1-1">
<div class="uk-padding-small uk-padding-remove-horizontal">
<h6 class="uk-margin-small-bottom">
<a *ngIf="item.openaireId || (item.grantId && item.funder)"
target="_blank"
[href]="projectUrl+'?' + ((item.openaireId) ? 'projectId='+item.openaireId : 'grantId='+item.grantId+'&funder='+item.funder)">
<span *ngIf="item.name">{{item.name}}</span>
<span *ngIf="item.name && item.acronym"> (</span><span *ngIf="item.acronym">{{item.acronym}}</span><span *ngIf="item.name && item.acronym">)</span>
<span *ngIf="!item.name && !item.acronym">[no title available]</span>
<span class="custom-external custom-icon space"></span>
</a>
<span *ngIf="!item.openaireId && !(item.grantId && item.funder)">
<span *ngIf="item.name">{{item.name}}</span>
<span *ngIf="item.name && item.acronym"> (</span><span *ngIf="item.acronym">{{item.acronym}}</span><span *ngIf="item.name && item.acronym">)</span>
<span *ngIf="!item.name && !item.acronym">[no title available]</span>
</span>
</h6>
<div *ngIf="item.grantId" class="uk-margin-small-bottom">
<span class="title">Grant ID: </span>
<span>{{item.grantId}}</span>
</div>
<div *ngIf="item.funder" class="uk-margin-small-bottom">
<span class="title">Funder: </span>
<span>{{item.funder}}</span>
</div>
</div>
</div>
<div class="uk-width-auto@m uk-width-1-1">
<div class="uk-flex uk-flex-middle uk-flex-center uk-height-1-1">
<div class="uk-padding-small uk-padding-remove-horizontal">
<a (click)="removeProject(item)" class="uk-button action uk-flex uk-flex-middle">
<icon name="remove_circle_outline"></icon>
<span class="uk-margin-small-left">Remove project</span>
</a>
</div>
</div>
</div>
</div>
</div>
</div>
<no-load-paging *ngIf="previewCommunityProjects.length > 0" [type]="'projects'"
(pageChange)="updatePage($event)"
[page]="page" [pageSize]="resultsPerPage"
[totalResults]="previewCommunityProjects.length">
</no-load-paging>
</div> </div>
</div> </div>
<modal-alert #AlertModalDeleteCommunity (alertOutput)="confirmedDeleteProject($event)"></modal-alert> <div class="uk-section uk-section-small uk-position-relative" style="min-height: 60vh">
<div *ngIf="loading" class="uk-position-center">
<loading></loading>
</div>
<div *ngIf="!loading">
<div class="uk-margin-medium-bottom">
<div *ngIf="previewCommunityProjects.length == 0"
class="uk-card uk-card-default uk-padding-large uk-text-center uk-margin-bottom uk-text-bold">
<div>No {{openaireEntiites.PROJECTS | lowercase}} for {{community.shortTitle}}</div>
</div>
<div *ngIf="previewCommunityProjects.length > 0"
class="uk-grid uk-grid-large uk-child-width-1-1 uk-child-width-1-2@m uk-margin-bottom" uk-grid uk-height-match="target: .uk-card-body">
<div *ngFor="let item of previewCommunityProjects.slice((page - 1)*resultsPerPage, page*resultsPerPage); let i=index">
<div class="uk-card uk-card-default">
<div class="uk-card-body">
<h6 class="uk-margin-bottom">
<a *ngIf="item.openaireId || (item.grantId && item.funder)"
target="_blank" class="custom-external uk-link-text"
[href]="projectUrl+'?' + ((item.openaireId) ? 'projectId='+item.openaireId : 'grantId='+item.grantId+'&funder='+item.funder)">
<span *ngIf="item.name">{{item.name}}</span>
<span *ngIf="item.name && item.acronym"> (</span><span *ngIf="item.acronym">{{item.acronym}}</span><span *ngIf="item.name && item.acronym">)</span>
<span *ngIf="!item.name && !item.acronym">[no title available]</span>
</a>
<span *ngIf="!item.openaireId && !(item.grantId && item.funder)">
<span *ngIf="item.name">{{item.name}}</span>
<span *ngIf="item.name && item.acronym"> (</span><span *ngIf="item.acronym">{{item.acronym}}</span><span *ngIf="item.name && item.acronym">)</span>
<span *ngIf="!item.name && !item.acronym">[no title available]</span>
</span>
</h6>
<div class="uk-grid uk-child-width-1-2@l uk-text-small">
<div *ngIf="item.grantId">
<span class="uk-text-meta">Grant ID: </span>
<span>{{item.grantId}}</span>
</div>
<div *ngIf="item.funder">
<span class="uk-text-meta">Funder: </span>
<span>{{item.funder}}</span>
</div>
</div>
</div>
<div class="uk-card-footer uk-padding-remove-vertical">
<div class="uk-grid uk-grid-small uk-flex-nowrap uk-grid-divider uk-flex-right" uk-grid>
<div>
<div class="uk-padding-small uk-padding-remove-horizontal">
<button class="uk-button uk-button-link uk-flex uk-flex-middle"
(click)="removeProject(item)">
<icon name="remove" [flex]="true"></icon>
<span class="uk-margin-xsmall-left">Remove</span>
</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="uk-margin-small-top">
<paging-no-load [currentPage]="page"
[totalResults]="previewCommunityProjects.length" [size]="resultsPerPage"
(pageChange)="updatePage($event)" customClasses="uk-flex-right@m uk-flex-center">
</paging-no-load>
</div>
</div>
</div>
<modal-alert #AlertModalDeleteCommunity (alertOutput)="confirmedDeleteProject($event)" [overflowBody]="false"></modal-alert>
</div>
</div> </div>
</div> </div>

View File

@ -16,6 +16,10 @@ import {properties} from "../../../environments/environment";
import {CommunityService} from "../../openaireLibrary/connect/community/community.service"; import {CommunityService} from "../../openaireLibrary/connect/community/community.service";
import {Option} from "../../openaireLibrary/sharedComponents/input/input.component"; import {Option} from "../../openaireLibrary/sharedComponents/input/input.component";
import {SearchInputComponent} from "../../openaireLibrary/sharedComponents/search-input/search-input.component"; import {SearchInputComponent} from "../../openaireLibrary/sharedComponents/search-input/search-input.component";
import {DropdownFilterComponent} from "../../openaireLibrary/utils/dropdown-filter/dropdown-filter.component";
import {OpenaireEntities} from "../../openaireLibrary/utils/properties/searchFields";
import {CommunityInfo} from "../../openaireLibrary/connect/community/communityInfo";
import {HelperFunctions} from "../../openaireLibrary/utils/HelperFunctions.class";
declare var UIkit; declare var UIkit;
@ -25,16 +29,16 @@ declare var UIkit;
}) })
export class RemoveProjectsComponent implements OnInit { export class RemoveProjectsComponent implements OnInit {
public portal: string; @Input() public community: CommunityInfo;
public name: string; @Input() public loading: boolean = true;
@Input() public disableAdd: boolean = false;
@Output() addProjects: EventEmitter<void> = new EventEmitter();
private subscriptions: any[] = []; private subscriptions: any[] = [];
public routerHelper: RouterHelper = new RouterHelper(); public routerHelper: RouterHelper = new RouterHelper();
private projectUrl = "https://" + ((properties.environment == "beta" || properties.environment == "development") ? "beta." : "") + "explore.openaire.eu" + properties.searchLinkToProject.split("?")[0]; private projectUrl = "https://" + ((properties.environment == "beta" || properties.environment == "development") ? "beta." : "") + "explore.openaire.eu" + properties.searchLinkToProject.split("?")[0];
@Input() public showLoading: boolean = true;
@Output() communityProjectsChanged = new EventEmitter(); @Output() communityProjectsChanged = new EventEmitter();
@Input() public communityProjects = []; @Input() public communityProjects = [];
public previewCommunityProjects = []; public previewCommunityProjects = [];
@ -55,6 +59,7 @@ export class RemoveProjectsComponent implements OnInit {
public fundersCtrl: FormArray; public fundersCtrl: FormArray;
private searchText: RegExp = new RegExp(''); private searchText: RegExp = new RegExp('');
public keyword: string = ''; public keyword: string = '';
selectedFunders: string[] = [];
allOptions: Option[] = []; allOptions: Option[] = [];
sortOptions: Option[] = [ sortOptions: Option[] = [
//{label:"Title (desc) ", value:{ sort: "title",descending: true }}, //{label:"Title (desc) ", value:{ sort: "title",descending: true }},
@ -65,8 +70,9 @@ export class RemoveProjectsComponent implements OnInit {
{label: "Funder ", value: {sort: "funder", descending: false}} {label: "Funder ", value: {sort: "funder", descending: false}}
]; ];
@Output() toggleView: EventEmitter<any> = new EventEmitter(); public stickyPageHeader: boolean = false;
@Input() public toggle: boolean = true;
public openaireEntiites = OpenaireEntities;
constructor(private route: ActivatedRoute, private _router: Router, constructor(private route: ActivatedRoute, private _router: Router,
private _fb: FormBuilder, private _fb: FormBuilder,
@ -105,11 +111,10 @@ export class RemoveProjectsComponent implements OnInit {
this.subscriptions.push(this.communityService.getCommunityAsObservable().subscribe(community => { this.subscriptions.push(this.communityService.getCommunityAsObservable().subscribe(community => {
if (community) { if (community) {
this.portal = community.communityId; this.community = community;
this.name = community.shortTitle;
this.projectUrl = "https://" this.projectUrl = "https://"
+ ((this.properties.environment == "beta" || this.properties.environment == "development") ? "beta." : "") + ((this.properties.environment == "beta" || this.properties.environment == "development") ? "beta." : "")
+ this.portal + ".openaire.eu" + this.properties.searchLinkToProject.split("?")[0]; + this.community.communityId + ".openaire.eu" + this.properties.searchLinkToProject.split("?")[0];
this.keyword = ''; this.keyword = '';
this._getCommunityProjects(); this._getCommunityProjects();
@ -155,14 +160,14 @@ export class RemoveProjectsComponent implements OnInit {
} }
}); });
} else { } else {
this.subscriptions.push(this._manageCommunityProjectsService.removeProject(this.properties, this.portal, this.selectedCommunityProject.id).subscribe( this.subscriptions.push(this._manageCommunityProjectsService.removeProject(this.properties, this.community.communityId, this.selectedCommunityProject.id).subscribe(
data => { data => {
let index = this.communityProjects.indexOf(this.selectedCommunityProject); let index = this.communityProjects.indexOf(this.selectedCommunityProject);
this.communityProjects.splice(index, 1); this.communityProjects.splice(index, 1);
this.applyFilters(); this.applyFilters();
UIkit.notification('Project successfully removed!', { UIkit.notification(OpenaireEntities.PROJECT+' successfully removed!', {
status: 'success', status: 'success',
timeout: 6000, timeout: 6000,
pos: 'bottom-right' pos: 'bottom-right'
@ -195,7 +200,7 @@ export class RemoveProjectsComponent implements OnInit {
this.selectedCommunityProject = communityProject; this.selectedCommunityProject = communityProject;
this.alertModalDeleteCommunity.cancelButton = true; this.alertModalDeleteCommunity.cancelButton = true;
this.alertModalDeleteCommunity.okButton = true; this.alertModalDeleteCommunity.okButton = true;
this.alertModalDeleteCommunity.alertTitle = "Remove project?"; this.alertModalDeleteCommunity.alertTitle = "Remove "+OpenaireEntities.PROJECT;
let title = ""; let title = "";
if (communityProject.name) { if (communityProject.name) {
title = communityProject.name; title = communityProject.name;
@ -209,11 +214,11 @@ export class RemoveProjectsComponent implements OnInit {
if (communityProject.name && communityProject.acronym) { if (communityProject.name && communityProject.acronym) {
title += ")"; title += ")";
} }
this.alertModalDeleteCommunity.message = "Project"; this.alertModalDeleteCommunity.message = OpenaireEntities.PROJECT;
if (title) { if (title) {
this.alertModalDeleteCommunity.message += " '" + title + "' "; this.alertModalDeleteCommunity.message += " <b>" + title + "</b> ";
} }
this.alertModalDeleteCommunity.message += "will be removed from your community. Are you sure?"; this.alertModalDeleteCommunity.message += "will be removed from your "+OpenaireEntities.COMMUNITY.toLowerCase()+". Are you sure?";
this.alertModalDeleteCommunity.okButtonText = "Yes"; this.alertModalDeleteCommunity.okButtonText = "Yes";
this.alertModalDeleteCommunity.open(); this.alertModalDeleteCommunity.open();
} }
@ -234,7 +239,7 @@ export class RemoveProjectsComponent implements OnInit {
this.communitySearchUtils.page = 1; this.communitySearchUtils.page = 1;
this.communitySearchUtils.keyword = ""; this.communitySearchUtils.keyword = "";
this.subscriptions.push(this._searchCommunityProjectsService.searchProjects(this.properties, this.portal).subscribe( this.subscriptions.push(this._searchCommunityProjectsService.searchProjects(this.properties, this.community.communityId).subscribe(
data => { data => {
this.communityProjects = data; this.communityProjects = data;
this.previewCommunityProjects = this.communityProjects; this.previewCommunityProjects = this.communityProjects;
@ -249,7 +254,7 @@ export class RemoveProjectsComponent implements OnInit {
this.createFunderFilter(); this.createFunderFilter();
this.showLoading = false; this.loading = false;
}, },
err => { err => {
console.error(err); console.error(err);
@ -263,7 +268,7 @@ export class RemoveProjectsComponent implements OnInit {
this.communitySearchUtils.status = this.errorCodes.NOT_AVAILABLE; this.communitySearchUtils.status = this.errorCodes.NOT_AVAILABLE;
} }
this.showLoading = false; this.loading = false;
} }
)); ));
} }
@ -283,11 +288,12 @@ export class RemoveProjectsComponent implements OnInit {
} }
public updatePage($event) { public updatePage($event) {
HelperFunctions.scroll();
this.page = $event.value; this.page = $event.value;
} }
addNew() { addNew() {
this.toggleView.emit(null); this.addProjects.emit();
} }
public applyFilters() { public applyFilters() {
@ -367,4 +373,24 @@ export class RemoveProjectsComponent implements OnInit {
pos: 'bottom-right' pos: 'bottom-right'
}); });
} }
select(value: string, event, dropdownFilter: DropdownFilterComponent) {
if(event.target instanceof HTMLInputElement) {
dropdownFilter.closeDropdown();
if(event.target.checked && !this.selectedFunders.find(entity => value === entity)) {
this.selectedFunders.push(value);
this.fundersCtrl.setControl(this.fundersCtrl.value.length, this._fb.control(value));
} else if(!event.target.checked) {
let index = this.selectedFunders.indexOf(value);
if(index !== -1) {
this.selectedFunders.splice(index, 1);
this.fundersCtrl.removeAt(index);
}
}
}
}
isSelected(value: string) {
return this.filterForm && this.filterForm.get('funder').value.find(funder => funder === value)
}
} }

View File

@ -10,26 +10,23 @@
<community-info tab="subjects"></community-info> <community-info tab="subjects"></community-info>
</div> </div>
<div inner> <div inner>
<div class="uk-grid uk-margin-top" uk-grid> <div class="uk-flex uk-flex-right@m uk-flex-center uk-flex-middle uk-grid uk-margin-top" uk-grid>
<div class="uk-width-1-2@m"></div> <div [disabled]="showLoading" search-input class="uk-width-1-3@xl uk-width-2-5@l uk-width-1-2@m uk-width-1-1"
<div class="uk-width-expand@m uk-width-1-1 uk-grid uk-flex-middle uk-flex-right@m uk-flex-center uk-margin-remove-left" uk-grid> [searchControl]="filterForm" [expandable]="true" placeholder="Search Subjects" searchInputClass="outer">
<div [disabled]="showLoading" search-input class="uk-width-expand@l uk-width-1-1" </div>
[searchControl]="filterForm" [expandable]="true" placeholder="Search Subjects" searchInputClass="outer"> <!-- <a *ngIf="!subjectsEnabled" (click)="enablePage()" class="uk-link-heading uk-text-small uk-text-uppercase"
</div> uk-tooltip="title:<div class='uk-padding-small'>This information will be visible in <b>Subjects page</b> of Research Community Dashboard, which is <b>disabled</b>. <br> Click to enable id.</div>">
<!-- <a *ngIf="!subjectsEnabled" (click)="enablePage()" class="uk-link-heading uk-text-small uk-text-uppercase" <span class="uk-text-secondary"><icon name="check_circle_outlined"></icon></span>
uk-tooltip="title:<div class='uk-padding-small'>This information will be visible in <b>Subjects page</b> of Research Community Dashboard, which is <b>disabled</b>. <br> Click to enable id.</div>"> Enable page
<span class="uk-text-secondary"><icon name="check_circle_outlined"></icon></span> </a>-->
Enable page <div>
</a>--> <button class="uk-button uk-button-default uk-flex uk-flex-middle"
<div> [disabled]="showLoading" [class.uk-disabled]="showLoading"
<button class="uk-button uk-button-default uk-flex uk-flex-middle" (click)="newSubject()"
[disabled]="showLoading" [class.uk-disabled]="showLoading" uk-tooltip="title:<div><div class='uk-margin-small-bottom uk-text-bold'>Add new subjects</div> All the research results associated to the subjects specified here will be automatically linked to the community dashboard in the next run of OpenAIRE workflows.</div>">
(click)="newSubject()" <icon name="add" [flex]="true"></icon>
uk-tooltip="title:<div><div class='uk-margin-small-bottom uk-text-bold'>Add new subjects</div> All the research results associated to the subjects specified here will be automatically linked to the community dashboard in the next run of OpenAIRE workflows.</div>"> <span class="uk-margin-small-left">New Subject</span>
<icon name="add" [flex]="true"></icon> </button>
<span class="uk-margin-small-left">New Subject</span>
</button>
</div>
</div> </div>
</div> </div>
<div class="uk-section uk-section-small uk-position-relative" style="min-height: 60vh"> <div class="uk-section uk-section-small uk-position-relative" style="min-height: 60vh">
@ -80,6 +77,11 @@
</div> </div>
</div> </div>
</div> </div>
<div class="uk-margin-small-top">
<paging-no-load [currentPage]="page" [totalResults]="community.subjects.length" [size]="size"
(pageChange)="updatePage($event)" customClasses="uk-flex-right@m uk-flex-center">
</paging-no-load>
</div>
</div> </div>
</div> </div>
</div> </div>

View File

@ -9,8 +9,6 @@ import {SubjectsService} from '../subjects.service';
import {SubjectsEditFormRoutingModule} from './subjects-edit-form-routing.module'; import {SubjectsEditFormRoutingModule} from './subjects-edit-form-routing.module';
import {PageContentModule} from '../../../openaireLibrary/dashboard/sharedComponents/page-content/page-content.module'; import {PageContentModule} from '../../../openaireLibrary/dashboard/sharedComponents/page-content/page-content.module';
import {IconsModule} from '../../../openaireLibrary/utils/icons/icons.module'; import {IconsModule} from '../../../openaireLibrary/utils/icons/icons.module';
import {IconsService} from '../../../openaireLibrary/utils/icons/icons.service';
import {add, check_circle_outlined, close, edit, remove} from '../../../openaireLibrary/utils/icons/icons';
import {AlertModalModule} from '../../../openaireLibrary/utils/modal/alertModal.module'; import {AlertModalModule} from '../../../openaireLibrary/utils/modal/alertModal.module';
import {NoLoadPaging} from '../../../openaireLibrary/searchPages/searchUtils/no-load-paging.module'; import {NoLoadPaging} from '../../../openaireLibrary/searchPages/searchUtils/no-load-paging.module';
import {LoadingModule} from '../../../openaireLibrary/utils/loading/loading.module'; import {LoadingModule} from '../../../openaireLibrary/utils/loading/loading.module';
@ -18,10 +16,11 @@ import {InputModule} from '../../../openaireLibrary/sharedComponents/input/input
import {CommunityInfoModule} from '../../community-info/community-info.module'; import {CommunityInfoModule} from '../../community-info/community-info.module';
import {SearchInputModule} from '../../../openaireLibrary/sharedComponents/search-input/search-input.module'; import {SearchInputModule} from '../../../openaireLibrary/sharedComponents/search-input/search-input.module';
import {FullScreenModalModule} from 'src/app/openaireLibrary/utils/modal/full-screen-modal/full-screen-modal.module'; import {FullScreenModalModule} from 'src/app/openaireLibrary/utils/modal/full-screen-modal/full-screen-modal.module';
import {PagingModule} from "../../../openaireLibrary/utils/paging.module";
@NgModule({ @NgModule({
imports: [ imports: [
SubjectsEditFormRoutingModule, CommonModule, FormsModule, RouterModule, PageContentModule, IconsModule, AlertModalModule, NoLoadPaging, LoadingModule, InputModule, CommunityInfoModule, SearchInputModule, FullScreenModalModule SubjectsEditFormRoutingModule, CommonModule, FormsModule, RouterModule, PageContentModule, IconsModule, AlertModalModule, NoLoadPaging, LoadingModule, InputModule, CommunityInfoModule, SearchInputModule, FullScreenModalModule, PagingModule
], ],
declarations: [ declarations: [
SubjectsEditFormComponent SubjectsEditFormComponent
@ -33,8 +32,4 @@ import {FullScreenModalModule} from 'src/app/openaireLibrary/utils/modal/full-sc
SubjectsEditFormComponent SubjectsEditFormComponent
] ]
}) })
export class SubjectsEditFormModule { export class SubjectsEditFormModule {}
constructor(private iconsService: IconsService) {
this.iconsService.registerIcons([add, edit, remove, close])
}
}

View File

@ -90,8 +90,8 @@ declare var UIkit;
<div class="uk-card uk-card-default uk-margin-bottom"> <div class="uk-card uk-card-default uk-margin-bottom">
<div class="uk-card-body"> <div class="uk-card-body">
<div class="uk-flex uk-flex-middle uk-flex-column"> <div class="uk-flex uk-flex-middle uk-flex-column">
<div class="uk-flex uk-flex-center"> <div class="uk-flex uk-flex-center uk-height-xsmall">
<img class="uk-height-xsmall uk-blend-multiply" [src]="affiliation.value.logo_url | urlPrefix"> <img class="uk-height-max-xsmall uk-blend-multiply" [src]="affiliation.value.logo_url | urlPrefix">
</div> </div>
<h5>{{affiliation.value.name}}</h5> <h5>{{affiliation.value.name}}</h5>
<div class="uk-text-truncate uk-text-small"> <div class="uk-text-truncate uk-text-small">
@ -148,7 +148,7 @@ declare var UIkit;
if you have any inquiries. if you have any inquiries.
</div> </div>
</modal-alert> </modal-alert>
<modal-alert #affiliationModal [okDisabled]="affiliationFb && affiliationFb.invalid" <modal-alert #affiliationModal [okDisabled]="affiliationFb && affiliationFb.invalid" classTitle="uk-background-primary uk-light"
(alertOutput)="editAffiliation()"> (alertOutput)="editAffiliation()">
<form *ngIf="affiliationFb" [formGroup]="affiliationFb"> <form *ngIf="affiliationFb" [formGroup]="affiliationFb">
<div class="uk-grid uk-child-width-1-1" uk-grid> <div class="uk-grid uk-child-width-1-1" uk-grid>
@ -161,9 +161,9 @@ declare var UIkit;
</div> </div>
</form> </form>
</modal-alert> </modal-alert>
<modal-alert #removeAffiliationModal [overflowBody]="false" (alertOutput)="removeAffiliation()"> <modal-alert #removeAffiliationModal [overflowBody]="false" (alertOutput)="removeAffiliation()" classTitle="uk-background-primary uk-light">
</modal-alert> </modal-alert>
<modal-alert #enableCuratorsModal [overflowBody]="false" (alertOutput)="enableCurators()"> <modal-alert #enableCuratorsModal [overflowBody]="false" (alertOutput)="enableCurators()" classTitle="uk-background-primary uk-light">
Your personal information has been successfully saved.<br><br> Your personal information has been successfully saved.<br><br>
This information will be visible in <span class="uk-text-bold">Curators page</span> of Research Community This information will be visible in <span class="uk-text-bold">Curators page</span> of Research Community
Dashboard, which is <span class="uk-text-bold">disabled</span>. Dashboard, which is <span class="uk-text-bold">disabled</span>.

View File

@ -1,62 +1,59 @@
<div class="uk-width-1-1 uk-flex uk-flex-right@m uk-flex-center uk-flex-wrap uk-flex-middle uk-grid uk-margin-bottom" uk-grid> <div class="uk-section uk-flex uk-flex-center uk-flex uk-flex-middle">
<div #searchInputComponent search-input [control]="filterForm" [showSearch]="false" <div search-input class="uk-width-xlarge@l uk-width-large" [searchControl]="filterForm" searchInputClass="outer"
placeholder="Search Zenodo Communites" placeholder="Search Zenodo Communities" [disabled]="zenodoCommunitySearchUtils.status == errorCodes.LOADING"></div>
[selected]="zenodoCommunitySearchUtils.keyword" (closeEmitter)="onSearchClose()" (resetEmitter)="resetInput()"
[bordered]="true" colorClass="uk-text-secondary"
class="uk-width-1-2@l uk-width-1-2@m uk-width-1-1"></div>
</div> </div>
<div *ngIf="zenodoCommunitySearchUtils.status == errorCodes.LOADING" class="uk-position-large-top"> <div class="uk-section uk-section-small uk-position-relative">
<loading></loading> <div *ngIf="zenodoCommunitySearchUtils.status == errorCodes.LOADING" class="uk-position-center">
</div> <loading></loading>
<div *ngIf="zenodoCommunitySearchUtils.status == errorCodes.NONE "
class="uk-card uk-card-default uk-padding-large uk-text-center uk-margin-bottom uk-text-bold">
<div> No zenodo communities found
</div> </div>
</div> <div *ngIf="zenodoCommunitySearchUtils.status !== errorCodes.LOADING">
<div *ngIf="zenodoCommunitySearchUtils.totalResults > 0"> <div *ngIf="zenodoCommunitySearchUtils.totalResults == 0"
<no-load-paging [type]="'Zenodo Communities'" class="uk-card uk-card-default uk-padding-large uk-text-center uk-margin-bottom uk-text-bold">
[page]="zenodoCommunitySearchUtils.page" [pageSize]="rowsOnPage" (pageChange)="goTo($event.value)" <div>No zenodo communities found</div>
[totalResults]="zenodoCommunitySearchUtils.totalResults"> </div>
</no-load-paging> <ng-container *ngIf="zenodoCommunitySearchUtils.totalResults > 0">
<ul class="uk-list"> <no-load-paging [type]="'zenodo communities'"
<li class="" *ngFor="let item of zenodoCommunities; let i = index;" [page]="zenodoCommunitySearchUtils.page" [pageSize]="rowsOnPage" (pageChange)="goTo($event.value)"
class="uk-card uk-card-default uk-margin-bottom uk-padding"> [totalResults]="zenodoCommunitySearchUtils.totalResults">
<div class="uk-grid uk-grid-divider " uk-grid> </no-load-paging>
<div class="uk-width-expand"> <div class="uk-grid uk-grid-large uk-child-width-1-1 uk-margin-medium-top uk-margin-bottom" uk-grid>
<preview-zenodo-community [item]="item"></preview-zenodo-community> <div *ngFor="let item of zenodoCommunities; let i=index">
</div> <div class="uk-card uk-card-default">
<div class="uk-card-body">
<div class="uk-width-auto@m uk-width-1-1"> <preview-zenodo-community [item]="item" [master]="masterCommunity && item.id==masterCommunity.id"></preview-zenodo-community>
<div class=" uk-flex uk-flex-middle uk-flex-center uk-flex-column uk-height-1-1"> </div>
<div class="uk-padding-small uk-padding-remove-horizontal"> <div *ngIf="!masterCommunity || item.id!==masterCommunity.id" class="uk-card-footer uk-padding-remove-vertical">
<div [class.hide-element]="inThelist(item, selectedCommunities)"> <div class="uk-grid uk-grid-small uk-flex-nowrap uk-grid-divider uk-flex-right" uk-grid>
<span *ngIf=" masterCommunity && item.id==masterCommunity.id" class="uk-label uk-label-warning">Master zenodo community</span> <div *ngIf="!inThelist(item, selectedCommunities) && !(masterCommunity && item.id==masterCommunity.id)">
<div (click)="addCommunity(item)" class="uk-button action uk-flex uk-flex-middle" <div class="uk-padding-small uk-padding-remove-horizontal">
uk-tooltip="title:<div class='uk-padding-small'><div class='uk-margin-bottom uk-text-bold'>Add new community </div><div>Newly added Zenodo communities will be linked to your community on the next run of our algorithms.</div></div>"> <a (click)="addCommunity(item)" class="uk-button uk-button-link uk-flex uk-flex-middle">
<!-- <i class="clickable uk-text-success" uk-icon="plus"></i>--> <icon name="add" [flex]="true"></icon>
<div class="uk-text-success"> <span class="uk-margin-small-left">
<icon name="add"></icon> Add
</span>
</a>
</div> </div>
<span class="uk-margin-small-left"> Add community</span>
</div> </div>
</div> <div *ngIf="inThelist(item, selectedCommunities)">
<div <div class="uk-padding-small uk-padding-remove-horizontal">
[class.hide-element]="!inThelist(item, selectedCommunities) && !(masterCommunity && item.id==masterCommunity.id)"> <a (click)="removeCommunity(item)"
<div (click)="removeCommunity(item)" class="uk-button action uk-flex uk-flex-middle"> class="uk-button uk-button-link uk-flex uk-flex-middle">
<icon name="remove_circle_outline"></icon> <icon name="remove" [flex]="true"></icon>
<span class="uk-margin-small-left"> Remove community </span> <span class="uk-margin-small-left">Remove</span>
</a>
</div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</li> <div class="uk-margin-small-top">
</ul> <paging-no-load [currentPage]="zenodoCommunitySearchUtils.page"
<no-load-paging [type]="'Zenodo Communities'" [totalResults]="zenodoCommunitySearchUtils.totalResults" [size]="rowsOnPage"
[page]="zenodoCommunitySearchUtils.page" [pageSize]="rowsOnPage" (pageChange)="goTo($event.value)" (pageChange)="goTo($event.value)" customClasses="uk-flex-right@m uk-flex-center">
[totalResults]="zenodoCommunitySearchUtils.totalResults"> </paging-no-load>
</no-load-paging> </div>
</div> </ng-container>
</div>
</div>

View File

@ -1,16 +1,16 @@
import {Component, Input, OnInit, ViewChild} from '@angular/core'; import {Component, EventEmitter, Input, OnInit, Output, ViewChild} from '@angular/core';
import {FormBuilder, FormControl} from '@angular/forms'; import {FormBuilder, FormControl} from '@angular/forms';
import {ActivatedRoute, Router} from '@angular/router'; import {ActivatedRoute, Router} from '@angular/router';
import {EnvProperties} from '../../openaireLibrary/utils/properties/env-properties'; import {EnvProperties} from '../../openaireLibrary/utils/properties/env-properties';
import {properties} from "../../../environments/environment";
import {ErrorCodes} from '../../openaireLibrary/utils/properties/errorCodes'; import {ErrorCodes} from '../../openaireLibrary/utils/properties/errorCodes';
import {SearchUtilsClass} from '../../openaireLibrary/searchPages/searchUtils/searchUtils.class'; import {SearchUtilsClass} from '../../openaireLibrary/searchPages/searchUtils/searchUtils.class';
import {ZenodoCommunitiesService} from '../../openaireLibrary/connect/zenodoCommunities/zenodo-communities.service'; import {ZenodoCommunitiesService} from '../../openaireLibrary/connect/zenodoCommunities/zenodo-communities.service';
import {Session} from '../../openaireLibrary/login/utils/helper.class';
import {LoginErrorCodes} from '../../openaireLibrary/login/utils/guardHelper.class';
import {ManageZenodoCommunitiesService} from '../../services/manageZenodoCommunities.service'; import {ManageZenodoCommunitiesService} from '../../services/manageZenodoCommunities.service';
import {SearchInputComponent} from '../../openaireLibrary/sharedComponents/search-input/search-input.component';
import {Subject, Subscription} from 'rxjs'; import {Subject, Subscription} from 'rxjs';
import {debounceTime, distinctUntilChanged} from 'rxjs/operators'; import {debounceTime, distinctUntilChanged} from 'rxjs/operators';
import {CommunityInfo} from "../../openaireLibrary/connect/community/communityInfo";
import {HelperFunctions} from "../../openaireLibrary/utils/HelperFunctions.class";
declare var UIkit; declare var UIkit;
@ -22,9 +22,8 @@ export class AddZenodoCommunitiesComponent implements OnInit {
public zenodoCommunities = null; // zenodo search API results public zenodoCommunities = null; // zenodo search API results
public totalZenodoCommunities = null; public totalZenodoCommunities = null;
@Input() properties: EnvProperties = null; properties: EnvProperties = properties;
@Input() communityId = null; @Input() community: CommunityInfo = null;
@ViewChild('searchInputComponent') searchInputComponent: SearchInputComponent;
public filterForm: FormControl; public filterForm: FormControl;
private subscriptions: any[] = []; private subscriptions: any[] = [];
public subResults: any; public subResults: any;
@ -34,7 +33,8 @@ export class AddZenodoCommunitiesComponent implements OnInit {
public rowsOnPage = 10; public rowsOnPage = 10;
@Input() masterCommunity = null; @Input() masterCommunity = null;
@Input() selectedCommunities = []; @Input() selectedCommunities = [];
@Output() zenodoCommunitiesChanged = new EventEmitter();
constructor(private route: ActivatedRoute, constructor(private route: ActivatedRoute,
private _router: Router, private _router: Router,
public _fb: FormBuilder, public _fb: FormBuilder,
@ -58,37 +58,27 @@ export class AddZenodoCommunitiesComponent implements OnInit {
})); }));
this.zenodoCommunitySearchUtils.keyword = ""; this.zenodoCommunitySearchUtils.keyword = "";
if (!Session.isLoggedIn()) { this.zenodoCommunitySearchUtils.status = this.errorCodes.LOADING;
this._router.navigate(['/user-info'], { if (this.community.communityId != null && this.community.communityId != '') {
queryParams: { this._zenodoCommunitieService.getZenodoCommunities(this.properties, this.properties.zenodoCommunities + "?page=" + this.zenodoCommunitySearchUtils.page + "&size=" + this.rowsOnPage).subscribe(
"errorCode": LoginErrorCodes.NOT_VALID, result => {
"redirectUrl": this._router.url this.zenodoCommunities = result[0];
} this.totalZenodoCommunities = result[1];
}); this.zenodoCommunitySearchUtils.totalResults = result[1];
} else { this.zenodoCommunitySearchUtils.page = 1;
this.zenodoCommunitySearchUtils.status = this.errorCodes.LOADING; this.zenodoCommunitySearchUtils.size = this.rowsOnPage;
if (this.communityId != null && this.communityId != '') { if (this.totalZenodoCommunities == 0) {
this._zenodoCommunitieService.getZenodoCommunities(this.properties, this.properties.zenodoCommunities + "?page=" + this.zenodoCommunitySearchUtils.page + "&size=" + this.rowsOnPage).subscribe( this.zenodoCommunitySearchUtils.status = this.errorCodes.NONE;
result => { } else {
this.zenodoCommunities = result[0]; this.zenodoCommunitySearchUtils.status = this.errorCodes.DONE;
this.totalZenodoCommunities = result[1];
this.zenodoCommunitySearchUtils.totalResults = result[1];
this.zenodoCommunitySearchUtils.page = 1;
this.zenodoCommunitySearchUtils.size = this.rowsOnPage;
if (this.totalZenodoCommunities == 0) {
this.zenodoCommunitySearchUtils.status = this.errorCodes.NONE;
} else {
this.zenodoCommunitySearchUtils.status = this.errorCodes.DONE;
}
},
error => {
this.zenodoCommunitySearchUtils.status = this.errorCodes.ERROR;
} }
);
} },
error => {
this.zenodoCommunitySearchUtils.status = this.errorCodes.ERROR;
}
);
} }
} }
ngOnDestroy() { ngOnDestroy() {
@ -103,41 +93,33 @@ export class AddZenodoCommunitiesComponent implements OnInit {
} }
public goTo(page: number = 1) { public goTo(page: number = 1) {
if (!Session.isLoggedIn()) { HelperFunctions.scroll();
this._router.navigate(['/user-info'], { this.zenodoCommunitySearchUtils.page = page;
queryParams: { this.zenodoCommunitySearchUtils.status = this.errorCodes.LOADING;
"errorCode": LoginErrorCodes.NOT_VALID, if(this.subResults){
"redirectUrl": this._router.url this.subResults.unsubscribe();
}
});
} else {
this.zenodoCommunitySearchUtils.page = page;
this.zenodoCommunitySearchUtils.status = this.errorCodes.LOADING;
if(this.subResults){
this.subResults.unsubscribe();
}
this.subResults = this._zenodoCommunitieService.getZenodoCommunities(this.properties,
this.properties.zenodoCommunities + "?page=" + this.zenodoCommunitySearchUtils.page
+ "&size=" + this.rowsOnPage
+ ((this.zenodoCommunitySearchUtils.keyword) ? ("&q=" + this.zenodoCommunitySearchUtils.keyword) : "")
).subscribe(
result => {
this.zenodoCommunities = result[0];
this.totalZenodoCommunities = result[1];
this.zenodoCommunitySearchUtils.totalResults = result[1];
this.zenodoCommunitySearchUtils.size = this.rowsOnPage;
if (this.totalZenodoCommunities == 0) {
this.zenodoCommunitySearchUtils.status = this.errorCodes.NONE;
} else {
this.zenodoCommunitySearchUtils.status = this.errorCodes.DONE;
}
},
error => {
this.zenodoCommunitySearchUtils.status = this.errorCodes.ERROR;
}
);
} }
this.subResults = this._zenodoCommunitieService.getZenodoCommunities(this.properties,
this.properties.zenodoCommunities + "?page=" + this.zenodoCommunitySearchUtils.page
+ "&size=" + this.rowsOnPage
+ ((this.zenodoCommunitySearchUtils.keyword) ? ("&q=" + this.zenodoCommunitySearchUtils.keyword) : "")
).subscribe(
result => {
this.zenodoCommunities = result[0];
this.totalZenodoCommunities = result[1];
this.zenodoCommunitySearchUtils.totalResults = result[1];
this.zenodoCommunitySearchUtils.size = this.rowsOnPage;
if (this.totalZenodoCommunities == 0) {
this.zenodoCommunitySearchUtils.status = this.errorCodes.NONE;
} else {
this.zenodoCommunitySearchUtils.status = this.errorCodes.DONE;
}
},
error => {
this.zenodoCommunitySearchUtils.status = this.errorCodes.ERROR;
}
);
} }
totalPages(): number { totalPages(): number {
@ -150,73 +132,55 @@ export class AddZenodoCommunitiesComponent implements OnInit {
public addCommunity(community) { public addCommunity(community) {
if (!Session.isLoggedIn()) { this.subscriptions.push(this._manageZenodoCommunitiesService.addZCommunity(this.properties, this.community.communityId, community.id).subscribe(
this._router.navigate(['/user-info'], { data => {
queryParams: { community["openaireId"] = data.id;
"errorCode": LoginErrorCodes.NOT_VALID, this.selectedCommunities.push(community);
"redirectUrl": this._router.url UIkit.notification('Community successfully added!', {
} status: 'success',
}); timeout: 6000,
} else { pos: 'bottom-right'
this.subscriptions.push(this._manageZenodoCommunitiesService.addZCommunity(this.properties, this.communityId, community.id).subscribe( });
data => { this.zenodoCommunitiesChanged.emit({
community["openaireId"] = data.id; value: this.selectedCommunities,
this.selectedCommunities.push(community); });
UIkit.notification('Community successfully added!', { },
status: 'success', err => {
timeout: 6000, this.handleError('An error has been occurred. Try again later!');
pos: 'bottom-right' console.log(err.status);
}); }
}, ));
err => {
this.handleError('An error has been occurred. Try again later!');
console.log(err.status);
}/*,
() => {
console.info("completed ADD");
}*/
));
}
} }
public removeCommunity(comm) { public removeCommunity(comm) {
if (!Session.isLoggedIn()) { var openaireId = this.getOpenaireId(comm);
this._router.navigate(['/user-info'], { this.subscriptions.push(this._manageZenodoCommunitiesService.removeZCommunity(this.properties, this.community.communityId, openaireId,).subscribe(
queryParams: { data => {
"errorCode": LoginErrorCodes.NOT_VALID, var pos = -1;
"redirectUrl": this._router.url for (var i = 0; i < this.selectedCommunities.length; i++) {
if (this.selectedCommunities[i].id == comm.id) {
pos = i;
break;
}
} }
}); if (pos != -1) {
} else { this.selectedCommunities.splice(pos, 1);
var openaireId = this.getOpenaireId(comm); }
this.subscriptions.push(this._manageZenodoCommunitiesService.removeZCommunity(this.properties, this.communityId, openaireId,).subscribe(
data => { UIkit.notification('Community successfully removed!', {
var pos = -1; status: 'success',
for (var i = 0; i < this.selectedCommunities.length; i++) { timeout: 6000,
if (this.selectedCommunities[i].id == comm.id) { pos: 'bottom-right'
pos = i; });
break; this.zenodoCommunitiesChanged.emit({
} value: this.selectedCommunities,
} });
if (pos != -1) { },
this.selectedCommunities.splice(pos, 1); err => {
} this.handleError('An error has been occurred. Try again later!');
console.log(err.status);
UIkit.notification('Community successfully removed!', { }
status: 'success', ));
timeout: 6000,
pos: 'bottom-right'
});
},
err => {
this.handleError('An error has been occurred. Try again later!');
console.log(err.status);
}/*,
() => {
console.info("completed remove");
}*/
));
}
} }
public inThelist(community: any, list): any { public inThelist(community: any, list): any {
@ -236,14 +200,9 @@ export class AddZenodoCommunitiesComponent implements OnInit {
} }
return null; return null;
} }
public onSearchClose() { get loading() {
this.zenodoCommunitySearchUtils.keyword = this.filterForm.value; return this.zenodoCommunitySearchUtils.status == this.errorCodes.LOADING
}
public resetInput() {
this.zenodoCommunitySearchUtils.keyword = null;
this.searchInputComponent.reset()
} }
handleError(message: string) { handleError(message: string) {

View File

@ -1,72 +1,78 @@
<div page-content> <div page-content (stickyEmitter)="stickyPageHeader = $event">
<div header> <div header>
<community-info tab="zenodo-communities"></community-info> <div class="uk-flex uk-flex-middle uk-margin-top info" [class.uk-active]="stickyPageHeader">
<div class="uk-width-1-1 uk-flex uk-flex-right@m uk-flex-center uk-flex-wrap uk-flex-middle uk-grid" uk-grid> <div>
<div class="uk-flex-last@m"> <div class="uk-margin-remove uk-text-background uk-text-bold uk-h6">Admin Dashboard - Manage Zenodo Communities
<a (click)="addNew()" </div>
uk-tooltip="title:<div class='uk-padding-small'><div class='uk-margin-bottom uk-text-bold'> Search and add more Zenodo Communities</div><div>The research results of a Zenodo community specified here will be automatically linked to your community dashboard.</div></div>" <h1 class="uk-h4 uk-margin-remove">{{community.shortTitle}}</h1>
class="uk-flex uk-flex-middle uk-text-uppercase">
<button class="large uk-icon-button uk-button-secondary">
<icon name="add"></icon>
</button>
<button class="uk-button uk-button-link uk-margin-small-left uk-text-secondary">Add new zenodo
communities
</button>
</a>
</div> </div>
<div #searchInputComponent search-input [control]="filterForm" [showSearch]="false"
placeholder="Search Zenodo Communities "
[selected]="searchUtils.keyword" (closeEmitter)="onSearchClose()" (resetEmitter)="resetInput()"
[bordered]="true" colorClass="uk-text-secondary"
class="uk-width-1-3@xl uk-width-2-5@l uk-width-1-2@m uk-width-1-1"></div>
</div> </div>
<community-info tab="zenodo-communities"></community-info>
</div> </div>
<div inner> <div inner>
<div *ngIf="searchUtils.status === errorCodes.LOADING" class="uk-position-center"> <div class="uk-flex uk-flex-right@m uk-flex-center uk-flex-middle uk-grid uk-margin-top" uk-grid>
<loading></loading> <div search-input [expandable]="true" [searchControl]="filterForm" searchInputClass="outer"
placeholder="Search Zenodo Community" [disabled]="searchUtils.status === errorCodes.LOADING"
class="uk-width-1-3@xl uk-width-2-5@l uk-width-1-2@m uk-width-1-1"></div>
<div>
<button class="uk-button uk-button-default uk-flex uk-flex-middle" (click)="addNew()"
uk-tooltip="title:<div class='uk-text-bold'> Search and add more Zenodo Communities</div><div>The research results of a Zenodo community specified here will be automatically linked to your community dashboard.</div>"
[disabled]="searchUtils.status === errorCodes.LOADING || disableAdd"
[class.uk-disabled]="searchUtils.status === errorCodes.LOADING || disableAdd">
<icon name="add" [flex]="true"></icon>
<span class="uk-margin-small-left uk-text-bold uk-text-uppercase">New Zenodo Community</span>
</button>
</div>
</div> </div>
<div *ngIf="searchUtils.status != errorCodes.LOADING && previewCommunities">
<div *ngIf="masterCommunity"
class="uk-animation-fade uk-alert uk-alert-primary uk-padding-small uk-margin-large-bottom">
<div class="uk-text-large uk-margin-bottom">Main Zenodo community</div>
<preview-zenodo-community [item]="masterCommunity"></preview-zenodo-community>
</div>
<div *ngIf="previewCommunities.length == 0"
class="uk-card uk-card-default uk-padding-large uk-text-center uk-margin-bottom uk-text-bold">
<div> No zenodo communities found
</div>
</div>
<div *ngIf="previewCommunities.length > 0">
<no-load-paging *ngIf=" previewCommunities && previewCommunities.length > 0" [type]="'Zenodo Communities'"
[page]="page" [pageSize]="size" (pageChange)="page = $event.value"
[totalResults]="previewCommunities.length">
</no-load-paging>
<ul class="uk-list">
<li class="" *ngFor="let item of previewCommunities; let i = index;" <div class="uk-section uk-section-small uk-position-relative" style="min-height: 60vh">
class="uk-card uk-card-default uk-margin-bottom" <div *ngIf="searchUtils.status == errorCodes.LOADING" class="uk-position-center">
[class.uk-hidden]="i >= page * size || <loading></loading>
i < (page - 1) * size"> </div>
<div class="uk-grid uk-padding uk-grid-divider " uk-grid> <div *ngIf="searchUtils.status !== errorCodes.LOADING">
<div class="uk-width-expand@m uk-width-1-1"> <div *ngIf="previewCommunities.length == 0"
<preview-zenodo-community [item]="item"></preview-zenodo-community> class="uk-card uk-card-default uk-padding-large uk-text-center uk-margin-bottom uk-text-bold">
</div> <div>No zenodo communities found</div>
<div class="uk-text-center uk-width-auto@m uk-width-1-1"> </div>
<div class=" uk-flex uk-flex-middle uk-flex-center uk-height-1-1"> <div *ngIf="previewCommunities.length > 0">
<div class="uk-padding-small uk-padding-remove-horizontal"> <no-load-paging [type]="'content providers'"
<div (click)="removeCommunity(item)" (pageChange)="updatePage($event)"
class="uk-button action uk-flex uk-flex-middle "> [page]="page" [pageSize]="size"
<icon name="remove_circle_outline"></icon> [totalResults]="previewCommunities.length">
<span class="uk-margin-small-left">Remove community</span> </no-load-paging>
<!-- <ul class="uk-margin-medium-top uk-margin-bottom uk-list uk-list-xlarge">-->
<div class="uk-grid uk-grid-large uk-child-width-1-1 uk-margin-medium-top uk-margin-bottom" uk-grid>
<div *ngFor="let item of previewCommunities.slice((this.page - 1)*this.size, this.page*this.size); let i=index">
<div class="uk-card uk-card-default">
<div class="uk-card-body">
<preview-zenodo-community [item]="item" [master]="masterCommunity && item.id==masterCommunity.id"></preview-zenodo-community>
</div>
<div *ngIf="!masterCommunity || item.id!==masterCommunity.id" class="uk-card-footer uk-padding-remove-vertical">
<div class="uk-grid uk-grid-small uk-flex-nowrap uk-grid-divider uk-flex-right" uk-grid>
<div>
<div class="uk-padding-small uk-padding-remove-horizontal">
<button class="uk-button uk-button-link uk-flex uk-flex-middle"
(click)="removeCommunity(item)">
<icon name="remove" [flex]="true"></icon>
<span class="uk-margin-xsmall-left">Remove</span>
</button>
</div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</li> </div>
</ul> <!-- </ul>-->
<div class="uk-margin-small-top">
<paging-no-load [currentPage]="page"
[totalResults]="previewCommunities.length" [size]="size"
(pageChange)="updatePage($event)" customClasses="uk-flex-right@m uk-flex-center">
</paging-no-load>
</div>
</div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<modal-alert #AlertModalDeleteCommunity (alertOutput)="confirmedDeleteCommunity($event)"></modal-alert> <modal-alert #AlertModalDeleteCommunity (alertOutput)="confirmedDeleteCommunity($event)" [overflowBody]="false"></modal-alert>

View File

@ -2,23 +2,23 @@ import {
Component, Component,
EventEmitter, EventEmitter,
Input, Input,
OnChanges,
OnDestroy, OnDestroy,
OnInit, OnInit,
Output, SimpleChanges, Output,
ViewChild, ViewChild,
ViewEncapsulation ViewEncapsulation
} from '@angular/core'; } from '@angular/core';
import {FormBuilder, FormControl} from '@angular/forms'; import {FormBuilder, FormControl} from '@angular/forms';
import {ActivatedRoute, Router} from '@angular/router'; import {ActivatedRoute, Router} from '@angular/router';
import {EnvProperties} from '../../openaireLibrary/utils/properties/env-properties'; import {EnvProperties} from '../../openaireLibrary/utils/properties/env-properties';
import {properties} from "../../../environments/environment";
import {ErrorCodes} from '../../openaireLibrary/utils/properties/errorCodes'; import {ErrorCodes} from '../../openaireLibrary/utils/properties/errorCodes';
import {SearchUtilsClass} from '../../openaireLibrary/searchPages/searchUtils/searchUtils.class'; import {SearchUtilsClass} from '../../openaireLibrary/searchPages/searchUtils/searchUtils.class';
import {Session} from '../../openaireLibrary/login/utils/helper.class';
import {LoginErrorCodes} from '../../openaireLibrary/login/utils/guardHelper.class';
import {ManageZenodoCommunitiesService} from '../../services/manageZenodoCommunities.service'; import {ManageZenodoCommunitiesService} from '../../services/manageZenodoCommunities.service';
import {SearchInputComponent} from '../../openaireLibrary/sharedComponents/search-input/search-input.component'; import {SearchInputComponent} from '../../openaireLibrary/sharedComponents/search-input/search-input.component';
import {Subscription} from 'rxjs'; import {Subscription} from 'rxjs';
import {CommunityInfo} from "../../openaireLibrary/connect/community/communityInfo";
import {HelperFunctions} from "../../openaireLibrary/utils/HelperFunctions.class";
declare var UIkit; declare var UIkit;
@ -29,9 +29,10 @@ declare var UIkit;
}) })
export class ManageZenodoCommunitiesComponent implements OnInit, OnDestroy { export class ManageZenodoCommunitiesComponent implements OnInit, OnDestroy {
@Input() properties: EnvProperties = null; properties: EnvProperties = properties;
@Input() communityId = null; @Input() community: CommunityInfo = null;
@Input() public loading: boolean = true;
@Input() public disableAdd: boolean = false;
@Input() searchUtils: SearchUtilsClass = null; @Input() searchUtils: SearchUtilsClass = null;
errorCodes: ErrorCodes; errorCodes: ErrorCodes;
@ -42,13 +43,17 @@ export class ManageZenodoCommunitiesComponent implements OnInit, OnDestroy {
@ViewChild('AlertModalDeleteCommunity') alertModalDeleteCommunity; @ViewChild('AlertModalDeleteCommunity') alertModalDeleteCommunity;
selectedToDelete = null; selectedToDelete = null;
@Output() toggleView: EventEmitter<any> = new EventEmitter(); @Output() addZenodoCommunity: EventEmitter<any> = new EventEmitter();
@Output() zenodoCommunitiesChanged = new EventEmitter();
page = 1; page = 1;
size = 10; size = 10;
@ViewChild('searchInputComponent') searchInputComponent: SearchInputComponent; @ViewChild('searchInputComponent') searchInputComponent: SearchInputComponent;
public filterForm: FormControl; public filterForm: FormControl;
private subscriptions: any[] = []; private subscriptions: any[] = [];
public stickyPageHeader: boolean = false;
constructor(private route: ActivatedRoute, constructor(private route: ActivatedRoute,
private _router: Router, private _router: Router,
public _fb: FormBuilder, public _fb: FormBuilder,
@ -83,7 +88,7 @@ export class ManageZenodoCommunitiesComponent implements OnInit, OnDestroy {
public filterPreviewCommunities(value: string) { public filterPreviewCommunities(value: string) {
this.previewCommunities = this.selectedCommunities.filter(community => { this.previewCommunities = this.selectedCommunities.filter(community => {
return community.title.toLowerCase().indexOf(value.toLowerCase()) != -1 return !value || community.title.toLowerCase().indexOf(value.toLowerCase()) != -1
}); });
if (this.previewCommunities.slice((this.page - 1) * this.rowsOnPage, this.page * this.rowsOnPage).length == 0) { if (this.previewCommunities.slice((this.page - 1) * this.rowsOnPage, this.page * this.rowsOnPage).length == 0) {
this.page = 1; this.page = 1;
@ -91,70 +96,54 @@ export class ManageZenodoCommunitiesComponent implements OnInit, OnDestroy {
} }
public confirmedDeleteCommunity(data: any) { public confirmedDeleteCommunity(data: any) {
if (!Session.isLoggedIn()) { this.subscriptions.push(this._manageZenodoCommunitiesService.removeZCommunity(this.properties, this.community.communityId, this.selectedToDelete.openaireId).subscribe(
this._router.navigate(['/user-info'], { data => {
queryParams: { var pos = -1;
"errorCode": LoginErrorCodes.NOT_VALID, for (var i = 0; i < this.selectedCommunities.length; i++) {
"redirectUrl": this._router.url if (this.selectedCommunities[i].id == this.selectedToDelete.id) {
pos = i;
break;
}
} }
}); if (pos != -1) {
} else { this.selectedCommunities.splice(pos, 1);
this.subscriptions.push(this._manageZenodoCommunitiesService.removeZCommunity(this.properties, this.communityId, this.selectedToDelete.openaireId).subscribe(
data => {
var pos = -1;
for (var i = 0; i < this.selectedCommunities.length; i++) {
if (this.selectedCommunities[i].id == this.selectedToDelete.id) {
pos = i;
break;
}
}
if (pos != -1) {
this.selectedCommunities.splice(pos, 1);
this.searchUtils.totalResults = this.selectedCommunities.length;
}
this.searchUtils.totalResults = this.selectedCommunities.length; this.searchUtils.totalResults = this.selectedCommunities.length;
this.filterPreviewCommunities(this.filterForm.value);
UIkit.notification('Community has been <b>successfully removed</b>!', {
status: 'success',
timeout: 6000,
pos: 'bottom-right'
});
},
err => {
this.handleError('An error has been occurred. Try again later!');
console.log(err.status);
} }
)); this.searchUtils.totalResults = this.selectedCommunities.length;
} this.filterPreviewCommunities(this.filterForm.value);
UIkit.notification('Community has been <b>successfully removed</b>!', {
status: 'success',
timeout: 6000,
pos: 'bottom-right'
});
this.zenodoCommunitiesChanged.emit({
value: this.selectedCommunities,
});
},
err => {
this.handleError('An error has been occurred. Try again later!');
console.log(err.status);
}
));
} }
public removeCommunity(comm) { public removeCommunity(comm) {
if (!Session.isLoggedIn()) { this.selectedToDelete = comm;
this._router.navigate(['/user-info'], { this.alertModalDeleteCommunity.cancelButton = true;
queryParams: { this.alertModalDeleteCommunity.okButton = true;
"errorCode": LoginErrorCodes.NOT_VALID, this.alertModalDeleteCommunity.alertTitle = "Remove zenodo community";
"redirectUrl": this._router.url let title = "";
} if (comm.title) {
}); title = comm.title;
} else {
this.selectedToDelete = comm;
this.alertModalDeleteCommunity.cancelButton = true;
this.alertModalDeleteCommunity.okButton = true;
this.alertModalDeleteCommunity.alertTitle = "Remove zenodo community?";
let title = "";
if (comm.title) {
title = comm.title;
}
this.alertModalDeleteCommunity.message = "Zenodo community";
if (title) {
this.alertModalDeleteCommunity.message += " '" + title + "' ";
}
this.alertModalDeleteCommunity.message += "will be removed from your community. Are you sure?";
this.alertModalDeleteCommunity.okButtonText = "Yes";
this.alertModalDeleteCommunity.open();
} }
this.alertModalDeleteCommunity.message = "Zenodo community";
if (title) {
this.alertModalDeleteCommunity.message += " '" + title + "' ";
}
this.alertModalDeleteCommunity.message += "will be removed from your community. Are you sure?";
this.alertModalDeleteCommunity.okButtonText = "Yes";
this.alertModalDeleteCommunity.open();
} }
@ -165,18 +154,14 @@ export class ManageZenodoCommunitiesComponent implements OnInit, OnDestroy {
} }
return totalPages; return totalPages;
} }
public updatePage($event) {
HelperFunctions.scroll();
this.page = $event.value;
}
addNew() { addNew() {
this.toggleView.emit(null); this.addZenodoCommunity.emit();
}
public onSearchClose() {
this.searchUtils.keyword = this.filterForm.value;
}
public resetInput() {
this.searchUtils.keyword = null;
this.searchInputComponent.reset()
} }
handleError(message: string) { handleError(message: string) {

View File

@ -3,30 +3,36 @@ import {Component, Input} from '@angular/core';
@Component({ @Component({
selector: 'preview-zenodo-community', selector: 'preview-zenodo-community',
template: ` template: `
<div class="uk-grid uk-flex uk-flex-middle"> <div class="header uk-grid uk-grid-medium uk-flex-middle" uk-grid>
<a *ngIf="item.logoUrl" target="_blank" [href]="item.link" class="uk-width-auto"> <div class="uk-width-auto" *ngIf="item.logoUrl">
<img class="uk-comment-avatar" src="{{item.logoUrl}}" width="80" height="80" alt=""> <a target="_blank" [href]="item.link">
</a> <img *ngIf="item.logoUrl"
<div class="uk-width-expand"> src="{{item.logoUrl}}" width="80" height="80"
<a class="" target="_blank" href="{{item.link}}"> alt="{{item.title}}">
<span *ngIf="item.title">{{item.title}}</span> </a>
<span *ngIf="!item.title">[no name available]</span> </div>
<span class="custom-external custom-icon space"></span> <div class="uk-width-expand">
</a> <div *ngIf="master"><div class="uk-badge uk-margin-small-bottom">Main Zenodo Community</div></div>
<div class="uk-comment-meta uk-margin-small-top"> <h2 class="uk-margin-remove uk-text-break uk-inline-block uk-h6">
last update: {{item.date | date:'yyyy/MM/dd'}} <a class="custom-external uk-link uk-link-text uk-width-expand" target="_blank"
</div> href="{{item.link}}">
</div> <span *ngIf="item.title">{{item.title}}</span>
</div> <span *ngIf="!item.title">[no name available]</span>
</a>
<div *ngIf="item.description" </h2>
class="uk-comment-body uk-text-meta uk-margin-top multi-line-ellipsis lines-3 "> <div *ngIf="item.date" class="uk-text-small uk-margin-small-top">
<p>{{item.description|htmlToString}}</p> <span class="uk-text-meta">Last update: </span>{{item.date | date:'yyyy/MM/dd'}}
</div> </div>
</div>
</div>
<div class="uk-margin-top uk-text-small multi-line-ellipsis lines-3">
<div *ngIf="item.description" class="uk-margin-remove"
[innerHtml]="item.description"></div>
</div>
` `
}) })
export class PreviewZenodoCommunityComponent { export class PreviewZenodoCommunityComponent {
@Input() item; @Input() item;
@Input() master: boolean = false;
} }

View File

@ -1,8 +1,6 @@
import {Component, ElementRef, OnDestroy, OnInit, ViewChild} from '@angular/core'; import {Component, ElementRef, Input, OnDestroy, OnInit, ViewChild} from '@angular/core';
import {ActivatedRoute, Router} from '@angular/router'; import {ActivatedRoute, Router} from '@angular/router';
import {Session} from '../../openaireLibrary/login/utils/helper.class';
import {LoginErrorCodes} from '../../openaireLibrary/login/utils/guardHelper.class';
import {EnvProperties} from '../../openaireLibrary/utils/properties/env-properties'; import {EnvProperties} from '../../openaireLibrary/utils/properties/env-properties';
import {ZenodoCommunitiesService} from '../../openaireLibrary/connect/zenodoCommunities/zenodo-communities.service'; import {ZenodoCommunitiesService} from '../../openaireLibrary/connect/zenodoCommunities/zenodo-communities.service';
import {SearchZenodoCommunitiesService} from '../../openaireLibrary/connect/zenodoCommunities/searchZenodoCommunities.service'; import {SearchZenodoCommunitiesService} from '../../openaireLibrary/connect/zenodoCommunities/searchZenodoCommunities.service';
@ -12,7 +10,6 @@ import {CommunityInfo} from '../../openaireLibrary/connect/community/communityIn
import {ZenodoCommunityInfo} from '../../openaireLibrary/connect/zenodoCommunities/zenodoCommunityInfo'; import {ZenodoCommunityInfo} from '../../openaireLibrary/connect/zenodoCommunities/zenodoCommunityInfo';
import {SearchUtilsClass} from '../../openaireLibrary/searchPages/searchUtils/searchUtils.class'; import {SearchUtilsClass} from '../../openaireLibrary/searchPages/searchUtils/searchUtils.class';
import {ErrorCodes} from '../../openaireLibrary/utils/properties/errorCodes'; import {ErrorCodes} from '../../openaireLibrary/utils/properties/errorCodes';
import {HelperFunctions} from '../../openaireLibrary/utils/HelperFunctions.class';
import {Title} from '@angular/platform-browser'; import {Title} from '@angular/platform-browser';
import {properties} from '../../../environments/environment'; import {properties} from '../../../environments/environment';
import {Subscription} from 'rxjs'; import {Subscription} from 'rxjs';
@ -22,32 +19,21 @@ import {ManageZenodoCommunitiesComponent} from './manage-zenodo-communities.comp
@Component({ @Component({
selector: 'zenodo-communities', selector: 'zenodo-communities',
template: ` template: `
<div *ngIf="zenodoSearchUtils.status == errorCodes.LOADING" page-content> <manage-zenodo-communities #manage *ngIf="community && zenodoSearchUtils && zenodoSearchUtils.status != errorCodes.LOADING"
<div header> [loading]="showLoadingInRemove" [disableAdd]="add && add.loading"
<community-info tab="zenodo-communities"></community-info> [masterCommunity]=masterZenodoCommunity [selectedCommunities]=selectedCommunities
</div> [community]="community" [searchUtils]=zenodoSearchUtils (addZenodoCommunity)="openAddZenodoCommunites()"
<div inner> (zenodoCommunitiesChanged)="zenodoCommunitiesChanged($event)"></manage-zenodo-communities>
<div class="uk-position-center"> <fs-modal #fsModal>
<loading></loading> <add-zenodo-communities #add *ngIf="zenodoSearchUtils.status != errorCodes.LOADING" [masterCommunity]=masterZenodoCommunity
</div> [selectedCommunities]=selectedCommunities
</div> [community]="community" (zenodoCommunitiesChanged)="zenodoCommunitiesChanged($event)"></add-zenodo-communities>
</div>
<ng-container *ngIf="zenodoSearchUtils.status != errorCodes.LOADING">
<manage-zenodo-communities #manage *ngIf="communityId && zenodoSearchUtils" [masterCommunity]=masterZenodoCommunity [selectedCommunities]=selectedCommunities
[properties]=properties [communityId]=communityId [searchUtils]=zenodoSearchUtils
(toggleView)="toggleAction()"></manage-zenodo-communities>
</ng-container>
<fs-modal #fsModal (cancelEmitter)="toggleAction()">
<add-zenodo-communities *ngIf="zenodoSearchUtils.status != errorCodes.LOADING" [masterCommunity]=masterZenodoCommunity [selectedCommunities]=selectedCommunities
[properties]=properties [communityId]=communityId></add-zenodo-communities>
</fs-modal> </fs-modal>
` `
}) })
export class ZenodoCommunitiesComponent implements OnInit, OnDestroy { export class ZenodoCommunitiesComponent implements OnInit, OnDestroy {
public communityId: string = null; public community: CommunityInfo = null;
private community: CommunityInfo = null;
public toggle = false; public toggle = false;
public updateCommunityProjectsOnToggle = false;
public pageTitle = 'Manage zenodo communities'; public pageTitle = 'Manage zenodo communities';
masterZenodoCommunityId = null; masterZenodoCommunityId = null;
masterZenodoCommunity = null; masterZenodoCommunity = null;
@ -59,8 +45,9 @@ export class ZenodoCommunitiesComponent implements OnInit, OnDestroy {
public errorCodes: ErrorCodes = new ErrorCodes(); public errorCodes: ErrorCodes = new ErrorCodes();
subscriptions = []; subscriptions = [];
@ViewChild('fsModal', { static: true }) fullscreen: FullScreenModalComponent; @ViewChild('fsModal', { static: true }) fullscreen: FullScreenModalComponent;
@ViewChild('manage') manage: ManageZenodoCommunitiesComponent; @ViewChild(ManageZenodoCommunitiesComponent) manage: ManageZenodoCommunitiesComponent;
public showLoadingInRemove: boolean = true;
constructor(private element: ElementRef, private route: ActivatedRoute, private _router: Router, constructor(private element: ElementRef, private route: ActivatedRoute, private _router: Router,
private _zenodoCommunitieService: ZenodoCommunitiesService, private title: Title, private _zenodoCommunitieService: ZenodoCommunitiesService, private title: Title,
private _communityService: CommunityService, private _communityService: CommunityService,
@ -70,55 +57,52 @@ export class ZenodoCommunitiesComponent implements OnInit, OnDestroy {
ngOnInit() { ngOnInit() {
this.zenodoSearchUtils.status = this.errorCodes.LOADING; this.zenodoSearchUtils.status = this.errorCodes.LOADING;
this.properties = properties; this.properties = properties;
this.route.params.subscribe(params => {
this.communityId = params['community']; this.subscriptions.push(this._communityService.getCommunityAsObservable().subscribe(
if (this.communityId) { community => {
this.title.setTitle(this.communityId.toUpperCase() + ' | Zenodo Communities'); this.community = community;
if (this.communityId != null && this.communityId !== '') { this.title.setTitle(this.community.shortTitle.toUpperCase() + ' | Zenodo Communities');
this.subscriptions.push(this._communityService.getCommunityAsObservable().subscribe( this.masterZenodoCommunityId = this.community.zenodoCommunity;
community => { if (this.masterZenodoCommunityId) {
this.community = community; this.subscriptions.push(this._zenodoCommunitieService.getZenodoCommunityById(this.properties,
this.masterZenodoCommunityId = this.community.zenodoCommunity; this.properties.zenodoCommunities + this.masterZenodoCommunityId,
if (this.masterZenodoCommunityId) { null).subscribe(
this.subscriptions.push(this._zenodoCommunitieService.getZenodoCommunityById(this.properties, result => {
this.properties.zenodoCommunities + this.masterZenodoCommunityId, this.masterZenodoCommunity = result;
null).subscribe( this.selectedCommunities.unshift(this.masterZenodoCommunity);
result => { },
this.masterZenodoCommunity = result; error => {
}, const emptyCommunity: ZenodoCommunityInfo = new ZenodoCommunityInfo();
error => { emptyCommunity.id = this.masterZenodoCommunityId;
const emptyCommunity: ZenodoCommunityInfo = new ZenodoCommunityInfo(); emptyCommunity.title = this.masterZenodoCommunityId;
emptyCommunity.id = this.masterZenodoCommunityId; this.masterZenodoCommunity = emptyCommunity;
emptyCommunity.title = this.masterZenodoCommunityId; }
this.masterZenodoCommunity = emptyCommunity; ));
// console.log("Master Zenodo community'"+this.masterZenodoCommunityId+"' couldn't be loaded");
}
));
}
this.zenodoSearchUtils.status = this.errorCodes.LOADING;
this._searchZenodoCommunitiesService.searchZCommunities(this.properties, this.communityId).subscribe(
result => {
this.selectedCommunityIds = result;
this.zenodoSearchUtils.totalResults = this.selectedCommunityIds.length;
if (this.selectedCommunityIds.length === 0) {
this.zenodoSearchUtils.status = this.errorCodes.NONE;
}
for (let i = 0; i < this.selectedCommunityIds.length; i++) {
this.getZenodoCommunityById(
this.selectedCommunityIds[i]['zenodoid'],
this.selectedCommunityIds[i]['id']);
}
},
error => {
console.log('list of zenodo communities couldn\'t be loaded');
this.zenodoSearchUtils.status = this.errorCodes.DONE;
} // this.handleError('System error retrieving community profile', error)
);
}));
} }
} this.zenodoSearchUtils.status = this.errorCodes.LOADING;
}); this.zenodoSearchUtils.status = this.errorCodes.LOADING;
this._searchZenodoCommunitiesService.searchZCommunities(this.properties, this.community.communityId).subscribe(
result => {
this.selectedCommunityIds = result;
this.zenodoSearchUtils.totalResults = this.selectedCommunityIds.length;
if (this.selectedCommunityIds.length === 0) {
this.zenodoSearchUtils.status = this.errorCodes.NONE;
}
for (let i = 0; i < this.selectedCommunityIds.length; i++) {
this.getZenodoCommunityById(
this.selectedCommunityIds[i]['zenodoid'],
this.selectedCommunityIds[i]['id']);
}
},
error => {
console.log('list of zenodo communities couldn\'t be loaded');
this.zenodoSearchUtils.status = this.errorCodes.DONE;
}
);
})
);
this.fullscreen.title = "Search and Add Zenodo Communities"; this.fullscreen.title = "Search and Add Zenodo Communities";
this.fullscreen.okButtonText = "Done"; this.fullscreen.okButtonText = "Done";
this.fullscreen.okButton = true; this.fullscreen.okButton = true;
@ -132,26 +116,6 @@ export class ZenodoCommunitiesComponent implements OnInit, OnDestroy {
}); });
} }
public toggleAction() {
if (!Session.isLoggedIn()) {
this._router.navigate(['/user-info'], {
queryParams: {'errorCode': LoginErrorCodes.NOT_VALID, 'redirectUrl': this._router.url}
});
} else {
HelperFunctions.scroll();
this.toggle = !this.toggle;
if (this.toggle) {
this.fullscreen.open();
this.pageTitle = 'Manage zenodo communities';
} else {
this.manage.filterPreviewCommunities(this.manage.filterForm.value);
this.updateCommunityProjectsOnToggle = false;
this.pageTitle = 'Search zenodo communities';
}
}
}
getZenodoCommunityById(zenodoid, openaireId) { getZenodoCommunityById(zenodoid, openaireId) {
this.subscriptions.push(this._zenodoCommunitieService.getZenodoCommunityById(this.properties, this.subscriptions.push(this._zenodoCommunitieService.getZenodoCommunityById(this.properties,
this.properties.zenodoCommunities + zenodoid, openaireId).subscribe( this.properties.zenodoCommunities + zenodoid, openaireId).subscribe(
@ -178,4 +142,22 @@ export class ZenodoCommunitiesComponent implements OnInit, OnDestroy {
} }
)); ));
} }
public openAddZenodoCommunites() {
this.fullscreen.title = "Search and Add Zenodo Communities";
this.fullscreen.okButtonText = "Done";
this.fullscreen.back = true;
this.fullscreen.okButton = true;
this.fullscreen.open();
}
public zenodoCommunitiesChanged($event) {
this.selectedCommunities = $event.value;
this.showLoadingInRemove = false;
if (this.fullscreen.isOpen) {
this.manage.filterPreviewCommunities(this.manage.filterForm.value);
}
}
} }

View File

@ -13,19 +13,18 @@ import {ZenodoCommunitiesRoutingModule} from './zenodo-communities-routing.modul
import {CommunityInfoModule} from '../community-info/community-info.module'; import {CommunityInfoModule} from '../community-info/community-info.module';
import {SearchInputModule} from '../../openaireLibrary/sharedComponents/search-input/search-input.module'; import {SearchInputModule} from '../../openaireLibrary/sharedComponents/search-input/search-input.module';
import {IconsModule} from '../../openaireLibrary/utils/icons/icons.module'; import {IconsModule} from '../../openaireLibrary/utils/icons/icons.module';
import {IconsService} from '../../openaireLibrary/utils/icons/icons.service';
import {add, arrow_left, remove_circle_outline} from '../../openaireLibrary/utils/icons/icons';
import {NoLoadPaging} from '../../openaireLibrary/searchPages/searchUtils/no-load-paging.module'; import {NoLoadPaging} from '../../openaireLibrary/searchPages/searchUtils/no-load-paging.module';
import {LoadingModule} from '../../openaireLibrary/utils/loading/loading.module'; import {LoadingModule} from '../../openaireLibrary/utils/loading/loading.module';
import {PreviewZenodoCommunityComponent} from './preview-z-community.component'; import {PreviewZenodoCommunityComponent} from './preview-z-community.component';
import {PageContentModule} from '../../openaireLibrary/dashboard/sharedComponents/page-content/page-content.module'; import {PageContentModule} from '../../openaireLibrary/dashboard/sharedComponents/page-content/page-content.module';
import {FullScreenModalModule} from '../../openaireLibrary/utils/modal/full-screen-modal/full-screen-modal.module'; import {FullScreenModalModule} from '../../openaireLibrary/utils/modal/full-screen-modal/full-screen-modal.module';
import {HTMLToStringPipeModule} from '../../openaireLibrary/utils/pipes/HTMLToStringPipe.module'; import {HTMLToStringPipeModule} from '../../openaireLibrary/utils/pipes/HTMLToStringPipe.module';
import {PagingModule} from "../../openaireLibrary/utils/paging.module";
@NgModule({ @NgModule({
imports: [ imports: [
CommonModule, FormsModule, RouterModule, SearchZenodoCommunitiesServiceModule, ZenodoCommunitiesServiceModule, CommonModule, FormsModule, RouterModule, SearchZenodoCommunitiesServiceModule, ZenodoCommunitiesServiceModule,
AlertModalModule, ZenodoCommunitiesRoutingModule, CommunityInfoModule, PageContentModule, SearchInputModule, IconsModule, NoLoadPaging, LoadingModule, FullScreenModalModule, HTMLToStringPipeModule AlertModalModule, ZenodoCommunitiesRoutingModule, CommunityInfoModule, PageContentModule, SearchInputModule, IconsModule, NoLoadPaging, LoadingModule, FullScreenModalModule, HTMLToStringPipeModule, PagingModule
], ],
declarations: [ declarations: [
ManageZenodoCommunitiesComponent, ZenodoCommunitiesComponent, AddZenodoCommunitiesComponent, PreviewZenodoCommunityComponent ManageZenodoCommunitiesComponent, ZenodoCommunitiesComponent, AddZenodoCommunitiesComponent, PreviewZenodoCommunityComponent
@ -39,7 +38,5 @@ import {HTMLToStringPipeModule} from '../../openaireLibrary/utils/pipes/HTMLToSt
}) })
export class ZenodoCommunitiesModule { export class ZenodoCommunitiesModule {
constructor(private iconsService: IconsService) { constructor() {}
this.iconsService.registerIcons([add, arrow_left, remove_circle_outline ])
}
} }

@ -1 +1 @@
Subproject commit 35bca0f68bf19337413167ecf770f1027902964f Subproject commit 3c6d5cab3a9e3a1e3be42e231424a5c1350749ad