mirror of
https://github.com/harvester/harvester-ui-extension.git
synced 2026-08-16 12:49:14 +00:00
feat: add migration plan duration time column (#1005)
* feat: add migration plan duration time column Signed-off-by: Andy Lee <andy.lee@suse.com> * feat: allow duration column to be sorted Signed-off-by: Andy Lee <andy.lee@suse.com> --------- Signed-off-by: Andy Lee <andy.lee@suse.com>
This commit is contained in:
parent
aea53fdd65
commit
44297ada16
@ -1947,6 +1947,7 @@ harvester:
|
|||||||
plan: Migration Plan
|
plan: Migration Plan
|
||||||
progress: Progress
|
progress: Progress
|
||||||
mappings: Mappings
|
mappings: Mappings
|
||||||
|
duration: Duration
|
||||||
progress:
|
progress:
|
||||||
failed: Failed
|
failed: Failed
|
||||||
migration: Migration
|
migration: Migration
|
||||||
|
|||||||
@ -97,6 +97,28 @@ const formatPipelineTooltip = (pipeline = []) => {
|
|||||||
.join('');
|
.join('');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const formatDuration = (started, completed) => {
|
||||||
|
if (!started || !completed) {
|
||||||
|
return { display: null, seconds: -1 };
|
||||||
|
}
|
||||||
|
|
||||||
|
const startMs = new Date(started).getTime();
|
||||||
|
const endMs = new Date(completed).getTime();
|
||||||
|
|
||||||
|
if (isNaN(startMs) || isNaN(endMs) || endMs < startMs) {
|
||||||
|
return { display: null, seconds: -1 };
|
||||||
|
}
|
||||||
|
|
||||||
|
const totalSeconds = Math.floor((endMs - startMs) / 1000);
|
||||||
|
const hours = Math.floor(totalSeconds / 3600);
|
||||||
|
const minutes = Math.floor((totalSeconds % 3600) / 60);
|
||||||
|
const seconds = totalSeconds % 60;
|
||||||
|
|
||||||
|
const display = hours > 0 ? `${ hours }h ${ minutes }m` : `${ minutes }m ${ seconds }s`;
|
||||||
|
|
||||||
|
return { display, seconds: totalSeconds };
|
||||||
|
};
|
||||||
|
|
||||||
const rows = computed(() => {
|
const rows = computed(() => {
|
||||||
return allPlans.value.map((plan) => {
|
return allPlans.value.map((plan) => {
|
||||||
const netMapName = plan.spec?.map?.network?.name;
|
const netMapName = plan.spec?.map?.network?.name;
|
||||||
@ -187,6 +209,11 @@ const rows = computed(() => {
|
|||||||
|
|
||||||
plan.progress = plan.vmProgress.length > 0 ? Math.round(plan.vmProgress.reduce((sum, vm) => sum + vm.progress, 0) / plan.vmProgress.length * 10) / 10 : 0;
|
plan.progress = plan.vmProgress.length > 0 ? Math.round(plan.vmProgress.reduce((sum, vm) => sum + vm.progress, 0) / plan.vmProgress.length * 10) / 10 : 0;
|
||||||
|
|
||||||
|
const durationResult = formatDuration(plan.status?.migration?.started, plan.status?.migration?.completed);
|
||||||
|
|
||||||
|
plan.duration = durationResult.display;
|
||||||
|
plan.durationSeconds = durationResult.seconds;
|
||||||
|
|
||||||
return plan;
|
return plan;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -210,12 +237,19 @@ const headers = [
|
|||||||
name: 'progress',
|
name: 'progress',
|
||||||
labelKey: 'harvester.addons.vmMigration.dashboard.columns.progress',
|
labelKey: 'harvester.addons.vmMigration.dashboard.columns.progress',
|
||||||
value: 'progress',
|
value: 'progress',
|
||||||
width: 500,
|
width: 450,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'mappings',
|
name: 'mappings',
|
||||||
labelKey: 'harvester.addons.vmMigration.dashboard.columns.mappings',
|
labelKey: 'harvester.addons.vmMigration.dashboard.columns.mappings',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: 'duration',
|
||||||
|
labelKey: 'harvester.addons.vmMigration.dashboard.columns.duration',
|
||||||
|
value: 'duration',
|
||||||
|
sort: 'durationSeconds',
|
||||||
|
width: 120,
|
||||||
|
},
|
||||||
{ ...AGE },
|
{ ...AGE },
|
||||||
];
|
];
|
||||||
|
|
||||||
@ -302,7 +336,17 @@ init();
|
|||||||
>
|
>
|
||||||
<template #cell:name="{ row }">
|
<template #cell:name="{ row }">
|
||||||
<div class="plan-name-cell">
|
<div class="plan-name-cell">
|
||||||
<div class="plan-name">
|
<router-link
|
||||||
|
v-if="row.detailLocation"
|
||||||
|
:to="row.detailLocation"
|
||||||
|
class="plan-name"
|
||||||
|
>
|
||||||
|
{{ row.metadata.name }}
|
||||||
|
</router-link>
|
||||||
|
<div
|
||||||
|
v-else
|
||||||
|
class="plan-name"
|
||||||
|
>
|
||||||
{{ row.metadata.name }}
|
{{ row.metadata.name }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -373,6 +417,13 @@ init();
|
|||||||
:storage-entries="row.storageEntries"
|
:storage-entries="row.storageEntries"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
<template #cell:duration="{ row }">
|
||||||
|
<span v-if="row.duration">{{ row.duration }}</span>
|
||||||
|
<span
|
||||||
|
v-else
|
||||||
|
class="text-muted"
|
||||||
|
>—</span>
|
||||||
|
</template>
|
||||||
</ResourceTable>
|
</ResourceTable>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user