diff --git a/src/app/pages/community-info/profile/edit-community/edit-community.component.ts b/src/app/pages/community-info/profile/edit-community/edit-community.component.ts
index 5d580e9..86a5e6a 100644
--- a/src/app/pages/community-info/profile/edit-community/edit-community.component.ts
+++ b/src/app/pages/community-info/profile/edit-community/edit-community.component.ts
@@ -189,7 +189,6 @@ export class EditCommunityComponent {
public save(callback: Function, errorCallback: Function = null) {
if (this.file) {
- this.communityFb.get('shortName').enable();
this.subscriptions.push(this.utilsService.uploadPhoto(this.properties.utilsService + "/upload/community/" + encodeURIComponent(this.community.communityId), this.file).subscribe(res => {
this.deletePhoto();
this.communityFb.get('logoUrl').setValue(res.filename);
@@ -211,7 +210,7 @@ export class EditCommunityComponent {
if (this.isNew) {
this.removePhoto();
this.subscriptions.push(this.communityService.updateCommunity(
- this.properties.communityAPI + this.community.communityId, this.communityFb.value).subscribe(() => {
+ this.properties.communityAPI + this.community.communityId, this.communityFb.getRawValue()).subscribe(() => {
this.communityService.getCommunity(this.community.communityId, true).subscribe(community => {
UIkit.notification(community.shortTitle + ' has been
successfully created ', {
status: 'success',
@@ -231,7 +230,7 @@ export class EditCommunityComponent {
}
}));
} else {
- this.subscriptions.push(this.communityService.updateCommunity(this.properties.communityAPI + this.community.communityId, this.communityFb.value).subscribe(() => {
+ this.subscriptions.push(this.communityService.updateCommunity(this.properties.communityAPI + this.community.communityId, this.communityFb.getRawValue()).subscribe(() => {
this.communityService.getCommunity(this.community.communityId, true).subscribe(community => {
UIkit.notification(community.shortTitle + ' has been
successfully saved ', {
status: 'success',
diff --git a/src/app/pages/community-routing.module.ts b/src/app/pages/community-routing.module.ts
index 23867e9..db7d597 100644
--- a/src/app/pages/community-routing.module.ts
+++ b/src/app/pages/community-routing.module.ts
@@ -31,7 +31,11 @@ import {ConnectRIGuard} from "../openaireLibrary/connect/communityGuard/connectR
{
path: 'customize-layout',
loadChildren: () => import('./customization/customization.module').then(m => m.CustomizationModule),
- }
+ },
+ {
+ path: 'user-info',
+ loadChildren: () => import('../login/libUser.module').then(m => m.LibUserModule),
+ },
])]
})
export class CommunityRoutingModule {}
diff --git a/src/app/pages/content-providers/add-content-providers.component.html b/src/app/pages/content-providers/add-content-providers.component.html
index e9bf995..39af79e 100644
--- a/src/app/pages/content-providers/add-content-providers.component.html
+++ b/src/app/pages/content-providers/add-content-providers.component.html
@@ -1,60 +1,59 @@
-
-
-
-
-
-
-
-
-
No OpenAIRE content providers available
-
An Error Occurred. No OpenAIRE content providers found
-
Service temporarily unavailable. Please try again later.
-
No OpenAIRE content providers found
+
+
+
+
+ If you cannot find a content provider relevant to your community, probably it is not OpenAIRE compliant.
+ Feel free to contact us
+ (
{{properties.feedbackmailForMissingEntities}} )
+ to let us know and we'll try to get the provider on board!
-
-
-
0">
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
No content providers found
+
+
0">
+
+
+
+
+
+
-
-
diff --git a/src/app/pages/content-providers/add-content-providers.component.ts b/src/app/pages/content-providers/add-content-providers.component.ts
index eb4ffe9..7220ba5 100644
--- a/src/app/pages/content-providers/add-content-providers.component.ts
+++ b/src/app/pages/content-providers/add-content-providers.component.ts
@@ -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
= 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');
}
}
diff --git a/src/app/pages/content-providers/communityContentProviders.module.ts b/src/app/pages/content-providers/communityContentProviders.module.ts
index 60bb644..3947c2f 100644
--- a/src/app/pages/content-providers/communityContentProviders.module.ts
+++ b/src/app/pages/content-providers/communityContentProviders.module.ts
@@ -17,7 +17,7 @@ import {NoLoadPaging} from "../../openaireLibrary/searchPages/searchUtils/no-loa
import {LoadingModule} from "../../openaireLibrary/utils/loading/loading.module";
import {IconsModule} from "../../openaireLibrary/utils/icons/icons.module";
import {IconsService} from "../../openaireLibrary/utils/icons/icons.service";
-import {add, arrow_left, close, edit, remove_circle_outline} from "../../openaireLibrary/utils/icons/icons";
+import {add, arrow_left, close, edit, filters, remove_circle_outline} from "../../openaireLibrary/utils/icons/icons";
import {FullScreenModalModule} from "../../openaireLibrary/utils/modal/full-screen-modal/full-screen-modal.module";
import {ResultPreviewModule} from "../../openaireLibrary/utils/result-preview/result-preview.module";
import {SearchDataprovidersServiceModule} from "../../openaireLibrary/connect/contentProviders/searchDataprovidersService.module";
@@ -63,6 +63,6 @@ import {SearchDataprovidersService} from "../../openaireLibrary/services/searchD
export class CommunityContentProvidersModule {
constructor(private iconsService: IconsService) {
- this.iconsService.registerIcons([remove_circle_outline, add, edit, close, arrow_left]);
+ this.iconsService.registerIcons([filters]);
}
}
diff --git a/src/app/pages/content-providers/manage-content-providers.component.ts b/src/app/pages/content-providers/manage-content-providers.component.ts
index d96550d..3f15e5e 100644
--- a/src/app/pages/content-providers/manage-content-providers.component.ts
+++ b/src/app/pages/content-providers/manage-content-providers.component.ts
@@ -1,42 +1,27 @@
import {Component, ElementRef, Input, OnInit, ViewChild} from '@angular/core';
-import {ActivatedRoute, Router} from "@angular/router";
-
+import {Router} from "@angular/router";
import {RemoveContentProvidersComponent} from './remove-content-providers.component';
-
-import {Session} from '../../openaireLibrary/login/utils/helper.class';
-import {LoginErrorCodes} from '../../openaireLibrary/login/utils/guardHelper.class';
-import {HelperFunctions} from "../../openaireLibrary/utils/HelperFunctions.class";
import {Title} from '@angular/platform-browser';
-import {FullScreenModalComponent} from "../../openaireLibrary/utils/modal/full-screen-modal/full-screen-modal.component";
+import {
+ FullScreenModalComponent
+} from "../../openaireLibrary/utils/modal/full-screen-modal/full-screen-modal.component";
import {StringUtils} from "../../openaireLibrary/utils/string-utils.class";
import {EnvProperties} from "../../openaireLibrary/utils/properties/env-properties";
import {properties} from "../../../environments/environment";
import {Subscriber} from "rxjs";
+import {CommunityInfo} from "../../openaireLibrary/connect/community/communityInfo";
+import {CommunityService} from "../../openaireLibrary/connect/community/community.service";
@Component({
selector: 'manage-content-providers',
template: `
-
+
-
-
-
-
-
- If you cannot find a content provider relevant to your community, probably it is not OpenAIRE compliant.
- Feel free to contact us
- (
{{properties.feedbackmailForMissingEntities}} )
- to let us know and we'll try to get the provider on board!
-
-
-
-
-
+
+
`
})
@@ -45,36 +30,26 @@ 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";
public properties: EnvProperties = properties;
- public communityId: string = "";
+ public community: CommunityInfo;
constructor(private element: ElementRef,
private title: Title,
- private route: ActivatedRoute, private _router: Router) {
+ private communityService: CommunityService, private _router: Router) {
}
ngOnInit() {
- this.subscriptions.push(this.route.params.subscribe(params => {
- this.communityId = params['community'];
-
- if (this.communityId) {
- this.title.setTitle(this.communityId.toUpperCase() + ' | Content Providers');
+ this.subscriptions.push(this.communityService.getCommunityAsObservable().subscribe(community => {
+ this.community = community;
+ if (this.community) {
+ this.title.setTitle(this.community.shortTitle.toUpperCase() + ' | Content Providers');
this.body = "[Please write your message here]";
this.body = StringUtils.URIEncode(this.body);
}
}));
-
- this.fullscreen.title = "Search and Add Content Providers";
- this.fullscreen.okButtonText = "Done";
- this.fullscreen.okButton = true;
}
public ngOnDestroy() {
@@ -84,27 +59,20 @@ export class ManageContentProvidersComponent implements OnInit {
}
});
}
-
- public toggleAction() {
- if (!Session.isLoggedIn()) {
- this._router.navigate(['/user-info'], {
- queryParams: {'errorCode': LoginErrorCodes.NOT_VALID, 'redirectUrl': this._router.url}
- });
- } else {
- HelperFunctions.scroll();
-
- this.toggle = !this.toggle;
- if (this.toggle) {
- this.fullscreen.open();
- }
- }
+
+ 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();
}
}
diff --git a/src/app/pages/content-providers/remove-content-providers.component.html b/src/app/pages/content-providers/remove-content-providers.component.html
index 7fad95a..66a80a8 100644
--- a/src/app/pages/content-providers/remove-content-providers.component.html
+++ b/src/app/pages/content-providers/remove-content-providers.component.html
@@ -1,150 +1,111 @@
-
+
-
-
-
'">
-
-
-
-
Add new content provider
-
-
+
+
+
Admin Dashboard - Manage Content Providers
+
+
{{community.shortTitle}}
-
+
-
-
-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
0" [type]="'content providers'"
- (pageChange)="updatePage($event)"
- [page]="page" [pageSize]="resultsPerPage"
- [totalResults]="previewCommunityContentProviders.length">
-
-
-
-
No content providers for {{name}}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ Search and add more Content Providers
The research results collected from the content providers specified here will be automatically linked to your community dashboard.
'"
+ [disabled]="loading || disableAdd" [class.uk-disabled]="loading || disableAdd">
+
+
New content provider
+
+
+
+
+
+
+
+
+
+
No content providers found
+
+
0">
+
+
+
+
+
-
0" [type]="'content providers'"
- (pageChange)="updatePage($event)"
- [page]="page" [pageSize]="resultsPerPage"
- [totalResults]="previewCommunityContentProviders.length">
-
-
+
diff --git a/src/app/pages/content-providers/remove-content-providers.component.ts b/src/app/pages/content-providers/remove-content-providers.component.ts
index 5a417c3..0e832ae 100644
--- a/src/app/pages/content-providers/remove-content-providers.component.ts
+++ b/src/app/pages/content-providers/remove-content-providers.component.ts
@@ -3,43 +3,40 @@ import {ActivatedRoute, Router} from "@angular/router";
import {Subscriber} from 'rxjs';
import {ErrorCodes} from '../../openaireLibrary/utils/properties/errorCodes';
-import {SearchUtilsClass} from '../../openaireLibrary/searchPages/searchUtils/searchUtils.class';
import {EnvProperties} from '../../openaireLibrary/utils/properties/env-properties';
import {ManageCommunityContentProvidersService} from '../../services/manageContentProviders.service';
-import {SearchCommunityDataprovidersService} from '../../openaireLibrary/connect/contentProviders/searchDataproviders.service';
+import {
+ SearchCommunityDataprovidersService
+} from '../../openaireLibrary/connect/contentProviders/searchDataproviders.service';
import {RouterHelper} from '../../openaireLibrary/utils/routerHelper.class';
-
-import {Session} from '../../openaireLibrary/login/utils/helper.class';
-import {LoginErrorCodes} from '../../openaireLibrary/login/utils/guardHelper.class';
-import {Criteria, SelectionCriteria} from '../../openaireLibrary/utils/entities/contentProvider';
+import {Criteria} from '../../openaireLibrary/utils/entities/contentProvider';
import {properties} from "../../../environments/environment";
import {SearchInputComponent} from "../../openaireLibrary/sharedComponents/search-input/search-input.component";
import {FormBuilder, FormGroup} from "@angular/forms";
-import {Option} from "../../openaireLibrary/sharedComponents/input/input.component";
-import {CommunityService} from "../../openaireLibrary/connect/community/community.service";
import {CriteriaUtils} from "./criteria-utils";
-
-declare var UIkit;
+import {CommunityInfo} from "../../openaireLibrary/connect/community/communityInfo";
+import {NotificationHandler} from "../../openaireLibrary/utils/notification-handler";
+import {AlertModal} from "../../openaireLibrary/utils/modal/alert";
@Component({
selector: 'remove-content-providers',
templateUrl: './remove-content-providers.component.html'
})
export class RemoveContentProvidersComponent implements OnInit {
- public portal: string;
- public name: string;
public routerHelper: RouterHelper = new RouterHelper();
public contentProviderUrl = "https://" + ((properties.environment == "beta" || properties.environment == "development") ? "beta." : "") + "explore.openaire.eu" + properties.searchLinkToDataProvider;
public previewCommunityContentProviders = [];
- public communitySearchUtils: SearchUtilsClass = new SearchUtilsClass();
public errorCodes: ErrorCodes;
- @Input() public showLoading: boolean = true;
+ @Input() public loading: boolean = true;
+ @Input() public disableAdd: boolean = false;
+ @Input() public community: CommunityInfo;
@Input() public communityContentProviders = [];
@Output() communityContentProvidersChanged = new EventEmitter();
private properties: EnvProperties = properties;
private subscriptions: any[] = [];
private selectedCommunityContentProvider: any;
- @ViewChild('AlertModalDeleteCommunity') alertModalDeleteCommunity;
+ public stickyPageHeader: boolean = false;
+ @ViewChild('deleteModal') deleteModal: AlertModal;
/** Criteria */
private fields = CriteriaUtils.fields;
private verbs = CriteriaUtils.verbs;
@@ -51,55 +48,30 @@ export class RemoveContentProvidersComponent implements OnInit {
filterForm: FormGroup;
private searchText: RegExp = new RegExp('');
public keyword: string = '';
- sortOptions: Option[] = [
- {label: "Name ", value: {sort: "name", descending: false}},
- {label: "Official Name ", value: {sort: "officialname", descending: false}}
- ];
-
- @Output() toggleView: EventEmitter
= new EventEmitter();
+ @Output() addContentProviders: EventEmitter = new EventEmitter();
@Input() public toggle: boolean = true;
-
+
constructor(private route: ActivatedRoute, private _router: Router,
- private _fb: FormBuilder, private communityService: CommunityService,
+ private _fb: FormBuilder,
private _manageCommunityContentProvidersService: ManageCommunityContentProvidersService,
private _searchCommunityContentProvidersService: SearchCommunityDataprovidersService) {
- this.errorCodes = new ErrorCodes();
- this.communitySearchUtils.status = this.errorCodes.LOADING;
}
-
+
ngOnInit() {
- this.communitySearchUtils.keyword = "";
-
this.filterForm = this._fb.group({
keyword: [''],
- // sort: this._fb.control(this.sortOptions[0].value)
});
-
this.subscriptions.push(this.filterForm.get('keyword').valueChanges.subscribe(value => {
this.searchText = new RegExp(value, 'i');
this.page = 1;
this.applyFilters();
}));
-
- // this.subscriptions.push(this.filterForm.get('sort').valueChanges.subscribe(value => {
- // this.page = 1;
- // this.sort();
- // }));
-
- this.subscriptions.push(this.communityService.getCommunityAsObservable().subscribe(community => {
- if (community) {
- this.portal = community.communityId;
- this.name = community.shortTitle;
- this.contentProviderUrl = "https://"
- + ((this.properties.environment == "beta" || this.properties.environment == "development") ? "beta." : "")
- + this.portal + ".openaire.eu" + this.properties.searchLinkToDataProvider;
-
- this.keyword = '';
- this._getCommunityContentProviders();
- }
- }));
+ this.contentProviderUrl = "https://"
+ + ((this.properties.environment == "beta" || this.properties.environment == "development") ? "beta." : "")
+ + this.community.communityId + ".openaire.eu" + this.properties.searchLinkToDataProvider;
+ this.getCommunityContentProviders();
}
-
+
public ngOnDestroy() {
this.subscriptions.forEach(sub => {
if (sub instanceof Subscriber) {
@@ -107,273 +79,117 @@ export class RemoveContentProvidersComponent implements OnInit {
}
});
}
-
- public getCriteriaLabel(selectionCriteria: SelectionCriteria): string {
- if (selectionCriteria && selectionCriteria.criteria.length > 0) {
- return (selectionCriteria.criteria.length === 1) ? '1 criterion' : (selectionCriteria.criteria.length + ' criteria')
- } else {
- return 'no criteria';
- }
- }
-
- // filterData(row: any, query: string) {
- // let returnValue: boolean = false;
- //
- // if(query) {
- // for(var i=0; i <2; i++){
- // var r= this.filterQuery(row[i], query);
- // if(r) {
- // returnValue = true;
- // break;
- // }
- // }
- //
- // if(!returnValue) {
- // return false;
- // }
- // }
- //
- // return true;
- // }
- //
- // filterQuery(data, query){
- // if(data.toLowerCase().indexOf(query.toLowerCase()) > -1){
- // return true;
- // }else{
- // return false;
- // }
- // }
-
- public inCommunity(result: any): any {
- let found = false;
- for (let contentProvider of this.communityContentProviders) {
- if (contentProvider.opeaireId == result.id) {
- return true;
- }
- }
- return found;
-
- }
-
- totalPages(): number {
- let totalPages: any = this.communitySearchUtils.totalResults / (this.resultsPerPage);
- if (!(Number.isInteger(totalPages))) {
- totalPages = (parseInt(totalPages, 10) + 1);
- }
- return totalPages;
- }
getFiltersAsText(criteria: Criteria[]): string {
- let text = criteria.slice(0,3).map((criterion, index) => (index + 1) + ". " + criterion.constraint.map(constraint => {
+ let text = criteria.slice(0, 3).map((criterion, index) => (index + 1) + ". " + criterion.constraint.map(constraint => {
let field = this.fields.find(field => field.value === constraint.field).label;
let matchCase = false;
- if(!constraint.verb.includes('_caseinsensitive')) {
+ if (!constraint.verb.includes('_caseinsensitive')) {
matchCase = true;
}
let verb = this.verbs.find(verb => verb.value === constraint.verb.replace("_caseinsensitive", "")).label;
- let value = '"' + constraint.value + '"' + (matchCase?" (Match case)":"");
+ let value = '"' + constraint.value + '"' + (matchCase ? " (Match case)" : "");
return field + " " + verb + " " + value;
}).join(" and "));
return text.join(" ");
}
-
- // goTo(page:number = 1){
- // this.communitySearchUtils.page=page;
- //
- // var table = $('#dpTable').DataTable();
- // table.page( page - 1 ).draw( false );
- //
- // var info = table.page.info();
- // this.communitySearchUtils.totalResults = info.recordsDisplay;
- // }
-
- public confirmedDeleteContentProvider(data: any) {
- if (!Session.isLoggedIn()) {
- this._router.navigate(['/user-info'], {
- queryParams: {
- "errorCode": LoginErrorCodes.NOT_VALID,
- "redirectUrl": this._router.url
- }
- });
- } else {
- this.subscriptions.push(this._manageCommunityContentProvidersService.removeContentProvider(this.properties, this.portal, this.selectedCommunityContentProvider.id).subscribe(
- data => {
- let index = this.communityContentProviders.indexOf(this.selectedCommunityContentProvider);
- this.communityContentProviders.splice(index, 1);
-
- this.applyFilters();
-
- UIkit.notification('Content Provider successfully removed!', {
- status: 'success',
- timeout: 6000,
- pos: 'bottom-right'
- });
-
- this.communityContentProvidersChanged.emit({
- value: this.communityContentProviders,
- });
-
- this.communitySearchUtils.totalResults--;
- this.communitySearchUtils.page = 1;
- },
- err => {
- this.handleError('An error has been occurred. Try again later!');
- console.error(err);
- }
- ));
- }
+
+ public confirmedDeleteContentProvider() {
+ this.subscriptions.push(this._manageCommunityContentProvidersService.removeContentProvider(this.properties, this.community.communityId, this.selectedCommunityContentProvider.id).subscribe(
+ () => {
+ let index = this.communityContentProviders.indexOf(this.selectedCommunityContentProvider);
+ this.communityContentProviders.splice(index, 1);
+ this.applyFilters();
+ this.handleSuccess('Content Provider successfully removed!')
+ this.communityContentProvidersChanged.emit({
+ value: this.communityContentProviders,
+ });
+ },
+ err => {
+ this.handleError('An error has been occurred. Try again later!');
+ console.error(err);
+ }
+ ));
}
-
+
public removeContentProvider(communityContentProvider: any) {
- if (!Session.isLoggedIn()) {
- this._router.navigate(['/user-info'], {
- queryParams: {
- "errorCode": LoginErrorCodes.NOT_VALID,
- "redirectUrl": this._router.url
- }
- });
- } else {
- this.selectedCommunityContentProvider = communityContentProvider;
- this.alertModalDeleteCommunity.cancelButton = true;
- this.alertModalDeleteCommunity.okButton = true;
- this.alertModalDeleteCommunity.alertTitle = "Remove content provider?";
- let title = "";
- if (communityContentProvider.name) {
- title = communityContentProvider.name;
- }
- if (communityContentProvider.name && communityContentProvider.acronym) {
- title += " (";
- }
- if (communityContentProvider.acronym) {
- title += communityContentProvider.acronym;
- }
- if (communityContentProvider.name && communityContentProvider.acronym) {
- title += ")";
- }
- this.alertModalDeleteCommunity.message = "Content Provider";
- if (title) {
- this.alertModalDeleteCommunity.message += " '" + title + "' ";
- }
- this.alertModalDeleteCommunity.message += "will be removed from your community. Are you sure?";
- this.alertModalDeleteCommunity.okButtonText = "Yes";
- this.alertModalDeleteCommunity.open();
+ this.selectedCommunityContentProvider = communityContentProvider;
+ this.deleteModal.alertTitle = "Remove content provider";
+ let title = "";
+ if (communityContentProvider.name) {
+ title = communityContentProvider.name;
}
- }
-
- public _getCommunityContentProviders() {
- if (!Session.isLoggedIn()) {
- this._router.navigate(['/user-info'], {
- queryParams: {
- "errorCode": LoginErrorCodes.NOT_VALID,
- "redirectUrl": this._router.url
- }
- });
- } else {
- this.communitySearchUtils.status = this.errorCodes.LOADING;
- this.communityContentProviders = [];
- this.communitySearchUtils.totalResults = 0;
- this.communitySearchUtils.page = 1;
- this.communitySearchUtils.keyword = "";
-
- this.subscriptions.push(this._searchCommunityContentProvidersService.searchDataproviders(this.properties, this.portal).subscribe(
- data => {
- this.communityContentProviders = data;
- this.previewCommunityContentProviders = this.communityContentProviders;
- // this.sort();
-
- this.communitySearchUtils.totalResults = data.length;
- this.communitySearchUtils.status = this.errorCodes.DONE;
-
- this.communityContentProvidersChanged.emit({
- value: this.communityContentProviders,
- });
-
- this.showLoading = false;
- },
- err => {
- console.error(err);
- //TODO check erros (service not available, bad request)
-
- if (err.status == '404') {
- this.communitySearchUtils.status = this.errorCodes.NOT_FOUND;
- } else if (err.status == '500') {
- this.communitySearchUtils.status = this.errorCodes.ERROR;
- } else {
- this.communitySearchUtils.status = this.errorCodes.NOT_AVAILABLE;
- }
-
- this.showLoading = false;
- }
- ));
+ if (communityContentProvider.name && communityContentProvider.acronym) {
+ title += " (";
}
+ if (communityContentProvider.acronym) {
+ title += communityContentProvider.acronym;
+ }
+ if (communityContentProvider.name && communityContentProvider.acronym) {
+ title += ")";
+ }
+ this.deleteModal.message = "Content Provider";
+ if (title) {
+ this.deleteModal.message += " '" + title + "' ";
+ }
+ this.deleteModal.message += "will be removed from your community. Are you sure?";
+ this.deleteModal.okButtonText = "Yes";
+ this.deleteModal.cancelButtonText = "No";
+ this.deleteModal.open();
}
-
+
+ public getCommunityContentProviders() {
+ this.communityContentProviders = [];
+ this.subscriptions.push(this._searchCommunityContentProvidersService.searchDataproviders(this.properties, this.community.communityId).subscribe(
+ data => {
+ this.communityContentProviders = data;
+ this.previewCommunityContentProviders = this.communityContentProviders;
+ this.communityContentProvidersChanged.emit({
+ value: this.communityContentProviders,
+ });
+ this.loading = false;
+ },
+ err => {
+ this.handleError('An error has been occurred. Try again later!', err)
+ this.loading = false;
+ }
+ ));
+ }
+
public updatePage($event) {
this.page = $event.value;
}
-
- addNew() {
- this.toggleView.emit(null);
+
+ get currentPage(): any[] {
+ return this.previewCommunityContentProviders.slice((this.page - 1)*this.resultsPerPage, this.page*this.resultsPerPage);
}
-
+
+ addNew() {
+ this.addContentProviders.emit();
+ }
+
public applyFilters() {
this.previewCommunityContentProviders = this.communityContentProviders.filter(contentProvider => {
return this.filterCommunityContentProviderByKeyword(contentProvider);
});
-
- // check paging here!!!
- if (this.previewCommunityContentProviders.slice((this.page - 1) * this.resultsPerPage, this.page * this.resultsPerPage).length == 0) {
- this.page = 1;
- }
-
- // this.sort();
}
-
+
public filterCommunityContentProviderByKeyword(contentProvider): boolean {
- const textFlag = this.searchText.toString() === ''
+ return this.searchText.toString() === ''
|| (contentProvider.name + " " + contentProvider.officialname).match(this.searchText) != null;
- return textFlag;
}
-
- private sort() {
- let sortOption: { sort: string, descending: boolean } = this.filterForm.get('sort').value;
-
- this.previewCommunityContentProviders.sort((left, right): number => {
- if (sortOption.sort == "name") {
- if (left.name > right.name) {
- return sortOption.descending ? -1 : 1;
- } else if (left.name < right.name) {
- return sortOption.descending ? 1 : -1;
- }
- } else if (sortOption.sort == "officialname") {
- if (left.officialname > right.officialname) {
- return sortOption.descending ? -1 : 1;
- } else if (left.officialname < right.officialname) {
- return sortOption.descending ? 1 : -1;
- }
- }
-
- return 0;
- });
+
+ handleSuccess(message) {
+ NotificationHandler.rise(message);
}
-
- public onSearchClose() {
- this.communitySearchUtils.keyword = this.filterForm.get('keyword').value;
+
+ handleError(message: string, error = null) {
+ if (error) {
+ console.error(error);
+ }
+ NotificationHandler.rise(message, 'danger');
}
-
- public resetInput() {
- this.communitySearchUtils.keyword = null;
- this.searchInputComponent.reset()
- }
-
- handleError(message: string) {
- UIkit.notification(message, {
- status: 'danger',
- timeout: 6000,
- pos: 'bottom-right'
- });
- }
-
+
goToCriteria(openaireId: string) {
this._router.navigate([openaireId], {
queryParams: {
diff --git a/src/app/pages/error/errorPage.component.ts b/src/app/pages/error/errorPage.component.ts
index 6db8884..e3f90f2 100644
--- a/src/app/pages/error/errorPage.component.ts
+++ b/src/app/pages/error/errorPage.component.ts
@@ -3,7 +3,7 @@ import {Component} from '@angular/core';
@Component({
selector: 'openaire-error',
template: `
-
+
`
diff --git a/src/app/pages/users/personal-info/personal-info.component.ts b/src/app/pages/users/personal-info/personal-info.component.ts
index d2e5292..e0c33a7 100644
--- a/src/app/pages/users/personal-info/personal-info.component.ts
+++ b/src/app/pages/users/personal-info/personal-info.component.ts
@@ -85,13 +85,13 @@ declare var UIkit;
Add New Affiliation
-
+
-
-
+
+
{{affiliation.value.name}}
diff --git a/src/assets/common-assets b/src/assets/common-assets
index 65cbf34..052d94e 160000
--- a/src/assets/common-assets
+++ b/src/assets/common-assets
@@ -1 +1 @@
-Subproject commit 65cbf342bc890aff15a8831711f69d9b35e6f85d
+Subproject commit 052d94e27ce698a119755973e0b7285d2b64370b
diff --git a/src/assets/dashboard-theme b/src/assets/dashboard-theme
index 8818983..319eff1 160000
--- a/src/assets/dashboard-theme
+++ b/src/assets/dashboard-theme
@@ -1 +1 @@
-Subproject commit 8818983564cb9e9232979af27fa568c18fa4eba8
+Subproject commit 319eff1cc355ffc4148cf20c4ba23e15fbc6a6f6
diff --git a/src/assets/openaire-theme b/src/assets/openaire-theme
index 25f7f7d..35bca0f 160000
--- a/src/assets/openaire-theme
+++ b/src/assets/openaire-theme
@@ -1 +1 @@
-Subproject commit 25f7f7dd34fae80d1e2e25935c2f2772c5800e70
+Subproject commit 35bca0f68bf19337413167ecf770f1027902964f
diff --git a/src/environments/environment.beta.ts b/src/environments/environment.beta.ts
index 622a654..fd327ea 100644
--- a/src/environments/environment.beta.ts
+++ b/src/environments/environment.beta.ts
@@ -85,5 +85,6 @@ export let properties: EnvProperties = {
lastIndexUpdate: "2020-05-06",
indexInfoAPI: "https://beta.services.openaire.eu/openaire/info/",
admins: ["rcd@openaire.eu"],
- adminPortalURL: "https://beta.admin.connect.openaire.eu"
+ adminPortalURL: "https://beta.admin.connect.openaire.eu",
+ errorLink: '/error'
};
diff --git a/src/environments/environment.prod.ts b/src/environments/environment.prod.ts
index afcfe95..00d8c0d 100644
--- a/src/environments/environment.prod.ts
+++ b/src/environments/environment.prod.ts
@@ -85,5 +85,6 @@ export let properties: EnvProperties = {
lastIndexUpdate: "2020-12-17",
indexInfoAPI: "https://services.openaire.eu/openaire/info/",
admins: ["rcd@openaire.eu"],
- adminPortalURL: "https://admin.connect.openaire.eu"
+ adminPortalURL: "https://admin.connect.openaire.eu",
+ errorLink: '/error'
};
diff --git a/src/environments/environment.ts b/src/environments/environment.ts
index 71c1a70..3792903 100644
--- a/src/environments/environment.ts
+++ b/src/environments/environment.ts
@@ -90,5 +90,6 @@ export let properties: EnvProperties = {
lastIndexUpdate: '2019-05-16',
indexInfoAPI: 'http://beta.services.openaire.eu/openaire/info/',
admins: ['kostis30fylloy@gmail.com'],
- adminPortalURL: 'https://beta.admin.connect.openaire.eu'
+ adminPortalURL: 'https://beta.admin.connect.openaire.eu',
+ errorLink: '/error'
};