-
Notifications
You must be signed in to change notification settings - Fork 323
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
NAS-133051 / 25.04 / Reorganize iSCSI wizard + NAS-133051 new form co…
…ntrols to handle fibre ports (#11207) * NAS-133051: Reorganize iSCSI wizard * NAS-133051: Build form controls to handle fibre ports * NAS-133051: Add FibreChannelService * NAS-133051: Add unit tests * NAS-133051: Fix remarks
- Loading branch information
1 parent
147c20c
commit 713074e
Showing
109 changed files
with
1,215 additions
and
207 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
...ages/sharing/iscsi/fibre-channel-ports/fc-ports-controls/fc-ports-controls.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<ix-radio-group | ||
[formControl]="isNewControl" | ||
[options]="isNewOptions$" | ||
></ix-radio-group> | ||
<ng-container [formGroup]="form()"> | ||
@if(isNewControl.value) { | ||
<ix-select | ||
formControlName="host_id" | ||
[label]="'Choose a new virtual port' | translate" | ||
[options]="creatingPortOptions$" | ||
[required]="true" | ||
></ix-select> | ||
} @else { | ||
<ix-select | ||
formControlName="port" | ||
[label]="'Existing Ports' | translate" | ||
[options]="existingPortOptions$" | ||
[required]="true" | ||
></ix-select> | ||
} | ||
</ng-container> |
81 changes: 81 additions & 0 deletions
81
.../pages/sharing/iscsi/fibre-channel-ports/fc-ports-controls/fc-ports-controls.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
import { | ||
ChangeDetectionStrategy, Component, input, OnInit, | ||
} from '@angular/core'; | ||
import { ReactiveFormsModule } from '@angular/forms'; | ||
import { FormBuilder } from '@ngneat/reactive-forms'; | ||
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'; | ||
import { TranslateService, TranslateModule } from '@ngx-translate/core'; | ||
import { map, Observable, of } from 'rxjs'; | ||
import { Option, nullOption, skipOption } from 'app/interfaces/option.interface'; | ||
import { IxRadioGroupComponent } from 'app/modules/forms/ix-forms/components/ix-radio-group/ix-radio-group.component'; | ||
import { IxSelectComponent } from 'app/modules/forms/ix-forms/components/ix-select/ix-select.component'; | ||
import { TargetFormComponent } from 'app/pages/sharing/iscsi/target/target-form/target-form.component'; | ||
import { ApiService } from 'app/services/websocket/api.service'; | ||
|
||
@UntilDestroy() | ||
@Component({ | ||
selector: 'ix-fc-ports-controls', | ||
templateUrl: './fc-ports-controls.component.html', | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
standalone: true, | ||
imports: [ | ||
ReactiveFormsModule, | ||
IxSelectComponent, | ||
IxRadioGroupComponent, | ||
TranslateModule, | ||
], | ||
}) | ||
export class FcPortsControlsComponent implements OnInit { | ||
form = input.required<TargetFormComponent['fcForm']>(); | ||
isEdit = input(false); | ||
|
||
isNewControl = this.fb.control(false); | ||
|
||
readonly isNewOptions$: Observable<Option<boolean>[]> = of([ | ||
{ label: this.translate.instant('Use an existing port'), value: false }, | ||
{ label: this.translate.instant('Create new virtual port'), value: true }, | ||
]); | ||
|
||
readonly creatingPortOptions$ = this.api.call('fc.fc_host.query').pipe(map((hosts) => { | ||
return hosts.map((host) => ({ | ||
label: `${this.translate.instant('Create')} ${host.alias}/${host.npiv + 1}`, | ||
value: host.id, | ||
})); | ||
})); | ||
|
||
readonly existingPortOptions$ = this.api.call('fcport.port_choices', [false]).pipe(map((ports) => { | ||
const option = [{ | ||
label: this.translate.instant('Do not connect to a fibre channel port'), | ||
value: nullOption, | ||
}]; | ||
|
||
if (this.isEdit()) { | ||
option.push({ | ||
label: this.translate.instant('Use current port'), | ||
value: skipOption, | ||
}); | ||
} | ||
return option.concat(Object.entries(ports).map(([value]) => ({ label: value, value }))); | ||
})); | ||
|
||
constructor( | ||
private fb: FormBuilder, | ||
private api: ApiService, | ||
private translate: TranslateService, | ||
) {} | ||
|
||
ngOnInit(): void { | ||
this.form().controls.host_id.disable(); | ||
this.isNewControl.valueChanges.pipe(untilDestroyed(this)).subscribe((isNew) => { | ||
if (isNew) { | ||
this.form().controls.port.disable(); | ||
this.form().controls.host_id.enable(); | ||
this.form().controls.port.setValue(null); | ||
} else { | ||
this.form().controls.port.enable(); | ||
this.form().controls.host_id.disable(); | ||
this.form().controls.host_id.setValue(null); | ||
} | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.