Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,14 @@ describe('DeviceTestsComponent', () => {
});

it('should fill tests with device test values if device not present', () => {
component.deviceTestModules = {
fixture.componentRef.setInput('deviceTestModules', {
connection: {
enabled: false,
},
dns: {
enabled: true,
},
};
});
component.ngOnInit();

expect(component.test_modules.controls[0].value).toEqual(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
import {
ChangeDetectionStrategy,
Component,
effect,
input,
Input,
OnInit,
} from '@angular/core';
Expand All @@ -39,11 +41,15 @@ import { MatCheckboxModule } from '@angular/material/checkbox';
})
export class DeviceTestsComponent implements OnInit {
@Input() deviceForm!: FormGroup;
@Input() deviceTestModules?: TestModules | null;
@Input() testModules: TestModule[] = [];
// For initiate test run form tests should be displayed and disabled for change
@Input() disabled = false;

deviceTestModules = input<TestModules | undefined>();
deviceTestModulesEffect = effect(() => {
this.fillTestModulesFormControls();
});

get test_modules() {
return this.deviceForm?.controls['test_modules'] as FormArray;
}
Expand All @@ -54,11 +60,12 @@ export class DeviceTestsComponent implements OnInit {

fillTestModulesFormControls() {
this.test_modules.controls = [];
if (this.deviceTestModules) {
if (this.deviceTestModules()) {
this.testModules.forEach(test => {
this.test_modules.push(
new FormControl(
(this.deviceTestModules as TestModules)[test.name]?.enabled || false
(this.deviceTestModules() as TestModules)[test.name]?.enabled ||
false
)
);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ export class DeviceQualificationFromComponent implements OnInit, OnDestroy {
const device = this.initialDevice();
if (device && device.mac_addr) {
this.fillDeviceForm(this.format, device);
} else {
this.resetForm();
}
});

Expand Down Expand Up @@ -193,6 +195,12 @@ export class DeviceQualificationFromComponent implements OnInit, OnDestroy {
this.delete.emit(this.initialDevice()!);
}

resetForm() {
this.deviceQualificationForm.reset({
test_pack: TestingType.Qualification,
});
}

private fillDeviceForm(format: QuestionFormat[], device: Device): void {
format.forEach((question, index) => {
const answer = device.additional_info?.find(
Expand Down
Loading