init commit

This commit is contained in:
Gundersen 2022-02-28 13:49:43 -06:00
commit 5b7c7d4d19
25 changed files with 8503 additions and 0 deletions

16
.browserslistrc Normal file
View file

@ -0,0 +1,16 @@
# This file is used by the build system to adjust CSS and JS output to support the specified browsers below.
# For additional information regarding the format and rule options, please see:
# https://github.com/browserslist/browserslist#queries
# For the full list of supported browsers by the Angular framework, please see:
# https://angular.io/guide/browser-support
# You can see what browsers were selected by your queries by running:
# npx browserslist
last 1 Chrome version
last 1 Firefox version
last 2 Edge major versions
last 2 Safari major versions
last 2 iOS major versions
Firefox ESR

42
.gitignore vendored Normal file
View file

@ -0,0 +1,42 @@
# See http://help.github.com/ignore-files/ for more about ignoring files.
# Compiled output
/dist
/tmp
/out-tsc
/bazel-out
# Node
/node_modules
npm-debug.log
yarn-error.log
# IDEs and editors
.idea/
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace
# Visual Studio Code
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
.history/*
# Miscellaneous
/.angular/cache
.sass-cache/
/connect.lock
/coverage
/libpeerconnection.log
testem.log
/typings
# System files
.DS_Store
Thumbs.db

27
README.md Normal file
View file

@ -0,0 +1,27 @@
# Am2
This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 13.2.2.
## Development server
Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files.
## Code scaffolding
Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module`.
## Build
Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory.
## Running unit tests
Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io).
## Running end-to-end tests
Run `ng e2e` to execute the end-to-end tests via a platform of your choice. To use this command, you need to first add a package that implements end-to-end testing capabilities.
## Further help
To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI Overview and Command Reference](https://angular.io/cli) page.

118
angular.json Normal file
View file

@ -0,0 +1,118 @@
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"cli": {
"analytics": "8fc39826-b5af-494a-9eb0-f338209558ff"
},
"version": 1,
"newProjectRoot": "projects",
"projects": {
"am2": {
"projectType": "application",
"schematics": {
"@schematics/angular:component": {
"inlineTemplate": true,
"inlineStyle": true,
"skipTests": true
},
"@schematics/angular:class": {
"skipTests": true
},
"@schematics/angular:directive": {
"skipTests": true
},
"@schematics/angular:guard": {
"skipTests": true
},
"@schematics/angular:interceptor": {
"skipTests": true
},
"@schematics/angular:pipe": {
"skipTests": true
},
"@schematics/angular:resolver": {
"skipTests": true
},
"@schematics/angular:service": {
"skipTests": true
},
"@schematics/angular:application": {
"strict": true
}
},
"root": "",
"sourceRoot": "src",
"prefix": "app",
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist/am2",
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "tsconfig.app.json",
"assets": [
"src/favicon.ico",
"src/assets"
],
"styles": [
"src/styles.css"
],
"scripts": []
},
"configurations": {
"production": {
"budgets": [
{
"type": "initial",
"maximumWarning": "500kb",
"maximumError": "1mb"
},
{
"type": "anyComponentStyle",
"maximumWarning": "2kb",
"maximumError": "4kb"
}
],
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
],
"outputHashing": "all"
},
"development": {
"buildOptimizer": false,
"optimization": false,
"vendorChunk": true,
"extractLicenses": false,
"sourceMap": true,
"namedChunks": true
}
},
"defaultConfiguration": "production"
},
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"configurations": {
"production": {
"browserTarget": "am2:build:production"
},
"development": {
"browserTarget": "am2:build:development"
}
},
"defaultConfiguration": "development"
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "am2:build"
}
}
}
}
},
"defaultProject": "am2"
}

7709
package-lock.json generated Normal file

File diff suppressed because it is too large Load diff

31
package.json Normal file
View file

@ -0,0 +1,31 @@
{
"name": "am2",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"watch": "ng build --watch --configuration development"
},
"private": true,
"dependencies": {
"@angular/animations": "~13.2.0",
"@angular/common": "~13.2.0",
"@angular/compiler": "~13.2.0",
"@angular/core": "~13.2.0",
"@angular/forms": "~13.2.0",
"@angular/platform-browser": "~13.2.0",
"@angular/platform-browser-dynamic": "~13.2.0",
"@angular/router": "~13.2.0",
"rxjs": "~7.5.0",
"tslib": "^2.3.0",
"zone.js": "~0.11.4"
},
"devDependencies": {
"@angular-devkit/build-angular": "~13.2.2",
"@angular/cli": "~13.2.2",
"@angular/compiler-cli": "~13.2.0",
"@types/node": "^12.11.1",
"typescript": "~4.5.2"
}
}

45
src/app/app.component.ts Normal file
View file

@ -0,0 +1,45 @@
import { Component } from '@angular/core';
import { forms } from "src/assets/forms";
@Component({
selector: 'app-root',
template: `
<button *ngFor="let template of templates"
(click)=change(template)
>
{{ template.name }}
</button>
<app-form [form]="form"></app-form>
<footer>Accenture | 2022</footer>
`
})
export class AppComponent {
templates: Form[] = forms;
form: Form; /* Active */
ngOnInit() { this.set(this.templates[0]); }
set(template: Form) {
this.form = Object.assign({}, template);
console.log("Setting", this.form);
}
change(template: Form) {
alert("Are you sure?");
this.set(template);
}
}

