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

Search Performance Release Candidate #217

Merged
merged 59 commits into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
b45ab01
added edit test
DmByK Jun 24, 2024
ac2dc84
Merge pull request #181 from swisstopo/feature/asset-147-crud-edit-test
DmByK Jul 1, 2024
7810a12
Show version in frontend
vej-ananas Jun 12, 2024
abb95aa
Use 0.0.0 for local version since prisma requires it
vej-ananas Jun 12, 2024
451d07f
Run lint
vej-ananas Jul 2, 2024
5ed2eb2
Run prettier
vej-ananas Jul 2, 2024
e905280
Rewrite map component
daniel-va Jun 28, 2024
2888be6
Merge pull request #166 from swisstopo/feature/asset-#120-versions-nu…
vej-ananas Jul 3, 2024
a669346
added test for asset creation
DmByK Jul 2, 2024
6078e37
Merge pull request #189 from swisstopo/feature/asset-186-cypress-crea…
DmByK Jul 4, 2024
3f965df
Use standalone version file instead of package.json
vej-ananas Jul 4, 2024
6ac5e14
Fix dockerfile
vej-ananas Jul 4, 2024
78ccd0b
Merge pull request #198 from swisstopo/feature/asset-#120-versions-nu…
vej-ananas Jul 4, 2024
7328f99
Merge pull request #190 from swisstopo/feature/asset-6-improve-map-co…
daniel-va Jul 4, 2024
e12658d
Allow selection of points via click
daniel-va Jul 3, 2024
c8a8458
Merge pull request #195 from swisstopo/feature/asset-27-selection-of-…
daniel-va Jul 4, 2024
f24507f
layout fixes for table
TIL-EBP Jul 3, 2024
70b8e71
finalize table layout
TIL-EBP Jul 4, 2024
84ad123
remove commented out code
TIL-EBP Jul 4, 2024
e3d18f7
Replace `GET /api/all-study` with more perfomant `GET /api/studies`
daniel-va Jul 5, 2024
5bfbc69
Move polygon search to Elasticsearch
daniel-va Jul 5, 2024
3d38905
Merge pull request #200 from swisstopo/feature/asset-192-bug-performa…
daniel-va Jul 8, 2024
97476ec
Activate cypress workflow step
daniel-va Jun 20, 2024
b310054
Add node to cypress workflow step
daniel-va Jun 20, 2024
b829e8c
Use correct prisma command
daniel-va Jun 20, 2024
0bd7069
Add sleep to allow db to spin up
daniel-va Jun 20, 2024
90c0522
Remove API start
daniel-va Jun 20, 2024
fe0edfe
Add cypress config file flag
daniel-va Jun 20, 2024
42e4cab
Disable cypress support file
daniel-va Jun 20, 2024
8a2571a
Add cypress working dir
daniel-va Jun 27, 2024
09672e7
Fix cypress app paths
daniel-va Jun 27, 2024
33e6d51
Move cypress app commands into `e2e/package.json`
daniel-va Jun 27, 2024
56413c8
Change node version in code-quality workflow
daniel-va Jun 27, 2024
2a60778
Run builds with `nx run-many`
daniel-va Jun 27, 2024
cb1733c
Add fully configured .env files
daniel-va Jul 1, 2024
44b5cc4
Ignore further changes to `.env.local`
daniel-va Jul 1, 2024
87c5c4a
Add s3 secret variables
daniel-va Jul 1, 2024
9948756
Add `.env.local` to `.gitignore`
daniel-va Jul 1, 2024
bc80beb
Adjust environment variables in workflow
daniel-va Jul 1, 2024
e526e7d
Handle warnings in client build
daniel-va Jul 8, 2024
7354081
Merge pull request #199 from swisstopo/feature/asset-191-fix-table-la…
TIL-EBP Jul 8, 2024
22e5282
Merge pull request #201 from swisstopo/feature/asset-197-maintenance-…
daniel-va Jul 8, 2024
1efdae5
Fix inversed parsing of LV95 coordinates
daniel-va Jul 9, 2024
c79d000
Merge pull request #203 from swisstopo/fix/studies-missing-from-map
TIL-EBP Jul 9, 2024
3bc6e17
Switch lat/lon coordinates in lv95-wgs84 mapping
daniel-va Jul 9, 2024
7a896de
Merge pull request #204 from swisstopo/fix/polygon-selection-not-working
vej-ananas Jul 9, 2024
5c18984
changed host
DmByK Jul 3, 2024
5bd4667
Fix language display
vej-ananas Jul 11, 2024
bd3f7dd
Only resolve login process on success
vej-ananas Jul 11, 2024
9533e45
implemented comments
DmByK Jul 12, 2024
337d509
Merge pull request #180 from swisstopo/feature/asset-164-cypress-test…
DmByK Jul 15, 2024
0813b34
Fix search flow
TIL-EBP Jul 9, 2024
6b65fef
Merge pull request #209 from swisstopo/feature/assets-202-search-flow
TIL-EBP Jul 15, 2024
374a085
Make filters dynamic between groups
vej-ananas Jul 10, 2024
477612a
Fix tests
vej-ananas Jul 11, 2024
6e0996f
Enable deselect of selected filter with 0 results
vej-ananas Jul 15, 2024
951e12d
Merge pull request #213 from swisstopo/bug/assets-212-sprache-in-deta…
vej-ananas Jul 15, 2024
b563901
Merge pull request #214 from swisstopo/bug/assets-208-background-visi…
vej-ananas Jul 15, 2024
55af2b9
Merge pull request #211 from swisstopo/feature/assets-205-make-filter…
vej-ananas Jul 15, 2024
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
125 changes: 19 additions & 106 deletions .github/workflows/code-quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ on:

