From a96c3e2a6bb9c7d8c1286cd7efa7b6d278bf2c0e Mon Sep 17 00:00:00 2001 From: Florent Gravin Date: Mon, 18 Sep 2023 10:01:17 +0200 Subject: [PATCH 1/4] geocat: customize runs proxy, nx, docker, github actions --- .github/workflows/artifacts.yml | 17 ++++++++++------- .github/workflows/checks.yml | 16 +++++++++------- .github/workflows/deploy.yml | 4 ++-- .github/workflows/snyk-security.yml | 2 +- .github/workflows/webcomponents.yml | 8 +++----- nx.json | 2 +- proxy-config.js | 2 +- tools/print-docker-tag.sh | 4 ++-- 8 files changed, 29 insertions(+), 26 deletions(-) diff --git a/.github/workflows/artifacts.yml b/.github/workflows/artifacts.yml index d3dd650b6..a1be616f0 100644 --- a/.github/workflows/artifacts.yml +++ b/.github/workflows/artifacts.yml @@ -6,7 +6,7 @@ run-name: 📦 Generate artifacts for ${{ github.event_name == 'issue_comment' & on: push: branches: - - main + - geocat release: types: [published] issue_comment: @@ -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 @@ -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 diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index f9bc91c37..efb547427 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -10,7 +10,7 @@ env: on: push: branches: - - main + - geocat pull_request: types: [opened, synchronize, ready_for_review] @@ -18,7 +18,7 @@ on: # 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: @@ -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' @@ -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 diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 7320553d0..a0d90ee01 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -9,7 +9,7 @@ env: on: push: branches: - - main + - geocat issue_comment: types: - edited @@ -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 diff --git a/.github/workflows/snyk-security.yml b/.github/workflows/snyk-security.yml index e114be3fe..9948981c1 100644 --- a/.github/workflows/snyk-security.yml +++ b/.github/workflows/snyk-security.yml @@ -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] diff --git a/.github/workflows/webcomponents.yml b/.github/workflows/webcomponents.yml index e090eb78b..87050b2da 100644 --- a/.github/workflows/webcomponents.yml +++ b/.github/workflows/webcomponents.yml @@ -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] @@ -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 }} diff --git a/nx.json b/nx.json index 561c05319..e8e66f2e9 100644 --- a/nx.json +++ b/nx.json @@ -1,6 +1,6 @@ { "affected": { - "defaultBase": "remotes/origin/main" + "defaultBase": "remotes/geocat/geocat" }, "npmScope": "geonetwork-ui", "tasksRunnerOptions": { diff --git a/proxy-config.js b/proxy-config.js index e492ffdbc..54bae27fa 100644 --- a/proxy-config.js +++ b/proxy-config.js @@ -1,6 +1,6 @@ module.exports = { '/geonetwork': { - target: 'http://localhost:8080', + target: 'https://www.geocat.ch', secure: true, logLevel: 'debug', changeOrigin: true, diff --git a/tools/print-docker-tag.sh b/tools/print-docker-tag.sh index d86b7bb3c..b40c693a3 100755 --- a/tools/print-docker-tag.sh +++ b/tools/print-docker-tag.sh @@ -9,8 +9,8 @@ gitTag=$(git describe --exact-match --tags 2>/dev/null | sed "s/^v//") # remove gitBranch=$(git symbolic-ref --short HEAD) gitRef=$(git rev-parse --short HEAD) dockerTag=${gitTag:-${gitBranch}} -if [ ${dockerTag} == "main" ]; then +if [ ${dockerTag} == "geocat" ]; then dockerTag=${dockerTag}-${gitRef} fi -echo "geonetwork/geonetwork-ui-${appName}:${dockerTag}" +echo "camptocamp/geocat-geonetwork-ui-${appName}:${dockerTag}" From 73742444cca5053acab270574e6884f8dfbab4a8 Mon Sep 17 00:00:00 2001 From: Olivia Guyot Date: Mon, 18 Sep 2023 13:24:34 +0200 Subject: [PATCH 2/4] geocat: add location filter in search & location input in home page --- apps/datahub/src/app/app.module.ts | 5 + .../home-header/home-header.component.html | 15 +- .../home/home-header/home-header.component.ts | 22 ++- .../elasticsearch.service.spec.ts | 30 ++-- .../elasticsearch/elasticsearch.service.ts | 35 +++-- .../router/src/lib/default/constants.ts | 2 + .../services/router-search.service.spec.ts | 57 +++++++- .../default/services/router-search.service.ts | 21 ++- .../lib/default/state/router.effects.spec.ts | 51 ++++--- .../src/lib/default/state/router.effects.ts | 37 ++++- libs/feature/search/src/index.ts | 4 + .../search/src/lib/feature-search.module.ts | 3 + .../fuzzy-search.component.spec.ts | 3 +- .../fuzzy-search/fuzzy-search.component.ts | 20 ++- .../location-search-result.model.ts | 27 ++++ .../location-search.component.css | 0 .../location-search.component.html | 10 ++ .../location-search.component.spec.ts | 128 ++++++++++++++++++ .../location-search.component.ts | 89 ++++++++++++ .../location-search.service.spec.ts | 118 ++++++++++++++++ .../location-search.service.ts | 44 ++++++ libs/feature/search/src/lib/state/actions.ts | 23 ++++ .../search/src/lib/state/effects.spec.ts | 61 ++++++++- libs/feature/search/src/lib/state/effects.ts | 34 ++++- .../search/src/lib/state/reducer.spec.ts | 27 ++++ libs/feature/search/src/lib/state/reducer.ts | 25 ++++ .../search/src/lib/state/search.facade.ts | 26 ++++ .../feature/search/src/lib/state/selectors.ts | 9 ++ .../lib/utils/service/search.service.spec.ts | 32 +++++ .../src/lib/utils/service/search.service.ts | 11 ++ .../autocomplete/autocomplete.component.html | 2 +- .../autocomplete.component.stories.ts | 19 ++- .../autocomplete/autocomplete.component.ts | 4 +- 33 files changed, 924 insertions(+), 70 deletions(-) create mode 100644 libs/feature/search/src/lib/location-search/location-search-result.model.ts create mode 100644 libs/feature/search/src/lib/location-search/location-search.component.css create mode 100644 libs/feature/search/src/lib/location-search/location-search.component.html create mode 100644 libs/feature/search/src/lib/location-search/location-search.component.spec.ts create mode 100644 libs/feature/search/src/lib/location-search/location-search.component.ts create mode 100644 libs/feature/search/src/lib/location-search/location-search.service.spec.ts create mode 100644 libs/feature/search/src/lib/location-search/location-search.service.ts diff --git a/apps/datahub/src/app/app.module.ts b/apps/datahub/src/app/app.module.ts index 935be29ad..70f8c76d3 100644 --- a/apps/datahub/src/app/app.module.ts +++ b/apps/datahub/src/app/app.module.ts @@ -70,6 +70,7 @@ 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' export const metaReducers: MetaReducer[] = !environment.production ? [] : [] // https://github.com/nrwl/nx/issues/191 @@ -190,6 +191,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], }) diff --git a/apps/datahub/src/app/home/home-header/home-header.component.html b/apps/datahub/src/app/home/home-header/home-header.component.html index a3c0dc80c..6daed33a7 100644 --- a/apps/datahub/src/app/home/home-header/home-header.component.html +++ b/apps/datahub/src/app/home/home-header/home-header.component.html @@ -13,10 +13,17 @@ [style.opacity]="expandRatio" [innerHTML]="'datahub.header.title.html' | translate" > - +
+ + +
diff --git a/apps/datahub/src/app/app.module.ts b/apps/datahub/src/app/app.module.ts index 70f8c76d3..a6abb75a8 100644 --- a/apps/datahub/src/app/app.module.ts +++ b/apps/datahub/src/app/app.module.ts @@ -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 @@ -90,6 +91,7 @@ export const metaReducers: MetaReducer[] = !environment.production ? [] : [] LastCreatedComponent, KeyFiguresComponent, NavigationMenuComponent, + GeocatHeaderComponent, ], imports: [ BrowserModule, diff --git a/apps/datahub/src/app/home/geocat-header/geocat-header.component.html b/apps/datahub/src/app/home/geocat-header/geocat-header.component.html new file mode 100644 index 000000000..eff5cbbe9 --- /dev/null +++ b/apps/datahub/src/app/home/geocat-header/geocat-header.component.html @@ -0,0 +1,14 @@ + diff --git a/apps/datahub/src/app/home/geocat-header/geocat-header.component.spec.ts b/apps/datahub/src/app/home/geocat-header/geocat-header.component.spec.ts new file mode 100644 index 000000000..1468b4eaa --- /dev/null +++ b/apps/datahub/src/app/home/geocat-header/geocat-header.component.spec.ts @@ -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; + + beforeEach(() => { + TestBed.configureTestingModule({ + declarations: [GeocatHeaderComponent] + }); + fixture = TestBed.createComponent(GeocatHeaderComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/apps/datahub/src/app/home/geocat-header/geocat-header.component.ts b/apps/datahub/src/app/home/geocat-header/geocat-header.component.ts new file mode 100644 index 000000000..e6ee16551 --- /dev/null +++ b/apps/datahub/src/app/home/geocat-header/geocat-header.component.ts @@ -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` + } +} diff --git a/apps/datahub/src/app/home/home-header/home-header.component.html b/apps/datahub/src/app/home/home-header/home-header.component.html index 6daed33a7..2a74eee67 100644 --- a/apps/datahub/src/app/home/home-header/home-header.component.html +++ b/apps/datahub/src/app/home/home-header/home-header.component.html @@ -82,8 +82,4 @@ > -