Merge remote-tracking branch 'origin/develop' into new-search

This commit is contained in:
Konstantinos Triantafyllou 2025-09-23 13:36:16 +03:00
commit 6b24f60c17
6 changed files with 158 additions and 145 deletions

View File

@ -54,7 +54,7 @@ import {ClearCacheService} from "../../../../openaireLibrary/services/clear-cach
<div class="uk-grid uk-grid-column-large uk-flex-middle" uk-grid>
<div class="uk-width-auto@l uk-width-1-1 uk-flex uk-flex-center">
<button class="uk-button uk-button-primary uk-flex uk-flex-middle uk-flex-wrap"
(click)="file.click()">
(click)="file.click()" [attr.uk-tooltip]="'Please upload a JPG or PNG image with maximum resolution 256x256 pixels.'">
<icon name="cloud_upload" [flex]="true"></icon>
<span class="uk-margin-small-left">Upload a file</span>
</button>

View File

@ -57,11 +57,11 @@
</ng-template>
<div class="uk-section-xsmall uk-margin-top">
<div class="uk-flex uk-flex-middle uk-grid" uk-grid>
<div class="uk-width-1-2@m uk-width-1-1">
<div *ngIf="communityService.selectedSubCommunityId()" class="uk-width-1-2@m uk-width-1-1">
<select-sub-community [readonly]="true"></select-sub-community>
</div>
<div class="uk-width-expand@m uk-width-1-1">
<div class="uk-grid uk-flex-middle uk-flex-right@l uk-flex-center" uk-grid>
<div class="uk-grid uk-flex-middle uk-flex-center" [class.uk-flex-right@l]="communityService.selectedSubCommunityId()" uk-grid>
<div class="uk-width-auto uk-margin-right">
<a uk-icon="icon: info; ratio: 1.3"></a>
<div *ngIf="community" class="uk-dropdown uk-padding-small uk-width-medium"
@ -104,7 +104,7 @@
<a class="uk-link-reset">
<icon name="more_vert" [flex]="true" [ratio]="1.2"></icon>
</a>
<div class="uk-dropdown uk-padding-small" [class.uk-open]="selectedIndexes.length > 0" uk-dropdown="mode: click">
<div #element class="uk-dropdown uk-padding-small" uk-dropdown="mode: click">
<div class="uk-flex uk-flex-middle">
<label>
<input id="checkAll" type="checkbox" (click)="selectAll()"
@ -140,7 +140,7 @@
title="Select"
value="{{selectedIndexes.indexOf(i) != -1}}"
[ngModel]="selectedIndexes.indexOf(i)!=-1"
(click)="toggleSelected(i)">
(click)="toggleSelected(i, element)">
</div>
<div *ngIf="!result['isPart']">
<div class="uk-padding-small uk-padding-remove-horizontal">
@ -148,8 +148,8 @@
class="uk-button uk-button-link uk-flex uk-flex-middle">
<icon name="add" [flex]="true"></icon>
<span class="uk-margin-small-left">
Add
</span>
Add
</span>
</a>
</div>
</div>

View File

