From b6a37d4e40c9be3bd1e5ccbea39efc70ec80c93e Mon Sep 17 00:00:00 2001 From: Chris Veilleux Date: Wed, 13 Mar 2019 23:51:14 -0500 Subject: [PATCH] new device add component --- .../device-add/device-add.component.html | 64 ++++++++++++++ .../device-add/device-add.component.scss | 5 ++ .../device/device-add/device-add.component.ts | 86 +++++++++++++++++++ .../device-add/pairing/pairing.component.html | 10 +++ .../device-add/pairing/pairing.component.scss | 8 ++ .../device-add/pairing/pairing.component.ts | 17 ++++ 6 files changed, 190 insertions(+) create mode 100644 projects/account/src/app/modules/device/device-add/device-add.component.html create mode 100644 projects/account/src/app/modules/device/device-add/device-add.component.scss create mode 100644 projects/account/src/app/modules/device/device-add/device-add.component.ts create mode 100644 projects/account/src/app/modules/device/device-add/pairing/pairing.component.html create mode 100644 projects/account/src/app/modules/device/device-add/pairing/pairing.component.scss create mode 100644 projects/account/src/app/modules/device/device-add/pairing/pairing.component.ts diff --git a/projects/account/src/app/modules/device/device-add/device-add.component.html b/projects/account/src/app/modules/device/device-add/device-add.component.html new file mode 100644 index 0000000..92e95c9 --- /dev/null +++ b/projects/account/src/app/modules/device/device-add/device-add.component.html @@ -0,0 +1,64 @@ + + + + + + + + + + + + +
+ + +
+
+ + +
+ + + +
+
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + diff --git a/projects/account/src/app/modules/device/device-add/device-add.component.scss b/projects/account/src/app/modules/device/device-add/device-add.component.scss new file mode 100644 index 0000000..fc2d384 --- /dev/null +++ b/projects/account/src/app/modules/device/device-add/device-add.component.scss @@ -0,0 +1,5 @@ +mat-horizontal-stepper { + margin-left: auto; + margin-right: auto; + max-width: 800px; +} diff --git a/projects/account/src/app/modules/device/device-add/device-add.component.ts b/projects/account/src/app/modules/device/device-add/device-add.component.ts new file mode 100644 index 0000000..5375fad --- /dev/null +++ b/projects/account/src/app/modules/device/device-add/device-add.component.ts @@ -0,0 +1,86 @@ +import { Component, OnInit } from '@angular/core'; +import { MediaChange, MediaObserver } from '@angular/flex-layout'; +import { + AbstractControl, + FormBuilder, + FormGroup, + Validators +} from '@angular/forms'; +import { ActivatedRoute } from '@angular/router'; + +import { faCheck } from '@fortawesome/free-solid-svg-icons'; +import { Subscription } from 'rxjs'; + +import { AccountPreferences, DeviceService } from '../../../core/http/device.service'; + +@Component({ + selector: 'account-device-add', + templateUrl: './device-add.component.html', + styleUrls: ['./device-add.component.scss'] +}) +export class DeviceAddComponent implements OnInit { + public alignVertical: boolean; + public deviceForm: FormGroup; + private mediaWatcher: Subscription; + public pairingCodeControl: AbstractControl; + public pairDeviceForm: FormGroup; + public preferencesForm: FormGroup; + public preferences: AccountPreferences; + public stepDoneIcon = faCheck; + + constructor( + private formBuilder: FormBuilder, + public mediaObserver: MediaObserver, + private deviceService: DeviceService, + private route: ActivatedRoute + ) { + this.mediaWatcher = mediaObserver.media$.subscribe( + (change: MediaChange) => { + this.alignVertical = ['xs', 'sm'].includes(change.mqAlias); + } + ); + } + + ngOnInit() { + this.getAccountPreferences(); + this.buildForms(); + this.setControlFormAliases(); + } + + private buildForms() { + this.preferencesForm = this.deviceService.buildPreferencesForm(this.preferences); + this.pairDeviceForm = this.formBuilder.group({ + pairingCode: ['', Validators.required], + }); + this.deviceForm = this.formBuilder.group( + { + name: ['', Validators.required], + placement: [''], + country: ['', Validators.required], + region: ['', Validators.required], + city: ['', Validators.required], + timeZone: ['', Validators.required] + } + ); + } + + getAccountPreferences() { + this.route.data.subscribe( + (data: {preferences: AccountPreferences}) => { + this.preferences = data.preferences; + } + ); + } + + private setControlFormAliases() { + this.pairingCodeControl = this.pairDeviceForm.controls['pairingCode']; + } + + onPairingSubmit() { + console.log('attempting to pair device'); + } + + onPreferencesSubmit() { + console.log('attempting to pair device'); + } +} diff --git a/projects/account/src/app/modules/device/device-add/pairing/pairing.component.html b/projects/account/src/app/modules/device/device-add/pairing/pairing.component.html new file mode 100644 index 0000000..02d7044 --- /dev/null +++ b/projects/account/src/app/modules/device/device-add/pairing/pairing.component.html @@ -0,0 +1,10 @@ + + Verify your pairing code + +

Enter the code spoken by your device:

+ + Pairing Code + + +
+
diff --git a/projects/account/src/app/modules/device/device-add/pairing/pairing.component.scss b/projects/account/src/app/modules/device/device-add/pairing/pairing.component.scss new file mode 100644 index 0000000..8a98cbc --- /dev/null +++ b/projects/account/src/app/modules/device/device-add/pairing/pairing.component.scss @@ -0,0 +1,8 @@ +@import "../../../../../../../../node_modules/@angular/material/theming"; +@import "mycroft-colors"; + +mat-card { + mat-card-title { + color: mat-color($mycroft-primary) + } +} diff --git a/projects/account/src/app/modules/device/device-add/pairing/pairing.component.ts b/projects/account/src/app/modules/device/device-add/pairing/pairing.component.ts new file mode 100644 index 0000000..34e084f --- /dev/null +++ b/projects/account/src/app/modules/device/device-add/pairing/pairing.component.ts @@ -0,0 +1,17 @@ +import { Component, OnInit, Input } from '@angular/core'; +import { AbstractControl } from '@angular/forms'; + +@Component({ + selector: 'account-device-pairing', + templateUrl: './pairing.component.html', + styleUrls: ['./pairing.component.scss'] +}) +export class PairingComponent implements OnInit { + @Input() pairingCodeControl: AbstractControl; + + constructor() { } + + ngOnInit() { + } + +}