diff --git a/src/app/openaireLibrary b/src/app/openaireLibrary index c4b57e9..dede290 160000 --- a/src/app/openaireLibrary +++ b/src/app/openaireLibrary @@ -1 +1 @@ -Subproject commit c4b57e91ab78bdbe16717c0060449ba83ea32968 +Subproject commit dede290a52c1aab54858eab3554dbb8ca92f8475 diff --git a/src/app/repository/browse-repositories/browse-repositories.component.ts b/src/app/repository/browse-repositories/browse-repositories.component.ts index 58d3830..4ad91e1 100644 --- a/src/app/repository/browse-repositories/browse-repositories.component.ts +++ b/src/app/repository/browse-repositories/browse-repositories.component.ts @@ -1,7 +1,6 @@ import {ChangeDetectorRef, Component} from "@angular/core"; import {ActivatedRoute, Router} from "@angular/router"; import {FormBuilder} from "@angular/forms"; -import {BrowseStakeholderBaseComponent} from "../../shared/browse-stakeholder-base.component"; import {LayoutService} from "../../openaireLibrary/dashboard/sharedComponents/sidebar/layout.service"; import {Option} from "../../openaireLibrary/sharedComponents/input/input.component"; import {SearchDataprovidersService} from "../../openaireLibrary/services/searchDataproviders.service"; @@ -11,12 +10,13 @@ import {forkJoin, Observable, of} from "rxjs"; import {catchError} from "rxjs/operators"; import {StakeholderPublication} from "../../shared/irish"; import {IrishMonitorService} from "../../shared/irish-monitor.service"; +import {BrowseStakeholderBaseComponent} from "../../openaireLibrary/monitor/browse-stakeholder/browse-stakeholder-base.component"; @Component({ selector: 'browse-repository', templateUrl: 'browse-repositories.component.html' }) -export class BrowseRepositoriesComponent extends BrowseStakeholderBaseComponent { +export class BrowseRepositoriesComponent extends BrowseStakeholderBaseComponent { sortBy = 'alphAsc'; sortOptions: Option[] = [ {value: 'alphAsc', label: 'Alphabetically Asc. (A-Z)'}, @@ -33,6 +33,20 @@ export class BrowseRepositoriesComponent extends BrowseStakeholderBaseComponent super(); } + init() { + this.subscriptions.push(this.irishMonitorService.getStakeholdersWithPublications(this.stakeholderType).subscribe(stakeholders => { + this.stakeholders = stakeholders; + this.filteredStakeholders = stakeholders; + this.hasPublications = this.stakeholders.length > 0 && this.stakeholders.filter(stakeholder => stakeholder.publications > 0).length > 0; + if(!this.hasPublications) { + this.sortBy = 'alphAsc'; + this.sortOptions = this.sortOptions.filter(option => !!option.value); + } + this.sortByChanged(); + this.filtering(this.keywordControl.value); + })); + } + sortByChanged() { switch(this.sortBy) { case 'alphAsc': @@ -84,7 +98,3 @@ export class BrowseRepositoriesComponent extends BrowseStakeholderBaseComponent return ResultPreview.searchResultConvert(result, (result.entityType) ? result.entityType : this.typeAsLabel); } } - -export class StakeholderRepository extends StakeholderPublication { - details: any; -} diff --git a/src/app/repository/repository.component.ts b/src/app/repository/repository.component.ts index 154714e..9d8e0fe 100644 --- a/src/app/repository/repository.component.ts +++ b/src/app/repository/repository.component.ts @@ -16,7 +16,7 @@ import {UserManagementService} from "../openaireLibrary/services/user-management import {ConfigurationService} from "../openaireLibrary/utils/configuration/configuration.service"; import {Irish} from "../shared/irish"; import {Session} from "../openaireLibrary/login/utils/helper.class"; -import {properties as beta} from "../../environments/environment.beta"; +import {properties as beta} from "../../environments/environment.beta"; @Component({ @@ -171,7 +171,7 @@ export class RepositoryComponent extends StakeholderBaseComponent implements OnI this.params.subscribe(params => { this.alias = params['stakeholder']; if (this.alias) { - if(this.stakeholder?.alias !== this.alias) { + if (this.stakeholder?.alias !== this.alias) { this._customFilterService.setCustomFilter(null); this.loading = true; this.subscriptions.push(this.stakeholderService.getStakeholder(this.alias, true).subscribe(stakeholder => { @@ -181,9 +181,9 @@ export class RepositoryComponent extends StakeholderBaseComponent implements OnI LinksResolver.resetProperties(); LinksResolver.setSearchAndResultLanding("repository/" + this.stakeholder.alias); this._customFilterService.setCustomFilter( - [new SearchCustomFilter("National", "country", "IE", "Irish National Monitor", false), + [ + new SearchCustomFilter("National", "country", "IE", "Irish National Monitor", false), new SearchCustomFilter("Repository", "resulthostingdatasourceid", this.stakeholder.index_id, this.stakeholder.index_name, true) - // new SearchCustomFilter("Repository", "collectedfromdatasourceid", this.stakeholder.index_id, this.stakeholder.index_name, true) ]); this.subscriptions.push(this.searchDataprovidersService.searchDataproviderById(this.stakeholder.index_id).subscribe(data => { this.stakeholder.details = data[0]; @@ -223,7 +223,7 @@ export class RepositoryComponent extends StakeholderBaseComponent implements OnI } get sandboxLink() { - if(this.properties.environment !== 'beta' && this.isMember) { + if (this.properties.environment !== 'beta' && this.isMember) { return beta.domain + '/repository/' + this.stakeholder.alias; } else { return null; @@ -231,8 +231,8 @@ export class RepositoryComponent extends StakeholderBaseComponent implements OnI } get provideLink() { - if(this.stakeholder?.details?.originalId) { - return 'https://' + (this.properties.environment != 'production'?'beta.':'') + 'provide.openaire.eu/repository/' + this.stakeholder.details.originalId + '/dashboard'; + if (this.stakeholder?.details?.originalId) { + return 'https://' + (this.properties.environment != 'production' ? 'beta.' : '') + 'provide.openaire.eu/repository/' + this.stakeholder.details.originalId + '/dashboard'; } else { return null; } diff --git a/src/app/shared/browse-stakeholder-base.component.ts b/src/app/shared/browse-stakeholder-base.component.ts deleted file mode 100644 index d8aaf29..0000000 --- a/src/app/shared/browse-stakeholder-base.component.ts +++ /dev/null @@ -1,123 +0,0 @@ -import {ChangeDetectorRef, Directive, OnInit} from "@angular/core"; -import {StakeholderBaseComponent} from "../openaireLibrary/monitor-admin/utils/stakeholder-base.component"; -import {StakeholderType} from "../openaireLibrary/monitor/entities/stakeholder"; -import {Option} from "../openaireLibrary/sharedComponents/input/input.component"; -import {FormBuilder, FormControl} from "@angular/forms"; -import {debounceTime, distinctUntilChanged} from "rxjs/operators"; -import {HelperFunctions} from "../openaireLibrary/utils/HelperFunctions.class"; -import {LayoutService} from "../openaireLibrary/dashboard/sharedComponents/sidebar/layout.service"; -import {IrishMonitorService} from "./irish-monitor.service"; -import {StakeholderPublication} from "./irish"; -import {OpenaireEntities} from "../openaireLibrary/utils/properties/searchFields"; - -@Directive() -export class BrowseStakeholderBaseComponent extends StakeholderBaseComponent implements OnInit { - openaireEntities = OpenaireEntities; - stakeholderType: StakeholderType; - stakeholders: StakeholderPublication[] = []; - filteredStakeholders: StakeholderPublication[] = []; - showLoading: boolean = true; - isMobile: boolean = false; - - gridView: boolean = true; - sortOptions: Option[] = [ - {value: null, label: 'Number of Publications'}, - {value: 'alphAsc', label: 'Alphabetically Asc. (A-Z)'}, - {value: 'alphDsc', label: 'Alphabetically Dsc. (Z-A)'}, - /*{value: 'oaDsc', label: '"Open Access %" Dsc.'}*/ - ]; - pageOptions: number[] = [10, 20, 30, 40]; - sortBy: string = null; - currentPage: number = 1; - pageSize: number = 10; - parameters = {}; - keywordControl: FormControl; - hasPublications: boolean = true; - - /* Services */ - protected irishMonitorService: IrishMonitorService; - protected layoutService: LayoutService; - protected cdr: ChangeDetectorRef; - protected fb: FormBuilder; - - constructor() { - super(); - } - - ngOnInit() { - this.keywordControl = this.fb.control(this._route.snapshot.queryParams.keyword); - this.subscriptions.push(this.layoutService.isMobile.subscribe(isMobile => { - this.isMobile = isMobile; - this.cdr.detectChanges(); - })); - this.stakeholderType = this._route.snapshot.data.type; - if(!this.stakeholderType) { - this.navigateToError(); - } - this.subscriptions.push(this.irishMonitorService.getStakeholdersWithPublications(this.stakeholderType).subscribe(stakeholders => { - this.stakeholders = stakeholders; - this.filteredStakeholders = stakeholders; - this.hasPublications = this.stakeholders.length > 0 && this.stakeholders.filter(stakeholder => stakeholder.publications > 0).length > 0; - if(!this.hasPublications) { - this.sortBy = 'alphAsc'; - this.sortOptions = this.sortOptions.filter(option => !!option.value); - } - this.sortByChanged(); - this.filtering(this.keywordControl.value); - })); - this.subscriptions.push(this.keywordControl.valueChanges.pipe(debounceTime(200), distinctUntilChanged()).subscribe(value => { - this.filtering(value); - if(value?.length > 0) { - this.parameters['keyword'] = value; - } else { - delete this.parameters['keyword'] - } - this._router.navigate([], {queryParams: this.parameters}); - })); - } - - private filtering(value) { - if(!value){ - this.filteredStakeholders = this.stakeholders; - } else { - this.filteredStakeholders = this.stakeholders.filter(item => (item['name'] && item['name'].toLowerCase().includes(value.toLowerCase())) || (item['alias'] && item['alias'].toLowerCase().includes(value.toLowerCase()))); - } - this.afterStakeholdersInitialized(); - this.currentPage = 1; - } - - sortByChanged() { - switch(this.sortBy) { - case 'alphAsc': - this.stakeholders = this.stakeholders.sort((a, b) => a['name'].localeCompare(b['name'])); - break; - case 'alphDsc': - this.stakeholders = this.stakeholders.sort((a, b) => b['name'].localeCompare(a['name'])); - break; - default: - this.stakeholders = this.stakeholders.sort((a, b) => b.publications - a.publications); - break; - } - } - - sizeChanged($event) { - this.pageSize = $event; - this.currentPage = 1; - this.afterStakeholdersInitialized(); - } - - updateCurrentPage($event) { - this.currentPage = $event.value; - HelperFunctions.scrollToId('target'); - this.afterStakeholdersInitialized(); - } - - get typeAsLabel() { - return this.stakeholderUtils.types.find(type => type.value === this.stakeholderType).label; - } - - afterStakeholdersInitialized() { - // this is a method that will be overriden from the components extending this base component, if needed - this.showLoading = false; - } -} diff --git a/src/app/shared/browse-stakeholders/browse-stakeholders.component.ts b/src/app/shared/browse-stakeholders/browse-stakeholders.component.ts index bcb6d66..a4429e5 100644 --- a/src/app/shared/browse-stakeholders/browse-stakeholders.component.ts +++ b/src/app/shared/browse-stakeholders/browse-stakeholders.component.ts @@ -2,14 +2,23 @@ import {ChangeDetectorRef, Component} from "@angular/core"; import {ActivatedRoute, Router} from "@angular/router"; import {LayoutService} from "src/app/openaireLibrary/dashboard/sharedComponents/sidebar/layout.service"; import {FormBuilder} from "@angular/forms"; -import {BrowseStakeholderBaseComponent} from "../browse-stakeholder-base.component"; import {IrishMonitorService} from "../irish-monitor.service"; +import {StakeholderPublication} from "../irish"; +import {Option} from "../../openaireLibrary/sharedComponents/input/input.component"; +import { + BrowseStakeholderBaseComponent +} from "../../openaireLibrary/monitor/browse-stakeholder/browse-stakeholder-base.component"; @Component({ selector: 'browse-stakeholder', templateUrl: 'browse-stakeholders.component.html' }) -export class BrowseStakeholdersComponent extends BrowseStakeholderBaseComponent { +export class BrowseStakeholdersComponent extends BrowseStakeholderBaseComponent { + sortOptions: Option[] = [ + {value: null, label: 'Number of Publications'}, + {value: 'alphAsc', label: 'Alphabetically Asc. (A-Z)'}, + {value: 'alphDsc', label: 'Alphabetically Dsc. (Z-A)'}, + ]; constructor(protected _route: ActivatedRoute, protected _router: Router, @@ -19,4 +28,32 @@ export class BrowseStakeholdersComponent extends BrowseStakeholderBaseComponent protected fb: FormBuilder) { super(); } + + init() { + this.subscriptions.push(this.irishMonitorService.getStakeholdersWithPublications(this.stakeholderType).subscribe(stakeholders => { + this.stakeholders = stakeholders; + this.filteredStakeholders = stakeholders; + this.hasPublications = this.stakeholders.length > 0 && this.stakeholders.filter(stakeholder => stakeholder.publications > 0).length > 0; + if(!this.hasPublications) { + this.sortBy = 'alphAsc'; + this.sortOptions = this.sortOptions.filter(option => !!option.value); + } + this.sortByChanged(); + this.filtering(this.keywordControl.value); + })); + } + + sortByChanged() { + switch(this.sortBy) { + case 'alphAsc': + this.stakeholders = this.stakeholders.sort((a, b) => a['name'].localeCompare(b['name'])); + break; + case 'alphDsc': + this.stakeholders = this.stakeholders.sort((a, b) => b['name'].localeCompare(a['name'])); + break; + default: + this.stakeholders = this.stakeholders.sort((a, b) => b.publications - a.publications); + break; + } + } } diff --git a/src/app/shared/monitor/monitor.component.html b/src/app/shared/monitor/monitor.component.html index 0640012..d556435 100644 --- a/src/app/shared/monitor/monitor.component.html +++ b/src/app/shared/monitor/monitor.component.html @@ -1,7 +1,6 @@
- Active filters: