Skip to content

Commit 861d264

Browse files
authored
Merge pull request #2115 from opensource-workshop/OW-2466
[ログ管理] 絞込条件に日時・URIを追加
2 parents 4345acd + 911cfb7 commit 861d264

File tree

2 files changed

+105
-13
lines changed

2 files changed

+105
-13
lines changed

app/Plugins/Manage/LogManage/LogManage.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,26 @@ private function getQuery($request)
4646
// ログデータ取得
4747
$app_logs_query = AppLog::select('app_logs.*');
4848

49+
// 日時Start
50+
if (session()->has('app_log_search_condition.start_created_at')) {
51+
$app_logs_query->where('created_at', '>=', session()->get('app_log_search_condition.start_created_at'));
52+
}
53+
54+
// 日時End
55+
if (session()->has('app_log_search_condition.end_created_at')) {
56+
$app_logs_query->where('created_at', '<=', session()->get('app_log_search_condition.end_created_at'));
57+
}
58+
4959
// ログインID
5060
if ($request->session()->has('app_log_search_condition.userid')) {
5161
$app_logs_query->where('userid', 'like', '%' . $request->session()->get('app_log_search_condition.userid') . '%');
5262
}
5363

64+
// URI
65+
if ($request->session()->has('app_log_search_condition.uri')) {
66+
$app_logs_query->where('uri', 'like', '%' . $request->session()->get('app_log_search_condition.uri') . '%');
67+
}
68+
5469
// 詳細条件
5570
$app_logs_query->where(function ($query) use ($request) {
5671
// ログイン

resources/views/plugins/manage/log/log.blade.php

Lines changed: 90 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
* ログ管理のメインテンプレート
33
*
44
* @author 永原 篤 <[email protected]>
5+
* @author 牟田口 満 <[email protected]>
56
* @copyright OpenSource-WorkShop Co.,Ltd. All Rights Reserved
67
* @category ログ管理
78
--}}
@@ -11,6 +12,24 @@
1112
{{-- 管理画面メイン部分のコンテンツ section:manage_content で作ること --}}
1213
@section('manage_content')
1314

15+
<script type="text/javascript">
16+
let calendar_setting = {
17+
@if (App::getLocale() == ConnectLocale::ja)
18+
dayViewHeaderFormat: 'YYYY年 M月',
19+
@endif
20+
locale: '{{ App::getLocale() }}',
21+
// 日時の両方入力
22+
format: 'YYYY-MM-DD HH:mm:ss',
23+
sideBySide: true
24+
};
25+
26+
$(function () {
27+
// 時計ボタン押下の設定
28+
$('#start_created_at').datetimepicker(calendar_setting);
29+
$('#end_created_at').datetimepicker(calendar_setting);
30+
});
31+
</script>
32+
1433
<div class="card">
1534
<div class="card-header p-0">
1635
{{-- 機能選択タブ --}}
@@ -31,18 +50,76 @@
3150
<form name="form_search" id="form_search" class="form-horizontal" method="post" action="{{url('/')}}/manage/log/search">
3251
{{ csrf_field() }}
3352

34-
{{-- ログインID --}}
53+
<!-- 日時 -->
3554
<div class="form-group row">
36-
<label for="app_log_search_condition_userid" class="col-md-3 col-form-label text-md-right">ログインID</label>
55+
<label class="col-md-3 col-form-label text-md-right">日時</label>
3756
<div class="col-md-9">
38-
<input type="text" name="app_log_search_condition[userid]" id="app_log_search_condition_userid" value="{{Session::get('app_log_search_condition.userid')}}" class="form-control">
39-
<small class="text-muted">ログインID & 以下の条件を指定した場合はいずれかに合致した場合</small>
57+
58+
<div class="form-row">
59+
<!-- 日時From -->
60+
<div class="col-md-6">
61+
<div class="input-group" id="start_created_at" data-target-input="nearest">
62+
@php
63+
$start_created_at = Session::get("app_log_search_condition.start_created_at");
64+
$start_created_at = $start_created_at ? (new Carbon($start_created_at)) : '';
65+
@endphp
66+
<input type="text" name="app_log_search_condition[start_created_at]" value="{{$start_created_at}}" class="form-control datetimepicker-input" data-target="#start_created_at">
67+
<div class="input-group-append" data-target="#start_created_at" data-toggle="datetimepicker">
68+
<div class="input-group-text"><i class="far fa-clock"></i></div>
69+
</div>
70+
<div class="form-text pl-2">
71+
72+
</div>
73+
</div>
74+
</div>
75+
<!-- 日時To -->
76+
<div class="col-md-6">
77+
<div class="input-group" id="end_created_at" data-target-input="nearest">
78+
@php
79+
$end_created_at = Session::get("app_log_search_condition.end_created_at");
80+
$end_created_at = $end_created_at ? (new Carbon($end_created_at)) : '';
81+
@endphp
82+
<input type="text" name="app_log_search_condition[end_created_at]" value="{{$end_created_at}}" class="form-control datetimepicker-input" data-target="#end_created_at">
83+
<div class="input-group-append" data-target="#end_created_at" data-toggle="datetimepicker">
84+
<div class="input-group-text"><i class="far fa-clock"></i></div>
85+
</div>
86+
</div>
87+
</div>
88+
</div><!-- /.form-row -->
89+
@include('plugins.common.errors_inline', ['name' => 'app_log_search_condition.start_created_at'])
90+
@include('plugins.common.errors_inline', ['name' => 'app_log_search_condition.end_created_at'])
91+
92+
</div><!-- /.col-md-9 -->
93+
</div><!-- /.row -->
94+
95+
<!-- ログインID -->
96+
<div class="form-group row">
97+
<label class="col-md-3 col-form-label text-md-right">ログインID</label>
98+
<div class="col-md-9">
99+
<input type="text" name="app_log_search_condition[userid]" value="{{Session::get('app_log_search_condition.userid')}}" class="form-control">
100+
</div>
101+
</div>
102+
103+
<!-- URI -->
104+
<div class="form-group row">
105+
<label class="col-md-3 col-form-label text-md-right">URI</label>
106+
<div class="col-md-9">
107+
<input type="text" name="app_log_search_condition[uri]" value="{{Session::get('app_log_search_condition.uri')}}" class="form-control">
108+
</div>
109+
</div>
110+
111+
<div class="row">
112+
<div class="col-md-3"></div>
113+
<div class="col-md-9">
114+
<div class="alert alert-secondary">
115+
以下の条件を指定した場合はいずれかに合致した場合
116+
</div>
40117
</div>
41118
</div>
42119

