Add icons in menu items. Fix initialization of menus. Finish content providers base page

This commit is contained in:
Konstantinos Triantafyllou 2022-07-02 14:45:34 +03:00
parent 1e71eafa45
commit 4160f837c1
14 changed files with 269 additions and 502 deletions

View File

@ -5,10 +5,9 @@
<div class="sidebar_main_swipe" [class.sidebar_main_active]="open && hasSidebar" [class.sidebar_mini]="!open && hasSidebar">
<div id="modal-container"></div>
<navbar *ngIf="hasHeader" portal="connect-admin" [header]="menuHeader" [communityId]="community ? community.communityId : null"
[userMenuItems]=userMenuItems [menuItems]="menuItems" [user]="user" [offCanvasFlip]="true"
[detectCommunityIdChanges]="true"></navbar>
[userMenuItems]=userMenuItems [menuItems]="menuItems" [user]="user" [offCanvasFlip]="true"></navbar>
<div>
<dashboard-sidebar *ngIf="hasSidebar" [headerUrl]="headerUrl" [items]="sideBarItems" [headerLogoUrl]="headerLogoUrl" [specialMenuItem]="specialSideBarMenuItem"></dashboard-sidebar>
<dashboard-sidebar *ngIf="hasSidebar" [items]="sideBarItems" [specialMenuItem]="specialSideBarMenuItem"></dashboard-sidebar>
<main>
<router-outlet></router-outlet>
</main>

View File

