Driver rename and icons: `Driver.display_name` plus a `DriverIcon` table, both global/shared like the `Driver` row they hang off, so a rename or an icon is what every Owner sees. The rename/icon dialog keeps its forms as siblings (nested forms are invalid HTML) and the icon routes return an `hx-swap-oob` thumbnail refresh rather than re-rendering the table, which would tear the open `<dialog>` out of the DOM. Web image picker: `GET /web/images` renders a pickable grid for a printer or a driver icon, with the search term prefilled from the entity name and editable. Picking one downloads it server-side and normalizes it. Driver download search: `GET /web/drivers` searches for a vendor-wide driver (the term is rewritten into the vendor's real product name for 15 brands) or for the exact model as typed. Links only — nothing is downloaded, and the fragment says the results are unvetted. Icon uploads no longer reject off-size or non-PNG files: `normalize_icon()` letterboxes any decodable raster into a 256x256 PNG. An already-exact 256x256 PNG is returned byte-identical, because icon storage is content-addressed and re-encoding would move the file on every save. `fetch_image()` makes the request from the server, so `assert_fetchable()` refuses any URL resolving to a private, loopback, or link-local address, and re-runs on every redirect. ImpTune sits on the same LAN as the printers it configures; an unguarded fetcher would be a port scanner for anyone who can reach the UI. DuckDuckGo is scraped, not called through an API — no key needed, but fragile, so both search functions swallow parse failures and return [] instead of 500ing a page. `WEB_SEARCH=false` disables every outbound request and hides the controls, for air-gapped installs. Also: one shared `Jinja2Templates` in `templating.py` instead of five per-router instances, so a template global is declared once; `_add_missing_columns()` in `database.py` adds new nullable columns to a pre-existing table, which `create_tables(safe=True)` skips; `db_env` in test_db.py now closes its connection on teardown, or the next test's ORM writes land in the previous test's DB file. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
116 lines
5.1 KiB
HTML
116 lines
5.1 KiB
HTML
{% import "partials/icons.html" as ico %}
|
|
{% set usage = usage | default({}, true) %}
|
|
{% set new_driver_id = new_driver_id | default(None, true) %}
|
|
<div id="driver-list">
|
|
{% if parsed is defined and parsed.unused_files %}
|
|
<div class="notice">
|
|
<p>
|
|
{{ parsed.unused_files | length }}
|
|
<span x-data x-text="$store.i18n.t('unused_files')">file(s) in the ZIP are unused — the .inf never references them.</span>
|
|
</p>
|
|
<details>
|
|
<summary x-data x-text="$store.i18n.t('show_unused')">Show unused files</summary>
|
|
<ul>
|
|
{% for f in parsed.unused_files %}
|
|
<li>{{ f }}</li>
|
|
{% endfor %}
|
|
</ul>
|
|
</details>
|
|
</div>
|
|
{% endif %}
|
|
|
|
{% if driver_data %}
|
|
<div class="card card-flush">
|
|
<div class="table-scroll">
|
|
<table class="data-table">
|
|
<thead>
|
|
<tr>
|
|
<th x-data x-text="$store.i18n.t('driver_filename')">File</th>
|
|
<th x-data x-text="$store.i18n.t('driver_names_col')">Driver name(s)</th>
|
|
<th class="col-arch" x-data x-text="$store.i18n.t('architecture')">Architecture</th>
|
|
<th class="col-used" x-data x-text="$store.i18n.t('th_used_by')">Used by</th>
|
|
<th class="col-added" x-data x-text="$store.i18n.t('uploaded_at')">Added</th>
|
|
<th class="col-actions"><span x-data x-text="$store.i18n.t('th_actions')">Actions</span></th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
{% for item in driver_data %}
|
|
<tr>
|
|
<td>
|
|
<div class="cell-with-thumb">
|
|
{# Placeholder span keeps the id addressable so an icon saved in
|
|
the dialog can be swapped in out of band. #}
|
|
<span id="driver-thumb-{{ item.driver.id }}" class="driver-thumb">
|
|
{% if item.has_icon %}
|
|
<img src="/drivers/{{ item.driver.id }}/icon" width="24" height="24" alt="">
|
|
{% endif %}
|
|
</span>
|
|
<span>
|
|
{% if item.driver.display_name %}
|
|
<span class="cell-name">{{ item.driver.display_name }}</span>
|
|
<span class="cell-sub mono">{{ item.driver.original_filename }}</span>
|
|
{% else %}
|
|
<span class="cell-name mono">{{ item.driver.original_filename }}</span>
|
|
{% endif %}
|
|
<span class="cell-sub">
|
|
{% if item.driver.size_bytes >= 1048576 %}{{ (item.driver.size_bytes / 1048576) | round(1) }} MB{% elif item.driver.size_bytes >= 1024 %}{{ (item.driver.size_bytes / 1024) | round(0) | int }} KB{% else %}{{ item.driver.size_bytes }} B{% endif %}
|
|
{% if item.driver.inf_filename %} · {{ item.driver.inf_filename }}{% endif %}
|
|
</span>
|
|
</span>
|
|
</div>
|
|
</td>
|
|
<td>
|
|
{% if item.names %}
|
|
{# Multi-model INFs can carry a dozen names — show three, fold the rest. #}
|
|
<span class="pill-row">
|
|
{% for name in item.names[:3] %}<span class="pill">{{ name }}</span>{% endfor %}
|
|
{% if item.names | length > 3 %}
|
|
<details class="more-pills">
|
|
<summary class="pill">+{{ item.names | length - 3 }}</summary>
|
|
<span class="pill-row">
|
|
{% for name in item.names[3:] %}<span class="pill">{{ name }}</span>{% endfor %}
|
|
</span>
|
|
</details>
|
|
{% endif %}
|
|
</span>
|
|
{% else %}
|
|
<span class="faint" x-data x-text="$store.i18n.t('unknown')">Unknown</span>
|
|
{% endif %}
|
|
</td>
|
|
<td class="col-arch">
|
|
{% if item.driver.architecture %}
|
|
<span class="badge">{{ item.driver.architecture }}</span>
|
|
{% else %}
|
|
<span class="faint" x-data x-text="$store.i18n.t('unknown')">Unknown</span>
|
|
{% endif %}
|
|
</td>
|
|
<td class="num col-used">
|
|
{% set n = usage.get(item.driver.id, 0) %}
|
|
{% if n %}<a href="/printers">{{ n }}</a>{% else %}<span class="faint">0</span>{% endif %}
|
|
</td>
|
|
<td class="num col-added">
|
|
{{ item.driver.uploaded_at.strftime('%Y-%m-%d %H:%M') if item.driver.uploaded_at is not string else item.driver.uploaded_at }}
|
|
{% if new_driver_id and item.driver.id == new_driver_id %}
|
|
<span class="badge ok">{{ ico.i('check', 12) }}new</span>
|
|
{% endif %}
|
|
</td>
|
|
<td class="actions col-actions">
|
|
{% include "partials/driver_edit_modal.html" %}
|
|
</td>
|
|
</tr>
|
|
{% endfor %}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
{% else %}
|
|
<div class="card">
|
|
<div class="empty">
|
|
<span class="empty-ico">{{ ico.i('driver', 18) }}</span>
|
|
<strong x-data x-text="$store.i18n.t('no_drivers')">No drivers uploaded yet.</strong>
|
|
<p x-data x-text="$store.i18n.t('hint_driver_zip')">The ZIP must contain the .inf file and every file it references.</p>
|
|
</div>
|
|
</div>
|
|
{% endif %}
|
|
</div>
|