env:
NODE_VERSION: "20.x"
DB_USERNAME: postgres-test
DB_PASSWORD: postgres-test
DB_DATABASE: postgres-test
DATABASE_URL: postgres://postgres-test:postgres-test@localhost:5432/postgres-test?schema=public
DB_USERNAME: postgres
DB_PASSWORD: postgres
DB_DATABASE: postgres
DATABASE_URL: postgres://postgres:postgres@localhost:5432/postgres?schema=public

jobs:
install:
Expand Down Expand Up @@ -55,85 +55,16 @@ jobs:
- name: Install e2e node dependencies
run: cd e2e && npm ci

test:
runs-on: ubuntu-latest
needs: install
services:
db:
image: postgis/postgis
ports:
- "5432:5432"
env:
POSTGRES_USER: ${{ env.DB_USERNAME }}
POSTGRES_PASSWORD: ${{ env.DB_PASSWORD }}
POSTGRES_DB: ${{ env.DB_DATABASE }}
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:8.12.1
ports:
- "9200:9200"
env:
ES_JAVA_OPTS: -Xms512m -Xmx512m
xpack.security.enabled: false
discovery.type: single-node
cluster.routing.allocation.disk.threshold_enabled: false
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: Restore cached node modules
uses: actions/cache/restore@v4
with:
path: ./node_modules
key: "${{ runner.os }}-node_modules-${{ hashFiles('package-lock.json') }}-${{ hashFiles('**/schema.prisma') }}"
- name: Migrate database
run: npm run prisma -- migrate deploy
- name: Run tests
run: npm run test

lint:
runs-on: ubuntu-latest
needs: install
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: Restore cached node modules
uses: actions/cache/restore@v4
with:
path: ./node_modules
key: "${{ runner.os }}-node_modules-${{ hashFiles('package-lock.json') }}-${{ hashFiles('**/schema.prisma') }}"
- name: Run lint
run: npm run lint
- name: Run prettier
run: npx prettier --check .

dependency-review:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Review Dependencies
uses: actions/dependency-review-action@v4

# It would be cleaner and probably more performant to replace this build step
# with either a non-emitting build or a simple type check.
# We only have `build` available for now,
# since the project is currently split across a multitude of small packages,
# all of which have to specify their own commands.
# (Daniel von Atzigen, 2024-04-12)
build:
cypress:
runs-on: ubuntu-latest
needs:
- test
- lint
- dependency-review
- install
strategy:
# https://github.com/cypress-io/github-action/issues/48
fail-fast: false
matrix:
# Use 2 parallel instances
containers: [1, 2]
steps:
- name: Checkout repository
uses: actions/checkout@v4
Expand All @@ -146,38 +77,18 @@ jobs:
with:
path: ./node_modules
key: "${{ runner.os }}-node_modules-${{ hashFiles('package-lock.json') }}-${{ hashFiles('**/schema.prisma') }}"
- name: Reset nx
run: npx nx reset
- name: Run build
run: npm run build

cypress:
runs-on: ubuntu-latest
if: ${{ false }}
needs:
- test
- lint
- dependency-review
strategy:
# https://github.com/cypress-io/github-action/issues/48
fail-fast: false
matrix:
# Use 2 parallel instances
containers: [1, 2]
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Start services
env:
DB_USER: ${{ env.DB_USERNAME }}
DB_PASSWORD: ${{ env.DB_PASSWORD }}
run: |
cd development
chmod +x ./init/elasticsearch/init.sh
sed -i 's/- \.\/volumes\/elasticsearch\/data:\/usr\/share\/elasticsearch\/data//g' ./docker-compose.yaml
docker compose up -d db oidc elasticsearch
- name: Setup
run: |
npm run prisma -- reset -f
# npm run start:server &> /dev/null &
sleep 60
- name: Migrate database
run: npm run prisma -- migrate deploy
- name: Restore cached e2e node modules
uses: actions/cache/restore@v4
with:
Expand All @@ -188,6 +99,7 @@ jobs:
with:
command: |
npx cypress run \
--browser edge \
--record \
--parallel \
--key ${{ secrets.CYPRESS_RECORD_KEY }} \
Expand All @@ -196,6 +108,7 @@ jobs:
start: npm start
wait-on: "http://localhost:4200"
wait-on-timeout: 120
working-directory: ./e2e
env:
VITE_APP_VERSION: 0.0.99+dev
TZ: Europe/Zurich
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ Thumbs.db
/libs/db-models/src/prisma/swisstopo-lambda_testdaten_asset_swissgeol

__pycache__

.env.local
.env.staging
.env.prod
Expand Down
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@
/dist
/node_modules
/tmp
/.idea
35 changes: 9 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,44 +13,31 @@ The following components must be installed on the development computer:
Follow these steps to set up the development environment on your local machine:

