diff --git a/routes/tscm.py b/routes/tscm.py index 6493cad..aad21dc 100644 --- a/routes/tscm.py +++ b/routes/tscm.py @@ -3165,12 +3165,18 @@ def list_playbooks(): try: from utils.tscm.advanced import PLAYBOOKS + # Return as array with id field for JavaScript compatibility + playbooks_list = [] + for pid, pb in PLAYBOOKS.items(): + pb_dict = pb.to_dict() + pb_dict['id'] = pid + pb_dict['name'] = pb_dict.get('title', pid) + pb_dict['category'] = pb_dict.get('risk_level', 'general') + playbooks_list.append(pb_dict) + return jsonify({ 'status': 'success', - 'playbooks': { - pid: pb.to_dict() - for pid, pb in PLAYBOOKS.items() - } + 'playbooks': playbooks_list }) except Exception as e: diff --git a/templates/index.html b/templates/index.html index 947946f..f137f6b 100644 --- a/templates/index.html +++ b/templates/index.html @@ -9402,14 +9402,14 @@ ${playbooks.map(p => `
- ${escapeHtml(p.name)} - ${escapeHtml(p.category || 'General')} + ${escapeHtml(p.name || p.title)} + ${escapeHtml(p.risk_level || p.category || 'General')}
${escapeHtml(p.description || 'No description')}
- ${p.steps?.length || 0} steps | Applies to: ${(p.applies_to || ['Any']).join(', ')} + ${p.steps?.length || 0} steps
`).join('')} @@ -9432,7 +9432,7 @@ const content = document.getElementById('tscmDeviceModalContent'); content.innerHTML = `
-

📋 ${escapeHtml(p.name)}

+

📋 ${escapeHtml(p.title || p.name || 'Playbook')}

${escapeHtml(p.description || '')}

@@ -9442,21 +9442,32 @@
    ${(p.steps || []).map((step, i) => `
  1. - ${escapeHtml(step.title || `Step ${i+1}`)} -

    ${escapeHtml(step.description || '')}

    - ${step.warning ? `
    ⚠️ ${escapeHtml(step.warning)}
    ` : ''} + ${escapeHtml(step.action || step.title || `Step ${step.step || i+1}`)} +

    ${escapeHtml(step.details || step.description || '')}

    + ${step.safety_note ? `
    ⚠️ ${escapeHtml(step.safety_note)}
    ` : ''}
  2. `).join('')}
- ${p.equipment_needed ? ` + ${p.when_to_escalate ? `
-

Equipment Needed

+

When to Escalate

+

${escapeHtml(p.when_to_escalate)}

+
+ ` : ''} + ${p.documentation_required && p.documentation_required.length > 0 ? ` +
+

Documentation Required

` : ''} + ${p.disclaimer ? ` +
+ Disclaimer: ${escapeHtml(p.disclaimer)} +
+ ` : ''}