// ============================================
// Upload Wizard — 5-Step Upload Flow
// ============================================
const UploadWizard = {
currentStep: 1,
uploadedFiles: [],
mappings: [],
init() {
this.renderWizardSteps();
this.bindEvents();
},
renderWizardSteps() {
const container = Helpers.$('#wizard-steps');
if (!container) return;
container.innerHTML = MockData.wizardSteps.map(ws => `
`).join('');
},
bindEvents() {
// Drop zone
const dropzone = Helpers.$('#upload-dropzone');
if (dropzone) {
dropzone.addEventListener('click', () => this.simulateFileSelect());
}
// Select folder button
const selectBtn = Helpers.$('#btn-select-folder');
if (selectBtn) {
selectBtn.addEventListener('click', () => this.simulateFileSelect());
}
// Wizard navigation
Helpers.$('#btn-wizard-prev').addEventListener('click', () => this.prevStep());
Helpers.$('#btn-wizard-next').addEventListener('click', () => this.nextStep());
// Compliance checkbox
const checkbox = Helpers.$('#compliance-checkbox');
if (checkbox) {
checkbox.addEventListener('change', () => {
Helpers.$('#btn-submit').disabled = !checkbox.checked;
});
}
// Submit button
Helpers.$('#btn-submit').addEventListener('click', () => this.submitDataset());
},
simulateFileSelect() {
// Simulate selecting a folder with images
this.uploadedFiles = MockData.images.slice(0, 8);
this.renderFileList();
this.goToStep(2);
Toast.show('Detected 8 images from 3 camera folders', 'success');
},
renderFileList() {
const container = Helpers.$('#file-list');
if (!container) return;
container.classList.remove('hidden');
container.innerHTML = `
` + this.uploadedFiles.map(img => `
${img.filename}
${img.size} · ${img.camera}
`).join('');
},
clearFiles() {
this.uploadedFiles = [];
Helpers.$('#file-list').classList.add('hidden');
this.goToStep(1);
},
renderCategoryMapping() {
const container = Helpers.$('#mapping-list');
if (!container) return;
const folders = [
{ name: 'C5 — Side View', count: 3 },
{ name: 'C6 — Top View', count: 2 },
{ name: 'C8 — Side View 3', count: 1 }
];
container.innerHTML = folders.map(f => `
${f.name}
${f.count} images
`).join('');
},
renderSecurityPipeline() {
const container = Helpers.$('#processing-pipeline');
if (!container) return;
container.innerHTML = MockData.pipelineSteps.map((ps, index) => {
const status = index < 3 ? 'completed' : (index === 3 ? 'active' : '');
return `
${index < MockData.pipelineSteps.length - 1 ? '' : ''}
`;
}).join('');
},
renderCategoryBuckets() {
const container = Helpers.$('#buckets-list');
if (!container) return;
const counts = {
good: MockData.getCategoryCount(this.uploadedFiles, 'good'),
d02: MockData.getCategoryCount(this.uploadedFiles, 'd02'),
d07: MockData.getCategoryCount(this.uploadedFiles, 'd07'),
d08: MockData.getCategoryCount(this.uploadedFiles, 'd08'),
unsorted: MockData.getCategoryCount(this.uploadedFiles, 'unsorted')
};
container.innerHTML = `
D07 Critical
${counts.d07}
Unsorted
${counts.unsorted}
`;
},
renderComplianceCheck() {
const container = Helpers.$('#compliance-check');
if (!container) return;
container.innerHTML = `
Metadata validation passed for all files
No corrupted files detected
Image dimensions verified (${this.uploadedFiles.length} files)
No duplicates found
`;
},
goToStep(step) {
this.currentStep = step;
// Update step indicators
Helpers.$$('.wizard-step').forEach(ws => {
const stepNum = parseInt(ws.dataset.step);
ws.classList.remove('wizard-step--active', 'wizard-step--completed');
if (stepNum === step) ws.classList.add('wizard-step--active');
if (stepNum < step) ws.classList.add('wizard-step--completed');
});
// Show/hide panels
Helpers.$$('.wizard-panel').forEach(panel => panel.classList.add('hidden'));
const targetPanel = Helpers.$('#wizard-panel-' + step);
if (targetPanel) targetPanel.classList.remove('hidden');
// Update buttons
Helpers.$('#btn-wizard-prev').disabled = step === 1;
const nextBtn = Helpers.$('#btn-wizard-next');
if (step === 5) {
nextBtn.style.display = 'none';
} else {
nextBtn.style.display = '';
nextBtn.innerHTML = 'Next ';
}
// Step-specific rendering
if (step === 2) this.renderCategoryMapping();
if (step === 3) this.renderSecurityPipeline();
if (step === 4) this.renderCategoryBuckets();
if (step === 5) this.renderComplianceCheck();
},
nextStep() {
if (this.currentStep < 5) this.goToStep(this.currentStep + 1);
},
prevStep() {
if (this.currentStep > 1) this.goToStep(this.currentStep - 1);
},
submitDataset() {
Toast.show('Dataset submitted successfully! ' + this.uploadedFiles.length + ' images processed.', 'success');
this.clearFiles();
App.navigate('dashboard');
}
};