|
|
|
@ -35,6 +35,7 @@ import { TranslateService } from '@ngx-translate/core'; |
|
|
|
import { EntityTableConfig } from '@home/models/entity/entities-table-config.models'; |
|
|
|
import { Subject } from 'rxjs'; |
|
|
|
import { OtaUpdateType } from '@shared/models/ota-package.models'; |
|
|
|
import { distinctUntilChanged } from 'rxjs/operators'; |
|
|
|
|
|
|
|
@Component({ |
|
|
|
selector: 'tb-device', |
|
|
|
@ -78,7 +79,7 @@ export class DeviceComponent extends EntityComponent<DeviceInfo> { |
|
|
|
} |
|
|
|
|
|
|
|
buildForm(entity: DeviceInfo): FormGroup { |
|
|
|
return this.fb.group( |
|
|
|
const form = this.fb.group( |
|
|
|
{ |
|
|
|
name: [entity ? entity.name : '', [Validators.required]], |
|
|
|
deviceProfileId: [entity ? entity.deviceProfileId : null, [Validators.required]], |
|
|
|
@ -95,6 +96,17 @@ export class DeviceComponent extends EntityComponent<DeviceInfo> { |
|
|
|
) |
|
|
|
} |
|
|
|
); |
|
|
|
form.get('deviceProfileId').valueChanges.pipe( |
|
|
|
distinctUntilChanged((prev, curr) => prev?.id === curr?.id) |
|
|
|
).subscribe(profileId => { |
|
|
|
if (profileId && this.isEdit) { |
|
|
|
this.entityForm.patchValue({ |
|
|
|
firmwareId: null, |
|
|
|
softwareId: null |
|
|
|
}, {emitEvent: false}); |
|
|
|
} |
|
|
|
}); |
|
|
|
return form; |
|
|
|
} |
|
|
|
|
|
|
|
updateForm(entity: DeviceInfo) { |
|
|
|
@ -156,10 +168,6 @@ export class DeviceComponent extends EntityComponent<DeviceInfo> { |
|
|
|
this.entityForm.markAsDirty(); |
|
|
|
} |
|
|
|
} |
|
|
|
this.entityForm.patchValue({ |
|
|
|
firmwareId: null, |
|
|
|
softwareId: null |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|