Add contente providers modal with new UI
This commit is contained in:
parent
4160f837c1
commit
9c75d63171
|
@ -83,11 +83,6 @@ export class AppComponent implements OnInit {
|
|||
}));
|
||||
this.subscriptions.push(this.layoutService.hasHeader.subscribe(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.subscriptions.push(this.layoutService.hasAdminMenu.subscribe(hasAdminMenu => {
|
||||
|
@ -121,11 +116,9 @@ export class AppComponent implements OnInit {
|
|||
this.loading = false;
|
||||
}
|
||||
} else {
|
||||
if(this.community) {
|
||||
this.communityService.setCommunity(null);
|
||||
this.community = null;
|
||||
this.buildMenu();
|
||||
}
|
||||
this.communityService.setCommunity(null);
|
||||
this.community = null;
|
||||
this.buildMenu();
|
||||
this.loading = false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit a738d3bb49d1af38f7eaf3ce34d519c76f075e4a
|
||||
Subproject commit de493c84923348f8289d4e507c04cfec80c30d69
|
|
@ -36,46 +36,46 @@
|
|||
[pageSize]="pageSize" [type]="'supporting organization' + (affiliations.length > 1?'s':'')">
|
||||
</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 *ngFor="let affiliation of currentPage; let i=index">
|
||||
<div class="uk-card uk-card-default">
|
||||
<div class="uk-card-body">
|
||||
<div class="uk-flex uk-flex-middle uk-flex-column">
|
||||
<div class="uk-flex uk-flex-center">
|
||||
<img class="uk-height-xsmall uk-blend-multiply" [src]="affiliation.logo_url | urlPrefix">
|
||||
</div>
|
||||
<h5>{{affiliation.name}}</h5>
|
||||
<div class="uk-text-truncate uk-text-small">
|
||||
<span class="uk-text-meta uk-margin-xsmall-right">URL:</span>
|
||||
<a [href]="affiliation.website_url | urlPrefix" class="uk-link"
|
||||
target="_blank">{{affiliation.website_url}}</a>
|
||||
</div>
|
||||
<div *ngFor="let affiliation of currentPage; let i=index">
|
||||
<div class="uk-card uk-card-default">
|
||||
<div class="uk-card-body">
|
||||
<div class="uk-flex uk-flex-middle uk-flex-column">
|
||||
<div class="uk-flex uk-flex-center">
|
||||
<img class="uk-height-xsmall uk-blend-multiply" [src]="affiliation.logo_url | urlPrefix">
|
||||
</div>
|
||||
<h5>{{affiliation.name}}</h5>
|
||||
<div class="uk-text-truncate uk-text-small">
|
||||
<span class="uk-text-meta uk-margin-xsmall-right">URL:</span>
|
||||
<a [href]="affiliation.website_url | urlPrefix" class="uk-link"
|
||||
target="_blank">{{affiliation.website_url}}</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="uk-card-footer uk-padding-remove-vertical">
|
||||
<div class="uk-grid uk-grid-small uk-flex-nowrap uk-grid-divider uk-flex-right" uk-grid>
|
||||
<div>
|
||||
<div class="uk-padding-small uk-padding-remove-horizontal">
|
||||
<a (click)="editAffiliationOpen(i)"
|
||||
class="uk-button uk-button-link uk-flex uk-flex-middle">
|
||||
<icon name="edit" [flex]="true"></icon>
|
||||
<span class="uk-margin-xsmall-left">Edit</span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="uk-card-footer uk-padding-remove-vertical">
|
||||
<div class="uk-grid uk-grid-small uk-flex-nowrap uk-grid-divider uk-flex-right" uk-grid>
|
||||
<div>
|
||||
<div class="uk-padding-small uk-padding-remove-horizontal">
|
||||
<a (click)="editAffiliationOpen(i)"
|
||||
class="uk-button uk-button-link uk-flex uk-flex-middle">
|
||||
<icon name="edit" [flex]="true"></icon>
|
||||
<span class="uk-margin-xsmall-left">Edit</span>
|
||||
</a>
|
||||
</div>
|
||||
<div>
|
||||
<div class="uk-padding-small uk-padding-remove-horizontal">
|
||||
<button class="uk-button uk-button-link uk-flex uk-flex-middle"
|
||||
(click)="deleteAffiliationOpen(i)">
|
||||
<icon name="delete" [flex]="true"></icon>
|
||||
<span class="uk-margin-xsmall-left">Delete</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<div class="uk-padding-small uk-padding-remove-horizontal">
|
||||
<button class="uk-button uk-button-link uk-flex uk-flex-middle"
|
||||
(click)="deleteAffiliationOpen(i)">
|
||||
<icon name="delete" [flex]="true"></icon>
|
||||
<span class="uk-margin-xsmall-left">Delete</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="uk-margin-small-top">
|
||||
<paging-no-load [currentPage]="page"
|
||||
[totalResults]="affiliations.length" [size]="pageSize"
|
||||
|
|
|
@ -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 #searchInputComponent search-input [control]="filterForm.controls.keyword" [showSearch]="false"
|
||||
placeholder="Search Content Providers"
|
||||
[selected]="openaireSearchUtils.keyword" (closeEmitter)="onSearchClose()" (resetEmitter)="resetInput()"
|
||||
[bordered]="true" colorClass="uk-text-secondary"
|
||||
class="uk-width-1-2@l uk-width-1-2@m uk-width-1-1"></div>
|
||||
</div>
|
||||
|
||||
<div id="manage-content-providers">
|
||||
<div *ngIf="openaireSearchUtils.status == errorCodes.LOADING" class="uk-position-large-top">
|
||||
<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 class="uk-section uk-flex uk-flex-center uk-flex uk-flex-middle">
|
||||
<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" uk-dropdown="mode: hover">
|
||||
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>
|
||||
<!-- <errorMessages [status]="[openaireSearchUtils.status]" [type]="'OpenAIRE content providers'"></errorMessages>-->
|
||||
|
||||
<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>
|
||||
|
||||
<ul class="uk-list search-results uk-margin-medium-top uk-margin-medium-bottom">
|
||||
<li *ngFor="let result of openaireContentProviders" class="uk-animation-fade">
|
||||
<div class="uk-card uk-card-default uk-card-hover uk-text-small uk-margin-bottom">
|
||||
<div class="uk-grid uk-grid-divider uk-padding-small" uk-grid>
|
||||
<div class="uk-width-expand@m uk-width-1-1">
|
||||
<div search-input class="uk-width-xlarge@l uk-width-large" [searchControl]="filterForm.get('keyword')" searchInputClass="outer"
|
||||
placeholder="Search Content Providers" [disabled]="loading"></div>
|
||||
</div>
|
||||
<div class="uk-section uk-section-small uk-position-relative">
|
||||
<div *ngIf="openaireSearchUtils.status == errorCodes.LOADING" class="uk-position-center">
|
||||
<loading></loading>
|
||||
</div>
|
||||
<div *ngIf="openaireSearchUtils.status !== errorCodes.LOADING">
|
||||
<div *ngIf="openaireSearchUtils.totalResults == 0"
|
||||
class="uk-card uk-card-default uk-padding-large uk-text-center uk-margin-bottom uk-text-bold">
|
||||
<div>No content providers found</div>
|
||||
</div>
|
||||
<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"
|
||||
[showSubjects]="true" [result]="getResultPreview(result)"
|
||||
[externalUrl]="contentProviderUrl">
|
||||
</result-preview>
|
||||
</div>
|
||||
<div class="uk-width-auto@m uk-width-1-1">
|
||||
<div class="uk-flex uk-flex-middle uk-flex-center uk-flex-column uk-height-1-1">
|
||||
<div class="uk-padding-small uk-padding-remove-horizontal">
|
||||
|
||||
<div [class.hide-element]="!getCommunityContentProvider(result)">
|
||||
<a (click)="removeContentProvider(result)" class="uk-button action uk-flex uk-flex-middle">
|
||||
<icon name="remove_circle_outline"></icon>
|
||||
<span class="uk-margin-small-left">Remove content provider</span>
|
||||
<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 *ngIf="!getCommunityContentProvider(result)">
|
||||
<div class="uk-padding-small uk-padding-remove-horizontal">
|
||||
<a (click)="addContentProvider(result)" 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>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div [class.hide-element]="getCommunityContentProvider(result)">
|
||||
<a (click)="addContentProvider(result)" class="uk-button action uk-flex uk-flex-middle"
|
||||
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>">
|
||||
<div class="uk-text-success">
|
||||
<icon name="add"></icon>
|
||||
</div>
|
||||
<span class="uk-margin-small-left">Add content provider</span>
|
||||
</div>
|
||||
<div *ngIf="getCommunityContentProvider(result)">
|
||||
<div class="uk-padding-small uk-padding-remove-horizontal">
|
||||
<a (click)="removeContentProvider(result)"
|
||||
class="uk-button uk-button-link uk-flex uk-flex-middle">
|
||||
<icon name="remove" [flex]="true"></icon>
|
||||
<span class="uk-margin-small-left">Remove</span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -62,17 +61,13 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<!-- <div [class]="openaireSearchUtils.page > pagingLimit ? 'search-results' : ''"-->
|
||||
<!-- *ngIf="(openaireSearchUtils.page >= pagingLimit) && (openaireSearchUtils.totalResults > resultsPerPage*pagingLimit)">-->
|
||||
<!-- <p class="uk-alert-warning" uk-alert>For more results please try a new, more specific query</p>-->
|
||||
<!-- </div>-->
|
||||
|
||||
<no-load-paging [type]="'Content Providers'"
|
||||
[page]="openaireSearchUtils.page" [pageSize]="resultsPerPage" (pageChange)="goTo($event.value)"
|
||||
[totalResults]="openaireSearchUtils.totalResults">
|
||||
</no-load-paging>
|
||||
</ng-container>
|
||||
</div>
|
||||
<div class="uk-margin-small-top">
|
||||
<paging-no-load [currentPage]="openaireSearchUtils.page"
|
||||
[totalResults]="openaireSearchUtils.totalResults" [size]="resultsPerPage"
|
||||
(pageChange)="goTo($event)" customClasses="uk-flex-right@m uk-flex-center">
|
||||
</paging-no-load>
|
||||
</div>
|
||||
</ng-container>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import {Component, OnInit, Input, Output, EventEmitter, ViewChild} from '@angular/core';
|
||||
import { ActivatedRoute, Router } from "@angular/router";
|
||||
import {SearchResult} from '../../openaireLibrary/utils/entities/searchResult';
|
||||
import {ActivatedRoute, Router} from "@angular/router";
|
||||
import {SearchResult} from '../../openaireLibrary/utils/entities/searchResult';
|
||||
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 {SearchDataprovidersService} from '../../openaireLibrary/services/searchDataproviders.service';
|
||||
import {RouterHelper} from '../../openaireLibrary/utils/routerHelper.class';
|
||||
|
@ -16,20 +16,17 @@ import {SearchInputComponent} from "../../openaireLibrary/sharedComponents/searc
|
|||
import {Subscriber} from "rxjs";
|
||||
import {debounceTime, distinctUntilChanged} from "rxjs/operators";
|
||||
import {ResultPreview} from "../../openaireLibrary/utils/result-preview/result-preview";
|
||||
|
||||
declare var UIkit;
|
||||
import {NotificationHandler} from "../../openaireLibrary/utils/notification-handler";
|
||||
import {CommunityInfo} from "../../openaireLibrary/connect/community/communityInfo";
|
||||
|
||||
@Component({
|
||||
selector: 'add-content-providers',
|
||||
templateUrl: './add-content-providers.component.html',
|
||||
selector: 'add-content-providers',
|
||||
templateUrl: './add-content-providers.component.html',
|
||||
})
|
||||
|
||||
export class AddContentProvidersComponent implements OnInit {
|
||||
private subscriptions: any[] = [];
|
||||
public subResults: any;
|
||||
|
||||
private community: string = '';
|
||||
|
||||
@Input() public community: CommunityInfo;
|
||||
public routerHelper: RouterHelper = new RouterHelper();
|
||||
public properties: EnvProperties = properties;
|
||||
public errorCodes: ErrorCodes;
|
||||
|
@ -38,46 +35,33 @@ export class AddContentProvidersComponent implements OnInit {
|
|||
@Input() communityContentProviders = [];
|
||||
public openaireContentProviders = [];
|
||||
public queryParameters: string = "";
|
||||
|
||||
// public pagingLimit: number = properties.pagingLimit;
|
||||
public resultsPerPage: number = properties.resultsPerPage;
|
||||
|
||||
filterForm: FormGroup;
|
||||
@ViewChild('searchInputComponent') searchInputComponent: SearchInputComponent;
|
||||
|
||||
private contentProviderUrl: string = "https://" + ((properties.environment == "beta" || properties.environment == "development") ? "beta." : "") + "explore.openaire.eu" + properties.searchLinkToDataProvider;
|
||||
public contentProviderUrl: string = "https://" + ((properties.environment == "beta" || properties.environment == "development") ? "beta." : "") + "explore.openaire.eu" + properties.searchLinkToDataProvider;
|
||||
public body: string = "Send from page";
|
||||
|
||||
|
||||
@Output() toggleView: EventEmitter<any> = new EventEmitter();
|
||||
|
||||
constructor(private route: ActivatedRoute, private _router: Router,
|
||||
private _searchContentProvidersService: SearchDataprovidersService,
|
||||
private _manageCommunityContentProvidersService: ManageCommunityContentProvidersService,
|
||||
private _fb: FormBuilder) {
|
||||
|
||||
constructor(private route: ActivatedRoute, private router: Router,
|
||||
private searchDataprovidersService: SearchDataprovidersService,
|
||||
private manageCommunityContentProvidersService: ManageCommunityContentProvidersService,
|
||||
private fb: FormBuilder) {
|
||||
this.errorCodes = new ErrorCodes();
|
||||
this.openaireSearchUtils.status = this.errorCodes.LOADING;
|
||||
}
|
||||
|
||||
|
||||
ngOnInit() {
|
||||
this.subscriptions.push(this.route.params.subscribe(params => {
|
||||
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.body = "[Please write your message here]";
|
||||
this.body = StringUtils.URIEncode(this.body);
|
||||
}));
|
||||
|
||||
this.openaireSearchUtils.keyword = "";
|
||||
|
||||
this.filterForm = this._fb.group({
|
||||
this.filterForm = this.fb.group({
|
||||
keyword: [''],
|
||||
});
|
||||
|
||||
this.subscriptions.push(this.filterForm.get('keyword').valueChanges
|
||||
.pipe(debounceTime(1000), distinctUntilChanged())
|
||||
.subscribe(value => {
|
||||
|
@ -85,81 +69,57 @@ export class AddContentProvidersComponent implements OnInit {
|
|||
})
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
public ngOnDestroy() {
|
||||
this.subscriptions.forEach(sub => {
|
||||
if (sub instanceof Subscriber) {
|
||||
sub.unsubscribe();
|
||||
}
|
||||
});
|
||||
|
||||
if(this.subResults){
|
||||
|
||||
if (this.subResults) {
|
||||
this.subResults.unsubscribe();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
get loading() {
|
||||
return this.openaireSearchUtils.status == this.errorCodes.LOADING
|
||||
}
|
||||
|
||||
public addContentProvider(contenProvider: SearchResult) {
|
||||
if (!Session.isLoggedIn()) {
|
||||
this._router.navigate(['/user-info'], {
|
||||
queryParams: {
|
||||
"errorCode": LoginErrorCodes.NOT_VALID,
|
||||
"redirectUrl": this._router.url
|
||||
}
|
||||
});
|
||||
} else {
|
||||
this.subscriptions.push(this._manageCommunityContentProvidersService.addContentProvider(this.properties, this.community, contenProvider).subscribe(
|
||||
data => {
|
||||
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);
|
||||
}
|
||||
));
|
||||
}
|
||||
this.subscriptions.push(this.manageCommunityContentProvidersService.addContentProvider(this.properties, this.community.communityId, contenProvider).subscribe(
|
||||
data => {
|
||||
this.communityContentProviders.push(data);
|
||||
NotificationHandler.rise('Content Provider successfully added!')
|
||||
this.communityContentProvidersChanged.emit({
|
||||
value: this.communityContentProviders,
|
||||
});
|
||||
},
|
||||
error => {
|
||||
this.handleError('An error has been occurred. Try again later!', error);
|
||||
}
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
public removeContentProvider(contentProvider) {
|
||||
if (!Session.isLoggedIn()) {
|
||||
this._router.navigate(['/user-info'], {
|
||||
queryParams: {
|
||||
"errorCode": LoginErrorCodes.NOT_VALID,
|
||||
"redirectUrl": this._router.url
|
||||
}
|
||||
});
|
||||
} else {
|
||||
let communityContentProvider = this.getCommunityContentProvider(contentProvider);
|
||||
let contentProviderId: string = communityContentProvider['id'];
|
||||
this.subscriptions.push(this._manageCommunityContentProvidersService.removeContentProvider(this.properties, this.community, contentProviderId).subscribe(
|
||||
data => {
|
||||
let index = this.communityContentProviders.indexOf(communityContentProvider);
|
||||
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);
|
||||
}
|
||||
));
|
||||
}
|
||||
let communityContentProvider = this.getCommunityContentProvider(contentProvider);
|
||||
let contentProviderId: string = communityContentProvider['id'];
|
||||
this.subscriptions.push(this.manageCommunityContentProvidersService.removeContentProvider(this.properties, this.community.communityId, contentProviderId).subscribe(
|
||||
data => {
|
||||
let index = this.communityContentProviders.indexOf(communityContentProvider);
|
||||
this.communityContentProviders.splice(index, 1);
|
||||
NotificationHandler.rise('Content Provider successfully removed!')
|
||||
this.communityContentProvidersChanged.emit({
|
||||
value: this.communityContentProviders,
|
||||
});
|
||||
},
|
||||
error => {
|
||||
this.handleError('An error has been occurred. Try again later!', error);
|
||||
}
|
||||
));
|
||||
}
|
||||
|
||||
public getCommunityContentProvider(contentProvider: any): string {
|
||||
|
||||
public getCommunityContentProvider(contentProvider: any): any {
|
||||
let index: number = 0;
|
||||
for (let communityContentProvider of this.communityContentProviders) {
|
||||
if (communityContentProvider.openaireId == contentProvider.id) {
|
||||
|
@ -167,133 +127,69 @@ export class AddContentProvidersComponent implements OnInit {
|
|||
}
|
||||
index++;
|
||||
}
|
||||
return "";
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public getResultPreview(result: SearchResult): ResultPreview {
|
||||
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) {
|
||||
if (!Session.isLoggedIn()) {
|
||||
this._router.navigate(['/user-info'], {
|
||||
queryParams: {
|
||||
"errorCode": LoginErrorCodes.NOT_VALID,
|
||||
"redirectUrl": this._router.url
|
||||
}
|
||||
});
|
||||
} else {
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
);
|
||||
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.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) {
|
||||
this.openaireSearchUtils.keyword = keyword;
|
||||
this.buildQueryParameters();
|
||||
this.goTo(1);
|
||||
}
|
||||
|
||||
|
||||
buildQueryParameters() {
|
||||
this.queryParameters = "";
|
||||
|
||||
if (this.openaireSearchUtils.keyword) {
|
||||
this.queryParameters = "q=" + StringUtils.URIEncode(this.openaireSearchUtils.keyword);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
goTo(page: number = 1) {
|
||||
this.openaireSearchUtils.page = page;
|
||||
this.openaireSearchUtils.status = this.errorCodes.LOADING;
|
||||
this._getOpenaireContentProviders(this.queryParameters, page, this.resultsPerPage);
|
||||
}
|
||||
|
||||
back() {
|
||||
this.toggleView.emit(null);
|
||||
}
|
||||
|
||||
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'
|
||||
});
|
||||
|
||||
handleError(message: string, error = null) {
|
||||
console.error(error);
|
||||
NotificationHandler.rise(message, 'danger');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
import {Component, ElementRef, Input, OnInit, ViewChild} from '@angular/core';
|
||||
import {Router} from "@angular/router";
|
||||
|
||||
import {RemoveContentProvidersComponent} from './remove-content-providers.component';
|
||||
import {HelperFunctions} from "../../openaireLibrary/utils/HelperFunctions.class";
|
||||
import {Title} from '@angular/platform-browser';
|
||||
import {
|
||||
FullScreenModalComponent
|
||||
|
@ -17,27 +15,13 @@ import {CommunityService} from "../../openaireLibrary/connect/community/communit
|
|||
@Component({
|
||||
selector: 'manage-content-providers',
|
||||
template: `
|
||||
<remove-content-providers (toggleView)="toggleAction()" [communityContentProviders]="communityContentProviders"
|
||||
[loading]="showLoadingInRemove" [community]="community"
|
||||
(communityContentProvidersChanged)="communityContentProvidersChanged($event)" [toggle]="toggle">
|
||||
<remove-content-providers #removeContentProvidersComponent (addContentProviders)="openAddContentProviders()" [communityContentProviders]="communityContentProviders"
|
||||
[loading]="showLoadingInRemove" [community]="community" [disableAdd]="add.loading"
|
||||
(communityContentProvidersChanged)="communityContentProvidersChanged($event)">
|
||||
</remove-content-providers>
|
||||
<fs-modal #fsModal (cancelEmitter)="toggleAction()">
|
||||
<div actions class="uk-flex uk-flex-middle uk-height-1-1">
|
||||
<span class="uk-button uk-text-secondary" uk-icon="icon: info; ratio: 1.3"></span>
|
||||
<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 #fsModal>
|
||||
<add-content-providers #add [communityContentProviders]="communityContentProviders" [community]="community"
|
||||
(communityContentProvidersChanged)="communityContentProvidersChanged($event)"></add-content-providers>
|
||||
</fs-modal>
|
||||
`
|
||||
})
|
||||
|
@ -46,7 +30,6 @@ export class ManageContentProvidersComponent implements OnInit {
|
|||
@Input() communityContentProviders = [];
|
||||
@ViewChild(RemoveContentProvidersComponent) removeContentProvidersComponent: RemoveContentProvidersComponent;
|
||||
@ViewChild('fsModal', { static: true }) fullscreen: FullScreenModalComponent;
|
||||
public toggle: boolean = false;
|
||||
private subscriptions: any[] = [];
|
||||
public showLoadingInRemove: boolean = true;
|
||||
public body: string = "Send from page";
|
||||
|
@ -67,9 +50,6 @@ export class ManageContentProvidersComponent implements OnInit {
|
|||
this.body = StringUtils.URIEncode(this.body);
|
||||
}
|
||||
}));
|
||||
this.fullscreen.title = "Search and Add Content Providers";
|
||||
this.fullscreen.okButtonText = "Done";
|
||||
this.fullscreen.okButton = true;
|
||||
}
|
||||
|
||||
public ngOnDestroy() {
|
||||
|
@ -79,20 +59,20 @@ export class ManageContentProvidersComponent implements OnInit {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
public toggleAction() {
|
||||
HelperFunctions.scroll();
|
||||
this.toggle = !this.toggle;
|
||||
if (this.toggle) {
|
||||
this.fullscreen.open();
|
||||
}
|
||||
|
||||
public openAddContentProviders() {
|
||||
this.fullscreen.title = "Search and Add Content Providers";
|
||||
this.fullscreen.okButtonText = "Done";
|
||||
this.fullscreen.back = true;
|
||||
this.fullscreen.okButton = true;
|
||||
this.fullscreen.open();
|
||||
}
|
||||
|
||||
public communityContentProvidersChanged($event) {
|
||||
this.communityContentProviders = $event.value;
|
||||
this.showLoadingInRemove = false;
|
||||
|
||||
if (this.toggle) {
|
||||
if (this.fullscreen.isOpen) {
|
||||
this.removeContentProvidersComponent.applyFilters();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,14 +18,14 @@
|
|||
<button class="uk-button uk-button-default uk-flex uk-flex-middle" (click)="addNew()"
|
||||
[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>'"
|
||||
[disabled]="loading" [class.uk-disabled]="loading">
|
||||
[disabled]="loading || disableAdd" [class.uk-disabled]="loading || disableAdd">
|
||||
<icon name="add" [flex]="true"></icon>
|
||||
<span class="uk-margin-small-left uk-text-bold uk-text-uppercase">New content provider</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<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>
|
||||
</div>
|
||||
<div *ngIf="!loading">
|
||||
|
@ -87,8 +87,8 @@
|
|||
<div class="uk-padding-small uk-padding-remove-horizontal">
|
||||
<a (click)="removeContentProvider(item)"
|
||||
class="uk-button uk-button-link uk-flex uk-flex-middle">
|
||||
<icon name="delete" [flex]="true"></icon>
|
||||
<span class="uk-margin-small-left">Delete</span>
|
||||
<icon name="remove" [flex]="true"></icon>
|
||||
<span class="uk-margin-small-left">Remove</span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -28,6 +28,7 @@ export class RemoveContentProvidersComponent implements OnInit {
|
|||
public previewCommunityContentProviders = [];
|
||||
public errorCodes: ErrorCodes;
|
||||
@Input() public loading: boolean = true;
|
||||
@Input() public disableAdd: boolean = false;
|
||||
@Input() public community: CommunityInfo;
|
||||
@Input() public communityContentProviders = [];
|
||||
@Output() communityContentProvidersChanged = new EventEmitter();
|
||||
|
@ -47,7 +48,7 @@ export class RemoveContentProvidersComponent implements OnInit {
|
|||
filterForm: FormGroup;
|
||||
private searchText: RegExp = new RegExp('');
|
||||
public keyword: string = '';
|
||||
@Output() toggleView: EventEmitter<any> = new EventEmitter();
|
||||
@Output() addContentProviders: EventEmitter<void> = new EventEmitter();
|
||||
@Input() public toggle: boolean = true;
|
||||
|
||||
constructor(private route: ActivatedRoute, private _router: Router,
|
||||
|
@ -164,7 +165,7 @@ export class RemoveContentProvidersComponent implements OnInit {
|
|||
}
|
||||
|
||||
addNew() {
|
||||
this.toggleView.emit(null);
|
||||
this.addContentProviders.emit();
|
||||
}
|
||||
|
||||
public applyFilters() {
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 318b3cdf42922d8b04400bb010733b78fcf1fe1c
|
||||
Subproject commit 319eff1cc355ffc4148cf20c4ba23e15fbc6a6f6
|
|
@ -1 +1 @@
|
|||
Subproject commit 25f7f7dd34fae80d1e2e25935c2f2772c5800e70
|
||||
Subproject commit 35bca0f68bf19337413167ecf770f1027902964f
|
Loading…
Reference in New Issue