30
src/app/app.module.ts Normal file
View file

@ -0,0 +1,30 @@
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule } from '@angular/forms';
import { AppComponent } from './app.component';
import { FormComponent } from './form.component';
import { TextComponent } from './text.component';
import { RadioComponent } from './radio.component';
import { MenuComponent } from './menu.component';
import { BarComponent } from './bar.component';
import { StepComponent } from './step.component';
@NgModule({
declarations: [
AppComponent,
FormComponent,
TextComponent,
RadioComponent,
MenuComponent,
BarComponent,
StepComponent,
],
imports: [
BrowserModule,
FormsModule,
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }

20
src/app/bar.component.ts Normal file
View file

@ -0,0 +1,20 @@
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-bar',
template: `
<p>
bar works!
</p>
`,
styles: [
]
})
export class BarComponent implements OnInit {
constructor() { }
ngOnInit(): void {
}
}

53
src/app/form.component.ts Normal file
View file

@ -0,0 +1,53 @@
import { Component, OnInit, Input } from '@angular/core';
@Component({
selector: 'app-form',
template: `
<div class="form">
<h1>{{ form.name }}</h1>
<app-step *ngFor="let _step of form.steps; let i=index"
[hidden]="i!==form.step"
[step]="_step"
></app-step>
<button
[class.active]="form.step > 0"
(click)="back()"
>
Back
</button>
<button
[class.active]="form.steps[form.step].ok"
(click)="next()"
>
Next
</button>
</div>
`
})
export class FormComponent implements OnInit {
@Input() form: Form;
ngOnInit() { console.log("Form", this.form); }
next() {
this.form.step == this.form.steps.length - 1 ?
this.submit() :
this.form.step++
}
back() { this.form.step--; }
/* Extract the values from the fields into a dict */
submit() { console.log("Submitting", this.form); }
}

20
src/app/menu.component.ts Normal file
View file

@ -0,0 +1,20 @@
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-menu',
template: `
<p>
menu works!
</p>
`,
styles: [
]
})
export class MenuComponent implements OnInit {
constructor() { }
ngOnInit(): void {
}
}

View file

@ -0,0 +1,38 @@
import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
@Component({
selector: 'app-radio',
template: `
<div class="radio">
<div *ngFor="let choice of field.options.choices">
<input type="radio" name="field.id" class="choice"
[value]="choice"
[(ngModel)]="field.value"
(ngModelChange)="check()"
/>
<label>{{ choice }}</label>
</div>
</div>
`
})
export class RadioComponent implements OnInit {
@Input() field: Field;
@Output() update: EventEmitter<null> = new EventEmitter();
ngOnInit() { console.log("Text", this.field.id); }
check() {
this.field.ok = true;
this.update.emit();
}
}

53
src/app/step.component.ts Normal file
View file

@ -0,0 +1,53 @@
import { Component, OnInit, Input } from '@angular/core';
@Component({
selector: 'app-step',
template: `
<div class="step">
<h2>{{ step.prompt }}</h2>
<div *ngFor="let field of step.fields" [ngSwitch]="field.type">
<app-text *ngSwitchCase="'text'"
[field]="field"
(update)="update()"
></app-text>
<app-radio *ngSwitchCase="'radio'"
[field]="field"
(update)="update()"
></app-radio>
</div>
</div>
`
})
export class StepComponent implements OnInit {
@Input() step: Step;
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;
return;
}
}
this.step.ok = true;
}
}

28
src/app/text.component.ts Normal file
View file

@ -0,0 +1,28 @@
import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
@Component({
selector: 'app-text',
template: `
<div class="text">
<input [(ngModel)]="field.value" (ngModelChange)="check()" />
</div>
`
})
export class TextComponent implements OnInit {
@Input() field: Field;
@Output() update: EventEmitter<null> = new EventEmitter();
ngOnInit() { console.log("Text", this.field.id); }
check() {
this.field.ok = this.field.value ? true : false;
this.update.emit()
}
}

92
src/assets/forms.ts Normal file
View file

@ -0,0 +1,92 @@
export const forms: Form[] = [{
name: "Check Out",
submit: "/api/checkout",
goto: "/confirmation",
step: 0,
steps: [{
ok: false,
prompt: "Enter in your name and EID.",
fields: [{
ok: false,
type: "text",
id: "name",
value: null,
options: { modifier: "name" }
},
{
ok: false,
type: "text",
id: "eid",
value: null,
options: { modifier: "eid" }
}],
},
{
ok: false,
prompt: "Choose an asset.",
fields: [{
ok: false,
type: "radio",
id: "asset",
value: null,
options: { choices: ["mouse", "keyboard", "monitor", "chair"] }
}]
},
{
ok: false,
prompt: "Would you like a confirmation email?",
fields: [{
ok: false,
type: "radio",
id: "confirmation",
value: null,
options: { choices: ["yes", "no"] }
}]
}]
}, {
name: "Check In",
submit: "/api/checkin",
goto: "/confirmation",
step: 0,
steps: [{
ok: false,
prompt: "Enter in your EID.",
fields: [{
ok: false,
type: "text",
id: "name",
value: null,
options: { modifier: "eid" }
}]
},
{
ok: false,
prompt: "Choose an asset",
fields: [{
ok: false,
type: "radio",
id: "asset",
value: null,
options: { choices: ["mouse", "keyboard", "monitor", "chair"] }
}]
},
{
ok: false,
prompt: "Would you like a confirmation email?",
fields: [{
ok: false,
type: "radio",
id: "confirmation",
value: null,
options: { choices: ["yes", "no"] }
}]
}]
}];

View file

@ -0,0 +1,3 @@
export const environment = {
production: true
};

View file

@ -0,0 +1,16 @@
// This file can be replaced during build by using the `fileReplacements` array.
// `ng build` replaces `environment.ts` with `environment.prod.ts`.
// The list of file replacements can be found in `angular.json`.
export const environment = {
production: false
};
/*
* For easier debugging in development mode, you can import the following file
* to ignore zone related error stack frames such as `zone.run`, `zoneDelegate.invokeTask`.
*
* This import should be commented out in production mode because it will have a negative impact
* on performance if an error is thrown.
*/
// import 'zone.js/plugins/zone-error'; // Included with Angular CLI.

BIN
src/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 948 B

13
src/index.html Normal file
View file

