Add contente providers modal with new UI

This commit is contained in:
Konstantinos Triantafyllou 2022-07-04 11:53:55 +03:00
parent 4160f837c1
commit 9c75d63171
10 changed files with 209 additions and 344 deletions

View File

@ -83,11 +83,6 @@ export class AppComponent implements OnInit {
})); }));
this.subscriptions.push(this.layoutService.hasHeader.subscribe(hasHeader => { this.subscriptions.push(this.layoutService.hasHeader.subscribe(hasHeader => {
this.hasHeader = hasHeader; this.hasHeader = hasHeader;
if(!this.hasHeader) {
document.documentElement.style.setProperty('--header-height', '0');
} else {
document.documentElement.style.setProperty('--header-height', '65px');
}
this.cdr.detectChanges(); this.cdr.detectChanges();
})); }));
this.subscriptions.push(this.layoutService.hasAdminMenu.subscribe(hasAdminMenu => { this.subscriptions.push(this.layoutService.hasAdminMenu.subscribe(hasAdminMenu => {
@ -121,11 +116,9 @@ export class AppComponent implements OnInit {
this.loading = false; this.loading = false;
} }
} else { } else {
if(this.community) { this.communityService.setCommunity(null);
this.communityService.setCommunity(null); this.community = null;
this.community = null; this.buildMenu();
this.buildMenu();
}
this.loading = false; this.loading = false;
} }
} }

@ -1 +1 @@
Subproject commit a738d3bb49d1af38f7eaf3ce34d519c76f075e4a Subproject commit de493c84923348f8289d4e507c04cfec80c30d69

View File

@ -36,46 +36,46 @@
[pageSize]="pageSize" [type]="'supporting organization' + (affiliations.length > 1?'s':'')"> [pageSize]="pageSize" [type]="'supporting organization' + (affiliations.length > 1?'s':'')">
</no-load-paging> </no-load-paging>
<div class="uk-grid uk-grid-large uk-child-width-1-1 uk-child-width-1-2@m uk-margin-top uk-margin-bottom" uk-height-match="target: .uk-card-body; row: false" uk-grid> <div class="uk-grid uk-grid-large uk-child-width-1-1 uk-child-width-1-2@m uk-margin-top uk-margin-bottom" uk-height-match="target: .uk-card-body; row: false" uk-grid>
<div *ngFor="let affiliation of currentPage; let i=index"> <div *ngFor="let affiliation of currentPage; 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">
<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">
<img class="uk-height-xsmall uk-blend-multiply" [src]="affiliation.logo_url | urlPrefix"> <img class="uk-height-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">
<span class="uk-text-meta uk-margin-xsmall-right">URL:</span> <span class="uk-text-meta uk-margin-xsmall-right">URL:</span>
<a [href]="affiliation.website_url | urlPrefix" class="uk-link" <a [href]="affiliation.website_url | urlPrefix" class="uk-link"
target="_blank">{{affiliation.website_url}}</a> target="_blank">{{affiliation.website_url}}</a>
</div>
</div> </div>
</div> </div>
<div class="uk-card-footer uk-padding-remove-vertical"> </div>
<div class="uk-grid uk-grid-small uk-flex-nowrap uk-grid-divider uk-flex-right" uk-grid> <div class="uk-card-footer uk-padding-remove-vertical">
<div> <div class="uk-grid uk-grid-small uk-flex-nowrap uk-grid-divider uk-flex-right" uk-grid>
<div class="uk-padding-small uk-padding-remove-horizontal"> <div>
<a (click)="editAffiliationOpen(i)" <div class="uk-padding-small uk-padding-remove-horizontal">
class="uk-button uk-button-link uk-flex uk-flex-middle"> <a (click)="editAffiliationOpen(i)"
<icon name="edit" [flex]="true"></icon> class="uk-button uk-button-link uk-flex uk-flex-middle">
<span class="uk-margin-xsmall-left">Edit</span> <icon name="edit" [flex]="true"></icon>
</a> <span class="uk-margin-xsmall-left">Edit</span>
</div> </a>
</div> </div>
<div> </div>
<div class="uk-padding-small uk-padding-remove-horizontal"> <div>
<button class="uk-button uk-button-link uk-flex uk-flex-middle" <div class="uk-padding-small uk-padding-remove-horizontal">
(click)="deleteAffiliationOpen(i)"> <button class="uk-button uk-button-link uk-flex uk-flex-middle"
<icon name="delete" [flex]="true"></icon> (click)="deleteAffiliationOpen(i)">
<span class="uk-margin-xsmall-left">Delete</span> <icon name="delete" [flex]="true"></icon>
</button> <span class="uk-margin-xsmall-left">Delete</span>
</div> </button>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </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]="affiliations.length" [size]="pageSize" [totalResults]="affiliations.length" [size]="pageSize"

