Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: WIP add geocat-header with langage switcher #11

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions .github/workflows/artifacts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ run-name: 📦 Generate artifacts for ${{ github.event_name == 'issue_comment' &
on:
push:
branches:
- main
- geocat
release:
types: [published]
issue_comment:
Expand Down Expand Up @@ -59,7 +59,7 @@ jobs:
- name: Derive appropriate SHAs for base and head for `nx affected` commands
uses: nrwl/nx-set-shas@v2
with:
main-branch-name: 'main'
main-branch-name: 'geocat'

- name: Install dependencies
run: npm ci
Expand Down Expand Up @@ -91,16 +91,19 @@ jobs:

- name: Tag all docker images on main also as latest
if: github.event_name == 'push' # only happens when pushing on the main branch
run: docker image ls --format 'docker tag {{.Repository}}:{{.Tag}} {{.Repository}}:latest' --filter=reference='geonetwork/*' | bash -
run: docker image ls --format 'docker tag {{.Repository}}:{{.Tag}} {{.Repository}}:latest' --filter=reference='camptocamp/*' | bash -

- name: Login to DockerHub
- name: Login to Github Packages
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_PASSWORD }}
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Push all docker images
# list all docker images, keep only the ones in the geonetwork org, and call docker push for each of them
run: |
docker image ls --format '{{.Repository}}:{{.Tag}}' --filter=reference='geonetwork/*' | \
docker image ls --format '{{.Repository}}:{{.Tag}}' --filter=reference='camptocamp/*' | \
xargs -I '{}' docker tag '{}' ghcr.io/'{}'
docker image ls --format '{{.Repository}}:{{.Tag}}' |grep ghcr.io | \
xargs -r -L1 docker push $1
16 changes: 9 additions & 7 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ env:
on:
push:
branches:
- main
- geocat
pull_request:
types: [opened, synchronize, ready_for_review]

# Only allow concurrent checks on the main branch to keep history
# on QA checks
concurrency:
group: checks-${{ github.ref }}
cancel-in-progress: ${{ github.ref_name != 'main' }}
cancel-in-progress: ${{ github.ref_name != 'geocat' }}

jobs:
format-lint-test:
Expand All @@ -40,16 +40,16 @@ jobs:
- name: Derive appropriate SHAs for base and head for `nx affected` commands
uses: nrwl/nx-set-shas@v2
with:
main-branch-name: 'main'
main-branch-name: 'geocat'
- run: npm ci
- run: npx nx format:check
- run: npx nx affected -t lint --parallel=3
- run: npx nx affected -t test --parallel=3 --configuration=ci --ci --codeCoverage --coverageReporters=lcov

- name: Coveralls
uses: coverallsapp/github-action@v2
with:
allow-empty: true
# - name: Coveralls
# uses: coverallsapp/github-action@v2
# with:
# allow-empty: true

# - name: Archive Code Coverage Results (on main)
# if: github.event_name != 'pull_request'
Expand Down Expand Up @@ -115,6 +115,8 @@ jobs:

- name: Derive appropriate SHAs for base and head for `nx affected` commands
uses: nrwl/nx-set-shas@v3
with:
main-branch-name: 'geocat'

- name: Install dependencies
run: npm ci
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ env:
on:
push:
branches:
- main
- geocat
issue_comment:
types:
- edited
Expand Down Expand Up @@ -38,7 +38,7 @@ jobs:
name: Deploy Storybook to GitHub Pages
runs-on: ubuntu-latest
env:
BRANCH_NAME: ${{needs.checks.outputs.ref || 'main'}}
BRANCH_NAME: ${{needs.checks.outputs.ref || 'geocat'}}

