Merge branch 'new-community-api' into develop

This commit is contained in:
argirok 2023-10-06 21:02:05 +03:00
commit 2f9b12c478
17 changed files with 160 additions and 208 deletions

@ -1 +1 @@
Subproject commit 1b989441db0b1f808d1b626d3588901d54ffaf90 Subproject commit 5e4aaab04f89446f956d524469ef2a856f556de5

View File

@ -113,6 +113,7 @@ export class AffiliationsComponent implements OnInit, OnDestroy {
deleteAffiliationOpen(index: number) { deleteAffiliationOpen(index: number) {
this.index = index; this.index = index;
let affiliation: Affiliation = this.affiliations[index]; let affiliation: Affiliation = this.affiliations[index];
console.log(index, affiliation)
this.removeAffiliationModal.alertTitle = 'Delete Organization'; this.removeAffiliationModal.alertTitle = 'Delete Organization';
this.removeAffiliationModal.message = 'Do you want to remove <b>' + this.removeAffiliationModal.message = 'Do you want to remove <b>' +
affiliation.name + '</b> from Organizations?'; affiliation.name + '</b> from Organizations?';
@ -164,7 +165,8 @@ export class AffiliationsComponent implements OnInit, OnDestroy {
removeAffiliation() { removeAffiliation() {
this.loading = true; this.loading = true;
this.affiliationService.deleteAffiliation(this.properties.communityAPI + this.community.communityId + '/organizations', console.log(this.index, this.affiliations[this.index].id)
this.affiliationService.deleteAffiliation(this.properties.communityAPI + this.community.communityId + '/organizations?organizationName='+this.affiliations[this.index].name,
this.affiliations[this.index].id).subscribe((deleteOK) => { this.affiliations[this.index].id).subscribe((deleteOK) => {
this.affiliations.splice(this.index, 1); this.affiliations.splice(this.index, 1);
if (this.currentPage.length === 0) { if (this.currentPage.length === 0) {

View File

@ -82,6 +82,17 @@ import {ClearCacheService} from "../../../../openaireLibrary/services/clear-cach
placeholder="Visibility status for your community's profile." placeholder="Visibility status for your community's profile."
[options]="statuses" type="select"></div> [options]="statuses" type="select"></div>
</div> </div>
<div class="uk-width-1-2@m">
<div input [formInput]="communityFb.get('claim')"
placeholder="Who can create links for your community"
[options]="claimOptions" type="select"></div>
</div>
<!-- Hide until the functionality is ready-->
<!-- <div class="uk-width-1-2@m">
<div input [formInput]="communityFb.get('membership')"
placeholder="Who can join"
[options]="membershipOptions" type="select"></div>
</div>-->
</div> </div>
</form> </form>
`, `,
@ -91,9 +102,24 @@ export class EditCommunityComponent {
public communityFb: UntypedFormGroup; public communityFb: UntypedFormGroup;
public statuses: Option[] = [ public statuses: Option[] = [
{label: 'Visible', value: 'all'}, {label: 'Visible', value: 'all'},
{label: 'Visible [Public*]', value: 'PUBLIC'},
{label: 'Visible to managers', value: 'manager'}, {label: 'Visible to managers', value: 'manager'},
{label: 'Visible to managers [Restricted*]', value: 'RESTRICTED'},
/*
{label: 'Hidden [Private*]', value: 'PRIVATE'},
*/
{label: 'Hidden', value: 'hidden'} {label: 'Hidden', value: 'hidden'}
] ]
public claimOptions: Option[] = [
{label: 'Logged in users', value: 'all'},
{label: 'Members only', value: 'membersOnly'},
{label: 'Managers only', value: 'managersOnly'}
]
public membershipOptions: Option[] = [
{label: 'Anyone can join', value: 'open'},
{label: 'By invitation', value: 'byInvitation'}
]
public community: CommunityInfo; public community: CommunityInfo;
public isNew: boolean; public isNew: boolean;
public properties: EnvProperties = properties public properties: EnvProperties = properties
@ -133,6 +159,8 @@ export class EditCommunityComponent {
shortName: this.fb.control(this.community.shortTitle, Validators.required), shortName: this.fb.control(this.community.shortTitle, Validators.required),
description: this.fb.control(this.community.description), description: this.fb.control(this.community.description),
status: this.fb.control(this.community.status), status: this.fb.control(this.community.status),
claim: this.fb.control(this.community.claim),
membership: this.fb.control(this.community.membership),
managers: this.fb.control(this.community.managers), managers: this.fb.control(this.community.managers),
isUpload: this.fb.control(this.community.isUpload), isUpload: this.fb.control(this.community.isUpload),
logoUrl: this.fb.control(this.community.logoUrl) logoUrl: this.fb.control(this.community.logoUrl)

View File

@ -81,7 +81,8 @@ export class RemoveContentProvidersComponent implements OnInit {
} }
public confirmedDeleteContentProvider() { public confirmedDeleteContentProvider() {
this.subscriptions.push(this._manageCommunityContentProvidersService.removeContentProvider(this.properties, this.community.communityId, this.selectedCommunityContentProvider.id).subscribe( console.log(this.selectedCommunityContentProvider)
this.subscriptions.push(this._manageCommunityContentProvidersService.removeContentProvider(this.properties, this.community.communityId, this.selectedCommunityContentProvider.openaireId).subscribe(
() => { () => {
let index = this.communityContentProviders.indexOf(this.selectedCommunityContentProvider); let index = this.communityContentProviders.indexOf(this.selectedCommunityContentProvider);
this.communityContentProviders.splice(index, 1); this.communityContentProviders.splice(index, 1);

View File

@ -94,12 +94,12 @@
<div class="uk-card-body"> <div class="uk-card-body">
<result-preview [properties]="properties" [showOrganizations]="true" <result-preview [properties]="properties" [showOrganizations]="true"
[showSubjects]="true" [result]="getResultPreview(result)" [showSubjects]="true" [result]="getResultPreview(result)"
[externalUrl]="projectUrl"> [externalUrl]="projectUrl" [hasLink]="false">
</result-preview> </result-preview>
</div> </div>
<div class="uk-card-footer uk-padding-remove-vertical"> <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 class="uk-grid uk-grid-small uk-flex-nowrap uk-grid-divider uk-flex-right" uk-grid>
<div *ngIf="!getCommunityProject(result)"> <div *ngIf="!result['isPart']">
<div class="uk-padding-small uk-padding-remove-horizontal"> <div class="uk-padding-small uk-padding-remove-horizontal">
<a (click)="addProject(result)" class="uk-button uk-button-link uk-flex uk-flex-middle"> <a (click)="addProject(result)" class="uk-button uk-button-link uk-flex uk-flex-middle">
<icon name="add" [flex]="true"></icon> <icon name="add" [flex]="true"></icon>
@ -109,7 +109,7 @@
</a> </a>
</div> </div>
</div> </div>
<div *ngIf="getCommunityProject(result)"> <div *ngIf="result['isPart']">
<div class="uk-padding-small uk-padding-remove-horizontal"> <div class="uk-padding-small uk-padding-remove-horizontal">
<a (click)="removeProject(result)" <a (click)="removeProject(result)"
class="uk-button uk-button-link uk-flex uk-flex-middle"> class="uk-button uk-button-link uk-flex uk-flex-middle">

View File

@ -19,6 +19,7 @@ import {CommunityInfo} from "../../openaireLibrary/connect/community/communityIn
import {OpenaireEntities} from "../../openaireLibrary/utils/properties/searchFields"; import {OpenaireEntities} from "../../openaireLibrary/utils/properties/searchFields";
import {Filter, Value} from "../../openaireLibrary/searchPages/searchUtils/searchHelperClasses.class"; import {Filter, Value} from "../../openaireLibrary/searchPages/searchUtils/searchHelperClasses.class";
import {ClearCacheService} from "../../openaireLibrary/services/clear-cache.service"; import {ClearCacheService} from "../../openaireLibrary/services/clear-cache.service";
import {SearchCommunityProjectsService} from "../../openaireLibrary/connect/projects/searchProjects.service";
declare var UIkit; declare var UIkit;
@ -38,7 +39,7 @@ export class AddProjectsComponent implements OnInit {
public errorCodes: ErrorCodes; public errorCodes: ErrorCodes;
public openaireSearchUtils: SearchUtilsClass = new SearchUtilsClass(); public openaireSearchUtils: SearchUtilsClass = new SearchUtilsClass();
@Output() communityProjectsChanged = new EventEmitter(); @Output() communityProjectsChanged = new EventEmitter();
@Input() communityProjects = []; // @Input() communityProjects = [];
public openaireProjects = []; public openaireProjects = [];
public queryParameters: string = ""; public queryParameters: string = "";
@ -58,7 +59,7 @@ export class AddProjectsComponent implements OnInit {
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 _clearCacheService: ClearCacheService, private _clearCacheService: ClearCacheService, private _searchCommunityProjectsService: SearchCommunityProjectsService,
private _fb: UntypedFormBuilder) { private _fb: UntypedFormBuilder) {
this.errorCodes = new ErrorCodes(); this.errorCodes = new ErrorCodes();
this.openaireSearchUtils.status = this.errorCodes.LOADING; this.openaireSearchUtils.status = this.errorCodes.LOADING;
@ -121,15 +122,17 @@ export class AddProjectsComponent implements OnInit {
public addProject(project: SearchResult) { public addProject(project: SearchResult) {
this.subscriptions.push(this._manageCommunityProjectsService.addProject(this.properties, this.community.communityId, project).subscribe( this.subscriptions.push(this._manageCommunityProjectsService.addProject(this.properties, this.community.communityId, project).subscribe(
data => { data => {
this.communityProjects.push(data); // this.communityProjects.push(data);
this._clearCacheService.purgeBrowserCache(this.openaireEntities.PROJECT+" added", this.community.communityId); this._clearCacheService.purgeBrowserCache(this.openaireEntities.PROJECT+" added", this.community.communityId);
UIkit.notification(this.openaireEntities.PROJECT+' successfully added!', { UIkit.notification(this.openaireEntities.PROJECT+' successfully added!', {
status: 'success', status: 'success',
timeout: 6000, timeout: 6000,
pos: 'bottom-right' pos: 'bottom-right'
}); });
project["isPart"] = true;
this.communityProjectsChanged.emit({ this.communityProjectsChanged.emit({
value: this.communityProjects, value: project,
}); });
}, },
err => { err => {
@ -140,20 +143,20 @@ export class AddProjectsComponent implements OnInit {
} }
public removeProject(project: any) { public removeProject(project: any) {
let communityProject = this.getCommunityProject(project); // let communityProject = this.getCommunityProject(project);
let projectId: string = communityProject['id']; this.subscriptions.push(this._manageCommunityProjectsService.removeProject(this.properties, this.community.communityId, project['id']).subscribe(
this.subscriptions.push(this._manageCommunityProjectsService.removeProject(this.properties, this.community.communityId, projectId).subscribe(
data => { data => {
let index = this.communityProjects.indexOf(communityProject); // let index = this.communityProjects.indexOf(communityProject);
this.communityProjects.splice(index, 1); // this.communityProjects.splice(index, 1);
this._clearCacheService.purgeBrowserCache(this.openaireEntities.PROJECT+" removed", this.community.communityId); this._clearCacheService.purgeBrowserCache(this.openaireEntities.PROJECT+" removed", this.community.communityId);
UIkit.notification(this.openaireEntities.PROJECT+' successfully removed!', { UIkit.notification(this.openaireEntities.PROJECT+' successfully removed!', {
status: 'success', status: 'success',
timeout: 6000, timeout: 6000,
pos: 'bottom-right' pos: 'bottom-right'
}); });
project["isPart"] = false;
this.communityProjectsChanged.emit({ this.communityProjectsChanged.emit({
value: this.communityProjects, value: project,
}); });
}, },
err => { err => {
@ -163,16 +166,19 @@ export class AddProjectsComponent implements OnInit {
)); ));
} }
public getCommunityProject(project: any): string { public getCommunityProject(project: any) {
let index: number = 0; this.subscriptions.push(this._searchCommunityProjectsService.searchProjectsWithPaging(this.properties, this.community.communityId, 1, this.resultsPerPage, project.id, null).subscribe(
for (let communityProject of this.communityProjects) { data => {
if (communityProject.openaireId == project.id || if(data.totalElements > 0){
(project.code == communityProject.grantId && project.funderShortname == communityProject.funder)) { project["isPart"] = true;
return communityProject;
} }
index++; },
err => {
console.error(err);
//TODO check erros (service not available, bad request)
} }
return ""; ));
} }
getFunders() { getFunders() {
@ -217,7 +223,9 @@ export class AddProjectsComponent implements OnInit {
data => { data => {
this.openaireSearchUtils.totalResults = data[0]; this.openaireSearchUtils.totalResults = data[0];
this.openaireProjects = data[1]; this.openaireProjects = data[1];
for(let project of this.openaireProjects){
this.getCommunityProject(project);
}
this.openaireSearchUtils.status = this.errorCodes.DONE; this.openaireSearchUtils.status = this.errorCodes.DONE;
if (this.openaireSearchUtils.totalResults == 0) { if (this.openaireSearchUtils.totalResults == 0) {
this.openaireSearchUtils.status = this.errorCodes.NONE; this.openaireSearchUtils.status = this.errorCodes.NONE;

View File

@ -16,12 +16,11 @@ import {CommunityService} from "../../openaireLibrary/connect/community/communit
@Component({ @Component({
selector: 'manage-projects', selector: 'manage-projects',
template: ` template: `
<remove-projects #removeProjectsComponent (addProjects)="openAddProjects()" [communityProjects]="communityProjects" <remove-projects #removeProjectsComponent (addProjects)="openAddProjects()"
[loading]="showLoadingInRemove" [community]="community" [loading]="showLoadingInRemove" [community]="community">
(communityProjectsChanged)="communityProjectsChanged($event)">
</remove-projects> </remove-projects>
<fs-modal #fsModalProjects> <fs-modal #fsModalProjects>
<add-projects #addProjects [communityProjects]="communityProjects" [community]="community" <add-projects *ngIf="modalIsOpen" #addProjects [community]="community"
(communityProjectsChanged)="communityProjectsChanged($event)"></add-projects> (communityProjectsChanged)="communityProjectsChanged($event)"></add-projects>
</fs-modal> </fs-modal>
` `
@ -36,6 +35,7 @@ export class ManageProjectsComponent implements OnInit {
public body: string = "Send from page"; public body: string = "Send from page";
public properties: EnvProperties = properties; public properties: EnvProperties = properties;
public community: CommunityInfo = null; public community: CommunityInfo = null;
modalIsOpen = false;
constructor(private element: ElementRef, constructor(private element: ElementRef,
private title: Title, private title: Title,
@ -68,15 +68,17 @@ export class ManageProjectsComponent implements OnInit {
this.fullscreen.back = true; this.fullscreen.back = true;
this.fullscreen.okButton = true; this.fullscreen.okButton = true;
this.fullscreen.open(); this.fullscreen.open();
this.modalIsOpen = true;
} }
public communityProjectsChanged($event) { public communityProjectsChanged($event) {
this.communityProjects = $event.value; /* this.communityProjects = $event.value;
this.showLoadingInRemove = false; this.showLoadingInRemove = false;
if (this.fullscreen.isOpen) { if (this.fullscreen.isOpen) {
this.removeProjectsComponent.applyFilters(); this.removeProjectsComponent.applyFilters();
this.removeProjectsComponent.createFunderFilter(); this.removeProjectsComponent.createFunderFilter();
} }*/
this.removeProjectsComponent.getCommunityProjects();
} }
} }

View File

@ -24,20 +24,21 @@
</div> </div>
<div inner> <div inner>
<div class="uk-margin-top"> <div class="uk-margin-top">
<results-and-pages [type]="openaireEntiites.PROJECTS | lowercase" [page]="page" [pageSize]="resultsPerPage" <results-and-pages [type]="openaireEntiites.PROJECTS | lowercase" [page]="communitySearchUtils.page" [pageSize]="resultsPerPage"
[totalResults]="previewCommunityProjects.length"></results-and-pages> [totalResults]="communitySearchUtils.totalResults"></results-and-pages>
</div> </div>
<div class="uk-grid uk-flex-middle uk-margin-medium-top" uk-grid> <div class="uk-grid uk-flex-middle uk-margin-medium-top" uk-grid>
<div *ngIf="allOptions.length > 0"> <div *ngIf="allFunderOptions.length > 0">
<dropdown-filter #dropdownFilter dropdownClass="uk-width-medium uk-padding-small" <dropdown-filter #dropdownFilter dropdownClass="uk-width-medium uk-padding-small"
name="Filter by Funder" [count]="filterForm.get('funder').value.length"> name="Filter by Funder" [count]="filterForm.get('funder').value?1:null">
<h6 class="uk-margin-remove-bottom" title="Filter by Funder">Funder</h6> <h6 class="uk-margin-remove-bottom" title="Filter by Funder">Funder</h6>
<ul class="uk-list uk-margin-remove-bottom"> <ul class="uk-list uk-margin-remove-bottom">
<li *ngFor="let option of allOptions">
<a class="uk-link-text"> <li *ngFor="let option of previewFunderOptions">
<label (click)="select(option.value, $event, dropdownFilter)" class="uk-flex uk-flex-middle"> <a class="uk-link-text" >
<label (click)="select(option, $event, dropdownFilter)" class="uk-flex uk-flex-middle">
<input class="uk-checkbox" <input class="uk-checkbox"
type="checkbox" [checked]="isSelected(option.value)"> type="checkbox" [checked]="isSelected(option.value.id)">
<span class="uk-margin-small-left">{{option.label}}</span> <span class="uk-margin-small-left">{{option.label}}</span>
</label> </label>
</a> </a>
@ -55,9 +56,9 @@
</div> </div>
<!-- </div>--> <!-- </div>-->
<div class="uk-width-expand@l uk-width-1-1 uk-flex uk-flex-right@m uk-flex-center"> <div class="uk-width-expand@l uk-width-1-1 uk-flex uk-flex-right@m uk-flex-center">
<paging-no-load *ngIf="previewCommunityProjects.length > 0" <paging-no-load *ngIf="communitySearchUtils.totalResults> 0" [currentPage]="communitySearchUtils.page"
(pageChange)="updatePage($event)" [size]="resultsPerPage" (pageChange)="updatePage($event)" [size]="resultsPerPage"
[totalResults]="previewCommunityProjects.length" customClasses="uk-flex-right"> [totalResults]="communitySearchUtils.totalResults" customClasses="uk-flex-right">
</paging-no-load> </paging-no-load>
</div> </div>
</div> </div>
@ -67,18 +68,17 @@
<loading></loading> <loading></loading>
</div> </div>
<div *ngIf="!loading"> <div *ngIf="!loading">
<div class="uk-margin-medium-bottom"> <div class="uk-margin-medium-bottom">
<div *ngIf="previewCommunityProjects.length == 0" <div *ngIf="previewCommunityProjects.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 {{openaireEntiites.PROJECTS | lowercase}} <div>No {{openaireEntiites.PROJECTS | lowercase}}
<span *ngIf="communityProjects.length == 0; else: notFound">for {{community.shortTitle}}</span> <span *ngIf="communitySearchUtils.totalResults == 0; else: notFound">for {{community.shortTitle}}</span>
<ng-template #notFound>found</ng-template> <ng-template #notFound>found</ng-template>
</div> </div>
</div> </div>
<div *ngIf="previewCommunityProjects.length > 0" <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"> 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 *ngFor="let item of previewCommunityProjects; let i=index">
<div class="uk-card uk-card-default"> <div class="uk-card uk-card-default">
<div class="uk-card-body"> <div class="uk-card-body">
<h6 class="uk-margin-bottom"> <h6 class="uk-margin-bottom">
@ -124,7 +124,7 @@
</div> </div>
<div class="uk-margin-small-top"> <div class="uk-margin-small-top">
<paging-no-load [currentPage]="page" <paging-no-load [currentPage]="page"
[totalResults]="previewCommunityProjects.length" [size]="resultsPerPage" [totalResults]="communitySearchUtils.totalResults" [size]="resultsPerPage"
(pageChange)="updatePage($event)" customClasses="uk-flex-right@m uk-flex-center"> (pageChange)="updatePage($event)" customClasses="uk-flex-right@m uk-flex-center">
</paging-no-load> </paging-no-load>
</div> </div>

View File

@ -19,6 +19,7 @@ import {CommunityInfo} from "../../openaireLibrary/connect/community/communityIn
import {HelperFunctions} from "../../openaireLibrary/utils/HelperFunctions.class"; import {HelperFunctions} from "../../openaireLibrary/utils/HelperFunctions.class";
import {NotificationHandler} from "../../openaireLibrary/utils/notification-handler"; import {NotificationHandler} from "../../openaireLibrary/utils/notification-handler";
import {ClearCacheService} from "../../openaireLibrary/services/clear-cache.service"; import {ClearCacheService} from "../../openaireLibrary/services/clear-cache.service";
import {debounceTime, distinctUntilChanged} from "rxjs/operators";
@Component({ @Component({
selector: 'remove-projects', selector: 'remove-projects',
@ -35,7 +36,7 @@ export class RemoveProjectsComponent implements OnInit {
public projectUrl = "https://" + ((properties.environment == "beta" || properties.environment == "development") ? "beta." : "") + "explore.openaire.eu" + properties.searchLinkToProject.split("?")[0]; public projectUrl = "https://" + ((properties.environment == "beta" || properties.environment == "development") ? "beta." : "") + "explore.openaire.eu" + properties.searchLinkToProject.split("?")[0];
@Output() communityProjectsChanged = new EventEmitter(); @Output() communityProjectsChanged = new EventEmitter();
@Input() public communityProjects = []; // @Input() public communityProjects = [];
public previewCommunityProjects = []; public previewCommunityProjects = [];
public communitySearchUtils: SearchUtilsClass = new SearchUtilsClass(); public communitySearchUtils: SearchUtilsClass = new SearchUtilsClass();
public errorCodes: ErrorCodes; public errorCodes: ErrorCodes;
@ -51,17 +52,13 @@ export class RemoveProjectsComponent implements OnInit {
/* Search */ /* Search */
@ViewChild('searchInputComponent') searchInputComponent: SearchInputComponent; @ViewChild('searchInputComponent') searchInputComponent: SearchInputComponent;
filterForm: UntypedFormGroup; filterForm: UntypedFormGroup;
public fundersCtrl: UntypedFormArray;
private searchText: RegExp = new RegExp(''); private searchText: RegExp = new RegExp('');
public keyword: string = ''; public keyword: string = '';
selectedFunders: string[] = []; allFunderOptions: Option[] = [];
allOptions: Option[] = []; previewFunderOptions: Option[] = [];
sortOptions: Option[] = [ sortOptions: Option[] = [
//{label:"Title (desc) ", value:{ sort: "title",descending: true }}, {label: "Title ", value: {sort: "name", descending: false}},
{label: "Title ", value: {sort: "title", descending: false}}, {label: "Grant ID ", value: {sort: "grantId", descending: false}},
//{label:"Grant ID (desc) ", value:{ sort: "grant",descending: true }},
{label: "Grant ID ", value: {sort: "grant", descending: false}},
//{label:"Funder (desc) ", value:{ sort: "funder",descending: true }},
{label: "Funder ", value: {sort: "funder", descending: false}} {label: "Funder ", value: {sort: "funder", descending: false}}
]; ];
@ -80,27 +77,21 @@ export class RemoveProjectsComponent implements OnInit {
ngOnInit() { ngOnInit() {
this.communitySearchUtils.keyword = ""; this.communitySearchUtils.keyword = "";
this.fundersCtrl = this._fb.array([]);
this.filterForm = this._fb.group({ this.filterForm = this._fb.group({
keyword: [''], keyword: [''],
funder: this.fundersCtrl, funder: this._fb.control(null),
sort: this._fb.control(this.sortOptions[0].value) sort: this._fb.control(this.sortOptions[0].value)
}); });
this.subscriptions.push(this.filterForm.get('keyword').valueChanges.subscribe(value => { this.subscriptions.push(this.filterForm.get('keyword').valueChanges.pipe(debounceTime(500), distinctUntilChanged()).subscribe(value => {
this.searchText = new RegExp(value, 'i');
this.page = 1; this.page = 1;
this.applyFilters(); this._getCommunityProjects(this.page, this.filterForm.get('keyword').value,(this.filterForm.get("funder").value? this.filterForm.get("funder").value.id:null),
})); this.filterForm.get("sort").value.sort );
this.subscriptions.push(this.filterForm.get('funder').valueChanges.subscribe(value => {
this.page = 1;
this.applyFilters();
})); }));
this.subscriptions.push(this.filterForm.get('sort').valueChanges.subscribe(value => { this.subscriptions.push(this.filterForm.get('sort').valueChanges.subscribe(value => {
this.page = 1; this.page = 1;
this.sort(); this._getCommunityProjects(this.page, this.filterForm.get('keyword').value, this.filterForm.get("funder").value? this.filterForm.get("funder").value.id:null, this.filterForm.get("sort").value.sort );
})); }));
this.subscriptions.push(this.communityService.getCommunityAsObservable().subscribe(community => { this.subscriptions.push(this.communityService.getCommunityAsObservable().subscribe(community => {
@ -111,7 +102,8 @@ export class RemoveProjectsComponent implements OnInit {
+ this.community.communityId + ".openaire.eu" + this.properties.searchLinkToProject.split("?")[0]; + this.community.communityId + ".openaire.eu" + this.properties.searchLinkToProject.split("?")[0];
this.keyword = ''; this.keyword = '';
this._getCommunityProjects(); this._getCommunityFunders();
this._getCommunityProjects(1,this.keyword, null);
} }
})); }));
} }
@ -133,18 +125,13 @@ export class RemoveProjectsComponent implements OnInit {
} }
public confirmedDeleteProject(data: any) { public confirmedDeleteProject(data: any) {
this.subscriptions.push(this._manageCommunityProjectsService.removeProject(this.properties, this.community.communityId, this.selectedCommunityProject.id).subscribe( this.subscriptions.push(this._manageCommunityProjectsService.removeProject(this.properties, this.community.communityId, this.selectedCommunityProject.openaireId).subscribe(
data => { data => {
let index = this.communityProjects.indexOf(this.selectedCommunityProject);
this.communityProjects.splice(index, 1);
this.applyFilters();
this._clearCacheService.purgeBrowserCache(this.openaireEntiites.PROJECT+" removed", this.community.communityId); this._clearCacheService.purgeBrowserCache(this.openaireEntiites.PROJECT+" removed", this.community.communityId);
NotificationHandler.rise(OpenaireEntities.PROJECT+' successfully removed!'); NotificationHandler.rise(OpenaireEntities.PROJECT+' successfully removed!');
this.communityProjectsChanged.emit({ this._getCommunityProjects(this.communitySearchUtils.page, this.keyword,null);
value: this.communityProjects,
});
this.communitySearchUtils.totalResults--;
this.communitySearchUtils.page = 1;
}, },
err => { err => {
this.handleError('An error has been occurred. Try again later!'); this.handleError('An error has been occurred. Try again later!');
@ -179,29 +166,21 @@ export class RemoveProjectsComponent implements OnInit {
this.alertModalDeleteCommunity.okButtonText = "Yes"; this.alertModalDeleteCommunity.okButtonText = "Yes";
this.alertModalDeleteCommunity.open(); this.alertModalDeleteCommunity.open();
} }
public getCommunityProjects() {
public _getCommunityProjects() { this._getCommunityProjects(this.communitySearchUtils.page, this.keyword,null );
}
public _getCommunityProjects(page, keyword, funder, orderBy = "name" ) {
this.communitySearchUtils.status = this.errorCodes.LOADING; this.communitySearchUtils.status = this.errorCodes.LOADING;
this.communityProjects = []; this.communitySearchUtils.page = page;
this.communitySearchUtils.totalResults = 0; this.communitySearchUtils.keyword = keyword;
this.communitySearchUtils.page = 1; this.subscriptions.push(this._searchCommunityProjectsService.searchProjectsWithPaging(this.properties, this.community.communityId, this.communitySearchUtils.page, this.resultsPerPage, this.communitySearchUtils.keyword, funder, orderBy).subscribe(
this.communitySearchUtils.keyword = "";
this.subscriptions.push(this._searchCommunityProjectsService.searchProjects(this.properties, this.community.communityId).subscribe(
data => { data => {
this.communityProjects = data; this.previewCommunityProjects = data.content;
this.previewCommunityProjects = this.communityProjects; this.communitySearchUtils.totalResults = data.totalElements;
this.sort();
this.communitySearchUtils.totalResults = data.length;
this.communitySearchUtils.status = this.errorCodes.DONE; this.communitySearchUtils.status = this.errorCodes.DONE;
this.communityProjectsChanged.emit({ this.communityProjectsChanged.emit({
value: this.communityProjects, value: this.communitySearchUtils.totalResults
}); });
this.createFunderFilter();
this.loading = false; this.loading = false;
}, },
err => { err => {
@ -215,90 +194,33 @@ export class RemoveProjectsComponent implements OnInit {
} else { } else {
this.communitySearchUtils.status = this.errorCodes.NOT_AVAILABLE; this.communitySearchUtils.status = this.errorCodes.NOT_AVAILABLE;
} }
this.loading = false; this.loading = false;
} }
)); ));
} }
public _getCommunityFunders() {
public createFunderFilter(): void { this.subscriptions.push(this._searchCommunityProjectsService.getProjectFunders(this.properties, this.community.communityId).subscribe(
let funders: Set<string> = new Set<string>(); data => {
this.allOptions = []; for (let funder of data) {
let i; this.allFunderOptions.push({label: funder, value: {id: funder, label: funder}});
for (i = 0; i < this.communityProjects.length; i++) {
let funder = this.communityProjects[i].funder;
if (funder && !funders.has(funder)) {
funders.add(funder);
this.allOptions.push({label: funder, value: {id: funder, label: funder}});
} }
this.previewFunderOptions =[...this.allFunderOptions];
},
err => {
} }
));
} }
public updatePage($event) { public updatePage($event) {
HelperFunctions.scroll(); HelperFunctions.scroll();
this.page = $event.value; this.page = $event.value;
this._getCommunityProjects(this.page, this.filterForm.get('keyword').value, null);
} }
addNew() { addNew() {
this.addProjects.emit(); this.addProjects.emit();
} }
public applyFilters() {
this.previewCommunityProjects = this.communityProjects.filter(project => {
return (this.filterCommunityProjectByKeyword(project) && this.filterCommunityProjectByFunder(project));
});
// check paging here!!!
if (this.previewCommunityProjects.slice((this.page - 1) * this.resultsPerPage, this.page * this.resultsPerPage).length == 0) {
this.page = 1;
}
this.sort();
}
public filterCommunityProjectByKeyword(project): boolean {
return this.searchText.toString() === ''
|| ((project.name + " " + project.acronym + " " + project.grantId + " " + project.funder)).match(this.searchText) != null;
}
public filterCommunityProjectByFunder(project): boolean {
if (this.fundersCtrl.getRawValue().length == 0) {
return true;
}
for (let funder of this.fundersCtrl.getRawValue()) {
if (project.funder.toLowerCase().indexOf(funder.label.toLowerCase()) != -1) {
return true;
}
}
return false;
}
private sort() {
let sortOption: { sort: string, descending: boolean } = this.filterForm.get('sort').value;
this.previewCommunityProjects.sort((left, right): number => {
if (sortOption.sort == "title") {
if ((left.name + left.acronym) > (right.name + right.acronym)) {
return sortOption.descending ? -1 : 1;
} else if ((left.name + left.acronym) < (right.name + right.acronym)) {
return sortOption.descending ? 1 : -1;
}
} else if (sortOption.sort == "grant") {
if (left.grantId > right.grantId) {
return sortOption.descending ? -1 : 1;
} else if (left.grantId < right.grantId) {
return sortOption.descending ? 1 : -1;
}
} else if (sortOption.sort == "funder") {
if (left.funder > right.funder) {
return sortOption.descending ? -1 : 1;
} else if (left.funder < right.funder) {
return sortOption.descending ? 1 : -1;
}
}
return 0;
});
}
public onSearchClose() { public onSearchClose() {
this.communitySearchUtils.keyword = this.filterForm.get('keyword').value; this.communitySearchUtils.keyword = this.filterForm.get('keyword').value;
@ -313,23 +235,23 @@ export class RemoveProjectsComponent implements OnInit {
NotificationHandler.rise(message, 'danger'); NotificationHandler.rise(message, 'danger');
} }
select(value: string, event, dropdownFilter: DropdownFilterComponent) { select(option, event, dropdownFilter: DropdownFilterComponent) {
console.log(option)
if(event.target instanceof HTMLInputElement) { if(event.target instanceof HTMLInputElement) {
dropdownFilter.closeDropdown(); dropdownFilter.closeDropdown();
if(event.target.checked && !this.selectedFunders.find(entity => value === entity)) { if(event.target.checked) {
this.selectedFunders.push(value); this.filterForm.get("funder").setValue(option.value);
this.fundersCtrl.setControl(this.fundersCtrl.value.length, this._fb.control(value)); this._getCommunityProjects(1, this.filterForm.get('keyword').value, this.filterForm.get('funder').value.id );
this.previewFunderOptions =[option];
} else if(!event.target.checked) { } else if(!event.target.checked) {
let index = this.selectedFunders.indexOf(value); this.filterForm.get("funder").setValue(null);
if(index !== -1) { this._getCommunityProjects(1, this.filterForm.get('keyword').value,null);
this.selectedFunders.splice(index, 1); this.previewFunderOptions =[...this.allFunderOptions];
this.fundersCtrl.removeAt(index);
}
} }
} }
} }
isSelected(value: string) { isSelected(value: string) {
return this.filterForm && this.filterForm.get('funder').value.find(funder => funder === value) return this.filterForm && this.filterForm.get('funder').value && this.filterForm.get('funder').value.id === value;
} }
} }

View File

@ -194,7 +194,7 @@ export class AddZenodoCommunitiesComponent implements OnInit {
public getOpenaireId(community: any): string { public getOpenaireId(community: any): string {
for (let com of this.selectedCommunities) { for (let com of this.selectedCommunities) {
if (com.id == community.id) { if (com.id == community.id) {
return com.openaireId; return com.id;
} }
} }
return null; return null;

View File

@ -88,7 +88,7 @@ export class ManageZenodoCommunitiesComponent implements OnInit, OnDestroy {
} }
public confirmedDeleteCommunity(data: any) { public confirmedDeleteCommunity(data: any) {
this.subscriptions.push(this._manageZenodoCommunitiesService.removeZCommunity(this.properties, this.community.communityId, this.selectedToDelete.openaireId).subscribe( this.subscriptions.push(this._manageZenodoCommunitiesService.removeZCommunity(this.properties, this.community.communityId, this.selectedToDelete.id).subscribe(
data => { data => {
var pos = -1; var pos = -1;
for (var i = 0; i < this.selectedCommunities.length; i++) { for (var i = 0; i < this.selectedCommunities.length; i++) {

View File

@ -3,8 +3,6 @@ import {ActivatedRoute, Router} from '@angular/router';
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 {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 {ZenodoCommunityInfo} from '../../openaireLibrary/connect/zenodoCommunities/zenodoCommunityInfo'; import {ZenodoCommunityInfo} from '../../openaireLibrary/connect/zenodoCommunities/zenodoCommunityInfo';
@ -50,8 +48,7 @@ export class ZenodoCommunitiesComponent implements OnInit, OnDestroy {
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) {
private _searchZenodoCommunitiesService: SearchZenodoCommunitiesService) {
} }
ngOnInit() { ngOnInit() {
@ -65,8 +62,7 @@ export class ZenodoCommunitiesComponent implements OnInit, OnDestroy {
this.masterZenodoCommunityId = this.community.zenodoCommunity; this.masterZenodoCommunityId = this.community.zenodoCommunity;
if (this.masterZenodoCommunityId) { if (this.masterZenodoCommunityId) {
this.subscriptions.push(this._zenodoCommunitieService.getZenodoCommunityById(this.properties, this.subscriptions.push(this._zenodoCommunitieService.getZenodoCommunityById(this.properties,
this.properties.zenodoCommunities + this.masterZenodoCommunityId, this.properties.zenodoCommunities + this.masterZenodoCommunityId).subscribe(
null).subscribe(
result => { result => {
this.masterZenodoCommunity = result; this.masterZenodoCommunity = result;
this.selectedCommunities.unshift(this.masterZenodoCommunity); this.selectedCommunities.unshift(this.masterZenodoCommunity);
@ -81,25 +77,24 @@ export class ZenodoCommunitiesComponent implements OnInit, OnDestroy {
} }
this.zenodoSearchUtils.status = this.errorCodes.LOADING; this.zenodoSearchUtils.status = this.errorCodes.LOADING;
this.zenodoSearchUtils.status = this.errorCodes.LOADING; this.zenodoSearchUtils.status = this.errorCodes.LOADING;
this._searchZenodoCommunitiesService.searchZCommunities(this.properties, this.community.communityId).subscribe( // this._searchZenodoCommunitiesService.searchZCommunities(this.properties, this.community.communityId).subscribe(
result => { // result => {
this.selectedCommunityIds = result; this.selectedCommunityIds = this.community.otherZenodoCommunities;
this.zenodoSearchUtils.totalResults = this.selectedCommunityIds.length; this.zenodoSearchUtils.totalResults = this.selectedCommunityIds.length;
if (this.selectedCommunityIds.length === 0) { if (this.selectedCommunityIds.length === 0) {
this.zenodoSearchUtils.status = this.errorCodes.NONE; this.zenodoSearchUtils.status = this.errorCodes.NONE;
} }
for (let i = 0; i < this.selectedCommunityIds.length; i++) { for (let i = 0; i < this.selectedCommunityIds.length; i++) {
this.getZenodoCommunityById( this.getZenodoCommunityById(
this.selectedCommunityIds[i]['zenodoid'], this.selectedCommunityIds[i]);
this.selectedCommunityIds[i]['id']);
} }
}, // },
error => { // error => {
console.log('list of zenodo communities couldn\'t be loaded'); // console.log('list of zenodo communities couldn\'t be loaded');
this.zenodoSearchUtils.status = this.errorCodes.DONE; // this.zenodoSearchUtils.status = this.errorCodes.DONE;
} // }
); // );
}) })
); );
@ -116,9 +111,9 @@ export class ZenodoCommunitiesComponent implements OnInit, OnDestroy {
}); });
} }
getZenodoCommunityById(zenodoid, openaireId) { getZenodoCommunityById(zenodoid) {
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).subscribe(
result => { result => {
this.selectedCommunities.push(result); this.selectedCommunities.push(result);
this.zenodocommunitiesloadedCount++; this.zenodocommunitiesloadedCount++;
@ -131,7 +126,6 @@ export class ZenodoCommunitiesComponent implements OnInit, OnDestroy {
error => { error => {
const emptyCommunity: ZenodoCommunityInfo = new ZenodoCommunityInfo(); const emptyCommunity: ZenodoCommunityInfo = new ZenodoCommunityInfo();
emptyCommunity.id = zenodoid; emptyCommunity.id = zenodoid;
emptyCommunity.openaireId = openaireId;
emptyCommunity.title = zenodoid; emptyCommunity.title = zenodoid;
this.selectedCommunities.push(emptyCommunity); this.selectedCommunities.push(emptyCommunity);
this.zenodocommunitiesloadedCount++; this.zenodocommunitiesloadedCount++;

View File

@ -5,7 +5,6 @@ import {RouterModule} from '@angular/router';
import {ManageZenodoCommunitiesComponent} from './manage-zenodo-communities.component'; import {ManageZenodoCommunitiesComponent} from './manage-zenodo-communities.component';
import {AddZenodoCommunitiesComponent} from './add-zenodo-communities.component'; import {AddZenodoCommunitiesComponent} from './add-zenodo-communities.component';
import {ZenodoCommunitiesComponent} from './zenodo-communities.component'; import {ZenodoCommunitiesComponent} from './zenodo-communities.component';
import {SearchZenodoCommunitiesServiceModule} from '../../openaireLibrary/connect/zenodoCommunities/searchZenodoCommunitiesService.module';
import {ManageZenodoCommunitiesService} from '../../services/manageZenodoCommunities.service'; import {ManageZenodoCommunitiesService} from '../../services/manageZenodoCommunities.service';
import {ZenodoCommunitiesServiceModule} from '../../openaireLibrary/connect/zenodoCommunities/zenodo-communitiesService.module'; import {ZenodoCommunitiesServiceModule} from '../../openaireLibrary/connect/zenodoCommunities/zenodo-communitiesService.module';
import {AlertModalModule} from '../../openaireLibrary/utils/modal/alertModal.module'; import {AlertModalModule} from '../../openaireLibrary/utils/modal/alertModal.module';
@ -22,7 +21,7 @@ import {PagingModule} from "../../openaireLibrary/utils/paging.module";
@NgModule({ @NgModule({
imports: [ imports: [
CommonModule, FormsModule, RouterModule, SearchZenodoCommunitiesServiceModule, ZenodoCommunitiesServiceModule, CommonModule, FormsModule, RouterModule, ZenodoCommunitiesServiceModule,
AlertModalModule, ZenodoCommunitiesRoutingModule, PageContentModule, SearchInputModule, IconsModule, NoLoadPaging, LoadingModule, FullScreenModalModule, HTMLToStringPipeModule, PagingModule AlertModalModule, ZenodoCommunitiesRoutingModule, PageContentModule, SearchInputModule, IconsModule, NoLoadPaging, LoadingModule, FullScreenModalModule, HTMLToStringPipeModule, PagingModule
], ],
declarations: [ declarations: [

View File

@ -11,7 +11,7 @@ export class ManageCommunityContentProvidersService {
removeContentProvider(properties: EnvProperties, pid: string, id: string): any { removeContentProvider(properties: EnvProperties, pid: string, id: string): any {
let headers = new HttpHeaders({'Content-Type': 'application/json', 'accept': 'application/json'}); let headers = new HttpHeaders({'Content-Type': 'application/json', 'accept': 'application/json'});
let url = properties.communityAPI + pid + '/contentproviders'; let url = properties.communityAPI + pid + '/contentproviders?contentproviderId=' +id;
return this.http.request('delete', url, {body: id, headers: headers}); return this.http.request('delete', url, {body: id, headers: headers});
} }

View File

@ -12,9 +12,9 @@ export class ManageCommunityProjectsService {
let headers = new HttpHeaders({'Content-Type': 'application/json', 'accept': 'application/json'}); let headers = new HttpHeaders({'Content-Type': 'application/json', 'accept': 'application/json'});
let url = properties.communityAPI+pid+"/projects"; let url = properties.communityAPI+pid+"/projects?projectId="+id;
//return this.http.delete(url, options) //return this.http.delete(url, options)
return this.http.request('delete', url, { body: id, headers: headers}) return this.http.request('delete', url, { headers: headers})
} }
addProject(properties:EnvProperties, pid: string, project: any) { addProject(properties:EnvProperties, pid: string, project: any) {

View File

@ -11,10 +11,10 @@ export class ManageZenodoCommunitiesService {
//let options = new RequestOptions({headers: headers, body: id}); //let options = new RequestOptions({headers: headers, body: id});
let headers = new HttpHeaders({'Content-Type': 'application/json', 'accept': 'application/json'}); let headers = new HttpHeaders({'Content-Type': 'application/json', 'accept': 'application/json'});
let url = properties.communityAPI + pid + "/zenodocommunities"; let url = properties.communityAPI + pid + "/zenodocommunities?zenodocommunity="+id;
//return this.http.delete(url, options); //return this.http.delete(url, options);
return this.http.request('delete', url, { body: id, headers: headers}) return this.http.request('delete', url, { headers: headers})
} }
addZCommunity(properties:EnvProperties, pid: string,zenodoid: string) { addZCommunity(properties:EnvProperties, pid: string,zenodoid: string) {
@ -23,13 +23,9 @@ export class ManageZenodoCommunitiesService {
let headers = new HttpHeaders({'Content-Type': 'application/json'}); let headers = new HttpHeaders({'Content-Type': 'application/json'});
let url = properties.communityAPI+pid+"/zenodocommunities"; let url = properties.communityAPI+pid+"/zenodocommunities?zenodocommunity="+zenodoid;
var zCommunity: any = {
"communityId": pid,
"zenodoid": zenodoid return this.http.post<any>(url, headers);
};
return this.http.post<any>(url, JSON.stringify(zCommunity), {headers: headers});
//.map(res => <any> res.json()) //.map(res => <any> res.json())
} }

@ -1 +1 @@
Subproject commit 2df4b377a3e89b7dd26a011a2e1e1f07fdcedf2a Subproject commit ac458b5a6d156167d7b6c9005ef1f9cfac75d3ae