Processing
@@ -178,7 +180,7 @@ tabs.forEach(tab => {
const target = tab.dataset.target;
tabs.forEach(t => t.classList.toggle('active', t.dataset.target === target));
contents.forEach(c => c.classList.toggle('active', c.id === target));
-
+
// Lazy load summary when tab is clicked
if (target === 'summary' && !summaryLoaded) {
loadSummary();
@@ -189,7 +191,7 @@ tabs.forEach(tab => {
// Function to load summary
function loadSummary() {
summaryLoaded = true;
- fetch('{{ url_for("import_view.import_summary_api", timestamp=timestamp) }}')
+ fetch('/app/import/api/{{ timestamp }}/summary')
.then(r => r.json())
.then(data => {
const summaryContent = document.getElementById('summaryContent');
@@ -207,7 +209,7 @@ function loadSummary() {
// Format JSON with syntax highlighting
function formatJson(obj) {
if (!obj) return '
No data available';
-
+
const json = JSON.stringify(obj, null, 2);
return json.replace(/("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?)/g, function (match) {
let cls = 'json-number';
@@ -271,7 +273,7 @@ const settingInput = document.getElementById('settingInput');
// Load facets for dropdown
function loadFacets() {
- fetch('{{ url_for("facets.facets_list") }}')
+ fetch('/facets/api/list')
.then(r => r.json())
.then(facets => {
const select = document.getElementById('facetSelect');
@@ -299,7 +301,7 @@ function watchImportProgress(importId) {
progressTiming.textContent = '';
// Listen for importer events for this import
- const cleanup = appEvents.listen('importer', msg => {
+ const cleanup = window.appEvents.listen('importer', msg => {
if (msg.import_id !== importId) return;
if (msg.event === 'started') {
@@ -334,7 +336,7 @@ document.getElementById('rerunBtn').addEventListener('click', () => {
btn.textContent = 'Starting...';
// Call the re-run endpoint
- fetch('{{ url_for("import_view.import_rerun", timestamp=timestamp) }}', {
+ fetch('/app/import/api/{{ timestamp }}/rerun', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ facet: facet, setting: setting })
@@ -361,7 +363,7 @@ document.getElementById('rerunBtn').addEventListener('click', () => {
});
// Load import details
-fetch('{{ url_for("import_view.import_detail_api", timestamp=timestamp) }}')
+fetch('/app/import/api/{{ timestamp }}')
.then(r => r.json())
.then(data => {
importData = data; // Store globally
@@ -371,7 +373,7 @@ fetch('{{ url_for("import_view.import_detail_api", timestamp=timestamp) }}')
const uploadTime = new Date(data.import_json.upload_datetime).toLocaleString();
const fileName = data.import_json.original_filename || 'Unknown';
const fileSize = formatFileSize(data.import_json.file_size);
-
+
// Determine status based on task_id and imported_json
let statusClass, statusText;
if (data.imported_json) {
@@ -385,18 +387,18 @@ fetch('{{ url_for("import_view.import_detail_api", timestamp=timestamp) }}')
statusClass = 'pending';
statusText = 'Pending';
}
-
+
metaDiv.innerHTML = `
-
${fileName} (${fileSize}) •
+
${fileName} (${fileSize}) •
Uploaded: ${uploadTime}
${statusText}
`;
}
-
+
// Update overview tab
const overviewContent = document.getElementById('overviewContent');
let overviewHtml = '';
-
+
if (data.import_json) {
overviewHtml += `
Original File:
${data.import_json.original_filename || '-'}
`;
overviewHtml += `
File Size:
${formatFileSize(data.import_json.file_size)}
`;
@@ -414,31 +416,31 @@ fetch('{{ url_for("import_view.import_detail_api", timestamp=timestamp) }}')
settingInput.value = data.import_json.setting || '';
}
}
-
+
if (data.imported_json) {
overviewHtml += `
Processing Status:
Completed
`;
overviewHtml += `
Target Day:
${data.imported_json.target_day || '-'}
`;
overviewHtml += `
Files Created:
${data.imported_json.total_files_created || 0}
`;
overviewHtml += `
Processing Time:
${new Date(data.imported_json.processing_completed).toLocaleString()}
`;
-
+
// Show quick links
if (data.imported_json.target_day) {
const linksSection = document.getElementById('linksSection');
const quickLinks = document.getElementById('quickLinks');
linksSection.style.display = 'block';
-
+
let linksHtml = '';
linksHtml += `
`;
linksHtml += `
`;
quickLinks.innerHTML = linksHtml;
}
-
+
// Show created files
if (data.imported_json.all_created_files && data.imported_json.all_created_files.length > 0) {
const filesList = document.getElementById('filesList');
const filesListContent = document.getElementById('filesListContent');
filesList.style.display = 'block';
-
+
let filesHtml = '';
data.imported_json.all_created_files.forEach(file => {
const basename = file.split('/').pop();
@@ -449,26 +451,26 @@ fetch('{{ url_for("import_view.import_detail_api", timestamp=timestamp) }}')
} else {
overviewHtml += `
Processing Status:
Pending
`;
}
-
+
overviewContent.innerHTML = overviewHtml;
-
+
// Update JSON tabs
document.getElementById('importJsonContent').innerHTML = formatJson(data.import_json);
document.getElementById('importedJsonContent').innerHTML = data.imported_json ? formatJson(data.imported_json) : '
Processing not yet completed';
-
+
// Show summary tab if summary exists
if (data.has_summary) {
const summaryTab = document.getElementById('summaryTab');
summaryTab.style.display = 'block';
}
-
+
// Show re-run section if import is completed or failed and file exists
if (data.import_json && data.import_json.file_path) {
// Show re-run section for completed or failed imports
if (data.imported_json || (data.import_json.task_id && !data.imported_json)) {
const rerunSection = document.getElementById('rerunSection');
rerunSection.style.display = 'block';
-
+
// Load facets for the dropdown
loadFacets();
}
@@ -482,4 +484,46 @@ fetch('{{ url_for("import_view.import_detail_api", timestamp=timestamp) }}')
document.getElementById('importedJsonContent').innerHTML = '
Error loading data';
});
-{% endblock %}
+
+
+
+