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

INT Release #245

Merged
merged 32 commits into from
Jul 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
048e2f4
Re-add missing code quality steps
daniel-va Jul 19, 2024
4056a83
Merge pull request #229 from swisstopo/fix/reactivate-code-quality-pi…
daniel-va Jul 22, 2024
a9ffd53
Add CHANGELOG.md
vej-ananas Jul 18, 2024
e56f30e
Comment out cypress tests until fixed
vej-ananas Jul 22, 2024
6067703
Merge pull request #224 from swisstopo/chore/assets-174-release-notes
vej-ananas Jul 22, 2024
f60da23
Ignore asset selections when polygon is being drawn
daniel-va Jul 18, 2024
db2b186
Fix author filters overflowing on new line
daniel-va Jul 19, 2024
60bde4c
Make author count always visible in asset filter
daniel-va Jul 22, 2024
14210e4
Merge pull request #225 from swisstopo/feature/asset-220-bug-polygon-…
daniel-va Jul 22, 2024
75b61bb
Merge pull request #228 from swisstopo/feature/asset-221-bug-autoren-…
daniel-va Jul 22, 2024
9026060
Disable map click event when drawing polygon
daniel-va Jul 22, 2024
2adc87e
Bump node version to 22.x
daniel-va Jul 22, 2024
4dd0009
Merge pull request #233 from swisstopo/feature/asset-225-polygon-sele…
daniel-va Jul 22, 2024
3542707
Merge pull request #231 from swisstopo/feature/asset-219-bug-stats-pr…
daniel-va Jul 22, 2024
4bcfa39
Add minimum date for `createDate` filter
daniel-va Jul 23, 2024
8bb6753
Add missing optional NX dependencies used by docker build
daniel-va Jul 23, 2024
29389fa
Merge pull request #236 from swisstopo/feature/asset-222-anfangsdatum…
daniel-va Jul 23, 2024
43b57d5
Merge pull request #237 from swisstopo/fix/missing-npm-docker-dependency
daniel-va Jul 23, 2024
35a035a
Fix non-point studies being displayed as points
daniel-va Jul 24, 2024
ce37989
Merge pull request #242 from swisstopo/feature/asset-230-bug-rauten-v…
daniel-va Jul 25, 2024
c4e70cc
Add workgroups to DB schema
TIL-EBP Jun 26, 2024
57d1896
Add workgroup API
TIL-EBP Jun 27, 2024
d5306be
Add policy-based API authorization
daniel-va Jul 10, 2024
d5e0be4
Add policy-based client authorization
daniel-va Jul 10, 2024
f05a87e
Add workgroup dropdown to asset form
daniel-va Jul 19, 2024
b27d281
Add workgroup admin ui
TIL-EBP Jun 26, 2024
d3a064e
Align multiple parts of workgroup changes
daniel-va Jul 24, 2024
f33438b
Add workgroup filter to asset search
daniel-va Jul 24, 2024
84ebfee
Update CHANGELOG.md
daniel-va Jul 25, 2024
88c7a82
Merge pull request #243 from swisstopo/feature/workgroups
daniel-va Jul 25, 2024
9103275
Fix workgroup activation not doing anything
daniel-va Jul 25, 2024
3e47f6c
Merge pull request #246 from swisstopo/fix/workgrup-activation-not-wo…
daniel-va Jul 25, 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
197 changes: 147 additions & 50 deletions .github/workflows/code-quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,21 @@ on:
- "!main"

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

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

install:
runs-on: ubuntu-latest
steps:
Expand All @@ -31,40 +39,52 @@ jobs:
uses: actions/cache@v4
with:
path: ${{ steps.npm-cache-dir.outputs.dir }}
key: "${{ runner.os }}-npm-${{ hashFiles('package-lock.json') }}"
key: "${{ runner.os }}-npm-${{ env.NODE_VERSION }}-${{ hashFiles('package-lock.json') }}"
restore-keys: |
${{ runner.os }}-npm-
- name: Cache node modules
uses: actions/cache@v4
with:
path: ./node_modules
key: "${{ runner.os }}-node_modules-${{ hashFiles('package-lock.json') }}-${{ hashFiles('**/schema.prisma') }}"
key: "${{ runner.os }}-node_modules-${{ env.NODE_VERSION }}-${{ hashFiles('package-lock.json') }}-${{ hashFiles('**/schema.prisma') }}"
restore-keys: |
${{ runner.os }}-node_modules-
- name: Cache e2e node modules
uses: actions/cache@v4
with:
path: ./e2e/node_modules
key: "${{ runner.os }}-node_modules_e2e-${{ hashFiles('./e2e/package-lock.json') }}"
key: "${{ runner.os }}-node_modules_e2e-${{ env.NODE_VERSION }}-${{ hashFiles('./e2e/package-lock.json') }}"
restore-keys: |
${{ runner.os }}-node_modules_e2e-
- name: Install node dependencies
run: npm ci
run: npm install
- name: Generate prisma types
run: npm run prisma -- generate
- name: Install e2e node dependencies
run: cd e2e && npm ci

