diff --git a/apps/picsa-tools/resources-tool/src/app/app-routing.module.ts b/apps/picsa-tools/resources-tool/src/app/app-routing.module.ts index eb1b2cec5..67d43c2f7 100644 --- a/apps/picsa-tools/resources-tool/src/app/app-routing.module.ts +++ b/apps/picsa-tools/resources-tool/src/app/app-routing.module.ts @@ -1,6 +1,8 @@ import { NgModule } from '@angular/core'; import { PreloadAllModules, RouterModule, Routes } from '@angular/router'; +import { ResourceSearchComponent } from './pages/search/search.component'; + export const ROUTES_COMMON: Routes = [ { path: '', @@ -15,6 +17,10 @@ export const ROUTES_COMMON: Routes = [ path: 'downloads', loadChildren: () => import('./pages/downloads/downloads.module').then((m) => m.DownloadsModule), }, + { + path: 'search', + component: ResourceSearchComponent, + }, ]; /** Routes only registered in standalone mode */ const ROUTES_STANDALONE: Routes = [{ path: '**', redirectTo: '' }]; diff --git a/apps/picsa-tools/resources-tool/src/app/components/resource-item/file/file.ts b/apps/picsa-tools/resources-tool/src/app/components/resource-item/file/file.ts index 4d6bc8b94..6654d5875 100644 --- a/apps/picsa-tools/resources-tool/src/app/components/resource-item/file/file.ts +++ b/apps/picsa-tools/resources-tool/src/app/components/resource-item/file/file.ts @@ -1,4 +1,4 @@ -import { Component, EventEmitter, Input, OnDestroy, OnInit, Output, ViewChild } from '@angular/core'; +import { ChangeDetectorRef, Component, EventEmitter, Input, OnDestroy, OnInit, Output } from '@angular/core'; import { _wait } from '@picsa/utils'; import { RxAttachment, RxDocument } from 'rxdb'; @@ -20,7 +20,7 @@ export class ResourceItemFileComponent implements OnInit, OnDestroy { public attachment: RxAttachment | undefined; public fileURI: string; - constructor(private service: ResourcesToolService) {} + constructor(private service: ResourcesToolService, private cdr: ChangeDetectorRef) {} async ngOnInit() { await this.service.ready(); @@ -47,6 +47,7 @@ export class ResourceItemFileComponent implements OnInit, OnDestroy { } } this.attachmentChange.next({ attachment, uri: this.fileURI }); + this.cdr.markForCheck(); } /** Display file in resource link format */ diff --git a/apps/picsa-tools/resources-tool/src/app/components/resource-item/link/link.ts b/apps/picsa-tools/resources-tool/src/app/components/resource-item/link/link.ts index ee30f294c..ca2a8c408 100644 --- a/apps/picsa-tools/resources-tool/src/app/components/resource-item/link/link.ts +++ b/apps/picsa-tools/resources-tool/src/app/components/resource-item/link/link.ts @@ -63,16 +63,19 @@ export class ResourceItemLinkComponent { /** Internal collection urls may have to replace current page id depending on */ private goToCollection(id: string) { + // Route from existing collection if (this.route.snapshot.paramMap.get('collectionId')) { - this.router.navigate([id], { + return this.router.navigate([id], { relativeTo: this.route, }); } - // Route from base to collection - else { - this.router.navigate(['collection', id], { - relativeTo: this.route, - }); + // Route from /search + if (this.route.snapshot.routeConfig?.path?.endsWith('/search')) { + return this.router.navigate(['../', 'collection', id], { relativeTo: this.route }); } + // Route from base to collection + return this.router.navigate(['collection', id], { + relativeTo: this.route, + }); } } diff --git a/apps/picsa-tools/resources-tool/src/app/material.module.ts b/apps/picsa-tools/resources-tool/src/app/material.module.ts index acc311ff9..b88962e4e 100644 --- a/apps/picsa-tools/resources-tool/src/app/material.module.ts +++ b/apps/picsa-tools/resources-tool/src/app/material.module.ts @@ -1,8 +1,9 @@ import { NgModule } from '@angular/core'; import { MatButtonModule } from '@angular/material/button'; import { MatCardModule } from '@angular/material/card'; -import { MAT_FORM_FIELD_DEFAULT_OPTIONS } from '@angular/material/form-field'; +import { MAT_FORM_FIELD_DEFAULT_OPTIONS, MatFormFieldModule } from '@angular/material/form-field'; import { MatIconModule, MatIconRegistry } from '@angular/material/icon'; +import { MatInputModule } from '@angular/material/input'; import { MatMenuModule } from '@angular/material/menu'; import { MatProgressBarModule } from '@angular/material/progress-bar'; import { MatProgressSpinnerModule } from '@angular/material/progress-spinner'; @@ -13,6 +14,8 @@ import { DomSanitizer } from '@angular/platform-browser'; const Modules = [ MatButtonModule, MatCardModule, + MatFormFieldModule, + MatInputModule, MatIconModule, MatMenuModule, MatProgressBarModule, diff --git a/apps/picsa-tools/resources-tool/src/app/pages/collection/collection.component.ts b/apps/picsa-tools/resources-tool/src/app/pages/collection/collection.component.ts index 85ebdbbb9..6abe0a267 100644 --- a/apps/picsa-tools/resources-tool/src/app/pages/collection/collection.component.ts +++ b/apps/picsa-tools/resources-tool/src/app/pages/collection/collection.component.ts @@ -74,7 +74,6 @@ export class CollectionComponent implements OnInit, OnDestroy { const fileDocs = await this.service.dbFiles.findByIds(files).sort('priority').exec(); this.files = this.processDocs(fileDocs); } - private processDocs(docs: Map>) { const entries = [...docs.values()]; return this.service.filterLocalisedResources(entries).map((d) => d._data); diff --git a/apps/picsa-tools/resources-tool/src/app/pages/home/home.component.html b/apps/picsa-tools/resources-tool/src/app/pages/home/home.component.html index f34559f71..e36097fcb 100644 --- a/apps/picsa-tools/resources-tool/src/app/pages/home/home.component.html +++ b/apps/picsa-tools/resources-tool/src/app/pages/home/home.component.html @@ -1,11 +1,12 @@
-

{{ 'Collections' | translate }}

+