feat(05-02): printer detail page with export buttons and command preview

- Update printer_detail() to pass install_cmd, uninstall_cmd, has_driver, has_icon to template
- Rewrite printer_detail.html with Intune Commands, Export, and Icon sections
- Show command strings with Alpine.js copy-to-clipboard buttons (install-cmd, uninstall-cmd)
- Show NinjaRMM ZIP and .intunewin download links when driver assigned
- Add HTMX icon upload form with #icon-status swap target
- Remove disabled placeholder Regenerate Package button
- Add TestCommandPreview class (4 tests) to test_packages.py
- All 94 tests pass
This commit is contained in:
2026-04-10 15:06:45 +02:00
parent f9e13ba96f
commit f96ea6fec9
7 changed files with 210 additions and 19 deletions
+38 -4
View File
@@ -24,10 +24,44 @@
<p>No driver assigned</p>
{% endif %}
<h2>Actions</h2>
<button disabled aria-busy="false" title="Available after script generation is implemented (Phase 4)">
Regenerate Package
</button>
{% if has_driver %}
<h2>Intune Commands</h2>
<div x-data="{ copiedInstall: false }">
<label>Install command</label>
<code id="install-cmd">{{ install_cmd }}</code>
<button @click="
const text = document.getElementById('install-cmd').innerText;
navigator.clipboard.writeText(text).then(() => { copiedInstall = true; setTimeout(() => copiedInstall = false, 2000) })
.catch(() => { /* fallback: text is visible for manual copy */ })
" x-text="copiedInstall ? 'Copied!' : 'Copy'" class="secondary outline"></button>
</div>
<div x-data="{ copiedUninstall: false }">
<label>Uninstall command</label>
<code id="uninstall-cmd">{{ uninstall_cmd }}</code>
<button @click="
const text = document.getElementById('uninstall-cmd').innerText;
navigator.clipboard.writeText(text).then(() => { copiedUninstall = true; setTimeout(() => copiedUninstall = false, 2000) })
.catch(() => { /* fallback: text is visible for manual copy */ })
" x-text="copiedUninstall ? 'Copied!' : 'Uninstall copy'" class="secondary outline"></button>
</div>
<h2>Export</h2>
<a href="/printers/{{ printer.id }}/packages/ninja" role="button">Download NinjaRMM ZIP</a>
<a href="/printers/{{ printer.id }}/packages/intunewin" role="button">Download .intunewin</a>
{% endif %}
<h2>Icon</h2>
{% if has_icon %}
<p>Icon uploaded</p>
{% endif %}
<form hx-post="/printers/{{ printer.id }}/icon"
hx-target="#icon-status" hx-swap="innerHTML"
enctype="multipart/form-data">
<input type="file" name="file" accept="image/png" required>
<button type="submit">Upload Icon</button>
</form>
<div id="icon-status"></div>
<a href="/printers" role="button" class="secondary">Back to Printers</a>
</article>
{% endblock %}