- [1. Configure Local Systems](#1-Configure-Local-Systems)
- [2. Configure the Asset Server](#2-Configure-the-Asset-Server)
- [3. Install Dependencies](#3-Install-Dependencies)
- [4. Generate Database Types](#4-Generate-Database-Types)
- [5. Initialize MinIO](#5-Initialize-MinIO)
- [2. Install Dependencies](#2-Install-Dependencies)
- [3. Generate Database Types](#3-Generate-Database-Types)
- [4. Initialize MinIO](#4-Initialize-MinIO)

#### 1. Configure Local Systems

Configure `development/.env` according to the [local service configuration](#Local-Service-Configuration).

#### 2. Configure the Asset Server

Create an empty copy of the [web server configuration](#Asset-Server-Configuration) as [`apps/server-asset-sg/.env.local`](apps/server-asset-sg/.env.local).
Configure the following variables:

- Set `FRONTEND_URL=http://localhost:4200`.
- Set `DATABASE_URL=postgres://{DB_USER}:{DB_PASSWORD}@localhost:5432/postgres?schema=public`,
where `{DB_USER}` and `{DB_PASSWORD}` equals the environment variables set for your local services.
- Set all `OAUTH_*` variables to the example values to use your local OIDC server.
- Leave `OCR_URL` empty.
- Leave `OCR_CALLBACK_URL` empty.

#### 3. Install Dependencies
#### 2. Install Dependencies

Install node modules:

```bash
npm install
```

#### 4. Generate Database Types
#### 3. Generate Database Types

Generate prisma-client for database-access:

```bash
npm run prisma -- generate
```

#### 5. Initialize MinIO
#### 4. Initialize MinIO

- [Start the development services](#Starting-the-Development-Environment).
- Open http://localhost:9001
Expand All @@ -59,13 +46,9 @@ npm run prisma -- generate
- Navigate to [the new bucket's browser](http://localhost:9001/browser/asset-sg) and create an empty folder with the name `asset-sg`.
- Navigate to [Configuration](http://localhost:9001/settings/configurations/region) and change the server region to `local`.
- Navigate to [Access Keys](http://localhost:9001/access-keys) and create a new access key.
- Open your Asset Server Configuration at [`apps/server-asset-sg/.env.local`](apps/server-asset-sg/.env.local) and make the following changes:
- `S3_REGION=local`
- `S3_ENDPOINT=http://localhost:9000`
- `S3_BUCKET_NAME=asset-sg`
- `S3_ASSET_FOLDER=asset-sg`
- `S3_ACCESS_KEY_ID` as your newly generated access key.
- `S3_SECRET_ACCESS_KEY` as your newly generated access key's secret.
- Open the file [`apps/server-asset-sg/.env.local`](apps/server-asset-sg/.env.local) and modify the following variables:
- Set `S3_ACCESS_KEY_ID` to your generated access key.
- Set `S3_SECRET_ACCESS_KEY` to your generated access key's secret.

### Starting the Development Environment

Expand Down
5 changes: 3 additions & 2 deletions apps/client-asset-sg/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
ARG APP_VERSION

FROM node:20-alpine as app-builder

ARG APP_VERSION
ENV APP_VERSION=${APP_VERSION}
ENV CYPRESS_INSTALL_BINARY=0

Expand All @@ -11,11 +10,13 @@ WORKDIR /app
COPY . .

RUN npm install
RUN sed -i ''s/0.0.0-local/${APP_VERSION}/g'' apps/client-asset-sg/src/assets/version.json
RUN npx nx build client-asset-sg --configuration=production

# final image build
FROM nginx:mainline-alpine

ARG APP_VERSION
ENV APP_VERSION=${APP_VERSION}

WORKDIR /usr/share/nginx/html
Expand Down
11 changes: 6 additions & 5 deletions apps/client-asset-sg/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,21 @@
"inlineStyleLanguage": "scss",
"assets": ["apps/client-asset-sg/src/favicon.ico", "apps/client-asset-sg/src/assets"],
"styles": ["apps/client-asset-sg/src/styles.scss"],
"scripts": []
"scripts": [],
"allowedCommonJsDependencies": ["tsafe", "validator", "xml-utils", "pbf", "rbush", "earcut"]
},
"configurations": {
"production": {
"budgets": [
{
"type": "initial",
"maximumWarning": "1.2mb",
"maximumError": "1.3mb"
"maximumWarning": "1.4mb",
"maximumError": "1.6mb"
},
{
"type": "anyComponentStyle",
"maximumWarning": "2kb",
"maximumError": "4kb"
"maximumWarning": "4kb",
"maximumError": "6kb"
}
],
"outputHashing": "all",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
<img class="logo" src="../../../assets/swissgeol_assets.svg" alt="{{ 'logoSwissGeol' | translate }}" />
</a>
<ng-content />
<div class="spacer"></div>
<span class="version">{{ version }}</span>
<div class="language-links" *rxLet="links$ | push; let l">
<a
asset-sg-reset
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,15 @@
}
}

.spacer {
flex: 10;
}

.version {
color: #828e9a;
}

.language-links {
flex: 1 1 auto;
display: flex;
justify-content: flex-end;
margin-right: 24px;
a {
margin-left: 0.5rem;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ENTER } from '@angular/cdk/keycodes';
import { HttpClient } from '@angular/common/http';
import { ChangeDetectionStrategy, Component, ElementRef, Input, OnInit, Output, ViewChild } from '@angular/core';
import { NavigationEnd, Router } from '@angular/router';
import { isTruthy } from '@asset-sg/core';
Expand All @@ -8,6 +9,7 @@ import { flow, pipe } from 'fp-ts/function';
import * as O from 'fp-ts/Option';
import queryString from 'query-string';
import { EMPTY, Observable, Subject, debounceTime, filter, map, startWith, switchMap } from 'rxjs';
import { Version } from './version';

@UntilDestroy()
@Component({
Expand All @@ -25,6 +27,8 @@ export class AppBarComponent implements OnInit {

public searchTextKeyDown$ = new Subject<KeyboardEvent>();

public version = '';

public _currentLang$ = this._router.events.pipe(
filter((e): e is NavigationEnd => e instanceof NavigationEnd),
map((e) => e.urlAfterRedirects),
Expand Down Expand Up @@ -72,7 +76,8 @@ export class AppBarComponent implements OnInit {

private _ngOnInit$ = new Subject<void>();

constructor(private _router: Router) {
constructor(private _router: Router, private readonly httpClient: HttpClient) {
this.httpClient.get<Version>('/assets/version.json').subscribe((v) => (this.version = v.version));
this.searchTextChanged = this.searchTextKeyDown$.pipe(
filter((ev) => ev.keyCode === ENTER),
map((ev) => {
Expand Down
6 changes: 6 additions & 0 deletions apps/client-asset-sg/src/app/components/app-bar/version.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export interface Version {
tag: string;
build: string;
commit: string;
version: string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
/>
<div class="text">
<p class="welcome">{{ "welcomeTo" | translate }} {{ host }}</p>
<p class="system">Asset Data Management System</p>
<p class="system">Assets</p>
</div>
<ng-container [ngSwitch]="authService.state$ | async">
<ng-container *ngSwitchCase="AuthState.Ongoing">
Expand Down
2 changes: 1 addition & 1 deletion apps/client-asset-sg/src/app/i18n/de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export const deAppTranslations = {
closeInstructions: 'Anleitung schliessen',
searchControl: 'Suchsteuerung',
refineSearch: 'Suche verfeinern',
searchResults: 'Suchtreffer',
searchResults: 'Assets',
author: 'Autor',
documentDate: 'Dokumentdatum',
usage: 'Nutzung',
Expand Down
2 changes: 1 addition & 1 deletion apps/client-asset-sg/src/app/i18n/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export const enAppTranslations: AppTranslations = {
closeInstructions: 'Close instructions',
searchControl: 'Search control',
refineSearch: 'Refine search',
searchResults: 'Search results',
searchResults: 'Assets',
author: 'Author',
documentDate: 'Document date',
usage: 'Usage',
Expand Down
Loading