diff --git a/apps/client-asset-sg/src/app/app-matchers.ts b/apps/client-asset-sg/src/app/app-matchers.ts deleted file mode 100644 index 7b979c7a..00000000 --- a/apps/client-asset-sg/src/app/app-matchers.ts +++ /dev/null @@ -1,37 +0,0 @@ -import { UrlMatchResult, UrlSegment } from '@angular/router'; -import { Lang } from '@asset-sg/shared'; -import { pipe } from 'fp-ts/function'; -import * as NEA from 'fp-ts/NonEmptyArray'; -import * as O from 'fp-ts/Option'; -import * as D from 'io-ts/Decoder'; - -const validSegments = D.union(D.literal('assets'), D.literal('favourites')); - -export function assetsPageMatcher(segments: UrlSegment[]): UrlMatchResult { - return pipe( - segments, - NEA.fromArray, - O.chain((ss) => { - const lang = NEA.head(ss); - return pipe( - O.fromEither(Lang.decode(lang.path)), - O.map(() => - pipe( - ss, - NEA.tail, - NEA.fromArray, - O.map(NEA.head), - O.chainFirstEitherK((a) => validSegments.decode(a.path)), - O.map((path) => ({ lang, path })), - O.getOrElse(() => ({ lang })) - ) - ) - ); - }), - O.map((posParams) => ({ - consumed: segments, - posParams, - })), - O.getOrElse(() => (null as unknown)) - ); -} diff --git a/apps/client-asset-sg/src/app/app.component.ts b/apps/client-asset-sg/src/app/app.component.ts index 03620109..0b1ac07a 100644 --- a/apps/client-asset-sg/src/app/app.component.ts +++ b/apps/client-asset-sg/src/app/app.component.ts @@ -1,12 +1,11 @@ import { HttpClient } from '@angular/common/http'; import { Component, inject } from '@angular/core'; -import { Router } from '@angular/router'; import { AuthService, AuthState, ErrorService } from '@asset-sg/auth'; import { AppPortalService, appSharedStateActions, setCssCustomProperties } from '@asset-sg/client-shared'; import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'; import { Store } from '@ngrx/store'; import { WINDOW } from 'ngx-window-token'; -import { debounceTime, fromEvent, startWith, tap } from 'rxjs'; +import { debounceTime, fromEvent, startWith, switchMap } from 'rxjs'; import { assert } from 'tsafe'; import { AppState } from './state/app-state'; @@ -23,7 +22,6 @@ export class AppComponent { private _httpClient = inject(HttpClient); public appPortalService = inject(AppPortalService); - private readonly router: Router = inject(Router); readonly errorService = inject(ErrorService); readonly authService = inject(AuthService); private readonly store = inject(Store); @@ -31,8 +29,8 @@ export class AppComponent { constructor() { this._httpClient .get>('api/oauth-config/config') - .pipe(tap(async (config) => await this.authService.initialize(config))) - .subscribe(async (oAuthConfig) => { + .pipe(switchMap(async (config) => await this.authService.initialize(config))) + .subscribe(async () => { this.store.dispatch(appSharedStateActions.loadWorkgroups()); this.store.dispatch(appSharedStateActions.loadReferenceData()); }); diff --git a/apps/client-asset-sg/src/app/app.module.ts b/apps/client-asset-sg/src/app/app.module.ts index d0c49edc..75eaeab2 100644 --- a/apps/client-asset-sg/src/app/app.module.ts +++ b/apps/client-asset-sg/src/app/app.module.ts @@ -21,6 +21,7 @@ import { icons, TranslateTsLoader, } from '@asset-sg/client-shared'; +import { assetsPageMatcher } from '@asset-sg/client-shared'; import { storeLogger } from '@asset-sg/core'; import { provideSvgIcons, SvgIconComponent } from '@ngneat/svg-icon'; import { EffectsModule } from '@ngrx/effects'; @@ -34,7 +35,6 @@ import { PushModule } from '@rx-angular/template/push'; import { environment } from '../environments/environment'; import { adminGuard, notAnonymousGuard } from './app-guards'; -import { assetsPageMatcher } from './app-matchers'; import { AppComponent } from './app.component'; import { AppBarComponent, MenuBarComponent, NotFoundComponent, RedirectToLangComponent } from './components'; import { SplashScreenComponent } from './components/splash-screen/splash-screen.component'; @@ -59,10 +59,6 @@ registerLocaleData(locale_deCH, 'de-CH'); BrowserAnimationsModule, HttpClientModule, RouterModule.forRoot([ - { - path: ':lang/auth', - loadChildren: () => AuthModule, - }, { path: ':lang/profile', loadChildren: () => import('@asset-sg/profile').then((m) => m.ProfileModule), diff --git a/apps/client-asset-sg/src/app/components/app-bar/app-bar.component.scss b/apps/client-asset-sg/src/app/components/app-bar/app-bar.component.scss index 6ec9cda6..35aa58bb 100644 --- a/apps/client-asset-sg/src/app/components/app-bar/app-bar.component.scss +++ b/apps/client-asset-sg/src/app/components/app-bar/app-bar.component.scss @@ -2,7 +2,7 @@ :host { box-shadow: 0px 4px 4px #00000029; - z-index: 1; + z-index: 10; display: flex; align-items: center; } diff --git a/apps/client-asset-sg/src/app/components/app-bar/app-bar.component.ts b/apps/client-asset-sg/src/app/components/app-bar/app-bar.component.ts index 7c351c9d..b9e96067 100644 --- a/apps/client-asset-sg/src/app/components/app-bar/app-bar.component.ts +++ b/apps/client-asset-sg/src/app/components/app-bar/app-bar.component.ts @@ -2,6 +2,7 @@ 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 { supportedLangs } from '@asset-sg/client-shared'; import { isTruthy } from '@asset-sg/core'; import { Lang } from '@asset-sg/shared'; import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'; @@ -52,7 +53,7 @@ export class AppBarComponent implements OnInit { public links$ = this._currentLang$.pipe( debounceTime(0), map((currentLang) => ({ - links: ['de', 'fr', 'it', 'rm', 'en'].map( + links: supportedLangs.map( (lang) => pipe( currentLang, diff --git a/apps/client-asset-sg/src/app/components/menu-bar/menu-bar.component.html b/apps/client-asset-sg/src/app/components/menu-bar/menu-bar.component.html index 6bc281ab..a66abde4 100644 --- a/apps/client-asset-sg/src/app/components/menu-bar/menu-bar.component.html +++ b/apps/client-asset-sg/src/app/components/menu-bar/menu-bar.component.html @@ -1,58 +1,43 @@
- - - - - menuBar.assets - - + menuBar.favourites - - - - - - menuBar.admin - - - + + + + menuBar.admin + menuBar.userManagement @@ -64,7 +49,7 @@ [routerLink]="[_translateService.currentLang, 'profile']" asset-sg-reset class="menu-bar-item" - [ngClass]="{ active: (isProfileActive$ | async) }" + routerLinkActive="active" > menuBar.profile diff --git a/apps/client-asset-sg/src/app/components/menu-bar/menu-bar.component.ts b/apps/client-asset-sg/src/app/components/menu-bar/menu-bar.component.ts index 2a20a6d6..bf41d5ba 100644 --- a/apps/client-asset-sg/src/app/components/menu-bar/menu-bar.component.ts +++ b/apps/client-asset-sg/src/app/components/menu-bar/menu-bar.component.ts @@ -1,12 +1,11 @@ import { ChangeDetectionStrategy, Component, HostBinding, inject } from '@angular/core'; import { NavigationEnd, Router } from '@angular/router'; -import { appSharedStateActions, fromAppShared } from '@asset-sg/client-shared'; +import { appSharedStateActions, assetsPageMatcher, fromAppShared } from '@asset-sg/client-shared'; import { AssetEditPolicy } from '@asset-sg/shared/v2'; -import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'; +import { UntilDestroy } from '@ngneat/until-destroy'; import { Store } from '@ngrx/store'; import { TranslateService } from '@ngx-translate/core'; -import queryString from 'query-string'; -import { filter, map, shareReplay } from 'rxjs'; +import { filter, map } from 'rxjs'; import { AppState } from '../../state/app-state'; @@ -24,30 +23,13 @@ export class MenuBarComponent { private _store = inject(Store); public userExists$ = this._store.select(fromAppShared.selectIsAnonymousMode).pipe(map((anonymous) => !anonymous)); - public isAssetsActive$ = this.createIsRouteActive$((url) => Boolean(url.match(/^\/\w\w$/))); - public isEditActive$ = this.isSegmentActive('asset-admin'); - public isFavouritesActive$ = this.isSegmentActive('favourites'); - public isAdminActive$ = this.isSegmentActive('admin'); - public isProfileActive$ = this.isSegmentActive('profile'); - - private createIsRouteActive$(fn: (url: string) => boolean) { - const o$ = this._router.events.pipe( - filter((event) => event instanceof NavigationEnd), - map(() => { - const { url } = queryString.parseUrl(this._router.url); - return fn(url); - }), - shareReplay({ bufferSize: 1, refCount: true }) - ); - o$.pipe(untilDestroyed(this)).subscribe(); - return o$; - } - - private isSegmentActive(segment: string) { - return this.createIsRouteActive$((url) => { - return Boolean(url.match(`^/\\w\\w/${segment}`)); - }); - } + public isAssetsActive$ = this._router.events.pipe( + filter((event) => event instanceof NavigationEnd), + map(() => { + const segments = this._router.parseUrl(this._router.url).root.children['primary'].segments; + return assetsPageMatcher(segments) !== null; + }) + ); public openAssetDrawer() { this._store.dispatch(appSharedStateActions.toggleSearchFilter()); diff --git a/apps/client-asset-sg/src/app/components/splash-screen/splash-screen.component.ts b/apps/client-asset-sg/src/app/components/splash-screen/splash-screen.component.ts index 2fcdeaed..440cd2de 100644 --- a/apps/client-asset-sg/src/app/components/splash-screen/splash-screen.component.ts +++ b/apps/client-asset-sg/src/app/components/splash-screen/splash-screen.component.ts @@ -2,7 +2,6 @@ import { Component, inject } from '@angular/core'; import { AuthService, AuthState } from '@asset-sg/auth'; import { CURRENT_LANG } from '@asset-sg/client-shared'; import { TranslateService } from '@ngx-translate/core'; -import { Observable, map, startWith } from 'rxjs'; @Component({ selector: 'app-splash-screen', @@ -18,18 +17,6 @@ export class SplashScreenComponent { return window.location.host; } - get languages$(): Observable> { - return this.currentLang$.pipe( - startWith('de'), - map((lang) => - ['de', 'fr', 'it', 'rm', 'en'].map((it) => ({ - name: it, - isActive: lang === it, - })) - ) - ); - } - selectLanguage(language: string): void { this.translateService.use(language); } diff --git a/apps/server-asset-sg/src/features/ocr/ocr.controller.ts b/apps/server-asset-sg/src/features/ocr/ocr.controller.ts index 5e228aab..e2c5d3ea 100644 --- a/apps/server-asset-sg/src/features/ocr/ocr.controller.ts +++ b/apps/server-asset-sg/src/features/ocr/ocr.controller.ts @@ -45,7 +45,6 @@ export class OcrController { private config: Config; constructor(private prismaService: PrismaService, private httpService: HttpService) { - console.log('hello ocr controller'); this.config = pipe( Config.decode({ ocrUrl: process.env.OCR_URL, diff --git a/libs/asset-editor/src/lib/components/asset-editor-tab-page/asset-editor-tab-page.component.ts b/libs/asset-editor/src/lib/components/asset-editor-tab-page/asset-editor-tab-page.component.ts index 120a2a18..4db4a093 100644 --- a/libs/asset-editor/src/lib/components/asset-editor-tab-page/asset-editor-tab-page.component.ts +++ b/libs/asset-editor/src/lib/components/asset-editor-tab-page/asset-editor-tab-page.component.ts @@ -148,9 +148,6 @@ export class AssetEditorTabPageComponent { this._form.controls.administration.controls.newStatusWorkItemCode.disable(); } }); - this._form.valueChanges.subscribe(() => { - // console.log('value', this._form.value); - }); this._lc.afterViewInit$ .pipe( diff --git a/libs/asset-viewer/src/lib/components/asset-search-filter-list/asset-search-filter-list.component.ts b/libs/asset-viewer/src/lib/components/asset-search-filter-list/asset-search-filter-list.component.ts index e2bd230f..bc03ba71 100644 --- a/libs/asset-viewer/src/lib/components/asset-search-filter-list/asset-search-filter-list.component.ts +++ b/libs/asset-viewer/src/lib/components/asset-search-filter-list/asset-search-filter-list.component.ts @@ -23,8 +23,8 @@ export class AssetSearchFilterListComponent { activeValues.add(filter.value); } this.store.dispatch( - actions.searchByFilterConfiguration({ - filterConfiguration: { [filter.queryKey]: activeValues.size > 0 ? [...activeValues] : undefined }, + actions.search({ + query: { [filter.queryKey]: activeValues.size > 0 ? [...activeValues] : undefined }, }) ); } diff --git a/libs/asset-viewer/src/lib/components/asset-search-refine/asset-search-refine.component.scss b/libs/asset-viewer/src/lib/components/asset-search-refine/asset-search-refine.component.scss index ca4bb81a..3e94f472 100644 --- a/libs/asset-viewer/src/lib/components/asset-search-refine/asset-search-refine.component.scss +++ b/libs/asset-viewer/src/lib/components/asset-search-refine/asset-search-refine.component.scss @@ -8,6 +8,7 @@ padding: 0 1rem 1rem 0; display: flex; flex-direction: column; + z-index: 1; } @include drawerPanel.draw-panel-header; diff --git a/libs/asset-viewer/src/lib/components/asset-search-refine/asset-search-refine.component.ts b/libs/asset-viewer/src/lib/components/asset-search-refine/asset-search-refine.component.ts index 872938f6..73672c34 100644 --- a/libs/asset-viewer/src/lib/components/asset-search-refine/asset-search-refine.component.ts +++ b/libs/asset-viewer/src/lib/components/asset-search-refine/asset-search-refine.component.ts @@ -101,7 +101,7 @@ export class AssetSearchRefineComponent implements OnInit, OnDestroy, AfterViewI public updateSearch(filterConfiguration: Partial) { if (this.isFiltersOpen) { - this.store.dispatch(actions.searchByFilterConfiguration({ filterConfiguration })); + this.store.dispatch(actions.search({ query: filterConfiguration })); } } diff --git a/libs/asset-viewer/src/lib/components/asset-search-results/asset-search-results.component.html b/libs/asset-viewer/src/lib/components/asset-search-results/asset-search-results.component.html index b8a5f83e..48a41684 100644 --- a/libs/asset-viewer/src/lib/components/asset-search-results/asset-search-results.component.html +++ b/libs/asset-viewer/src/lib/components/asset-search-results/asset-search-results.component.html @@ -2,7 +2,7 @@
{{ "search.searchResults" | translate }}: - +