feat: client software overview based on netbox-slm

New page "Client Software Übersicht" in a "Software" group of the netbox-inventory
menu (fallback: own Hardware menu). It shows, per tenant or tenant group
including subgroups, the software products recorded with netbox-slm, their
versions and the clients they are installed on: key figures, charts of the most
widespread products and their version distribution, a sortable and searchable
product list, a drill-down per product/version with the list of clients, and a
CSV export. Without an own selection the global tenant filter applies; the
device role filter is pre-set to the configured client roles.

Devices with a client role (software_device_roles, default "Clients") get a
"Software" tab listing their installations with add, edit and delete actions.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
MrBlakeandClaude Opus 5.5 committed 2026-11-18 14:18:59 +01:00
1 parent 5d6c4c9cd8
commit 63b3b31763
15 files changed
+1209 -3

No files matched your search

@@ -0,0 +1,77 @@
{% extends 'dcim/device/base.html' %}
{% load helpers %}
{% block content %}
<div class="card">
<div class="card-header d-flex flex-wrap gap-2 align-items-center">
<h2 class="card-title me-auto mb-0">
<i class="mdi mdi-package-variant me-1" aria-hidden="true"></i>Installierte Software
<span class="badge text-bg-secondary ms-1">{{ entries|length }}</span>
</h2>
{% if entries|length > 8 %}
<input type="search" class="form-control form-control-sm w-auto" data-nbu-sw-search="#nbu-sw-device-software"
placeholder="Software filtern …" aria-label="Software filtern">
{% endif %}
<a href="{{ overview_url }}" class="btn btn-sm btn-outline-secondary" title="Client Software Übersicht für den Mandanten dieses Geräts">
<i class="mdi mdi-chart-bar" aria-hidden="true"></i> Übersicht{% if object.tenant %} {{ object.tenant }}{% endif %}
</a>
{% if can_add %}
<a href="{{ add_url }}" class="btn btn-sm btn-primary"><i class="mdi mdi-plus-thick" aria-hidden="true"></i> Software hinzufügen</a>
{% endif %}
</div>
{% if entries %}
<div class="table-responsive">
<table class="table table-hover table-vcenter mb-0" id="nbu-sw-device-software">
<thead>
<tr>
<th data-nbu-sort="text">Software</th>
<th data-nbu-sort="text">Hersteller</th>
<th data-nbu-sort="text">Version</th>
<th>Release</th>
<th data-nbu-sort="text">Support-Ende</th>
<th></th>
</tr>
</thead>
<tbody>
{% for entry in entries %}
{% with product=entry.software_product version=entry.version %}
<tr>
<td><a href="{{ product.get_absolute_url }}" class="fw-bold">{{ product }}</a></td>
<td>{{ product.manufacturer|placeholder }}</td>
<td><a href="{{ version.get_absolute_url }}">{{ version }}</a></td>
<td>{{ version.get_release_type_display|placeholder }}</td>
<td>
{% if version.end_of_support %}
{% if version.end_of_support < today %}
<span class="badge text-bg-danger" title="Support abgelaufen">{{ version.end_of_support|isodate }}</span>
{% else %}{{ version.end_of_support|isodate }}{% endif %}
{% else %}<span class="text-muted">—</span>{% endif %}
</td>
<td class="text-end text-nowrap">
{% if can_change %}
<a href="{% url 'plugins:netbox_slm:softwareproductinstallation_edit' pk=entry.pk %}?return_url={{ tab_url|urlencode }}" class="btn btn-sm btn-warning" title="Bearbeiten">
<i class="mdi mdi-pencil" aria-hidden="true"></i>
</a>
{% endif %}
{% if can_delete %}
<a href="{% url 'plugins:netbox_slm:softwareproductinstallation_delete' pk=entry.pk %}?return_url={{ tab_url|urlencode }}" class="btn btn-sm btn-danger" title="Entfernen">
<i class="mdi mdi-trash-can-outline" aria-hidden="true"></i>
</a>
{% endif %}
</td>
</tr>
{% endwith %}
{% endfor %}
</tbody>
</table>
</div>
{% else %}
<div class="card-body text-center text-muted py-5">
<i class="mdi mdi-package-variant-closed mdi-48px d-block mb-2" aria-hidden="true"></i>
Für dieses Gerät ist noch keine Software erfasst.
{% if can_add %}<div class="mt-3"><a href="{{ add_url }}" class="btn btn-primary"><i class="mdi mdi-plus-thick" aria-hidden="true"></i> Software hinzufügen</a></div>{% endif %}
</div>
{% endif %}
</div>
{% include 'netbox_utilities/inc/software_table_js.html' %}
{% endblock %}
@@ -0,0 +1,115 @@
{% load helpers %}
<nav class="mb-2" aria-label="Navigation">
<a href="?{{ filter_query }}" class="btn btn-sm btn-outline-secondary">
<i class="mdi mdi-arrow-left" aria-hidden="true"></i> Alle Software-Produkte
</a>
</nav>
<div class="row row-cards mb-3">
<div class="col-12 col-xl-5">
<div class="card h-100">
<div class="card-header d-flex align-items-center">
<div class="me-auto">
<h2 class="card-title mb-0">{{ product.name }}</h2>
<div class="text-muted small">{{ product.manufacturer|default:"Kein Hersteller" }}</div>
</div>
{% if product_obj %}
<a href="{{ product_obj.get_absolute_url }}" class="btn btn-sm btn-outline-primary" title="Produkt in netbox-slm öffnen">
<i class="mdi mdi-open-in-new" aria-hidden="true"></i> Produkt
</a>
{% endif %}
</div>
<div class="card-body">
<div class="row text-center mb-3">
<div class="col"><div class="nbu-sw-kpi-value">{{ product.device_count }}</div><div class="nbu-sw-kpi-label">Rechner</div></div>
<div class="col"><div class="nbu-sw-kpi-value">{{ product.share }} %</div><div class="nbu-sw-kpi-label">der Rechner</div></div>
<div class="col"><div class="nbu-sw-kpi-value">{{ product.version_count }}</div><div class="nbu-sw-kpi-label">Versionen</div></div>
</div>
{% with item=product %}{% include 'netbox_utilities/inc/software_version_stack.html' %}{% endwith %}
</div>
</div>
</div>
<div class="col-12 col-xl-7">
<div class="card h-100">
<h2 class="card-header">Rechner je Version <span class="text-muted fw-normal small ms-1">anklicken zum Filtern</span></h2>
<div class="card-body">
<ul class="nbu-sw-bars list-unstyled mb-0">
{% for version in product.versions_by_name %}
<li>
<a href="?{{ filter_query }}&product={{ product.id }}{% if selected_version.id != version.id %}&version={{ version.id }}{% endif %}"
class="nbu-sw-bar-row{% if selected_version.id == version.id %} active{% endif %}"
aria-current="{% if selected_version.id == version.id %}true{% else %}false{% endif %}">
<span class="nbu-sw-bar-label">
{{ version.name }}
{% if forloop.first %}<span class="badge text-bg-green ms-1">neueste</span>{% endif %}
{% if version.support_expired %}<span class="badge text-bg-danger ms-1" title="Support-Ende {{ version.end_of_support|isodate }}">EoS</span>{% endif %}
</span>
<span class="nbu-sw-bar-track"><span class="nbu-sw-bar-fill{% if version.support_expired %} nbu-sw-expired{% endif %}" style="width: {{ version.share }}%; --nbu-sw-shade: {{ version.shade }}%"></span></span>
<span class="nbu-sw-bar-value">{{ version.device_count }}<span class="text-muted"> · {{ version.share }} %</span></span>
</a>
</li>
{% endfor %}
</ul>
</div>
</div>
</div>
</div>
<div class="card">
<div class="card-header d-flex flex-wrap gap-2 align-items-center">
<h2 class="card-title me-auto mb-0">
Installiert auf
<span class="badge text-bg-secondary ms-1">{{ entries|length }}</span>
{% if selected_version %}
<a href="?{{ filter_query }}&product={{ product.id }}" class="badge text-bg-primary ms-1 text-decoration-none" title="Versionsfilter entfernen">
Version {{ selected_version.name }} <i class="mdi mdi-close" aria-hidden="true"></i>
</a>
{% endif %}
</h2>
<input type="search" class="form-control form-control-sm w-auto" data-nbu-sw-search="#nbu-sw-devices"
placeholder="Rechner, Mandant, Standort …" aria-label="Rechnerliste filtern">
</div>
<div class="table-responsive">
<table class="table table-hover table-vcenter mb-0" id="nbu-sw-devices">
<thead>
<tr>
<th data-nbu-sort="text">Rechner</th>
<th data-nbu-sort="text">Mandant</th>
<th data-nbu-sort="text">Standort</th>
<th data-nbu-sort="text">Rolle</th>
<th data-nbu-sort="text">Version</th>
<th data-nbu-sort="text">Support-Ende</th>
<th></th>
</tr>
</thead>
<tbody>
{% for entry in entries %}
{% with device=entry.device version=entry.version %}
<tr>
<td><a href="{% url 'dcim:device_software' pk=device.pk %}" class="fw-bold">{{ device }}</a></td>
<td>{{ device.tenant|linkify|placeholder }}</td>
<td>{{ device.site|linkify|placeholder }}</td>
<td>{{ device.role|placeholder }}</td>
<td>
{{ version.name }}
{% if product.latest_version.id == version.id %}<span class="badge text-bg-green ms-1">neueste</span>{% endif %}
</td>
<td>
{% if version.end_of_support %}
<span class="{% if version.end_of_support < today %}text-danger fw-bold{% endif %}">{{ version.end_of_support|isodate }}</span>
{% else %}<span class="text-muted">—</span>{% endif %}
</td>
<td class="text-end">
<a href="{{ entry.get_absolute_url }}" class="btn btn-sm btn-outline-secondary" title="Installation öffnen">
<i class="mdi mdi-open-in-new" aria-hidden="true"></i>
</a>
</td>
</tr>
{% endwith %}
{% empty %}
<tr><td colspan="7" class="text-muted text-center py-4">Keine Installationen.</td></tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
@@ -0,0 +1,41 @@
<script>
document.addEventListener("DOMContentLoaded", () => {
// Liste filtern: Zeilen ausblenden, deren Suchtext nicht passt
for (const input of document.querySelectorAll("[data-nbu-sw-search]")) {
const rows = document.querySelectorAll(`${input.dataset.nbuSwSearch} tbody tr`);
input.addEventListener("input", () => {
const terms = input.value.toLowerCase().split(/\s+/).filter(Boolean);
for (const row of rows) {
const text = row.dataset.nbuSearch || row.textContent.toLowerCase();
row.hidden = !terms.every((term) => text.includes(term));
}
});
}
// Sortieren per Klick auf den Spaltenkopf
for (const header of document.querySelectorAll("th[data-nbu-sort]")) {
header.classList.add("nbu-sw-sortable");
header.tabIndex = 0;
const sort = () => {
const table = header.closest("table");
const index = [...header.parentElement.children].indexOf(header);
const numeric = header.dataset.nbuSort === "number";
const ascending = header.getAttribute("aria-sort") !== "ascending";
for (const other of header.parentElement.children) other.removeAttribute("aria-sort");
header.setAttribute("aria-sort", ascending ? "ascending" : "descending");
const body = table.tBodies[0];
const value = (row) => {
const cell = row.children[index];
return numeric ? Number(cell.dataset.value ?? cell.textContent) || 0 : cell.textContent.trim().toLowerCase();
};
const rows = [...body.rows].sort((a, b) => {
const [x, y] = [value(a), value(b)];
const result = numeric ? x - y : x.localeCompare(y, "de", { numeric: true });
return ascending ? result : -result;
});
body.append(...rows);
};
header.addEventListener("click", sort);
header.addEventListener("keydown", (event) => { if (event.key === "Enter" || event.key === " ") { event.preventDefault(); sort(); } });
}
});
</script>
@@ -0,0 +1,7 @@
<span class="nbu-sw-stack" role="img" aria-label="Versionsverteilung {{ item.name }}: {% for version in item.versions_by_name %}{{ version.name }} {{ version.device_count }} Rechner{% if not forloop.last %}, {% endif %}{% endfor %}">
{% for version in item.versions_by_name %}
<span class="nbu-sw-stack-part{% if version.support_expired %} nbu-sw-expired{% endif %}"
style="flex-grow: {{ version.device_count }}; --nbu-sw-shade: {{ version.shade }}%"
title="{{ version.name }}: {{ version.device_count }} Rechner ({{ version.share }} %){% if version.support_expired %} · Support abgelaufen{% endif %}"></span>
{% endfor %}
</span>
@@ -0,0 +1,196 @@
{% extends 'base/layout.html' %}
{% load helpers %}
{% block title %}{% if product %}{{ product.name }} · {% endif %}Client Software Übersicht{% endblock %}
{% block controls %}
<div class="btn-list">
<a href="?{{ filter_query }}{% if product %}&product={{ product.id }}{% if selected_version %}&version={{ selected_version.id }}{% endif %}{% endif %}&export=csv"
class="btn btn-purple" title="Aktuelle Auswahl als CSV (Excel) herunterladen">
<i class="mdi mdi-download" aria-hidden="true"></i> CSV exportieren
</a>
{% if can_add %}
<a href="{% url 'plugins:netbox_slm:softwareproductinstallation_add' %}?return_url={{ request.get_full_path|urlencode }}" class="btn btn-primary">
<i class="mdi mdi-plus-thick" aria-hidden="true"></i> Installation erfassen
</a>
{% endif %}
</div>
{% endblock controls %}
{% block content %}
{# Filter #}
<form method="get" class="card mb-3 nbu-sw-filter">
<input type="hidden" name="submitted" value="1">
{% if product %}<input type="hidden" name="product" value="{{ product.id }}">{% endif %}
<div class="card-body">
<div class="row g-3 align-items-end">
<div class="col-12 col-md-6 col-xl-3">
<label class="form-label" for="{{ form.tenant_group_id.id_for_label }}">Mandantengruppe</label>
{{ form.tenant_group_id }}
</div>
<div class="col-12 col-md-6 col-xl-3">
<label class="form-label" for="{{ form.tenant_id.id_for_label }}">Mandant</label>
{{ form.tenant_id }}
</div>
<div class="col-12 col-md-6 col-xl-2">
<label class="form-label" for="{{ form.role_id.id_for_label }}">Gerätrolle</label>
{{ form.role_id }}
</div>
<div class="col-12 col-md-6 col-xl-2">
<label class="form-label" for="id_q">Software suchen</label>
<input type="search" name="q" id="id_q" value="{{ form.q.value|default:'' }}" class="form-control"
placeholder="Produkt, Hersteller, Version">
</div>
<div class="col-12 col-xl-2 d-flex gap-2">
<button type="submit" class="btn btn-primary flex-grow-1"><i class="mdi mdi-filter" aria-hidden="true"></i> Anwenden</button>
<a href="{% url 'plugins:netbox_utilities:software_overview' %}" class="btn btn-outline-secondary" title="Filter zurücksetzen">
<i class="mdi mdi-backspace" aria-hidden="true"></i>
</a>
</div>
</div>
<div class="form-text mt-2">
{% if scope_label %}
<i class="mdi mdi-filter-check text-primary" aria-hidden="true"></i>
Es gilt der globale Mandantenfilter <strong>{{ scope_label }}</strong>. Eine eigene Auswahl hier hat Vorrang.
{% else %}
Mandantengruppen schließen alle Untergruppen ein. Ohne Gerätrolle werden alle Geräte berücksichtigt.
{% endif %}
</div>
</div>
</form>
{# Kennzahlen #}
<div class="row row-cards mb-3">
<div class="col-6 col-lg-3">
<div class="card nbu-sw-kpi"><div class="card-body">
<div class="nbu-sw-kpi-label">Rechner</div>
<div class="nbu-sw-kpi-value">{{ summary.device_total }}</div>
<div class="nbu-sw-kpi-hint">{{ summary.devices_with_software }} mit erfasster Software</div>
</div></div>
</div>
<div class="col-6 col-lg-3">
<div class="card nbu-sw-kpi"><div class="card-body">
<div class="nbu-sw-kpi-label">Erfassungsgrad</div>
<div class="nbu-sw-kpi-value">{{ summary.coverage }} %</div>
<div class="progress progress-sm mt-2" role="progressbar" aria-label="Erfassungsgrad" aria-valuenow="{{ summary.coverage }}" aria-valuemin="0" aria-valuemax="100">
<div class="progress-bar" style="width: {{ summary.coverage }}%"></div>
</div>
<div class="nbu-sw-kpi-hint">{{ summary.devices_without_software }} Rechner ohne Software</div>
</div></div>
</div>
<div class="col-6 col-lg-3">
<div class="card nbu-sw-kpi"><div class="card-body">
<div class="nbu-sw-kpi-label">Software-Produkte</div>
<div class="nbu-sw-kpi-value">{{ summary.product_count }}</div>
<div class="nbu-sw-kpi-hint">{{ summary.version_count }} Version{{ summary.version_count|pluralize:"en" }} · {{ summary.installations }} Installation{{ summary.installations|pluralize:"en" }}</div>
</div></div>
</div>
<div class="col-6 col-lg-3">
<div class="card nbu-sw-kpi{% if summary.expired_device_count %} nbu-sw-kpi-warning{% endif %}"><div class="card-body">
<div class="nbu-sw-kpi-label">Support abgelaufen</div>
<div class="nbu-sw-kpi-value">{{ summary.expired_device_count }}</div>
<div class="nbu-sw-kpi-hint">Rechner mit mindestens einer Version nach Support-Ende</div>
</div></div>
</div>
</div>
{% if product_missing %}
<div class="alert alert-warning">Dieses Produkt ist mit der aktuellen Auswahl auf keinem Rechner installiert.
<a href="?{{ filter_query }}">Zur Übersicht</a></div>
{% endif %}
{% if product %}
{% include 'netbox_utilities/inc/software_product.html' %}
{% elif summary.products %}
<div class="row row-cards mb-3">
{# Diagramm: Top-Produkte #}
<div class="col-12 col-xl-6">
<div class="card h-100">
<h2 class="card-header">Verbreitetste Software <span class="text-muted fw-normal small ms-1">Rechner je Produkt</span></h2>
<div class="card-body">
<ul class="nbu-sw-bars list-unstyled mb-0">
{% for item in summary.top_products %}
<li>
<a href="?{{ filter_query }}&product={{ item.id }}" class="nbu-sw-bar-row" title="{{ item.name }}: {{ item.device_count }} Rechner ({{ item.share }} %)">
<span class="nbu-sw-bar-label">{{ item.name }}</span>
<span class="nbu-sw-bar-track"><span class="nbu-sw-bar-fill" style="width: {{ item.bar }}%"></span></span>
<span class="nbu-sw-bar-value">{{ item.device_count }}<span class="text-muted"> · {{ item.share }} %</span></span>
</a>
</li>
{% endfor %}
</ul>
</div>
</div>
</div>
{# Diagramm: Versionsverteilung #}
<div class="col-12 col-xl-6">
<div class="card h-100">
<h2 class="card-header">Versionsverteilung <span class="text-muted fw-normal small ms-1">neueste Version am kräftigsten</span></h2>
<div class="card-body">
<ul class="nbu-sw-bars list-unstyled mb-0">
{% for item in summary.top_products %}
<li>
<a href="?{{ filter_query }}&product={{ item.id }}" class="nbu-sw-bar-row">
<span class="nbu-sw-bar-label">{{ item.name }}</span>
{% include 'netbox_utilities/inc/software_version_stack.html' %}
<span class="nbu-sw-bar-value">{{ item.version_count }} Version{{ item.version_count|pluralize:"en" }}</span>
</a>
</li>
{% endfor %}
</ul>
</div>
</div>
</div>
</div>
{# Tabelle aller Produkte #}
<div class="card">
<div class="card-header d-flex flex-wrap gap-2 align-items-center">
<h2 class="card-title me-auto mb-0">Alle Software-Produkte <span class="badge text-bg-secondary ms-1">{{ summary.product_count }}</span></h2>
<input type="search" class="form-control form-control-sm w-auto" data-nbu-sw-search="#nbu-sw-products"
placeholder="In Liste filtern …" aria-label="Produktliste filtern">
</div>
<div class="table-responsive">
<table class="table table-hover table-vcenter mb-0 nbu-sw-table" id="nbu-sw-products">
<thead>
<tr>
<th data-nbu-sort="text">Produkt</th>
<th data-nbu-sort="text">Hersteller</th>
<th data-nbu-sort="number" class="text-end">Rechner</th>
<th data-nbu-sort="number" class="text-end">Anteil</th>
<th data-nbu-sort="number" class="text-end">Versionen</th>
<th style="min-width: 12rem">Verteilung</th>
<th>Neueste Version</th>
<th data-nbu-sort="number" class="text-end">Support abgelaufen</th>
</tr>
</thead>
<tbody>
{% for item in summary.products %}
<tr data-nbu-search="{{ item.name|lower }} {{ item.manufacturer|lower }}{% for version in item.versions_by_name %} {{ version.name|lower }}{% endfor %}">
<td><a href="?{{ filter_query }}&product={{ item.id }}" class="fw-bold">{{ item.name }}</a></td>
<td>{{ item.manufacturer|placeholder }}</td>
<td class="text-end" data-value="{{ item.device_count }}">{{ item.device_count }}</td>
<td class="text-end" data-value="{{ item.share }}">{{ item.share }} %</td>
<td class="text-end" data-value="{{ item.version_count }}">{{ item.version_count }}</td>
<td>{% include 'netbox_utilities/inc/software_version_stack.html' %}</td>
<td>{% with latest=item.latest_version %}{{ latest.name }} <span class="text-muted small">({{ latest.device_count }})</span>{% endwith %}</td>
{% with expired=item.expired_devices|length %}
<td class="text-end" data-value="{{ expired }}">{% if expired %}<span class="badge text-bg-danger">{{ expired }}</span>{% else %}<span class="text-muted">—</span>{% endif %}</td>
{% endwith %}
</tr>
{% endfor %}
</tbody>
</table>
</div>
<div class="card-footer text-muted small">Spaltenköpfe anklicken zum Sortieren, Produkt anklicken für Versionen und Rechner.</div>
</div>
{% else %}
<div class="card"><div class="card-body text-center text-muted py-5">
<i class="mdi mdi-package-variant-closed mdi-48px d-block mb-2" aria-hidden="true"></i>
Für diese Auswahl ist keine Software erfasst.
{% if can_add %}<div class="mt-3"><a href="{% url 'plugins:netbox_slm:softwareproductinstallation_add' %}" class="btn btn-primary"><i class="mdi mdi-plus-thick" aria-hidden="true"></i> Installation erfassen</a></div>{% endif %}
</div></div>
{% endif %}
{% include 'netbox_utilities/inc/software_table_js.html' %}
{% endblock content %}