diff --git a/e2e/src/app.e2e-spec.ts b/e2e/src/app.e2e-spec.ts index 770476e..69ed2b5 100644 --- a/e2e/src/app.e2e-spec.ts +++ b/e2e/src/app.e2e-spec.ts @@ -10,9 +10,10 @@ describe('COVID19 Testing Kiosk App', () => { http = new HttpClient('http://localhost:5001'); }); - it('should automatically sign-in and redirect to home screen', () => { + it('should automatically sign-in and redirect to sample input screen', () => { page.navigateTo(); expect(page.getRoute()).toEqual('/'); + }); it('should navigate to settings screen', () => { @@ -23,15 +24,7 @@ describe('COVID19 Testing Kiosk App', () => { page.clickAndExpectRoute('#nav_home', '/'); }); - it('should navigate to occupancy count input screen', () => { - page.clickAndExpectRoute('#nav_count', '/count'); - }); - - it('should navigate back to home screen', () => { + it('should navigate back to sample input screen', () => { page.clickAndExpectRoute('#nav_home', '/'); }); - - it('should navigate to sample input screen', () => { - page.clickAndExpectRoute('#nav_sample', '/sample'); - }); }); diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index 8ae8075..f281a2d 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -11,7 +11,7 @@ export const routes: Routes = [ { path: '', pathMatch: 'full', - component: HomeComponent + component: SampleComponent }, { path: 'sample', diff --git a/src/app/app.component.html b/src/app/app.component.html index f07453d..f3e33c7 100644 --- a/src/app/app.component.html +++ b/src/app/app.component.html @@ -1,5 +1,5 @@
- +
diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 13a8787..b2d34ea 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -1,22 +1,15 @@ import {Component, Inject} from '@angular/core'; -import {MatIconRegistry} from '@angular/material/icon'; -import {DomSanitizer, Title} from '@angular/platform-browser'; -import {Router} from '@angular/router'; +import {Title} from '@angular/platform-browser'; import {AppEnvironment} from './models/appEnvironment.interface'; -import {TestingLocation} from './models/testingLocation.interface'; -import {GoogleAnalyticsService} from './services/google-analytics.service'; @Component({ selector: 'app-root', templateUrl: './app.component.html', styleUrls: ['./app.component.scss'] }) + export class AppComponent { loading: boolean; - testingLocation: TestingLocation = { - id: '0000', - name: 'Click here to set location', - }; constructor( @Inject('APP_ENVIRONMENT') private environment: AppEnvironment, @@ -25,6 +18,7 @@ export class AppComponent { this.titleService.setTitle(this.environment.title); } + reload() { this.loading = true; setTimeout(() => this.loading = false, 300); diff --git a/src/app/barcode-data-matrix/barcode-data-matrix.component.spec.ts b/src/app/barcode-data-matrix/barcode-data-matrix.component.spec.ts index 7d3104a..9085ec7 100644 --- a/src/app/barcode-data-matrix/barcode-data-matrix.component.spec.ts +++ b/src/app/barcode-data-matrix/barcode-data-matrix.component.spec.ts @@ -20,7 +20,7 @@ describe('BarcodeDataMatrixComponent', () => { beforeEach(() => { fixture = TestBed.createComponent(BarcodeDataMatrixComponent); component = fixture.componentInstance; - settings.labelLayout = labelLayouts.rectangular_lg; + // settings.labelLayout = labelLayouts.rectangular_lg; component.settings = settings; component.format = settings.labelLayout.barcodeType; component.value = '987654321-202101231122-ABCDE-0123'; diff --git a/src/app/config/defaults.ts b/src/app/config/defaults.ts index bf33c23..abf779e 100644 --- a/src/app/config/defaults.ts +++ b/src/app/config/defaults.ts @@ -26,31 +26,31 @@ export const labelLayouts = { topTextMargin: 0, bottomTextMargin: 0, }), - rectangular_lg: new LabelLayout({ - name: '2in x 1.25in Rectangular Label', - barcodeType: 'qrcode', - type: 'rectangular_lg', - numCols: 1, - columnGap: 0, - labelWidth: 28.6, - labelHeight: 28.6, - sideTextMargin: 10, - topTextMargin: 1, - bottomTextMargin: 1, - }), - rectangular_sm: new LabelLayout({ - name: '96mm x 15mm Rectangular Label', - barcodeType: 'datamatrix', - type: 'rectangular_sm', - numCols: 1, - columnGap: 0, - labelWidth: 32, - labelHeight: 16, - marginSize: 6, - sideTextMargin: 2, - topTextMargin: 3, - bottomTextMargin: 3, - }), + // rectangular_lg: new LabelLayout({ + // name: '2in x 1.25in Rectangular Label', + // barcodeType: 'qrcode', + // type: 'rectangular_lg', + // numCols: 1, + // columnGap: 0, + // labelWidth: 28.6, + // labelHeight: 28.6, + // sideTextMargin: 10, + // topTextMargin: 1, + // bottomTextMargin: 1, + // }), + // rectangular_sm: new LabelLayout({ + // name: '96mm x 15mm Rectangular Label', + // barcodeType: 'datamatrix', + // type: 'rectangular_sm', + // numCols: 1, + // columnGap: 0, + // labelWidth: 32, + // labelHeight: 16, + // marginSize: 6, + // sideTextMargin: 2, + // topTextMargin: 3, + // bottomTextMargin: 3, + // }), }; export const defaultOptions: AppDefaultsOptions = { diff --git a/src/app/label-layout/label-layout.component.html b/src/app/label-layout/label-layout.component.html index b63ff8c..240c86c 100644 --- a/src/app/label-layout/label-layout.component.html +++ b/src/app/label-layout/label-layout.component.html @@ -5,7 +5,7 @@
{{dateCreated | date:'yyMMdd'}}{{initials}}
+ >{{dateCreated | date:'yyMMdd'}}{{initials.toUpperCase()}}
{ + this.settings = settings; + this.locationId = !this.hasDefaultId ? this.settings.locationId : '0000'; + }); + } + + get hasDefaultId(): boolean { + return (!this.settings || this.settings.locationId === '0000'); } ngOnInit(): void { } - - get locationId(): string { - const settings = this.settingsService.getSettings(); - return settings.locationId; - } } diff --git a/src/app/print-layout/print-layout.component.html b/src/app/print-layout/print-layout.component.html index bfacf75..034bac9 100644 --- a/src/app/print-layout/print-layout.component.html +++ b/src/app/print-layout/print-layout.component.html @@ -16,7 +16,7 @@
diff --git a/src/app/print-layout/print-layout.component.spec.ts b/src/app/print-layout/print-layout.component.spec.ts index a6f6116..4d3cbdc 100644 --- a/src/app/print-layout/print-layout.component.spec.ts +++ b/src/app/print-layout/print-layout.component.spec.ts @@ -16,6 +16,7 @@ describe('PrintLayoutComponent', () => { beforeEach(() => { fixture = TestBed.createComponent(PrintLayoutComponent); component = fixture.componentInstance; + component.initials = 'abcde'; fixture.detectChanges(); }); diff --git a/src/app/print/print.component.html b/src/app/print/print.component.html index d47bbe9..e04e356 100644 --- a/src/app/print/print.component.html +++ b/src/app/print/print.component.html @@ -17,7 +17,7 @@ > @@ -26,7 +26,7 @@ #saveAndPrintButton="matButton" mat-flat-button class="btn-lg" - [color]="isSaved ? '' : 'accent'" + color="accent" (click)="saveAndPrint()" autofocus fxFlex="33%" @@ -37,8 +37,7 @@ class="btn-lg" routerLink="/" fxFlex="33%" - [color]="isSaved ? 'accent' : ''" - >done Done + >cancel Cancel @@ -46,7 +45,7 @@
diff --git a/src/app/print/print.component.ts b/src/app/print/print.component.ts index 1f604b6..89e16e0 100644 --- a/src/app/print/print.component.ts +++ b/src/app/print/print.component.ts @@ -1,6 +1,6 @@ import {AfterViewInit, ChangeDetectorRef, Component, OnInit, ViewChild} from '@angular/core'; import {MatButton} from '@angular/material/button'; -import {ActivatedRoute} from '@angular/router'; +import {ActivatedRoute, Router} from '@angular/router'; import {createQrCodeValue} from '../_util/qrCode'; import {AppDefaults} from '../models/appDefaults.interface'; import {LabelLayout} from '../models/labelLayout.interface'; @@ -26,6 +26,7 @@ export class PrintComponent implements AfterViewInit { constructor( private api: ApiService, private route: ActivatedRoute, + private router: Router, private changeDetector: ChangeDetectorRef, private settingsService: SettingsService, private cacheService: CacheService, @@ -33,13 +34,14 @@ export class PrintComponent implements AfterViewInit { this.dateCreated = new Date(); this.route.queryParamMap.subscribe(queryParamMap => { this.barCode = queryParamMap.get('barCode'); - this.initials = queryParamMap.get('initials'); + this.initials = queryParamMap.get('initials').toUpperCase(); }); this.settings = this.settingsService.getSettings(); this.isSaved = false; this.save(s => { this.isSaved = true; + this.changeDetector.detectChanges(); }); } @@ -73,7 +75,7 @@ export class PrintComponent implements AfterViewInit { save(callback: (s: Sample) => void) { const id = createQrCodeValue( this.barCode, - this.initials, + this.initials.toUpperCase(), this.dateCreated, this.settings.locationId ); @@ -102,8 +104,7 @@ export class PrintComponent implements AfterViewInit { saveAndPrint() { this.save(s => { window.print(); - this.doneButton.focus(); - this.changeDetector.detectChanges(); + this.router.navigate(['/']); }); } } diff --git a/src/app/sample/sample.component.html b/src/app/sample/sample.component.html index 339af2e..1c64a68 100644 --- a/src/app/sample/sample.component.html +++ b/src/app/sample/sample.component.html @@ -45,20 +45,14 @@ color="accent" [disabled]="hasErrors" (click)="goPrint()" - fxFlex="33%" + fxFlex="50%" >Next navigate_next - diff --git a/src/app/sample/sample.component.ts b/src/app/sample/sample.component.ts index 759d1e9..c5f99fe 100644 --- a/src/app/sample/sample.component.ts +++ b/src/app/sample/sample.component.ts @@ -41,7 +41,7 @@ export class SampleComponent implements AfterViewInit { get queryParams(): Params { return { barCode: this.barCodeValue.slice(0, 9), - initials: this.initialsValue, + initials: this.initialsValue.toUpperCase(), }; } @@ -50,7 +50,7 @@ export class SampleComponent implements AfterViewInit { } get initialsValue(): string { - return this.initialsFormControl.value; + return this.initialsFormControl.value.toUpperCase(); } get hasBarCode(): boolean { @@ -58,7 +58,7 @@ export class SampleComponent implements AfterViewInit { } get hasInitials(): boolean { - return this.settings.initialsRegExp.test(this.initialsValue); + return this.settings.initialsRegExp.test(this.initialsValue.toUpperCase()); } get hasErrors(): boolean { diff --git a/src/app/services/settings.service.ts b/src/app/services/settings.service.ts index e73e04c..3eb388f 100644 --- a/src/app/services/settings.service.ts +++ b/src/app/services/settings.service.ts @@ -1,5 +1,6 @@ import {Injectable} from '@angular/core'; import createClone from 'rfdc'; +import {BehaviorSubject} from 'rxjs'; import serializeJs from 'serialize-javascript'; import {defaultOptions} from '../config/defaults'; import {AppDefaults, AppDefaultsOptions} from '../models/appDefaults.interface'; @@ -11,10 +12,15 @@ export class SettingsService { // Default form field and data values defaults: AppDefaults = new AppDefaults(defaultOptions); + // Observable to subscribe to settings updates + settings = new BehaviorSubject(this.defaults); + // Deserializes settings from local storage and returns AppDefaults instance getStoredSettings(): AppDefaults { // tslint:disable-next-line:no-eval - return new AppDefaults(eval(`(${localStorage.getItem('settings')})`)); + const storedSettings = new AppDefaults(eval(`(${localStorage.getItem('settings')})`)); + this.settings.next(storedSettings); + return storedSettings; } // Returns true if settings are found in local storage @@ -40,6 +46,7 @@ export class SettingsService { }); localStorage.setItem('settings', serializeJs(settings)); + this.settings.next(settings); return settings; } diff --git a/src/app/settings/settings.component.html b/src/app/settings/settings.component.html index 8ea6279..630ddaf 100644 --- a/src/app/settings/settings.component.html +++ b/src/app/settings/settings.component.html @@ -10,13 +10,14 @@ - + Location ID # This field is required. Please enter exactly 4 digits. @@ -38,6 +39,7 @@ matInput type="number" [formControl]="numCopiesFormControl" + (keyup.enter)="save()" > This field is required. Please enter only 2-5 letters. diff --git a/src/app/settings/settings.component.ts b/src/app/settings/settings.component.ts index 9ab0f23..168ae97 100644 --- a/src/app/settings/settings.component.ts +++ b/src/app/settings/settings.component.ts @@ -1,5 +1,6 @@ -import {Component, OnInit} from '@angular/core'; +import {AfterViewInit, Component, OnInit, ViewChild} from '@angular/core'; import {FormControl, Validators} from '@angular/forms'; +import {MatInput} from '@angular/material/input'; import {Router} from '@angular/router'; import {labelLayouts} from '../config/defaults'; import {AppDefaults} from '../models/appDefaults.interface'; @@ -11,13 +12,15 @@ import {SettingsService} from '../services/settings.service'; templateUrl: './settings.component.html', styleUrls: ['./settings.component.scss'] }) -export class SettingsComponent implements OnInit { +export class SettingsComponent implements AfterViewInit { settings: AppDefaults; numCopiesFormControl: FormControl; labelLayoutFormControl: FormControl; locationIdFormControl: FormControl; labelLayouts: LabelLayout[]; + @ViewChild('locationIdInput') locationIdInput: MatInput; + constructor( private router: Router, private settingsService: SettingsService @@ -43,15 +46,18 @@ export class SettingsComponent implements OnInit { return this.numCopiesFormControl.valid && this.locationIdFormControl.valid; } - ngOnInit(): void { + ngAfterViewInit(): void { + this.locationIdInput.focus(); } save() { - this.settingsService.saveSettings({ - labelLayout: labelLayouts[this.labelLayoutFormControl.value], - numCopies: this.numCopiesFormControl.value, - locationId: this.locationIdFormControl.value, - }); - this.router.navigate(['/']); + if (this.hasInfo) { + this.settingsService.saveSettings({ + labelLayout: labelLayouts[this.labelLayoutFormControl.value], + numCopies: this.numCopiesFormControl.value, + locationId: this.locationIdFormControl.value, + }); + this.router.navigate(['/']); + } } }