@ -27,7 +27,7 @@ export class AppComponent implements OnInit {
params: BehaviorSubject<Params> = new BehaviorSubject<Params>(null);
data: BehaviorSubject<Data> = new BehaviorSubject<Data>(null);
hasSidebar: boolean = false;
hasHeader: boolean = false;
hasHeader: boolean = true;
hasAdminMenu: boolean = false;
isFrontPage: boolean = false;
sideBarItems: MenuItem[] = [];
@ -83,6 +83,11 @@ 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 => {
@ -113,14 +118,14 @@ export class AppComponent implements OnInit {
}
}));
} else {
this.buildMenu();
this.loading = false;
}
} else {
this.communityService.setCommunity(null);
this.layoutService.setOpen(!(this.innerWidth && this.innerWidth < 1219));
this.community = null;
this.buildMenu();
if(this.community) {
this.communityService.setCommunity(null);
this.community = null;
this.buildMenu();
}
this.loading = false;
}
}
@ -212,12 +217,12 @@ export class AppComponent implements OnInit {
badge: false,
stickyAnimation: false
};
this.sideBarItems.push(new MenuItem("community", "Community Info", "", "/" + this.community.communityId, false, [], [], {}, null, null, null, "/" + this.community.communityId + "/info"));
this.sideBarItems.push(new MenuItem("users", "Users", "", "/" + this.community.communityId + "/users", false, [], [], {}, null, null, null, "/" + this.community.communityId + "/users"));
this.sideBarItems.push(new MenuItem("admin-tools", "Pages & Entities", "", "/" + this.community.communityId + "/admin-tools/pages", false, [], [], {}, null, null, null, "/" + this.community.communityId + "/admin-tools"));
this.sideBarItems.push(new MenuItem("customization", "Customization", "", "/" + this.community.communityId + "/customize-layout", false, [], [], {}));
this.sideBarItems.push(new MenuItem("community", "Community Info", "", "/" + this.community.communityId, false, [], [], {}, {name: 'badge'}, null, null, "/" + this.community.communityId + "/info"));
this.sideBarItems.push(new MenuItem("users", "Users", "", "/" + this.community.communityId + "/users", false, [], [], {}, {name: 'group'}, null, null, "/" + this.community.communityId + "/users"));
this.sideBarItems.push(new MenuItem("admin-tools", "Pages & Entities", "", "/" + this.community.communityId + "/admin-tools/pages", false, [], [], {}, {name: 'description'}, null, null, "/" + this.community.communityId + "/admin-tools"));
this.sideBarItems.push(new MenuItem("customization", "Customization", "", "/" + this.community.communityId + "/customize-layout", false, [], [], {}, {name: 'brush'}));
if (this.community.type === 'ri') {
this.sideBarItems.push(new MenuItem("mining", "Mining", "", "/" + this.community.communityId + "/mining/manage-profiles", false, [], [], {}, null, null, null, "/" + this.community.communityId + "/mining"));
this.sideBarItems.push(new MenuItem("mining", "Mining", "", "/" + this.community.communityId + "/mining/manage-profiles", false, [], [], {}, {name: 'architecture'}, null, null, "/" + this.community.communityId + "/mining"));
}
this.specialSideBarMenuItem = new MenuItem("back", "Manage communities", "", "/", false, [], null, {}, {name: 'search', class: 'uk-text-secondary'});
@ -283,7 +288,9 @@ export class AppComponent implements OnInit {
badge: false,
stickyAnimation: false
};
this.sideBarItems.push(new MenuItem("communities", "Manage Communities", "", "/", false, [], [], {}, {name: 'settings'}));
if(this.isCurator()) {
this.sideBarItems.push(new MenuItem("communities", "Manage Communities", "", "/", false, [], [], {}, {name: 'settings'}));
}
if (Session.isPortalAdministrator(this.user)) {
this.sideBarItems.push(new MenuItem("super_admin", "Super Admin Options", "", "/admin-tools/portals", false, [], [], {}, {name: 'settings'}, null, null, '/admin-tools'));
this.sideBarItems.push(new MenuItem("connect", "Connect Options", "", "/connect/admin-tools/pages", false, [], [], {}, {name: 'settings'}, null, null, '/connect/admin-tools'));
@ -291,6 +298,7 @@ export class AppComponent implements OnInit {
}
this.specialSideBarMenuItem = null;
}
this.hasSidebar = this.hasSidebar && this.sideBarItems.length > 0;
}
private isCurator() {

View File

@ -1,5 +1,5 @@
import {NgModule} from '@angular/core';
import {PreloadAllModules, RouterModule, Routes} from '@angular/router';
import {RouterModule, Routes} from '@angular/router';
import {IsCommunity} from './openaireLibrary/connect/communityGuard/isCommunity.guard';
import {ConnectAdminLoginGuard} from './openaireLibrary/connect/communityGuard/connectAdminLoginGuard.guard';
import {AdminErrorPageComponent} from './pages/error/errorPage.component';
@ -60,10 +60,7 @@ const routes: Routes = [
];
@NgModule({
imports: [RouterModule.forRoot(routes, {
preloadingStrategy: PreloadAllModules,
onSameUrlNavigation: "reload"
})],
imports: [RouterModule.forRoot(routes)],
exports: [ RouterModule ]
})
export class AppRoutingModule {}

@ -1 +1 @@
Subproject commit 936c870abcb48b632f3a1433130e8701c813fa65
Subproject commit a738d3bb49d1af38f7eaf3ce34d519c76f075e4a

View File

@ -35,47 +35,47 @@
<no-load-paging (pageChange)="updatePage($event)" [page]="page" [totalResults]="affiliations.length"
[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">
<div *ngFor="let affiliation of currentPage; let i=index">
<div class="uk-card uk-card-default uk-margin-bottom">
<div class="uk-card-body">
<div class="uk-flex uk-flex-middle uk-flex-column">
<div class="uk-width-small uk-height-max-small">
<img [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>
<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 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>
<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 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>
<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>
<div class="uk-margin-small-top">
<paging-no-load [currentPage]="page"
[totalResults]="affiliations.length" [size]="pageSize"

View File

@ -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 <b>successfully created</b>', {
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 <b>successfully saved</b>', {
status: 'success',

View File

@ -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]);
}
}

View File

