Skip to content

Commit d7fb220

Browse files
f-necasjahow
authored andcommitted
geocat: add geocat-header with langage switcher
1 parent 7547c79 commit d7fb220

8 files changed

+88
-5
lines changed

apps/datahub/src/app/app.component.html

+1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@
22
gnUiSearchRouterContainer="mainSearch"
33
class="selection:bg-primary-lightest selection:text-primary-darker"
44
>
5+
<datahub-geocat-header></datahub-geocat-header>
56
<router-outlet></router-outlet>
67
</div>

apps/datahub/src/app/app.module.ts

+2
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ import {
104104
} from '@ng-icons/material-icons/outline'
105105
import { NgIconsModule, provideNgIconsConfig } from '@ng-icons/core'
106106
import { ORGANIZATIONS_STRATEGY } from '@geonetwork-ui/api/repository/gn4'
107+
import { GeocatHeaderComponent } from './home/geocat-header/geocat-header.component'
107108

108109
export const metaReducers: MetaReducer[] = !environment.production ? [] : []
109110

@@ -176,6 +177,7 @@ export const metaReducers: MetaReducer[] = !environment.production ? [] : []
176177
OrganisationsComponent,
177178
LanguageSwitcherComponent,
178179
LocationSearchComponent,
180+
GeocatHeaderComponent,
179181
],
180182
providers: [
181183
provideNgIconsConfig({
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<div
2+
class="px-5 mx-auto flex items-center justify-center sm:justify-end gap-6 py-1 text-sm"
3+
>
4+
<a class="block hover:underline" [href]="gnLinkGeneral" target="_blank">{{
5+
'datahub.header.geonetwork' | translate
6+
}}</a>
7+
<a class="block hover:underline" [href]="docLink" target="_blank">{{
8+
'datahub.header.documentation' | translate
9+
}}</a>
10+
<a class="block hover:underline" [href]="gnLinkAdmin" target="_blank">{{
11+
'datahub.header.admin' | translate
12+
}}</a>
13+
<gn-ui-language-switcher
14+
*ngIf="showLanguageSwitcher"
15+
class="language-switcher"
16+
></gn-ui-language-switcher>
17+
</div>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { ComponentFixture, TestBed } from '@angular/core/testing'
2+
import { GeocatHeaderComponent } from './geocat-header.component'
3+
import { TranslateModule } from '@ngx-translate/core'
4+
5+
jest.mock('@geonetwork-ui/util/app-config', () => ({
6+
getGlobalConfig: jest.fn(() => ({
7+
LANGUAGES: ['de', 'fr'],
8+
})),
9+
}))
10+
11+
describe('GeocatHeaderComponent', () => {
12+
let component: GeocatHeaderComponent
13+
let fixture: ComponentFixture<GeocatHeaderComponent>
14+
15+
beforeEach(() => {
16+
TestBed.configureTestingModule({
17+
declarations: [GeocatHeaderComponent],
18+
imports: [TranslateModule.forRoot()],
19+
})
20+
fixture = TestBed.createComponent(GeocatHeaderComponent)
21+
component = fixture.componentInstance
22+
fixture.detectChanges()
23+
})
24+
25+
it('should create', () => {
26+
expect(component).toBeTruthy()
27+
})
28+
})
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import { Component } from '@angular/core'
2+
import { TranslateModule, TranslateService } from '@ngx-translate/core'
3+
import { LANG_2_TO_3_MAPPER } from '@geonetwork-ui/util/i18n'
4+
import { getGlobalConfig } from '@geonetwork-ui/util/app-config'
5+
import { LanguageSwitcherComponent } from '@geonetwork-ui/ui/catalog'
6+
import { CommonModule } from '@angular/common'
7+
8+
@Component({
9+
selector: 'datahub-geocat-header',
10+
templateUrl: './geocat-header.component.html',
11+
imports: [CommonModule, TranslateModule, LanguageSwitcherComponent],
12+
standalone: true,
13+
})
14+
export class GeocatHeaderComponent {
15+
showLanguageSwitcher = getGlobalConfig().LANGUAGES?.length > 0
16+
17+
constructor(private translate: TranslateService) {}
18+
19+
get docLink() {
20+
return `https://www.info.geocat.ch`
21+
}
22+
23+
get gnLinkAdmin() {
24+
return `/geonetwork/srv/${
25+
LANG_2_TO_3_MAPPER[this.translate.currentLang] || 'eng'
26+
}/catalog.edit#/board`
27+
}
28+
29+
get gnLinkGeneral() {
30+
return `/geonetwork/srv/${
31+
LANG_2_TO_3_MAPPER[this.translate.currentLang] || 'eng'
32+
}/catalog.search#/home`
33+
}
34+
}

apps/datahub/src/app/home/home-header/home-header.component.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -91,13 +91,13 @@
9191
class="tabs flex justify-between font-medium -mx-5 sm:mx-0 sm:mt-32 inset-x-0 bottom-0 z-50"
9292
></datahub-navigation-menu>
9393
</div>
94-
<gn-ui-language-switcher
94+
<!-- <gn-ui-language-switcher
9595
*ngIf="showLanguageSwitcher"
9696
class="language-switcher absolute top-3.5 right-6 text-[13px]"
9797
[style.--color-main]="foregroundColor"
9898
[style.--color-gray-300]="foregroundColor"
9999
[style.--color-primary-darker]="foregroundColor"
100100
[style.--color-primary-black]="foregroundColor"
101-
></gn-ui-language-switcher>
101+
></gn-ui-language-switcher> -->
102102
</div>
103103
</header>

apps/datahub/src/app/home/home-header/home-header.component.spec.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,8 @@ describe('HeaderComponent', () => {
260260
})
261261
})
262262

263-
describe('language switcher', () => {
263+
// skipped for geocat
264+
describe.skip('language switcher', () => {
264265
describe('given predefined languages', () => {
265266
it('should display language switcher', () => {
266267
const languageSwitcher = fixture.debugElement.queryAll(

apps/datahub/src/app/organization/organization-header/organization-header.component.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@
1212
>
1313
</gn-ui-navigation-button>
1414
</div>
15-
<div class="flex flex-row mr-6 content-center gap-3">
15+
<!-- <div class="flex flex-row mr-6 content-center gap-3">
1616
<gn-ui-language-switcher
1717
*ngIf="showLanguageSwitcher"
1818
class="language-switcher text-[13px] mt-0.5"
1919
[style.--color-main]="foregroundColor"
2020
[style.--color-gray-300]="foregroundColor"
2121
></gn-ui-language-switcher>
22-
</div>
22+
</div> -->
2323
</div>
2424
<ng-container *ngIf="organization">
2525
<div

0 commit comments

Comments
 (0)