diff --git a/package-lock.json b/package-lock.json
index f91a41a..0fd8d31 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -4610,6 +4610,22 @@
}
}
},
+ "jasmine": {
+ "version": "4.0.2",
+ "resolved": "https://registry.npmjs.org/jasmine/-/jasmine-4.0.2.tgz",
+ "integrity": "sha512-YsrgxJQEggxzByYe4j68eQLOiQeSrPDYGv4sHhGBp3c6HHdq+uPXeAQ73kOAQpdLZ3/0zN7x/TZTloqeE1/qIA==",
+ "dev": true,
+ "requires": {
+ "glob": "^7.1.6",
+ "jasmine-core": "^4.0.0"
+ }
+ },
+ "jasmine-core": {
+ "version": "4.0.1",
+ "resolved": "https://registry.npmjs.org/jasmine-core/-/jasmine-core-4.0.1.tgz",
+ "integrity": "sha512-w+JDABxQCkxbGGxg+a2hUVZyqUS2JKngvIyLGu/xiw2ZwgsoSB0iiecLQsQORSeaKQ6iGrCyWG86RfNDuoA7Lg==",
+ "dev": true
+ },
"jest-worker": {
"version": "27.5.1",
"resolved": "https://registry.npmjs.org/jest-worker/-/jest-worker-27.5.1.tgz",
diff --git a/package.json b/package.json
index 041ff88..377a52f 100644
--- a/package.json
+++ b/package.json
@@ -3,6 +3,7 @@
"version": "0.0.0",
"scripts": {
"ng": "ng",
+ "test": "jasmine",
"start": "ng serve",
"build": "ng build",
"watch": "ng build --watch --configuration development"
@@ -26,6 +27,7 @@
"@angular/cli": "~13.2.2",
"@angular/compiler-cli": "~13.2.0",
"@types/node": "^12.11.1",
+ "jasmine": "^4.0.2",
"typescript": "~4.5.2"
}
}
diff --git a/spec/support/jasmine.json b/spec/support/jasmine.json
new file mode 100644
index 0000000..6afe603
--- /dev/null
+++ b/spec/support/jasmine.json
@@ -0,0 +1,13 @@
+{
+ "spec_dir": "spec",
+ "spec_files": [
+ "**/*[sS]pec.?(m)js"
+ ],
+ "helpers": [
+ "helpers/**/*.?(m)js"
+ ],
+ "env": {
+ "stopSpecOnExpectationFailure": false,
+ "random": true
+ }
+}
diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts
new file mode 100644
index 0000000..d703db0
--- /dev/null
+++ b/src/app/app-routing.module.ts
@@ -0,0 +1,17 @@
+import { NgModule } from '@angular/core';
+import { RouterModule, Routes } from '@angular/router';
+import { HomeComponent } from './home.component';
+import { ReportComponent } from './report.component';
+import { ThanksComponent } from './thanks.component';
+
+const routes: Routes = [
+ { path: '', component: HomeComponent },
+ { path: 'thanks', component: ThanksComponent },
+ { path: 'report', component: ReportComponent }
+];
+
+@NgModule({
+ imports: [RouterModule.forRoot(routes)],
+ exports: [RouterModule]
+})
+export class AppRoutingModule { }
diff --git a/src/app/app.component.ts b/src/app/app.component.ts
index 2a5ce6c..51b5ece 100644
--- a/src/app/app.component.ts
+++ b/src/app/app.component.ts
@@ -1,39 +1,13 @@
import { Component } from '@angular/core';
-import { checkin, checkout } from "src/assets/forms";
-
@Component({
selector: 'app-root',
template: `
-
-
-
-
-
-
-
+
`
})
export class AppComponent {
-
- checkin: Form = checkin;
- checkout: Form = checkout;
-
- action: string = "checkout";
ngOnInit() { }
- switch(action: string) {
-
- alert("Are you sure?");
-
- this.action = action;
-
- }
-
}
diff --git a/src/app/app.module.ts b/src/app/app.module.ts
index b79eb98..13af438 100644
--- a/src/app/app.module.ts
+++ b/src/app/app.module.ts
@@ -7,6 +7,12 @@ import { FormComponent } from './form.component';
import { TextComponent } from './text.component';
import { RadioComponent } from './radio.component';
import { StepComponent } from './step.component';
+import { CameraComponent } from './camera.component';
+import { SignComponent } from './sign.component';
+import { ThanksComponent } from './thanks.component';
+import { AppRoutingModule } from './app-routing.module';
+import { HomeComponent } from './home.component';
+import { ReportComponent } from './report.component';
@NgModule({
declarations: [
@@ -15,10 +21,16 @@ import { StepComponent } from './step.component';
TextComponent,
RadioComponent,
StepComponent,
+ CameraComponent,
+ SignComponent,
+ ThanksComponent,
+ HomeComponent,
+ ReportComponent,
],
imports: [
BrowserModule,
FormsModule,
+ AppRoutingModule,
],
providers: [],
bootstrap: [AppComponent]
diff --git a/src/app/camera.component.ts b/src/app/camera.component.ts
new file mode 100644
index 0000000..a05b708
--- /dev/null
+++ b/src/app/camera.component.ts
@@ -0,0 +1,58 @@
+import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
+
+@Component({
+ selector: 'app-camera',
+ template: `
+
+
+
+
+
![]()
+
+
+
+
+ `
+})
+export class CameraComponent implements OnInit {
+
+ @Input() field: Field;
+ @Output() update: EventEmitter = new EventEmitter();
+
+ video: HTMLVideoElement;
+
+ ngOnInit() { console.log("Camera", this.field.id); }
+
+ ngAfterViewInit() {
+
+ this.video = document.getElementById("video") as HTMLVideoElement;
+
+ navigator.mediaDevices.getUserMedia({video: true, audio: false})
+
+ .then((stream) => {
+ this.video.srcObject = stream;
+ this.video.play();
+
+ });
+
+ }
+
+ capture() {
+
+ const canvas = document.createElement("canvas") as HTMLCanvasElement;
+
+ canvas.width = this.video.videoWidth;
+ canvas.height = this.video.videoHeight;
+
+ canvas
+ .getContext("2d")
+ .drawImage(this.video, 0, 0, canvas.width, canvas.height);
+
+ this.field.ok = true;
+ this.field.value = canvas.toDataURL();
+
+ this.update.emit();
+
+ }
+
+}
diff --git a/src/app/form.component.ts b/src/app/form.component.ts
index 699009d..7347f4f 100644
--- a/src/app/form.component.ts
+++ b/src/app/form.component.ts
@@ -1,4 +1,5 @@
import { Component, OnInit, Input } from '@angular/core';
+import { Router } from '@angular/router';
@Component({
selector: 'app-form',
@@ -15,6 +16,7 @@ import { Component, OnInit, Input } from '@angular/core';
>