Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NAS-133723 / 25.10 / Adds "Enable VLAN" checkbox and sends null when disabled #11495

Merged
merged 7 commits into from
Feb 12, 2025
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
3 changes: 2 additions & 1 deletion src/app/interfaces/ipmi.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export interface Ipmi {
mac_addresss: string;
subnet_mask: string;
vlan_id: number;
vlan_id_enable: boolean;
vlan_priority: number;
}

Expand All @@ -29,7 +30,7 @@ export interface IpmiUpdate {
gateway: string;
ipaddress: string;
netmask: string;
vlan: unknown;
vlan: number;
password: string;
apply_remote: boolean;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,19 @@
[tooltip]="helptext.gateway_tooltip | translate"
></ix-input>

<ix-input
formControlName="vlan"
type="number"
[label]="'VLAN ID' | translate"
[tooltip]="helptext.vlan_tooltip | translate"
></ix-input>
<ix-checkbox
formControlName="vlan_id_enable"
[label]="'Enable VLAN' | translate"
></ix-checkbox>
@if (vlanEnabled()) {
<ix-input
formControlName="vlan_id"
type="number"
[required]="true"
[label]="'VLAN ID' | translate"
[tooltip]="helptext.vlan_tooltip | translate"
></ix-input>
}
</ix-fieldset>
<mat-divider></mat-divider>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ describe('IpmiFormComponent', () => {
let spectator: Spectator<IpmiFormComponent>;
let loader: HarnessLoader;
let form: IxFormHarness;
let api: ApiService;
let productType: ProductType;

const slideInRef: SlideInRef<number | undefined, unknown> = {
Expand Down Expand Up @@ -80,6 +79,8 @@ describe('IpmiFormComponent', () => {
id: 1,
ip_address: '10.220.15.115',
subnet_mask: '255.255.240.0',
vlan_id_enable: true,
vlan_id: 3,
}] as Ipmi[];
}

Expand All @@ -90,6 +91,8 @@ describe('IpmiFormComponent', () => {
id: 1,
ip_address: '10.220.15.114',
subnet_mask: '255.255.240.0',
vlan_id_enable: true,
vlan_id: 2,
}] as Ipmi[];
}),
mockCall('ipmi.lan.update', {
Expand Down Expand Up @@ -118,7 +121,6 @@ describe('IpmiFormComponent', () => {
});
loader = TestbedHarnessEnvironment.loader(spectator.fixture);
form = await loader.getHarness(IxFormHarness);
api = spectator.inject(ApiService);
}

describe('product type is SCALE_ENTERPRISE', () => {
Expand All @@ -135,7 +137,8 @@ describe('IpmiFormComponent', () => {
'IPv4 Default Gateway': '10.220.0.1',
'IPv4 Address': '10.220.15.114',
'IPv4 Netmask': '255.255.240.0',
'VLAN ID': '',
'Enable VLAN': true,
'VLAN ID': '2',
Password: '',
});
});
Expand All @@ -153,7 +156,8 @@ describe('IpmiFormComponent', () => {
'IPv4 Default Gateway': '10.220.0.2',
'IPv4 Netmask': '255.255.240.0',
Password: '',
'VLAN ID': '',
'Enable VLAN': true,
'VLAN ID': '3',
});
});

Expand All @@ -176,17 +180,19 @@ describe('IpmiFormComponent', () => {
'IPv4 Default Gateway': '10.220.0.1',
'IPv4 Address': '10.220.15.114',
'IPv4 Netmask': '255.255.240.0',
'VLAN ID': '',
'Enable VLAN': true,
'VLAN ID': '2',
Password: '',
});
const saveButton = await loader.getHarness(MatButtonHarness.with({ text: 'Save' }));
await saveButton.click();

