Priority filtering for syslog widget (#13134)

* Update SyslogController.php

* Update SyslogController.php

* Update syslog.blade.php

* Update syslog.blade.php

* Update web.php

* Create PriorityController.php

* Update SyslogController.php

* Update SyslogController.php

* changed priority controller to static list

* Update PriorityController.php

* Update PriorityController.php

* Update PriorityController.php

* using static list directly with standard select box without backend logic

* removed not required if statement
avoided array_flip by flipping foreach arguments
This commit is contained in:
Talkabout 2021-08-21 05:52:15 +02:00 committed by GitHub
parent d6fee82e1a
commit 1de372ca1b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 17 additions and 1 deletions

View File

@ -37,6 +37,7 @@ class SyslogController extends TableController
'priority' => 'nullable|string',
'to' => 'nullable|date',
'from' => 'nullable|date',
'level' => 'nullable|string',
];
}
@ -77,6 +78,9 @@ class SyslogController extends TableController
})
->when($request->to, function ($query) use ($request) {
$query->where('timestamp', '<=', $request->to);
})
->when($request->level, function ($query) use ($request) {
$query->where('level', '<=', $request->level);
});
}

View File

@ -35,6 +35,7 @@ class SyslogController extends WidgetController
'device' => null,
'device_group' => null,
'hidenavigation' => 0,
'level' => null,
];
public function getSettingsView(Request $request)
@ -43,6 +44,8 @@ class SyslogController extends WidgetController
$data['device'] = Device::hasAccess($request->user())->find($data['device']);
$data['priorities'] = app('translator')->get('syslog.severity');
return view('widgets.settings.syslog', $data);
}

View File

@ -25,6 +25,14 @@
<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>
</div>
<div class="form-group">
<label for="level-{{ $id }}" class="control-label">@lang('Priority')</label>
<select class="form-control" name="level" id="level-{{ $id }}">
@foreach($priorities as $val => $name)
<option value="{{ $val }}" @if($level == $val) selected @endif>{{ $name }}</option>
@endforeach
</select>
</div>
@endsection
@section('javascript')

View File

@ -22,7 +22,8 @@
{
return {
device: '{{ $device ?: '' }}',
device_group: '{{ $device_group }}'
device_group: '{{ $device_group }}',
level: '{{ $level }}'
};
},
url: "{{ url('/ajax/table/syslog') }}"