Skip to content

Commit b6900ec

Browse files
authored
Fix various devices links (librenms#19759)
1 parent 60bcd5c commit b6900ec

12 files changed

Lines changed: 33 additions & 34 deletions

File tree

app/Http/Controllers/Widgets/AvailabilityMapController.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ public function getView(Request $request): string|View
6666
$data['device_totals'] = $device_totals;
6767
$data['services'] = $services;
6868
$data['services_totals'] = $services_totals;
69+
$data['base_filter'] = isset($data['device_group']) ? ['groups.id' => ['eq' => $data['device_group']]] : [];
6970

7071
return view('widgets.availability-map', $data);
7172
}

app/Models/Device.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ class Device extends BaseModel
107107
'disable_notify',
108108
'poller_group',
109109
'groups.id',
110+
'serviceTemplates.id',
110111
'search',
111112
'state',
112113
];

includes/html/print-alert-rules.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@
2626

2727
use App\Facades\DeviceCache;
2828
use App\Models\AlertRule;
29-
use App\Models\AlertTransport;
30-
use App\Models\AlertTransportGroup;
31-
use Illuminate\Support\Facades\Schema;
3229
use LibreNMS\Alerting\QueryBuilderParser;
3330
use LibreNMS\Enum\AlertState;
3431

@@ -300,7 +297,7 @@
300297
$location_query = 'SELECT locations.location, locations.id FROM alert_location_map, locations WHERE alert_location_map.rule_id=? and alert_location_map.location_id = locations.id ORDER BY location';
301298
$location_maps = dbFetchRows($location_query, [$rule['id']]);
302299
foreach ($location_maps as $location_map) {
303-
$locations .= $except_device_or_group . '<a href="' . url('devices/location=' . $location_map['id']) . '" data-container="body" data-toggle="popover" data-placement="right" data-content="View Devices for Location" target="_blank">' . htmlentities((string) $location_map['location']) . '</a><br>';
300+
$locations .= $except_device_or_group . '<a href="' . route('devices', ['filter' => ['location_id' => $location_map['id']]]) . '" data-container="body" data-toggle="popover" data-placement="right" data-content="View Devices for Location" target="_blank">' . htmlentities((string) $location_map['location']) . '</a><br>';
304301
}
305302
}
306303

@@ -334,7 +331,7 @@
334331
}
335332
if (! $devices && ! $groups && ! $locations) {
336333
// All Devices
337-
echo '<a href="' . url('devices') . '" data-container="body" data-toggle="popover" data-placement="right" data-content="View All Devices" target="_blank">All Devices</a><br>';
334+
echo '<a href="' . route('devices') . '" data-container="body" data-toggle="popover" data-placement="right" data-content="View All Devices" target="_blank">All Devices</a><br>';
338335
}
339336

340337
echo '</td>';

resources/views/components/device/page.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class="fa fa-server fa-fw fa-lg"></i></a>
2222
@endif
2323
</span>
2424
<br/>
25-
<a href="{{ url('/devices/location=' . urlencode((string) $device->location)) }}">{{ $device->location }}</a>
25+
<a href="{{ route('devices', ['filter' => ['location_id' => ['eq' => $device->location_id]]]) }}">{{ $device->location }}</a>
2626
</div>
2727
<div class="pull-right">
2828
@foreach($overviewGraphs() as $graph)

resources/views/device-group/index.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<a type="button" class="btn btn-primary" href="{{ route('device-groups.create') }}">
1515
<i class="fa fa-plus"></i> {{ __('New Device Group') }}
1616
</a>
17-
<a type="button" class="btn btn-default" href="{{ url('devices/group=none') }}">
17+
<a type="button" class="btn btn-default" href="{{ route('devices', ['filter' => ['groups.id' => ['is_empty' => 1]]]) }}">
1818
<i class="fas fa-border-none"></i> {{ __('View Ungrouped Devices') }}
1919
</a>
2020
</div>

resources/views/layouts/menu.blade.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,14 +126,14 @@ class="tw:md:hidden tw:2xl:inline-block">{{ __('Overview') }}</span></a>
126126
</li>
127127
{{-- Devices --}}
128128
<li class="dropdown">
129-
<a href="{{ url('devices/') }}" class="dropdown-toggle" data-hover="dropdown"
129+
<a href="{{ route('devices') }}" class="dropdown-toggle" data-hover="dropdown"
130130
data-toggle="dropdown"><i class="fa fa-server fa-fw fa-lg fa-nav-icons"
131131
aria-hidden="true"></i> <span>{{ __('Devices') }}</span></a>
132132
<ul class="dropdown-menu">
133133
@if($no_devices_added)
134134
<li><a href="#"><i class="fa fa-server fa-fw fa-lg" aria-hidden="true"></i> {{ __('No Devices') }}</a>
135135
@else
136-
<li @class(['dropdown-submenu' => $device_types->isNotEmpty()])><a href="{{ url('devices') }}"><i class="fa fa-server fa-fw fa-lg" aria-hidden="true"></i> {{ __('All Devices') }}</a>
136+
<li @class(['dropdown-submenu' => $device_types->isNotEmpty()])><a href="{{ route('devices') }}"><i class="fa fa-server fa-fw fa-lg" aria-hidden="true"></i> {{ __('All Devices') }}</a>
137137
@if($device_types->isNotEmpty())
138138
<ul class="dropdown-menu scrollable-menu">
139139
@foreach($device_types as $type => $icon)
@@ -162,7 +162,7 @@ class="tw:md:hidden tw:2xl:inline-block">{{ __('Overview') }}</span></a>
162162
<ul class="dropdown-menu scrollable-menu">
163163
<li><a href="{{ url('locations') }}"><i class="fa fa-map-marker fa-fw fa-lg" aria-hidden="true"></i> {{ __('All Locations') }}</a></li>
164164
@foreach($locations as $location)
165-
<li><a href="{{ url("devices/location=" . $location->id) }}"><i class="fa fa-building fa-fw fa-lg" aria-hidden="true"></i> {{ $location->display() }}</a></li>
165+
<li><a href="{{ route('devices', ['filter' => ['location_id' => ['eq' => $location->id]]]) }}"><i class="fa fa-building fa-fw fa-lg" aria-hidden="true"></i> {{ $location->display() }}</a></li>
166166
@endforeach
167167
</ul>
168168
</li>

resources/views/locations.blade.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
</style>
6868
@endsection
6969

70-
@section('javascript')
70+
@push('scripts')
7171
<script src="js/leaflet.js"></script>
7272
<script src="js/L.Control.Locate.min.js"></script>
7373
<script>
@@ -85,7 +85,7 @@
8585
formatters: {
8686
"location": function (column, row) {
8787
var a = document.createElement('a');
88-
a.href = '{{ url('/devices') }}/location=' + row.id;
88+
a.href = '{{ route('devices', ['filter' => ['location_id' => ['eq' => '_location_id']]]) }}'.replace('_location_id', row.id);
8989
a.textContent = row.location;
9090
return a.outerHTML;
9191
},
@@ -258,4 +258,4 @@ function toggle_location_graphs(locationId, source) {
258258
}
259259
}
260260
</script>
261-
@endsection
261+
@endpush

resources/views/poller/groups.blade.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@
2222
<tr id="0">
2323
<td>0</td>
2424
<td>General @if($default_group_id == 0) ({{ __('default') }}) @endif</td>
25-
<td><a href="{{ url('devices/poller_group=0') }}">{{ $ungrouped_count }}</a></td>
25+
<td><a href="{{ route('devices', ['filter' => ['poller_group' => ['eq' => $default_group_id]]]) }}">{{ $ungrouped_count }}</a></td>
2626
<td></td>
2727
<td>
2828
</tr>
2929
@foreach ($poller_groups as $group)
3030
<tr id="{{ $group->id }}">
3131
<td>{{ $group->id }}</td>
3232
<td>{{ $group->group_name }}@if($group->id == $default_group_id) ({{ __('default') }}) @endif</td>
33-
<td><a href="{{ url('devices/poller_group=' . $group->id) }}">{{ $group->devices_count }}</a></td>
33+
<td><a href="{{ route('devices', ['filter' => ['poller_group' => ['eq' => $group->id]]]) }}">{{ $group->devices_count }}</a></td>
3434
<td>{{ $group->descr }}</td>
3535
<td>
3636
@can('update', $group)

resources/views/service-template/index.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class="fa fa-refresh" aria-hidden="true"></i> {{ __('Apply Service Templates') }
4141
<td>{{ $template->name }}</td>
4242
<td>{{ $template->desc }}</td>
4343
<td>
44-
<a href="{{ url("/devices/serviceTemplates=$template->id") }}">{{ $template->devices_count }}</a>
44+
<a href="{{ route('devices', ['filter' => ['serviceTemplates.id' => ['eq' => $template->id]]]) }}">{{ $template->devices_count }}</a>
4545
</td>
4646
<td>
4747
<a href="{{ url("/device-groups/serviceTemplates=$template->id") }}">{{ $template->groups_count }}</a>

resources/views/widgets/availability-map.blade.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
<div class="widget-availability-host">
44
<span>{{ __('Total hosts') }}</span>
55
@if($show_disabled_and_ignored)
6-
<a href="{{ url('devices/disable_notify=1') }}"><span class="label label-default label-font-border label-border">{{ __('alert-disabled') }}: {{ $device_totals['ignored'] }}</span></a>
7-
<a href="{{ url('devices/disabled=1') }}"><span class="label blackbg label-font-border label-border">{{ __('disabled') }}: {{ $device_totals['disabled'] }}</span></a>
6+
<a href="{{ route('devices', ['filter' => $base_filter + ['disable_notify' => ['eq' => 1]]]) }}"><span class="label label-default label-font-border label-border">{{ __('alert-disabled') }}: {{ $device_totals['ignored'] }}</span></a>
7+
<a href="{{ route('devices', ['filter' => $base_filter + ['disabled' => ['eq' => 1]]]) }}"><span class="label blackbg label-font-border label-border">{{ __('disabled') }}: {{ $device_totals['disabled'] }}</span></a>
88
@endif
9-
<a href="{{ url('devices/state=up') }}@if($device_group){{ '/group='.$device_group }}@endif"><span class="label label-success label-font-border label-border">{{ __('up') }}: {{ $device_totals['up'] }}</span></a>
9+
<a href="{{ route('devices', ['filter' => $base_filter + ['state' => ['eq' => 'up']]]) }}"><span class="label label-success label-font-border label-border">{{ __('up') }}: {{ $device_totals['up'] }}</span></a>
1010
<span class="label label-warning label-font-border label-border">{{ __('warn') }}: {{ $device_totals['warn'] }}</span>
11-
<a href="{{ url('devices/state=down') }}@if($device_group){{ '/group='.$device_group }}@endif"><span class="label label-danger label-font-border label-border">{{ __('down') }}: {{ $device_totals['down'] }}</span></a>
11+
<a href="{{ route('devices', ['filter' => $base_filter + ['state' => ['eq' => 'down']]]) }}"><span class="label label-danger label-font-border label-border">{{ __('down') }}: {{ $device_totals['down'] }}</span></a>
1212
@if($device_totals['maintenance'])
1313
<span class="label label-default label-font-border label-border">{{ __('alerting.maintenance.maintenance') }}: {{ $device_totals['maintenance'] }}</span>
1414
@endif

0 commit comments

Comments
 (0)