const result = await response.json();
- if (response.ok) {
- showDropdownStatus(
- "success",
- `✅ Successfully imported ${result.imported} tools`,
- );
- resetDropdownImport();
- setTimeout(() => {
- window.location.reload();
- }, 2000);
- } else {
- showDropdownStatus(
- "error",
- `❌ Import failed: ${result.detail || "Unknown error"}`,
- );
+ // Collapse sample template section
+ if (sampleSection) {
+ sampleSection.style.display = 'none';
}
+
+ // Show detailed import results
+ if (importResultSection) {
+ importResultSection.classList.remove('hidden');
+
+ const totalTools = data.length;
+ const imported = result.imported || 0;
+ const failed = totalTools - imported;
+
+ let resultHTML = `
+
+
📊 Import Results
+
+
+
${totalTools}
+
Total
+
+
+
${imported}
+
Uploaded
+
+
+
+ `;
+
+ if (response.ok && imported > 0) {
+ resultHTML += `
✅ Successfully imported ${imported} tool${imported !== 1 ? 's' : ''}
`;
+ }
+
+ if (failed > 0) {
+ resultHTML += `
❌ ${failed} tool${failed !== 1 ? 's' : ''} failed to import
`;
+ if (result.detail) {
+ resultHTML += `
Error: ${result.detail}
`;
+ }
+ }
+
+ resultHTML += `
+
+
+ `;
+
+ importResultSection.innerHTML = resultHTML;
+ }
+
+ status.classList.add('hidden');
+
} catch (error) {
showDropdownStatus("error", `❌ Network error: ${error.message}`);
} finally {
@@ -11622,6 +11667,10 @@
}
};
+ window.closeImportResult = function() {
+ window.location.reload();
+ };
+
// Close dropdown when clicking outside
document.addEventListener("click", function (event) {
const dropdown = document.getElementById("bulk-import-dropdown");