Skip to content

Commit 02adaba

Browse files
Merge pull request #16 from regulaforensics/feature/sp-11707
SP-11707 - Add controller sample
2 parents 13ec167 + 3f14bbc commit 02adaba

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+1097
-9
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
1. [SDK sample](#sdk-sample)
88
1. [API sample](#api-sample)
99
1. [Nuxt sample](#nuxt-sample)
10+
1. [Controller sample](#controller-sample)
1011
1. [CodePen samples](#codepen-samples)
1112

1213
---
@@ -91,6 +92,10 @@ The ```nuxt``` folder contains an example of using Document reader component wit
9192

9293
Follow the steps as in [Webpack sample](#webpack-sample).
9394

95+
## Controller sample
96+
97+
The ```controller``` folder contains an example of using the SDK to work with Regula Document Reader Web Service.
98+
9499
## CodePen samples
95100

96101
### Camera snapshot component
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
{
2+
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
3+
"version": 1,
4+
"newProjectRoot": "projects",
5+
"projects": {
6+
"document-reader": {
7+
"projectType": "application",
8+
"schematics": {},
9+
"root": "",
10+
"sourceRoot": "src",
11+
"prefix": "app",
12+
"architect": {
13+
"build": {
14+
"builder": "@angular-devkit/build-angular:browser",
15+
"options": {
16+
"outputPath": "build",
17+
"index": "src/index.html",
18+
"main": "src/main.ts",
19+
"polyfills": [
20+
"zone.js"
21+
],
22+
"tsConfig": "tsconfig.app.json",
23+
"scripts": []
24+
},
25+
"configurations": {
26+
"production": {
27+
"budgets": [
28+
{
29+
"type": "initial",
30+
"maximumWarning": "500kb",
31+
"maximumError": "1mb"
32+
},
33+
{
34+
"type": "anyComponentStyle",
35+
"maximumWarning": "2kb",
36+
"maximumError": "4kb"
37+
}
38+
],
39+
"outputHashing": "all"
40+
},
41+
"development": {
42+
"buildOptimizer": false,
43+
"optimization": false,
44+
"vendorChunk": true,
45+
"extractLicenses": false,
46+
"sourceMap": true,
47+
"namedChunks": true
48+
}
49+
},
50+
"defaultConfiguration": "production"
51+
},
52+
"serve": {
53+
"builder": "@angular-devkit/build-angular:dev-server",
54+
"configurations": {
55+
"production": {
56+
"browserTarget": "document-reader:build:production"
57+
},
58+
"development": {
59+
"browserTarget": "document-reader:build:development"
60+
}
61+
},
62+
"defaultConfiguration": "development"
63+
},
64+
"extract-i18n": {
65+
"builder": "@angular-devkit/build-angular:extract-i18n",
66+
"options": {
67+
"browserTarget": "document-reader:build"
68+
}
69+
}
70+
}
71+
}
72+
},
73+
"cli": {
74+
"analytics": false
75+
}
76+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{
2+
"name": "document-reader",
3+
"version": "0.0.0",
4+
"scripts": {
5+
"ng": "ng",
6+
"serve": "ng serve",
7+
"build": "ng build",
8+
"watch": "ng build --watch --configuration development",
9+
"test": "ng test"
10+
},
11+
"private": true,
12+
"dependencies": {
13+
"@angular/animations": "^15.1.0",
14+
"@angular/common": "^15.1.0",
15+
"@angular/compiler": "^15.1.0",
16+
"@angular/core": "^15.1.0",
17+
"@angular/forms": "^15.1.0",
18+
"@angular/platform-browser": "^15.1.0",
19+
"@angular/platform-browser-dynamic": "^15.1.0",
20+
"@angular/router": "^15.1.0",
21+
"@regulaforensics/vp-frontend-document-components-beta": "*",
22+
"rxjs": "~7.8.0",
23+
"tslib": "^2.3.0",
24+
"zone.js": "~0.12.0"
25+
},
26+
"devDependencies": {
27+
"@angular-devkit/build-angular": "^15.1.4",
28+
"@angular/cli": "~15.1.4",
29+
"@angular/compiler-cli": "^15.1.0",
30+
"@types/jasmine": "~4.3.0",
31+
"jasmine-core": "~4.5.0",
32+
"karma": "~6.4.0",
33+
"karma-chrome-launcher": "~3.1.0",
34+
"karma-coverage": "~2.2.0",
35+
"karma-jasmine": "~5.1.0",
36+
"karma-jasmine-html-reporter": "~2.0.0",
37+
"typescript": "~4.9.4"
38+
}
39+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
.container {
2+
display: flex;
3+
position: absolute;
4+
height: 100%;
5+
width: 100%;
6+
top: 0;
7+
left: 0;
8+
justify-content: center;
9+
align-items: center;
10+
}
11+
12+
button {
13+
padding: 10px 30px;
14+
color: white;
15+
font-size: 16px;
16+
border-radius: 2px;
17+
background-color: #bd7dff;
18+
border: 1px solid #bd7dff;
19+
cursor: pointer;
20+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<div class="container" (document-reader-device)="documentReaderHandler($event)">
2+
<app-reader *ngIf="isOpen; else openButton"></app-reader>
3+
<ng-template #openButton>
4+
<button (click)="isOpen = true">Open component</button>
5+
</ng-template>
6+
</div>
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { Component, OnInit } from '@angular/core';
2+
import {
3+
defineComponents,
4+
DocumentReaderDetailType,
5+
} from '@regulaforensics/vp-frontend-document-components-beta';
6+
7+
@Component({
8+
selector: 'app-root',
9+
templateUrl: './app.component.html',
10+
styleUrls: ['./app.component.css']
11+
})
12+
export class AppComponent implements OnInit {
13+
isOpen: boolean = false;
14+
15+
ngOnInit() {
16+
defineComponents();
17+
}
18+
19+
documentReaderHandler(data: CustomEvent<DocumentReaderDetailType>) {
20+
if (data.detail.action === 'PROCESS_FINISHED') {
21+
const status = data.detail.data?.status;
22+
const isFinishStatus = status === 1;
23+
24+
if (!isFinishStatus || !data.detail.data?.response) return;
25+
console.log(data.detail.data.response);
26+
}
27+
28+
if (data.detail?.action === 'CLOSE') {
29+
this.isOpen = false;
30+
}
31+
}
32+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { CUSTOM_ELEMENTS_SCHEMA, NgModule } from '@angular/core';
2+
import { BrowserModule } from '@angular/platform-browser';
3+
import { AppComponent } from './app.component';
4+
import { ReaderComponent } from './components/reader.component';
5+
6+
@NgModule({
7+
declarations: [
8+
AppComponent,
9+
ReaderComponent,
10+
],
11+
imports: [
12+
BrowserModule
13+
],
14+
providers: [],
15+
bootstrap: [AppComponent],
16+
schemas: [CUSTOM_ELEMENTS_SCHEMA]
17+
})
18+
export class AppModule {
19+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
:host {
2+
display: flex;
3+
height: 100%;
4+
width: 100%;
5+
justify-content: center;
6+
align-items: center;
7+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<document-reader-device #reader></document-reader-device>
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { Component, AfterViewInit, ViewChild, ElementRef } from '@angular/core';
2+
import { DocumentReaderDeviceWebComponent } from '@regulaforensics/vp-frontend-document-components-beta';
3+
4+
@Component({
5+
selector: 'app-reader',
6+
templateUrl: './reader.component.html',
7+
styleUrls: ['./reader.component.css'],
8+
})
9+
export class ReaderComponent implements AfterViewInit {
10+
@ViewChild('reader', { static: false }) reader?: ElementRef<DocumentReaderDeviceWebComponent>;
11+
12+
ngAfterViewInit() {
13+
if (!this.reader) return;
14+
15+
this.reader.nativeElement.settings = {
16+
serviceUrl: 'http://172.20.40.178:4003'
17+
};
18+
}
19+
}

0 commit comments

Comments
 (0)