cypress:
test:
runs-on: ubuntu-latest
needs:
- install
strategy:
# https://github.com/cypress-io/github-action/issues/48
fail-fast: false
matrix:
# Use 2 parallel instances
containers: [1, 2]
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
Expand All @@ -76,44 +96,121 @@ jobs:
uses: actions/cache/restore@v4
with:
path: ./node_modules
key: "${{ runner.os }}-node_modules-${{ hashFiles('package-lock.json') }}-${{ hashFiles('**/schema.prisma') }}"
- 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
sleep 60
key: "${{ runner.os }}-node_modules-${{ env.NODE_VERSION }}-${{ hashFiles('package-lock.json') }}-${{ hashFiles('**/schema.prisma') }}"
- name: Migrate database
run: npm run prisma -- migrate deploy
- name: Restore cached e2e node modules
- 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: ./e2e/node_modules
key: "${{ runner.os }}-node_modules_e2e-${{ hashFiles('./e2e/package-lock.json') }}"
- name: Cypress run
uses: cypress-io/github-action@v6
path: ./node_modules
key: "${{ runner.os }}-node_modules-${{ env.NODE_VERSION }}-${{ hashFiles('package-lock.json') }}-${{ hashFiles('**/schema.prisma') }}"
- name: Run lint
run: npm run lint
- name: Run prettier
run: npx prettier --check .

# 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:
runs-on: ubuntu-latest
needs:
- test
- lint
- dependency-review
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup node
uses: actions/setup-node@v4
with:
command: |
npx cypress run \
--browser edge \
--record \
--parallel \
--key ${{ secrets.CYPRESS_RECORD_KEY }} \
--ci-build-id ${{ github.repository }}-${{ github.head_ref || github.ref_name }}-${{ github.sha }}
build: npm run build
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
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Stop services
run: |
cd development
docker compose down
node-version: ${{ env.NODE_VERSION }}
- name: Restore cached node modules
uses: actions/cache/restore@v4
with:
path: ./node_modules
key: "${{ runner.os }}-node_modules-${{ env.NODE_VERSION }}-${{ 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
# 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: 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-${{ env.NODE_VERSION }}-${{ hashFiles('package-lock.json') }}-${{ hashFiles('**/schema.prisma') }}"
# - 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
# sleep 60
# - name: Migrate database
# run: npm run prisma -- migrate deploy
# - name: Restore cached e2e node modules
# uses: actions/cache/restore@v4
# with:
# path: ./e2e/node_modules
# key: "${{ runner.os }}-node_modules_e2e-${{ env.NODE_VERSION }}-${{ hashFiles('./e2e/package-lock.json') }}"
# - name: Cypress run
# uses: cypress-io/github-action@v6
# with:
# command: |
# npx cypress run \
# --browser edge \
# --record \
# --parallel \
# --key ${{ secrets.CYPRESS_RECORD_KEY }} \
# --ci-build-id ${{ github.repository }}-${{ github.head_ref || github.ref_name }}-${{ github.sha }}
# build: npm run build
# 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
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# - name: Stop services
# run: |
# cd development
# docker compose down
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@
/node_modules
/tmp
/.idea
/development/volumes
24 changes: 24 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Changelog

## [Unreleased]

### Added

- Suchfilter zeigen Anzahl Ergebnisse und sind inital verfügbar
- Mehrsprachigkeit von Assets
- Versionsnummer der Applikation wird angezeigt
- Direktauswahl von Assets ohne Suche
- Testing
- Regeneriere Elasticsearch Index via Admin Panel
- Einteilung von Assets in Arbeitsgruppen

### Changed

- UI Refactoring: Neuanordnung der Container
- UI Refactoring: Suchergebnisse als Tabelle
- Update Dependencies
- Bearbeitungsrechte werden auf Basis der Arbeitsgruppen vergeben anstatt global

### Fixed

- Error Handling
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ npm run prisma -- migrate deploy

