Compare commits
14 changed files with 39 additions and 128 deletions
16
package-lock.json
generated
16
package-lock.json
generated
|
|
@ -4610,22 +4610,6 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"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",
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@
|
|||
"version": "0.0.0",
|
||||
"scripts": {
|
||||
"ng": "ng",
|
||||
"test": "jasmine",
|
||||
"start": "ng serve",
|
||||
"build": "ng build",
|
||||
"watch": "ng build --watch --configuration development"
|
||||
|
|
@ -27,7 +26,6 @@
|
|||
"@angular/cli": "~13.2.2",
|
||||
"@angular/compiler-cli": "~13.2.0",
|
||||
"@types/node": "^12.11.1",
|
||||
"jasmine": "^4.0.2",
|
||||
"typescript": "~4.5.2"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,13 +0,0 @@
|
|||
{
|
||||
"spec_dir": "spec",
|
||||
"spec_files": [
|
||||
"**/*[sS]pec.?(m)js"
|
||||
],
|
||||
"helpers": [
|
||||
"helpers/**/*.?(m)js"
|
||||
],
|
||||
"env": {
|
||||
"stopSpecOnExpectationFailure": false,
|
||||
"random": true
|
||||
}
|
||||
}
|
||||
|
|
@ -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({
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ export class CameraComponent implements OnInit {
|
|||
|
||||
video: HTMLVideoElement;
|
||||
|
||||
ngOnInit() { console.log("Camera", this.field.id); }
|
||||
ngOnInit() { console.log("Smile!"); }
|
||||
|
||||
ngAfterViewInit() {
|
||||
|
||||
|
|
|
|||
|
|
@ -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."); }
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,8 +16,6 @@ import { checkin, checkout } from "src/assets/forms";
|
|||
|
||||
<app-form *ngIf="action=='checkout'" [template]="checkout"></app-form>
|
||||
|
||||
<a routerLink="/report">Go To Report Page</a>
|
||||
|
||||
<footer>Accenture | 2022</footer>
|
||||
`
|
||||
})
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ export class RadioComponent implements OnInit {
|
|||
@Input() field: Field;
|
||||
@Output() update: EventEmitter<null> = new EventEmitter();
|
||||
|
||||
ngOnInit() { console.log("Radio", this.field.id); }
|
||||
ngOnInit() { console.log("Text", this.field.id); }
|
||||
|
||||
check() {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,53 +0,0 @@
|
|||
import { Component, OnInit } from '@angular/core';
|
||||
|
||||
@Component({
|
||||
selector: 'app-report',
|
||||
template: `
|
||||
<div class="report">
|
||||
|
||||
<span *ngFor="let entry of data">
|
||||
|
||||
<img [src]="entry.photo"/>
|
||||
|
||||
<div class="info">
|
||||
|
||||
{{ entry.name }}
|
||||
|
||||
</div>
|
||||
|
||||
</span>
|
||||
|
||||
</div>
|
||||
`,
|
||||
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"
|
||||
}]
|
||||
|
|
@ -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() {
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Binary file not shown.
|
Before Width: | Height: | Size: 4.4 KiB |
18
src/types.d.ts
vendored
18
src/types.d.ts
vendored
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue