Skip to content

Commit

Permalink
NAS-132491: PR update
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexKarpov98 committed Nov 15, 2024
1 parent 04850bf commit 5547273
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 24 deletions.
32 changes: 16 additions & 16 deletions src/app/interfaces/vm-device.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,40 +3,40 @@ import {
VmDeviceType, VmDiskMode, VmDisplayType, VmNicType,
} from 'app/enums/vm.enum';

export interface BaseVmDevice<T> {
export interface BaseVmDevice {
id: number;
dtype: VmDeviceType;
attributes: T;
attributes: unknown;
order: number;
vm: number;
}

export interface VmPciPassthroughDevice extends BaseVmDevice<VmPciPassthroughAttributes> {
dtype: VmDeviceType.Pci;
export interface VmPciPassthroughDevice extends BaseVmDevice {
attributes: VmPciPassthroughAttributes;
}

export interface VmUsbPassthroughDevice extends BaseVmDevice<VmUsbPassthroughAttributes> {
dtype: VmDeviceType.Usb;
export interface VmUsbPassthroughDevice extends BaseVmDevice {
attributes: VmUsbPassthroughAttributes;
}

export interface VmDisplayDevice extends BaseVmDevice<VmDisplayAttributes> {
dtype: VmDeviceType.Display;
export interface VmDisplayDevice extends BaseVmDevice {
attributes: VmDisplayAttributes;
}

export interface VmCdRomDevice extends BaseVmDevice<VmCdRomAttributes> {
dtype: VmDeviceType.Cdrom;
export interface VmCdRomDevice extends BaseVmDevice {
attributes: VmCdRomAttributes;
}

export interface VmRawFileDevice extends BaseVmDevice<VmRawFileAttributes> {
dtype: VmDeviceType.Raw;
export interface VmRawFileDevice extends BaseVmDevice {
attributes: VmRawFileAttributes;
}

export interface VmNicDevice extends BaseVmDevice<VmNicAttributes> {
dtype: VmDeviceType.Nic;
export interface VmNicDevice extends BaseVmDevice {
attributes: VmNicAttributes;
}

export interface VmDiskDevice extends BaseVmDevice<VmDiskAttributes> {
dtype: VmDeviceType.Disk;
export interface VmDiskDevice extends BaseVmDevice {
attributes: VmDiskAttributes;
}

export type VmDevice =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,11 @@ describe('DeviceDetailsComponent', () => {

it('shows device attributes in a list', () => {
const attributes = spectator.queryAll('.attributes div');
expect(attributes).toHaveLength(6);
expect(attributes[0]).toHaveText('dtype: DISPLAY');
expect(attributes[1]).toHaveText('web: true');
expect(attributes[2]).toHaveText('port: 720');
expect(attributes[3]).toHaveText('wait: true');
expect(attributes[4]).toHaveText('type: SPICE');
expect(attributes[5]).toHaveText('resolution: 1024x768');
expect(attributes).toHaveLength(5);
expect(attributes[0]).toHaveText('web: true');
expect(attributes[1]).toHaveText('port: 720');
expect(attributes[2]).toHaveText('wait: true');
expect(attributes[3]).toHaveText('type: SPICE');
expect(attributes[4]).toHaveText('resolution: 1024x768');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export class DeviceDetailsComponent {
private translate: TranslateService,
@Inject(MAT_DIALOG_DATA) protected device: VmDevice,
) {
this.attributes = Object.entries(device.attributes);
this.attributes = Object.entries(device.attributes).filter(([key]) => key !== 'dtype');
}

get title(): string {
Expand Down

0 comments on commit 5547273

Please sign in to comment.