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 authored and fgravin committed Dec 11, 2023
1 parent 92f0750 commit 10d45f4
Show file tree
Hide file tree
Showing 7 changed files with 68 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 @@ -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
Expand All @@ -105,6 +106,7 @@ export const metaReducers: MetaReducer[] = !environment.production ? [] : []
RecordOtherlinksComponent,
RecordDownloadsComponent,
RecordApisComponent,
GeocatHeaderComponent,
],
imports: [
BrowserModule,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<div class="px-5">
<div
class="mx-auto flex items-center justify-center sm:justify-end gap-2 py-1 text-sm"
>
<a class="block hover:underline mr-4" [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 @@ -84,8 +84,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>
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,7 @@
[selected]="currentLang"
ariaName="languages"
[showTitle]="false"
[extraBtnClass]="'border-0'"
class="text-sm"
>
</gn-ui-dropdown-selector>

0 comments on commit 10d45f4

Please sign in to comment.