expect(api.call).toHaveBeenCalledWith('ipmi.lan.update', [1, {
expect(spectator.inject(ApiService).call).toHaveBeenCalledWith('ipmi.lan.update', [1, {
dhcp: false,
ipaddress: '10.220.15.114',
gateway: '10.220.0.1',
netmask: '255.255.240.0',
vlan: 2,
}]);
expect(spectator.inject(SlideInRef).close).toHaveBeenCalled();
expect(spectator.inject(SnackbarService).success).toHaveBeenCalledWith('Successfully saved IPMI settings.');
Expand All @@ -200,17 +206,44 @@ describe('IpmiFormComponent', () => {
'IPv4 Default Gateway': '10.220.0.2',
'IPv4 Netmask': '255.255.240.0',
Password: '',
'VLAN ID': '',
'Enable VLAN': true,
'VLAN ID': '2',
});
const saveButton = await loader.getHarness(MatButtonHarness.with({ text: 'Save' }));
await saveButton.click();

expect(api.call).toHaveBeenCalledWith('ipmi.lan.update', [1, {
expect(spectator.inject(ApiService).call).toHaveBeenLastCalledWith('ipmi.lan.update', [1, {
dhcp: false,
ipaddress: '10.220.15.115',
gateway: '10.220.0.2',
netmask: '255.255.240.0',
apply_remote: true,
vlan: 2,
}]);
expect(spectator.inject(SlideInRef).close).toHaveBeenCalled();
expect(spectator.inject(SnackbarService).success).toHaveBeenCalledWith('Successfully saved IPMI settings.');
});

it('updates remote controller data and closes modal when save is pressed with vlan disabled', async () => {
await form.fillForm({
'Remote Controller': 'Standby: TrueNAS Controller 2',
DHCP: false,
'IPv4 Address': '10.220.15.115',
'IPv4 Default Gateway': '10.220.0.2',
'IPv4 Netmask': '255.255.240.0',
Password: '',
'Enable VLAN': false,
});
const saveButton = await loader.getHarness(MatButtonHarness.with({ text: 'Save' }));
await saveButton.click();

expect(spectator.inject(ApiService).call).toHaveBeenLastCalledWith('ipmi.lan.update', [1, {
dhcp: false,
ipaddress: '10.220.15.115',
gateway: '10.220.0.2',
netmask: '255.255.240.0',
apply_remote: true,
vlan: null,
}]);
expect(spectator.inject(SlideInRef).close).toHaveBeenCalled();
expect(spectator.inject(SnackbarService).success).toHaveBeenCalledWith('Successfully saved IPMI settings.');
Expand All @@ -230,7 +263,8 @@ describe('IpmiFormComponent', () => {
'IPv4 Default Gateway': '10.220.0.1',
'IPv4 Address': '10.220.15.114',
'IPv4 Netmask': '255.255.240.0',
'VLAN ID': '',
'Enable VLAN': true,
'VLAN ID': '2',
Password: '',
});
});
Expand All @@ -245,7 +279,7 @@ describe('IpmiFormComponent', () => {
const flashButton = await loader.getHarness(MatButtonHarness.with({ text: 'Flash Identify Light' }));
await flashButton.click();

expect(api.call).toHaveBeenLastCalledWith('ipmi.chassis.identify', [OnOff.On]);
expect(spectator.inject(ApiService).call).toHaveBeenLastCalledWith('ipmi.chassis.identify', [OnOff.On]);
});

it('stops flashing IPMI light when Flash Identify Light is pressed again', async () => {
Expand All @@ -254,7 +288,7 @@ describe('IpmiFormComponent', () => {
const stopFlashing = await loader.getHarness(MatButtonHarness.with({ text: 'Stop Flashing' }));
await stopFlashing.click();

expect(api.call).toHaveBeenLastCalledWith('ipmi.chassis.identify', [OnOff.Off]);
expect(spectator.inject(ApiService).call).toHaveBeenLastCalledWith('ipmi.chassis.identify', [OnOff.Off]);
});
});
});
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {
ChangeDetectionStrategy, ChangeDetectorRef, Component, OnInit,
} from '@angular/core';
import { toSignal } from '@angular/core/rxjs-interop';
import { Validators, ReactiveFormsModule } from '@angular/forms';
import { MatButton } from '@angular/material/button';
import { MatCard, MatCardContent, MatCardActions } from '@angular/material/card';
Expand Down Expand Up @@ -100,7 +101,8 @@ export class IpmiFormComponent implements OnInit {
this.translate.instant(helptextIpmi.ip_error),
),
]],
vlan: new FormControl(null as number | null),
vlan_id_enable: [false],
vlan_id: [null as number | null, [Validators.required]],
password: ['', [
this.validatorsService.withMessage(
Validators.maxLength(20),
Expand All @@ -109,6 +111,8 @@ export class IpmiFormComponent implements OnInit {
]],
});

