This commit is contained in:
2026-06-25 13:35:50 -05:00
parent ff94c0cce5
commit dfc2c9b475
6 changed files with 96 additions and 3 deletions

View File

@@ -425,6 +425,7 @@
:loading="vcenterImportLoading"
:error="vcenterImportError"
:status="vcenterImportStatus"
:diagnostics="vcenterImportDiagnostics"
@close="vcenterImportOpen = false"
@preview="previewVCenterImport"
@import="importVCenterHosts"
@@ -980,6 +981,7 @@ const vcenterImportLoading = ref(false);
const vcenterImportError = ref('');
const vcenterPreviewRows = ref([]);
const vcenterImportStatus = ref(null);
const vcenterImportDiagnostics = ref(null);
const credentialModalOpen = ref(false);
const runPlanModalOpen = ref(false);
const variableModalOpen = ref(false);
@@ -2349,6 +2351,7 @@ async function saveHost() {
async function openVCenterImport() {
vcenterImportOpen.value = true;
vcenterImportError.value = '';
vcenterImportDiagnostics.value = null;
try {
vcenterImportStatus.value = await api.get('/api/hosts/import/vcenter/status');
} catch (err) {
@@ -2362,8 +2365,9 @@ async function previewVCenterImport(payload) {
try {
const result = await api.post('/api/hosts/import/vcenter/preview', payload);
vcenterImportStatus.value = result.status;
vcenterImportDiagnostics.value = result.diagnostics || null;
vcenterPreviewRows.value = result.candidates || [];
notify(`Found ${result.count || 0} vCenter host candidate(s)`);
notify(`Found ${result.count || 0} vCenter host candidate(s) from ${result.diagnostics?.totalFromVCenter ?? 'unknown'} VM(s)`);
} catch (err) {
vcenterImportError.value = err.message;
notify(err.message, 'error');
@@ -2379,6 +2383,7 @@ async function importVCenterHosts(payload) {
const result = await api.post('/api/hosts/import/vcenter', payload);
await refreshAll();
vcenterPreviewRows.value = [];
vcenterImportDiagnostics.value = null;
vcenterImportOpen.value = false;
const skipped = result.skipped?.length || 0;
notify(`Imported ${result.imported?.length || 0} host(s)${skipped ? `, skipped ${skipped} duplicate(s)` : ''}`);

View File

@@ -115,6 +115,13 @@
</div>
</div>
<div v-if="error" class="inline-error">{{ error }}</div>
<div v-if="diagnostics" class="vcenter-diagnostics">
<strong>Preview diagnostics</strong>
<span>{{ diagnostics.totalFromVCenter }} VM(s) returned by vCenter</span>
<span>{{ diagnostics.summaryMatched }} VM(s) matched before guest enrichment</span>
<span>{{ diagnostics.scanned }} VM(s) scanned for guest FQDN/IP details</span>
<small v-if="diagnostics.sampleNames?.length">Sample inventory names: {{ diagnostics.sampleNames.join(', ') }}</small>
</div>
<div class="preview-toolbar">
<button class="ghost-button compact" type="button" :disabled="!previewRows.length" @click="toggleAll">
<CheckSquare :size="15" />{{ allSelected ? 'Clear selection' : 'Select all' }}
@@ -177,7 +184,8 @@ const props = defineProps({
groups: { type: Array, default: () => [] },
loading: Boolean,
error: { type: String, default: '' },
status: { type: Object, default: null }
status: { type: Object, default: null },
diagnostics: { type: Object, default: null }
});
const emit = defineEmits(['close', 'preview', 'import']);

View File

@@ -6981,6 +6981,40 @@ input:read-only {
margin-bottom: 12px;
}
.vcenter-diagnostics {
display: flex;
flex-wrap: wrap;
gap: 8px;
align-items: center;
margin-bottom: 12px;
padding: 10px 12px;
border: 1px solid rgba(117, 216, 255, .16);
border-radius: 14px;
color: rgba(219, 227, 255, .7);
background: rgba(88, 221, 255, .055);
}
.vcenter-diagnostics strong {
color: rgba(255, 255, 255, .9);
}
.vcenter-diagnostics span {
display: inline-flex;
align-items: center;
min-height: 24px;
padding: 4px 8px;
border-radius: 999px;
border: 1px solid rgba(139, 224, 255, .14);
background: rgba(3, 8, 18, .35);
font-size: .76rem;
}
.vcenter-diagnostics small {
flex-basis: 100%;
color: rgba(219, 227, 255, .52);
overflow-wrap: anywhere;
}
.vcenter-preview-table {
position: relative;
overflow: auto;