steps:
- name: Dump GitHub event
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/snyk-security.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ run-name: 🐺 Run Snyk on ${{ github.event_name == 'pull_request' && 'PR' || '

on:
push:
branches: ['main']
branches: ['geocat']
pull_request:
types: [opened, synchronize, ready_for_review]

Expand Down
8 changes: 3 additions & 5 deletions .github/workflows/webcomponents.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ run-name: 🧩 Build Web Components for ${{ github.event_name == 'issue_comment'
on:
push:
branches:
- main
tags:
- 'v*.*.*'
- geocat
release:
types: [published]

Expand Down Expand Up @@ -56,10 +54,10 @@ jobs:
tag: ${{ github.ref }}
overwrite: true

- name: Publish web component to ${{ env.PUBLISH_BRANCH }}-${{ github.ref_name }} branch
- name: Publish web component to ${{ env.PUBLISH_BRANCH }} branch
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
force_orphan: true
publish_dir: ./wc-dist
publish_branch: ${{ env.PUBLISH_BRANCH }}-${{ github.ref_name }}
publish_branch: ${{ env.PUBLISH_BRANCH }}
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>
7 changes: 7 additions & 0 deletions apps/datahub/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ import { METADATA_LANGUAGE } from '@geonetwork-ui/api/repository'
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 @@ -89,6 +91,7 @@ export const metaReducers: MetaReducer[] = !environment.production ? [] : []
LastCreatedComponent,
KeyFiguresComponent,
NavigationMenuComponent,
GeocatHeaderComponent,
],
imports: [
BrowserModule,
Expand Down Expand Up @@ -190,6 +193,10 @@ export const metaReducers: MetaReducer[] = !environment.production ? [] : []
provide: ORGANIZATION_URL_TOKEN,
useValue: `${ROUTER_ROUTE_SEARCH}?${ROUTE_PARAMS.PUBLISHER}=\${name}`,
},
{
provide: ORGANIZATIONS_STRATEGY,
useValue: 'groups',
},
],
bootstrap: [AppComponent],
})
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`
}
}
19 changes: 11 additions & 8 deletions apps/datahub/src/app/home/home-header/home-header.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,17 @@
[style.opacity]="expandRatio"
[innerHTML]="'datahub.header.title.html' | translate"
></div>
<gn-ui-fuzzy-search
class="text-[18px]"
(itemSelected)="onFuzzySearchSelection($event)"
></gn-ui-fuzzy-search>
<div class="flex flex-wrap gap-4">
<gn-ui-fuzzy-search
class="text-[18px] grow"
(itemSelected)="onFuzzySearchSelection($event)"
(inputSubmitted)="updateLocationFilter()"
></gn-ui-fuzzy-search>
<gn-ui-location-search
class="text-[18px] grow"
(inputSubmitted)="updateTextFilter()"
></gn-ui-location-search>
</div>
<div class="flex h-0 py-5 gap-3" [style.opacity]="-0.6 + expandRatio * 2">
<datahub-header-badge-button
[routerLink]="ROUTE_SEARCH"
Expand Down Expand Up @@ -75,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>
22 changes: 21 additions & 1 deletion apps/datahub/src/app/home/home-header/home-header.component.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
import { ChangeDetectionStrategy, Component, Input } from '@angular/core'
import {
ChangeDetectionStrategy,
Component,
Input,
ViewChild,
} from '@angular/core'
import { marker } from '@biesbjerg/ngx-translate-extract-marker'
import {
RouterFacade,
ROUTER_ROUTE_SEARCH,
} from '@geonetwork-ui/feature/router'
import {
FieldsService,
FuzzySearchComponent,
LocationSearchComponent,
SearchFacade,
SearchService,
} from '@geonetwork-ui/feature/search'
Expand Down Expand Up @@ -37,6 +44,11 @@ marker('datahub.header.popularRecords')
export class HomeHeaderComponent {
@Input() expandRatio: number

// specific geocat: used to trigger the other field when one is triggered
@ViewChild(FuzzySearchComponent)
textSearch: FuzzySearchComponent
@ViewChild(LocationSearchComponent) locationSearch: LocationSearchComponent

backgroundCss =
getThemeConfig().HEADER_BACKGROUND ||
`center /cover url('assets/img/header_bg.webp')`
Expand Down Expand Up @@ -91,4 +103,12 @@ export class HomeHeaderComponent {
this.searchService.setFilters(searchFilters)
}
}

// specific geocat
updateLocationFilter() {
this.locationSearch.trigger()
}
updateTextFilter() {
this.textSearch.trigger()
}
}
1 change: 1 addition & 0 deletions apps/datahub/tailwind.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const { join } = require('path')

module.exports = {
...baseConfig,
safelist: [...baseConfig.safelist, 'w-max', 'items-end'],
theme: {
...baseConfig.theme,
extend: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,26 @@ describe('ElasticsearchService', () => {
)
expect(query).toEqual({
bool: {
filter: [],
filter: [
{
geo_shape: {
geom: {
relation: 'intersects',
shape: {
coordinates: [
[
[3.017921158755172, 50.65759907920972],
[3.017921158755172, 50.613483610573155],
[3.1098886148436122, 50.613483610573155],
[3.017921158755172, 50.65759907920972],
],
],
type: 'Polygon',
},
},
},
},
],
must: [
{
terms: {
Expand Down Expand Up @@ -340,15 +359,6 @@ describe('ElasticsearchService', () => {
boost: 10.0,
},
},
{
geo_shape: {
geom: {
shape: geojsonPolygon,
relation: 'intersects',
},
boost: 7.0,
},
},
],
},
})
Expand Down
Loading