From c0ee7d490b5ed94c68c0c4e909e0de1757f79fc3 Mon Sep 17 00:00:00 2001
From: Paul Nhlapo <62051532+paul-nhlapo@users.noreply.github.com>
Date: Sun, 11 Aug 2024 17:38:40 +0200
Subject: [PATCH 1/7] test
---
.../upload-document.component.spec.ts | 114 ++++++++++++++++++
1 file changed, 114 insertions(+)
diff --git a/gnd-app/src/app/upload-document/upload-document.component.spec.ts b/gnd-app/src/app/upload-document/upload-document.component.spec.ts
index 8b305675..df5e709b 100644
--- a/gnd-app/src/app/upload-document/upload-document.component.spec.ts
+++ b/gnd-app/src/app/upload-document/upload-document.component.spec.ts
@@ -139,3 +139,117 @@
// expect(resultContent.innerHTML).toContain('line1
line2');
// });
// });
+import { ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testing';
+import { UploadDocumentComponent } from './upload-document.component';
+import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
+import { DebugElement } from '@angular/core';
+import { By } from '@angular/platform-browser';
+import { NO_ERRORS_SCHEMA } from '@angular/core';
+import { RouterTestingModule } from '@angular/router/testing';
+import { ActivatedRoute } from '@angular/router';
+import { of } from 'rxjs';
+
+describe('UploadDocumentComponent', () => {
+ let component: UploadDocumentComponent;
+ let fixture: ComponentFixture;
+ let httpMock: HttpTestingController;
+ let debugElement: DebugElement;
+
+ beforeEach(async () => {
+ await TestBed.configureTestingModule({
+ imports: [RouterTestingModule, HttpClientTestingModule, UploadDocumentComponent],
+ providers: [
+ {
+ provide: ActivatedRoute,
+ useValue: {
+ paramMap: of({
+ get: (key: string) => {
+ switch (key) {
+ case 'fileType': return 'someFileType';
+ default: return null;
+ }
+ }
+ })
+ }
+ }
+ ],
+ schemas: [NO_ERRORS_SCHEMA]
+ })
+ .compileComponents();
+
+ fixture = TestBed.createComponent(UploadDocumentComponent);
+ component = fixture.componentInstance;
+ fixture.detectChanges();
+ debugElement = fixture.debugElement;
+ httpMock = TestBed.inject(HttpTestingController);
+ });
+
+ it('should create', () => {
+ expect(component).toBeTruthy();
+ });
+
+ afterEach(() => {
+ httpMock.verify();
+ });
+
+ it('should call onFileSelected and upload file', fakeAsync(() => {
+ const file = new File(['file content'], 'test.txt', { type: 'text/plain' });
+ const input = fixture.debugElement.query(By.css('input[type="file"]')).nativeElement;
+
+ spyOn(component, 'onFileSelected').and.callThrough();
+
+ input.dispatchEvent(new Event('change'));
+ input.files = [file];
+
+ fixture.detectChanges();
+ tick();
+
+ expect(component.onFileSelected).toHaveBeenCalled();
+ expect(component.fileName).toBe('test.txt');
+
+ const req = httpMock.expectOne('http://127.0.0.1:8000/file-upload-new');
+ expect(req.request.method).toBe('POST');
+ req.flush({
+ fileName: 'test.txt',
+ result: 'file processed',
+ documentStatus: 'Compliant',
+ nerCount: 5,
+ location: 'New York',
+ personalData: 'Present',
+ financialData: 'Present',
+ contactData: 'Present',
+ medicalData: 'Absent',
+ ethnicData: 'Absent',
+ biometricData: 'Absent',
+ consentAgreement: 'Consent obtained'
+ });
+
+ fixture.detectChanges();
+ tick();
+
+ expect(component.result).toBe('file processed');
+ expect(component.documentStatus).toBe('Compliant');
+ }));
+
+ it('should display the analysis result in the analysis window', () => {
+ const file = new File(['file content'], 'test.txt', { type: 'text/plain' });
+ const input = debugElement.query(By.css('input[type="file"]')).nativeElement;
+
+ const dataTransfer = new DataTransfer();
+ dataTransfer.items.add(file);
+
+ input.files = dataTransfer.files;
+ input.dispatchEvent(new Event('change', { bubbles: true, cancelable: true }));
+
+ const req = httpMock.expectOne('http://127.0.0.1:8000/file-upload-new');
+ req.flush({ fileName: 'test.txt', result: 'line1\nline2' });
+
+ fixture.detectChanges();
+
+ const analysisHeader = debugElement.query(By.css('.analysis-box-header')).nativeElement;
+ const resultContent = debugElement.query(By.css('.result-content')).nativeElement;
+
+ expect(analysisHeader.textContent).toContain('Analysis Result:');
+ expect(resultContent.innerHTML).toContain('line1
line2');
+ });
+});
From 08d007962229ff61861efe3b21aaa617481f94ae Mon Sep 17 00:00:00 2001
From: Paul Nhlapo <62051532+paul-nhlapo@users.noreply.github.com>
Date: Sun, 11 Aug 2024 18:00:34 +0200
Subject: [PATCH 2/7] Updated the walkthrough
---
gnd-app/src/app/home/home.component.ts | 8 +
.../upload-document.component.spec.ts | 228 +++++++++---------
2 files changed, 122 insertions(+), 114 deletions(-)
diff --git a/gnd-app/src/app/home/home.component.ts b/gnd-app/src/app/home/home.component.ts
index 2b25c76b..4f15e40e 100644
--- a/gnd-app/src/app/home/home.component.ts
+++ b/gnd-app/src/app/home/home.component.ts
@@ -50,6 +50,14 @@ export class HomeComponent implements OnInit, OnDestroy {
element: '#home',
intro: 'This button will always navigate you back to the home page'
},
+ {
+ element:'#upload-document',
+ intro:'This button will navigate you to the upload document page. Where you can upload a document.'
+ },
+ {
+ element: '#inbox',
+ into: 'This button will navigate you to the inbox page. Where you can see all the attachments in the received inbox.'
+ },
{
element: '#help',
intro: 'This button will navigate you to the help page. Where you will see how to use the app.'
diff --git a/gnd-app/src/app/upload-document/upload-document.component.spec.ts b/gnd-app/src/app/upload-document/upload-document.component.spec.ts
index df5e709b..0c70952a 100644
--- a/gnd-app/src/app/upload-document/upload-document.component.spec.ts
+++ b/gnd-app/src/app/upload-document/upload-document.component.spec.ts
@@ -139,117 +139,117 @@
// expect(resultContent.innerHTML).toContain('line1
line2');
// });
// });
-import { ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testing';
-import { UploadDocumentComponent } from './upload-document.component';
-import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
-import { DebugElement } from '@angular/core';
-import { By } from '@angular/platform-browser';
-import { NO_ERRORS_SCHEMA } from '@angular/core';
-import { RouterTestingModule } from '@angular/router/testing';
-import { ActivatedRoute } from '@angular/router';
-import { of } from 'rxjs';
-
-describe('UploadDocumentComponent', () => {
- let component: UploadDocumentComponent;
- let fixture: ComponentFixture;
- let httpMock: HttpTestingController;
- let debugElement: DebugElement;
-
- beforeEach(async () => {
- await TestBed.configureTestingModule({
- imports: [RouterTestingModule, HttpClientTestingModule, UploadDocumentComponent],
- providers: [
- {
- provide: ActivatedRoute,
- useValue: {
- paramMap: of({
- get: (key: string) => {
- switch (key) {
- case 'fileType': return 'someFileType';
- default: return null;
- }
- }
- })
- }
- }
- ],
- schemas: [NO_ERRORS_SCHEMA]
- })
- .compileComponents();
-
- fixture = TestBed.createComponent(UploadDocumentComponent);
- component = fixture.componentInstance;
- fixture.detectChanges();
- debugElement = fixture.debugElement;
- httpMock = TestBed.inject(HttpTestingController);
- });
-
- it('should create', () => {
- expect(component).toBeTruthy();
- });
-
- afterEach(() => {
- httpMock.verify();
- });
-
- it('should call onFileSelected and upload file', fakeAsync(() => {
- const file = new File(['file content'], 'test.txt', { type: 'text/plain' });
- const input = fixture.debugElement.query(By.css('input[type="file"]')).nativeElement;
-
- spyOn(component, 'onFileSelected').and.callThrough();
-
- input.dispatchEvent(new Event('change'));
- input.files = [file];
-
- fixture.detectChanges();
- tick();
-
- expect(component.onFileSelected).toHaveBeenCalled();
- expect(component.fileName).toBe('test.txt');
-
- const req = httpMock.expectOne('http://127.0.0.1:8000/file-upload-new');
- expect(req.request.method).toBe('POST');
- req.flush({
- fileName: 'test.txt',
- result: 'file processed',
- documentStatus: 'Compliant',
- nerCount: 5,
- location: 'New York',
- personalData: 'Present',
- financialData: 'Present',
- contactData: 'Present',
- medicalData: 'Absent',
- ethnicData: 'Absent',
- biometricData: 'Absent',
- consentAgreement: 'Consent obtained'
- });
-
- fixture.detectChanges();
- tick();
-
- expect(component.result).toBe('file processed');
- expect(component.documentStatus).toBe('Compliant');
- }));
-
- it('should display the analysis result in the analysis window', () => {
- const file = new File(['file content'], 'test.txt', { type: 'text/plain' });
- const input = debugElement.query(By.css('input[type="file"]')).nativeElement;
-
- const dataTransfer = new DataTransfer();
- dataTransfer.items.add(file);
-
- input.files = dataTransfer.files;
- input.dispatchEvent(new Event('change', { bubbles: true, cancelable: true }));
-
- const req = httpMock.expectOne('http://127.0.0.1:8000/file-upload-new');
- req.flush({ fileName: 'test.txt', result: 'line1\nline2' });
-
- fixture.detectChanges();
-
- const analysisHeader = debugElement.query(By.css('.analysis-box-header')).nativeElement;
- const resultContent = debugElement.query(By.css('.result-content')).nativeElement;
-
- expect(analysisHeader.textContent).toContain('Analysis Result:');
- expect(resultContent.innerHTML).toContain('line1
line2');
- });
-});
+// import { ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testing';
+// import { UploadDocumentComponent } from './upload-document.component';
+// import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
+// import { DebugElement } from '@angular/core';
+// import { By } from '@angular/platform-browser';
+// import { NO_ERRORS_SCHEMA } from '@angular/core';
+// import { RouterTestingModule } from '@angular/router/testing';
+// import { ActivatedRoute } from '@angular/router';
+// import { of } from 'rxjs';
+
+// describe('UploadDocumentComponent', () => {
+// let component: UploadDocumentComponent;
+// let fixture: ComponentFixture;
+// let httpMock: HttpTestingController;
+// let debugElement: DebugElement;
+
+// beforeEach(async () => {
+// await TestBed.configureTestingModule({
+// imports: [RouterTestingModule, HttpClientTestingModule, UploadDocumentComponent],
+// providers: [
+// {
+// provide: ActivatedRoute,
+// useValue: {
+// paramMap: of({
+// get: (key: string) => {
+// switch (key) {
+// case 'fileType': return 'someFileType';
+// default: return null;
+// }
+// }
+// })
+// }
+// }
+// ],
+// schemas: [NO_ERRORS_SCHEMA]
+// })
+// .compileComponents();
+
+// fixture = TestBed.createComponent(UploadDocumentComponent);
+// component = fixture.componentInstance;
+// fixture.detectChanges();
+// debugElement = fixture.debugElement;
+// httpMock = TestBed.inject(HttpTestingController);
+// });
+
+// it('should create', () => {
+// expect(component).toBeTruthy();
+// });
+
+// afterEach(() => {
+// httpMock.verify();
+// });
+
+// it('should call onFileSelected and upload file', fakeAsync(() => {
+// const file = new File(['file content'], 'test.txt', { type: 'text/plain' });
+// const input = fixture.debugElement.query(By.css('input[type="file"]')).nativeElement;
+
+// spyOn(component, 'onFileSelected').and.callThrough();
+
+// input.dispatchEvent(new Event('change'));
+// input.files = [file];
+
+// fixture.detectChanges();
+// tick();
+
+// expect(component.onFileSelected).toHaveBeenCalled();
+// expect(component.fileName).toBe('test.txt');
+
+// const req = httpMock.expectOne('http://127.0.0.1:8000/file-upload-new');
+// expect(req.request.method).toBe('POST');
+// req.flush({
+// fileName: 'test.txt',
+// result: 'file processed',
+// documentStatus: 'Compliant',
+// nerCount: 5,
+// location: 'New York',
+// personalData: 'Present',
+// financialData: 'Present',
+// contactData: 'Present',
+// medicalData: 'Absent',
+// ethnicData: 'Absent',
+// biometricData: 'Absent',
+// consentAgreement: 'Consent obtained'
+// });
+
+// fixture.detectChanges();
+// tick();
+
+// expect(component.result).toBe('file processed');
+// expect(component.documentStatus).toBe('Compliant');
+// }));
+
+// it('should display the analysis result in the analysis window', () => {
+// const file = new File(['file content'], 'test.txt', { type: 'text/plain' });
+// const input = debugElement.query(By.css('input[type="file"]')).nativeElement;
+
+// const dataTransfer = new DataTransfer();
+// dataTransfer.items.add(file);
+
+// input.files = dataTransfer.files;
+// input.dispatchEvent(new Event('change', { bubbles: true, cancelable: true }));
+
+// const req = httpMock.expectOne('http://127.0.0.1:8000/file-upload-new');
+// req.flush({ fileName: 'test.txt', result: 'line1\nline2' });
+
+// fixture.detectChanges();
+
+// const analysisHeader = debugElement.query(By.css('.analysis-box-header')).nativeElement;
+// const resultContent = debugElement.query(By.css('.result-content')).nativeElement;
+
+// expect(analysisHeader.textContent).toContain('Analysis Result:');
+// expect(resultContent.innerHTML).toContain('line1
line2');
+// });
+// });
From 8ab2df54e5eb77145f276ec42105fc84b946cb81 Mon Sep 17 00:00:00 2001
From: Paul Nhlapo <62051532+paul-nhlapo@users.noreply.github.com>
Date: Sun, 11 Aug 2024 18:02:43 +0200
Subject: [PATCH 3/7] updating the walkthrough
---
gnd-app/src/app/home/home.component.ts | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/gnd-app/src/app/home/home.component.ts b/gnd-app/src/app/home/home.component.ts
index 4f15e40e..5e1fee7d 100644
--- a/gnd-app/src/app/home/home.component.ts
+++ b/gnd-app/src/app/home/home.component.ts
@@ -56,7 +56,7 @@ export class HomeComponent implements OnInit, OnDestroy {
},
{
element: '#inbox',
- into: 'This button will navigate you to the inbox page. Where you can see all the attachments in the received inbox.'
+ intro: 'This button will navigate you to the inbox page. Where you can see all the attachments in the received inbox.'
},
{
element: '#help',
From 610f7c8f8c11026b3b6f436050d42bc5d72ef5fc Mon Sep 17 00:00:00 2001
From: Yudi-G <133056840+Yudi-G@users.noreply.github.com>
Date: Sun, 11 Aug 2024 18:06:48 +0200
Subject: [PATCH 4/7] biometric
---
.../Detection_Engine/biometric_detection.py | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/backend/Detection_Engine/biometric_detection.py b/backend/Detection_Engine/biometric_detection.py
index e2cd9771..1ed6c71d 100644
--- a/backend/Detection_Engine/biometric_detection.py
+++ b/backend/Detection_Engine/biometric_detection.py
@@ -59,44 +59,50 @@ def biometric_detect_all(self,pdf_path):
if (pdf_path.endswith('.pdf')):
# extract_images_from_pdf(pdf_path)
- images = [f'./Detection_Engine/extracted_images/pdf_images/{i}' for i in os.listdir('./Detection_Engine/extracted_images/pdf_images') if i.endswith('.png')]
+ images = [f'./Detection_Engine/extracted_images/pdf_images/{i}' for i in os.listdir('./Detection_Engine/extracted_images/pdf_images') if i.endswith('.png') or i.endswith('.jpg')]
output = []
+ count = 0
for image in images:
+ count += 1
output.append(self.biometric_detect_people(image))
png_files = glob.glob(os.path.join("./Detection_Engine/extracted_images/pdf_images", '*.png'))
for file in png_files:
os.remove(file)
- return output
+ return count
elif (pdf_path.endswith('.docx')):
# extract_images_from_docx(pdf_path)
- images = [f'./Detection_Engine/extracted_images/docx_images/{i}' for i in os.listdir('./Detection_Engine/extracted_images/docx_images') if i.endswith('.png')]
+ images = [f'./Detection_Engine/extracted_images/docx_images/{i}' for i in os.listdir('./Detection_Engine/extracted_images/docx_images') if i.endswith('.png') or i.endswith('.jpg')]
output = []
+ count = 0
for image in images:
+ count += 1
output.append(self.biometric_detect_people(image))
png_files = glob.glob(os.path.join("./Detection_Engine/extracted_images/docx_images", '*.png'))
for file in png_files:
os.remove(file)
- return output
+ return count
elif (pdf_path.endswith('.xlsx')):
# extract_images_from_excel(pdf_path)
- images = [f'./Detection_Engine/extracted_images/xlsx_images/{i}' for i in os.listdir('./Detection_Engine/extracted_images/xlsx_images') if i.endswith('.png')]
+ images = [f'./Detection_Engine/extracted_images/xlsx_images/{i}' for i in os.listdir('./Detection_Engine/extracted_images/xlsx_images') if i.endswith('.png') or i.endswith('.jpg')]
# images = [f'extracted_images/xlsx_images/{i}' for i in os.listdir('extracted_images/xlsx_images')]
output = []
+ count = 0
for image in images:
+ count += 1
output.append(self.biometric_detect_people(image))
png_files = glob.glob(os.path.join("./Detection_Engine/extracted_images/xlsx_images", '*.png'))
for file in png_files:
os.remove(file)
- return output
+ return count
directories = [
"./Detection_Engine/extracted_images/xlsx_images",
From 635c43568e03d73db24db58311d025875eb6b2cf Mon Sep 17 00:00:00 2001
From: Paul Nhlapo <62051532+paul-nhlapo@users.noreply.github.com>
Date: Sun, 11 Aug 2024 18:13:45 +0200
Subject: [PATCH 5/7] Testing
---
.../upload-document.component.html | 12 +-
.../upload-document.component.spec.ts | 228 +++++++++---------
2 files changed, 116 insertions(+), 124 deletions(-)
diff --git a/gnd-app/src/app/upload-document/upload-document.component.html b/gnd-app/src/app/upload-document/upload-document.component.html
index 6164e07b..852da539 100644
--- a/gnd-app/src/app/upload-document/upload-document.component.html
+++ b/gnd-app/src/app/upload-document/upload-document.component.html
@@ -71,13 +71,8 @@