View File

@ -1,60 +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-medium-bottom" uk-grid> <div class="uk-section uk-flex uk-flex-center uk-flex uk-flex-middle">
<div #searchInputComponent search-input [control]="filterForm.controls.keyword" [showSearch]="false" <div class="uk-width-auto uk-margin-right">
placeholder="Search Content Providers" <a uk-icon="icon: info; ratio: 1.3"></a>
[selected]="openaireSearchUtils.keyword" (closeEmitter)="onSearchClose()" (resetEmitter)="resetInput()" <div *ngIf="community" class="uk-dropdown uk-padding-small uk-width-medium" uk-dropdown="mode: hover">
[bordered]="true" colorClass="uk-text-secondary" If you cannot find a content provider relevant to your community, probably it is not OpenAIRE compliant.
class="uk-width-1-2@l uk-width-1-2@m uk-width-1-1"></div> Feel free to contact us
</div> (<a
[href]="'mailto:' + properties.feedbackmailForMissingEntities +'?Subject=[OpenAIRE Connect - '+ community.shortTitle + '] report missing Funder' + '&body=' + body"
<div id="manage-content-providers"> target="_top">{{properties.feedbackmailForMissingEntities}}</a>)
<div *ngIf="openaireSearchUtils.status == errorCodes.LOADING" class="uk-position-large-top"> to let us know and we'll try to get the provider on board!
<loading></loading>
</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 content providers available</div>
<div *ngIf="openaireSearchUtils.status == errorCodes.ERROR">An Error Occurred. No OpenAIRE content providers 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 content providers found</div>
</div> </div>
</div> </div>
<!-- <errorMessages [status]="[openaireSearchUtils.status]" [type]="'OpenAIRE content providers'"></errorMessages>--> <div search-input class="uk-width-xlarge@l uk-width-large" [searchControl]="filterForm.get('keyword')" searchInputClass="outer"
placeholder="Search Content Providers" [disabled]="loading"></div>
<ng-container *ngIf="openaireSearchUtils.totalResults > 0"> </div>
<no-load-paging [type]="'Content Providers'" <div class="uk-section uk-section-small uk-position-relative">
[page]="openaireSearchUtils.page" [pageSize]="resultsPerPage" (pageChange)="goTo($event.value)" <div *ngIf="openaireSearchUtils.status == errorCodes.LOADING" class="uk-position-center">
[totalResults]="openaireSearchUtils.totalResults"> <loading></loading>
</no-load-paging> </div>
<div *ngIf="openaireSearchUtils.status !== errorCodes.LOADING">
<ul class="uk-list search-results uk-margin-medium-top uk-margin-medium-bottom"> <div *ngIf="openaireSearchUtils.totalResults == 0"
<li *ngFor="let result of openaireContentProviders" class="uk-animation-fade"> class="uk-card uk-card-default uk-padding-large uk-text-center uk-margin-bottom uk-text-bold">
<div class="uk-card uk-card-default uk-card-hover uk-text-small uk-margin-bottom"> <div>No content providers found</div>
<div class="uk-grid uk-grid-divider uk-padding-small" uk-grid> </div>
<div class="uk-width-expand@m uk-width-1-1"> <ng-container *ngIf="openaireSearchUtils.totalResults > 0">
<no-load-paging [type]="'content Providers'"
[page]="openaireSearchUtils.page" [pageSize]="resultsPerPage" (pageChange)="goTo($event.value)"
[totalResults]="openaireSearchUtils.totalResults">
</no-load-paging>
<div class="uk-grid uk-child-width-1-1 uk-margin-top uk-margin-bottom" uk-grid>
<div *ngFor="let result of openaireContentProviders">
<div class="uk-card uk-card-default">
<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]="contentProviderUrl"> [externalUrl]="contentProviderUrl">
</result-preview> </result-preview>
</div> </div>
<div class="uk-width-auto@m uk-width-1-1"> <div class="uk-card-footer uk-padding-remove-vertical">
<div class="uk-flex uk-flex-middle uk-flex-center uk-flex-column uk-height-1-1"> <div class="uk-grid uk-grid-small uk-flex-nowrap uk-grid-divider uk-flex-right" uk-grid>
<div class="uk-padding-small uk-padding-remove-horizontal"> <div *ngIf="!getCommunityContentProvider(result)">
<div class="uk-padding-small uk-padding-remove-horizontal">
<div [class.hide-element]="!getCommunityContentProvider(result)"> <a (click)="addContentProvider(result)" class="uk-button uk-button-link uk-flex uk-flex-middle">
<a (click)="removeContentProvider(result)" class="uk-button action uk-flex uk-flex-middle"> <icon name="add" [flex]="true"></icon>
<icon name="remove_circle_outline"></icon> <span class="uk-margin-small-left">
<span class="uk-margin-small-left">Remove content provider</span> Add
</span>
</a> </a>
</div> </div>
</div>
<div [class.hide-element]="getCommunityContentProvider(result)"> <div *ngIf="getCommunityContentProvider(result)">
<a (click)="addContentProvider(result)" 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 content provider </div><div>Newly added content providers will be linked to your community on the next run of our algorithms.</div></div>"> <a (click)="removeContentProvider(result)"
<div class="uk-text-success"> class="uk-button uk-button-link uk-flex uk-flex-middle">
<icon name="add"></icon> <icon name="remove" [flex]="true"></icon>
</div> <span class="uk-margin-small-left">Remove</span>
<span class="uk-margin-small-left">Add content provider</span>
</a> </a>
</div> </div>
</div> </div>
@ -62,17 +61,13 @@
</div> </div>
</div> </div>
</div> </div>
</li> </div>
</ul> <div class="uk-margin-small-top">
<paging-no-load [currentPage]="openaireSearchUtils.page"
<!-- <div [class]="openaireSearchUtils.page > pagingLimit ? 'search-results' : ''"--> [totalResults]="openaireSearchUtils.totalResults" [size]="resultsPerPage"
<!-- *ngIf="(openaireSearchUtils.page >= pagingLimit) && (openaireSearchUtils.totalResults > resultsPerPage*pagingLimit)">--> (pageChange)="goTo($event)" customClasses="uk-flex-right@m uk-flex-center">
<!-- <p class="uk-alert-warning" uk-alert>For more results please try a new, more specific query</p>--> </paging-no-load>
<!-- </div>--> </div>
</ng-container>
<no-load-paging [type]="'Content Providers'" </div>
[page]="openaireSearchUtils.page" [pageSize]="resultsPerPage" (pageChange)="goTo($event.value)"
[totalResults]="openaireSearchUtils.totalResults">
</no-load-paging>
</ng-container>
</div> </div>

