From 545f5b28d9dbedf5b89ad070e235d2fb81cf185b Mon Sep 17 00:00:00 2001 From: Florian Necas Date: Mon, 2 Oct 2023 16:34:09 +0200 Subject: [PATCH] feat: 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 | 14 ++++++++++ .../geocat-header.component.spec.ts | 21 +++++++++++++++ .../geocat-header/geocat-header.component.ts | 26 +++++++++++++++++++ .../home-header/home-header.component.html | 4 --- 6 files changed, 64 insertions(+), 4 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 70f8c76d3..a6abb75a8 100644 --- a/apps/datahub/src/app/app.module.ts +++ b/apps/datahub/src/app/app.module.ts @@ -71,6 +71,7 @@ import { BrowserAnimationsModule } from '@angular/platform-browser/animations' import { GN_UI_VERSION } from '@geonetwork-ui/feature/record' import { LOGIN_URL } from '@geonetwork-ui/api/repository/gn4' 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 @@ -90,6 +91,7 @@ export const metaReducers: MetaReducer[] = !environment.production ? [] : [] LastCreatedComponent, KeyFiguresComponent, NavigationMenuComponent, + 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..eff5cbbe9 --- /dev/null +++ b/apps/datahub/src/app/home/geocat-header/geocat-header.component.html @@ -0,0 +1,14 @@ +
+ +
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..1468b4eaa --- /dev/null +++ b/apps/datahub/src/app/home/geocat-header/geocat-header.component.spec.ts @@ -0,0 +1,21 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { GeocatHeaderComponent } from './geocat-header.component'; + +describe('GeocatHeaderComponent', () => { + let component: GeocatHeaderComponent; + let fixture: ComponentFixture; + + beforeEach(() => { + TestBed.configureTestingModule({ + declarations: [GeocatHeaderComponent] + }); + 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..e6ee16551 --- /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 `https://www.geocat.ch/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 6daed33a7..2a74eee67 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 @@ -82,8 +82,4 @@ > -