43-
{{-- ログイン関係 --}}
120+
<!-- ログイン関係 -->
44121
<div class="form-group row">
45-
<label for="app_log_search_condition_type" class="col-md-3 text-md-right">ログイン関係</label>
122+
<label class="col-md-3 text-md-right">ログイン関係</label>
46123
<div class="col-md-9">
47124
<div class="custom-control custom-control-inline custom-checkbox">
48125
<input name="app_log_search_condition[log_type_login]" value="1" type="checkbox" class="custom-control-input" id="log_type_login"@if(Session::get('app_log_search_condition.log_type_login') == "1") checked @endif>
@@ -59,9 +136,9 @@
59136
</div>
60137
</div>
61138

62-
{{-- 種別 --}}
139+
<!-- 種別 -->
63140
<div class="form-group row">
64-
<label for="app_log_search_condition_type" class="col-md-3 text-md-right">種別</label>
141+
<label class="col-md-3 text-md-right">種別</label>
65142
<div class="col-md-9">
66143
<div class="custom-control custom-control-inline custom-checkbox">
67144
<input name="app_log_search_condition[log_type_page]" value="1" type="checkbox" class="custom-control-input" id="log_type_page"@if(Session::get('app_log_search_condition.log_type_page') == "1") checked @endif>
@@ -130,9 +207,9 @@
130207
</div>
131208
</div>
132209

133-
{{-- HTTPメソッド --}}
210+
<!-- HTTPメソッド -->
134211
<div class="form-group row">
135-
<label for="app_log_search_condition_type" class="col-md-3 text-md-right">HTTPメソッド</label>
212+
<label class="col-md-3 text-md-right">HTTPメソッド</label>
136213
<div class="col-md-9">
137214
<div class="custom-control custom-control-inline custom-checkbox">
138215
<input name="app_log_search_condition[log_type_http_get]" value="1" type="checkbox" class="custom-control-input" id="log_type_http_get"@if(Session::get('app_log_search_condition.log_type_http_get') == "1") checked @endif>
@@ -145,7 +222,7 @@
145222
</div>
146223
</div>
147224

148-
{{-- ボタンエリア --}}
225+
<!-- ボタンエリア -->
149226
<div class="form-group text-center">
150227
<div class="row">
151228
<div class="mx-auto">
@@ -166,12 +243,12 @@
166243

167244
<div class="row mt-2">
168245
<div class="col text-left d-flex align-items-end">
169-
{{-- (左側)件数 --}}
246+
<!-- (左側)件数 -->
170247
<span class="badge badge-pill badge-light">{{ $app_logs->total() }} 件</span>
171248
</div>
172249

173250
<div class="col text-right">
174-
{{-- (右側)ダウンロードボタン --}}
251+
<!-- (右側)ダウンロードボタン -->
175252
<a href="{{url('/')}}/manage/log/downloadCsv" target="_blank" onclick="return confirm('現在の絞り込み条件のログをダウンロードします。\nよろしいですか?')">
176253
<span class="btn btn-link"><i class="fas fa-file-download"></i> ダウンロード</span>
177254
</a>

0 commit comments

Comments
 (0)