vlanEnabled = toSignal(this.form.controls.vlan_id_enable.valueChanges);

constructor(
private api: ApiService,
private translate: TranslateService,
Expand Down Expand Up @@ -211,7 +215,8 @@ export class IpmiFormComponent implements OnInit {
ipaddress: ipmi.ip_address || '',
netmask: ipmi.subnet_mask || '',
gateway: ipmi.default_gateway_ip_address || '',
vlan: ipmi.vlan_id || null,
vlan_id: ipmi.vlan_id || null,
vlan_id_enable: ipmi.vlan_id_enable,
});
}

Expand Down Expand Up @@ -255,16 +260,23 @@ export class IpmiFormComponent implements OnInit {
onSubmit(): void {
this.isLoading = true;

const updateParams: IpmiUpdate = { ...this.form.value };
const updateParams: IpmiUpdate = {
dhcp: this.form.value.dhcp,
gateway: this.form.value.gateway,
ipaddress: this.form.value.ipaddress,
netmask: this.form.value.netmask,
vlan: this.form.value.vlan_id_enable ? this.form.value.vlan_id : null,
password: this.form.value.password,
apply_remote: this.form.value.apply_remote,
};

if (!updateParams.apply_remote) {
delete updateParams.apply_remote;
}
if (!updateParams.password) {
delete updateParams.password;
}
if (!updateParams.vlan) {
delete updateParams.vlan;
}

this.api.call('ipmi.lan.update', [this.ipmiId, updateParams])
.pipe(untilDestroyed(this))
.subscribe({
Expand Down
1 change: 1 addition & 0 deletions src/assets/i18n/af.json
Original file line number Diff line number Diff line change
Expand Up @@ -1585,6 +1585,7 @@
"Enable Time Machine backups on this share.": "",
"Enable Two Factor Authentication Globally": "",
"Enable Two Factor Authentication for SSH": "",
"Enable VLAN": "",
"Enable VNC": "",
"Enable for TrueNAS to periodically review data blocks and identify empty blocks, or obsolete blocks that can be deleted. Unset to use dirty block overwrites (default).": "",
"Enable iXsystems Proactive Support": "",
Expand Down
1 change: 1 addition & 0 deletions src/assets/i18n/ar.json
Original file line number Diff line number Diff line change
Expand Up @@ -1585,6 +1585,7 @@
"Enable Time Machine backups on this share.": "",
"Enable Two Factor Authentication Globally": "",
"Enable Two Factor Authentication for SSH": "",
"Enable VLAN": "",
"Enable VNC": "",
"Enable for TrueNAS to periodically review data blocks and identify empty blocks, or obsolete blocks that can be deleted. Unset to use dirty block overwrites (default).": "",
"Enable iXsystems Proactive Support": "",
Expand Down
1 change: 1 addition & 0 deletions src/assets/i18n/ast.json
Original file line number Diff line number Diff line change
Expand Up @@ -1585,6 +1585,7 @@
"Enable Time Machine backups on this share.": "",
"Enable Two Factor Authentication Globally": "",
"Enable Two Factor Authentication for SSH": "",
"Enable VLAN": "",
"Enable VNC": "",
"Enable for TrueNAS to periodically review data blocks and identify empty blocks, or obsolete blocks that can be deleted. Unset to use dirty block overwrites (default).": "",
"Enable iXsystems Proactive Support": "",
Expand Down
1 change: 1 addition & 0 deletions src/assets/i18n/az.json
Original file line number Diff line number Diff line change
Expand Up @@ -1585,6 +1585,7 @@
"Enable Time Machine backups on this share.": "",
"Enable Two Factor Authentication Globally": "",
"Enable Two Factor Authentication for SSH": "",
"Enable VLAN": "",
"Enable VNC": "",
"Enable for TrueNAS to periodically review data blocks and identify empty blocks, or obsolete blocks that can be deleted. Unset to use dirty block overwrites (default).": "",
"Enable iXsystems Proactive Support": "",
Expand Down
1 change: 1 addition & 0 deletions src/assets/i18n/be.json
Original file line number Diff line number Diff line change
Expand Up @@ -1585,6 +1585,7 @@
"Enable Time Machine backups on this share.": "",
"Enable Two Factor Authentication Globally": "",
"Enable Two Factor Authentication for SSH": "",
"Enable VLAN": "",
"Enable VNC": "",
"Enable for TrueNAS to periodically review data blocks and identify empty blocks, or obsolete blocks that can be deleted. Unset to use dirty block overwrites (default).": "",
"Enable iXsystems Proactive Support": "",
Expand Down
1 change: 1 addition & 0 deletions src/assets/i18n/bg.json
Original file line number Diff line number Diff line change
Expand Up @@ -1585,6 +1585,7 @@
"Enable Time Machine backups on this share.": "",
"Enable Two Factor Authentication Globally": "",
"Enable Two Factor Authentication for SSH": "",
"Enable VLAN": "",
"Enable VNC": "",
"Enable for TrueNAS to periodically review data blocks and identify empty blocks, or obsolete blocks that can be deleted. Unset to use dirty block overwrites (default).": "",
"Enable iXsystems Proactive Support": "",
Expand Down
1 change: 1 addition & 0 deletions src/assets/i18n/bn.json
Original file line number Diff line number Diff line change
Expand Up @@ -1585,6 +1585,7 @@
"Enable Time Machine backups on this share.": "",
"Enable Two Factor Authentication Globally": "",
"Enable Two Factor Authentication for SSH": "",
"Enable VLAN": "",
"Enable VNC": "",
"Enable for TrueNAS to periodically review data blocks and identify empty blocks, or obsolete blocks that can be deleted. Unset to use dirty block overwrites (default).": "",
"Enable iXsystems Proactive Support": "",
Expand Down
1 change: 1 addition & 0 deletions src/assets/i18n/br.json
Original file line number Diff line number Diff line change
Expand Up @@ -1585,6 +1585,7 @@
"Enable Time Machine backups on this share.": "",
"Enable Two Factor Authentication Globally": "",
"Enable Two Factor Authentication for SSH": "",
"Enable VLAN": "",
"Enable VNC": "",
"Enable for TrueNAS to periodically review data blocks and identify empty blocks, or obsolete blocks that can be deleted. Unset to use dirty block overwrites (default).": "",
"Enable iXsystems Proactive Support": "",
Expand Down
1 change: 1 addition & 0 deletions src/assets/i18n/bs.json
Original file line number Diff line number Diff line change
Expand Up @@ -1585,6 +1585,7 @@
"Enable Time Machine backups on this share.": "",
"Enable Two Factor Authentication Globally": "",
"Enable Two Factor Authentication for SSH": "",
"Enable VLAN": "",
"Enable VNC": "",
"Enable for TrueNAS to periodically review data blocks and identify empty blocks, or obsolete blocks that can be deleted. Unset to use dirty block overwrites (default).": "",
"Enable iXsystems Proactive Support": "",
Expand Down
1 change: 1 addition & 0 deletions src/assets/i18n/ca.json
Original file line number Diff line number Diff line change
Expand Up @@ -1585,6 +1585,7 @@
"Enable Time Machine backups on this share.": "",
"Enable Two Factor Authentication Globally": "",
"Enable Two Factor Authentication for SSH": "",
"Enable VLAN": "",
"Enable VNC": "",
"Enable for TrueNAS to periodically review data blocks and identify empty blocks, or obsolete blocks that can be deleted. Unset to use dirty block overwrites (default).": "",
"Enable iXsystems Proactive Support": "",
Expand Down
1 change: 1 addition & 0 deletions src/assets/i18n/cs.json
Original file line number Diff line number Diff line change
Expand Up @@ -1225,6 +1225,7 @@
"Enable Time Machine backups on this share.": "",
"Enable Two Factor Authentication Globally": "",
"Enable Two Factor Authentication for SSH": "",
"Enable VLAN": "",
"Enable VNC": "",
"Enable for TrueNAS to periodically review data blocks and identify empty blocks, or obsolete blocks that can be deleted. Unset to use dirty block overwrites (default).": "",
"Enable iXsystems Proactive Support": "",
Expand Down
1 change: 1 addition & 0 deletions src/assets/i18n/cy.json
Original file line number Diff line number Diff line change
Expand Up @@ -1585,6 +1585,7 @@
"Enable Time Machine backups on this share.": "",
"Enable Two Factor Authentication Globally": "",
"Enable Two Factor Authentication for SSH": "",
"Enable VLAN": "",
"Enable VNC": "",
"Enable for TrueNAS to periodically review data blocks and identify empty blocks, or obsolete blocks that can be deleted. Unset to use dirty block overwrites (default).": "",
"Enable iXsystems Proactive Support": "",
Expand Down
1 change: 1 addition & 0 deletions src/assets/i18n/da.json
Original file line number Diff line number Diff line change
Expand Up @@ -1585,6 +1585,7 @@
"Enable Time Machine backups on this share.": "",
"Enable Two Factor Authentication Globally": "",
"Enable Two Factor Authentication for SSH": "",
"Enable VLAN": "",
"Enable VNC": "",
"Enable for TrueNAS to periodically review data blocks and identify empty blocks, or obsolete blocks that can be deleted. Unset to use dirty block overwrites (default).": "",
"Enable iXsystems Proactive Support": "",
Expand Down
1 change: 1 addition & 0 deletions src/assets/i18n/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -1162,6 +1162,7 @@
"Enable TLS": "",
"Enable Two Factor Authentication Globally": "",
"Enable Two Factor Authentication for SSH": "",
"Enable VLAN": "",
"Enable VNC": "",
"Enable for TrueNAS to periodically review data blocks and identify empty blocks, or obsolete blocks that can be deleted. Unset to use dirty block overwrites (default).": "",
"Enable or disable NICs.": "",
Expand Down
1 change: 1 addition & 0 deletions src/assets/i18n/dsb.json
Original file line number Diff line number Diff line change
Expand Up @@ -1585,6 +1585,7 @@
"Enable Time Machine backups on this share.": "",
"Enable Two Factor Authentication Globally": "",
"Enable Two Factor Authentication for SSH": "",
"Enable VLAN": "",
"Enable VNC": "",
"Enable for TrueNAS to periodically review data blocks and identify empty blocks, or obsolete blocks that can be deleted. Unset to use dirty block overwrites (default).": "",
"Enable iXsystems Proactive Support": "",
Expand Down
1 change: 1 addition & 0 deletions src/assets/i18n/el.json
Original file line number Diff line number Diff line change
Expand Up @@ -1585,6 +1585,7 @@
"Enable Time Machine backups on this share.": "",
"Enable Two Factor Authentication Globally": "",
"Enable Two Factor Authentication for SSH": "",
"Enable VLAN": "",
"Enable VNC": "",
"Enable for TrueNAS to periodically review data blocks and identify empty blocks, or obsolete blocks that can be deleted. Unset to use dirty block overwrites (default).": "",
"Enable iXsystems Proactive Support": "",
Expand Down
1 change: 1 addition & 0 deletions src/assets/i18n/en-au.json
Original file line number Diff line number Diff line change
Expand Up @@ -1585,6 +1585,7 @@
"Enable Time Machine backups on this share.": "",
"Enable Two Factor Authentication Globally": "",
"Enable Two Factor Authentication for SSH": "",
"Enable VLAN": "",
"Enable VNC": "",
"Enable for TrueNAS to periodically review data blocks and identify empty blocks, or obsolete blocks that can be deleted. Unset to use dirty block overwrites (default).": "",
"Enable iXsystems Proactive Support": "",
Expand Down
Loading
Loading