mirror of
				https://github.com/paperless-ngx/paperless-ngx.git
				synced 2025-10-30 03:56:23 -05:00 
			
		
		
		
	implements #807
This commit is contained in:
		| @@ -11,6 +11,7 @@ import { SettingsComponent } from './components/manage/settings/settings.compone | ||||
| import { TagListComponent } from './components/manage/tag-list/tag-list.component'; | ||||
| import { NotFoundComponent } from './components/not-found/not-found.component'; | ||||
| import { SearchComponent } from './components/search/search.component'; | ||||
| import {DocumentASNComponentComponent} from "./components/document-asncomponent/document-asncomponent.component"; | ||||
|  | ||||
| const routes: Routes = [ | ||||
|   {path: '', redirectTo: 'dashboard', pathMatch: 'full'}, | ||||
| @@ -20,13 +21,14 @@ const routes: Routes = [ | ||||
|     {path: 'view/:id', component: DocumentListComponent }, | ||||
|     {path: 'search', component: SearchComponent }, | ||||
|     {path: 'documents/:id', component: DocumentDetailComponent }, | ||||
|    | ||||
|       {path: 'asn/:id', component: DocumentASNComponentComponent }, | ||||
|  | ||||
|     {path: 'tags', component: TagListComponent }, | ||||
|     {path: 'documenttypes', component: DocumentTypeListComponent }, | ||||
|     {path: 'correspondents', component: CorrespondentListComponent }, | ||||
|     {path: 'logs', component: LogsComponent }, | ||||
|     {path: 'settings', component: SettingsComponent }, | ||||
|   ]},  | ||||
|   ]}, | ||||
|  | ||||
|   {path: '404', component: NotFoundComponent}, | ||||
|   {path: '**', redirectTo: '/404', pathMatch: 'full'} | ||||
|   | ||||
| @@ -75,6 +75,7 @@ import localeEnGb from '@angular/common/locales/en-GB'; | ||||
| import localeRo from '@angular/common/locales/ro'; | ||||
| import localeRu from '@angular/common/locales/ru'; | ||||
| import localeEs from '@angular/common/locales/es'; | ||||
| import { DocumentASNComponentComponent } from './components/document-asncomponent/document-asncomponent.component'; | ||||
|  | ||||
|  | ||||
| registerLocaleData(localeFr) | ||||
| @@ -138,7 +139,8 @@ registerLocaleData(localeEs) | ||||
|     SafePipe, | ||||
|     CustomDatePipe, | ||||
|     DateComponent, | ||||
|     ColorComponent | ||||
|     ColorComponent, | ||||
|     DocumentASNComponentComponent | ||||
|   ], | ||||
|   imports: [ | ||||
|     BrowserModule, | ||||
|   | ||||
| @@ -0,0 +1 @@ | ||||
| <p>Searching document with asn {{asn}}</p> | ||||
| @@ -0,0 +1,25 @@ | ||||
| import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||||
|  | ||||
| import { DocumentASNComponentComponent } from './document-asncomponent.component'; | ||||
|  | ||||
| describe('DocumentASNComponentComponent', () => { | ||||
|   let component: DocumentASNComponentComponent; | ||||
|   let fixture: ComponentFixture<DocumentASNComponentComponent>; | ||||
|  | ||||
|   beforeEach(async () => { | ||||
|     await TestBed.configureTestingModule({ | ||||
|       declarations: [ DocumentASNComponentComponent ] | ||||
|     }) | ||||
|     .compileComponents(); | ||||
|   }); | ||||
|  | ||||
|   beforeEach(() => { | ||||
|     fixture = TestBed.createComponent(DocumentASNComponentComponent); | ||||
|     component = fixture.componentInstance; | ||||
|     fixture.detectChanges(); | ||||
|   }); | ||||
|  | ||||
|   it('should create', () => { | ||||
|     expect(component).toBeTruthy(); | ||||
|   }); | ||||
| }); | ||||
| @@ -0,0 +1,38 @@ | ||||
| import { Component, OnInit } from '@angular/core'; | ||||
| import {DocumentService} from "../../services/rest/document.service"; | ||||
| import {ActivatedRoute, Router} from "@angular/router"; | ||||
| import {CorrespondentService} from "../../services/rest/correspondent.service"; | ||||
| import {DocumentTypeService} from "../../services/rest/document-type.service"; | ||||
| import {FILTER_ASN} from "../../data/filter-rule-type"; | ||||
|  | ||||
| @Component({ | ||||
|   selector: 'app-document-asncomponent', | ||||
|   templateUrl: './document-asncomponent.component.html', | ||||
|   styleUrls: ['./document-asncomponent.component.scss'] | ||||
| }) | ||||
| export class DocumentASNComponentComponent implements OnInit { | ||||
|  | ||||
|   asn: string; | ||||
|   constructor( | ||||
|     private documentsService: DocumentService, | ||||
|     private route: ActivatedRoute, | ||||
|     private correspondentService: CorrespondentService, | ||||
|     private documentTypeService: DocumentTypeService, | ||||
|     private router: Router) { } | ||||
|  | ||||
|  | ||||
|   ngOnInit(): void { | ||||
|  | ||||
|     this.route.paramMap.subscribe(paramMap => { | ||||
|       this.asn = paramMap.get('id'); | ||||
|       this.documentsService.listAllFilteredIds([{rule_type: FILTER_ASN, value: this.asn}]).subscribe(documentId => { | ||||
|         if (documentId.length == 1) { | ||||
|           this.router.navigate(['documents', documentId[0]]) | ||||
|         } else { | ||||
|           this.router.navigate(['404']) | ||||
|         } | ||||
|       }) | ||||
|     }) | ||||
|  | ||||
|   } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user
	 Tobi
					Tobi