diff --git a/apps/datahub-e2e/src/e2e/organization-page.cy.ts b/apps/datahub-e2e/src/e2e/organization-page.cy.ts new file mode 100644 index 0000000000..5cddc7935c --- /dev/null +++ b/apps/datahub-e2e/src/e2e/organization-page.cy.ts @@ -0,0 +1,118 @@ +import 'cypress-real-events' + +describe('organizations', () => { + beforeEach(() => { + cy.visit('organization/Barbie%20Inc.') + + // aliases + cy.get('gn-ui-navigation-button').as('backButton') + cy.get('[data-test="organizationHeaderName"]').as('organizationHeaderName') + cy.get('[data-test="organizationHeaderWebsiteLink"]').as( + 'organizationHeaderWebsiteLink' + ) + cy.get('[data-test="organizationDescription"]').as( + 'organizationDescription' + ) + cy.get('gn-ui-max-lines').contains('Read more').as('readMoreButton') + cy.get('[data-test="organizationLogo"]').as('organizationLogo') + cy.get('[data-test="organizationDatasetCount"]').as( + 'organizationDatasetCount' + ) + cy.get('[data-test="organizationEmail"]').as('organizationEmail') + cy.get('[data-test="orgPageLasPubDat"]').as('orgPageLasPubDat') + cy.get('[data-test="orgDetailsSearchAllBtn"]').as('orgDetailsSearchAllBtn') + }) + + describe('general display', () => { + describe('header', () => { + describe('back button', () => { + beforeEach(() => { + cy.visit('organisations') + cy.visit('organization/Barbie%20Inc.') + }) + + it('back button goes to the previous visited page', () => { + cy.get('@backButton').click() + cy.url().should('include', '/organisations') + }) + }) + + it('should display the organization name', () => { + cy.get('@organizationHeaderName').should('contain', 'Barbie Inc.') + }) + + it('should display the organization website link', () => { + cy.get('@organizationHeaderWebsiteLink') + .should('be.visible') + .should('have.attr', 'href', 'https://www.barbie-inc.com/') + .and('have.attr', 'target', '_blank') + }) + }) + + describe('details', () => { + describe('left column', () => { + it('should display the organization description', () => { + cy.get('@organizationDescription').should('be.visible') + }) + + it('click on read more should expand the organization description', () => { + let initialDescription + let newDescription + + cy.get('@organizationDescription').then((firstDescription) => { + initialDescription = firstDescription + cy.get('@readMoreButton').trigger('click') + cy.get('@organizationDescription').then((secondDescription) => { + newDescription = secondDescription + expect(newDescription).to.not.equal(initialDescription) + }) + }) + }) + }) + + describe('right column', () => { + it('should display the organization logo', () => { + cy.get('@organizationLogo').should('be.visible') + }) + + it('should display the organization dataset count', () => { + cy.get('@organizationDatasetCount').should('be.visible') + }) + + it('a click on the organization dataset count should open the dataset search page filtered on the organization', () => { + cy.get('@organizationDatasetCount').then(($link) => { + const url = $link.prop('href') + cy.wrap($link).click() + + cy.url().should('eq', url) + }) + }) + + it('should display the organization email', () => { + cy.get('@organizationEmail') + .should('be.visible') + .and('have.attr', 'href', 'mailto:contact@barbie-inc.com') + }) + }) + + describe('last published datasets', () => { + it('should display the last published datasets', () => { + cy.get('@orgPageLasPubDat').should('be.visible') + }) + + it('should display the search all button', () => { + cy.get('@orgDetailsSearchAllBtn').should('be.visible') + }) + + it('a click on the search all button should open the dataset search page filtered on the organization', () => { + cy.get('@orgDetailsSearchAllBtn').then(($link) => { + const url = $link.prop('href') + cy.wrap($link).click() + + cy.url().should('eq', url) + }) + }) + }) + }) + }) +}) diff --git a/apps/datahub-e2e/src/e2e/organizations.cy.ts b/apps/datahub-e2e/src/e2e/organizations.cy.ts index b39da4ca39..ded2dc026d 100644 --- a/apps/datahub-e2e/src/e2e/organizations.cy.ts +++ b/apps/datahub-e2e/src/e2e/organizations.cy.ts @@ -77,14 +77,15 @@ describe('organizations', () => { }) describe('list features', () => { - it('should search with a filter on the selected org on click', () => { + it('should open the organization page', () => { cy.get('@organizationsName') .eq(10) .then(($clickedName) => { cy.get('@organizations').eq(10).click() - cy.url() - .should('include', 'publisher=') - .and('include', encodeURIComponent($clickedName.text().trim())) + cy.url().should( + 'contain', + `organization/${encodeURIComponent($clickedName.text().trim())}` + ) }) }) }) diff --git a/apps/datahub/src/app/app.module.ts b/apps/datahub/src/app/app.module.ts index 534338f09d..0c69562559 100644 --- a/apps/datahub/src/app/app.module.ts +++ b/apps/datahub/src/app/app.module.ts @@ -5,6 +5,7 @@ import { BrowserModule } from '@angular/platform-browser' import { Router, RouterModule } from '@angular/router' import { FeatureCatalogModule, + ORGANIZATION_PAGE_URL_TOKEN, ORGANIZATION_URL_TOKEN, } from '@geonetwork-ui/feature/catalog' import { @@ -94,7 +95,6 @@ import { UiWidgetsModule } from '@geonetwork-ui/ui/widgets' import { RecordUserFeedbacksComponent } from './record/record-user-feedbacks/record-user-feedbacks.component' import { LetDirective } from '@ngrx/component' import { OrganizationPageComponent } from './organization/organization-page/organization-page.component' -import { ORGANIZATION_PAGE_URL_TOKEN } from '../../../../libs/feature/catalog/src/lib/organization-url.token' export const metaReducers: MetaReducer[] = !environment.production ? [] : [] diff --git a/apps/datahub/src/app/organization/header-organization/organization-header.component.html b/apps/datahub/src/app/organization/header-organization/organization-header.component.html deleted file mode 100644 index 9c16ff9bc0..0000000000 --- a/apps/datahub/src/app/organization/header-organization/organization-header.component.html +++ /dev/null @@ -1,54 +0,0 @@ -
-
-
-
- - -
-
- -
-
-
- {{ organization.name }} -
-
- folder -

- {{ organization.recordCount }} -

-

- organization.header.recordCount -

- -

- - {{ organization.website.href }} - open_in_new -
-
-
-
diff --git a/apps/datahub/src/app/organization/organization-details/organization-details.component.css b/apps/datahub/src/app/organization/organization-details/organization-details.component.css index e69de29bb2..c0d50f2d1c 100644 --- a/apps/datahub/src/app/organization/organization-details/organization-details.component.css +++ b/apps/datahub/src/app/organization/organization-details/organization-details.component.css @@ -0,0 +1,15 @@ +.list-page-dot { + width: 6px; + height: 6px; + border-radius: 6px; + position: relative; +} + +.list-page-dot:after { + content: ''; + position: absolute; + left: -7px; + top: -7px; + width: 20px; + height: 20px; +} diff --git a/apps/datahub/src/app/organization/organization-details/organization-details.component.html b/apps/datahub/src/app/organization/organization-details/organization-details.component.html index 9ef5da0aef..d08616ad65 100644 --- a/apps/datahub/src/app/organization/organization-details/organization-details.component.html +++ b/apps/datahub/src/app/organization/organization-details/organization-details.component.html @@ -1,117 +1,108 @@ - -
-
-
- - - -
-
- -
- -
-
+ + +
+
+
+
+
+ +
+ +
+
+
-
- - - - -
- - -
- - + +
+ - + [routerLink]="['/', ROUTER_ROUTE_SEARCH]" + [queryParams]="{ publisher: organization.name }" + > + + - - organization.details.mailContact - - + +
-
-
-
-
-
-

- organization.lastPublishedDatasets -

- +
+
+
+
+

+ organization.lastPublishedDatasets +

+ - - -
+
-
- +
+
+ +
- - -
- -
-
+ +
+ +
+
- - - + + + +
-
+ + + + + diff --git a/apps/datahub/src/app/organization/organization-details/organization-details.component.spec.ts b/apps/datahub/src/app/organization/organization-details/organization-details.component.spec.ts index 6e4d6078ac..bec7bfd76b 100644 --- a/apps/datahub/src/app/organization/organization-details/organization-details.component.spec.ts +++ b/apps/datahub/src/app/organization/organization-details/organization-details.component.spec.ts @@ -52,10 +52,6 @@ class OrganisationsServiceMock { } const anOrganizationWithManyDatasets: Organization = ORGANISATIONS_FIXTURE[0] -const anOrganizationWithOnlyOneDataset: Organization = { - ...ORGANISATIONS_FIXTURE[0], - recordCount: 1, -} const oneDataset = [DATASET_RECORDS[0]] const manyDatasets = DATASET_RECORDS.concat(DATASET_RECORDS[0]) @@ -204,14 +200,9 @@ describe('OrganizationDetailsComponent', () => { organizationIsLoading.next(true) fixture.detectChanges() - const organizationDetailsLastPublishedDatasetsPreviousNextButtons = - getHTMLElement( - 'organizationDetailsLastPublishedDatasetsPreviousNextButtons' - ) + const orgDetailsNavBtn = getHTMLElement('orgDetailsNavBtn') - expect( - organizationDetailsLastPublishedDatasetsPreviousNextButtons - ).toBeFalsy() + expect(orgDetailsNavBtn).toBeFalsy() }) it('should not be displayed organization is loaded but has no pagination', () => { @@ -219,14 +210,9 @@ describe('OrganizationDetailsComponent', () => { totalPages.next(1) fixture.detectChanges() - const organizationDetailsLastPublishedDatasetsPreviousNextButtons = - getHTMLElement( - 'organizationDetailsLastPublishedDatasetsPreviousNextButtons' - ) + const orgDetailsNavBtn = getHTMLElement('orgDetailsNavBtn') - expect( - organizationDetailsLastPublishedDatasetsPreviousNextButtons - ).toBeFalsy() + expect(orgDetailsNavBtn).toBeFalsy() }) it('should be displayed if organization is loadded and have pagination', () => { @@ -234,39 +220,29 @@ describe('OrganizationDetailsComponent', () => { totalPages.next(10) fixture.detectChanges() - const organizationDetailsLastPublishedDatasetsPreviousNextButtons = - getHTMLElement( - 'organizationDetailsLastPublishedDatasetsPreviousNextButtons' - ) + const orgDetailsNavBtn = getHTMLElement('orgDetailsNavBtn') - expect( - organizationDetailsLastPublishedDatasetsPreviousNextButtons - ).toBeTruthy() + expect(orgDetailsNavBtn).toBeTruthy() }) it('should call paginate from the facade if button is clicked', () => { const initialPageNumber = currentPage.getValue() const nextPageNumber = initialPageNumber + 1 - const organizationDetailsLastPublishedDatasetsPreviousNextButtons = - getHTMLElement( - 'organizationDetailsLastPublishedDatasetsPreviousNextButtons' - ) + const orgDetailsNavBtn = getHTMLElement('orgDetailsNavBtn') - const nextButton = - organizationDetailsLastPublishedDatasetsPreviousNextButtons?.querySelector( - '[data-test="nextButton"]' - ) as HTMLElement + const nextButton = orgDetailsNavBtn?.querySelector( + '[data-test="nextButton"]' + ) as HTMLElement ;(nextButton?.firstChild as HTMLElement).click() fixture.detectChanges() expect(searchFacade.paginate).toHaveBeenCalledWith(nextPageNumber) - const previousButton = - organizationDetailsLastPublishedDatasetsPreviousNextButtons?.querySelector( - '[data-test="previousButton"]' - ) as HTMLElement + const previousButton = orgDetailsNavBtn?.querySelector( + '[data-test="previousButton"]' + ) as HTMLElement ;(previousButton?.firstChild as HTMLElement).click() fixture.detectChanges() @@ -276,20 +252,13 @@ describe('OrganizationDetailsComponent', () => { describe('Search all button', () => { it('should send to the search page filtered on the correct organization', () => { - const organizationDetailsLastPublishedDatasetsSearchAllButton = - getHTMLElement( - 'organizationDetailsLastPublishedDatasetsSearchAllButton' - ) - - expect( - organizationDetailsLastPublishedDatasetsSearchAllButton - ).toBeTruthy() - - expect( - organizationDetailsLastPublishedDatasetsSearchAllButton?.getAttribute( - 'href' - ) - ).toEqual( + const orgDetailsSearchAllBtn = getHTMLElement( + 'orgDetailsSearchAllBtn' + ) + + expect(orgDetailsSearchAllBtn).toBeTruthy() + + expect(orgDetailsSearchAllBtn?.getAttribute('href')).toEqual( `/${ROUTER_ROUTE_SEARCH}?publisher=${encodeURIComponent( anOrganizationWithManyDatasets.name )}` @@ -300,21 +269,26 @@ describe('OrganizationDetailsComponent', () => { describe('Last published datasets', () => { it('should display the datasets properly', () => { - const organizationPageLastPublishedDatasets = getHTMLElement( - 'organizationPageLastPublishedDatasets' - ) + const orgPageLasPubDat = getHTMLElement('orgPageLasPubDat') - expect(organizationPageLastPublishedDatasets).toBeTruthy() - expect(organizationPageLastPublishedDatasets?.children.length).toEqual( - desiredPageSize - ) + expect(orgPageLasPubDat).toBeTruthy() + expect(orgPageLasPubDat?.children.length).toEqual(desiredPageSize) results.next(oneDataset) fixture.detectChanges() - expect(organizationPageLastPublishedDatasets?.children.length).toEqual( - 1 - ) + expect(orgPageLasPubDat?.children.length).toEqual(1) + }) + + it('should display the orgHasNodataset error component if the org has no dataset', () => { + results.next([]) + fixture.detectChanges() + + const orgHasNoDataset = getHTMLElement('lastPubliDatasets') + + console.log(orgHasNoDataset?.outerHTML) + + expect(orgHasNoDataset).toBeTruthy() }) }) }) diff --git a/apps/datahub/src/app/organization/organization-details/organization-details.component.ts b/apps/datahub/src/app/organization/organization-details/organization-details.component.ts index 23ab3fd7a2..2656219bee 100644 --- a/apps/datahub/src/app/organization/organization-details/organization-details.component.ts +++ b/apps/datahub/src/app/organization/organization-details/organization-details.component.ts @@ -4,11 +4,13 @@ import { ChangeDetectorRef, Component, Input, + OnChanges, OnDestroy, OnInit, + SimpleChanges, ViewChild, } from '@angular/core' -import { AsyncPipe, NgForOf, NgIf } from '@angular/common' +import { AsyncPipe, NgClass, NgForOf, NgIf } from '@angular/common' import { CatalogRecord, Organization, @@ -32,7 +34,15 @@ import { } from '@geonetwork-ui/ui/elements' import { UiSearchModule } from '@geonetwork-ui/ui/search' import { SearchFacade } from '@geonetwork-ui/feature/search' -import { Observable, of, Subscription, switchMap } from 'rxjs' +import { + BehaviorSubject, + combineLatest, + distinctUntilChanged, + Observable, + of, + Subscription, + switchMap, +} from 'rxjs' import { UiDatavizModule } from '@geonetwork-ui/ui/dataviz' import { RouterLink } from '@angular/router' import { ROUTER_ROUTE_SEARCH } from '@geonetwork-ui/feature/router' @@ -63,27 +73,36 @@ import { UiWidgetsModule } from '@geonetwork-ui/ui/widgets' UiDatavizModule, RouterLink, UiWidgetsModule, + NgClass, ], }) export class OrganizationDetailsComponent - implements OnInit, AfterViewInit, OnDestroy + implements OnInit, AfterViewInit, OnDestroy, OnChanges { protected readonly Error = Error protected readonly ErrorType = ErrorType + protected readonly ROUTER_ROUTE_SEARCH = ROUTER_ROUTE_SEARCH - @Input() organization: Organization + protected get pages() { + return new Array(this.totalPages).fill(0).map((_, i) => i + 1) + } lastPublishedDatasets$: Observable = of([]) subscriptions$: Subscription = new Subscription() - isOrganizationsLoading = true + isSearchFacadeLoading = true totalPages = 0 currentPage = 1 isFirstPage = this.currentPage === 1 isLastPage = false + organizationHasChanged$ = new BehaviorSubject(undefined) + + @Input() organization?: Organization + @Input() paginationContainerClass = 'w-full bottom-0 top-auto' + @ViewChild(BlockListComponent) list: BlockListComponent constructor( @@ -95,19 +114,30 @@ export class OrganizationDetailsComponent ngOnInit(): void { this.searchFacade.setPageSize(3) - this.lastPublishedDatasets$ = this.organizationsService - .getFiltersForOrgs([this.organization]) - .pipe( - switchMap((filters) => { - return this.searchFacade - .setFilters(filters) - .setSortBy(['desc', 'changeDate']).results$ - }) - ) + this.lastPublishedDatasets$ = this.organizationHasChanged$.pipe( + distinctUntilChanged(), + switchMap(() => { + return this.organizationsService + .getFiltersForOrgs([this.organization]) + .pipe( + switchMap((filters) => { + return this.searchFacade + .setFilters(filters) + .setSortBy(['desc', 'changeDate']).results$ + }) + ) + }) + ) this.manageSubscriptions() } + ngOnChanges(changes: SimpleChanges): void { + if (changes['organization']) { + this.organizationHasChanged$.next() + } + } + ngAfterViewInit() { // this is required to show the pagination correctly this.changeDetector.detectChanges() @@ -129,38 +159,35 @@ export class OrganizationDetailsComponent } } - private manageSubscriptions() { - this.subscriptions$.add( - this.searchFacade.isLoading$.subscribe( - (isOrganizationsLoading) => - (this.isOrganizationsLoading = isOrganizationsLoading) - ) - ) - - this.subscriptions$.add( - this.searchFacade.totalPages$.subscribe( - (totalPages) => (this.totalPages = totalPages) - ) - ) - - this.subscriptions$.add( - this.searchFacade.isBeginningOfResults$.subscribe( - (isBeginningOfResults) => (this.isFirstPage = isBeginningOfResults) - ) - ) - - this.subscriptions$.add( - this.searchFacade.isEndOfResults$.subscribe( - (isEndOfResults) => (this.isLastPage = isEndOfResults) - ) - ) + goToPage(page: number) { + this.searchFacade.paginate(page) + } + private manageSubscriptions() { this.subscriptions$.add( - this.searchFacade.currentPage$.subscribe( - (currentPage) => (this.currentPage = currentPage) + combineLatest([ + this.searchFacade.isLoading$.pipe(distinctUntilChanged()), + this.searchFacade.totalPages$.pipe(distinctUntilChanged()), + this.searchFacade.isBeginningOfResults$.pipe(distinctUntilChanged()), + this.searchFacade.isEndOfResults$.pipe(distinctUntilChanged()), + this.searchFacade.currentPage$.pipe(distinctUntilChanged()), + ]).subscribe( + ([ + isSearchFacadeLoading, + totalPages, + isBeginningOfResults, + isEndOfResults, + currentPage, + ]) => { + this.isSearchFacadeLoading = isSearchFacadeLoading + this.totalPages = totalPages + this.isFirstPage = isBeginningOfResults + this.isLastPage = isEndOfResults + this.currentPage = currentPage + } ) ) } - protected readonly ROUTER_ROUTE_SEARCH = ROUTER_ROUTE_SEARCH + protected readonly errorTypes = ErrorType } diff --git a/apps/datahub/src/app/organization/header-organization/organization-header.component.css b/apps/datahub/src/app/organization/organization-header/organization-header.component.css similarity index 100% rename from apps/datahub/src/app/organization/header-organization/organization-header.component.css rename to apps/datahub/src/app/organization/organization-header/organization-header.component.css diff --git a/apps/datahub/src/app/organization/organization-header/organization-header.component.html b/apps/datahub/src/app/organization/organization-header/organization-header.component.html new file mode 100644 index 0000000000..42e90a94bd --- /dev/null +++ b/apps/datahub/src/app/organization/organization-header/organization-header.component.html @@ -0,0 +1,60 @@ +
+
+
+
+ + +
+
+ +
+
+ +
+ {{ organization.name }} +
+
+ folder +

+ {{ organization.recordCount }} +

+

+ organization.header.recordCount +

+ +

+ + {{ organization.website.href }} + open_in_new +
+
+
+
+
diff --git a/apps/datahub/src/app/organization/header-organization/organization-header.component.spec.ts b/apps/datahub/src/app/organization/organization-header/organization-header.component.spec.ts similarity index 100% rename from apps/datahub/src/app/organization/header-organization/organization-header.component.spec.ts rename to apps/datahub/src/app/organization/organization-header/organization-header.component.spec.ts diff --git a/apps/datahub/src/app/organization/header-organization/organization-header.component.ts b/apps/datahub/src/app/organization/organization-header/organization-header.component.ts similarity index 75% rename from apps/datahub/src/app/organization/header-organization/organization-header.component.ts rename to apps/datahub/src/app/organization/organization-header/organization-header.component.ts index 58c51e903f..8e62fd986d 100644 --- a/apps/datahub/src/app/organization/header-organization/organization-header.component.ts +++ b/apps/datahub/src/app/organization/organization-header/organization-header.component.ts @@ -6,6 +6,8 @@ import { UiCatalogModule } from '@geonetwork-ui/ui/catalog' import { Organization } from '@geonetwork-ui/common/domain/model/record' import { AsyncPipe, Location, NgIf } from '@angular/common' import { MatIconModule } from '@angular/material/icon' +import { ErrorType, UiElementsModule } from '@geonetwork-ui/ui/elements' +import { Router } from '@angular/router' @Component({ selector: 'datahub-organization-header', @@ -20,10 +22,11 @@ import { MatIconModule } from '@angular/material/icon' NgIf, MatIconModule, AsyncPipe, + UiElementsModule, ], }) export class OrganizationHeaderComponent { - @Input() organization: Organization + @Input() organization?: Organization backgroundCss = getThemeConfig().HEADER_BACKGROUND || @@ -31,9 +34,13 @@ export class OrganizationHeaderComponent { foregroundColor = getThemeConfig().HEADER_FOREGROUND_COLOR || '#ffffff' showLanguageSwitcher = getGlobalConfig().LANGUAGES?.length > 0 - constructor(private location: Location) {} + constructor(private location: Location, private router: Router) {} back() { - this.location.back() + this.organization + ? this.location.back() + : this.router.navigateByUrl('/organisations') } + + protected readonly errorTypes = ErrorType } diff --git a/apps/datahub/src/app/organization/organization-page/organization-page.component.ts b/apps/datahub/src/app/organization/organization-page/organization-page.component.ts index a1dc77c981..99cc91b16b 100644 --- a/apps/datahub/src/app/organization/organization-page/organization-page.component.ts +++ b/apps/datahub/src/app/organization/organization-page/organization-page.component.ts @@ -1,7 +1,7 @@ import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core' import { RouterFacade } from '@geonetwork-ui/feature/router' import { AsyncPipe, NgIf } from '@angular/common' -import { OrganizationHeaderComponent } from '../header-organization/organization-header.component' +import { OrganizationHeaderComponent } from '../organization-header/organization-header.component' import { OrganizationDetailsComponent } from '../organization-details/organization-details.component' import { combineLatest, Observable, of, switchMap } from 'rxjs' import { filter } from 'rxjs/operators' diff --git a/libs/api/repository/src/lib/gn4/organizations/organizations-from-groups.service.spec.ts b/libs/api/repository/src/lib/gn4/organizations/organizations-from-groups.service.spec.ts index fe4c0ad104..dd77d0a52c 100644 --- a/libs/api/repository/src/lib/gn4/organizations/organizations-from-groups.service.spec.ts +++ b/libs/api/repository/src/lib/gn4/organizations/organizations-from-groups.service.spec.ts @@ -50,12 +50,14 @@ const sampleOrgA: Organization = { recordCount: 80, description: 'A description for Köniz Municipality', website: new URL('https://www.koeniz.ch/'), + email: 'reto.jau@koeniz.ch', } const sampleOrgB: Organization = { logoUrl: new URL('http://localhost/geonetwork/images/harvesting/bakom.png'), name: 'Office fédéral de la communication OFCOM', recordCount: 50, website: new URL('http://www.bakom.admin.ch/'), + email: 'christian.meier@bakom.admin.ch', } const sampleOrgC: Organization = { logoUrl: new URL( @@ -65,6 +67,7 @@ const sampleOrgC: Organization = { recordCount: 20, description: 'A description for ARE', website: new URL('http://www.are.admin.ch/'), + email: 'rolf.giezendanner@are.admin.ch', } class SearchApiServiceMock { diff --git a/libs/api/repository/src/lib/gn4/organizations/organizations-from-metadata.service.spec.ts b/libs/api/repository/src/lib/gn4/organizations/organizations-from-metadata.service.spec.ts index 10fb3101b8..5f17e9e1d7 100644 --- a/libs/api/repository/src/lib/gn4/organizations/organizations-from-metadata.service.spec.ts +++ b/libs/api/repository/src/lib/gn4/organizations/organizations-from-metadata.service.spec.ts @@ -25,21 +25,22 @@ const sampleOrgA: Organization = { name: 'ARE', recordCount: 5, website: new URL('http://www.are.admin.ch/'), + email: 'rolf.giezendanner@are.admin.ch', } const sampleOrgB: Organization = { logoUrl: new URL('http://localhost/geonetwork/images/harvesting/bakom.png'), name: 'BAKOM', recordCount: 2, website: new URL('http://www.bakom.admin.ch/'), + email: 'christian.meier@bakom.admin.ch', } const sampleOrgC: Organization = { - logoUrl: new URL( - 'http://localhost/geonetwork/images/harvesting/ifremer-org.png' - ), + logoUrl: new URL('http://localhost/geonetwork/images/harvesting/ifremer.png'), name: 'Ifremer', recordCount: 1, description: "Institut français de recherche pour l'exploitation de la mer", website: new URL('https://www.ifremer.fr/'), + email: 'ifremer.ifremer@ifremer.admin.fr', } let geonetworkVersion: string diff --git a/libs/common/domain/src/lib/model/user/user.model.ts b/libs/common/domain/src/lib/model/user/user.model.ts index fefd657049..591fc7bf18 100644 --- a/libs/common/domain/src/lib/model/user/user.model.ts +++ b/libs/common/domain/src/lib/model/user/user.model.ts @@ -5,6 +5,6 @@ export interface UserModel { name: string surname: string email: string - organization: string + organisation: string profileIcon?: string } diff --git a/libs/feature/catalog/src/index.ts b/libs/feature/catalog/src/index.ts index efa22c7852..54cc255a57 100644 --- a/libs/feature/catalog/src/index.ts +++ b/libs/feature/catalog/src/index.ts @@ -1,4 +1,5 @@ export * from './lib/feature-catalog.module' +export * from './lib/organization-url.token' export * from './lib/sources/sources.service' export * from './lib/sources/sources.model' export * from './lib/records/records.service' diff --git a/libs/feature/catalog/src/lib/my-org/my-org.service.ts b/libs/feature/catalog/src/lib/my-org/my-org.service.ts index 324884f5a7..8840cc3bba 100644 --- a/libs/feature/catalog/src/lib/my-org/my-org.service.ts +++ b/libs/feature/catalog/src/lib/my-org/my-org.service.ts @@ -27,12 +27,12 @@ export class MyOrgService { this.orgService.organisations$, ]).pipe( map(([user, allUsers, orgs]) => { - const orgName = user.organization + const orgName = user.organisation const org = orgs.find((org) => org.name === orgName) const logoUrl = org?.logoUrl?.toString() const recordCount = org?.recordCount const userList = allUsers.filter( - (user) => user.organization === orgName + (user) => user.organisation === orgName ) const userCount = userList.length return { diff --git a/libs/feature/catalog/src/lib/organisations/organisations.component.spec.ts b/libs/feature/catalog/src/lib/organisations/organisations.component.spec.ts index 70e97b09b7..138e62fdeb 100644 --- a/libs/feature/catalog/src/lib/organisations/organisations.component.spec.ts +++ b/libs/feature/catalog/src/lib/organisations/organisations.component.spec.ts @@ -4,6 +4,7 @@ import { DebugElement, EventEmitter, Input, + NO_ERRORS_SCHEMA, Output, } from '@angular/core' import { ComponentFixture, TestBed } from '@angular/core/testing' @@ -27,8 +28,8 @@ class OrganisationsFilterMockComponent { template: '
', }) class OrganisationPreviewMockComponent { - @Input() organisation: Organization - @Output() clickedOrganisation = new EventEmitter() + @Input() organization: Organization + @Output() clickedOrganization = new EventEmitter() } @Component({ @@ -85,6 +86,7 @@ describe('OrganisationsComponent', () => { useClass: OrganisationsServiceMock, }, ], + schemas: [NO_ERRORS_SCHEMA], }) .overrideComponent(OrganisationsComponent, { set: { changeDetection: ChangeDetectionStrategy.Default }, @@ -118,10 +120,10 @@ describe('OrganisationsComponent', () => { .map((debugElement) => debugElement.componentInstance) }) it('should pass first organisation (sorted by name-asc) to first ui preview component', () => { - expect(orgPreviewComponents[0].organisation.name).toEqual('A Data Org') + expect(orgPreviewComponents[0].organization.name).toEqual('A Data Org') }) it('should pass 6th organisation (sorted by name-asc) on page to 6th ui preview component', () => { - expect(orgPreviewComponents[5].organisation.name).toEqual('E Data Org') + expect(orgPreviewComponents[5].organization.name).toEqual('E Data Org') }) }) describe('pass params to ui pagination component', () => { @@ -152,13 +154,13 @@ describe('OrganisationsComponent', () => { expect(paginationComponentDE.componentInstance.currentPage).toEqual(2) }) it('should pass first organisation of second page (sorted by name-asc) to first ui preview component', () => { - expect(orgPreviewComponents[0].organisation.name).toEqual( + expect(orgPreviewComponents[0].organization.name).toEqual( 'é Data Org' ) }) it('should pass last organisation of second page (sorted by name-asc) to last ui preview component', () => { expect( - orgPreviewComponents[orgPreviewComponents.length - 1].organisation + orgPreviewComponents[orgPreviewComponents.length - 1].organization .name ).toEqual('J Data Org') }) @@ -193,12 +195,12 @@ describe('OrganisationsComponent', () => { expect(organisations[0]).toEqual(ORGANISATIONS_FIXTURE[5]) }) it('should pass organisation with max recordCount to first preview component', () => { - expect(orgPreviewComponents[0].organisation).toEqual( + expect(orgPreviewComponents[0].organization).toEqual( ORGANISATIONS_FIXTURE[5] ) }) it('should pass organisation with 6th highest recordCount to 6th preview component', () => { - expect(orgPreviewComponents[5].organisation).toEqual( + expect(orgPreviewComponents[5].organization).toEqual( ORGANISATIONS_FIXTURE[3] ) }) diff --git a/libs/feature/router/src/lib/default/router.service.spec.ts b/libs/feature/router/src/lib/default/router.service.spec.ts index bfae57c838..02e1736354 100644 --- a/libs/feature/router/src/lib/default/router.service.spec.ts +++ b/libs/feature/router/src/lib/default/router.service.spec.ts @@ -3,18 +3,24 @@ import { Router } from '@angular/router' import { RouterService } from './router.service' import { ROUTER_CONFIG } from './router.config' +import { ROUTER_ROUTE_ORGANIZATION } from './constants' const SearchRouteComponent = { name: 'searchRoute', } const RecordRouteComponent = { - name: 'recordhRoute', + name: 'recordRoute', +} + +const OrganizationRouteComponent = { + name: 'organizationRoute', } const routerConfigMock = { searchStateId: 'main', searchRouteComponent: SearchRouteComponent, recordRouteComponent: RecordRouteComponent, + organizationRouteComponent: OrganizationRouteComponent, } const RouterMock = { resetConfig: jest.fn(), @@ -37,10 +43,16 @@ const expectedRoutes = [ }, { component: { - name: 'recordhRoute', + name: 'recordRoute', }, path: 'dataset/:metadataUuid', }, + { + path: `${ROUTER_ROUTE_ORGANIZATION}/:name`, + component: { + name: 'organizationRoute', + }, + }, ] describe('RouterService', () => { let service: RouterService diff --git a/libs/ui/elements/src/lib/error/error.component.html b/libs/ui/elements/src/lib/error/error.component.html index 0b0c302281..e06e2a1b2f 100644 --- a/libs/ui/elements/src/lib/error/error.component.html +++ b/libs/ui/elements/src/lib/error/error.component.html @@ -8,11 +8,11 @@
face question_mark + >question_mark + question_mark + >question_mark +
search.error.couldNotReachApi
@@ -36,12 +36,11 @@
computer question_mark + >question_mark +
search.error.organizationHasNoDataset
-
computer question_mark + >question_mark +
search.error.recordNotFound
{{ error }}
+
+
+ computer + question_mark + +
+
+ search.error.organizationNotFound +
+
{{ error }}
+
diff --git a/libs/ui/elements/src/lib/error/error.component.ts b/libs/ui/elements/src/lib/error/error.component.ts index 6129f28a5f..a7b79425b0 100644 --- a/libs/ui/elements/src/lib/error/error.component.ts +++ b/libs/ui/elements/src/lib/error/error.component.ts @@ -6,6 +6,7 @@ export enum ErrorType { RECORD_NOT_FOUND, DATASET_HAS_NO_LINK, ORGANIZATION_HAS_NO_DATASET, + ORGANIZATION_NOT_FOUND, } @Component({ diff --git a/libs/ui/elements/src/lib/related-record-card/related-record-card.component.html b/libs/ui/elements/src/lib/related-record-card/related-record-card.component.html index 932c405b23..85fb920c14 100644 --- a/libs/ui/elements/src/lib/related-record-card/related-record-card.component.html +++ b/libs/ui/elements/src/lib/related-record-card/related-record-card.component.html @@ -1,5 +1,5 @@ diff --git a/libs/ui/elements/src/lib/related-record-card/related-record-card.component.ts b/libs/ui/elements/src/lib/related-record-card/related-record-card.component.ts index f883b3c31b..c166ea575d 100644 --- a/libs/ui/elements/src/lib/related-record-card/related-record-card.component.ts +++ b/libs/ui/elements/src/lib/related-record-card/related-record-card.component.ts @@ -1,4 +1,4 @@ -import { Component, ChangeDetectionStrategy, Input } from '@angular/core' +import { ChangeDetectionStrategy, Component, Input } from '@angular/core' import { CatalogRecord } from '@geonetwork-ui/common/domain/model/record' @Component({ @@ -8,5 +8,26 @@ import { CatalogRecord } from '@geonetwork-ui/common/domain/model/record' changeDetection: ChangeDetectionStrategy.OnPush, }) export class RelatedRecordCardComponent { + private readonly baseClasses: string + @Input() record: CatalogRecord + @Input() extraClass = '' + + constructor() { + this.baseClasses = [ + 'w-72', + 'h-96', + 'overflow-hidden', + 'rounded-lg', + 'bg-white', + 'cursor-pointer', + 'block', + 'hover:-translate-y-2 ', + 'duration-[180ms]', + ].join(' ') + } + + get classList() { + return `${this.baseClasses} ${this.extraClass}` + } } diff --git a/libs/ui/layout/src/lib/max-lines/max-lines.component.spec.ts b/libs/ui/layout/src/lib/max-lines/max-lines.component.spec.ts index dc28d6869c..075b5aae7c 100644 --- a/libs/ui/layout/src/lib/max-lines/max-lines.component.spec.ts +++ b/libs/ui/layout/src/lib/max-lines/max-lines.component.spec.ts @@ -4,6 +4,13 @@ import { MaxLinesComponent } from './max-lines.component' import { Component, importProvidersFrom } from '@angular/core' import { TranslateModule } from '@ngx-translate/core' +// Mock implementation of ResizeObserver +class ResizeObserverMock { + observe = jest.fn() + unobserve = jest.fn() + disconnect = jest.fn() +} + @Component({ template: ` @@ -22,10 +29,12 @@ describe('MaxLinesComponent', () => { let maxLinesComponent: MaxLinesComponent beforeEach(() => { + ;(window as any).ResizeObserver = ResizeObserverMock + TestBed.configureTestingModule({ - imports: [TranslateModule.forRoot()], + imports: [TranslateModule.forRoot(), MaxLinesComponent], providers: [importProvidersFrom(TranslateModule.forRoot())], - declarations: [MaxLinesComponent, TestHostComponent], + declarations: [TestHostComponent], }) fixture = TestBed.createComponent(TestHostComponent) hostComponent = fixture.componentInstance diff --git a/libs/ui/layout/src/lib/max-lines/max-lines.component.stories.ts b/libs/ui/layout/src/lib/max-lines/max-lines.component.stories.ts index c93ce310e2..1a811f97ab 100644 --- a/libs/ui/layout/src/lib/max-lines/max-lines.component.stories.ts +++ b/libs/ui/layout/src/lib/max-lines/max-lines.component.stories.ts @@ -10,7 +10,7 @@ import { TranslateModule } from '@ngx-translate/core' import { TRANSLATE_DEFAULT_CONFIG, UtilI18nModule, -} from '../../../../../util/i18n/src' +} from '@geonetwork-ui/util/i18n' import { importProvidersFrom } from '@angular/core' export default { diff --git a/support-services/docker-entrypoint-initdb.d/dump b/support-services/docker-entrypoint-initdb.d/dump index 0a433c68ec..f1f88acdff 100644 Binary files a/support-services/docker-entrypoint-initdb.d/dump and b/support-services/docker-entrypoint-initdb.d/dump differ diff --git a/translations/de.json b/translations/de.json index 51ea7ea43e..1f7936a6b2 100644 --- a/translations/de.json +++ b/translations/de.json @@ -245,6 +245,7 @@ "organization.details.mailContact": "", "organization.datasets": "", "organization.lastPublishedDatasets": "", + "organization.lastPublishedDatasets.searchAllButton": "", "pagination.nextPage": "Nächste Seite", "pagination.page": "Seite", "pagination.pageOf": "von", @@ -345,6 +346,7 @@ "search.error.receivedError": "Ein Fehler ist aufgetreten", "search.error.recordHasnolink": "", "search.error.recordNotFound": "Der Datensatz mit der Kennung \"{ id }\" konnte nicht gefunden werden.", + "search.error.organizationNotFound": "", "search.error.organizationHasNoDataset": "", "search.field.any.placeholder": "Suche Datensätze ...", "search.field.sortBy": "Sortieren nach:", diff --git a/translations/en.json b/translations/en.json index c9c3eff5dd..4ea86a9ea6 100644 --- a/translations/en.json +++ b/translations/en.json @@ -245,6 +245,7 @@ "organization.details.mailContact": "Contact by email", "organization.datasets": "Datasets", "organization.lastPublishedDatasets": "Last published datasets", + "organization.lastPublishedDatasets.searchAllButton": "Search all", "pagination.nextPage": "Next page", "pagination.page": "page", "pagination.pageOf": "of", @@ -345,6 +346,7 @@ "search.error.receivedError": "An error was received", "search.error.recordHasnolink": "This record currently has no link yet, please come back later.", "search.error.recordNotFound": "The record with identifier \"{ id }\" could not be found.", + "search.error.organizationNotFound": "This organization could not be found.", "search.error.organizationHasNoDataset": "This organization has no dataset yet.", "search.field.any.placeholder": "Search datasets ...", "search.field.sortBy": "Sort by:", diff --git a/translations/es.json b/translations/es.json index 6905a25102..341cc8961f 100644 --- a/translations/es.json +++ b/translations/es.json @@ -245,6 +245,7 @@ "organization.details.mailContact": "", "organization.datasets": "", "organization.lastPublishedDatasets": "", + "organization.lastPublishedDatasets.searchAllButton": "", "pagination.nextPage": "", "pagination.page": "", "pagination.pageOf": "", @@ -345,6 +346,7 @@ "search.error.receivedError": "", "search.error.recordHasnolink": "", "search.error.recordNotFound": "", + "search.error.organizationNotFound": "", "search.error.organizationHasNoDataset": "", "search.field.any.placeholder": "", "search.field.sortBy": "", diff --git a/translations/fr.json b/translations/fr.json index 90b6272333..5175e9ad24 100644 --- a/translations/fr.json +++ b/translations/fr.json @@ -245,6 +245,7 @@ "organization.details.mailContact": "Contacter par mail", "organization.datasets": "Données", "organization.lastPublishedDatasets": "Dernières données publiées", + "organization.lastPublishedDatasets.searchAllButton": "Rechercher tous", "pagination.nextPage": "Page suivante", "pagination.page": "page", "pagination.pageOf": "sur", @@ -345,6 +346,7 @@ "search.error.receivedError": "Erreur retournée", "search.error.recordHasnolink": "Ce dataset n'a pas encore de lien, réessayez plus tard s'il vous plaît.", "search.error.recordNotFound": "Cette donnée n'a pu être trouvée.", + "search.error.organizationNotFound": "L'organisation n'a pas pu être trouvée.", "search.error.organizationHasNoDataset": "Cette organisation n'a pas encore de données.", "search.field.any.placeholder": "Rechercher une donnée...", "search.field.sortBy": "Trier par :", diff --git a/translations/it.json b/translations/it.json index 88b55b64bb..bfcb2c988f 100644 --- a/translations/it.json +++ b/translations/it.json @@ -245,6 +245,7 @@ "organization.details.mailContact": "", "organization.datasets": "", "organization.lastPublishedDatasets": "", + "organization.lastPublishedDatasets.searchAllButton": "", "pagination.nextPage": "Pagina successiva", "pagination.page": "pagina", "pagination.pageOf": "di", @@ -345,6 +346,7 @@ "search.error.receivedError": "Errore ricevuto", "search.error.recordHasnolink": "", "search.error.recordNotFound": "Impossibile trovare questo dato", + "search.error.organizationNotFound": "", "search.error.organizationHasNoDataset": "", "search.field.any.placeholder": "Cerca un dato...", "search.field.sortBy": "Ordina per:", diff --git a/translations/nl.json b/translations/nl.json index 837e08bd73..b7d0823e3a 100644 --- a/translations/nl.json +++ b/translations/nl.json @@ -245,6 +245,7 @@ "organization.details.mailContact": "", "organization.datasets": "", "organization.lastPublishedDatasets": "", + "organization.lastPublishedDatasets.searchAllButton": "", "pagination.nextPage": "", "pagination.page": "", "pagination.pageOf": "", @@ -345,6 +346,7 @@ "search.error.receivedError": "", "search.error.recordHasnolink": "", "search.error.recordNotFound": "", + "search.error.organizationNotFound": "", "search.error.organizationHasNoDataset": "", "search.field.any.placeholder": "", "search.field.sortBy": "", diff --git a/translations/pt.json b/translations/pt.json index d79183c173..096eef05fd 100644 --- a/translations/pt.json +++ b/translations/pt.json @@ -245,6 +245,7 @@ "organization.details.mailContact": "", "organization.datasets": "", "organization.lastPublishedDatasets": "", + "organization.lastPublishedDatasets.searchAllButton": "", "pagination.nextPage": "", "pagination.page": "", "pagination.pageOf": "", @@ -345,6 +346,7 @@ "search.error.receivedError": "", "search.error.recordHasnolink": "", "search.error.recordNotFound": "", + "search.error.organizationNotFound": "", "search.error.organizationHasNoDataset": "", "search.field.any.placeholder": "", "search.field.sortBy": "", diff --git a/translations/sk.json b/translations/sk.json index 4c601e5da3..56768147b0 100644 --- a/translations/sk.json +++ b/translations/sk.json @@ -245,6 +245,7 @@ "organization.details.mailContact": "", "organization.datasets": "", "organization.lastPublishedDatasets": "", + "organization.lastPublishedDatasets.searchAllButton": "", "pagination.nextPage": "Ďalšia stránka", "pagination.page": "strana", "pagination.pageOf": "z", @@ -345,6 +346,7 @@ "search.error.receivedError": "Bola zaznamenaná chyba", "search.error.recordHasnolink": "", "search.error.recordNotFound": "Záznam s identifikátorom \"{ id }\" sa nepodarilo nájsť.", + "search.error.organizationNotFound": "", "search.error.organizationHasNoDataset": "", "search.field.any.placeholder": "Hľadať datasety ...", "search.field.sortBy": "Zoradiť podľa:",