Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show custom maps in device overview #15985

Merged
merged 3 commits into from Apr 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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>