diff --git a/projects/account/src/app/app-routing.module.ts b/projects/account/src/app/app-routing.module.ts index 1f4158a..5c489d5 100644 --- a/projects/account/src/app/app-routing.module.ts +++ b/projects/account/src/app/app-routing.module.ts @@ -28,6 +28,7 @@ const routes: Routes = [ { path: 'dashboard', component: DashboardComponent, resolve: {account: AccountResolverService} }, { path: 'maintenance', component: MaintenancePageComponent}, { path: '', redirectTo: '/dashboard', pathMatch: 'full'}, + { path: 'pair', redirectTo: '/devices/add', pathMatch: 'full'}, { path: '**', component: PageNotFoundComponent } ]; diff --git a/projects/account/src/app/core/http/device.service.ts b/projects/account/src/app/core/http/device.service.ts index e16206e..f455ac3 100644 --- a/projects/account/src/app/core/http/device.service.ts +++ b/projects/account/src/app/core/http/device.service.ts @@ -31,6 +31,7 @@ const deviceUrl = '/api/devices'; const geographyUrl = 'api/geographies'; const pairingCodeUrl = '/api/pairing-code'; const preferencesUrl = '/api/preferences'; +const softwareUpdateUrl = '/api/software-update'; const voicesUrl = '/api/voices'; const wakeWordUrl = '/api/wake-words'; @@ -100,4 +101,8 @@ export class DeviceService { getWakeWords() { return this.http.get(wakeWordUrl); } + + applySoftwareUpdate(pantacorUpdateId: string) { + return this.http.patch(softwareUpdateUrl, {deploymentId: pantacorUpdateId}); + } } diff --git a/projects/account/src/app/modules/device/components/card/device-display/device-display.component.html b/projects/account/src/app/modules/device/components/card/device-display/device-display.component.html index acf8919..b3ef95a 100644 --- a/projects/account/src/app/modules/device/components/card/device-display/device-display.component.html +++ b/projects/account/src/app/modules/device/components/card/device-display/device-display.component.html @@ -11,13 +11,18 @@ [value]="getPlatform(device)" > - + + @@ -26,6 +31,14 @@ [value]="device.pantacorConfig.ipAddress" > + diff --git a/projects/account/src/app/modules/device/components/card/device-display/device-display.component.scss b/projects/account/src/app/modules/device/components/card/device-display/device-display.component.scss index ab78c9d..88d8070 100644 --- a/projects/account/src/app/modules/device/components/card/device-display/device-display.component.scss +++ b/projects/account/src/app/modules/device/components/card/device-display/device-display.component.scss @@ -1,6 +1,14 @@ +@import "~@angular/material/theming"; +@import 'mycroft-colors'; +@import 'components/buttons'; + mat-tab-group { mat-card-content { margin-top: 32px; height: 180px; + button { + @include action-button-primary; + background-color: mat-color($mycroft-accent, 'A100'); + } } } diff --git a/projects/account/src/app/modules/device/components/card/device-display/device-display.component.ts b/projects/account/src/app/modules/device/components/card/device-display/device-display.component.ts index 4bfc52c..f38beab 100644 --- a/projects/account/src/app/modules/device/components/card/device-display/device-display.component.ts +++ b/projects/account/src/app/modules/device/components/card/device-display/device-display.component.ts @@ -17,10 +17,13 @@ and limitations under the License. ***************************************************************************** */ import { Component, Input, OnInit } from '@angular/core'; +import { MatSnackBar, MatSnackBarConfig } from '@angular/material/snack-bar'; import { faInfoCircle, faCog, faMapMarkerAlt } from '@fortawesome/free-solid-svg-icons'; import { Device } from '@account/models/device.model'; +import { DeviceService } from '@account/http/device.service'; +import { SnackbarComponent } from 'shared'; @Component({ selector: 'account-device-info', @@ -38,10 +41,22 @@ export class DeviceDisplayComponent implements OnInit { public infoIcon = faInfoCircle; public configIcon = faCog; public locationIcon = faMapMarkerAlt; + public softwareUpdateText: string; + public softwareUpdateDisabled: boolean; - constructor() { } + constructor( + private deviceService: DeviceService, + private snackbar: MatSnackBar + ) { } ngOnInit() { + if (!this.device.pantacorUpdateId) { + this.softwareUpdateText = 'NO UPDATES AVAILABLE'; + this.softwareUpdateDisabled = true; + } else { + this.softwareUpdateText = 'APPLY SOFTWARE UPDATE'; + this.softwareUpdateDisabled = false; + } } getPlatform(device: Device) { @@ -49,4 +64,29 @@ export class DeviceDisplayComponent implements OnInit { return knownPlatform ? knownPlatform.displayName : device.platform; } + openErrorSnackbar() { + const config = new MatSnackBarConfig(); + config.data = {type: 'error', message: 'An error occurred, device will not be updated.'}; + this.snackbar.openFromComponent(SnackbarComponent, config); + } + + openSuccessSnackbar() { + const config = new MatSnackBarConfig(); + config.duration = 3000; + config.data = {type: 'success', message: 'The update will be applied to your device momentarily'}; + this.snackbar.openFromComponent(SnackbarComponent, config); + } + + applySoftwareUpdate() { + this.deviceService.applySoftwareUpdate(this.device.pantacorUpdateId).subscribe( + () => { + this.openSuccessSnackbar(); + this.softwareUpdateText = 'NO UPDATES AVAILABLE'; + this.softwareUpdateDisabled = true; + + }, + () => { this.openErrorSnackbar(); } + ); + } + } diff --git a/projects/account/src/app/modules/device/components/card/device-edit-card/device-edit-card.component.html b/projects/account/src/app/modules/device/components/card/device-edit-card/device-edit-card.component.html index f019592..42e6a32 100644 --- a/projects/account/src/app/modules/device/components/card/device-edit-card/device-edit-card.component.html +++ b/projects/account/src/app/modules/device/components/card/device-edit-card/device-edit-card.component.html @@ -37,9 +37,17 @@ - - - + + + + + diff --git a/projects/account/src/app/modules/device/components/card/device-edit-card/device-edit-card.component.ts b/projects/account/src/app/modules/device/components/card/device-edit-card/device-edit-card.component.ts index 5edb24b..70f838f 100644 --- a/projects/account/src/app/modules/device/components/card/device-edit-card/device-edit-card.component.ts +++ b/projects/account/src/app/modules/device/components/card/device-edit-card/device-edit-card.component.ts @@ -27,6 +27,7 @@ import { FormGroup } from '@angular/forms'; export class DeviceEditCardComponent implements OnInit { @Input() deviceForm: FormGroup; @Input() addDevice = false; + @Input() pantacorId: string; @Output() saveChanges = new EventEmitter(); constructor() { } diff --git a/projects/account/src/app/modules/device/pages/device-edit/device-edit.component.html b/projects/account/src/app/modules/device/pages/device-edit/device-edit.component.html index ecb068b..66e39d7 100644 --- a/projects/account/src/app/modules/device/pages/device-edit/device-edit.component.html +++ b/projects/account/src/app/modules/device/pages/device-edit/device-edit.component.html @@ -2,6 +2,7 @@ *ngIf="device$ | async" [deviceForm]="deviceForm" [addDevice]="false" + [pantacorId]="pantacorId" (saveChanges)="onExit($event)" > diff --git a/projects/account/src/app/modules/device/pages/device-edit/device-edit.component.ts b/projects/account/src/app/modules/device/pages/device-edit/device-edit.component.ts index eea4e21..bb4e59d 100644 --- a/projects/account/src/app/modules/device/pages/device-edit/device-edit.component.ts +++ b/projects/account/src/app/modules/device/pages/device-edit/device-edit.component.ts @@ -38,6 +38,7 @@ export class DeviceEditComponent implements OnInit { public deviceForm: FormGroup; private deviceId: string; public device$ = new Observable(); + public pantacorId: string; private snackbarConfig = new MatSnackBarConfig(); constructor( @@ -57,6 +58,7 @@ export class DeviceEditComponent implements OnInit { switchMap((params: ParamMap) => this.deviceService.getDevice(params.get('deviceId'))), tap((device) => { this.deviceId = device.id; + this.pantacorId = device.pantacorConfig.pantacorId; this.buildDeviceForm(device); }) ); diff --git a/projects/account/src/app/modules/device/pages/device-list/device-list.component.html b/projects/account/src/app/modules/device/pages/device-list/device-list.component.html index b820c0d..2461091 100644 --- a/projects/account/src/app/modules/device/pages/device-list/device-list.component.html +++ b/projects/account/src/app/modules/device/pages/device-list/device-list.component.html @@ -6,7 +6,7 @@ fxLayoutAlign="start center" routerLink="/devices/add" > - + ADD DEVICE @@ -49,9 +49,6 @@ - diff --git a/projects/account/src/app/modules/device/pages/device-list/device-list.component.scss b/projects/account/src/app/modules/device/pages/device-list/device-list.component.scss index 19c0554..bd8d394 100644 --- a/projects/account/src/app/modules/device/pages/device-list/device-list.component.scss +++ b/projects/account/src/app/modules/device/pages/device-list/device-list.component.scss @@ -22,7 +22,7 @@ } img { - height: 32px; + height: 48px; margin-left: 16px; margin-right: 16px; } diff --git a/projects/account/src/app/modules/device/pages/device-list/device-list.component.ts b/projects/account/src/app/modules/device/pages/device-list/device-list.component.ts index d6389af..10f33ce 100644 --- a/projects/account/src/app/modules/device/pages/device-list/device-list.component.ts +++ b/projects/account/src/app/modules/device/pages/device-list/device-list.component.ts @@ -95,6 +95,6 @@ export class DeviceListComponent implements OnInit { getDeviceIcon(device: Device) { const knownPlatform = this.platforms[device.platform]; - return knownPlatform ? knownPlatform.icon : '../assets/generic-device-icon-white.svg'; + return knownPlatform ? knownPlatform.icon : '../assets/generic-device-icon-blue.svg'; } } diff --git a/projects/account/src/app/shared/models/device.model.ts b/projects/account/src/app/shared/models/device.model.ts index 08aad8a..9783033 100644 --- a/projects/account/src/app/shared/models/device.model.ts +++ b/projects/account/src/app/shared/models/device.model.ts @@ -40,4 +40,5 @@ export interface Device { voice: Voice; wakeWord: WakeWord; pantacorConfig: PantacorConfig; + pantacorUpdateId: string; } diff --git a/projects/account/src/app/shared/models/pantacorConfig.model.ts b/projects/account/src/app/shared/models/pantacorConfig.model.ts index 047bbc3..cfd6e47 100644 --- a/projects/account/src/app/shared/models/pantacorConfig.model.ts +++ b/projects/account/src/app/shared/models/pantacorConfig.model.ts @@ -17,7 +17,7 @@ and limitations under the License. ***************************************************************************** */ export interface PantacorConfig { - autoUpdate: string; + autoUpdate: boolean; ipAddress: string; pantacorId: string; sshPublicKey: string; diff --git a/projects/account/src/assets/generic-device-icon-blue.svg b/projects/account/src/assets/generic-device-icon-blue.svg index 7325be1..046d9c7 100644 --- a/projects/account/src/assets/generic-device-icon-blue.svg +++ b/projects/account/src/assets/generic-device-icon-blue.svg @@ -1,10 +1,18 @@ - - - - - - - - - + + + + + + + + + + + diff --git a/projects/account/src/assets/generic-device-icon-white.svg b/projects/account/src/assets/generic-device-icon-white.svg index d6dcec1..6efbc73 100644 --- a/projects/account/src/assets/generic-device-icon-white.svg +++ b/projects/account/src/assets/generic-device-icon-white.svg @@ -1,10 +1,18 @@ - - - - - - - - - + + + + + + + + + + + diff --git a/projects/account/src/assets/mark-2-icon.svg b/projects/account/src/assets/mark-2-icon.svg index 7ad52fb..cfff9fe 100644 --- a/projects/account/src/assets/mark-2-icon.svg +++ b/projects/account/src/assets/mark-2-icon.svg @@ -1,6 +1,55 @@ - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +