feat: closed batch loop — manual positions, Generate CVs, download links
This commit is contained in:
@@ -209,6 +209,7 @@ function renderBatchDetail(data) {
|
||||
<span class="badge badge-${item.match_score >= 70 ? 'green' : item.match_score >= 50 ? 'orange' : 'red'}">${item.match_score}%</span>
|
||||
<span class="badge badge-${item.status === 'approved' ? 'green' : item.status === 'removed' ? 'red' : 'orange'}">${item.status}</span>
|
||||
${item.match_reasoning ? '<div class="text-muted text-sm" style="margin-top:4px">' + escapeHtml(item.match_reasoning) + '</div>' : ''}
|
||||
${item.generated_cv_path ? '<a href="' + item.generated_cv_path + '" target="_blank" class="btn btn-sm btn-outline" style="margin-top:4px">Download CV</a>' : ''}
|
||||
</div>
|
||||
<div class="flex gap-8">
|
||||
${item.status !== 'approved' ? '<button class="btn btn-sm btn-green" onclick="approveItem(\'' + item.id + '\')">Approve</button>' : ''}
|
||||
@@ -253,6 +254,7 @@ function renderBatchDetail(data) {
|
||||
</div>
|
||||
<div class="flex gap-8">
|
||||
<button class="btn" onclick="analyzeBatch()">Analyze & Match</button>
|
||||
<button class="btn btn-green" onclick="generateBatchCVs()">Generate CVs</button>
|
||||
<button class="btn btn-outline" onclick="openBatchChat()">Discuss</button>
|
||||
<button class="btn btn-danger" onclick="deleteBatch()">Delete</button>
|
||||
<button class="btn btn-outline" onclick="closeBatchDetail()">Back</button>
|
||||
@@ -271,6 +273,41 @@ function renderBatchDetail(data) {
|
||||
</div>
|
||||
</div>
|
||||
${positionsHtml}
|
||||
<div class="card mb-16">
|
||||
<div class="card-header">
|
||||
<span class="card-title">Add Position</span>
|
||||
<button class="btn btn-sm" onclick="showAddPositionForm()">+ Add</button>
|
||||
</div>
|
||||
<div id="add-position-form" style="display:none;margin-top:12px">
|
||||
<div class="form-group">
|
||||
<label>Job Title</label>
|
||||
<input type="text" id="new-pos-title" placeholder="e.g. Senior Developer">
|
||||
</div>
|
||||
<div class="flex gap-8">
|
||||
<div class="form-group" style="flex:1">
|
||||
<label>Quantity</label>
|
||||
<input type="number" id="new-pos-qty" value="1" min="1" style="width:80px">
|
||||
</div>
|
||||
<div class="form-group" style="flex:1">
|
||||
<label>Min Years</label>
|
||||
<input type="number" id="new-pos-years" placeholder="5" style="width:80px">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Required Skills (comma-separated)</label>
|
||||
<input type="text" id="new-pos-skills" placeholder="Python, Docker, AWS">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Required Certs (comma-separated)</label>
|
||||
<input type="text" id="new-pos-certs" placeholder="AWS, CKAD">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Description</label>
|
||||
<textarea id="new-pos-desc" placeholder="Role description"></textarea>
|
||||
</div>
|
||||
<button class="btn" onclick="addPosition()">Add Position</button>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
|
||||
@@ -292,6 +329,89 @@ async function saveBatchTemplate() {
|
||||
}
|
||||
}
|
||||
|
||||
// ============================================================
|
||||
// ADD POSITION
|
||||
// ============================================================
|
||||
function showAddPositionForm() {
|
||||
const form = document.getElementById('add-position-form');
|
||||
form.style.display = form.style.display === 'none' ? 'block' : 'none';
|
||||
}
|
||||
|
||||
async function addPosition() {
|
||||
const title = document.getElementById('new-pos-title').value.trim();
|
||||
if (!title) { toast('Job title required', 'error'); return; }
|
||||
const qty = parseInt(document.getElementById('new-pos-qty').value) || 1;
|
||||
const years = document.getElementById('new-pos-years').value ? parseInt(document.getElementById('new-pos-years').value) : null;
|
||||
const skills = document.getElementById('new-pos-skills').value.split(',').map(s => s.trim()).filter(s => s);
|
||||
const certs = document.getElementById('new-pos-certs').value.split(',').map(s => s.trim()).filter(s => s);
|
||||
const desc = document.getElementById('new-pos-desc').value.trim();
|
||||
|
||||
const positions = currentBatch.batch.positions || [];
|
||||
positions.push({
|
||||
job_title: title,
|
||||
num_positions: qty,
|
||||
required_years: years,
|
||||
required_skills: skills,
|
||||
required_certs: certs,
|
||||
nice_to_have: [],
|
||||
disqualifiers: [],
|
||||
description: desc
|
||||
});
|
||||
|
||||
try {
|
||||
await fetch('/api/batches/' + currentBatchId + '/positions', {
|
||||
method: 'PUT',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ positions })
|
||||
});
|
||||
toast('Position added');
|
||||
openBatch(currentBatchId);
|
||||
} catch (e) {
|
||||
toast('Error: ' + e.message, 'error');
|
||||
}
|
||||
}
|
||||
|
||||
// ============================================================
|
||||
// GENERATE CVs
|
||||
// ============================================================
|
||||
async function generateBatchCVs() {
|
||||
if (!currentBatchId) return;
|
||||
|
||||
const templateId = currentBatch.batch.template_id;
|
||||
if (!templateId) {
|
||||
toast('Select a template first', 'error');
|
||||
return;
|
||||
}
|
||||
|
||||
const approvedCount = (currentBatch.items || []).filter(i => i.status === 'approved').length;
|
||||
if (approvedCount === 0) {
|
||||
toast('No approved candidates to generate CVs for', 'error');
|
||||
return;
|
||||
}
|
||||
|
||||
if (!confirm('Generate ' + approvedCount + ' CV(s) using the selected template?')) return;
|
||||
toast('Generating CVs... this may take a minute');
|
||||
|
||||
try {
|
||||
const resp = await fetch('/api/batches/' + currentBatchId + '/generate', { method: 'POST' });
|
||||
const data = await resp.json();
|
||||
if (resp.ok) {
|
||||
const ok = data.generated || 0;
|
||||
const failed = (data.results || []).filter(r => r.status === 'error').length;
|
||||
if (failed > 0) {
|
||||
toast('Generated ' + ok + ' CVs, ' + failed + ' failed', 'error');
|
||||
} else {
|
||||
toast('Generated ' + ok + ' CVs successfully');
|
||||
}
|
||||
openBatch(currentBatchId);
|
||||
} else {
|
||||
toast('Error: ' + (data.detail || 'Generation failed'), 'error');
|
||||
}
|
||||
} catch (e) {
|
||||
toast('Error: ' + e.message, 'error');
|
||||
}
|
||||
}
|
||||
|
||||
function closeBatchDetail() {
|
||||
document.getElementById('batches-list-view').style.display = 'block';
|
||||
document.getElementById('batch-detail-view').style.display = 'none';
|
||||
|
||||
@@ -203,6 +203,6 @@
|
||||
|
||||
<script src="/static/app.js?v=19"></script>
|
||||
<script src="/static/carbone.js?v=16"></script>
|
||||
<script src="/static/batches.js?v=2"></script>
|
||||
<script src="/static/batches.js?v=3"></script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user