From cf579ebfbae7a6fbaab2dcd78ccc3f4926a16eea 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 | 16 +++++++++++ .../geocat-header.component.spec.ts | 28 +++++++++++++++++++ .../geocat-header/geocat-header.component.ts | 26 +++++++++++++++++ .../home-header/home-header.component.html | 4 --- .../home-header/home-header.component.spec.ts | 3 +- .../language-switcher.component.html | 1 + 8 files changed, 76 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 d8b1524f6..331d93669 100644 --- a/apps/datahub/src/app/app.module.ts +++ b/apps/datahub/src/app/app.module.ts @@ -81,6 +81,7 @@ import { RecordDownloadsComponent } from './record/record-downloads/record-downl import { RecordApisComponent } from './record/record-apis/record-apis.component' import { MatTabsModule } from '@angular/material/tabs' import { ORGANIZATIONS_STRATEGY } from '@geonetwork-ui/api/repository/gn4' +import { GeocatHeaderComponent } from './home/geocat-header/geocat-header.component' export const metaReducers: MetaReducer[] = !environment.production ? [] : [] // https://github.com/nrwl/nx/issues/191 @@ -105,6 +106,7 @@ export const metaReducers: MetaReducer[] = !environment.production ? [] : [] RecordOtherlinksComponent, RecordDownloadsComponent, RecordApisComponent, + GeocatHeaderComponent, ], imports: [ BrowserModule, 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..7fd1bb832 --- /dev/null +++ b/apps/datahub/src/app/home/geocat-header/geocat-header.component.html @@ -0,0 +1,16 @@ +
+ +
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..f12bb19f6 --- /dev/null +++ b/apps/datahub/src/app/home/geocat-header/geocat-header.component.ts @@ -0,0 +1,26 @@ +import { Component } from '@angular/core' +import { TranslateService } from '@ngx-translate/core' +import { LANG_2_TO_3_MAPPER } from '@geonetwork-ui/util/i18n' +import { getGlobalConfig } from '@geonetwork-ui/util/app-config' + +@Component({ + selector: 'datahub-geocat-header', + templateUrl: './geocat-header.component.html', +}) +export class GeocatHeaderComponent { + showLanguageSwitcher = getGlobalConfig().LANGUAGES?.length > 0 + + constructor(private translate: TranslateService) {} + + get docLink() { + return `https://www.geocat.admin.ch/${ + this.translate.currentLang || 'en' + }/home.html` + } + + get gnLink() { + return `/geonetwork/srv/${ + LANG_2_TO_3_MAPPER[this.translate.currentLang] || 'eng' + }/catalog.edit#/board` + } +} 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 ba867ebcf..0897e811d 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 @@ -84,8 +84,4 @@ > - 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 1d764bdd7..7c92669ae 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/libs/ui/catalog/src/lib/language-switcher/language-switcher.component.html b/libs/ui/catalog/src/lib/language-switcher/language-switcher.component.html index ea68c4e4d..7cfe1ea08 100644 --- a/libs/ui/catalog/src/lib/language-switcher/language-switcher.component.html +++ b/libs/ui/catalog/src/lib/language-switcher/language-switcher.component.html @@ -6,5 +6,6 @@ ariaName="languages" [showTitle]="false" extraBtnClass="bg-transparent flex justify-items-center !pl-2 !py-1" + class="text-sm" >