View File

@ -1,8 +1,8 @@
import {Component, OnInit, Input, Output, EventEmitter, ViewChild} from '@angular/core'; import {Component, OnInit, Input, Output, EventEmitter, ViewChild} from '@angular/core';
import { ActivatedRoute, Router } from "@angular/router"; import {ActivatedRoute, Router} from "@angular/router";
import {SearchResult} from '../../openaireLibrary/utils/entities/searchResult'; import {SearchResult} from '../../openaireLibrary/utils/entities/searchResult';
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 {EnvProperties} from '../../openaireLibrary/utils/properties/env-properties'; import {EnvProperties} from '../../openaireLibrary/utils/properties/env-properties';
import {SearchDataprovidersService} from '../../openaireLibrary/services/searchDataproviders.service'; import {SearchDataprovidersService} from '../../openaireLibrary/services/searchDataproviders.service';
import {RouterHelper} from '../../openaireLibrary/utils/routerHelper.class'; import {RouterHelper} from '../../openaireLibrary/utils/routerHelper.class';
@ -16,20 +16,17 @@ import {SearchInputComponent} from "../../openaireLibrary/sharedComponents/searc
import {Subscriber} from "rxjs"; import {Subscriber} from "rxjs";
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 {NotificationHandler} from "../../openaireLibrary/utils/notification-handler";
declare var UIkit; import {CommunityInfo} from "../../openaireLibrary/connect/community/communityInfo";
@Component({ @Component({
selector: 'add-content-providers', selector: 'add-content-providers',
templateUrl: './add-content-providers.component.html', templateUrl: './add-content-providers.component.html',
}) })
export class AddContentProvidersComponent implements OnInit { export class AddContentProvidersComponent implements OnInit {
private subscriptions: any[] = []; private subscriptions: any[] = [];
public subResults: any; public subResults: any;
@Input() public community: CommunityInfo;
private community: string = '';
public routerHelper: RouterHelper = new RouterHelper(); public routerHelper: RouterHelper = new RouterHelper();
public properties: EnvProperties = properties; public properties: EnvProperties = properties;
public errorCodes: ErrorCodes; public errorCodes: ErrorCodes;
@ -38,46 +35,33 @@ export class AddContentProvidersComponent implements OnInit {
@Input() communityContentProviders = []; @Input() communityContentProviders = [];
public openaireContentProviders = []; public openaireContentProviders = [];
public queryParameters: string = ""; public queryParameters: string = "";
// public pagingLimit: number = properties.pagingLimit;
public resultsPerPage: number = properties.resultsPerPage; public resultsPerPage: number = properties.resultsPerPage;
filterForm: FormGroup; filterForm: FormGroup;
@ViewChild('searchInputComponent') searchInputComponent: SearchInputComponent; @ViewChild('searchInputComponent') searchInputComponent: SearchInputComponent;
public contentProviderUrl: string = "https://" + ((properties.environment == "beta" || properties.environment == "development") ? "beta." : "") + "explore.openaire.eu" + properties.searchLinkToDataProvider;
private contentProviderUrl: string = "https://" + ((properties.environment == "beta" || properties.environment == "development") ? "beta." : "") + "explore.openaire.eu" + properties.searchLinkToDataProvider;
public body: string = "Send from page"; public body: string = "Send from page";
@Output() toggleView: EventEmitter<any> = new EventEmitter(); @Output() toggleView: EventEmitter<any> = new EventEmitter();
constructor(private route: ActivatedRoute, private _router: Router, constructor(private route: ActivatedRoute, private router: Router,
private _searchContentProvidersService: SearchDataprovidersService, private searchDataprovidersService: SearchDataprovidersService,
private _manageCommunityContentProvidersService: ManageCommunityContentProvidersService, private manageCommunityContentProvidersService: ManageCommunityContentProvidersService,
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;
} }
ngOnInit() { ngOnInit() {
this.subscriptions.push(this.route.params.subscribe(params => { this.subscriptions.push(this.route.params.subscribe(params => {
this.openaireSearchUtils.status = this.errorCodes.LOADING; this.openaireSearchUtils.status = this.errorCodes.LOADING;
this.community = params['community'];
// this.contentProviderUrl = "https://" + ((this.properties.environment == "beta" || this.properties.environment == "development") ? "beta." : "")
// + this.community + ".openaire.eu" + this.properties.searchLinkToDataProvider;
this._getOpenaireContentProviders("", 1, this.resultsPerPage); this._getOpenaireContentProviders("", 1, this.resultsPerPage);
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.openaireSearchUtils.keyword = ""; this.openaireSearchUtils.keyword = "";
this.filterForm = this.fb.group({
this.filterForm = this._fb.group({
keyword: [''], keyword: [''],
}); });
this.subscriptions.push(this.filterForm.get('keyword').valueChanges this.subscriptions.push(this.filterForm.get('keyword').valueChanges
.pipe(debounceTime(1000), distinctUntilChanged()) .pipe(debounceTime(1000), distinctUntilChanged())
.subscribe(value => { .subscribe(value => {
@ -85,81 +69,57 @@ export class AddContentProvidersComponent implements OnInit {
}) })
); );
} }
public ngOnDestroy() { public ngOnDestroy() {
this.subscriptions.forEach(sub => { this.subscriptions.forEach(sub => {
if (sub instanceof Subscriber) { if (sub instanceof Subscriber) {
sub.unsubscribe(); sub.unsubscribe();
} }
}); });
if(this.subResults){ if (this.subResults) {
this.subResults.unsubscribe(); this.subResults.unsubscribe();
} }
} }
get loading() {
return this.openaireSearchUtils.status == this.errorCodes.LOADING
}
public addContentProvider(contenProvider: SearchResult) { public addContentProvider(contenProvider: SearchResult) {
if (!Session.isLoggedIn()) { this.subscriptions.push(this.manageCommunityContentProvidersService.addContentProvider(this.properties, this.community.communityId, contenProvider).subscribe(
this._router.navigate(['/user-info'], { data => {
queryParams: { this.communityContentProviders.push(data);
"errorCode": LoginErrorCodes.NOT_VALID, NotificationHandler.rise('Content Provider successfully added!')
"redirectUrl": this._router.url this.communityContentProvidersChanged.emit({
} value: this.communityContentProviders,
}); });
} else { },
this.subscriptions.push(this._manageCommunityContentProvidersService.addContentProvider(this.properties, this.community, contenProvider).subscribe( error => {
data => { this.handleError('An error has been occurred. Try again later!', error);
this.communityContentProviders.push(data); }
UIkit.notification('Content Provider successfully added!', { ));
status: 'success',
timeout: 6000,
pos: 'bottom-right'
});
this.communityContentProvidersChanged.emit({
value: this.communityContentProviders,
});
},
err => {
this.handleError('An error has been occurred. Try again later!');
console.error(err.status);
}
));
}
} }
public removeContentProvider(contentProvider) { public removeContentProvider(contentProvider) {
if (!Session.isLoggedIn()) { let communityContentProvider = this.getCommunityContentProvider(contentProvider);
this._router.navigate(['/user-info'], { let contentProviderId: string = communityContentProvider['id'];
queryParams: { this.subscriptions.push(this.manageCommunityContentProvidersService.removeContentProvider(this.properties, this.community.communityId, contentProviderId).subscribe(
"errorCode": LoginErrorCodes.NOT_VALID, data => {
"redirectUrl": this._router.url let index = this.communityContentProviders.indexOf(communityContentProvider);
} this.communityContentProviders.splice(index, 1);
}); NotificationHandler.rise('Content Provider successfully removed!')
} else { this.communityContentProvidersChanged.emit({
let communityContentProvider = this.getCommunityContentProvider(contentProvider); value: this.communityContentProviders,
let contentProviderId: string = communityContentProvider['id']; });
this.subscriptions.push(this._manageCommunityContentProvidersService.removeContentProvider(this.properties, this.community, contentProviderId).subscribe( },
data => { error => {
let index = this.communityContentProviders.indexOf(communityContentProvider); this.handleError('An error has been occurred. Try again later!', error);
this.communityContentProviders.splice(index, 1); }
UIkit.notification('Content Provider successfully removed!', { ));
status: 'success',
timeout: 6000,
pos: 'bottom-right'
});
this.communityContentProvidersChanged.emit({
value: this.communityContentProviders,
});
},
err => {
this.handleError('An error has been occurred. Try again later!');
console.error(err);
}
));
}
} }
public getCommunityContentProvider(contentProvider: any): string { public getCommunityContentProvider(contentProvider: any): any {
let index: number = 0; let index: number = 0;
for (let communityContentProvider of this.communityContentProviders) { for (let communityContentProvider of this.communityContentProviders) {
if (communityContentProvider.openaireId == contentProvider.id) { if (communityContentProvider.openaireId == contentProvider.id) {
@ -167,133 +127,69 @@ export class AddContentProvidersComponent implements OnInit {
} }
index++; index++;
} }
return ""; return null;
} }
public getResultPreview(result: SearchResult): ResultPreview { public getResultPreview(result: SearchResult): ResultPreview {
return ResultPreview.searchResultConvert(result, "dataprovider"); return ResultPreview.searchResultConvert(result, "dataprovider");
} }
// public inCommunity(contentProvider: any): any {
// for(let communityContentProvider of this.communityContentProviders) {
// if(communityContentProvider.openaireId == contentProvider.id) {
// return true;
// }
// }
//
// if(this.undo[contentProvider.id]) {
// return true;
// }
// return false;
// }
private _getOpenaireContentProviders(parameters: string, page: number, size: number) { private _getOpenaireContentProviders(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, this.openaireContentProviders = [];
"redirectUrl": this._router.url this.openaireSearchUtils.totalResults = 0;
}
}); if (this.subResults) {
} else { this.subResults.unsubscribe();
// if (page > this.pagingLimit) {
// size = 0;
// }
if (this.openaireSearchUtils.status == this.errorCodes.LOADING) {
this.openaireSearchUtils.status = this.errorCodes.LOADING;
this.openaireContentProviders = [];
this.openaireSearchUtils.totalResults = 0;
if(this.subResults){
this.subResults.unsubscribe();
}
this.subResults = this._searchContentProvidersService.searchDataproviders(parameters, null, page, size, [], this.properties).subscribe(
data => {
this.openaireSearchUtils.totalResults = data[0];
this.openaireContentProviders = 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.searchDataprovidersService.searchDataproviders(parameters, null, page, size, [], this.properties).subscribe(
data => {
this.openaireSearchUtils.totalResults = data[0];
this.openaireContentProviders = data[1];
this.openaireSearchUtils.status = this.errorCodes.DONE;
if (this.openaireSearchUtils.totalResults == 0) {
this.openaireSearchUtils.status = this.errorCodes.NONE;
}
},
error => {
if (error.status == '404') {
this.handleError('No OpenAIRE content providers found.', error);
this.openaireSearchUtils.status = this.errorCodes.NOT_FOUND;
} else if (error.status == '500') {
this.handleError('An Error Occurred. No OpenAIRE content providers found.', error);
this.openaireSearchUtils.status = this.errorCodes.ERROR;
} else {
this.handleError('Service temporarily unavailable. Please try again later.', error);
this.openaireSearchUtils.status = this.errorCodes.NOT_AVAILABLE;
}
}
);
} }
} }
totalPages(): number {
let totalPages: any = this.openaireSearchUtils.totalResults / (this.resultsPerPage);
if (!(Number.isInteger(totalPages))) {
totalPages = (parseInt(totalPages, 10) + 1);
}
return totalPages;
}
keywordChanged(keyword) { keywordChanged(keyword) {
this.openaireSearchUtils.keyword = keyword; this.openaireSearchUtils.keyword = keyword;
this.buildQueryParameters(); this.buildQueryParameters();
this.goTo(1); this.goTo(1);
} }
buildQueryParameters() { buildQueryParameters() {
this.queryParameters = ""; this.queryParameters = "";
if (this.openaireSearchUtils.keyword) { if (this.openaireSearchUtils.keyword) {
this.queryParameters = "q=" + StringUtils.URIEncode(this.openaireSearchUtils.keyword); this.queryParameters = "q=" + StringUtils.URIEncode(this.openaireSearchUtils.keyword);
} }
} }
goTo(page: number = 1) { goTo(page: number = 1) {
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);
} }
back() { handleError(message: string, error = null) {
this.toggleView.emit(null); console.error(error);
} NotificationHandler.rise(message, 'danger');
public onSearchClose() {
this.openaireSearchUtils.keyword = this.filterForm.get('keyword').value;
}
public resetInput() {
this.openaireSearchUtils.keyword = null;
this.searchInputComponent.reset()
}
handleError(message: string) {
UIkit.notification(message, {
status: 'danger',
timeout: 6000,
pos: 'bottom-right'
});
} }
} }

View File

@ -1,8 +1,6 @@
import {Component, ElementRef, Input, OnInit, ViewChild} from '@angular/core'; import {Component, ElementRef, Input, OnInit, ViewChild} from '@angular/core';
import {Router} from "@angular/router"; import {Router} from "@angular/router";
import {RemoveContentProvidersComponent} from './remove-content-providers.component'; import {RemoveContentProvidersComponent} from './remove-content-providers.component';
import {HelperFunctions} from "../../openaireLibrary/utils/HelperFunctions.class";
import {Title} from '@angular/platform-browser'; import {Title} from '@angular/platform-browser';
import { import {
FullScreenModalComponent FullScreenModalComponent
@ -17,27 +15,13 @@ import {CommunityService} from "../../openaireLibrary/connect/community/communit
@Component({ @Component({
selector: 'manage-content-providers', selector: 'manage-content-providers',
template: ` template: `
<remove-content-providers (toggleView)="toggleAction()" [communityContentProviders]="communityContentProviders" <remove-content-providers #removeContentProvidersComponent (addContentProviders)="openAddContentProviders()" [communityContentProviders]="communityContentProviders"
[loading]="showLoadingInRemove" [community]="community" [loading]="showLoadingInRemove" [community]="community" [disableAdd]="add.loading"
(communityContentProvidersChanged)="communityContentProvidersChanged($event)" [toggle]="toggle"> (communityContentProvidersChanged)="communityContentProvidersChanged($event)">
</remove-content-providers> </remove-content-providers>
<fs-modal #fsModal (cancelEmitter)="toggleAction()"> <fs-modal #fsModal>
<div actions class="uk-flex uk-flex-middle uk-height-1-1"> <add-content-providers #add [communityContentProviders]="communityContentProviders" [community]="community"
<span class="uk-button uk-text-secondary" uk-icon="icon: info; ratio: 1.3"></span> (communityContentProvidersChanged)="communityContentProvidersChanged($event)"></add-content-providers>
<div *ngIf="community" uk-drop="mode: hover">
<div class="uk-card uk-card-body uk-card-default">
If you cannot find a content provider relevant to your community, probably it is not OpenAIRE compliant.
Feel free to contact us
(<a
[href]="'mailto:' + properties.feedbackmailForMissingEntities +'?Subject=[OpenAIRE Connect - '+ community.shortTitle + '] report missing Funder' + '&body=' + body"
target="_top">{{properties.feedbackmailForMissingEntities}}</a>)
to let us know and we'll try to get the provider on board!
</div>
</div>
</div>
<add-content-providers [communityContentProviders]="communityContentProviders"
(communityContentProvidersChanged)="communityContentProvidersChanged($event)"></add-content-providers>
</fs-modal> </fs-modal>
` `
}) })
@ -46,7 +30,6 @@ export class ManageContentProvidersComponent implements OnInit {
@Input() communityContentProviders = []; @Input() communityContentProviders = [];
@ViewChild(RemoveContentProvidersComponent) removeContentProvidersComponent: RemoveContentProvidersComponent; @ViewChild(RemoveContentProvidersComponent) removeContentProvidersComponent: RemoveContentProvidersComponent;
@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";
@ -67,9 +50,6 @@ export class ManageContentProvidersComponent implements OnInit {
this.body = StringUtils.URIEncode(this.body); this.body = StringUtils.URIEncode(this.body);
} }
})); }));
this.fullscreen.title = "Search and Add Content Providers";
this.fullscreen.okButtonText = "Done";
this.fullscreen.okButton = true;
} }
public ngOnDestroy() { public ngOnDestroy() {
@ -79,20 +59,20 @@ export class ManageContentProvidersComponent implements OnInit {
} }
}); });
} }
public toggleAction() { public openAddContentProviders() {
HelperFunctions.scroll(); this.fullscreen.title = "Search and Add Content Providers";
this.toggle = !this.toggle; this.fullscreen.okButtonText = "Done";
if (this.toggle) { this.fullscreen.back = true;
this.fullscreen.open(); this.fullscreen.okButton = true;
} this.fullscreen.open();
} }
public communityContentProvidersChanged($event) { public communityContentProvidersChanged($event) {
this.communityContentProviders = $event.value; this.communityContentProviders = $event.value;
this.showLoadingInRemove = false; this.showLoadingInRemove = false;
if (this.toggle) { if (this.fullscreen.isOpen) {
this.removeContentProvidersComponent.applyFilters(); this.removeContentProvidersComponent.applyFilters();
} }
} }

View File

@ -18,14 +18,14 @@
<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]="(toggle? 'cls: uk-invisible; ' : 'cls: uk-active; ') +
'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>'" '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" [class.uk-disabled]="loading"> [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 content provider</span>
</button> </button>
</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">
<div *ngIf="loading" class="uk-margin-large-top"> <div *ngIf="loading" class="uk-position-center">
<loading></loading> <loading></loading>
</div> </div>
<div *ngIf="!loading"> <div *ngIf="!loading">
@ -87,8 +87,8 @@
<div class="uk-padding-small uk-padding-remove-horizontal"> <div class="uk-padding-small uk-padding-remove-horizontal">
<a (click)="removeContentProvider(item)" <a (click)="removeContentProvider(item)"
class="uk-button uk-button-link uk-flex uk-flex-middle"> class="uk-button uk-button-link uk-flex uk-flex-middle">
<icon name="delete" [flex]="true"></icon> <icon name="remove" [flex]="true"></icon>
<span class="uk-margin-small-left">Delete</span> <span class="uk-margin-small-left">Remove</span>
</a> </a>
</div> </div>
</div> </div>

View File

@ -28,6 +28,7 @@ export class RemoveContentProvidersComponent implements OnInit {
public previewCommunityContentProviders = []; public previewCommunityContentProviders = [];
public errorCodes: ErrorCodes; public errorCodes: ErrorCodes;
@Input() public loading: boolean = true; @Input() public loading: boolean = true;
@Input() public disableAdd: boolean = false;
@Input() public community: CommunityInfo; @Input() public community: CommunityInfo;
@Input() public communityContentProviders = []; @Input() public communityContentProviders = [];
@Output() communityContentProvidersChanged = new EventEmitter(); @Output() communityContentProvidersChanged = new EventEmitter();
@ -47,7 +48,7 @@ export class RemoveContentProvidersComponent implements OnInit {
filterForm: FormGroup; filterForm: FormGroup;
private searchText: RegExp = new RegExp(''); private searchText: RegExp = new RegExp('');
public keyword: string = ''; public keyword: string = '';
@Output() toggleView: EventEmitter<any> = new EventEmitter(); @Output() addContentProviders: EventEmitter<void> = new EventEmitter();
@Input() public toggle: boolean = true; @Input() public toggle: boolean = true;
constructor(private route: ActivatedRoute, private _router: Router, constructor(private route: ActivatedRoute, private _router: Router,
@ -164,7 +165,7 @@ export class RemoveContentProvidersComponent implements OnInit {
} }
addNew() { addNew() {
this.toggleView.emit(null); this.addContentProviders.emit();
} }
public applyFilters() { public applyFilters() {

@ -1 +1 @@
Subproject commit 318b3cdf42922d8b04400bb010733b78fcf1fe1c Subproject commit 319eff1cc355ffc4148cf20c4ba23e15fbc6a6f6

@ -1 +1 @@
Subproject commit 25f7f7dd34fae80d1e2e25935c2f2772c5800e70 Subproject commit 35bca0f68bf19337413167ecf770f1027902964f