@ -1,34 +1,35 @@
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: `
<remove-content-providers (toggleView)="toggleAction()" [communityContentProviders]="communityContentProviders"
[showLoading]="showLoadingInRemove"
[loading]="showLoadingInRemove" [community]="community"
(communityContentProvidersChanged)="communityContentProvidersChanged($event)" [toggle]="toggle">
</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="communityId" uk-drop="mode: hover">
<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 - '+ communityId + '] report missing Funder' + '&body=' + body"
[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>
@ -45,33 +46,27 @@ 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;
@ -86,17 +81,10 @@ 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();
}
HelperFunctions.scroll();
this.toggle = !this.toggle;
if (this.toggle) {
this.fullscreen.open();
}
}

View File

@ -1,150 +1,111 @@
<div page-content>
<div page-content (stickyEmitter)="stickyPageHeader = $event">
<div header>
<community-info tab="content-providers"></community-info>
<div [class.uk-invisible]="showLoading"
class="uk-width-1-1 uk-flex uk-flex-right@m uk-flex-center uk-flex-wrap uk-flex-middle uk-grid" uk-grid>
<div class="uk-flex-last@m">
<a class="uk-text-uppercase uk-flex uk-flex-middle" (click)="addNew()"
[attr.uk-tooltip]="(toggle? 'cls: uk-invisible; ' : 'cls: uk-active; ') +
'title: <div class=\'uk-padding-small\'><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>'">
<button class="uk-icon-button large uk-button-secondary">
<icon name="add"></icon>
</button>
<button class="uk-button uk-button-link uk-margin-small-left uk-text-secondary">Add new content provider
</button>
</a>
<div class="uk-flex uk-flex-middle uk-margin-top info" [class.uk-active]="stickyPageHeader">
<div>
<div class="uk-margin-remove uk-text-background uk-text-bold uk-h6">Admin Dashboard - Manage Content Providers
</div>
<h1 class="uk-h4 uk-margin-remove">{{community.shortTitle}}</h1>
</div>
<div #searchInputComponent search-input [control]="filterForm.controls.keyword" [showSearch]="false"
placeholder="Search Content Providers"
[selected]="communitySearchUtils.keyword" (closeEmitter)="onSearchClose()" (resetEmitter)="resetInput()"
[bordered]="true" colorClass="uk-text-secondary"
class="uk-width-1-3@xl uk-width-2-5@l uk-width-1-2@m uk-width-1-1"></div>
</div>
<community-info tab="content-providers"></community-info>
</div>
<div inner>
<div *ngIf="showLoading" class="uk-margin-large-top">
<loading></loading>
</div>
<div *ngIf="!showLoading">
<div class="uk-flex uk-flex-right@m uk-flex-center uk-flex-middle uk-grid uk-margin-top" uk-grid>
<div search-input [expandable]="true" [searchControl]="filterForm.get('keyword')" searchInputClass="outer"
placeholder="Search Content Providers" [disabled]="loading"
class="uk-width-1-3@xl uk-width-2-5@l uk-width-1-2@m uk-width-1-1"></div>
<div>
<!-- <div class="uk-grid uk-flex uk-flex-middle uk-margin-medium-bottom" uk-grid>-->
<!-- <div *ngIf="previewCommunityContentProviders.length > 0"-->
<!-- class="uk-width-expand@m uk-width-1-1">-->
<!-- <div class="uk-flex-middle uk-flex-right@m uk-flex-center uk-grid">-->
<!-- <span class="">Sort by: </span>-->
<!-- <div class="uk-width-medium uk-padding-remove uk-margin-small-left" dashboard-input-->
<!-- [formInput]="filterForm.get('sort')"-->
<!-- type="select"-->
<!-- [options]="sortOptions">-->
<!-- </div>-->
<!-- </div>-->
<!-- </div>-->
<!-- </div>-->
<no-load-paging *ngIf="previewCommunityContentProviders.length > 0" [type]="'content providers'"
(pageChange)="updatePage($event)"
[page]="page" [pageSize]="resultsPerPage"
[totalResults]="previewCommunityContentProviders.length">
</no-load-paging>
<div class="uk-margin-medium-top uk-margin-medium-bottom">
<div *ngIf="previewCommunityContentProviders.length == 0"
class="uk-card uk-card-default uk-padding-large uk-text-center uk-margin-bottom uk-text-bold">
<div>No content providers for {{name}}</div>
</div>
<div class="uk-card uk-card-default uk-text-small uk-margin-bottom"
*ngFor="let item of previewCommunityContentProviders.slice((page - 1)*resultsPerPage, page*resultsPerPage)">
<div class="uk-grid uk-grid-divider uk-padding" uk-grid>
<div class="uk-width-expand@m uk-width-1-1">
<div class="uk-padding-small uk-padding-remove-horizontal">
<!-- <h6 *ngIf="item.name || item.officialname || item.openaireId || item.selectioncriteria"-->
<!-- class="uk-margin-small-bottom">-->
<!-- <a *ngIf="item.openaireId"-->
<!-- target="_blank"-->
<!-- [href]="contentProviderUrl+item.openaireId">-->
<!-- <span *ngIf="item.name">{{item.name}}</span>-->
<!-- <span *ngIf="!item.name && item.officialname">{{item.officialname}}</span>-->
<!-- <span *ngIf="!item.name && !item.officialname">[no title available]</span>-->
<!-- <span class="custom-external custom-icon space"></span>-->
<!-- </a>-->
<!-- <span *ngIf="!item.openaireId">-->
<!-- <span *ngIf="item.name">{{item.name}}</span>-->
<!-- <span *ngIf="!item.name && item.officialname">{{item.officialname}}</span>-->
<!-- <span *ngIf="!item.name && !item.officialname">[no title available]</span>-->
<!-- </span>-->
<!-- </h6>-->
<!-- <h6 *ngIf="item.name || item.officialname || item.openaireId || item.selectioncriteria"-->
<!-- class="uk-margin-small-bottom">-->
<!-- <a *ngIf="item.openaireId"-->
<!-- target="_blank"-->
<!-- [href]="contentProviderUrl+item.openaireId">-->
<!-- <span *ngIf="item.name">{{item.name}}</span>-->
<!-- <span *ngIf="!item.name">[no title available]</span>-->
<!-- <span class="custom-external custom-icon space"></span>-->
<!-- </a>-->
<!-- <span *ngIf="!item.openaireId">-->
<!-- <span *ngIf="item.name">{{item.name}}</span>-->
<!-- <span *ngIf="!item.name">[no title available]</span>-->
<!-- </span>-->
<!-- </h6>-->
<h6 class="uk-margin-small-bottom">
<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">
<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">
<loading></loading>
</div>
<div *ngIf="!loading">
<div *ngIf="previewCommunityContentProviders.length == 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>
<div *ngIf="previewCommunityContentProviders.length > 0">
<no-load-paging [type]="'content providers'"
(pageChange)="updatePage($event)"
[page]="page" [pageSize]="resultsPerPage"
[totalResults]="previewCommunityContentProviders.length">
</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 item of currentPage; let i=index">
<div class="uk-card uk-card-default">
<div class="uk-card-body">
<h6 class="uk-margin-bottom">
<a *ngIf="item.openaireId"
target="_blank"
target="_blank" class="custom-external uk-link-text"
[href]="contentProviderUrl+item.openaireId">
<span *ngIf="item.officialname">{{item.officialname}}</span>
<span *ngIf="!item.officialname && item.name">{{item.name}}</span>
<span *ngIf="!item.officialname && !item.name">[no title available]</span>
<span class="custom-external custom-icon space"></span>
</a>
<span *ngIf="!item.openaireId">
<span *ngIf="item.officialname">{{item.officialname}}</span>
<span *ngIf="!item.officialname && item.name">{{item.name}}</span>
<span *ngIf="!item.officialname && !item.name">[no title available]</span>
</span>
<span *ngIf="item.officialname">{{item.officialname}}</span>
<span *ngIf="!item.officialname && item.name">{{item.name}}</span>
<span *ngIf="!item.officialname && !item.name">[no title available]</span>
</span>
</h6>
<!-- <div *ngIf="item.name && item.officialname" class="uk-margin-small-bottom">-->
<!-- <div *ngIf="item.officialname" class="uk-margin-small-bottom">-->
<!-- <span class="title">Official Name: </span>-->
<!-- <span>{{item.officialname}}</span>-->
<!-- </div>-->
<div *ngIf="item.selectioncriteria?.criteria?.length > 0" class="uk-margin-small-bottom">
<div class="title uk-margin-small-bottom">Filters</div>
<div *ngIf="item.selectioncriteria?.criteria?.length > 0" class="uk-margin-small-bottom uk-text-small">
<div class="uk-text-meta uk-margin-small-bottom">Filters</div>
<div [innerHTML]="getFiltersAsText(item.selectioncriteria.criteria)"></div>
<a *ngIf="item.selectioncriteria.criteria.length > 3" class="uk-link uk-margin-top" [routerLink]="'./' + item.openaireId">View all {{item.selectioncriteria.criteria.length}} filters</a>
<div *ngIf="item.selectioncriteria.criteria.length > 3" class="uk-margin-small-top">
<a class="uk-link view-more-less-link" [routerLink]="'./' + item.openaireId">View all {{item.selectioncriteria.criteria.length}} filters</a>
</div>
</div>
</div>
</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">
<a (click)="goToCriteria(item.openaireId)" class="uk-button action uk-flex uk-flex-middle">
<icon name="edit"></icon>
<span *ngIf="item.selectioncriteria?.criteria?.length > 0" class="uk-margin-small-left"
uk-tooltip="<div class='uk-padding-small'>Edit filters to limit research results.<br>Results which satisfy any of the selected filters will be included in your community.</div>">
Edit filters
</span>
<span *ngIf="!(item.selectioncriteria?.criteria?.length > 0)" class="uk-margin-small-left"
uk-tooltip="<div class='uk-padding-small'>Add filter to limit research results.<br>Results which satisfy any of the selected filters will be included in your community.</div>">
Add filters
</span>
</a>
<a (click)="removeContentProvider(item)"
class="uk-button action uk-flex uk-flex-middle uk-margin-small-top">
<icon name="remove_circle_outline"></icon>
<span class="uk-margin-small-left">Remove content provider</span>
</a>
<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)="goToCriteria(item.openaireId)" class="uk-button uk-button-link uk-flex uk-flex-middle">
<icon name="filters" [flex]="true"></icon>
<span *ngIf="item.selectioncriteria?.criteria?.length > 0" class="uk-margin-small-left"
uk-tooltip="<div>Edit filters to limit research results.<br>Results which satisfy any of the selected filters will be included in your community.</div>">
Edit filters
</span>
<span *ngIf="!(item.selectioncriteria?.criteria?.length > 0)" class="uk-margin-small-left"
uk-tooltip="<div>Add filter to limit research results.<br>Results which satisfy any of the selected filters will be included in your community.</div>">
Add filters
</span>
</a>
</div>
</div>
<div>
<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>
</a>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="uk-margin-small-top">
<paging-no-load [currentPage]="page"
[totalResults]="previewCommunityContentProviders.length" [size]="resultsPerPage"
(pageChange)="updatePage($event)" customClasses="uk-flex-right@m uk-flex-center">
</paging-no-load>
</div>
</div>
<no-load-paging *ngIf="previewCommunityContentProviders.length > 0" [type]="'content providers'"
(pageChange)="updatePage($event)"
[page]="page" [pageSize]="resultsPerPage"
[totalResults]="previewCommunityContentProviders.length">
</no-load-paging>
</div>
</div>
<modal-alert #AlertModalDeleteCommunity (alertOutput)="confirmedDeleteContentProvider($event)"></modal-alert>
</div>
</div>
<modal-alert #deleteModal [overflowBody]="false" (alertOutput)="confirmedDeleteContentProvider()"></modal-alert>

View File

@ -3,43 +3,39 @@ 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 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 +47,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<any> = 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 +78,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(" <b>and</b> "));
return text.join("<br>");
}
// 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;
}
get currentPage(): any[] {
return this.previewCommunityContentProviders.slice((this.page - 1)*this.resultsPerPage, this.page*this.resultsPerPage);
}
addNew() {
this.toggleView.emit(null);
}
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: {

View File

@ -3,7 +3,7 @@ import {Component} from '@angular/core';
@Component({
selector: 'openaire-error',
template: `
<div class="uk-margin-large-top">
<div class="uk-section">
<error></error>
</div>
`

View File

@ -85,13 +85,13 @@ declare var UIkit;
<span class="uk-margin-small-left">Add New Affiliation</span>
</button>
</div>
<div class="uk-margin-medium uk-grid uk-child-width-1-2@m uk-child-width-1-1" uk-grid>
<div class="uk-margin-medium uk-grid uk-child-width-1-2@m uk-child-width-1-1" uk-height-match="target: .uk-card-body; row: false" uk-grid>
<div *ngFor="let affiliation of affiliations.controls; let i=index">
<div class="uk-card uk-card-default uk-margin-bottom">
<div class="uk-card-body">
<div class="uk-flex uk-flex-middle uk-flex-column">
<div class="uk-width-small uk-height-max-small">
<img [src]="affiliation.value.logo_url | urlPrefix">
<div class="uk-flex uk-flex-center">
<img class="uk-height-xsmall uk-blend-multiply" [src]="affiliation.value.logo_url | urlPrefix">
</div>
<h5>{{affiliation.value.name}}</h5>
<div class="uk-text-truncate uk-text-small">

@ -1 +1 @@
Subproject commit 65cbf342bc890aff15a8831711f69d9b35e6f85d
Subproject commit 052d94e27ce698a119755973e0b7285d2b64370b

@ -1 +1 @@
Subproject commit 8818983564cb9e9232979af27fa568c18fa4eba8
Subproject commit 318b3cdf42922d8b04400bb010733b78fcf1fe1c