Skip to content

Commit

Permalink
Feature/assets 7 eIAM (#75)
Browse files Browse the repository at this point in the history
#7:  integrate eIAM
  • Loading branch information
TIL-EBP authored Apr 10, 2024
1 parent 64b027c commit b6e7063
Show file tree
Hide file tree
Showing 38 changed files with 1,086 additions and 510 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ The following steps must be carried out once:
| pgAdmin (docker) | [localhost:5051](http://localhost:5051/) | .env `$PGADMIN_EMAIL` |.env `$PGADMIN_PASSWORD` |
| MinIO (docker) | [localhost:9001](http://localhost:9001/) | .env `$STORAGE_USER` |.env `$STORAGE_PASSWORD` |
| smtp4dev (docker) | [localhost:5000](http://localhost:5000/) | n/a | n/a |
| oidc-server (docker) | [localhost:4011](http://localhost:4011/) | n/a | n/a |

### Creating elastic-search index

Expand Down
193 changes: 110 additions & 83 deletions apps/client-asset-sg/project.json
Original file line number Diff line number Diff line change
@@ -1,93 +1,120 @@
{
"name": "client-asset-sg",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"projectType": "application",
"sourceRoot": "apps/client-asset-sg/src",
"prefix": "asset-sg",
"targets": {
"build": {
"executor": "@angular-devkit/build-angular:browser",
"outputs": ["{options.outputPath}"],
"options": {
"outputPath": "dist/apps/client-asset-sg",
"index": "apps/client-asset-sg/src/index.html",
"main": "apps/client-asset-sg/src/main.ts",
"polyfills": ["zone.js"],
"tsConfig": "apps/client-asset-sg/tsconfig.app.json",
"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": []
"name": "client-asset-sg",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"projectType": "application",
"sourceRoot": "apps/client-asset-sg/src",
"prefix": "asset-sg",
"targets": {
"build": {
"executor": "@angular-devkit/build-angular:browser",
"outputs": [
"{options.outputPath}"
],
"options": {
"outputPath": "dist/apps/client-asset-sg",
"index": "apps/client-asset-sg/src/index.html",
"main": "apps/client-asset-sg/src/main.ts",
"polyfills": [
"zone.js"
],
"tsConfig": "apps/client-asset-sg/tsconfig.app.json",
"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": []
},
"configurations": {
"production": {
"budgets": [
{
"type": "initial",
"maximumWarning": "1.2mb",
"maximumError": "1.3mb"
},
"configurations": {
"production": {
"budgets": [
{
"type": "initial",
"maximumWarning": "1.2mb",
"maximumError": "1.3mb"
},
{
"type": "anyComponentStyle",
"maximumWarning": "2kb",
"maximumError": "4kb"
}
],
"outputHashing": "all",
"fileReplacements": [
{
"replace": "apps/client-asset-sg/src/environments/environment.ts",
"with": "apps/client-asset-sg/src/environments/environment.prod.ts"
}
]
},
"development": {
"buildOptimizer": false,
"optimization": false,
"vendorChunk": true,
"extractLicenses": false,
"sourceMap": true,
"namedChunks": true
}
},
"defaultConfiguration": "production"
},
"serve": {
"executor": "@angular-devkit/build-angular:dev-server",
"configurations": {
"production": {
"browserTarget": "client-asset-sg:build:production"
},
"development": {
"browserTarget": "client-asset-sg:build:development"
}
},
"defaultConfiguration": "development",
"options": {
"proxyConfig": "apps/client-asset-sg/proxy.conf.json"
{
"type": "anyComponentStyle",
"maximumWarning": "2kb",
"maximumError": "4kb"
}
},
"extract-i18n": {
"executor": "@angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "client-asset-sg:build"
],
"outputHashing": "all",
"fileReplacements": [
{
"replace": "apps/client-asset-sg/src/environments/environment.ts",
"with": "apps/client-asset-sg/src/environments/environment.prod.ts"
}
]
},
"lint": {
"executor": "@nrwl/linter:eslint",
"outputs": ["{options.outputFile}"],
"options": {
"lintFilePatterns": ["apps/client-asset-sg/**/*.ts", "apps/client-asset-sg/**/*.html"]
"int": {
"fileReplacements": [
{
"replace": "apps/client-asset-sg/src/environments/environment.ts",
"with": "apps/client-asset-sg/src/environments/environment.int.ts"
}
]
},
"test": {
"executor": "@nrwl/jest:jest",
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
"options": {
"jestConfig": "apps/client-asset-sg/jest.config.ts",
"passWithNoTests": true
}
"development": {
"buildOptimizer": false,
"optimization": false,
"vendorChunk": true,
"extractLicenses": false,
"sourceMap": true,
"namedChunks": true
}
},
"defaultConfiguration": "production"
},
"serve": {
"executor": "@angular-devkit/build-angular:dev-server",
"configurations": {
"production": {
"browserTarget": "client-asset-sg:build:production"
},
"int": {
"browserTarget": "client-asset-sg:build:int"
},
"development": {
"browserTarget": "client-asset-sg:build:development"
}
},
"defaultConfiguration": "development",
"options": {
"proxyConfig": "apps/client-asset-sg/proxy.conf.json"
}
},
"extract-i18n": {
"executor": "@angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "client-asset-sg:build"
}
},
"lint": {
"executor": "@nrwl/linter:eslint",
"outputs": [
"{options.outputFile}"
],
"options": {
"lintFilePatterns": [
"apps/client-asset-sg/**/*.ts",
"apps/client-asset-sg/**/*.html"
]
}
},
"tags": []
"test": {
"executor": "@nrwl/jest:jest",
"outputs": [
"{workspaceRoot}/coverage/{projectRoot}"
],
"options": {
"jestConfig": "apps/client-asset-sg/jest.config.ts",
"passWithNoTests": true
}
}
},
"tags": []
}
6 changes: 3 additions & 3 deletions apps/client-asset-sg/src/app/app.component.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<asset-sg-app-bar>
<ng-template [cdkPortalOutlet]="appPortalService.appBarPortalContent$ | push"></ng-template>
<ng-template [cdkPortalOutlet]="appPortalService.appBarPortalContent$ | push"></ng-template>
</asset-sg-app-bar>
<asset-sg-menu-bar />
<div class="router-outlet">
<router-outlet></router-outlet>
<router-outlet></router-outlet>
</div>
<div class="drawer-portal">
<ng-template [cdkPortalOutlet]="appPortalService.drawerPortalContent$ | push"></ng-template>
<ng-template [cdkPortalOutlet]="appPortalService.drawerPortalContent$ | push"></ng-template>
</div>
38 changes: 31 additions & 7 deletions apps/client-asset-sg/src/app/app.component.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import { HttpClient } from '@angular/common/http';
import { Component, inject } from '@angular/core';
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy';
import { Store } from '@ngrx/store';
import { WINDOW } from 'ngx-window-token';
import { debounceTime, fromEvent, startWith } from 'rxjs';
import { debounceTime, fromEvent, map, startWith } from 'rxjs';
import { assert } from 'tsafe';

import { AppPortalService, setCssCustomProperties } from '@asset-sg/client-shared';
import { FavouriteService } from '@asset-sg/favourite';
import { AuthService } from '@asset-sg/auth';
import { AppPortalService, appSharedStateActions, setCssCustomProperties } from '@asset-sg/client-shared';

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

const fullHdWidth = 1920;

Expand All @@ -17,18 +21,38 @@ const fullHdWidth = 1920;
})
export class AppComponent {
private _wndw = inject(WINDOW);

private _httpClient = inject(HttpClient);
public appPortalService = inject(AppPortalService);
private _favouriteService = inject(FavouriteService);
private store = inject(Store<AppState>);

constructor(private readonly _authService: AuthService) {
this._httpClient
.get('api/oauth-config/config')
.pipe(
map((response: any) => {

Check warning on line 32 in apps/client-asset-sg/src/app/app.component.ts

View workflow job for this annotation

GitHub Actions / Build and run tests

Unexpected any. Specify a different type
return response;
}),
)
.subscribe(async oAuthConfig => {
await this._authService.configureOAuth(
oAuthConfig.oauth_issuer,
oAuthConfig.oauth_clientId,
oAuthConfig.oauth_scope,
oAuthConfig.oauth_showDebugInformation,
oAuthConfig.oauth_tokenEndpoint,
);

this.store.dispatch(appSharedStateActions.loadUserProfile());
this.store.dispatch(appSharedStateActions.loadReferenceData());
});

constructor() {
const wndw = this._wndw;
assert(wndw != null);

fromEvent(wndw, 'resize')
.pipe(debounceTime(50), startWith(null), untilDestroyed(this))
.subscribe(() => {
let fontSize = '1rem';
let fontSize;
const width = window.innerWidth;
if (width >= fullHdWidth) {
fontSize = '1rem';
Expand Down
6 changes: 5 additions & 1 deletion apps/client-asset-sg/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { PushModule } from '@rx-angular/template/push';
import * as O from 'fp-ts/Option';
import * as C from 'io-ts/Codec';

import { AuthInterceptor } from '@asset-sg/auth';
import { AuthInterceptor, AuthModule } from '@asset-sg/auth';
import {
AnchorComponent,
ButtonComponent,
Expand Down Expand Up @@ -104,6 +104,7 @@ registerLocaleData(locale_deCH, 'de-CH');
ButtonComponent,
DialogModule,
A11yModule,
AuthModule,
],
providers: [
provideSvgIcons(icons),
Expand All @@ -115,6 +116,7 @@ registerLocaleData(locale_deCH, 'de-CH');
})
export class AppModule {
private _translateService = inject(TranslateService);

constructor() {
this._translateService.setDefaultLang('de');
}
Expand All @@ -123,9 +125,11 @@ export class AppModule {
export interface Encoder<O, A> {
readonly encode: (a: A) => O;
}

function optionFromNullable<O, A>(encoder: Encoder<O, A>): Encoder<O | null, O.Option<A>> {
return {
encode: O.fold(() => null, encoder.encode),
};
}

const foooobar = optionFromNullable(C.string);

Check warning on line 135 in apps/client-asset-sg/src/app/app.module.ts

View workflow job for this annotation

GitHub Actions / Build and run tests

'foooobar' is assigned a value but never used
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ import { Component } from '@angular/core';

@Component({
selector: 'asset-sg-not-found',
template: `<div>Not Found</div>`,
template: ` <div>Not Found</div>`,
})
export class NotFoundComponent {}
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,16 @@ import * as E from 'fp-ts/Either';
import * as D from 'io-ts/Decoder';
import queryString from 'query-string';

import { AuthService } from '@asset-sg/auth';
import { Lang } from '@asset-sg/shared';

@UntilDestroy()
@Component({
selector: 'asset-sg-redirect-to-lang',
template: 'redirect',
template: 'Redirect to main page...',
})
export class RedirectToLangComponent {
constructor(route: ActivatedRoute, router: Router) {
constructor(route: ActivatedRoute, router: Router, authService: AuthService) {
route.queryParams.pipe(untilDestroyed(this)).subscribe(params => {
const paramsDecoded = D.struct({
lang: Lang,
Expand All @@ -25,6 +26,10 @@ export class RedirectToLangComponent {
const { lang, ...rest } = query;
const newUrl = `/${paramsDecoded.right.lang}${url}?${queryString.stringify(rest)}`;
router.navigateByUrl(newUrl);
} else if (!authService.isLoggedIn()) {
setTimeout(() => {
router.navigate(['/de']);
}, 500);
} else {
router.navigate(['/de']);
}
Expand Down
5 changes: 5 additions & 0 deletions apps/client-asset-sg/src/environments/environment.int.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { CompileTimeEnvironment } from './environment-type';

export const environment: CompileTimeEnvironment = {
ngrxStoreLoggerEnabled: false,
};
Loading

0 comments on commit b6e7063

Please sign in to comment.