From 1d73171f51b1130aba0a30a2113dbd6f5e8db0b0 Mon Sep 17 00:00:00 2001 From: Florian Necas Date: Thu, 5 Oct 2023 09:50:06 +0200 Subject: [PATCH] geocat: add geocat-header with langage switcher --- apps/datahub/src/app/app.component.html | 1 + apps/datahub/src/app/app.module.ts | 2 ++ .../geocat-header.component.html | 17 ++++++++++ .../geocat-header.component.spec.ts | 28 +++++++++++++++ .../geocat-header/geocat-header.component.ts | 34 +++++++++++++++++++ .../home-header/home-header.component.html | 4 +-- .../home-header/home-header.component.spec.ts | 3 +- .../organization-header.component.html | 4 +-- 8 files changed, 88 insertions(+), 5 deletions(-) create mode 100644 apps/datahub/src/app/home/geocat-header/geocat-header.component.html create mode 100644 apps/datahub/src/app/home/geocat-header/geocat-header.component.spec.ts create mode 100644 apps/datahub/src/app/home/geocat-header/geocat-header.component.ts diff --git a/apps/datahub/src/app/app.component.html b/apps/datahub/src/app/app.component.html index feeab422e..7c528cf29 100644 --- a/apps/datahub/src/app/app.component.html +++ b/apps/datahub/src/app/app.component.html @@ -2,5 +2,6 @@ gnUiSearchRouterContainer="mainSearch" class="selection:bg-primary-lightest selection:text-primary-darker" > + diff --git a/apps/datahub/src/app/app.module.ts b/apps/datahub/src/app/app.module.ts index d7a5ade21..5a7f8de82 100644 --- a/apps/datahub/src/app/app.module.ts +++ b/apps/datahub/src/app/app.module.ts @@ -104,6 +104,7 @@ import { } from '@ng-icons/material-icons/outline' import { NgIconsModule, provideNgIconsConfig } from '@ng-icons/core' import { ORGANIZATIONS_STRATEGY } from '@geonetwork-ui/api/repository/gn4' +import { GeocatHeaderComponent } from './home/geocat-header/geocat-header.component' export const metaReducers: MetaReducer[] = !environment.production ? [] : [] @@ -176,6 +177,7 @@ export const metaReducers: MetaReducer[] = !environment.production ? [] : [] OrganisationsComponent, LanguageSwitcherComponent, LocationSearchComponent, + GeocatHeaderComponent, ], providers: [ provideNgIconsConfig({ diff --git a/apps/datahub/src/app/home/geocat-header/geocat-header.component.html b/apps/datahub/src/app/home/geocat-header/geocat-header.component.html new file mode 100644 index 000000000..7fc8462ce --- /dev/null +++ b/apps/datahub/src/app/home/geocat-header/geocat-header.component.html @@ -0,0 +1,17 @@ +
+ {{ + 'datahub.header.geonetwork' | translate + }} + {{ + 'datahub.header.documentation' | translate + }} + {{ + 'datahub.header.admin' | translate + }} + +
diff --git a/apps/datahub/src/app/home/geocat-header/geocat-header.component.spec.ts b/apps/datahub/src/app/home/geocat-header/geocat-header.component.spec.ts new file mode 100644 index 000000000..aa591d933 --- /dev/null +++ b/apps/datahub/src/app/home/geocat-header/geocat-header.component.spec.ts @@ -0,0 +1,28 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing' +import { GeocatHeaderComponent } from './geocat-header.component' +import { TranslateModule } from '@ngx-translate/core' + +jest.mock('@geonetwork-ui/util/app-config', () => ({ + getGlobalConfig: jest.fn(() => ({ + LANGUAGES: ['de', 'fr'], + })), +})) + +describe('GeocatHeaderComponent', () => { + let component: GeocatHeaderComponent + let fixture: ComponentFixture + + beforeEach(() => { + TestBed.configureTestingModule({ + declarations: [GeocatHeaderComponent], + imports: [TranslateModule.forRoot()], + }) + fixture = TestBed.createComponent(GeocatHeaderComponent) + component = fixture.componentInstance + fixture.detectChanges() + }) + + it('should create', () => { + expect(component).toBeTruthy() + }) +}) diff --git a/apps/datahub/src/app/home/geocat-header/geocat-header.component.ts b/apps/datahub/src/app/home/geocat-header/geocat-header.component.ts new file mode 100644 index 000000000..18a500d72 --- /dev/null +++ b/apps/datahub/src/app/home/geocat-header/geocat-header.component.ts @@ -0,0 +1,34 @@ +import { Component } from '@angular/core' +import { TranslateModule, TranslateService } from '@ngx-translate/core' +import { LANG_2_TO_3_MAPPER } from '@geonetwork-ui/util/i18n' +import { getGlobalConfig } from '@geonetwork-ui/util/app-config' +import { LanguageSwitcherComponent } from '@geonetwork-ui/ui/catalog' +import { CommonModule } from '@angular/common' + +@Component({ + selector: 'datahub-geocat-header', + templateUrl: './geocat-header.component.html', + imports: [CommonModule, TranslateModule, LanguageSwitcherComponent], + standalone: true, +}) +export class GeocatHeaderComponent { + showLanguageSwitcher = getGlobalConfig().LANGUAGES?.length > 0 + + constructor(private translate: TranslateService) {} + + get docLink() { + return `https://www.info.geocat.ch` + } + + get gnLinkAdmin() { + return `/geonetwork/srv/${ + LANG_2_TO_3_MAPPER[this.translate.currentLang] || 'eng' + }/catalog.edit#/board` + } + + get gnLinkGeneral() { + return `/geonetwork/srv/${ + LANG_2_TO_3_MAPPER[this.translate.currentLang] || 'eng' + }/catalog.search#/home` + } +} diff --git a/apps/datahub/src/app/home/home-header/home-header.component.html b/apps/datahub/src/app/home/home-header/home-header.component.html index 8231d5c26..f5c0b0be5 100644 --- a/apps/datahub/src/app/home/home-header/home-header.component.html +++ b/apps/datahub/src/app/home/home-header/home-header.component.html @@ -91,13 +91,13 @@ class="tabs flex justify-between font-medium -mx-5 sm:mx-0 sm:mt-32 inset-x-0 bottom-0 z-50" > - + > --> diff --git a/apps/datahub/src/app/home/home-header/home-header.component.spec.ts b/apps/datahub/src/app/home/home-header/home-header.component.spec.ts index 2ff6c089d..d550293a2 100644 --- a/apps/datahub/src/app/home/home-header/home-header.component.spec.ts +++ b/apps/datahub/src/app/home/home-header/home-header.component.spec.ts @@ -260,7 +260,8 @@ describe('HeaderComponent', () => { }) }) - describe('language switcher', () => { + // skipped for geocat + describe.skip('language switcher', () => { describe('given predefined languages', () => { it('should display language switcher', () => { const languageSwitcher = fixture.debugElement.queryAll( 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 index 1497e7e2a..e66d6d089 100644 --- a/apps/datahub/src/app/organization/organization-header/organization-header.component.html +++ b/apps/datahub/src/app/organization/organization-header/organization-header.component.html @@ -12,14 +12,14 @@ > -
+