diff --git a/packages/forklift-console-plugin/locales/en/plugin__forklift-console-plugin.json b/packages/forklift-console-plugin/locales/en/plugin__forklift-console-plugin.json index f78448971..b39f9324b 100644 --- a/packages/forklift-console-plugin/locales/en/plugin__forklift-console-plugin.json +++ b/packages/forklift-console-plugin/locales/en/plugin__forklift-console-plugin.json @@ -112,7 +112,8 @@ "Description": "Description", "Details": "Details", "Determines the frequency with which the system checks the status of snapshot creation or removal during oVirt warm migration. The default value is 10 seconds.": "Determines the frequency with which the system checks the status of snapshot creation or removal during oVirt warm migration. The default value is 10 seconds.", - "Disk Transfer": "Disk Transfer", + "Disk counter": "Disk counter", + "Disk transfer": "Disk transfer", "Do not try to preserve the static IPs of VMs with Windows guest operating system from vSphere.": "Do not try to preserve the static IPs of VMs with Windows guest operating system from vSphere.", "Domain": "Domain", "Domain name": "Domain name", diff --git a/packages/forklift-console-plugin/src/modules/Plans/views/details/tabs/VirtualMachines/Migration/MigrationVirtualMachinesList.tsx b/packages/forklift-console-plugin/src/modules/Plans/views/details/tabs/VirtualMachines/Migration/MigrationVirtualMachinesList.tsx index 07b996164..790f26e00 100644 --- a/packages/forklift-console-plugin/src/modules/Plans/views/details/tabs/VirtualMachines/Migration/MigrationVirtualMachinesList.tsx +++ b/packages/forklift-console-plugin/src/modules/Plans/views/details/tabs/VirtualMachines/Migration/MigrationVirtualMachinesList.tsx @@ -112,7 +112,20 @@ const fieldsMetadataFactory: ResourceFieldFactory = (t) => [ ? diskTransfer?.progress?.completed / diskTransfer?.progress?.total : 0; }, - label: t('Disk Transfer'), + label: t('Disk transfer'), + isVisible: true, + sortable: true, + }, + { + resourceFieldId: 'diskCounter', + jsonPath: (obj: VMData) => { + const diskTransfer = obj.statusVM?.pipeline.find((p) => p.name === 'DiskTransfer'); + + return diskTransfer && diskTransfer?.progress?.total + ? diskTransfer?.progress?.completed / diskTransfer?.progress?.total + : 0; + }, + label: t('Disk counter'), isVisible: true, sortable: true, }, diff --git a/packages/forklift-console-plugin/src/modules/Plans/views/details/tabs/VirtualMachines/Migration/MigrationVirtualMachinesRow.tsx b/packages/forklift-console-plugin/src/modules/Plans/views/details/tabs/VirtualMachines/Migration/MigrationVirtualMachinesRow.tsx index 54819bbad..c6ab062df 100644 --- a/packages/forklift-console-plugin/src/modules/Plans/views/details/tabs/VirtualMachines/Migration/MigrationVirtualMachinesRow.tsx +++ b/packages/forklift-console-plugin/src/modules/Plans/views/details/tabs/VirtualMachines/Migration/MigrationVirtualMachinesRow.tsx @@ -51,11 +51,26 @@ const cellRenderers: Record> = { p?.name?.startsWith('DiskTransfer'), ); const annotations: { unit: string } = diskTransfer?.annotations as undefined; + const { completed, total } = getTransferProgress(diskTransfer); return annotations?.unit ? ( <> - {diskTransfer?.progress?.completed || '-'} / {diskTransfer?.progress?.total || '-'}{' '} - {annotations?.unit || '-'} + {completed} / {total} {annotations?.unit || '-'} + + ) : ( + <>- + ); + }, + diskCounter: (props: PlanVMsCellProps) => { + const diskTransfer = props.data.statusVM?.pipeline.find((p) => + p?.name?.startsWith('DiskTransfer'), + ); + + const { totalTasks, completedTasks } = countTasks(diskTransfer); + + return totalTasks ? ( + <> + {completedTasks || '-'} / {totalTasks || '-'} Discs ) : ( <>- @@ -200,3 +215,26 @@ export const getIcon: GetIconType = (p) => { return undefined; } }; + +const countTasks = (diskTransfer: V1beta1PlanStatusMigrationVmsPipeline) => { + if (!diskTransfer || !Array.isArray(diskTransfer?.tasks)) { + return { totalTasks: 0, completedTasks: 0 }; + } + + const totalTasks = diskTransfer.tasks.length; + const completedTasks = diskTransfer.tasks.filter((task) => task.phase === 'Completed').length; + + return { totalTasks, completedTasks }; +}; + +const getTransferProgress = (diskTransfer) => { + if (!diskTransfer || !diskTransfer.progress) { + return { completed: '-', total: '-' }; + } + + const { completed, total } = diskTransfer.progress; + return { + completed: completed !== undefined ? completed : '-', + total: total !== undefined ? total : '-', + }; +};