Skip to content

Commit 9f806b3

Browse files
committed
Show device assignments in MDM enrolled device view
1 parent 190445d commit 9f806b3

File tree

2 files changed

+67
-0
lines changed

2 files changed

+67
-0
lines changed

zentral/contrib/mdm/templates/mdm/enrolleddevice_detail.html

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,63 @@ <h3>Artifact{{ target_artifacts_count|pluralize }} ({{ target_artifacts_count }}
394394
</table>
395395
{% endif %}
396396

397+
<h3>Device assignment{{ device_assignments_count|pluralize }} ({{ device_assignments_count }})</h3>
398+
399+
{% if device_assignments_count %}
400+
<table class="table table-striped align-middle">
401+
<thead>
402+
<tr>
403+
<th></th>
404+
<th>Location</th>
405+
<th>Name</th>
406+
<th>Bundle ID</th>
407+
<th>Platform</th>
408+
<th>Assign time</th>
409+
</tr>
410+
</thead>
411+
<tbody>
412+
{% for device_assignment in device_assignments %}
413+
{% with device_assignment.location_asset as location_asset %}
414+
{% with location_asset.asset as asset %}
415+
<tr>
416+
<td>
417+
{% if asset.icon_url %}
418+
{% if asset.store_url %}
419+
<a href="{{ asset.store_url }}">
420+
<img style="max-width:32px;max-height:32px" src="{{ asset.icon_url }}">
421+
</a>
422+
{% else %}
423+
<img style="max-width:32px;max-height:32px" src="{{ asset.icon_url }}">
424+
{% endif %}
425+
{% else %}
426+
-
427+
{% endif %}
428+
</td>
429+
<td>
430+
{% if perms.mdm.view_location %}
431+
<a href="{{ location_asset.location.get_absolute_url }}">{{ location_asset.location }}</a>
432+
{% else %}
433+
{{ location_asset.location }}
434+
{% endif %}
435+
</td>
436+
<td>
437+
{% if perms.mdm.view_asset %}
438+
<a href="{{ location_asset.get_absolute_url }}">{{ asset.name }}</a>
439+
{% else %}
440+
{{ asset.name }}
441+
{% endif %}
442+
</td>
443+
<td>{{ asset.bundle_id }}</td>
444+
<td>{{ asset.supported_platforms|join:", " }}</td>
445+
<td>{{ device_assignment.created_at }}</td>
446+
</tr>
447+
{% endwith %}
448+
{% endwith %}
449+
{% endfor %}
450+
</tbody>
451+
</table>
452+
{% endif %}
453+
397454
<div class="d-flex align-items-center mb-1">
398455
<h3 class="m-0">Last commands</h3>
399456
<div class="ms-auto">

zentral/contrib/mdm/views/management.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
CertAsset, DataAsset, Declaration,
4040
DEPDevice, DEPEnrollment,
4141
DeviceArtifact, UserArtifact,
42+
DeviceAssignment,
4243
DeviceCommand, UserCommand,
4344
EnrolledDevice, EnrolledUser, EnterpriseApp,
4445
FileVaultConfig,
@@ -1263,11 +1264,20 @@ def get_context_data(self, **kwargs):
12631264
.get(serial_number=self.object.serial_number))
12641265
except DEPDevice.DoesNotExist:
12651266
pass
1267+
# device assignments
1268+
ctx["device_assignments"] = (DeviceAssignment.objects
1269+
.select_related("location_asset__asset",
1270+
"location_asset__location")
1271+
.filter(serial_number=self.object.serial_number)
1272+
.order_by("location_asset__asset__name"))
1273+
ctx["device_assignments_count"] = ctx["device_assignments"].count()
1274+
# target artifacts
12661275
ctx["target_artifacts"] = (self.object.target_artifacts
12671276
.select_related("artifact_version__artifact")
12681277
.all()
12691278
.order_by("-updated_at"))
12701279
ctx["target_artifacts_count"] = ctx["target_artifacts"].count()
1280+
# commands
12711281
commands_qs = (
12721282
self.object.commands
12731283
.select_related("artifact_version__artifact")

0 commit comments

Comments
 (0)