Show custom maps in device overview (#15985)

* Show custom maps in device overview

* remove extra line return

* Sort by name
This commit is contained in:
Tony Murray
2024-04-26 15:10:24 -05:00
committed by GitHub
parent 3f4bd69718
commit 1dc62454fc
4 changed files with 26 additions and 0 deletions

View File

@@ -794,6 +794,11 @@ class Device extends BaseModel
return $this->hasMany(Ipv4Mac::class, 'device_id');
}
public function maps(): HasManyThrough
{
return $this->hasManyThrough(CustomMap::class, CustomMapNode::class, 'device_id', 'custom_map_id', 'device_id', 'custom_map_id');
}
public function mefInfo(): HasMany
{
return $this->hasMany(MefInfo::class, 'device_id');

View File

@@ -15,6 +15,7 @@ echo '
<div class="col-md-6">
';
require 'includes/html/dev-overview-data.inc.php';
require 'overview/maps.inc.php';
require 'includes/html/dev-groups-overview-data.inc.php';
require 'overview/puppet_agent.inc.php';

View File

@@ -0,0 +1,7 @@
<?php
$maps = DeviceCache::getPrimary()->maps;
if ($maps->isNotEmpty()) {
echo view('device.overview.maps', ['maps' => $maps->sortBy('name')]);
}

View File

@@ -0,0 +1,13 @@
<div class="row">
<div class="col-md-12">
<x-panel class="device-overview panel-condensed">
<x-slot name="heading">
<i class="fa fa-map-marked fa-lg icon-theme" aria-hidden="true"></i>
<strong>{{ __('Custom Maps') }}</strong>
</x-slot>
@foreach($maps as $map)
<p><a href="{{ route('maps.custom.show', $map->custom_map_id) }}">{{ $map->name }}</a></p>
@endforeach
</x-panel>
</div>
</div>