mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Update alertlog-widget to allow filtering by device group (#13380)
* Add group filter to alertlog widget * Remove extra characters from settings * Apply fixes from StyleCI Co-authored-by: ottorei <ottorei@users.noreply.github.com>
This commit is contained in:
@@ -33,6 +33,7 @@ class AlertlogController extends WidgetController
|
||||
protected $defaults = [
|
||||
'title' => null,
|
||||
'device_id' => '',
|
||||
'device_group' => null,
|
||||
'state' => -1,
|
||||
'min_severity' => null,
|
||||
'hidenavigation' => 0,
|
||||
|
@@ -40,6 +40,11 @@ if (isset($vars['min_severity'])) {
|
||||
$where .= get_sql_filter_min_severity($vars['min_severity'], 'R');
|
||||
}
|
||||
|
||||
if (is_numeric($vars['device_group'])) {
|
||||
$where .= ' AND D.device_id IN (SELECT `device_id` FROM `device_group_device` WHERE `device_group_id` = ?)';
|
||||
$param[] = $vars['device_group'];
|
||||
}
|
||||
|
||||
if (! Auth::user()->hasGlobalRead()) {
|
||||
$device_ids = Permissions::devicesForUser()->toArray() ?: [0];
|
||||
$where .= ' AND `E`.`device_id` IN ' . dbGenPlaceholders(count($device_ids));
|
||||
|
@@ -20,6 +20,7 @@
|
||||
return {
|
||||
id: "alertlog",
|
||||
device_id: "",
|
||||
device_group: "{{ $device_group }}",
|
||||
state: '{{ $state }}',
|
||||
min_severity: '{{ $min_severity }}',
|
||||
};
|
||||
|
@@ -6,7 +6,7 @@
|
||||
<input type="text" class="form-control" name="title" id="title-{{ $id }}" placeholder="@lang('Custom title')" value="{{ $title }}">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="state-{{ $id }}" class="control-label">@lang('State'):</label>
|
||||
<label for="state-{{ $id }}" class="control-label">@lang('State')</label>
|
||||
<select class="form-control" name="state" id="state-{{ $id }}">
|
||||
<option value="-1">@lang('not filtered')</option>
|
||||
<option value="0" @if($state === '1') selected @endif>@lang('OK')</option>
|
||||
@@ -14,7 +14,7 @@
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="min_severity-{{ $id }}" class="control-label">@lang('Displayed severity'):</label>
|
||||
<label for="min_severity-{{ $id }}" class="control-label">@lang('Displayed severity')</label>
|
||||
<select class="form-control" name="min_severity" id="min_severity-{{ $id }}">
|
||||
<option value="">@lang('any severity')</option>
|
||||
@foreach($severities as $name => $val)
|
||||
@@ -22,6 +22,14 @@
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="device_group-{{ $id }}" class="control-label">@lang('Device group')</label>
|
||||
<select class="form-control" name="device_group" id="device_group-{{ $id }}" data-placeholder="@lang('All Devices')">
|
||||
@if($device_group)
|
||||
<option value="{{ $device_group->id }}" selected>{{ $device_group->name }}</option>
|
||||
@endif
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="hidenavigation-{{ $id }}" class="control-label">@lang('Hide Navigation')</label>
|
||||
<input type="checkbox" class="form-control" name="hidenavigation" id="hidenavigation-{{ $id }}" value="{{ $hidenavigation }}" data-size="normal" @if($hidenavigation) checked @endif>
|
||||
@@ -30,6 +38,7 @@
|
||||
|
||||
@section('javascript')
|
||||
<script type="text/javascript">
|
||||
init_select2('#device_group-{{ $id }}', 'device-group', {});
|
||||
$('#hidenavigation-{{ $id }}')
|
||||
.bootstrapSwitch('offColor','danger')
|
||||
.on('switchChange.bootstrapSwitch', function (e, data) {
|
||||
|
Reference in New Issue
Block a user