From f2bbf0fb852ad2d312e1860bccaa9c7b6d9b5544 Mon Sep 17 00:00:00 2001 From: "k.triantafyllou" Date: Fri, 10 Mar 2023 17:15:26 +0200 Subject: [PATCH] Delete header from all pages of communityInfo and users. Add advanced criteria page. --- src/app/app.component.ts | 5 +- src/app/openaireLibrary | 2 +- .../advanced-criteria.component.ts | 121 ++++++++++++++++++ .../advanced-criteria.module.ts | 18 +++ .../advanced-criteria.service.ts | 25 ++++ .../affiliations/affiliations.component.html | 11 +- src/app/pages/claims/claims.component.ts | 7 - .../community-info-routing.module.ts | 1 + .../profile/profile.component.ts | 14 +- .../connect-admin-customization.component.ts | 9 -- .../pages/content-providers/criteria-utils.ts | 25 +++- .../criteria/criteria.component.html | 33 +++-- .../criteria/criteria.component.less | 4 - .../criteria/criteria.component.ts | 20 +-- .../manage-content-providers.component.ts | 11 +- .../remove-content-providers.component.html | 13 +- .../remove-content-providers.component.ts | 17 +-- .../manage-communities.component.ts | 8 -- .../projects/remove-projects.component.html | 11 +- .../manage-user-notifications.component.html | 6 - .../personal-info/personal-info.component.ts | 10 +- .../users-managers.component.ts | 6 - .../users-subscribers.component.ts | 6 - .../manage-zenodo-communities.component.html | 11 +- src/assets/common-assets | 2 +- src/assets/openaire-theme | 2 +- 26 files changed, 239 insertions(+), 159 deletions(-) create mode 100644 src/app/pages/advanced-criteria/advanced-criteria.component.ts create mode 100644 src/app/pages/advanced-criteria/advanced-criteria.module.ts create mode 100644 src/app/pages/advanced-criteria/advanced-criteria.service.ts diff --git a/src/app/app.component.ts b/src/app/app.component.ts index d30ed2d..74d22ca 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -221,9 +221,12 @@ export class AppComponent implements OnInit { new MenuItem("organizations", "Organizations", "", "/" + this.community.communityId + "/info/organizations", false, [], [], {}, null, null, null, "/" + this.community.communityId + "/info/organizations"), new MenuItem("projects", OpenaireEntities.PROJECTS, "", "/" + this.community.communityId + "/info/projects", false, [], [], {}, null, null, null, "/" + this.community.communityId + "/info/projects"), new MenuItem("content-providers", OpenaireEntities.DATASOURCES, "", "/" + this.community.communityId + "/info/content-providers", false, [], [], {}, null, null, null, "/" + this.community.communityId + "/info/content-providers"), - new MenuItem("subjects", "Subjects", "", "/" + this.community.communityId + "/info/subjects", false, [], [], {}, null, null, null, "/" + this.community.communityId + "/info/subjects"), new MenuItem("zenodo-communities", "Zenodo Communities ", "", "/" + this.community.communityId + "/info/zenodo-communities", false, [], [], {}, null, null, null, "/" + this.community.communityId + "/info/zenodo-communities"), + new MenuItem("advanced-criteria", "Advanced Criteria", "", "/" + this.community.communityId + "/info/advanced-criteria", false, [], [], {}, null, null, null, "/" + this.community.communityId + "/info/advanced-criteria") ] + if(this.community.type === 'community') { + communityInfo.items.splice(4, 0, new MenuItem("subjects", "Subjects", "", "/" + this.community.communityId + "/info/subjects", false, [], [], {}, null, null, null, "/" + this.community.communityId + "/info/subjects")) + } this.sideBarItems.push(communityInfo); this.sideBarItems.push(new MenuItem("users", "Users", "", "/" + this.community.communityId + "/users", false, [], [], {}, {name: 'group'}, null, null, "/" + this.community.communityId + "/users")); this.sideBarItems.push(new MenuItem("admin-tools", "Pages & Menus", "", "/" + this.community.communityId + "/admin-tools/pages", false, [], [], {}, {name: 'description'}, null, null, "/" + this.community.communityId + "/admin-tools")); diff --git a/src/app/openaireLibrary b/src/app/openaireLibrary index efc2d6c..cdd59b6 160000 --- a/src/app/openaireLibrary +++ b/src/app/openaireLibrary @@ -1 +1 @@ -Subproject commit efc2d6c47b1c8e81150274589550b26c25b6eb8f +Subproject commit cdd59b68abb368dc178e898ce3b336606cd499d1 diff --git a/src/app/pages/advanced-criteria/advanced-criteria.component.ts b/src/app/pages/advanced-criteria/advanced-criteria.component.ts new file mode 100644 index 0000000..07ae3f8 --- /dev/null +++ b/src/app/pages/advanced-criteria/advanced-criteria.component.ts @@ -0,0 +1,121 @@ +import {ChangeDetectorRef, Component, OnDestroy, OnInit, ViewChild} from "@angular/core"; +import {CommunityService} from "../../openaireLibrary/connect/community/community.service"; +import {AdvancedCriteriaService} from "./advanced-criteria.service"; +import {Subscription} from "rxjs"; +import {ContentProvider, SelectionCriteria} from "../../openaireLibrary/utils/entities/contentProvider"; +import { + FullScreenModalComponent +} from "../../openaireLibrary/utils/modal/full-screen-modal/full-screen-modal.component"; +import {NotificationHandler} from "../../openaireLibrary/utils/notification-handler"; +import {CriteriaComponent} from "../content-providers/criteria/criteria.component"; +import {CriteriaUtils} from "../content-providers/criteria-utils"; +import {OpenaireEntities} from "../../openaireLibrary/utils/properties/searchFields"; +import {CommunityInfo} from "../../openaireLibrary/connect/community/communityInfo"; + +@Component({ + selector: 'advanced-criteria', + template: ` +
+
+
+
+ + +
+
+
+
+
+ +
+
+
+
Criteria
+
+
+
+
No criteria yet
+ + Add multiple constraints in AND to define a criterion: results that satisfy at least one of the criteria will be included in your community. + +
+
+
+
+ +
+ +
+
No Criteria yet
+ + Add multiple constraints in AND to define a criterion: results that satisfy at least one of the criteria will be included in your community. + +
+
+
+
+ ` +}) +export class AdvancedCriteriaComponent implements OnInit, OnDestroy { + public loading = true; + public selectionCriteria: SelectionCriteria; + public community: CommunityInfo; + public criteriaUtils: CriteriaUtils = new CriteriaUtils(); + private subscriptions: any[] = []; + @ViewChild('criteria') criteria: CriteriaComponent; + @ViewChild('filtersModal', { static: true }) filtersModal: FullScreenModalComponent; + + constructor(private communityService: CommunityService, + private cdr: ChangeDetectorRef, + private advancedCriteriaService: AdvancedCriteriaService) {} + + ngOnInit() { + this.loading = true; + this.subscriptions.push(this.communityService.getCommunityAsObservable().subscribe(community => { + this.community = community; + this.selectionCriteria = community.selectionCriteria; + this.loading = false; + })); + } + + saveCriteria() { + let callback = (selectionCriteria): void => { + this.advancedCriteriaService.saveAdvancedCriteria(this.community.communityId, selectionCriteria).subscribe(() => { + this.criteria.reset(); + this.criteria.loading = false; + NotificationHandler.rise('Filters have been successfully updated'); + }, error => { + this.criteria.loading = false; + this.criteria.handeError('An error has been occurred. Try again later!', error); + }); + } + this.loading = true; + this.criteria.save(callback); + } + + public openCriteria() { + this.criteria.reset(); + this.filtersModal.title = 'Criteria'; + this.filtersModal.okButtonText = "Save"; + this.filtersModal.back = true; + this.filtersModal.okButton = true; + this.filtersModal.open(); + this.cdr.detectChanges(); + } + + ngOnDestroy() { + this.subscriptions.forEach(subscription => { + if(subscription instanceof Subscription) { + subscription.unsubscribe(); + } + }) + } +} diff --git a/src/app/pages/advanced-criteria/advanced-criteria.module.ts b/src/app/pages/advanced-criteria/advanced-criteria.module.ts new file mode 100644 index 0000000..1645825 --- /dev/null +++ b/src/app/pages/advanced-criteria/advanced-criteria.module.ts @@ -0,0 +1,18 @@ +import {NgModule} from "@angular/core"; +import {CommonModule} from "@angular/common"; +import {RouterModule} from "@angular/router"; +import {AdvancedCriteriaComponent} from "./advanced-criteria.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 {CriteriaModule} from "../content-providers/criteria/criteria.module"; +import {IconsModule} from "../../openaireLibrary/utils/icons/icons.module"; +import {LoadingModule} from "../../openaireLibrary/utils/loading/loading.module"; + +@NgModule({ + imports: [CommonModule, RouterModule.forChild([ + {path: '', component: AdvancedCriteriaComponent,} + ]), PageContentModule, FullScreenModalModule, CriteriaModule, IconsModule, LoadingModule], + declarations: [AdvancedCriteriaComponent], + exports: [AdvancedCriteriaComponent] +}) +export class AdvancedCriteriaModule {} diff --git a/src/app/pages/advanced-criteria/advanced-criteria.service.ts b/src/app/pages/advanced-criteria/advanced-criteria.service.ts new file mode 100644 index 0000000..703bd80 --- /dev/null +++ b/src/app/pages/advanced-criteria/advanced-criteria.service.ts @@ -0,0 +1,25 @@ +import {Injectable} from "@angular/core"; +import {SelectionCriteria} from "../../openaireLibrary/utils/entities/contentProvider"; +import {Observable} from "rxjs"; +import {CommunityInfo} from "../../openaireLibrary/connect/community/communityInfo"; +import {HttpClient} from "@angular/common/http"; +import {properties} from "../../../environments/environment"; +import {map} from "rxjs/operators"; +import {CommunityService} from "../../openaireLibrary/connect/community/community.service"; + +@Injectable({ + providedIn: 'root' +}) +export class AdvancedCriteriaService { + + constructor(private httpClient: HttpClient, + private communityService: CommunityService) { + } + + public saveAdvancedCriteria(communityId, selectionCriteria: SelectionCriteria): Observable { + return this.httpClient.post(properties.communityAPI + communityId + '/advancedConstraint', selectionCriteria).pipe(map(community => { + this.communityService.updateAdvancedCriteria(this.communityService.parseCommunity(community).selectionCriteria); + })); + } + +} diff --git a/src/app/pages/affiliations/affiliations.component.html b/src/app/pages/affiliations/affiliations.component.html index ef6d5f5..ccfdef9 100644 --- a/src/app/pages/affiliations/affiliations.component.html +++ b/src/app/pages/affiliations/affiliations.component.html @@ -1,15 +1,6 @@
-
-
-
-
Admin Dashboard - Manage Organizations -
-

