Skip to content

Commit

Permalink
feat: WIP add geocat-header with langage switcher
Browse files Browse the repository at this point in the history
harcoded links
  • Loading branch information
f-necas committed Sep 26, 2023
1 parent 21a48ab commit 5008ffe
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 4 deletions.
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,22 @@
<div class="absolute top-0 left-0 right-0">
<div
class="container-lg mx-auto flex items-center justify-{{
horizontalPosition
}} gap-3 py-1 text-sm"
>
<gn-ui-language-switcher
*ngIf="showLanguageSwitcher && horizontalPosition !== 'end'"
class="language-switcher"
></gn-ui-language-switcher>
<a class="block hover:underline" [href]="docLink" target="_blank">{{
'datahub.header.documentation' | translate
}}</a>
<a class="block hover:underline" [href]="gnLink" target="_blank"
>Geonetwork</a
>
<gn-ui-language-switcher
*ngIf="showLanguageSwitcher && horizontalPosition === 'end'"
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();
});
});
27 changes: 27 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,27 @@
import { Component, Input } 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 {
@Input() horizontalPosition: 'start' | 'center' | 'end' = 'center'
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 @@ -2,6 +2,7 @@
<div
class="container-lg h-full mx-auto flex flex-col-reverse justify-between sm:flex-col sm:justify-end"
>
<datahub-geocat-header horizontalPosition="start"></datahub-geocat-header>
<div
class="py-8 relative z-40 mb-[184px] sm:mb-0"
[style.transform]="'translate(0, ' + (1 - expandRatio) * 242 + 'px)'"
Expand Down Expand Up @@ -82,8 +83,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 @@ -2,6 +2,7 @@
<div
class="h-full container-lg mx-auto flex flex-col justify-center relative"
>
<datahub-geocat-header></datahub-geocat-header>
<gn-ui-favorite-star
*ngIf="metadata?.uniqueIdentifier"
[record]="metadata"
Expand Down

0 comments on commit 5008ffe

Please sign in to comment.