@ -54,13 +54,13 @@ export class AddProjectsComponent implements OnInit {
funders: Filter = null;
@ViewChild('searchInputComponent') searchInputComponent: SearchInputComponent;
private projectUrl: string = "https://" + ((properties.environment == "beta" || properties.environment == "development") ? "beta." : "") + "explore.openaire.eu" + properties.searchLinkToProject;
public projectUrl: string = "https://" + ((properties.environment == "beta" || properties.environment == "development") ? "beta." : "") + "explore.openaire.eu" + properties.searchLinkToProject;
public body: string = "Send from page";
openaireEntities = OpenaireEntities;
constructor(private route: ActivatedRoute, private _router: Router, private _searchProjectsService: SearchProjectsService,
private communityService: CommunityService,
protected communityService: CommunityService,
private _manageCommunityProjectsService: ManageCommunityProjectsService,
private _clearCacheService: ClearCacheService, private _searchCommunityProjectsService: SearchCommunityProjectsService,
private _fb: UntypedFormBuilder) {
@ -86,10 +86,10 @@ export class AddProjectsComponent implements OnInit {
});
this.subscriptions.push(this.filterForm.get('keyword').valueChanges
.pipe(debounceTime(1000), distinctUntilChanged(), skip(1))
.subscribe(value => {
this.keywordChanged(value);
}));
.pipe(debounceTime(1000), distinctUntilChanged(), skip(1))
.subscribe(value => {
this.keywordChanged(value);
}));
}
public ngOnDestroy() {
@ -114,97 +114,97 @@ export class AddProjectsComponent implements OnInit {
get infoMessage(): string {
return "<div>" +
"If you cannot find a funder that is relevant for your "+OpenaireEntities.COMMUNITY.toLowerCase()+", please contact us " +
"(<a href=\"mailto:" + properties.feedbackmailForMissingEntities +
"?Subject=[OpenAIRE Connect - "+ this.community.shortTitle + "] report missing Funder" + "&body=" + this.body + "\" " +
"target=\"_top\">"+properties.feedbackmailForMissingEntities+"</a>) " +
"and we will try to get the funder on board!" +
"</div>";
"If you cannot find a funder that is relevant for your " + OpenaireEntities.COMMUNITY.toLowerCase() + ", please contact us " +
"(<a href=\"mailto:" + properties.feedbackmailForMissingEntities +
"?Subject=[OpenAIRE Connect - " + this.community.shortTitle + "] report missing Funder" + "&body=" + this.body + "\" " +
"target=\"_top\">" + properties.feedbackmailForMissingEntities + "</a>) " +
"and we will try to get the funder on board!" +
"</div>";
}
public addProject(project: SearchResult) {
this.subscriptions.push(this._manageCommunityProjectsService.addProject(this.properties, this.community.communityId, project, this.communityService.selectedSubCommunityId()).subscribe(
data => {
// this.communityProjects.push(data);
this._clearCacheService.purgeBrowserCache(this.openaireEntities.PROJECT+" added", this.community.communityId);
data => {
// this.communityProjects.push(data);
this._clearCacheService.purgeBrowserCache(this.openaireEntities.PROJECT + " added", this.community.communityId);
UIkit.notification(this.openaireEntities.PROJECT+' successfully added!', {
status: 'success',
timeout: 6000,
pos: 'bottom-right'
});
project["isPart"] = true;
this.communityProjectsChanged.emit({
value: project,
});
},
err => {
this.handleError('An error has been occurred. Try again later!');
console.error(err.status);
}
UIkit.notification(this.openaireEntities.PROJECT + ' successfully added!', {
status: 'success',
timeout: 6000,
pos: 'bottom-right'
});
project["isPart"] = true;
this.communityProjectsChanged.emit({
value: project,
});
},
err => {
this.handleError('An error has been occurred. Try again later!');
console.error(err.status);
}
));
}
public removeProject(project: any) {
// let communityProject = this.getCommunityProject(project);
this.subscriptions.push(this._manageCommunityProjectsService.removeProject(this.properties, this.community.communityId, project['id'], this.communityService.selectedSubCommunityId()).subscribe(
data => {
// let index = this.communityProjects.indexOf(communityProject);
// this.communityProjects.splice(index, 1);
this._clearCacheService.purgeBrowserCache(this.openaireEntities.PROJECT+" removed", this.community.communityId);
UIkit.notification(this.openaireEntities.PROJECT+' successfully removed!', {
status: 'success',
timeout: 6000,
pos: 'bottom-right'
});
project["isPart"] = false;
this.communityProjectsChanged.emit({
value: project,
});
},
err => {
this.handleError('An error has been occurred. Try again later!');
console.error(err);
}
this.subscriptions.push(this._manageCommunityProjectsService.removeProject(this.properties, this.community.communityId, project['id'], this.communityService.selectedSubCommunityId()).subscribe(
data => {
// let index = this.communityProjects.indexOf(communityProject);
// this.communityProjects.splice(index, 1);
this._clearCacheService.purgeBrowserCache(this.openaireEntities.PROJECT + " removed", this.community.communityId);
UIkit.notification(this.openaireEntities.PROJECT + ' successfully removed!', {
status: 'success',
timeout: 6000,
pos: 'bottom-right'
});
project["isPart"] = false;
this.communityProjectsChanged.emit({
value: project,
});
},
err => {
this.handleError('An error has been occurred. Try again later!');
console.error(err);
}
));
}
public getCommunityProject(project: any) {
this.subscriptions.push(this._searchCommunityProjectsService.searchProjectsWithPaging(this.properties, this.community.communityId, 1, this.resultsPerPage, project.id, null).subscribe(
data => {
if(data.totalElements > 0){
project["isPart"] = true;
}
},
err => {
console.error(err);
//TODO check erros (service not available, bad request)
data => {
if (data.totalElements > 0) {
project["isPart"] = true;
}
},
err => {
console.error(err);
//TODO check erros (service not available, bad request)
}
}
));
}
getFunders() {
this.openaireSearchUtils.refineStatus = this.errorCodes.LOADING;
this.subscriptions.push(this._searchProjectsService.getFunders(this.queryParameters, this.properties).subscribe(
data => {
this.funders = data[1][0];
this.funders.values.map((value) => {
if(value.id == this.selectedFunderId) {
value.selected = true;
this.funders.countSelectedValues++;
data => {
this.funders = data[1][0];
this.funders.values.map((value) => {
if (value.id == this.selectedFunderId) {
value.selected = true;
this.funders.countSelectedValues++;
}
})
if (this.funders.values && this.funders.values.length == 0) {
this.openaireSearchUtils.refineStatus = this.errorCodes.NONE;
} else {
this.openaireSearchUtils.refineStatus = this.errorCodes.DONE;
}
})
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)
}
},
err => {
this.openaireSearchUtils.refineStatus = this.errorCodes.ERROR;
console.error("Server error fetching funders: ", err)
}
));
}
@ -223,28 +223,28 @@ export class AddProjectsComponent implements OnInit {
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];
for(let project of this.openaireProjects){
this.getCommunityProject(project);
data => {
this.openaireSearchUtils.totalResults = data[0];
this.openaireProjects = data[1];
for (let project of this.openaireProjects) {
this.getCommunityProject(project);
}
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;
}
}
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;
}
}
);
}
}
@ -286,7 +286,7 @@ export class AddProjectsComponent implements OnInit {
this.openaireSearchUtils.page = page;
this.openaireSearchUtils.status = this.errorCodes.LOADING;
this.selectedIndexes = [];
if(refineQuery) {
if (refineQuery) {
this.openaireSearchUtils.refineStatus = this.errorCodes.LOADING;
this.getFunders();
}
@ -312,7 +312,7 @@ export class AddProjectsComponent implements OnInit {
getSelectedValues(filter): any {
var selected = [];
if(filter.values.length == 0 && this.selectedFunderId) {
if (filter.values.length == 0 && this.selectedFunderId) {
return [this.selectedFunder];
} else {
this.selectedFunderId = "";
@ -343,7 +343,7 @@ export class AddProjectsComponent implements OnInit {
this.selectedFunderId = "";
this.selectedFunder = null;
if(value) {
if (value) {
filter.countSelectedValues--;
if (value.selected == true) {
value.selected = false;
@ -355,46 +355,54 @@ export class AddProjectsComponent implements OnInit {
this.buildQueryParameters();
this.goTo(1);
}
public toggleSelected(index){
if (this.selectedIndexes.indexOf(index) != -1){
public toggleSelected(index, element) {
if (this.selectedIndexes.indexOf(index) != -1) {
this.selectedIndexes.splice(this.selectedIndexes.indexOf(index), 1);
}else{
} else {
this.selectedIndexes.push(index);
}
if (this.selectedIndexes.length > 0) {
UIkit.dropdown(element).show();
} else {
UIkit.dropdown(element).hide(false);
}
}
public addAll(){
public addAll() {
let projectList = [];
for(let index of this.selectedIndexes){
projectList.push(this.openaireProjects[index]);
for (let index of this.selectedIndexes) {
projectList.push(this.openaireProjects[index]);
}
this.subscriptions.push(this._manageCommunityProjectsService.addProjectList(this.properties, this.community.communityId, projectList, this.communityService.selectedSubCommunityId()).subscribe(
data => {
// this.communityProjects.push(data);
this._clearCacheService.purgeBrowserCache(this.openaireEntities.PROJECT+" added", this.community.communityId);
UIkit.notification(this.openaireEntities.PROJECT+' successfully added!', {
status: 'success',
timeout: 6000,
pos: 'bottom-right'
});
for(let index of this.selectedIndexes){
this.openaireProjects[index]["isPart"] = true;
data => {
// this.communityProjects.push(data);
this._clearCacheService.purgeBrowserCache(this.openaireEntities.PROJECT + " added", this.community.communityId);
UIkit.notification(this.openaireEntities.PROJECT + ' successfully added!', {
status: 'success',
timeout: 6000,
pos: 'bottom-right'
});
for (let index of this.selectedIndexes) {
this.openaireProjects[index]["isPart"] = true;
}
this.selectedIndexes = [];
this.communityProjectsChanged.emit({
list: projectList,
});
},
err => {
this.handleError('An error has been occurred. Try again later!');
console.error(err.status);
}
this.selectedIndexes = [];
this.communityProjectsChanged.emit({
list: projectList,
});
},
err => {
this.handleError('An error has been occurred. Try again later!');
console.error(err.status);
}
));
}
public selectAll(){
if(this.selectedIndexes.length < this.openaireProjects.length) {
public selectAll() {
if (this.selectedIndexes.length < this.openaireProjects.length) {
this.selectedIndexes = Array.from(Array(this.openaireProjects.length).keys());
}else{
} else {
this.selectedIndexes = [];
}
}

View File

@ -89,13 +89,13 @@
<ng-container *ngIf="communitySearchUtils.totalResults > 0">
<no-load-paging [type]="openaireEntities.PROJECTS | lowercase"
[page]="communitySearchUtils.page" [pageSize]="resultsPerPage"
(pageChange)="updatePage($event.value)"
(pageChange)="updatePage($event)"
[totalResults]="communitySearchUtils.totalResults">
<div class="uk-width-auto">
<a class="uk-link-reset">
<icon name="more_vert" [flex]="true" [ratio]="1.2"></icon>
</a>
<div class="uk-dropdown uk-padding-small" [class.uk-open]="selectedIndexes.length > 0" uk-dropdown="mode: click">
<div #element class="uk-dropdown uk-padding-small" uk-dropdown="mode: click">
<div class="uk-flex uk-flex-middle">
<label>
<input id="checkAll" type="checkbox" (click)="selectAll()"
@ -113,9 +113,8 @@
</div>
</div>
</no-load-paging>
</ng-container>
<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"
class="uk-grid uk-grid-large uk-child-width-1-1 uk-child-width-1-2@m uk-margin-top uk-margin-bottom"
uk-grid uk-height-match="target: .uk-card-body">
<div *ngFor="let item of previewCommunityProjects; let i=index">
<div class="uk-card uk-card-default">
@ -131,12 +130,12 @@
<span *ngIf="!item.name && !item.acronym">[no title available]</span>
</a>
<span *ngIf="(!item.openaireId && !(item.grantId && item.funder) || (item['availableSince'] && lastDBLoadDate && item['availableSince'] >= lastDBLoadDate))">
<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>
<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">
@ -156,7 +155,7 @@
<input [id]="item.id" class="uk-checkbox" type="checkbox" title="Select"
value="{{selectedIndexes.indexOf(i) != -1}}"
[ngModel]="selectedIndexes.indexOf(i)!=-1"
(click)="toggleSelected(i)">
(click)="toggleSelected(i, element)">
</div>
<div>
<div class="uk-padding-small uk-padding-remove-horizontal">
@ -179,6 +178,7 @@
customClasses="uk-flex-right@m uk-flex-center">
</paging-no-load>
</div>
</ng-container>
</div>
</div>
<!-- in all content config : show subcommunities in preview mode-->

View File

@ -312,12 +312,17 @@ export class RemoveProjectsComponent implements OnInit {
}
}
public toggleSelected(index) {
public toggleSelected(index, element) {
if (this.selectedIndexes.indexOf(index) != -1) {
this.selectedIndexes.splice(this.selectedIndexes.indexOf(index), 1);
} else {
this.selectedIndexes.push(index);
}
if(this.selectedIndexes.length > 0) {
UIkit.dropdown(element).show();
} else {
UIkit.dropdown(element).hide(false);
}
}
public removeAll() {

View File

@ -12,7 +12,7 @@ export class ManageCommunityProjectsService {
let headers = new HttpHeaders({'Content-Type': 'application/json', 'accept': 'application/json'});
let url = properties.communityAPI+pid+(subCommunity?'/subcommunities':'') +"/projects?projectId="+id + (subCommunity?'?subCommunityId=' + subCommunity:'') ;
let url = properties.communityAPI+pid+(subCommunity?'/subcommunities':'') +"/projects?projectId="+id + (subCommunity?'&subCommunityId=' + subCommunity:'') ;
//return this.http.delete(url, options)
return this.http.request('delete', url, { headers: headers})
}