Skip to content

Commit cad9ce2

Browse files
committed
cleanup
1 parent 59a5cbd commit cad9ce2

12 files changed

+362
-45
lines changed

Diff for: LICENSE

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2017 jeremykenedy
3+
Copyright (c) 2018 jeremykenedy
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal
@@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1818
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1919
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2020
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21-
SOFTWARE.
21+
SOFTWARE.

Diff for: composer.json

+8
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
11
{
22
"name": "jeremykenedy/laravel-logger",
33
"description": "Laravel Logger Package",
4+
"keywords": [
5+
"Laravel activity",
6+
"Laravel activity logger",
7+
"Laravel activity log",
8+
"Laravel logger",
9+
"Laravel log"
10+
],
411
"license": "MIT",
12+
"type": "package",
513
"authors": [
614
{
715
"name": "jeremykenedy",

Diff for: src/app/Http/Controllers/LaravelLoggerController.php

+7-2
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public function __construct()
3939
/**
4040
* Add additional details to a collections
4141
*
42-
* @param collection $collectionItems
42+
* @param collection $collectionItems
4343
*
4444
* @return collection
4545
*/
@@ -86,6 +86,9 @@ public function showAccessLog()
8686
/**
8787
* Show an individual activity log entry.
8888
*
89+
* @param Request $request
90+
* @param int $id
91+
*
8992
* @return \Illuminate\Http\Response
9093
*/
9194
public function showAccessLogEntry(Request $request, $id)
@@ -177,6 +180,9 @@ public function showClearedActivityLog()
177180
/**
178181
* Show an individual cleared (soft deleted) activity log entry.
179182
*
183+
* @param Request $request
184+
* @param int $id
185+
*
180186
* @return \Illuminate\Http\Response
181187
*/
182188
public function showClearedAccessLogEntry(Request $request, $id)
@@ -253,5 +259,4 @@ public function restoreClearedActivityLog(Request $request)
253259

254260
return redirect('activity')->with('success', trans('LaravelLogger::laravel-logger.messages.logRestoredSuccessfuly'));
255261
}
256-
257262
}

Diff for: src/app/Http/Middleware/LogActivity.php

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ class LogActivity
1616
*
1717
* @param Request $request
1818
* @param \Closure $next
19+
*
1920
* @return mixed
2021
*/
2122
public function handle($request, Closure $next, $description = null)

Diff for: src/app/Http/Traits/ActivityLogger.php

+4
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ trait ActivityLogger
1212
{
1313
/**
1414
* Laravel Logger Log Activity
15+
*
1516
* @param string $description
17+
*
1618
* @return void
1719
*/
1820
public static function activity($description = null)
@@ -80,7 +82,9 @@ public static function activity($description = null)
8082

8183
/**
8284
* Store activity entry to database
85+
*
8386
* @param array $data
87+
*
8488
* @return void
8589
*/
8690
private static function storeActivity($data)

Diff for: src/app/Http/Traits/UserAgentDetails.php

+15-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@
44

55
trait UserAgentDetails
66
{
7+
/**
8+
* Get the user's agents details
9+
*
10+
* @param $ua
11+
*
12+
* @return array
13+
*/
714
public static function details($ua)
815
{
916
$ua = is_null($ua) ? $_SERVER['HTTP_USER_AGENT'] : $ua;
@@ -41,7 +48,6 @@ public static function details($ua)
4148
numbers 31.0.1234.122 becomes 31.0, while a "normal" 3 digit version number
4249
like 10.2.1 would stay 10.2.1, 11.0 stays 11.0. Non-match stays what it is.
4350
*/
44-
4551
if (preg_match("/^[\d]+\.[\d]+(?:\.[\d]{0,2}$)?/",$ua_array[4],$matches))
4652
{
4753
$return['version'] = $matches[0];
@@ -85,9 +91,16 @@ public static function details($ua)
8591
return $return;
8692
}
8793

94+
/**
95+
* Return the locales language from PHP's Local
96+
* http://php.net/manual/en/class.locale.php
97+
* http://php.net/manual/en/locale.acceptfromhttp.php
98+
*
99+
* @param string $locale
100+
* @return string (Example: "en_US")
101+
*/
88102
public static function localeLang($locale)
89103
{
90104
return \Locale::acceptFromHttp($locale);
91105
}
92-
93106
}
+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{!! Form::open(array('route' => 'destroy-activity')) !!}
1+
{!! Form::open(array('route' => 'destroy-activity', 'class' => 'mb-0')) !!}
22
{!! Form::hidden('_method', 'DELETE') !!}
3-
{!! Form::button('<i class="fa fa-fw fa-eraser" aria-hidden="true"></i>' . trans('LaravelLogger::laravel-logger.dashboardCleared.menu.deleteAll'), array('type' => 'button', 'class' => 'text-danger', 'data-toggle' => 'modal', 'data-target' => '#confirmDelete', 'data-title' => trans('LaravelLogger::laravel-logger.modals.deleteLog.title'),'data-message' => trans('LaravelLogger::laravel-logger.modals.deleteLog.message'))) !!}
3+
{!! Form::button('<i class="fa fa-fw fa-eraser" aria-hidden="true"></i>' . trans('LaravelLogger::laravel-logger.dashboardCleared.menu.deleteAll'), array('type' => 'button', 'class' => 'text-danger dropdown-item', 'data-toggle' => 'modal', 'data-target' => '#confirmDelete', 'data-title' => trans('LaravelLogger::laravel-logger.modals.deleteLog.title'),'data-message' => trans('LaravelLogger::laravel-logger.modals.deleteLog.message'))) !!}
44
{!! Form::close() !!}
+2-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
{!! Form::open(array('route' => 'restore-activity', 'method' => 'POST')) !!}
2-
{!! Form::button('<i class="fa fa-fw fa-history" aria-hidden="true"></i>' . trans('LaravelLogger::laravel-logger.dashboardCleared.menu.restoreAll'), array('type' => 'button', 'class' => 'text-success', 'data-toggle' => 'modal', 'data-target' => '#confirmRestore', 'data-title' => trans('LaravelLogger::laravel-logger.modals.restoreLog.title'),'data-message' => trans('LaravelLogger::laravel-logger.modals.restoreLog.message'))) !!}
1+
{!! Form::open(array('route' => 'restore-activity', 'method' => 'POST', 'class' => 'mb-0')) !!}
2+
{!! Form::button('<i class="fa fa-fw fa-history" aria-hidden="true"></i>' . trans('LaravelLogger::laravel-logger.dashboardCleared.menu.restoreAll'), array('type' => 'button', 'class' => 'text-success dropdown-item', 'data-toggle' => 'modal', 'data-target' => '#confirmRestore', 'data-title' => trans('LaravelLogger::laravel-logger.modals.restoreLog.title'),'data-message' => trans('LaravelLogger::laravel-logger.modals.restoreLog.message'))) !!}
33
{!! Form::close() !!}

Diff for: src/resources/views/logger/activity-log-cleared.blade.php

+50-20
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,22 @@
1212
@include('LaravelLogger::partials.styles')
1313
@endif
1414

15+
@php
16+
switch (config('LaravelLogger.bootstapVersion')) {
17+
case '4':
18+
$containerClass = 'card';
19+
$containerHeaderClass = 'card-header';
20+
$containerBodyClass = 'card-body';
21+
break;
22+
case '3':
23+
default:
24+
$containerClass = 'panel panel-default';
25+
$containerHeaderClass = 'panel-heading';
26+
$containerBodyClass = 'panel-body';
27+
}
28+
$bootstrapCardClasses = (is_null(config('LaravelLogger.bootstrapCardClasses')) ? '' : config('LaravelLogger.bootstrapCardClasses'));
29+
@endphp
30+
1531
@section('content')
1632

1733
<div class="container-fluid">
@@ -22,41 +38,55 @@
2238

2339
<div class="row">
2440
<div class="col-sm-12">
25-
<div class="panel panel-danger">
26-
<div class="panel-heading">
27-
<div style="display: flesx; justify-content: spacse-between; align-items: censter;">
28-
29-
@lang('LaravelLogger::laravel-logger.dashboardCleared.title')
30-
31-
<sup class="label">
32-
{{ $totalActivities }} @lang('LaravelLogger::laravel-logger.dashboardCleared.subtitle')
33-
</sup>
34-
41+
<div class="{{ $containerClass }} {{ $bootstrapCardClasses }}">
42+
<div class="{{ $containerHeaderClass }}">
43+
<div style="display: flex; justify-content: space-between; align-items: center;">
44+
<span>
45+
@lang('LaravelLogger::laravel-logger.dashboardCleared.title')
46+
<sup class="label">
47+
{{ $totalActivities }} @lang('LaravelLogger::laravel-logger.dashboardCleared.subtitle')
48+
</sup>
49+
</span>
3550
<div class="btn-group pull-right btn-group-xs">
3651
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
3752
<i class="fa fa-ellipsis-v fa-fw" aria-hidden="true"></i>
3853
<span class="sr-only">
3954
@lang('LaravelLogger::laravel-logger.dashboard.menu.alt')
4055
</span>
4156
</button>
42-
<ul class="dropdown-menu">
43-
<li>
44-
<a href="{{route('activity')}}">
57+
@if(config('LaravelLogger.bootstapVersion') == '4')
58+
<div class="dropdown-menu dropdown-menu-right">
59+
<a href="{{route('activity')}}" class="dropdown-item">
4560
<span class="text-primary">
4661
<i class="fa fa-fw fa-mail-reply" aria-hidden="true"></i>
4762
@lang('LaravelLogger::laravel-logger.dashboard.menu.back')
4863
</span>
4964
</a>
50-
</li>
51-
@if($totalActivities)
52-
<li>
65+
@if($totalActivities)
5366
@include('LaravelLogger::forms.delete-activity-log')
54-
</li>
55-
<li>
5667
@include('LaravelLogger::forms.restore-activity-log')
68+
@endif
69+
</div>
70+
@else
71+
<ul class="dropdown-menu">
72+
<li>
73+
<a href="{{route('activity')}}">
74+
<span class="text-primary">
75+
<i class="fa fa-fw fa-mail-reply" aria-hidden="true"></i>
76+
@lang('LaravelLogger::laravel-logger.dashboard.menu.back')
77+
</span>
78+
</a>
5779
</li>
58-
@endif
59-
</ul>
80+
@if($totalActivities)
81+
<li>
82+
@include('LaravelLogger::forms.delete-activity-log')
83+
</li>
84+
<li>
85+
@include('LaravelLogger::forms.restore-activity-log')
86+
</li>
87+
@endif
88+
</ul>
89+
@endif
6090
</div>
6191
</div>
6292
</div>

Diff for: src/resources/views/logger/activity-log-item.blade.php

+23-11
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,20 @@
1313
@endif
1414

1515
@php
16+
switch (config('LaravelLogger.bootstapVersion')) {
17+
case '4':
18+
$containerClass = 'card';
19+
$containerHeaderClass = 'card-header';
20+
$containerBodyClass = 'card-body';
21+
break;
22+
case '3':
23+
default:
24+
$containerClass = 'panel panel-default';
25+
$containerHeaderClass = 'panel-heading';
26+
$containerBodyClass = 'panel-body';
27+
}
28+
$bootstrapCardClasses = (is_null(config('LaravelLogger.bootstrapCardClasses')) ? '' : config('LaravelLogger.bootstrapCardClasses'));
29+
1630
switch ($activity->userType) {
1731
case trans('LaravelLogger::laravel-logger.userTypes.registered'):
1832
$userTypeClass = 'success';
@@ -126,19 +140,17 @@
126140
@endif
127141

128142
<div class="panel @if($isClearedEntry) panel-danger @else panel-default @endif">
129-
<div class="panel-heading">
143+
<div class="{{ $containerClass }} @if($isClearedEntry) panel-danger @else panel-default @endif">
144+
<div class="{{ $containerHeaderClass }} @if($isClearedEntry) bg-danger text-white @else @endif" >
130145
@lang('LaravelLogger::laravel-logger.drilldown.title', ['id' => $activity->id])
131-
132-
133-
134-
<a href="@if($isClearedEntry) {{route('cleared')}} @else {{route('activity')}} @endif" class="btn @if($isClearedEntry) btn-default @else btn-info @endif btn-xs pull-right">
146+
<a href="@if($isClearedEntry) {{route('cleared')}} @else {{route('activity')}} @endif" class="btn @if($isClearedEntry) btn-default @else btn-info @endif btn-sm pull-right">
135147
<i class="fa fa-fw fa-mail-reply" aria-hidden="true"></i>
136148
@lang('LaravelLogger::laravel-logger.drilldown.buttons.back')
137149
</a>
138150
</div>
139-
<div class="panel-body">
151+
<div class="{{ $containerBodyClass }}">
140152
<div class="row">
141-
<div class="col-xs-12">
153+
<div class="col-xs-12 col-12">
142154
<div class="row">
143155

144156
<div class="col-md-6 col-lg-4">
@@ -194,7 +206,7 @@
194206

195207
<dt>@lang('LaravelLogger::laravel-logger.drilldown.list-group.labels.methodType')</dt>
196208
<dd>
197-
<span class="label label-{{$methodClass}}">
209+
<span class="badge badge-{{$methodClass}}">
198210
{{ $activity->methodType }}
199211
</span>
200212
</dd>
@@ -247,7 +259,7 @@
247259
<dl class="dl-horizontal">
248260
<dt>@lang('LaravelLogger::laravel-logger.drilldown.list-group.labels.userType')</dt>
249261
<dd>
250-
<span class="label label-{{$userTypeClass}}">
262+
<span class="badge badge-{{$userTypeClass}}">
251263
{{$activity->userType}}
252264
</span>
253265
</dd>
@@ -278,7 +290,7 @@
278290
@endif
279291

280292
<dd>
281-
<span class="label label-{{$labelClass}}">
293+
<span class="badge badge-{{$labelClass}}">
282294
{{ $user_role->name }} - @lang('LaravelLogger::laravel-logger.drilldown.labels.userLevel') {{ $user_role->level }}
283295
</span>
284296
</dd>
@@ -329,7 +341,7 @@
329341

330342
@if(!$isClearedEntry)
331343
<div class="row">
332-
<div class="col-xs-12">
344+
<div class="col-xs-12 col-12">
333345
<ul class="list-group">
334346
<li class="list-group-item list-group-item-info">
335347
@lang('LaravelLogger::laravel-logger.drilldown.title-user-activity')

Diff for: src/resources/views/logger/partials/activity-table.blade.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@
9898
}
9999
100100
@endphp
101-
<span class="label label-{{$userTypeClass}}">
101+
<span class="badge badge-{{$userTypeClass}}">
102102
{{$userLabel}}
103103
</span>
104104
</td>
@@ -126,7 +126,7 @@
126126
break;
127127
}
128128
@endphp
129-
<span class="label label-{{$methodClass}}">
129+
<span class="badge badge-{{$methodClass}}">
130130
{{ $activity->methodType }}
131131
</span>
132132
</td>

0 commit comments

Comments
 (0)