diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts
index d703db0..a0e2bc6 100644
--- a/src/app/app-routing.module.ts
+++ b/src/app/app-routing.module.ts
@@ -1,13 +1,11 @@
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 }
+ { path: 'thanks', component: ThanksComponent }
];
@NgModule({
diff --git a/src/app/app.module.ts b/src/app/app.module.ts
index 13af438..8eee8ed 100644
--- a/src/app/app.module.ts
+++ b/src/app/app.module.ts
@@ -12,7 +12,6 @@ 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: [
@@ -25,7 +24,6 @@ import { ReportComponent } from './report.component';
SignComponent,
ThanksComponent,
HomeComponent,
- ReportComponent,
],
imports: [
BrowserModule,
diff --git a/src/app/camera.component.ts b/src/app/camera.component.ts
index a05b708..975a293 100644
--- a/src/app/camera.component.ts
+++ b/src/app/camera.component.ts
@@ -21,7 +21,7 @@ export class CameraComponent implements OnInit {
video: HTMLVideoElement;
- ngOnInit() { console.log("Camera", this.field.id); }
+ ngOnInit() { console.log("Smile!"); }
ngAfterViewInit() {
diff --git a/src/app/form.component.ts b/src/app/form.component.ts
index 7347f4f..99422b7 100644
--- a/src/app/form.component.ts
+++ b/src/app/form.component.ts
@@ -36,20 +36,15 @@ import { Router } from '@angular/router';
})
export class FormComponent implements OnInit {
- constructor(private router: Router) { }
+ constructor(private route: Router) { }
@Input() template: Form;
form: Form;
- ngOnInit() { this.set(); }
+ ngOnInit() { this.set() }
- set() {
-
- /* Make a deep copy of the template */
- this.form = JSON.parse(JSON.stringify(this.template));
-
- }
+ set() { this.form = Object.assign({}, this.template); }
next() {
@@ -63,33 +58,36 @@ export class FormComponent implements OnInit {
async submit() {
- const res = await fetch(this.form.submit, parseForm(this.form.steps));
+ const results = {};
- res.ok ?
- this.router.navigate(["/thanks"]) :
- alert("Failed to connect to the backend.");
+ this.form.steps.forEach((s: Step) => {
- }
+ s.fields.forEach((f: Field) => {
-}
+ results[f.id] = f.value;
-
-
-/* Util to extract key, values from Form */
-const parseForm = (steps: Step[]) => {
-
- const results = {};
-
- steps.forEach((s: Step) => {
-
- s.fields.forEach((f: Field) => {
-
- results[f.id] = f.value;
+ });
});
- });
+ try {
- return results;
+ const res = await fetch(this.form.submit, results);
-};
+ if (res.ok) {
+
+ this.set();
+
+ this.route.navigate(["/thanks"]);
+
+ } else {
+
+ alert("Backend does't like you.");
+
+ }
+
+ } catch (e) { alert("Something went wrong."); }
+
+ }
+
+}
diff --git a/src/app/home.component.ts b/src/app/home.component.ts
index 7b62035..3471ba4 100644
--- a/src/app/home.component.ts
+++ b/src/app/home.component.ts
@@ -16,8 +16,6 @@ import { checkin, checkout } from "src/assets/forms";
- Go To Report Page
-
`
})
diff --git a/src/app/radio.component.ts b/src/app/radio.component.ts
index 32833d9..4c5e014 100644
--- a/src/app/radio.component.ts
+++ b/src/app/radio.component.ts
@@ -25,7 +25,7 @@ export class RadioComponent implements OnInit {
@Input() field: Field;
@Output() update: EventEmitter = new EventEmitter();
- ngOnInit() { console.log("Radio", this.field.id); }
+ ngOnInit() { console.log("Text", this.field.id); }
check() {
diff --git a/src/app/report.component.ts b/src/app/report.component.ts
deleted file mode 100644
index b6ec342..0000000
--- a/src/app/report.component.ts
+++ /dev/null
@@ -1,53 +0,0 @@
-import { Component, OnInit } from '@angular/core';
-
-@Component({
- selector: 'app-report',
- template: `
-
-
-
-
-
-
-
-
- {{ entry.name }}
-
-
-
-
-
-
- `,
- styles: [
- ]
-})
-export class ReportComponent implements OnInit {
-
- data: Entry[];
-
- ngOnInit() {
-
- this.data = data;
-
- // try {
-
- // const res = await fetch("url");
-
- // } catch(e) { alert("Something went wrong."); }
-
- // this.data = res.json();
-
- }
-
-}
-
-
-/* Placeholder data */
-const data: Entry[] = [{
- name: "John Doe",
- eid: "john.doe",
- asset: "monitor",
- complete: false,
- photo: "./assets/monitor.jfif"
-}]
diff --git a/src/app/sign.component.ts b/src/app/sign.component.ts
index 87d9a87..2ae87c8 100644
--- a/src/app/sign.component.ts
+++ b/src/app/sign.component.ts
@@ -19,7 +19,7 @@ export class SignComponent implements OnInit {
pad: HTMLCanvasElement;
- ngOnInit() { console.log("Sign", this.field.id); }
+ ngOnInit() { console.log("Sign your name!"); }
ngAfterViewInit() {
diff --git a/src/app/step.component.ts b/src/app/step.component.ts
index 813709c..8e16b4a 100644
--- a/src/app/step.component.ts
+++ b/src/app/step.component.ts
@@ -46,10 +46,13 @@ export class StepComponent implements OnInit {
@Input() step: Step;
- ngOnInit() { console.log("Step", this.step.prompt); }
+ ngOnInit() { console.log("Step", this.step); }
update() {
+ console.log(this.step.fields);
+
+ /* Check for completeness */
for (let field of this.step.fields) {
if (!field.ok) {
this.step.ok = false;
diff --git a/src/assets/monitor.jfif b/src/assets/monitor.jfif
deleted file mode 100644
index 2ed1cca..0000000
Binary files a/src/assets/monitor.jfif and /dev/null differ
diff --git a/src/types.d.ts b/src/types.d.ts
index 35b221c..7f8c2c5 100644
--- a/src/types.d.ts
+++ b/src/types.d.ts
@@ -1,3 +1,11 @@
+declare interface TextOptions {
+ modifier: string;
+}
+
+declare interface RadioOptions {
+ choices: string[];
+}
+
declare interface Field {
type: string;
id: string;
@@ -18,12 +26,4 @@ declare interface Form {
goto: string;
step: number;
steps: Step[];
-}
-
-declare interface Entry {
- name: string;
- eid: string;
- asset: string;
- complete: boolean;
- photo: string;
-}
+}