# Import example data:
cd development
docker compose exec db sh -c 'psql --dbname=postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@localhost:5432/${POSTGRES_DB} -f /dump.sql'
docker compose exec db sh -c 'psql --dbname=postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@localhost:5432/${POSTGRES_DB} -v ON_ERROR_STOP=1 -f /dump.sql'
```

> You will need to manually sync the data to Elasticsearch via the admin panel in the web UI.
Expand Down
2 changes: 1 addition & 1 deletion apps/client-asset-sg/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:20-alpine as app-builder
FROM node:22-alpine as app-builder

ARG APP_VERSION
ENV APP_VERSION=${APP_VERSION}
Expand Down
2 changes: 1 addition & 1 deletion apps/client-asset-sg/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"assets": ["apps/client-asset-sg/src/favicon.ico", "apps/client-asset-sg/src/assets"],
"styles": ["apps/client-asset-sg/src/styles.scss"],
"scripts": [],
"allowedCommonJsDependencies": ["tsafe", "validator", "xml-utils", "pbf", "rbush", "earcut"]
"allowedCommonJsDependencies": ["tsafe", "validator", "xml-utils", "pbf", "rbush", "earcut", "@prisma/client"]
},
"configurations": {
"production": {
Expand Down
25 changes: 6 additions & 19 deletions apps/client-asset-sg/src/app/app-guards.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,16 @@
import { inject } from '@angular/core';
import { CanActivateFn } from '@angular/router';
import { fromAppShared } from '@asset-sg/client-shared';
import { ORD } from '@asset-sg/core';
import { User, isAdmin, isEditor } from '@asset-sg/shared';
import { isNotNull } from '@asset-sg/core';
import { User } from '@asset-sg/shared/v2';
import { Store } from '@ngrx/store';
import * as E from 'fp-ts/Either';
import { pipe } from 'fp-ts/function';
import { map } from 'rxjs';
import { filter, map } from 'rxjs';

import { AppState } from './state/app-state';

export const roleGuard = (rolePredicate: (u: User) => boolean) => {
export const roleGuard = (testUser: (u: User) => boolean) => {
const store = inject(Store<AppState>);
return store.select(fromAppShared.selectRDUserProfile).pipe(
ORD.filterIsCompleteEither,
map((user) =>
E.isRight(
pipe(
user,
E.filterOrElseW(rolePredicate, () => undefined)
)
)
)
);
return store.select(fromAppShared.selectUser).pipe(filter(isNotNull), map(testUser));
};

export const adminGuard: CanActivateFn = () => roleGuard(isAdmin);
export const editorGuard: CanActivateFn = () => roleGuard(isEditor);
export const adminGuard: CanActivateFn = () => roleGuard((user) => user.isAdmin);
40 changes: 23 additions & 17 deletions apps/client-asset-sg/src/app/app.component.html
Original file line number Diff line number Diff line change
@@ -1,30 +1,36 @@
<ng-container *ngIf="errorService.onMessage | async as error; else splashScreen">
<ng-container *ngIf="errorService.onMessage | async as error; else content">
<asset-sg-app-bar />
<div class="error">
<span>{{ error }}</span>
<button asset-sg-warn (click)="authService.logOut()">Logout</button>
</div>
</ng-container>

<ng-template #splashScreen>
<ng-container *ngIf="(authService.state$ | async) !== AuthState.Success; else content">
<ng-template #content>
<ng-container *ngIf="authService.state$ | async as authState">
@if (authState === AuthState.Success || authState === AuthState.ForbiddenResource) {
<asset-sg-app-bar>
<ng-template [cdkPortalOutlet]="(appPortalService.appBarPortalContent$ | push) ?? ''"></ng-template>
</asset-sg-app-bar>
<asset-sg-menu-bar />
<div class="router-outlet">
@if (authState === AuthState.Success) {
<router-outlet />
} @else {
<div class="forbidden">
<h1 translate>resourceForbidden</h1>
<p>403 - Forbidden</p>
</div>
}
</div>
<div class="drawer-portal">
<ng-template [cdkPortalOutlet]="(appPortalService.drawerPortalContent$ | push) ?? ''"></ng-template>
</div>
} @else {
<app-splash-screen />
}
</ng-container>
</ng-template>

<ng-template #content>
<asset-sg-app-bar>
<ng-template [cdkPortalOutlet]="appPortalService.appBarPortalContent$ | push"></ng-template>
</asset-sg-app-bar>
<asset-sg-menu-bar />
<div class="router-outlet">
<router-outlet></router-outlet>
</div>
<div class="drawer-portal">
<ng-template [cdkPortalOutlet]="appPortalService.drawerPortalContent$ | push"></ng-template>
</div>
</ng-template>

<div class="alerts">
<ul app-alert-list></ul>
</div>
Loading