{{community.shortTitle}}

-
-
-
-
+
+ [options]="criteriaUtils.fields" [formInput]="constraint.get('field')">
+ [options]="criteriaUtils.verbs" [formInput]="constraint.get('verb')">
+ [options]="criteriaUtils.fields" [formInput]="constraint.get('field')">
-
+
+
@@ -107,9 +106,9 @@
diff --git a/src/app/pages/content-providers/criteria/criteria.component.less b/src/app/pages/content-providers/criteria/criteria.component.less index 1d3f7ca..6fff62f 100644 --- a/src/app/pages/content-providers/criteria/criteria.component.less +++ b/src/app/pages/content-providers/criteria/criteria.component.less @@ -1,7 +1,3 @@ .criteria { padding-right: 20px; } - -.criterion { - max-height: 400px; -} diff --git a/src/app/pages/content-providers/criteria/criteria.component.ts b/src/app/pages/content-providers/criteria/criteria.component.ts index 88ae678..41a54ae 100644 --- a/src/app/pages/content-providers/criteria/criteria.component.ts +++ b/src/app/pages/content-providers/criteria/criteria.component.ts @@ -12,7 +12,6 @@ import {EnvProperties} from '../../../openaireLibrary/utils/properties/env-prope import {Constraint, Criteria, SelectionCriteria} from '../../../openaireLibrary/utils/entities/contentProvider'; import {AbstractControl, UntypedFormArray, UntypedFormBuilder, UntypedFormGroup, Validators} from '@angular/forms'; import {properties} from "../../../../environments/environment"; -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"; @@ -28,17 +27,19 @@ import {Subscription} from "rxjs"; }) export class CriteriaComponent implements OnInit, OnChanges, AfterViewInit, OnDestroy { @Input() - public dataProvider: string; + public entityType: string = 'filter'; + @Input() + public entityTypePlural: string = 'filters'; @Input() public selectionCriteria: SelectionCriteria; @Input() public height: number = 0; - public maxHeight: number = 0; + public criteriaHeight: number = 0; public selectionCriteriaForm: UntypedFormGroup; public properties: EnvProperties = properties; - public fields: Option[] = CriteriaUtils.fields; - public verbs: Option[] = CriteriaUtils.verbs; + public criteriaUtils: CriteriaUtils = new CriteriaUtils(); public fos: string[] = []; + public sdg: string[] = []; public loading = true; public openaireEntities = OpenaireEntities; private subscriptions: any[] = []; @@ -53,6 +54,9 @@ export class CriteriaComponent implements OnInit, OnChanges, AfterViewInit, OnDe this.subscriptions.push(this.vocabulariesService.getVocabularyByType('fos', null, properties).subscribe((fos: any[]) => { this.fos = fos.map(element => element.id); })); + this.subscriptions.push(this.vocabulariesService.getVocabularyByType('sdg', null, properties).subscribe((sdg: any[]) => { + this.sdg = sdg.map(element => element.id); + })); } ngOnChanges(changes: SimpleChanges) { @@ -74,8 +78,8 @@ export class CriteriaComponent implements OnInit, OnChanges, AfterViewInit, OnDe calculateMaxHeight() { if(this.height) { if(this.height > 0) { - /* Element height - section (70 + 70) - margins(20 + 20) - button height(42) */ - this.maxHeight = this.height - 140 - 40 - 42; + /* Element height - margins(20 + 20) - button height(42) */ + this.criteriaHeight = this.height - 40 - 42; this.cdr.detectChanges(); } } @@ -154,7 +158,7 @@ export class CriteriaComponent implements OnInit, OnChanges, AfterViewInit, OnDe } get dirty() { - if (!this.dataProvider || !this.criteria) { + if (!this.selectionCriteria || !this.criteria) { return false; } else if (this.criteria.length !== this.criteriaArray.length) { return true; 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 4d3a4d6..f211f4f 100644 --- a/src/app/pages/content-providers/manage-content-providers.component.ts +++ b/src/app/pages/content-providers/manage-content-providers.component.ts @@ -34,8 +34,14 @@ import {ManageCommunityContentProvidersService} from "../../services/manageConte [okButtonDisabled]="criteria && criteria.disabled">
+ [selectionCriteria]="dataProvider.selectioncriteria"> +
+
No Filters for {{dataProvider.officialname}} yet
+ If no Filters are specified, all {{openaireEntities.RESULTS | lowercase}} of this {{openaireEntities.DATASOURCE | lowercase}} will be included in your + {{openaireEntities.COMMUNITY | lowercase}}. + +
+
` @@ -51,6 +57,7 @@ export class ManageContentProvidersComponent implements OnInit { public showLoadingInRemove: boolean = true; public body: string = "Send from page"; public properties: EnvProperties = properties; + public openaireEntities = OpenaireEntities; public community: CommunityInfo; public dataProvider: ContentProvider; 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 4dcd4b4..6156177 100644 --- a/src/app/pages/content-providers/remove-content-providers.component.html +++ b/src/app/pages/content-providers/remove-content-providers.component.html @@ -1,15 +1,6 @@
-
-
-
-
Admin Dashboard - Manage {{openAIREEntities.DATASOURCES}} -
-

{{community.shortTitle}}

-
-
-
-
+
Filters
-
+
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 ad47053..8fce21e 100644 --- a/src/app/pages/content-providers/remove-content-providers.component.ts +++ b/src/app/pages/content-providers/remove-content-providers.component.ts @@ -38,8 +38,7 @@ export class RemoveContentProvidersComponent implements OnInit { private selectedCommunityContentProvider: any; @ViewChild('deleteModal') deleteModal: AlertModal; /** Criteria */ - private fields = CriteriaUtils.fields; - private verbs = CriteriaUtils.verbs; + public criteriaUtils: CriteriaUtils = new CriteriaUtils(); /** Paging */ page: number = 1; resultsPerPage: number = properties.resultsPerPage; @@ -81,20 +80,6 @@ export class RemoveContentProvidersComponent implements OnInit { }); } - getFiltersAsText(criteria: Criteria[]): string { - let text = criteria.slice(0, 3).map((criterion, index) => (index + 1) + ". " + criterion.constraint.map(constraint => { - let field = this.fields.find(field => field.value === constraint.field)?.label; - let matchCase = false; - if (!constraint.verb.includes('_caseinsensitive')) { - matchCase = true; - } - let verb = this.verbs.find(verb => verb.value === constraint.verb.replace("_caseinsensitive", "")).label; - let value = '"' + constraint.value + '"' + (matchCase ? " (Match case)" : ""); - return field + " " + verb + " " + value; - }).join(" and ")); - return text.join("
"); - } - public confirmedDeleteContentProvider() { this.subscriptions.push(this._manageCommunityContentProvidersService.removeContentProvider(this.properties, this.community.communityId, this.selectedCommunityContentProvider.id).subscribe( () => { diff --git a/src/app/pages/manage-communities/manage-communities.component.ts b/src/app/pages/manage-communities/manage-communities.component.ts index f61835f..fc7f9d7 100644 --- a/src/app/pages/manage-communities/manage-communities.component.ts +++ b/src/app/pages/manage-communities/manage-communities.component.ts @@ -20,14 +20,6 @@ type Tab = 'all' | 'communities' | 'ris'; template: `
-
-
-
- Admin Dashboard - Manage Communities -
-

Research Communities & Initiatives

-
-
  • All
  • Research Communities diff --git a/src/app/pages/projects/remove-projects.component.html b/src/app/pages/projects/remove-projects.component.html index 9096018..c5633e9 100644 --- a/src/app/pages/projects/remove-projects.component.html +++ b/src/app/pages/projects/remove-projects.component.html @@ -1,15 +1,6 @@
    -
    -
    -
    -
    Admin Dashboard - Manage {{openaireEntiites.PROJECTS}} -
    -

    {{community.shortTitle}}

    -
    -
    -
    -
    +
    -
    -
    -
    Admin Dashboard - Manage Notification Settings
    -

    {{community.shortTitle}}

    -
    -
    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 a474484..a73a57f 100644 --- a/src/app/pages/users/personal-info/personal-info.component.ts +++ b/src/app/pages/users/personal-info/personal-info.component.ts @@ -25,18 +25,10 @@ declare var UIkit; template: `
    -
    -
    -
    Admin Dashboard - Manage Personal Info & - Affiliations -
    -

    {{community.shortTitle}}

    -
    -
    -
    +