Skip to content

Commit

Permalink
fix: profile now handles direct connection mode correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike authored and rsdmike committed Oct 17, 2024
1 parent 1f4f2dd commit b4dff71
Showing 1 changed file with 25 additions and 19 deletions.
44 changes: 25 additions & 19 deletions src/app/profiles/profile-detail/profile-detail.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -392,27 +392,33 @@ export class ProfileDetailComponent implements OnInit {
}

connectionModeChange(value: string): void {
if (this.cloudMode) {
if (value === this.connectionMode.tls) {
this.profileForm.controls.ciraConfigName.clearValidators()
this.profileForm.controls.ciraConfigName.setValue(null)
this.profileForm.controls.tlsMode.setValidators(Validators.required)
// set a default value if not set already
if (!this.profileForm.controls.tlsSigningAuthority.value) {
this.profileForm.controls.tlsSigningAuthority.setValue(this.tlsDefaultSigningAuthority)
}
this.profileForm.controls.tlsSigningAuthority.setValidators(Validators.required)
} else if (value === this.connectionMode.cira) {
this.profileForm.controls.tlsMode.clearValidators()
this.profileForm.controls.tlsMode.setValue(null)
this.profileForm.controls.tlsSigningAuthority.clearValidators()
this.profileForm.controls.tlsSigningAuthority.setValue(null)
this.profileForm.controls.ciraConfigName.setValidators(Validators.required)
if (value === this.connectionMode.tls) {
this.profileForm.controls.ciraConfigName.clearValidators()
this.profileForm.controls.ciraConfigName.setValue(null)
this.profileForm.controls.tlsMode.setValidators(Validators.required)
// set a default value if not set already
if (!this.profileForm.controls.tlsSigningAuthority.value) {
this.profileForm.controls.tlsSigningAuthority.setValue(this.tlsDefaultSigningAuthority)
}
this.profileForm.controls.ciraConfigName.updateValueAndValidity()
this.profileForm.controls.tlsMode.updateValueAndValidity()
this.profileForm.controls.tlsSigningAuthority.updateValueAndValidity()
this.profileForm.controls.tlsSigningAuthority.setValidators(Validators.required)
} else if (value === this.connectionMode.cira) {
this.profileForm.controls.tlsMode.clearValidators()
this.profileForm.controls.tlsMode.setValue(null)
this.profileForm.controls.tlsSigningAuthority.clearValidators()
this.profileForm.controls.tlsSigningAuthority.setValue(null)
this.profileForm.controls.ciraConfigName.setValidators(Validators.required)
} else if (value === this.connectionMode.direct) {
this.profileForm.controls.ciraConfigName.clearValidators()
this.profileForm.controls.ciraConfigName.setValue(null)
this.profileForm.controls.tlsMode.clearValidators()
this.profileForm.controls.tlsMode.setValue(null)
this.profileForm.controls.tlsSigningAuthority.clearValidators()
this.profileForm.controls.tlsSigningAuthority.setValue(null)
}

this.profileForm.controls.ciraConfigName.updateValueAndValidity()
this.profileForm.controls.tlsMode.updateValueAndValidity()
this.profileForm.controls.tlsSigningAuthority.updateValueAndValidity()
}

selectWifiProfile(event: MatAutocompleteSelectedEvent): void {
Expand Down

0 comments on commit b4dff71

Please sign in to comment.