diff --git a/src/app/app.component.html b/src/app/app.component.html
index 8b941d9..20c0476 100644
--- a/src/app/app.component.html
+++ b/src/app/app.component.html
@@ -11,5 +11,5 @@
\ No newline at end of file
diff --git a/src/app/components/testrunner/testrunner.component.ts b/src/app/components/testrunner/testrunner.component.ts
index ebffa0a..181e006 100644
--- a/src/app/components/testrunner/testrunner.component.ts
+++ b/src/app/components/testrunner/testrunner.component.ts
@@ -1,5 +1,5 @@
-import { ChangeDetectorRef, Component, Input, OnInit, ViewChild } from '@angular/core';
+import { ChangeDetectorRef, Component, Input, OnDestroy, OnInit, ViewChild } from '@angular/core';
import { MatStepper } from '@angular/material/stepper';
import { ActivatedRoute } from '@angular/router';
import { FirmwareMessage } from 'src/app//model/firmware-message';
@@ -9,13 +9,15 @@ import { EspPortService } from 'src/app/shared/esp-port.service';
import { Partition, PartitionProgress, sleep, TestState } from 'src/app/shared/utils.service';
import { TestResultService } from 'src/app/shared/test-result.service';
import { TestResult } from 'src/app/model/test-result';
+import { Subscription } from 'rxjs';
+
@Component({
selector: 'app-testrunner',
templateUrl: './testrunner.component.html',
styleUrls: ['./testrunner.component.scss']
})
-export class TestrunnerComponent implements OnInit {
+export class TestrunnerComponent implements OnInit, OnDestroy {
deviceId: string;
title = 'ThingPulse Hardware Test Tool';
@@ -23,7 +25,6 @@ export class TestrunnerComponent implements OnInit {
@ViewChild('stepper') stepper: MatStepper;
-
private connected = false;
private monitoring = false;
messageArea: string = "";
@@ -34,6 +35,7 @@ export class TestrunnerComponent implements OnInit {
progresses: PartitionProgress[] = new Array();
deviceConfiguration: DeviceConfiguration;
+ private subscriptions: Subscription = new Subscription();
constructor(private espPortService: EspPortService,
private route: ActivatedRoute,
@@ -43,24 +45,29 @@ export class TestrunnerComponent implements OnInit {
}
ngOnInit(): void {
+ console.log("init TestrunnerComponent");
this.deviceId = this.route.snapshot.paramMap.get("deviceId")!;
console.log("deviceId: ", this.deviceId);
this.deviceConfigurationService.getDeviceConfigurationById(this.deviceId).then(configuration => {
this.deviceConfiguration = configuration!;
})
- this.espPortService.portStateStream.subscribe(isConnected => {
+ const portStateStreamSubscription = this.espPortService.portStateStream.subscribe(isConnected => {
console.log("isConnected: ", isConnected);
this.connected = isConnected;
- })
- this.espPortService.monitorStateStream.subscribe(isMonitoring => {
+ });
+ this.subscriptions.add(portStateStreamSubscription);
+ const monitorStateSubscription = this.espPortService.monitorStateStream.subscribe(isMonitoring => {
console.log("isMonitoring: ", isMonitoring);
this.monitoring = isMonitoring;
- })
- this.espPortService.flashProgressStream.subscribe(progress => {
-
+ });
+ this.subscriptions.add(monitorStateSubscription);
+
+ const flashProgressStreamSubscription = this.espPortService.flashProgressStream.subscribe(progress => {
this.progresses[progress.index] = progress;
- })
- this.espPortService.monitorMessageStream.subscribe(message => {
+ });
+ this.subscriptions.add(flashProgressStreamSubscription);
+
+ const monitorStreamSubscription = this.espPortService.monitorMessageStream.subscribe(message => {
try {
this.firmwareMessages = JSON.parse(message);
this.espPortService.stopMonitor();
@@ -74,7 +81,8 @@ export class TestrunnerComponent implements OnInit {
}
})
- this.espPortService.testStateStream.subscribe(state => {
+ this.subscriptions.add(monitorStreamSubscription);
+ const testStateStreamSubscription = this.espPortService.testStateStream.subscribe(state => {
console.log("Test State: ", state);
switch(state) {
case TestState.Restarting:
@@ -92,8 +100,12 @@ export class TestrunnerComponent implements OnInit {
}
});
+ this.subscriptions.add(testStateStreamSubscription);
}
+ ngOnDestroy(): void {
+ this.subscriptions.unsubscribe();
+ }
resetState() {
this.messageArea = ""
diff --git a/src/app/home/home.component.html b/src/app/home/home.component.html
index 249c86f..111ec6d 100644
--- a/src/app/home/home.component.html
+++ b/src/app/home/home.component.html
@@ -15,6 +15,5 @@
Device Class
-
diff --git a/src/app/home/home.component.ts b/src/app/home/home.component.ts
index 911908b..4a59f00 100644
--- a/src/app/home/home.component.ts
+++ b/src/app/home/home.component.ts
@@ -1,8 +1,6 @@
import { Component, OnInit } from '@angular/core';
import { DeviceConfiguration } from '../model/device-configuration';
import { DeviceConfigurationService } from '../shared/device-configuration.service';
-import { TestResultService } from '../shared/test-result.service';
-import { TestResult } from '../model/test-result';
@Component({
selector: 'app-home',
@@ -13,7 +11,7 @@ export class HomeComponent implements OnInit {
deviceConfigurations: DeviceConfiguration[];
- constructor(public deviceConfigurationService: DeviceConfigurationService, private testResultService: TestResultService) {
+ constructor(public deviceConfigurationService: DeviceConfigurationService) {
}
@@ -38,21 +36,6 @@ export class HomeComponent implements OnInit {
return this.deviceConfigurationService.isLocalConfiguration(id);
}
- sendResult() {
- const testResult = {
- mac_address: '00:1A:2B:3C:4D:5E',
- overall_result: 'OK',
- device_type: 'DeviceTypeA',
- additional_info: {
- test1: 'pass',
- test2: 'fail'
- }
- };
-
- this.testResultService.sendTestResult(testResult).subscribe(response => {
- console.log('Test result sent successfully:', response);
- });
- }
}