@ -0,0 +1,13 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Am2</title>
<base href="/">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
</head>
<body>
<app-root></app-root>
</body>
</html>

12
src/main.ts Normal file
View file

@ -0,0 +1,12 @@
import { enableProdMode } from '@angular/core';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { AppModule } from './app/app.module';
import { environment } from './environments/environment';
if (environment.production) {
enableProdMode();
}
platformBrowserDynamic().bootstrapModule(AppModule)
.catch(err => console.error(err));

53
src/polyfills.ts Normal file
View file

@ -0,0 +1,53 @@
/**
* This file includes polyfills needed by Angular and is loaded before the app.
* You can add your own extra polyfills to this file.
*
* This file is divided into 2 sections:
* 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers.
* 2. Application imports. Files imported after ZoneJS that should be loaded before your main
* file.
*
* The current setup is for so-called "evergreen" browsers; the last versions of browsers that
* automatically update themselves. This includes recent versions of Safari, Chrome (including
* Opera), Edge on the desktop, and iOS and Chrome on mobile.
*
* Learn more in https://angular.io/guide/browser-support
*/
/***************************************************************************************************
* BROWSER POLYFILLS
*/
/**
* By default, zone.js will patch all possible macroTask and DomEvents
* user can disable parts of macroTask/DomEvents patch by setting following flags
* because those flags need to be set before `zone.js` being loaded, and webpack
* will put import in the top of bundle, so user need to create a separate file
* in this directory (for example: zone-flags.ts), and put the following flags
* into that file, and then add the following code before importing zone.js.
* import './zone-flags';
*
* The flags allowed in zone-flags.ts are listed here.
*
* The following flags will work for all browsers.
*
* (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame
* (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick
* (window as any).__zone_symbol__UNPATCHED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames
*
* in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js
* with the following flag, it will bypass `zone.js` patch for IE/Edge
*
* (window as any).__Zone_enable_cross_context_check = true;
*
*/
/***************************************************************************************************
* Zone JS is required by default for Angular itself.
*/
import 'zone.js'; // Included with Angular CLI.
/***************************************************************************************************
* APPLICATION IMPORTS
*/

5
src/styles.css Normal file
View file

@ -0,0 +1,5 @@
.active {
pointer-events: auto;
color: blue;
border-color: blue;
}

29
src/types.d.ts vendored Normal file
View file

@ -0,0 +1,29 @@
declare interface TextOptions {
modifier: string;
}
declare interface RadioOptions {
choices: string[];
}
declare interface Field {
type: string;
id: string;
value: any;
ok: boolean;
options: any;
}
declare interface Step {
ok: boolean;
prompt: string;
fields: Field[];
}
declare interface Form {
name: string;
submit: string;
goto: string;
step: number;
steps: Step[];
}

15
tsconfig.app.json Normal file
View file

@ -0,0 +1,15 @@
/* To learn more about this file see: https://angular.io/config/tsconfig. */
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "./out-tsc/app",
"types": []
},
"files": [
"src/main.ts",
"src/polyfills.ts"
],
"include": [
"src/**/*.d.ts"
]
}

35
tsconfig.json Normal file
View file

@ -0,0 +1,35 @@
/* To learn more about this file see: https://angular.io/config/tsconfig. */
{
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "./",
"outDir": "./dist/out-tsc",
"forceConsistentCasingInFileNames": true,
"strict": false,
"noImplicitOverride": true,
"noPropertyAccessFromIndexSignature": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"sourceMap": true,
"declaration": false,
"downlevelIteration": true,
"experimentalDecorators": true,
"moduleResolution": "node",
"importHelpers": true,
"target": "es2017",
"module": "es2020",
"lib": [
"es2020",
"dom"
]
},
"angularCompilerOptions": {
"enableI18nLegacyMessageIdFormat": false,
"strictInjectionParameters": true,
"strictInputAccessModifiers": true,
"strictTemplates": true
},
"paths": {
"*": ["*.d.ts"]
},
}