From 7c9d0936b3a98a7f049459e781c93b1277e5f7a9 Mon Sep 17 00:00:00 2001 From: "k.triantafyllou" Date: Mon, 4 Jul 2022 21:45:20 +0300 Subject: [PATCH 1/3] Finish UI of Content Providers and their Criteria. Fix search width in subjects --- src/app/app.component.ts | 3 +- src/app/app.module.ts | 1 - src/app/openaireLibrary | 2 +- .../affiliations/affiliations.component.html | 8 +- .../affiliations/affiliations.component.ts | 5 +- .../pages/affiliations/affiliations.module.ts | 6 - .../community-info-routing.module.ts | 1 - .../community-info.component.ts | 16 +- .../add-content-providers.component.html | 8 +- .../add-content-providers.component.ts | 9 +- .../communityContentProviders.module.ts | 9 +- .../criteria/criteria-routing.module.ts | 13 -- .../criteria/criteria.component.css | 6 - .../criteria/criteria.component.html | 156 ++++++------------ .../criteria/criteria.component.less | 8 + .../criteria/criteria.component.ts | 104 ++++-------- .../criteria/criteria.module.ts | 16 +- .../manage-content-providers.component.ts | 61 +++++-- .../remove-content-providers.component.html | 19 +-- .../remove-content-providers.component.ts | 31 ++-- src/app/pages/mining/mining.component.ts | 2 +- .../subjects-edit-form.component.html | 42 ++--- .../subjects-edit-form.module.ts | 11 +- .../personal-info/personal-info.component.ts | 10 +- src/assets/openaire-theme | 2 +- 25 files changed, 237 insertions(+), 312 deletions(-) delete mode 100644 src/app/pages/content-providers/criteria/criteria-routing.module.ts delete mode 100644 src/app/pages/content-providers/criteria/criteria.component.css create mode 100644 src/app/pages/content-providers/criteria/criteria.component.less diff --git a/src/app/app.component.ts b/src/app/app.component.ts index bfdf853..cb27fba 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -15,6 +15,7 @@ import {ConnectHelper} from './openaireLibrary/connect/connectHelper'; import {ConfigurationService} from './openaireLibrary/utils/configuration/configuration.service'; import {StringUtils} from "./openaireLibrary/utils/string-utils.class"; import {OpenaireEntities} from "./openaireLibrary/utils/properties/searchFields"; +import {mining} from "./openaireLibrary/utils/icons/icons"; @Component({ selector: 'app-root', @@ -215,7 +216,7 @@ export class AppComponent implements OnInit { 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, [], [], {}, {name: 'architecture'}, null, null, "/" + this.community.communityId + "/mining")); + this.sideBarItems.push(new MenuItem("mining", "Mining", "", "/" + this.community.communityId + "/mining/manage-profiles", false, [], [], {}, {svg: mining.data}, null, null, "/" + this.community.communityId + "/mining")); } this.specialSideBarMenuItem = new MenuItem("back", "Manage communities", "", "/", false, [], null, {}, {name: 'search', class: 'uk-text-secondary'}); diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 3800ab0..46ebb0b 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -11,7 +11,6 @@ import {IsCommunity} from './openaireLibrary/connect/communityGuard/isCommunity. import {AdminErrorPageComponent} from './pages/error/errorPage.component'; import {ErrorModule} from './openaireLibrary/error/error.module'; import {TitleCasePipe} from '@angular/common'; -import {CommunityService} from './openaireLibrary/connect/community/community.service'; import {SubscribeService} from './openaireLibrary/utils/subscribe/subscribe.service'; import {ConnectRIGuard} from './openaireLibrary/connect/communityGuard/connectRIGuard.guard'; import {BrowserAnimationsModule} from '@angular/platform-browser/animations'; diff --git a/src/app/openaireLibrary b/src/app/openaireLibrary index e61d449..f08c63d 160000 --- a/src/app/openaireLibrary +++ b/src/app/openaireLibrary @@ -1 +1 @@ -Subproject commit e61d4495aee212f7e991f0ad9c54c0429cf01757 +Subproject commit f08c63d3849e966bcfe916f0ca48788e0b401306 diff --git a/src/app/pages/affiliations/affiliations.component.html b/src/app/pages/affiliations/affiliations.component.html index b89164a..0360d8f 100644 --- a/src/app/pages/affiliations/affiliations.component.html +++ b/src/app/pages/affiliations/affiliations.component.html @@ -40,8 +40,8 @@
-
- +
+
{{affiliation.name}}
@@ -87,7 +87,7 @@
- +
@@ -96,5 +96,5 @@
- + diff --git a/src/app/pages/affiliations/affiliations.component.ts b/src/app/pages/affiliations/affiliations.component.ts index 011ac0e..d800ef7 100644 --- a/src/app/pages/affiliations/affiliations.component.ts +++ b/src/app/pages/affiliations/affiliations.component.ts @@ -15,6 +15,7 @@ import {Subscription} from "rxjs"; import {CommunityService} from "../../openaireLibrary/connect/community/community.service"; import {CommunityInfo} from "../../openaireLibrary/connect/community/communityInfo"; import {NotificationHandler} from "../../openaireLibrary/utils/notification-handler"; +import {HelperFunctions} from "../../openaireLibrary/utils/HelperFunctions.class"; @Component({ selector: 'affiliations', @@ -67,8 +68,7 @@ export class AffiliationsComponent implements OnInit, OnDestroy { getAffiliations() { this.loading = true; - this.affiliationService.initAffiliations(this.community.communityId); - this.affiliationService.affiliations.subscribe( + this.affiliationService.getAffiliations(this.community.communityId).subscribe( affiliations => { this.affiliations = affiliations; this.loading = false; @@ -133,6 +133,7 @@ export class AffiliationsComponent implements OnInit, OnDestroy { } public updatePage(event) { + HelperFunctions.scroll(); this.page = event.value; } diff --git a/src/app/pages/affiliations/affiliations.module.ts b/src/app/pages/affiliations/affiliations.module.ts index 6dd1d69..3c5142c 100644 --- a/src/app/pages/affiliations/affiliations.module.ts +++ b/src/app/pages/affiliations/affiliations.module.ts @@ -13,8 +13,6 @@ import {InputModule} from "../../openaireLibrary/sharedComponents/input/input.mo import {PageContentModule} from "../../openaireLibrary/dashboard/sharedComponents/page-content/page-content.module"; import {CommunityInfoModule} from "../community-info/community-info.module"; import {IconsModule} from "../../openaireLibrary/utils/icons/icons.module"; -import {IconsService} from "../../openaireLibrary/utils/icons/icons.service"; -import {add, edit, preview, remove} from "../../openaireLibrary/utils/icons/icons"; import {NoLoadPaging} from "../../openaireLibrary/searchPages/searchUtils/no-load-paging.module"; import {LoadingModule} from "../../openaireLibrary/utils/loading/loading.module"; import {UrlPrefixModule} from "../../openaireLibrary/utils/pipes/url-prefix.module"; @@ -38,8 +36,4 @@ import {PagingModule} from "../../openaireLibrary/utils/paging.module"; }) export class AffiliationsModule { - - constructor(private iconsService: IconsService) { - this.iconsService.registerIcons([add, preview, remove]) - } } diff --git a/src/app/pages/community-info/community-info-routing.module.ts b/src/app/pages/community-info/community-info-routing.module.ts index a5ffc9f..a8afa4e 100644 --- a/src/app/pages/community-info/community-info-routing.module.ts +++ b/src/app/pages/community-info/community-info-routing.module.ts @@ -10,7 +10,6 @@ import {ConnectCommunityGuard} from "../../openaireLibrary/connect/communityGuar {path: 'organizations', loadChildren: () => import('../affiliations/affiliations.module').then(m => m.AffiliationsModule)}, {path: 'projects', loadChildren: () => import('../projects/communityProjects.module').then(m => m.CommunityProjectsModule)}, {path: 'content-providers', loadChildren: () => import('../content-providers/communityContentProviders.module').then(m => m.CommunityContentProvidersModule)}, - {path: 'content-providers/:provider', loadChildren: () => import('../content-providers/criteria/criteria.module').then(m => m.CriteriaModule)}, {path: 'zenodo-communities', loadChildren: () => import('../zenodo-communities/zenodo-communities.module').then(m => m.ZenodoCommunitiesModule)}, {path: 'subjects', canActivateChild: [ConnectCommunityGuard], loadChildren: () => import('../subjects/subjects-edit-form/subjects-edit-form.module').then(m => m.SubjectsEditFormModule)}, ]) diff --git a/src/app/pages/community-info/community-info.component.ts b/src/app/pages/community-info/community-info.component.ts index a048115..4f579af 100644 --- a/src/app/pages/community-info/community-info.component.ts +++ b/src/app/pages/community-info/community-info.component.ts @@ -2,17 +2,18 @@ import {Component, Input, OnInit} from '@angular/core'; import {CommunityInfo} from '../../openaireLibrary/connect/community/communityInfo'; import {CommunityService} from '../../openaireLibrary/connect/community/community.service'; import {Subscription} from 'rxjs'; +import {OpenaireEntities} from "../../openaireLibrary/utils/properties/searchFields"; @Component({ selector: 'community-info', template: ` -
@@ -20,10 +20,10 @@
-
No content providers found
+
No {{openAIREEntities.DATASOURCE}} found
- 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 7220ba5..4d51d18 100644 --- a/src/app/pages/content-providers/add-content-providers.component.ts +++ b/src/app/pages/content-providers/add-content-providers.component.ts @@ -18,6 +18,9 @@ import {debounceTime, distinctUntilChanged} from "rxjs/operators"; import {ResultPreview} from "../../openaireLibrary/utils/result-preview/result-preview"; import {NotificationHandler} from "../../openaireLibrary/utils/notification-handler"; import {CommunityInfo} from "../../openaireLibrary/connect/community/communityInfo"; +import {ContentProvider} from "../../openaireLibrary/utils/entities/contentProvider"; +import {OpenaireEntities} from "../../openaireLibrary/utils/properties/searchFields"; +import {HelperFunctions} from "../../openaireLibrary/utils/HelperFunctions.class"; @Component({ selector: 'add-content-providers', @@ -32,8 +35,9 @@ export class AddContentProvidersComponent implements OnInit { public errorCodes: ErrorCodes; public openaireSearchUtils: SearchUtilsClass = new SearchUtilsClass(); @Output() communityContentProvidersChanged = new EventEmitter(); - @Input() communityContentProviders = []; - public openaireContentProviders = []; + @Input() communityContentProviders: ContentProvider[] = []; + public openaireContentProviders: SearchResult[] = []; + public openAIREEntities = OpenaireEntities; public queryParameters: string = ""; public resultsPerPage: number = properties.resultsPerPage; filterForm: FormGroup; @@ -183,6 +187,7 @@ export class AddContentProvidersComponent implements OnInit { } goTo(page: number = 1) { + HelperFunctions.scroll(); this.openaireSearchUtils.page = page; this.openaireSearchUtils.status = this.errorCodes.LOADING; this._getOpenaireContentProviders(this.queryParameters, page, this.resultsPerPage); diff --git a/src/app/pages/content-providers/communityContentProviders.module.ts b/src/app/pages/content-providers/communityContentProviders.module.ts index 3947c2f..5d29600 100644 --- a/src/app/pages/content-providers/communityContentProviders.module.ts +++ b/src/app/pages/content-providers/communityContentProviders.module.ts @@ -17,15 +17,18 @@ 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, filters, remove_circle_outline} from "../../openaireLibrary/utils/icons/icons"; +import {filters} 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"; +import { + SearchDataprovidersServiceModule +} from "../../openaireLibrary/connect/contentProviders/searchDataprovidersService.module"; import {ManageContentProvidersComponent} from "./manage-content-providers.component"; import {RemoveContentProvidersComponent} from "./remove-content-providers.component"; import {AddContentProvidersComponent} from "./add-content-providers.component"; import {ManageCommunityContentProvidersService} from "../../services/manageContentProviders.service"; import {SearchDataprovidersService} from "../../openaireLibrary/services/searchDataproviders.service"; +import {CriteriaModule} from "./criteria/criteria.module"; @NgModule({ imports: [ @@ -47,7 +50,7 @@ import {SearchDataprovidersService} from "../../openaireLibrary/services/searchD path: '', component: ManageContentProvidersComponent } ]), - NoLoadPaging, LoadingModule, IconsModule, FullScreenModalModule, ResultPreviewModule + NoLoadPaging, LoadingModule, IconsModule, FullScreenModalModule, ResultPreviewModule, CriteriaModule ], declarations: [ ManageContentProvidersComponent, diff --git a/src/app/pages/content-providers/criteria/criteria-routing.module.ts b/src/app/pages/content-providers/criteria/criteria-routing.module.ts deleted file mode 100644 index 745c32f..0000000 --- a/src/app/pages/content-providers/criteria/criteria-routing.module.ts +++ /dev/null @@ -1,13 +0,0 @@ -import {NgModule} from '@angular/core'; -import {RouterModule} from '@angular/router'; -import {CriteriaComponent} from './criteria.component'; - -@NgModule({ - imports: [ - RouterModule.forChild([ - {path: '', component: CriteriaComponent} - ]) - ] -}) -export class CriteriaRoutingModule { -} diff --git a/src/app/pages/content-providers/criteria/criteria.component.css b/src/app/pages/content-providers/criteria/criteria.component.css deleted file mode 100644 index 18e6796..0000000 --- a/src/app/pages/content-providers/criteria/criteria.component.css +++ /dev/null @@ -1,6 +0,0 @@ -.criterion { - border: rgba(26,26,26,0.5) solid 1px; - border-radius: 4px; - max-height: 400px; - overflow: auto; -} diff --git a/src/app/pages/content-providers/criteria/criteria.component.html b/src/app/pages/content-providers/criteria/criteria.component.html index d70b17f..6357dd2 100644 --- a/src/app/pages/content-providers/criteria/criteria.component.html +++ b/src/app/pages/content-providers/criteria/criteria.component.html @@ -1,54 +1,34 @@ -
-
-
- - - - - - Go back to Content Providers - + -
-
-
-
-
Filters for
-
- {{dataProvider.officialname}} - (unsaved changes) -
-
-
- - -
+
+
No filters for {{dataProvider.officialname}}.
+
If no filters are specified, all research results of this content provider will be included in your + community.
-
-
-
-
No filters for {{dataProvider.officialname}}.
-
If no filters are specified, all research results of this content provider will be included in your - community. -
-
-
-
- - -
-
Filter {{getIndex(i) + 1}}
-
-
-
+ +
+ + + +
+ +
-
- -
-
-
+ +
diff --git a/src/app/pages/content-providers/criteria/criteria.component.less b/src/app/pages/content-providers/criteria/criteria.component.less new file mode 100644 index 0000000..6bec815 --- /dev/null +++ b/src/app/pages/content-providers/criteria/criteria.component.less @@ -0,0 +1,8 @@ +@import (reference) "~src/assets/openaire-theme/less/_import-variables.less"; + +.criterion { + border: @global-border solid @global-border-width; + border-radius: @global-border-radius; + max-height: 400px; + overflow: auto; +} diff --git a/src/app/pages/content-providers/criteria/criteria.component.ts b/src/app/pages/content-providers/criteria/criteria.component.ts index 4c3e0a9..5a3d659 100644 --- a/src/app/pages/content-providers/criteria/criteria.component.ts +++ b/src/app/pages/content-providers/criteria/criteria.component.ts @@ -1,6 +1,4 @@ -import {ChangeDetectorRef, Component, OnDestroy, OnInit} from '@angular/core'; -import {ActivatedRoute, Router} from '@angular/router'; -import {SearchCommunityDataprovidersService} from '../../../openaireLibrary/connect/contentProviders/searchDataproviders.service'; +import {ChangeDetectorRef, Component, Input, OnInit} from '@angular/core'; import {EnvProperties} from '../../../openaireLibrary/utils/properties/env-properties'; import { Constraint, @@ -10,25 +8,21 @@ import { } from '../../../openaireLibrary/utils/entities/contentProvider'; import {AbstractControl, FormArray, FormBuilder, FormGroup, Validators} from '@angular/forms'; import {ManageCommunityContentProvidersService} from '../../../services/manageContentProviders.service'; -import {Title} from '@angular/platform-browser'; import {properties} from "../../../../environments/environment"; -import {Subscription} from "rxjs"; import {Option} from "../../../openaireLibrary/sharedComponents/input/input.component"; import {MatSlideToggleChange} from "@angular/material/slide-toggle"; import {HelperFunctions} from "../../../openaireLibrary/utils/HelperFunctions.class"; import {CriteriaUtils} from "../criteria-utils"; - -declare var UIkit; +import {NotificationHandler} from "../../../openaireLibrary/utils/notification-handler"; @Component({ selector: 'criteria', - templateUrl: './criteria.component.html', - styleUrls: ['criteria.component.css'], + templateUrl: 'criteria.component.html', + styleUrls: ['criteria.component.less'] }) -export class CriteriaComponent implements OnInit, OnDestroy { - public community: string = ''; - public openaireId: string = ''; - public dataProvider: ContentProvider = null; +export class CriteriaComponent implements OnInit { + @Input() + public dataProvider: ContentProvider; public selectionCriteria: FormGroup; public properties: EnvProperties = properties; public fields: Option[] = CriteriaUtils.fields; @@ -37,51 +31,15 @@ export class CriteriaComponent implements OnInit, OnDestroy { /** Paging */ public page: number = 1; public pageSize: number = 5; - private subs: any[] = []; - constructor(private route: ActivatedRoute, private router: Router, - private title: Title, - private searchCommunityDataprovidersService: SearchCommunityDataprovidersService, - private manageCommunityContentProvidersService: ManageCommunityContentProvidersService, + constructor(private manageCommunityContentProvidersService: ManageCommunityContentProvidersService, private cdr: ChangeDetectorRef, private fb: FormBuilder) { } ngOnInit() { - this.subs.push(this.route.params.subscribe(params => { - this.community = params['community']; - this.route.params.subscribe(params => { - if (params['provider']) { - this.openaireId = params['provider']; - } - this.searchCommunityDataprovidersService.searchDataproviders(this.properties, this.community).subscribe(dataProviders => { - dataProviders.forEach(dataProvider => { - if (dataProvider.openaireId == this.openaireId) { - this.dataProvider = dataProvider; - this.title.setTitle(this.community.toUpperCase() + ' | Criteria for ' + this.dataProvider.officialname); - } - }); - if (!this.dataProvider) { - this.navigateToError(); - } else { - this.reset(); - this.loading = false; - } - }); - }); - })); - } - - public ngOnDestroy() { - this.subs.forEach(subscription => { - if (subscription instanceof Subscription) { - subscription.unsubscribe(); - } - }) - } - - private navigateToError() { - this.router.navigate(['/error'], {queryParams: {'page': this.properties.baseLink + this.router.url}}); + this.reset(); + this.loading = false; } reset() { @@ -110,6 +68,10 @@ export class CriteriaComponent implements OnInit, OnDestroy { } } + get disabled() { + return this.loading || !this.dirty || this.selectionCriteria.invalid; + } + get currentPage(): AbstractControl[] { if (this.criteria) { return this.criteria.controls.slice((this.page - 1) * this.pageSize, this.page * this.pageSize); @@ -162,8 +124,8 @@ export class CriteriaComponent implements OnInit, OnDestroy { constraintArray.removeAt(j); if (constraintArray.length === 0) { this.criteria.removeAt(i); - if (this.currentPage.length === 0) { - this.page = 1; + while(this.currentPage.length === 0 && this.page > 0) { + this.page--; } } this.cdr.detectChanges(); @@ -192,34 +154,31 @@ export class CriteriaComponent implements OnInit, OnDestroy { } } - save() { + save(callback: Function = null) { if (this.selectionCriteria.valid) { this.loading = true; this.dataProvider.selectioncriteria = this.parseForm(this.selectionCriteria.value); this.manageCommunityContentProvidersService.saveContentProvider(this.properties, this.dataProvider).subscribe(() => { this.reset(); + if(callback) { + callback(); + } this.loading = false; - UIkit.notification('Filters has been successfully updated', { - status: 'success', - timeout: 6000, - pos: 'bottom-right' - }); + NotificationHandler.rise('Filters have been successfully updated'); }, error => { - UIkit.notification('An error has been occurred. Try again later!', { - status: 'danger', - timeout: 6000, - pos: 'bottom-right' - }); + this.loading = false; + this.handeError('An error has been occurred. Try again later!', error); }); } else { - UIkit.notification('An error has been occurred. Try again later!', { - status: 'danger', - timeout: 6000, - pos: 'bottom-right' - }); + this.handeError('An error has been occurred. Try again later!'); } } + handeError(message, error = null) { + console.error(error); + NotificationHandler.rise(message, 'danger'); + } + caseSensitive(event: MatSlideToggleChange, constraint: AbstractControl) { if(event.checked) { constraint.get('verb_suffix').setValue(''); @@ -254,4 +213,9 @@ export class CriteriaComponent implements OnInit, OnDestroy { }) return selectionCriteria; } + + public updatePage(event) { + this.page = event.value; + HelperFunctions.scroll(); + } } diff --git a/src/app/pages/content-providers/criteria/criteria.module.ts b/src/app/pages/content-providers/criteria/criteria.module.ts index aecf8ba..b73bd68 100644 --- a/src/app/pages/content-providers/criteria/criteria.module.ts +++ b/src/app/pages/content-providers/criteria/criteria.module.ts @@ -1,25 +1,24 @@ import {NgModule} from '@angular/core'; import {CommonModule} from '@angular/common'; import {CriteriaComponent} from './criteria.component'; -import {CriteriaRoutingModule} from './criteria-routing.module'; -import {SearchCommunityDataprovidersService} from '../../../openaireLibrary/connect/contentProviders/searchDataproviders.service'; +import { + SearchCommunityDataprovidersService +} from '../../../openaireLibrary/connect/contentProviders/searchDataproviders.service'; import {RouterModule} from '@angular/router'; import {FormsModule, ReactiveFormsModule} from '@angular/forms'; import {ManageCommunityContentProvidersService} from '../../../services/manageContentProviders.service'; import {PageContentModule} from "../../../openaireLibrary/dashboard/sharedComponents/page-content/page-content.module"; import {IconsModule} from "../../../openaireLibrary/utils/icons/icons.module"; -import {IconsService} from "../../../openaireLibrary/utils/icons/icons.service"; -import {add, arrow_left, close} from "../../../openaireLibrary/utils/icons/icons"; import {LoadingModule} from "../../../openaireLibrary/utils/loading/loading.module"; import {InputModule} from "../../../openaireLibrary/sharedComponents/input/input.module"; import {MatSlideToggleModule} from "@angular/material/slide-toggle"; import {ScrollingModule} from "@angular/cdk/scrolling"; import {NoLoadPaging} from "../../../openaireLibrary/searchPages/searchUtils/no-load-paging.module"; +import {PagingModule} from "../../../openaireLibrary/utils/paging.module"; @NgModule({ imports: [ CommonModule, - CriteriaRoutingModule, RouterModule, FormsModule, ReactiveFormsModule, @@ -30,6 +29,7 @@ import {NoLoadPaging} from "../../../openaireLibrary/searchPages/searchUtils/no- MatSlideToggleModule, ScrollingModule, NoLoadPaging, + PagingModule, ], declarations: [ CriteriaComponent @@ -41,8 +41,4 @@ import {NoLoadPaging} from "../../../openaireLibrary/searchPages/searchUtils/no- exports: [CriteriaComponent] }) -export class CriteriaModule { - constructor(private iconsService: IconsService) { - this.iconsService.registerIcons([arrow_left, add, close]) - } -} +export class CriteriaModule {} 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 3f15e5e..d86a0d8 100644 --- a/src/app/pages/content-providers/manage-content-providers.component.ts +++ b/src/app/pages/content-providers/manage-content-providers.component.ts @@ -1,5 +1,4 @@ -import {Component, ElementRef, Input, OnInit, ViewChild} from '@angular/core'; -import {Router} from "@angular/router"; +import {Component, OnInit, ViewChild} from '@angular/core'; import {RemoveContentProvidersComponent} from './remove-content-providers.component'; import {Title} from '@angular/platform-browser'; import { @@ -11,41 +10,53 @@ import {properties} from "../../../environments/environment"; import {Subscriber} from "rxjs"; import {CommunityInfo} from "../../openaireLibrary/connect/community/communityInfo"; import {CommunityService} from "../../openaireLibrary/connect/community/community.service"; +import {ContentProvider} from "../../openaireLibrary/utils/entities/contentProvider"; +import {OpenaireEntities} from "../../openaireLibrary/utils/properties/searchFields"; +import {CriteriaComponent} from "./criteria/criteria.component"; @Component({ selector: 'manage-content-providers', template: ` - - + + +
+ +
+
` }) export class ManageContentProvidersComponent implements OnInit { - @Input() communityContentProviders = []; + communityContentProviders: ContentProvider[] = []; @ViewChild(RemoveContentProvidersComponent) removeContentProvidersComponent: RemoveContentProvidersComponent; - @ViewChild('fsModal', { static: true }) fullscreen: FullScreenModalComponent; + @ViewChild('criteria') criteria: CriteriaComponent; + @ViewChild('addContentProvidersModal', { static: true }) addContentProvidersModal: FullScreenModalComponent; + @ViewChild('filtersModal', { static: true }) filtersModal: FullScreenModalComponent; private subscriptions: any[] = []; public showLoadingInRemove: boolean = true; public body: string = "Send from page"; public properties: EnvProperties = properties; public community: CommunityInfo; + public contentProvider: ContentProvider; - constructor(private element: ElementRef, - private title: Title, - private communityService: CommunityService, private _router: Router) { + constructor(private title: Title, + private communityService: CommunityService) { } ngOnInit() { this.subscriptions.push(this.communityService.getCommunityAsObservable().subscribe(community => { this.community = community; if (this.community) { - this.title.setTitle(this.community.shortTitle.toUpperCase() + ' | Content Providers'); + this.title.setTitle(this.community.shortTitle.toUpperCase() + ' | ' + OpenaireEntities.DATASOURCES); this.body = "[Please write your message here]"; this.body = StringUtils.URIEncode(this.body); } @@ -61,18 +72,34 @@ export class ManageContentProvidersComponent implements OnInit { } 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(); + this.addContentProvidersModal.title = "Search and Add " + OpenaireEntities.DATASOURCES; + this.addContentProvidersModal.okButtonText = "Done"; + this.addContentProvidersModal.back = true; + this.addContentProvidersModal.okButton = true; + this.addContentProvidersModal.open(); + } + + public openCriteria(contentProvider: ContentProvider) { + this.contentProvider = contentProvider; + this.filtersModal.title = 'Filters'; + this.filtersModal.okButtonText = "Save"; + this.filtersModal.back = true; + this.filtersModal.okButton = true; + this.filtersModal.open(); + } + + public saveCriteria() { + let callback: Function = () => { + this.removeContentProvidersComponent.getCommunityContentProviders(); + } + this.removeContentProvidersComponent.loading = true; + this.criteria.save(callback); } public communityContentProvidersChanged($event) { this.communityContentProviders = $event.value; this.showLoadingInRemove = false; - - if (this.fullscreen.isOpen) { + if (this.addContentProvidersModal.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 66a80a8..9f5f7ef 100644 --- a/src/app/pages/content-providers/remove-content-providers.component.html +++ b/src/app/pages/content-providers/remove-content-providers.component.html @@ -2,7 +2,7 @@
-
Admin Dashboard - Manage Content Providers +
Admin Dashboard - Manage {{openAIREEntities.DATASOURCES}}

{{community.shortTitle}}

@@ -12,15 +12,14 @@
@@ -31,10 +30,10 @@
-
No content providers found
+
No {{openAIREEntities.DATASOURCES}} found
@@ -70,7 +69,7 @@ - + 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 0e832ae..6e8be80 100644 --- a/src/app/pages/content-providers/remove-content-providers.component.ts +++ b/src/app/pages/content-providers/remove-content-providers.component.ts @@ -9,7 +9,7 @@ import { SearchCommunityDataprovidersService } from '../../openaireLibrary/connect/contentProviders/searchDataproviders.service'; import {RouterHelper} from '../../openaireLibrary/utils/routerHelper.class'; -import {Criteria} from '../../openaireLibrary/utils/entities/contentProvider'; +import {ContentProvider, 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"; @@ -17,6 +17,8 @@ import {CriteriaUtils} from "./criteria-utils"; import {CommunityInfo} from "../../openaireLibrary/connect/community/communityInfo"; import {NotificationHandler} from "../../openaireLibrary/utils/notification-handler"; import {AlertModal} from "../../openaireLibrary/utils/modal/alert"; +import {OpenaireEntities} from "../../openaireLibrary/utils/properties/searchFields"; +import {HelperFunctions} from "../../openaireLibrary/utils/HelperFunctions.class"; @Component({ selector: 'remove-content-providers', @@ -25,12 +27,13 @@ import {AlertModal} from "../../openaireLibrary/utils/modal/alert"; export class RemoveContentProvidersComponent implements OnInit { public routerHelper: RouterHelper = new RouterHelper(); public contentProviderUrl = "https://" + ((properties.environment == "beta" || properties.environment == "development") ? "beta." : "") + "explore.openaire.eu" + properties.searchLinkToDataProvider; - public previewCommunityContentProviders = []; + public previewCommunityContentProviders: ContentProvider[] = []; public errorCodes: ErrorCodes; + public openAIREEntities = OpenaireEntities; @Input() public loading: boolean = true; @Input() public disableAdd: boolean = false; @Input() public community: CommunityInfo; - @Input() public communityContentProviders = []; + @Input() public communityContentProviders: ContentProvider[] = []; @Output() communityContentProvidersChanged = new EventEmitter(); private properties: EnvProperties = properties; private subscriptions: any[] = []; @@ -49,7 +52,7 @@ export class RemoveContentProvidersComponent implements OnInit { private searchText: RegExp = new RegExp(''); public keyword: string = ''; @Output() addContentProviders: EventEmitter = new EventEmitter(); - @Input() public toggle: boolean = true; + @Output() editCriteria: EventEmitter = new EventEmitter(); constructor(private route: ActivatedRoute, private _router: Router, private _fb: FormBuilder, @@ -100,7 +103,7 @@ export class RemoveContentProvidersComponent implements OnInit { let index = this.communityContentProviders.indexOf(this.selectedCommunityContentProvider); this.communityContentProviders.splice(index, 1); this.applyFilters(); - this.handleSuccess('Content Provider successfully removed!') + this.handleSuccess(this.openAIREEntities.DATASOURCE + ' successfully removed!') this.communityContentProvidersChanged.emit({ value: this.communityContentProviders, }); @@ -114,7 +117,7 @@ export class RemoveContentProvidersComponent implements OnInit { public removeContentProvider(communityContentProvider: any) { this.selectedCommunityContentProvider = communityContentProvider; - this.deleteModal.alertTitle = "Remove content provider"; + this.deleteModal.alertTitle = "Remove " + this.openAIREEntities.DATASOURCE; let title = ""; if (communityContentProvider.name) { title = communityContentProvider.name; @@ -128,7 +131,7 @@ export class RemoveContentProvidersComponent implements OnInit { if (communityContentProvider.name && communityContentProvider.acronym) { title += ")"; } - this.deleteModal.message = "Content Provider"; + this.deleteModal.message = this.openAIREEntities.DATASOURCE; if (title) { this.deleteModal.message += " '" + title + "' "; } @@ -140,6 +143,7 @@ export class RemoveContentProvidersComponent implements OnInit { public getCommunityContentProviders() { this.communityContentProviders = []; + this.loading = true; this.subscriptions.push(this._searchCommunityContentProvidersService.searchDataproviders(this.properties, this.community.communityId).subscribe( data => { this.communityContentProviders = data; @@ -157,10 +161,11 @@ export class RemoveContentProvidersComponent implements OnInit { } public updatePage($event) { + HelperFunctions.scroll(); this.page = $event.value; } - get currentPage(): any[] { + get currentPage(): ContentProvider[] { return this.previewCommunityContentProviders.slice((this.page - 1)*this.resultsPerPage, this.page*this.resultsPerPage); } @@ -190,13 +195,7 @@ export class RemoveContentProvidersComponent implements OnInit { NotificationHandler.rise(message, 'danger'); } - goToCriteria(openaireId: string) { - this._router.navigate([openaireId], { - queryParams: { - // community: this.portal, - // provider: openaireId - }, - relativeTo: this.route - }) + openCriteria(contentProvider: ContentProvider) { + this.editCriteria.emit(contentProvider); } } diff --git a/src/app/pages/mining/mining.component.ts b/src/app/pages/mining/mining.component.ts index de410ea..1360314 100644 --- a/src/app/pages/mining/mining.component.ts +++ b/src/app/pages/mining/mining.component.ts @@ -8,7 +8,7 @@ import {Subscription} from "rxjs"; template: `
-
+
diff --git a/src/app/pages/subjects/subjects-edit-form/subjects-edit-form.component.html b/src/app/pages/subjects/subjects-edit-form/subjects-edit-form.component.html index 368fbc3..a9b4205 100644 --- a/src/app/pages/subjects/subjects-edit-form/subjects-edit-form.component.html +++ b/src/app/pages/subjects/subjects-edit-form/subjects-edit-form.component.html @@ -10,26 +10,23 @@
-
-
-
-
-
- -
- -
+
+
+
+ +
+
@@ -80,6 +77,11 @@
+
+ + +
diff --git a/src/app/pages/subjects/subjects-edit-form/subjects-edit-form.module.ts b/src/app/pages/subjects/subjects-edit-form/subjects-edit-form.module.ts index 9c96d1f..28af737 100644 --- a/src/app/pages/subjects/subjects-edit-form/subjects-edit-form.module.ts +++ b/src/app/pages/subjects/subjects-edit-form/subjects-edit-form.module.ts @@ -9,8 +9,6 @@ import {SubjectsService} from '../subjects.service'; import {SubjectsEditFormRoutingModule} from './subjects-edit-form-routing.module'; import {PageContentModule} from '../../../openaireLibrary/dashboard/sharedComponents/page-content/page-content.module'; import {IconsModule} from '../../../openaireLibrary/utils/icons/icons.module'; -import {IconsService} from '../../../openaireLibrary/utils/icons/icons.service'; -import {add, check_circle_outlined, close, edit, remove} from '../../../openaireLibrary/utils/icons/icons'; import {AlertModalModule} from '../../../openaireLibrary/utils/modal/alertModal.module'; import {NoLoadPaging} from '../../../openaireLibrary/searchPages/searchUtils/no-load-paging.module'; import {LoadingModule} from '../../../openaireLibrary/utils/loading/loading.module'; @@ -18,10 +16,11 @@ import {InputModule} from '../../../openaireLibrary/sharedComponents/input/input import {CommunityInfoModule} from '../../community-info/community-info.module'; import {SearchInputModule} from '../../../openaireLibrary/sharedComponents/search-input/search-input.module'; import {FullScreenModalModule} from 'src/app/openaireLibrary/utils/modal/full-screen-modal/full-screen-modal.module'; +import {PagingModule} from "../../../openaireLibrary/utils/paging.module"; @NgModule({ imports: [ - SubjectsEditFormRoutingModule, CommonModule, FormsModule, RouterModule, PageContentModule, IconsModule, AlertModalModule, NoLoadPaging, LoadingModule, InputModule, CommunityInfoModule, SearchInputModule, FullScreenModalModule + SubjectsEditFormRoutingModule, CommonModule, FormsModule, RouterModule, PageContentModule, IconsModule, AlertModalModule, NoLoadPaging, LoadingModule, InputModule, CommunityInfoModule, SearchInputModule, FullScreenModalModule, PagingModule ], declarations: [ SubjectsEditFormComponent @@ -33,8 +32,4 @@ import {FullScreenModalModule} from 'src/app/openaireLibrary/utils/modal/full-sc SubjectsEditFormComponent ] }) -export class SubjectsEditFormModule { - constructor(private iconsService: IconsService) { - this.iconsService.registerIcons([add, edit, remove, close]) - } -} +export class SubjectsEditFormModule {} 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 e0c33a7..7847206 100644 --- a/src/app/pages/users/personal-info/personal-info.component.ts +++ b/src/app/pages/users/personal-info/personal-info.component.ts @@ -90,8 +90,8 @@ declare var UIkit;
-
- +
+
{{affiliation.value.name}}
@@ -148,7 +148,7 @@ declare var UIkit; if you have any inquiries.
-
@@ -161,9 +161,9 @@ declare var UIkit;
- + - + Your personal information has been successfully saved.

This information will be visible in Curators page of Research Community Dashboard, which is disabled. diff --git a/src/assets/openaire-theme b/src/assets/openaire-theme index 35bca0f..8f8b85e 160000 --- a/src/assets/openaire-theme +++ b/src/assets/openaire-theme @@ -1 +1 @@ -Subproject commit 35bca0f68bf19337413167ecf770f1027902964f +Subproject commit 8f8b85e69d5c505ed59b12b8b70348096f339775 From 4c08b4dad3d8461d7c4bd5345bcc75d47566ac7e Mon Sep 17 00:00:00 2001 From: "konstantina.galouni" Date: Tue, 5 Jul 2022 01:31:56 +0300 Subject: [PATCH 2/3] [Connect Admin | Library | new-theme]: Redesign of remove/add projects and zenodo communities pages according to the new mocks. 1. searchProjects.service.ts: Added "params" parameter in "getFunders()" method. 2. resultsAndPagesNum.component.ts: Do not show number of results and pages when no results. 3. manage-communities.module.ts: Remove "group" and "lock" icons from registerIcons call. 4. add-projects.component & communityProjects.module.ts & manage-projects.component.ts & remove-projects.component: Redesign of remove/add projects pages according to the new mocks. 5. add-zenodo-communities.component & manage-zenodo-communities.component & preview-z-community.component.ts & zenodo-communities.component.ts & zenodo-communities.module.ts: Redesign of remove/add zenodo communities pages according to the new mocks. --- .../manage-communities.module.ts | 2 +- .../projects/add-projects.component.html | 230 ++++++++----- .../pages/projects/add-projects.component.ts | 321 ++++++++---------- .../projects/communityProjects.module.ts | 10 +- .../projects/manage-projects.component.ts | 73 ++-- .../projects/remove-projects.component.html | 230 +++++++------ .../projects/remove-projects.component.ts | 64 ++-- .../add-zenodo-communities.component.html | 101 +++--- .../add-zenodo-communities.component.ts | 243 ++++++------- .../manage-zenodo-communities.component.html | 118 ++++--- .../manage-zenodo-communities.component.ts | 139 ++++---- .../preview-z-community.component.ts | 48 +-- .../zenodo-communities.component.ts | 172 +++++----- .../zenodo-communities.module.ts | 9 +- 14 files changed, 867 insertions(+), 893 deletions(-) diff --git a/src/app/pages/manage-communities/manage-communities.module.ts b/src/app/pages/manage-communities/manage-communities.module.ts index bf73f92..9077ee0 100644 --- a/src/app/pages/manage-communities/manage-communities.module.ts +++ b/src/app/pages/manage-communities/manage-communities.module.ts @@ -24,6 +24,6 @@ import {SearchInputModule} from '../../openaireLibrary/sharedComponents/search-i }) export class ManageCommunitiesModule { constructor(private iconsService: IconsService) { - this.iconsService.registerIcons([group, lock, earth]); + this.iconsService.registerIcons([earth]); } } diff --git a/src/app/pages/projects/add-projects.component.html b/src/app/pages/projects/add-projects.component.html index b531824..013c485 100644 --- a/src/app/pages/projects/add-projects.component.html +++ b/src/app/pages/projects/add-projects.component.html @@ -1,110 +1,152 @@ -
-
-
- Filter by: -
+ +

+ +

+ + + +
+
+

Filters

+ + Clear All + +
+ + + + +
+ No filters available + Filters temporarily unavailable. Please try again later. +
+
    +
  • + + +
  • +
-
-
-
+ + +
+
+ +
+ If you cannot find a funder that is relevant for your community, please contact us + ({{properties.feedbackmailForMissingEntities}}) + and we will try to get the funder on board!
+
- -
-
- -
-
-
-
No OpenAIRE projects available
-
- If you wish to suggest a new funder to include or report a missing project, please contact us via - - feedback@openaire.eu. -
- -
An Error Occurred. No OpenAIRE projects found
-
Service temporarily unavailable. Please try again later.
-
No OpenAIRE projects found
- +
+
+
+
-
- - - - - - - - - - - - - - +
- - - - - - - - - - -
+
+
+
\ No newline at end of file diff --git a/src/app/pages/projects/add-projects.component.ts b/src/app/pages/projects/add-projects.component.ts index cdfa9fe..eeaba05 100644 --- a/src/app/pages/projects/add-projects.component.ts +++ b/src/app/pages/projects/add-projects.component.ts @@ -9,15 +9,16 @@ import {RouterHelper} from '../../openaireLibrary/utils/routerHelper.class'; import {StringUtils} from '../../openaireLibrary/utils/string-utils.class'; import {ManageCommunityProjectsService} from '../../services/manageProjects.service'; -import {Session} from '../../openaireLibrary/login/utils/helper.class'; -import {LoginErrorCodes} from '../../openaireLibrary/login/utils/guardHelper.class'; import {properties} from "../../../environments/environment"; import {Subscriber} from "rxjs"; import {FormBuilder, FormGroup} from "@angular/forms"; -import {Option} from "../../openaireLibrary/sharedComponents/input/input.component"; import {debounceTime, distinctUntilChanged} from "rxjs/operators"; import {ResultPreview} from "../../openaireLibrary/utils/result-preview/result-preview"; import {SearchInputComponent} from "../../openaireLibrary/sharedComponents/search-input/search-input.component"; +import {CommunityInfo} from "../../openaireLibrary/connect/community/communityInfo"; +import {OpenaireEntities} from "../../openaireLibrary/utils/properties/searchFields"; +import {Filter, Value} from "../../openaireLibrary/searchPages/searchUtils/searchHelperClasses.class"; +import {HelperFunctions} from "../../openaireLibrary/utils/HelperFunctions.class"; declare var UIkit; @@ -30,7 +31,7 @@ export class AddProjectsComponent implements OnInit { private subscriptions: any[] = []; public subResults: any; - private community: string = ''; + @Input() community: CommunityInfo = null; public routerHelper: RouterHelper = new RouterHelper(); public properties: EnvProperties = properties; @@ -46,35 +47,30 @@ export class AddProjectsComponent implements OnInit { public selectedFunderId: string = ""; filterForm: FormGroup; - allOptions: Option[] = []; + funders: Filter = null; @ViewChild('searchInputComponent') searchInputComponent: SearchInputComponent; private projectUrl: string = "https://" + ((properties.environment == "beta" || properties.environment == "development") ? "beta." : "") + "explore.openaire.eu" + properties.searchLinkToProject; public body: string = "Send from page"; - @Output() toggleView: EventEmitter = new EventEmitter(); + openaireEntities = OpenaireEntities; constructor(private route: ActivatedRoute, private _router: Router, private _searchProjectsService: SearchProjectsService, private _manageCommunityProjectsService: ManageCommunityProjectsService, private _fb: FormBuilder) { this.errorCodes = new ErrorCodes(); this.openaireSearchUtils.status = this.errorCodes.LOADING; + this.openaireSearchUtils.refineStatus = this.errorCodes.LOADING; } ngOnInit() { - this.subscriptions.push(this.route.params.subscribe(params => { - this.openaireSearchUtils.status = this.errorCodes.LOADING; + this.openaireSearchUtils.status = this.errorCodes.LOADING; + this.openaireSearchUtils.refineStatus = this.errorCodes.LOADING; + this.getFunders(); + this._getOpenaireProjects("", 1, this.resultsPerPage); - this.community = params['community']; - // this.projectUrl = "https://" + ((this.properties.environment == "beta" || this.properties.environment == "development") ? "beta." : "") - // + this.community + ".openaire.eu" + this.properties.searchLinkToProject; - - this.getFunders(); - this._getOpenaireProjects("", 1, this.resultsPerPage); - - this.body = "[Please write your message here]"; - this.body = StringUtils.URIEncode(this.body); - })); + this.body = "[Please write your message here]"; + this.body = StringUtils.URIEncode(this.body); this.openaireSearchUtils.keyword = ""; @@ -88,19 +84,6 @@ export class AddProjectsComponent implements OnInit { .subscribe(value => { this.keywordChanged(value); })); - - this.subscriptions.push(this.filterForm.get('funder').valueChanges - .pipe(debounceTime(1000), distinctUntilChanged()) - .subscribe(value => { - // console.log("value: ",value); - if (value == null) { - // console.log("will be called funder changed: null"); - this.funderChanged("", ""); - } else if (value && value.id != undefined && value.id != this.selectedFunderId) { - // console.log("will be called funder changed: name="+value.label+", id="+value.id); - this.funderChanged(value.id, value.label); - } - })); } public ngOnDestroy() { @@ -115,65 +98,55 @@ export class AddProjectsComponent implements OnInit { } } + get loading() { + return this.openaireSearchUtils.status == this.errorCodes.LOADING + } + + get disabled() { + return this.openaireSearchUtils.status == this.errorCodes.LOADING || this.openaireSearchUtils.refineStatus == this.errorCodes.LOADING; + } + public addProject(project: SearchResult) { - if (!Session.isLoggedIn()) { - this._router.navigate(['/user-info'], { - queryParams: { - "errorCode": LoginErrorCodes.NOT_VALID, - "redirectUrl": this._router.url - } - }); - } else { - this.subscriptions.push(this._manageCommunityProjectsService.addProject(this.properties, this.community, project).subscribe( - data => { - this.communityProjects.push(data); - UIkit.notification('Project successfully added!', { - status: 'success', - timeout: 6000, - pos: 'bottom-right' - }); - this.communityProjectsChanged.emit({ - value: this.communityProjects, - }); - }, - err => { - this.handleError('An error has been occurred. Try again later!'); - console.error(err.status); - } - )); - } + this.subscriptions.push(this._manageCommunityProjectsService.addProject(this.properties, this.community.communityId, project).subscribe( + data => { + this.communityProjects.push(data); + UIkit.notification('Project successfully added!', { + status: 'success', + timeout: 6000, + pos: 'bottom-right' + }); + this.communityProjectsChanged.emit({ + value: this.communityProjects, + }); + }, + err => { + this.handleError('An error has been occurred. Try again later!'); + console.error(err.status); + } + )); } public removeProject(project: any) { - if (!Session.isLoggedIn()) { - this._router.navigate(['/user-info'], { - queryParams: { - "errorCode": LoginErrorCodes.NOT_VALID, - "redirectUrl": this._router.url - } - }); - } else { - let communityProject = this.getCommunityProject(project); - let projectId: string = communityProject['id']; - this.subscriptions.push(this._manageCommunityProjectsService.removeProject(this.properties, this.community, projectId).subscribe( - data => { - let index = this.communityProjects.indexOf(communityProject); - this.communityProjects.splice(index, 1); - UIkit.notification('Project successfully removed!', { - status: 'success', - timeout: 6000, - pos: 'bottom-right' - }); - this.communityProjectsChanged.emit({ - value: this.communityProjects, - }); - }, - err => { - this.handleError('An error has been occurred. Try again later!'); - console.error(err); - } - )); - } + let communityProject = this.getCommunityProject(project); + let projectId: string = communityProject['id']; + this.subscriptions.push(this._manageCommunityProjectsService.removeProject(this.properties, this.community.communityId, projectId).subscribe( + data => { + let index = this.communityProjects.indexOf(communityProject); + this.communityProjects.splice(index, 1); + UIkit.notification('Project successfully removed!', { + status: 'success', + timeout: 6000, + pos: 'bottom-right' + }); + this.communityProjectsChanged.emit({ + value: this.communityProjects, + }); + }, + err => { + this.handleError('An error has been occurred. Try again later!'); + console.error(err); + } + )); } public getCommunityProject(project: any): string { @@ -189,29 +162,27 @@ export class AddProjectsComponent implements OnInit { } getFunders() { - if (!Session.isLoggedIn()) { - this._router.navigate(['/user-info'], { - queryParams: { - "errorCode": LoginErrorCodes.NOT_VALID, - "redirectUrl": this._router.url - } - }); - } else { - this.subscriptions.push(this._searchProjectsService.getFunders(this.properties).subscribe( - data => { - let funders = data[1]; - this.allOptions = []; - let i; - for (i = 0; i < funders.length; i++) { - let funder = funders[i]; - if (funder && funder['id']) { - this.allOptions.push({label: funder['name'], value: {id: funder['id'], label: funder['name']}}); - } + this.openaireSearchUtils.refineStatus = this.errorCodes.LOADING; + this.subscriptions.push(this._searchProjectsService.getFunders(this.queryParameters, this.properties).subscribe( + data => { + this.funders = data[1][0]; + this.funders.values.map((value) => { + if(value.id == this.selectedFunderId) { + value.selected = true; + this.funders.countSelectedValues++; } - }, - err => console.error("Server error fetching funders: ", err) - )); - } + }) + if(this.funders.values && this.funders.values.length == 0) { + this.openaireSearchUtils.refineStatus = this.errorCodes.NONE; + } else { + this.openaireSearchUtils.refineStatus = this.errorCodes.DONE; + } + }, + err => { + this.openaireSearchUtils.refineStatus = this.errorCodes.ERROR; + console.error("Server error fetching funders: ", err) + } + )); } public getResultPreview(result: SearchResult): ResultPreview { @@ -219,63 +190,37 @@ export class AddProjectsComponent implements OnInit { } private _getOpenaireProjects(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; - if (this.openaireSearchUtils.status == this.errorCodes.LOADING) { - this.openaireSearchUtils.status = this.errorCodes.LOADING; + this.openaireProjects = []; + this.openaireSearchUtils.totalResults = 0; - this.openaireProjects = []; - this.openaireSearchUtils.totalResults = 0; - - if (this.subResults) { - this.subResults.unsubscribe(); - } - this.subResults = this._searchProjectsService.searchProjects(parameters, null, page, size, [], this.properties).subscribe( - data => { - this.openaireSearchUtils.totalResults = data[0]; - this.openaireProjects = data[1]; - - //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.subResults) { + this.subResults.unsubscribe(); } + this.subResults = this._searchProjectsService.searchProjects(parameters, null, page, size, [], this.properties).subscribe( + data => { + this.openaireSearchUtils.totalResults = data[0]; + this.openaireProjects = data[1]; + + this.openaireSearchUtils.status = this.errorCodes.DONE; + if (this.openaireSearchUtils.totalResults == 0) { + this.openaireSearchUtils.status = this.errorCodes.NONE; + } + }, + err => { + console.error(err); + //TODO check erros (service not available, bad request) + if (err.status == '404') { + this.openaireSearchUtils.status = this.errorCodes.NOT_FOUND; + } else if (err.status == '500') { + this.openaireSearchUtils.status = this.errorCodes.ERROR; + } else { + this.openaireSearchUtils.status = this.errorCodes.NOT_AVAILABLE; + } + } + ); } } @@ -293,9 +238,8 @@ export class AddProjectsComponent implements OnInit { this.goTo(1); } - funderChanged(funderId: string, funderName: string) { - this.selectedFunderId = funderId; - + funderChanged(filter: Filter) { + this.getSelectedValues(filter); this.buildQueryParameters(); this.goTo(1); } @@ -313,16 +257,17 @@ export class AddProjectsComponent implements OnInit { } } - goTo(page: number = 1) { + goTo(page: number = 1, refineQuery: boolean = true) { + HelperFunctions.scroll(); this.openaireSearchUtils.page = page; this.openaireSearchUtils.status = this.errorCodes.LOADING; + if(refineQuery) { + this.openaireSearchUtils.refineStatus = this.errorCodes.LOADING; + this.getFunders(); + } this._getOpenaireProjects(this.queryParameters, page, this.resultsPerPage); } - back() { - this.toggleView.emit(null); - } - public onSearchClose() { this.openaireSearchUtils.keyword = this.filterForm.get('keyword').value; } @@ -339,4 +284,40 @@ export class AddProjectsComponent implements OnInit { pos: 'bottom-right' }); } + + getSelectedValues(filter): any { + var selected = []; + this.selectedFunderId = ""; + if (filter.countSelectedValues > 0) { + for (var i = 0; i < filter.values.length; i++) { + if (filter.values[i].selected) { + selected.push(filter.values[i]); + this.selectedFunderId = filter.values[i].id; + } + } + } + return selected; + } + + clearFilters() { + for (var j = 0; j < this.funders.countSelectedValues; j++) { + if (this.funders.values[j].selected) { + this.removeFilter(this.funders.values[j], this.funders); + break; + } + } + } + + public removeFilter(value: Value, filter: Filter) { + this.selectedFunderId = ""; + filter.countSelectedValues--; + if (value.selected == true) { + value.selected = false; + } + if (filter.filterType == "radio") { + filter.radioValue = ""; + } + this.buildQueryParameters(); + this.goTo(1); + } } diff --git a/src/app/pages/projects/communityProjects.module.ts b/src/app/pages/projects/communityProjects.module.ts index 9596c63..e7b935f 100644 --- a/src/app/pages/projects/communityProjects.module.ts +++ b/src/app/pages/projects/communityProjects.module.ts @@ -20,11 +20,11 @@ import {SearchInputModule} from "../../openaireLibrary/sharedComponents/search-i import {NoLoadPaging} from "../../openaireLibrary/searchPages/searchUtils/no-load-paging.module"; 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, 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 {ErrorMessagesModule} from "../../openaireLibrary/utils/errorMessages.module"; +import {DropdownFilterModule} from "../../openaireLibrary/utils/dropdown-filter/dropdown-filter.module"; +import {SearchFilterModule} from "../../openaireLibrary/searchPages/searchUtils/searchFilter.module"; @NgModule({ imports: [ @@ -46,7 +46,7 @@ import {ErrorMessagesModule} from "../../openaireLibrary/utils/errorMessages.mod path: '', component: ManageProjectsComponent } ]), - NoLoadPaging, LoadingModule, IconsModule, FullScreenModalModule, ResultPreviewModule + NoLoadPaging, LoadingModule, IconsModule, FullScreenModalModule, ResultPreviewModule, DropdownFilterModule, SearchFilterModule ], declarations: [ ManageProjectsComponent, @@ -60,7 +60,5 @@ import {ErrorMessagesModule} from "../../openaireLibrary/utils/errorMessages.mod exports: [ManageProjectsComponent] }) export class CommunityProjectsModule { - constructor(private iconsService: IconsService) { - this.iconsService.registerIcons([remove_circle_outline, add, close, arrow_left]); - } + constructor() {} } diff --git a/src/app/pages/projects/manage-projects.component.ts b/src/app/pages/projects/manage-projects.component.ts index 69d0a23..166ccc8 100644 --- a/src/app/pages/projects/manage-projects.component.ts +++ b/src/app/pages/projects/manage-projects.component.ts @@ -3,39 +3,26 @@ import {ActivatedRoute, Router} from "@angular/router"; import {RemoveProjectsComponent} from './remove-projects.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 {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 {OpenaireEntities} from "../../openaireLibrary/utils/properties/searchFields"; +import {CommunityService} from "../../openaireLibrary/connect/community/community.service"; @Component({ selector: 'manage-projects', template: ` - + - -
- -
-
- If you cannot find a funder that is relevant for your community, please contact us - ({{properties.feedbackmailForMissingEntities}}) - and we will try to get the funder on board! -
-
-
- - + + ` }) @@ -44,34 +31,27 @@ export class ManageProjectsComponent implements OnInit { @Input() communityProjects = []; @ViewChild(RemoveProjectsComponent) removeProjectsComponent: RemoveProjectsComponent; @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 = null; constructor(private element: ElementRef, private title: Title, - private route: ActivatedRoute, private _router: Router) { + private route: ActivatedRoute, private _router: Router, + private communityService: CommunityService) { } ngOnInit() { - this.subscriptions.push(this.route.params.subscribe(params => { - this.communityId = params['community']; - - if (this.communityId) { - this.title.setTitle(this.communityId.toUpperCase() + ' | Projects'); + this.subscriptions.push(this.communityService.getCommunityAsObservable().subscribe(community => { + this.community = community; + if (this.community) { + this.title.setTitle(this.community.shortTitle.toUpperCase() + ' | ' + OpenaireEntities.PROJECTS); this.body = "[Please write your message here]"; this.body = StringUtils.URIEncode(this.body); } - this.fullscreen.title = "Search and Add Projects"; - this.fullscreen.okButtonText = "Done"; - this.fullscreen.okButton = true; })); } @@ -83,26 +63,19 @@ export class ManageProjectsComponent 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 openAddProjects() { + this.fullscreen.title = "Search and Add "+OpenaireEntities.PROJECTS; + this.fullscreen.okButtonText = "Done"; + this.fullscreen.back = true; + this.fullscreen.okButton = true; + this.fullscreen.open(); } public communityProjectsChanged($event) { this.communityProjects = $event.value; this.showLoadingInRemove = false; - if (this.toggle) { + if (this.fullscreen.isOpen) { this.removeProjectsComponent.applyFilters(); this.removeProjectsComponent.createFunderFilter(); } diff --git a/src/app/pages/projects/remove-projects.component.html b/src/app/pages/projects/remove-projects.component.html index 1aa8e88..3ac487f 100644 --- a/src/app/pages/projects/remove-projects.component.html +++ b/src/app/pages/projects/remove-projects.component.html @@ -1,116 +1,138 @@ -
+
- -
-
- - - - +
+
+
Admin Dashboard - Manage {{openaireEntiites.PROJECTS}} +
+

{{community.shortTitle}}

-
+
-
- +
+
+
+
+ +
+
+
+
+
-
-
-
-
- Filter by: -
-
-
-
-
- Sort by: -
-
-
-
-
- - -
-
-
No projects for {{name}}
-
-
-
-
-
-
- - {{item.name}} - ({{item.acronym}}) - [no title available] - - - - {{item.name}} - ({{item.acronym}}) - [no title available] - -
-
- Grant ID: - {{item.grantId}} -
-
- Funder: - {{item.funder}} -
-
-
- -
-
-
- - +
+
+ +
Funder
+ +
+
+
+
+ +
+ +
- +
+
+ +
+
+ +
+
+
No {{openaireEntiites.PROJECTS | lowercase}} for {{community.shortTitle}}
+
+
+
+
+
+
+ + {{item.name}} + ({{item.acronym}}) + [no title available] + + + {{item.name}} + ({{item.acronym}}) + [no title available] + +
+
+
+ Grant ID: + {{item.grantId}} +
+
+ Funder: + {{item.funder}} +
+
+
+ +
+
+
+
+ + +
+
+
+ + +
diff --git a/src/app/pages/projects/remove-projects.component.ts b/src/app/pages/projects/remove-projects.component.ts index d4224eb..6a3b525 100644 --- a/src/app/pages/projects/remove-projects.component.ts +++ b/src/app/pages/projects/remove-projects.component.ts @@ -16,6 +16,10 @@ import {properties} from "../../../environments/environment"; import {CommunityService} from "../../openaireLibrary/connect/community/community.service"; import {Option} from "../../openaireLibrary/sharedComponents/input/input.component"; import {SearchInputComponent} from "../../openaireLibrary/sharedComponents/search-input/search-input.component"; +import {DropdownFilterComponent} from "../../openaireLibrary/utils/dropdown-filter/dropdown-filter.component"; +import {OpenaireEntities} from "../../openaireLibrary/utils/properties/searchFields"; +import {CommunityInfo} from "../../openaireLibrary/connect/community/communityInfo"; +import {HelperFunctions} from "../../openaireLibrary/utils/HelperFunctions.class"; declare var UIkit; @@ -25,16 +29,16 @@ declare var UIkit; }) export class RemoveProjectsComponent implements OnInit { - public portal: string; - public name: string; + @Input() public community: CommunityInfo; + @Input() public loading: boolean = true; + @Input() public disableAdd: boolean = false; + @Output() addProjects: EventEmitter = new EventEmitter(); private subscriptions: any[] = []; public routerHelper: RouterHelper = new RouterHelper(); private projectUrl = "https://" + ((properties.environment == "beta" || properties.environment == "development") ? "beta." : "") + "explore.openaire.eu" + properties.searchLinkToProject.split("?")[0]; - @Input() public showLoading: boolean = true; - @Output() communityProjectsChanged = new EventEmitter(); @Input() public communityProjects = []; public previewCommunityProjects = []; @@ -55,6 +59,7 @@ export class RemoveProjectsComponent implements OnInit { public fundersCtrl: FormArray; private searchText: RegExp = new RegExp(''); public keyword: string = ''; + selectedFunders: string[] = []; allOptions: Option[] = []; sortOptions: Option[] = [ //{label:"Title (desc) ", value:{ sort: "title",descending: true }}, @@ -65,8 +70,9 @@ export class RemoveProjectsComponent implements OnInit { {label: "Funder ", value: {sort: "funder", descending: false}} ]; - @Output() toggleView: EventEmitter = new EventEmitter(); - @Input() public toggle: boolean = true; + public stickyPageHeader: boolean = false; + + public openaireEntiites = OpenaireEntities; constructor(private route: ActivatedRoute, private _router: Router, private _fb: FormBuilder, @@ -105,11 +111,10 @@ export class RemoveProjectsComponent implements OnInit { this.subscriptions.push(this.communityService.getCommunityAsObservable().subscribe(community => { if (community) { - this.portal = community.communityId; - this.name = community.shortTitle; + this.community = community; this.projectUrl = "https://" + ((this.properties.environment == "beta" || this.properties.environment == "development") ? "beta." : "") - + this.portal + ".openaire.eu" + this.properties.searchLinkToProject.split("?")[0]; + + this.community.communityId + ".openaire.eu" + this.properties.searchLinkToProject.split("?")[0]; this.keyword = ''; this._getCommunityProjects(); @@ -155,14 +160,14 @@ export class RemoveProjectsComponent implements OnInit { } }); } else { - this.subscriptions.push(this._manageCommunityProjectsService.removeProject(this.properties, this.portal, this.selectedCommunityProject.id).subscribe( + this.subscriptions.push(this._manageCommunityProjectsService.removeProject(this.properties, this.community.communityId, this.selectedCommunityProject.id).subscribe( data => { let index = this.communityProjects.indexOf(this.selectedCommunityProject); this.communityProjects.splice(index, 1); this.applyFilters(); - UIkit.notification('Project successfully removed!', { + UIkit.notification(OpenaireEntities.PROJECT+' successfully removed!', { status: 'success', timeout: 6000, pos: 'bottom-right' @@ -195,7 +200,7 @@ export class RemoveProjectsComponent implements OnInit { this.selectedCommunityProject = communityProject; this.alertModalDeleteCommunity.cancelButton = true; this.alertModalDeleteCommunity.okButton = true; - this.alertModalDeleteCommunity.alertTitle = "Remove project?"; + this.alertModalDeleteCommunity.alertTitle = "Remove "+OpenaireEntities.PROJECT; let title = ""; if (communityProject.name) { title = communityProject.name; @@ -209,11 +214,11 @@ export class RemoveProjectsComponent implements OnInit { if (communityProject.name && communityProject.acronym) { title += ")"; } - this.alertModalDeleteCommunity.message = "Project"; + this.alertModalDeleteCommunity.message = OpenaireEntities.PROJECT; if (title) { - this.alertModalDeleteCommunity.message += " '" + title + "' "; + this.alertModalDeleteCommunity.message += " " + title + " "; } - this.alertModalDeleteCommunity.message += "will be removed from your community. Are you sure?"; + this.alertModalDeleteCommunity.message += "will be removed from your "+OpenaireEntities.COMMUNITY.toLowerCase()+". Are you sure?"; this.alertModalDeleteCommunity.okButtonText = "Yes"; this.alertModalDeleteCommunity.open(); } @@ -234,7 +239,7 @@ export class RemoveProjectsComponent implements OnInit { this.communitySearchUtils.page = 1; this.communitySearchUtils.keyword = ""; - this.subscriptions.push(this._searchCommunityProjectsService.searchProjects(this.properties, this.portal).subscribe( + this.subscriptions.push(this._searchCommunityProjectsService.searchProjects(this.properties, this.community.communityId).subscribe( data => { this.communityProjects = data; this.previewCommunityProjects = this.communityProjects; @@ -249,7 +254,7 @@ export class RemoveProjectsComponent implements OnInit { this.createFunderFilter(); - this.showLoading = false; + this.loading = false; }, err => { console.error(err); @@ -263,7 +268,7 @@ export class RemoveProjectsComponent implements OnInit { this.communitySearchUtils.status = this.errorCodes.NOT_AVAILABLE; } - this.showLoading = false; + this.loading = false; } )); } @@ -283,11 +288,12 @@ export class RemoveProjectsComponent implements OnInit { } public updatePage($event) { + HelperFunctions.scroll(); this.page = $event.value; } addNew() { - this.toggleView.emit(null); + this.addProjects.emit(); } public applyFilters() { @@ -367,4 +373,24 @@ export class RemoveProjectsComponent implements OnInit { pos: 'bottom-right' }); } + + select(value: string, event, dropdownFilter: DropdownFilterComponent) { + if(event.target instanceof HTMLInputElement) { + dropdownFilter.closeDropdown(); + if(event.target.checked && !this.selectedFunders.find(entity => value === entity)) { + this.selectedFunders.push(value); + this.fundersCtrl.setControl(this.fundersCtrl.value.length, this._fb.control(value)); + } else if(!event.target.checked) { + let index = this.selectedFunders.indexOf(value); + if(index !== -1) { + this.selectedFunders.splice(index, 1); + this.fundersCtrl.removeAt(index); + } + } + } + } + + isSelected(value: string) { + return this.filterForm && this.filterForm.get('funder').value.find(funder => funder === value) + } } diff --git a/src/app/pages/zenodo-communities/add-zenodo-communities.component.html b/src/app/pages/zenodo-communities/add-zenodo-communities.component.html index 23ae98e..140d89d 100644 --- a/src/app/pages/zenodo-communities/add-zenodo-communities.component.html +++ b/src/app/pages/zenodo-communities/add-zenodo-communities.component.html @@ -1,62 +1,59 @@ -
-
- +
+
-
- -
-
-
No zenodo communities found +
+
+
-
-
- - -
    -
  • -
    -
    - -
    - -
    -
    -
    -
    - Master zenodo community -
    - -
    - +
    +
    +
    No zenodo communities found
    +
    + + + +
    +
    +
    +
    + +
    +
    -
    -
  • -
- - -
+
+ + +
+ +
+
\ No newline at end of file diff --git a/src/app/pages/zenodo-communities/add-zenodo-communities.component.ts b/src/app/pages/zenodo-communities/add-zenodo-communities.component.ts index 0f00c58..9bea3ff 100644 --- a/src/app/pages/zenodo-communities/add-zenodo-communities.component.ts +++ b/src/app/pages/zenodo-communities/add-zenodo-communities.component.ts @@ -1,16 +1,16 @@ -import {Component, Input, OnInit, ViewChild} from '@angular/core'; +import {Component, EventEmitter, Input, OnInit, Output, ViewChild} from '@angular/core'; import {FormBuilder, FormControl} from '@angular/forms'; import {ActivatedRoute, Router} from '@angular/router'; import {EnvProperties} from '../../openaireLibrary/utils/properties/env-properties'; +import {properties} from "../../../environments/environment"; import {ErrorCodes} from '../../openaireLibrary/utils/properties/errorCodes'; import {SearchUtilsClass} from '../../openaireLibrary/searchPages/searchUtils/searchUtils.class'; import {ZenodoCommunitiesService} from '../../openaireLibrary/connect/zenodoCommunities/zenodo-communities.service'; -import {Session} from '../../openaireLibrary/login/utils/helper.class'; -import {LoginErrorCodes} from '../../openaireLibrary/login/utils/guardHelper.class'; import {ManageZenodoCommunitiesService} from '../../services/manageZenodoCommunities.service'; -import {SearchInputComponent} from '../../openaireLibrary/sharedComponents/search-input/search-input.component'; import {Subject, Subscription} from 'rxjs'; import {debounceTime, distinctUntilChanged} from 'rxjs/operators'; +import {CommunityInfo} from "../../openaireLibrary/connect/community/communityInfo"; +import {HelperFunctions} from "../../openaireLibrary/utils/HelperFunctions.class"; declare var UIkit; @@ -22,9 +22,8 @@ export class AddZenodoCommunitiesComponent implements OnInit { public zenodoCommunities = null; // zenodo search API results public totalZenodoCommunities = null; - @Input() properties: EnvProperties = null; - @Input() communityId = null; - @ViewChild('searchInputComponent') searchInputComponent: SearchInputComponent; + properties: EnvProperties = properties; + @Input() community: CommunityInfo = null; public filterForm: FormControl; private subscriptions: any[] = []; public subResults: any; @@ -34,7 +33,8 @@ export class AddZenodoCommunitiesComponent implements OnInit { public rowsOnPage = 10; @Input() masterCommunity = null; @Input() selectedCommunities = []; - + @Output() zenodoCommunitiesChanged = new EventEmitter(); + constructor(private route: ActivatedRoute, private _router: Router, public _fb: FormBuilder, @@ -58,37 +58,27 @@ export class AddZenodoCommunitiesComponent implements OnInit { })); this.zenodoCommunitySearchUtils.keyword = ""; - if (!Session.isLoggedIn()) { - this._router.navigate(['/user-info'], { - queryParams: { - "errorCode": LoginErrorCodes.NOT_VALID, - "redirectUrl": this._router.url - } - }); - } else { - this.zenodoCommunitySearchUtils.status = this.errorCodes.LOADING; - if (this.communityId != null && this.communityId != '') { - this._zenodoCommunitieService.getZenodoCommunities(this.properties, this.properties.zenodoCommunities + "?page=" + this.zenodoCommunitySearchUtils.page + "&size=" + this.rowsOnPage).subscribe( - result => { - this.zenodoCommunities = result[0]; - this.totalZenodoCommunities = result[1]; - this.zenodoCommunitySearchUtils.totalResults = result[1]; - this.zenodoCommunitySearchUtils.page = 1; - this.zenodoCommunitySearchUtils.size = this.rowsOnPage; - if (this.totalZenodoCommunities == 0) { - this.zenodoCommunitySearchUtils.status = this.errorCodes.NONE; - } else { - this.zenodoCommunitySearchUtils.status = this.errorCodes.DONE; - } - - }, - error => { - this.zenodoCommunitySearchUtils.status = this.errorCodes.ERROR; + this.zenodoCommunitySearchUtils.status = this.errorCodes.LOADING; + if (this.community.communityId != null && this.community.communityId != '') { + this._zenodoCommunitieService.getZenodoCommunities(this.properties, this.properties.zenodoCommunities + "?page=" + this.zenodoCommunitySearchUtils.page + "&size=" + this.rowsOnPage).subscribe( + result => { + this.zenodoCommunities = result[0]; + this.totalZenodoCommunities = result[1]; + this.zenodoCommunitySearchUtils.totalResults = result[1]; + this.zenodoCommunitySearchUtils.page = 1; + this.zenodoCommunitySearchUtils.size = this.rowsOnPage; + if (this.totalZenodoCommunities == 0) { + this.zenodoCommunitySearchUtils.status = this.errorCodes.NONE; + } else { + this.zenodoCommunitySearchUtils.status = this.errorCodes.DONE; } - ); - } + + }, + error => { + this.zenodoCommunitySearchUtils.status = this.errorCodes.ERROR; + } + ); } - } ngOnDestroy() { @@ -103,41 +93,33 @@ export class AddZenodoCommunitiesComponent implements OnInit { } public goTo(page: number = 1) { - if (!Session.isLoggedIn()) { - this._router.navigate(['/user-info'], { - queryParams: { - "errorCode": LoginErrorCodes.NOT_VALID, - "redirectUrl": this._router.url - } - }); - } else { - this.zenodoCommunitySearchUtils.page = page; - this.zenodoCommunitySearchUtils.status = this.errorCodes.LOADING; - if(this.subResults){ - this.subResults.unsubscribe(); - } - this.subResults = this._zenodoCommunitieService.getZenodoCommunities(this.properties, - this.properties.zenodoCommunities + "?page=" + this.zenodoCommunitySearchUtils.page - + "&size=" + this.rowsOnPage - + ((this.zenodoCommunitySearchUtils.keyword) ? ("&q=" + this.zenodoCommunitySearchUtils.keyword) : "") - ).subscribe( - result => { - this.zenodoCommunities = result[0]; - this.totalZenodoCommunities = result[1]; - this.zenodoCommunitySearchUtils.totalResults = result[1]; - this.zenodoCommunitySearchUtils.size = this.rowsOnPage; - if (this.totalZenodoCommunities == 0) { - this.zenodoCommunitySearchUtils.status = this.errorCodes.NONE; - } else { - this.zenodoCommunitySearchUtils.status = this.errorCodes.DONE; - } - - }, - error => { - this.zenodoCommunitySearchUtils.status = this.errorCodes.ERROR; - } - ); + HelperFunctions.scroll(); + this.zenodoCommunitySearchUtils.page = page; + this.zenodoCommunitySearchUtils.status = this.errorCodes.LOADING; + if(this.subResults){ + this.subResults.unsubscribe(); } + this.subResults = this._zenodoCommunitieService.getZenodoCommunities(this.properties, + this.properties.zenodoCommunities + "?page=" + this.zenodoCommunitySearchUtils.page + + "&size=" + this.rowsOnPage + + ((this.zenodoCommunitySearchUtils.keyword) ? ("&q=" + this.zenodoCommunitySearchUtils.keyword) : "") + ).subscribe( + result => { + this.zenodoCommunities = result[0]; + this.totalZenodoCommunities = result[1]; + this.zenodoCommunitySearchUtils.totalResults = result[1]; + this.zenodoCommunitySearchUtils.size = this.rowsOnPage; + if (this.totalZenodoCommunities == 0) { + this.zenodoCommunitySearchUtils.status = this.errorCodes.NONE; + } else { + this.zenodoCommunitySearchUtils.status = this.errorCodes.DONE; + } + + }, + error => { + this.zenodoCommunitySearchUtils.status = this.errorCodes.ERROR; + } + ); } totalPages(): number { @@ -150,73 +132,55 @@ export class AddZenodoCommunitiesComponent implements OnInit { public addCommunity(community) { - if (!Session.isLoggedIn()) { - this._router.navigate(['/user-info'], { - queryParams: { - "errorCode": LoginErrorCodes.NOT_VALID, - "redirectUrl": this._router.url - } - }); - } else { - this.subscriptions.push(this._manageZenodoCommunitiesService.addZCommunity(this.properties, this.communityId, community.id).subscribe( - data => { - community["openaireId"] = data.id; - this.selectedCommunities.push(community); - UIkit.notification('Community successfully added!', { - status: 'success', - timeout: 6000, - pos: 'bottom-right' - }); - }, - err => { - this.handleError('An error has been occurred. Try again later!'); - console.log(err.status); - }/*, - () => { - console.info("completed ADD"); - }*/ - )); - } + this.subscriptions.push(this._manageZenodoCommunitiesService.addZCommunity(this.properties, this.community.communityId, community.id).subscribe( + data => { + community["openaireId"] = data.id; + this.selectedCommunities.push(community); + UIkit.notification('Community successfully added!', { + status: 'success', + timeout: 6000, + pos: 'bottom-right' + }); + this.zenodoCommunitiesChanged.emit({ + value: this.selectedCommunities, + }); + }, + err => { + this.handleError('An error has been occurred. Try again later!'); + console.log(err.status); + } + )); } public removeCommunity(comm) { - if (!Session.isLoggedIn()) { - this._router.navigate(['/user-info'], { - queryParams: { - "errorCode": LoginErrorCodes.NOT_VALID, - "redirectUrl": this._router.url + var openaireId = this.getOpenaireId(comm); + this.subscriptions.push(this._manageZenodoCommunitiesService.removeZCommunity(this.properties, this.community.communityId, openaireId,).subscribe( + data => { + var pos = -1; + for (var i = 0; i < this.selectedCommunities.length; i++) { + if (this.selectedCommunities[i].id == comm.id) { + pos = i; + break; + } } - }); - } else { - var openaireId = this.getOpenaireId(comm); - this.subscriptions.push(this._manageZenodoCommunitiesService.removeZCommunity(this.properties, this.communityId, openaireId,).subscribe( - data => { - var pos = -1; - for (var i = 0; i < this.selectedCommunities.length; i++) { - if (this.selectedCommunities[i].id == comm.id) { - pos = i; - break; - } - } - if (pos != -1) { - this.selectedCommunities.splice(pos, 1); - } - - UIkit.notification('Community successfully removed!', { - status: 'success', - timeout: 6000, - pos: 'bottom-right' - }); - }, - err => { - this.handleError('An error has been occurred. Try again later!'); - console.log(err.status); - }/*, - () => { - console.info("completed remove"); - }*/ - )); - } + if (pos != -1) { + this.selectedCommunities.splice(pos, 1); + } + + UIkit.notification('Community successfully removed!', { + status: 'success', + timeout: 6000, + pos: 'bottom-right' + }); + this.zenodoCommunitiesChanged.emit({ + value: this.selectedCommunities, + }); + }, + err => { + this.handleError('An error has been occurred. Try again later!'); + console.log(err.status); + } + )); } public inThelist(community: any, list): any { @@ -236,14 +200,9 @@ export class AddZenodoCommunitiesComponent implements OnInit { } return null; } - - public onSearchClose() { - this.zenodoCommunitySearchUtils.keyword = this.filterForm.value; - } - - public resetInput() { - this.zenodoCommunitySearchUtils.keyword = null; - this.searchInputComponent.reset() + + get loading() { + return this.zenodoCommunitySearchUtils.status == this.errorCodes.LOADING } handleError(message: string) { diff --git a/src/app/pages/zenodo-communities/manage-zenodo-communities.component.html b/src/app/pages/zenodo-communities/manage-zenodo-communities.component.html index 934a3ca..7afc88a 100644 --- a/src/app/pages/zenodo-communities/manage-zenodo-communities.component.html +++ b/src/app/pages/zenodo-communities/manage-zenodo-communities.component.html @@ -1,72 +1,78 @@ -
+
- -
-
- - - - +
+
+
Admin Dashboard - Manage Zenodo Communities +
+

{{community.shortTitle}}

-
+
-
- +
+
+
+ +
-
-
-
Main Zenodo community
- -
-
-
No zenodo communities found -
-
-
- - -
    -
  • -
    -
    - -
    -
    -
    -
    -
    - - Remove community +
    +
    + +
    +
    +
    +
    No zenodo communities found
    +
    +
    + + + +
    +
    +
    +
    + +
    +
    -
  • -
+
+ +
+ + +
+
- + diff --git a/src/app/pages/zenodo-communities/manage-zenodo-communities.component.ts b/src/app/pages/zenodo-communities/manage-zenodo-communities.component.ts index a88ad09..f3450a3 100644 --- a/src/app/pages/zenodo-communities/manage-zenodo-communities.component.ts +++ b/src/app/pages/zenodo-communities/manage-zenodo-communities.component.ts @@ -2,23 +2,23 @@ import { Component, EventEmitter, Input, - OnChanges, OnDestroy, OnInit, - Output, SimpleChanges, + Output, ViewChild, ViewEncapsulation } from '@angular/core'; import {FormBuilder, FormControl} from '@angular/forms'; import {ActivatedRoute, Router} from '@angular/router'; import {EnvProperties} from '../../openaireLibrary/utils/properties/env-properties'; +import {properties} from "../../../environments/environment"; import {ErrorCodes} from '../../openaireLibrary/utils/properties/errorCodes'; import {SearchUtilsClass} from '../../openaireLibrary/searchPages/searchUtils/searchUtils.class'; -import {Session} from '../../openaireLibrary/login/utils/helper.class'; -import {LoginErrorCodes} from '../../openaireLibrary/login/utils/guardHelper.class'; import {ManageZenodoCommunitiesService} from '../../services/manageZenodoCommunities.service'; import {SearchInputComponent} from '../../openaireLibrary/sharedComponents/search-input/search-input.component'; import {Subscription} from 'rxjs'; +import {CommunityInfo} from "../../openaireLibrary/connect/community/communityInfo"; +import {HelperFunctions} from "../../openaireLibrary/utils/HelperFunctions.class"; declare var UIkit; @@ -29,9 +29,10 @@ declare var UIkit; }) export class ManageZenodoCommunitiesComponent implements OnInit, OnDestroy { - @Input() properties: EnvProperties = null; - @Input() communityId = null; - + properties: EnvProperties = properties; + @Input() community: CommunityInfo = null; + @Input() public loading: boolean = true; + @Input() public disableAdd: boolean = false; @Input() searchUtils: SearchUtilsClass = null; errorCodes: ErrorCodes; @@ -42,13 +43,17 @@ export class ManageZenodoCommunitiesComponent implements OnInit, OnDestroy { @ViewChild('AlertModalDeleteCommunity') alertModalDeleteCommunity; selectedToDelete = null; - @Output() toggleView: EventEmitter = new EventEmitter(); + @Output() addZenodoCommunity: EventEmitter = new EventEmitter(); + @Output() zenodoCommunitiesChanged = new EventEmitter(); + page = 1; size = 10; @ViewChild('searchInputComponent') searchInputComponent: SearchInputComponent; public filterForm: FormControl; private subscriptions: any[] = []; - + + public stickyPageHeader: boolean = false; + constructor(private route: ActivatedRoute, private _router: Router, public _fb: FormBuilder, @@ -83,7 +88,7 @@ export class ManageZenodoCommunitiesComponent implements OnInit, OnDestroy { public filterPreviewCommunities(value: string) { this.previewCommunities = this.selectedCommunities.filter(community => { - return community.title.toLowerCase().indexOf(value.toLowerCase()) != -1 + return !value || community.title.toLowerCase().indexOf(value.toLowerCase()) != -1 }); if (this.previewCommunities.slice((this.page - 1) * this.rowsOnPage, this.page * this.rowsOnPage).length == 0) { this.page = 1; @@ -91,70 +96,54 @@ export class ManageZenodoCommunitiesComponent implements OnInit, OnDestroy { } public confirmedDeleteCommunity(data: any) { - if (!Session.isLoggedIn()) { - this._router.navigate(['/user-info'], { - queryParams: { - "errorCode": LoginErrorCodes.NOT_VALID, - "redirectUrl": this._router.url + this.subscriptions.push(this._manageZenodoCommunitiesService.removeZCommunity(this.properties, this.community.communityId, this.selectedToDelete.openaireId).subscribe( + data => { + var pos = -1; + for (var i = 0; i < this.selectedCommunities.length; i++) { + if (this.selectedCommunities[i].id == this.selectedToDelete.id) { + pos = i; + break; + } } - }); - } else { - this.subscriptions.push(this._manageZenodoCommunitiesService.removeZCommunity(this.properties, this.communityId, this.selectedToDelete.openaireId).subscribe( - data => { - var pos = -1; - for (var i = 0; i < this.selectedCommunities.length; i++) { - if (this.selectedCommunities[i].id == this.selectedToDelete.id) { - pos = i; - break; - } - } - if (pos != -1) { - this.selectedCommunities.splice(pos, 1); - this.searchUtils.totalResults = this.selectedCommunities.length; - } + if (pos != -1) { + this.selectedCommunities.splice(pos, 1); this.searchUtils.totalResults = this.selectedCommunities.length; - this.filterPreviewCommunities(this.filterForm.value); - UIkit.notification('Community has been successfully removed!', { - status: 'success', - timeout: 6000, - pos: 'bottom-right' - }); - }, - err => { - this.handleError('An error has been occurred. Try again later!'); - console.log(err.status); } - )); - } + this.searchUtils.totalResults = this.selectedCommunities.length; + this.filterPreviewCommunities(this.filterForm.value); + UIkit.notification('Community has been successfully removed!', { + status: 'success', + timeout: 6000, + pos: 'bottom-right' + }); + this.zenodoCommunitiesChanged.emit({ + value: this.selectedCommunities, + }); + }, + err => { + this.handleError('An error has been occurred. Try again later!'); + console.log(err.status); + } + )); } public removeCommunity(comm) { - if (!Session.isLoggedIn()) { - this._router.navigate(['/user-info'], { - queryParams: { - "errorCode": LoginErrorCodes.NOT_VALID, - "redirectUrl": this._router.url - } - }); - } else { - this.selectedToDelete = comm; - this.alertModalDeleteCommunity.cancelButton = true; - this.alertModalDeleteCommunity.okButton = true; - this.alertModalDeleteCommunity.alertTitle = "Remove zenodo community?"; - let title = ""; - if (comm.title) { - title = comm.title; - } - - - this.alertModalDeleteCommunity.message = "Zenodo community"; - 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.selectedToDelete = comm; + this.alertModalDeleteCommunity.cancelButton = true; + this.alertModalDeleteCommunity.okButton = true; + this.alertModalDeleteCommunity.alertTitle = "Remove zenodo community"; + let title = ""; + if (comm.title) { + title = comm.title; } + + this.alertModalDeleteCommunity.message = "Zenodo community"; + 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(); } @@ -165,18 +154,14 @@ export class ManageZenodoCommunitiesComponent implements OnInit, OnDestroy { } return totalPages; } + + public updatePage($event) { + HelperFunctions.scroll(); + this.page = $event.value; + } addNew() { - this.toggleView.emit(null); - } - - public onSearchClose() { - this.searchUtils.keyword = this.filterForm.value; - } - - public resetInput() { - this.searchUtils.keyword = null; - this.searchInputComponent.reset() + this.addZenodoCommunity.emit(); } handleError(message: string) { diff --git a/src/app/pages/zenodo-communities/preview-z-community.component.ts b/src/app/pages/zenodo-communities/preview-z-community.component.ts index ce68049..eade205 100644 --- a/src/app/pages/zenodo-communities/preview-z-community.component.ts +++ b/src/app/pages/zenodo-communities/preview-z-community.component.ts @@ -3,30 +3,36 @@ import {Component, Input} from '@angular/core'; @Component({ selector: 'preview-zenodo-community', template: ` -
- - - -
- - {{item.title}} - [no name available] - - -
- last update: {{item.date | date:'yyyy/MM/dd'}} -
-
-
- -
-

{{item.description|htmlToString}}

-
- +
+
+ + {{item.title}} + +
+
+
Main Zenodo Community
+

+ + {{item.title}} + [no name available] + +

+
+ Last update: {{item.date | date:'yyyy/MM/dd'}} +
+
+
+
+
+
` }) export class PreviewZenodoCommunityComponent { @Input() item; + @Input() master: boolean = false; } diff --git a/src/app/pages/zenodo-communities/zenodo-communities.component.ts b/src/app/pages/zenodo-communities/zenodo-communities.component.ts index 6336ed9..a4d38c2 100644 --- a/src/app/pages/zenodo-communities/zenodo-communities.component.ts +++ b/src/app/pages/zenodo-communities/zenodo-communities.component.ts @@ -1,8 +1,6 @@ -import {Component, ElementRef, OnDestroy, OnInit, ViewChild} from '@angular/core'; +import {Component, ElementRef, Input, OnDestroy, OnInit, ViewChild} from '@angular/core'; import {ActivatedRoute, Router} from '@angular/router'; -import {Session} from '../../openaireLibrary/login/utils/helper.class'; -import {LoginErrorCodes} from '../../openaireLibrary/login/utils/guardHelper.class'; import {EnvProperties} from '../../openaireLibrary/utils/properties/env-properties'; import {ZenodoCommunitiesService} from '../../openaireLibrary/connect/zenodoCommunities/zenodo-communities.service'; import {SearchZenodoCommunitiesService} from '../../openaireLibrary/connect/zenodoCommunities/searchZenodoCommunities.service'; @@ -12,7 +10,6 @@ import {CommunityInfo} from '../../openaireLibrary/connect/community/communityIn import {ZenodoCommunityInfo} from '../../openaireLibrary/connect/zenodoCommunities/zenodoCommunityInfo'; import {SearchUtilsClass} from '../../openaireLibrary/searchPages/searchUtils/searchUtils.class'; import {ErrorCodes} from '../../openaireLibrary/utils/properties/errorCodes'; -import {HelperFunctions} from '../../openaireLibrary/utils/HelperFunctions.class'; import {Title} from '@angular/platform-browser'; import {properties} from '../../../environments/environment'; import {Subscription} from 'rxjs'; @@ -22,32 +19,21 @@ import {ManageZenodoCommunitiesComponent} from './manage-zenodo-communities.comp @Component({ selector: 'zenodo-communities', template: ` -
-
- -
-
-
- -
-
-
- - - - - + + + ` }) export class ZenodoCommunitiesComponent implements OnInit, OnDestroy { - public communityId: string = null; - private community: CommunityInfo = null; + public community: CommunityInfo = null; public toggle = false; - public updateCommunityProjectsOnToggle = false; public pageTitle = 'Manage zenodo communities'; masterZenodoCommunityId = null; masterZenodoCommunity = null; @@ -59,8 +45,9 @@ export class ZenodoCommunitiesComponent implements OnInit, OnDestroy { public errorCodes: ErrorCodes = new ErrorCodes(); subscriptions = []; @ViewChild('fsModal', { static: true }) fullscreen: FullScreenModalComponent; - @ViewChild('manage') manage: ManageZenodoCommunitiesComponent; - + @ViewChild(ManageZenodoCommunitiesComponent) manage: ManageZenodoCommunitiesComponent; + public showLoadingInRemove: boolean = true; + constructor(private element: ElementRef, private route: ActivatedRoute, private _router: Router, private _zenodoCommunitieService: ZenodoCommunitiesService, private title: Title, private _communityService: CommunityService, @@ -70,55 +57,52 @@ export class ZenodoCommunitiesComponent implements OnInit, OnDestroy { ngOnInit() { this.zenodoSearchUtils.status = this.errorCodes.LOADING; this.properties = properties; - this.route.params.subscribe(params => { - this.communityId = params['community']; - if (this.communityId) { - this.title.setTitle(this.communityId.toUpperCase() + ' | Zenodo Communities'); - if (this.communityId != null && this.communityId !== '') { - this.subscriptions.push(this._communityService.getCommunityAsObservable().subscribe( - community => { - this.community = community; - this.masterZenodoCommunityId = this.community.zenodoCommunity; - if (this.masterZenodoCommunityId) { - this.subscriptions.push(this._zenodoCommunitieService.getZenodoCommunityById(this.properties, - this.properties.zenodoCommunities + this.masterZenodoCommunityId, - null).subscribe( - result => { - this.masterZenodoCommunity = result; - }, - error => { - const emptyCommunity: ZenodoCommunityInfo = new ZenodoCommunityInfo(); - emptyCommunity.id = this.masterZenodoCommunityId; - emptyCommunity.title = this.masterZenodoCommunityId; - this.masterZenodoCommunity = emptyCommunity; - // console.log("Master Zenodo community'"+this.masterZenodoCommunityId+"' couldn't be loaded"); - } - )); - } - this.zenodoSearchUtils.status = this.errorCodes.LOADING; - this._searchZenodoCommunitiesService.searchZCommunities(this.properties, this.communityId).subscribe( - result => { - this.selectedCommunityIds = result; - this.zenodoSearchUtils.totalResults = this.selectedCommunityIds.length; - if (this.selectedCommunityIds.length === 0) { - this.zenodoSearchUtils.status = this.errorCodes.NONE; - } - for (let i = 0; i < this.selectedCommunityIds.length; i++) { - this.getZenodoCommunityById( - this.selectedCommunityIds[i]['zenodoid'], - this.selectedCommunityIds[i]['id']); - } - - }, - error => { - console.log('list of zenodo communities couldn\'t be loaded'); - this.zenodoSearchUtils.status = this.errorCodes.DONE; - } // this.handleError('System error retrieving community profile', error) - ); - })); + + this.subscriptions.push(this._communityService.getCommunityAsObservable().subscribe( + community => { + this.community = community; + this.title.setTitle(this.community.shortTitle.toUpperCase() + ' | Zenodo Communities'); + this.masterZenodoCommunityId = this.community.zenodoCommunity; + if (this.masterZenodoCommunityId) { + this.subscriptions.push(this._zenodoCommunitieService.getZenodoCommunityById(this.properties, + this.properties.zenodoCommunities + this.masterZenodoCommunityId, + null).subscribe( + result => { + this.masterZenodoCommunity = result; + this.selectedCommunities.unshift(this.masterZenodoCommunity); + }, + error => { + const emptyCommunity: ZenodoCommunityInfo = new ZenodoCommunityInfo(); + emptyCommunity.id = this.masterZenodoCommunityId; + emptyCommunity.title = this.masterZenodoCommunityId; + this.masterZenodoCommunity = emptyCommunity; + } + )); } - } - }); + this.zenodoSearchUtils.status = this.errorCodes.LOADING; + this.zenodoSearchUtils.status = this.errorCodes.LOADING; + this._searchZenodoCommunitiesService.searchZCommunities(this.properties, this.community.communityId).subscribe( + result => { + this.selectedCommunityIds = result; + this.zenodoSearchUtils.totalResults = this.selectedCommunityIds.length; + if (this.selectedCommunityIds.length === 0) { + this.zenodoSearchUtils.status = this.errorCodes.NONE; + } + for (let i = 0; i < this.selectedCommunityIds.length; i++) { + this.getZenodoCommunityById( + this.selectedCommunityIds[i]['zenodoid'], + this.selectedCommunityIds[i]['id']); + } + + }, + error => { + console.log('list of zenodo communities couldn\'t be loaded'); + this.zenodoSearchUtils.status = this.errorCodes.DONE; + } + ); + }) + ); + this.fullscreen.title = "Search and Add Zenodo Communities"; this.fullscreen.okButtonText = "Done"; this.fullscreen.okButton = true; @@ -132,26 +116,6 @@ export class ZenodoCommunitiesComponent implements OnInit, OnDestroy { }); } - 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(); - this.pageTitle = 'Manage zenodo communities'; - } else { - this.manage.filterPreviewCommunities(this.manage.filterForm.value); - this.updateCommunityProjectsOnToggle = false; - this.pageTitle = 'Search zenodo communities'; - } - } - } - getZenodoCommunityById(zenodoid, openaireId) { this.subscriptions.push(this._zenodoCommunitieService.getZenodoCommunityById(this.properties, this.properties.zenodoCommunities + zenodoid, openaireId).subscribe( @@ -178,4 +142,22 @@ export class ZenodoCommunitiesComponent implements OnInit, OnDestroy { } )); } + + + public openAddZenodoCommunites() { + this.fullscreen.title = "Search and Add Zenodo Communities"; + this.fullscreen.okButtonText = "Done"; + this.fullscreen.back = true; + this.fullscreen.okButton = true; + this.fullscreen.open(); + } + + public zenodoCommunitiesChanged($event) { + this.selectedCommunities = $event.value; + this.showLoadingInRemove = false; + + if (this.fullscreen.isOpen) { + this.manage.filterPreviewCommunities(this.manage.filterForm.value); + } + } } diff --git a/src/app/pages/zenodo-communities/zenodo-communities.module.ts b/src/app/pages/zenodo-communities/zenodo-communities.module.ts index ce96c76..5f2f20a 100644 --- a/src/app/pages/zenodo-communities/zenodo-communities.module.ts +++ b/src/app/pages/zenodo-communities/zenodo-communities.module.ts @@ -13,19 +13,18 @@ import {ZenodoCommunitiesRoutingModule} from './zenodo-communities-routing.modul import {CommunityInfoModule} from '../community-info/community-info.module'; import {SearchInputModule} from '../../openaireLibrary/sharedComponents/search-input/search-input.module'; import {IconsModule} from '../../openaireLibrary/utils/icons/icons.module'; -import {IconsService} from '../../openaireLibrary/utils/icons/icons.service'; -import {add, arrow_left, remove_circle_outline} from '../../openaireLibrary/utils/icons/icons'; import {NoLoadPaging} from '../../openaireLibrary/searchPages/searchUtils/no-load-paging.module'; import {LoadingModule} from '../../openaireLibrary/utils/loading/loading.module'; import {PreviewZenodoCommunityComponent} from './preview-z-community.component'; import {PageContentModule} from '../../openaireLibrary/dashboard/sharedComponents/page-content/page-content.module'; import {FullScreenModalModule} from '../../openaireLibrary/utils/modal/full-screen-modal/full-screen-modal.module'; import {HTMLToStringPipeModule} from '../../openaireLibrary/utils/pipes/HTMLToStringPipe.module'; +import {PagingModule} from "../../openaireLibrary/utils/paging.module"; @NgModule({ imports: [ CommonModule, FormsModule, RouterModule, SearchZenodoCommunitiesServiceModule, ZenodoCommunitiesServiceModule, - AlertModalModule, ZenodoCommunitiesRoutingModule, CommunityInfoModule, PageContentModule, SearchInputModule, IconsModule, NoLoadPaging, LoadingModule, FullScreenModalModule, HTMLToStringPipeModule + AlertModalModule, ZenodoCommunitiesRoutingModule, CommunityInfoModule, PageContentModule, SearchInputModule, IconsModule, NoLoadPaging, LoadingModule, FullScreenModalModule, HTMLToStringPipeModule, PagingModule ], declarations: [ ManageZenodoCommunitiesComponent, ZenodoCommunitiesComponent, AddZenodoCommunitiesComponent, PreviewZenodoCommunityComponent @@ -39,7 +38,5 @@ import {HTMLToStringPipeModule} from '../../openaireLibrary/utils/pipes/HTMLToSt }) export class ZenodoCommunitiesModule { - constructor(private iconsService: IconsService) { - this.iconsService.registerIcons([add, arrow_left, remove_circle_outline ]) - } + constructor() {} } From b18e2f75a02d992ebbba23109ce40264adadf6bb Mon Sep 17 00:00:00 2001 From: "konstantina.galouni" Date: Tue, 5 Jul 2022 12:07:43 +0300 Subject: [PATCH 3/3] [Connect Admin | new-theme]: remove-projects.component.html: Added uk-width-small in sorting input. --- .../pages/projects/remove-projects.component.html | 13 ++++++++----- src/assets/openaire-theme | 2 +- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/app/pages/projects/remove-projects.component.html b/src/app/pages/projects/remove-projects.component.html index 3ac487f..01d649c 100644 --- a/src/app/pages/projects/remove-projects.component.html +++ b/src/app/pages/projects/remove-projects.component.html @@ -52,13 +52,16 @@
-
+
+
+
-
+
diff --git a/src/assets/openaire-theme b/src/assets/openaire-theme index 8f8b85e..3c6d5ca 160000 --- a/src/assets/openaire-theme +++ b/src/assets/openaire-theme @@ -1 +1 @@ -Subproject commit 8f8b85e69d5c505ed59b12b8b70348096f339775 +Subproject commit 3c6d5cab3a9e3a1e3be42e231424a5c1350749ad