Skip to content

Commit

Permalink
Show custom maps in device overview (#15985)
Browse files Browse the repository at this point in the history
* Show custom maps in device overview

* remove extra line return

* Sort by name
  • Loading branch information
murrant committed Apr 26, 2024
1 parent 3f4bd69 commit 1dc6245
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 0 deletions.
5 changes: 5 additions & 0 deletions app/Models/Device.php
Expand Up @@ -794,6 +794,11 @@ public function macs(): HasMany
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');
Expand Down
1 change: 1 addition & 0 deletions includes/html/pages/device/overview.inc.php
Expand Up @@ -15,6 +15,7 @@
<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';

Expand Down
7 changes: 7 additions & 0 deletions includes/html/pages/device/overview/maps.inc.php
@@ -0,0 +1,7 @@
<?php

$maps = DeviceCache::getPrimary()->maps;

if ($maps->isNotEmpty()) {
echo view('device.overview.maps', ['maps' => $maps->sortBy('name')]);
}
13 changes: 13 additions & 0 deletions resources/views/device/overview/maps.blade.php
@@ -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>

0 comments on commit 1dc6245

Please sign in to comment.