Skip to content

Commit

Permalink
feat: add geocat-header with langage switcher
Browse files Browse the repository at this point in the history
  • Loading branch information
f-necas committed Oct 3, 2023
1 parent 84152fa commit 545f5b2
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 4 deletions.
1 change: 1 addition & 0 deletions apps/datahub/src/app/app.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
gnUiSearchRouterContainer="mainSearch"
class="selection:bg-primary-lightest selection:text-primary-darker"
>
<datahub-geocat-header></datahub-geocat-header>
<router-outlet></router-outlet>
</div>
2 changes: 2 additions & 0 deletions apps/datahub/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -90,6 +91,7 @@ export const metaReducers: MetaReducer[] = !environment.production ? [] : []
LastCreatedComponent,
KeyFiguresComponent,
NavigationMenuComponent,
GeocatHeaderComponent,
],
imports: [
BrowserModule,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<div class="px-5">
<div class="mx-auto flex items-center justify-end gap-3 py-1 text-sm">
<a class="block hover:underline" [href]="docLink" target="_blank">{{
'datahub.header.documentation' | translate
}}</a>
<a class="block hover:underline" [href]="gnLink" target="_blank">{{
'datahub.header.admin' | translate
}}</a>
<gn-ui-language-switcher
*ngIf="showLanguageSwitcher"
class="language-switcher"
></gn-ui-language-switcher>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -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<GeocatHeaderComponent>;

beforeEach(() => {
TestBed.configureTestingModule({
declarations: [GeocatHeaderComponent]
});
fixture = TestBed.createComponent(GeocatHeaderComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
26 changes: 26 additions & 0 deletions apps/datahub/src/app/home/geocat-header/geocat-header.component.ts
Original file line number Diff line number Diff line change
@@ -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`
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,4 @@
></datahub-navigation-menu>
</div>
</div>
<gn-ui-language-switcher
*ngIf="showLanguageSwitcher"
class="language-switcher absolute top-2.5 left-2.5 text-[13px]"
></gn-ui-language-switcher>
</header>

0 comments on commit 545f5b2

Please sign in to comment.