Skip to content

Commit

Permalink
feat: add search component
Browse files Browse the repository at this point in the history
  • Loading branch information
Angular2Guy committed Nov 11, 2023
1 parent 3c72fb5 commit ad6a1a4
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 2 deletions.
4 changes: 4 additions & 0 deletions frontend/src/angular/src/app/app.routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ export const routes: Routes = [
{
path: "doclist",
loadChildren: () => import("./doc-list").then((mod) => mod.DOCLIST),
},
{
path: "docsearch",
loadChildren: () => import("./doc-search").then((mod) => mod.DOCSEARCH),
},
{ path: "**", redirectTo: "doclist" },
];
5 changes: 5 additions & 0 deletions frontend/src/angular/src/app/doc-list/doc-list.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
<div class="toolbar-content">
<div i18n="@@doclistHeading">Document List</div>
<div class="example-fill-remaining-space"></div>
<div>
<button mat-flat-button color="primary" (click)="search()" i18n="@@search">
Search
</button>
</div>
<div>
<button mat-flat-button color="primary" (click)="import()" i18n="@@import">
Import
Expand Down
7 changes: 6 additions & 1 deletion frontend/src/angular/src/app/doc-list/doc-list.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { DocImportComponent } from '../doc-import/doc-import.component';
import { DocImportData } from '../doc-import/doc-import.component';
import { DocumentService } from '../service/document.service';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { Router } from '@angular/router';

@Component({
selector: 'app-doclist',
Expand All @@ -34,7 +35,7 @@ export class DocListComponent implements OnInit {
protected documents: DocumentFile[] = [];
private destroyRef = inject(DestroyRef);

constructor(private dialog: MatDialog, private documentService: DocumentService) { }
constructor(private dialog: MatDialog, private documentService: DocumentService, private router: Router) { }

public ngOnInit(): void {
this.updateDocuments();
Expand All @@ -44,6 +45,10 @@ export class DocListComponent implements OnInit {
this.documentService.getDocumentList().pipe(takeUntilDestroyed(this.destroyRef)).subscribe(result => this.documents = result);
}

protected search(): void {
this.router.navigate(['/docsearch']);
}

protected import(): void {
const dialogRef = this.dialog.open(DocImportComponent, {data: {} as DocImportData});
dialogRef.afterClosed().subscribe(result => this.updateDocuments());
Expand Down
1 change: 0 additions & 1 deletion frontend/src/angular/src/app/doc-list/doc-list.routes.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/**
* Copyright 2023 Sven Loesekann
Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
22 changes: 22 additions & 0 deletions frontend/src/angular/src/app/doc-search/doc-search.routes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/**
* Copyright 2023 Sven Loesekann
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
import { Routes } from "@angular/router";
import { DocSearchComponent } from "./doc-search.component";

export const DOCSEARCH: Routes = [
{
path: "",
component: DocSearchComponent,
},
{ path: "**", redirectTo: "" },
];
13 changes: 13 additions & 0 deletions frontend/src/angular/src/app/doc-search/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/**
* Copyright 2018 Sven Loesekann
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
export * from "./doc-search.routes";

0 comments on commit ad6a1a4

Please sign in to comment.