Skip to content

Commit bed22db

Browse files
committed
fix audit log
1 parent c921eda commit bed22db

File tree

6 files changed

+83
-27
lines changed

6 files changed

+83
-27
lines changed

app/Http/Controllers/AuditLogsController.php

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public function show(int $id)
5555
return view('logs.show', compact('auditLog'));
5656
}
5757

58-
public function history(int $id)
58+
public function history(string $type, int $id)
5959
{
6060
// Only for admin and users
6161
abort_if(
@@ -64,10 +64,17 @@ public function history(int $id)
6464
'403 Forbidden'
6565
);
6666

67-
// Get audit Log
68-
$auditLog = AuditLog::find($id);
69-
70-
abort_if($auditLog === null, 400, '400 log not found');
67+
// Set the object type
68+
if ($type=='bob')
69+
$type = 'App\Models\Control';
70+
elseif ($type='alice')
71+
$type = 'App\Models\Measure';
72+
elseif ($type='action')
73+
$type = 'App\Models\Action';
74+
elseif ($type='user')
75+
$type = 'App\Models\User';
76+
else
77+
abort(404, 'Not found');
7178

7279
// Get the list
7380
$auditLogs =
@@ -84,8 +91,8 @@ public function history(int $id)
8491
'audit_logs.created_at'
8592
)
8693
->join('users', 'users.id', '=', 'user_id')
87-
->where('subject_id', $auditLog->subject_id)
88-
->where('subject_type', $auditLog->subject_type)
94+
->where('subject_id', $id)
95+
->where('subject_type', $type)
8996
->orderBy('audit_logs.id')
9097
->get();
9198

resources/views/actions/index.blade.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,10 +132,18 @@
132132
{{ $action->status }}
133133
@endif
134134
</td>
135-
<td>
136-
@if ($action->progress!==null)
137-
{{ $action->progress }} %
135+
<td width="40">
136+
<div data-role="donut" data-value="{{ $action->progress }}"
137+
{{ $action->progress }}
138+
@if ($action->progress<25)
139+
class="donut-red"
140+
@elseif ($action->progress<50)
141+
class="donut-orange"
142+
@else
143+
class="donut-green"
138144
@endif
145+
>
146+
</div>
139147
</td>
140148
<td >
141149
<b>{{ $action->name }}</b>

resources/views/controls/show.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@
294294
</button>
295295
</form>
296296
&nbsp;
297-
<a class="button" href="/logs/history/{{ $control->id }}">
297+
<a class="button" href="/logs/history/bob/{{ $control->id }}">
298298
<span class="mif-log-file"></span>
299299
&nbsp;
300300
{{ trans("common.history") }}

resources/views/logs/index.blade.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,17 @@ class="table striped row-hover cell-border"
9191
<a class="button success small" href="/logs/show/{{ $log->id }}">
9292
{{ trans('common.show') }}
9393
</a>
94-
<a class="button info small" href="/logs/history/{{ $log->id }}">
94+
<a class="button info small"
95+
@if ($log->subject_type=='App\\Models\\Measure')
96+
href="/logs/history/alice/{{ $log->subject_id }}"
97+
@elseif ($log->subject_type=='App\\Models\\Control')
98+
href="/logs/history/bob/{{ $log->subject_id }}"
99+
@elseif ($log->subject_type=='App\\Models\\Action')
100+
href="/logs/history/action/{{ $log->subject_id }}"
101+
@elseif ($log->subject_type=='App\\Models\\User')
102+
href="/logs/history/user/{{ $log->subject_id }}"
103+
@endif
104+
>
95105
{{ trans('common.history') }}
96106
</a>
97107
</td>

resources/views/radar/actions.blade.php

Lines changed: 45 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,6 @@
5454
<table
5555
id="controls"
5656
class="table striped row-hover cell-border"
57-
data-role="table"
58-
data-rows="100"
59-
data-show-activity="true"
60-
data-rownum="false"
61-
data-check="false"
62-
data-check-style="1"
63-
data-show-search="false"
64-
data-show-pagination="false"
65-
data-show-rows-steps="false"
6657
>
6758
<thead>
6859
<tr>
@@ -78,10 +69,8 @@ class="table striped row-hover cell-border"
7869
<td>{{ $action->reference }}</td>
7970
<td>{{ $action->scope }}</td>
8071
<td>{{ $action->name }}</td>
81-
<td>
82-
<div data-role="donut" data-value="{{ $action->progress }}" class="donut-red"
83-
data-stroke="#f5f5f5" data-fill="#9C27B0" data-color="#FFFFFF">
84-
</div>
72+
<td style="padding: 0; text-align: center; vertical-align: middle;" width=400 height=110>
73+
<canvas id="progressChart1" width="400" height="100"></canvas>
8574
</td>
8675
</tr>
8776
@endforeach
@@ -92,6 +81,7 @@ class="table striped row-hover cell-border"
9281
</div>
9382
</div>
9483
</div>
84+
9585
</form>
9686

9787
<script>
@@ -119,7 +109,6 @@ class="table striped row-hover cell-border"
119109
]
120110
};
121111
122-
123112
const ctx = document.getElementById('actionsChart').getContext('2d');
124113
const myChart = new Chart(ctx, {
125114
type: 'bar',
@@ -162,6 +151,48 @@ class="table striped row-hover cell-border"
162151
});
163152
});
164153
154+
155+
new Chart(document.getElementById("progressChart1"), {
156+
type: 'line',
157+
data: {
158+
datasets: [{
159+
label: 'Progression',
160+
data: [
161+
{ x: '2025-07-01', y: 10 },
162+
{ x: '2025-07-10', y: 35 },
163+
{ x: '2025-07-15', y: 50 },
164+
{ x: '2025-07-25', y: 80 },
165+
{ x: '2025-07-29', y: 100 }
166+
],
167+
borderColor: "#2196F3",
168+
backgroundColor: "transparent",
169+
borderWidth: 2,
170+
pointRadius: 3
171+
}]
172+
},
173+
options: {
174+
responsive: false,
175+
scales: {
176+
x: {
177+
type: 'time',
178+
display: false // ⛔️ masque les dates
179+
},
180+
181+
y: {
182+
beginAtZero: true,
183+
max: 100,
184+
display: false
185+
}
186+
},
187+
plugins: {
188+
legend: { display: false },
189+
datalabels: {
190+
display: false // 👈 Désactive les labels à côté des points
191+
},
192+
}
193+
}
194+
});
195+
165196
});
166197
</script>
167198

routes/web.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@
124124
// Audit Logs
125125
Route::get('/logs', 'AuditLogsController@index');
126126
Route::get('/logs/show/{id}', 'AuditLogsController@show');
127-
Route::get('/logs/history/{id}', 'AuditLogsController@history');
127+
Route::get('/logs/history/{type}/{id}', 'AuditLogsController@history');
128128

129129
/* Exports */
130130
Route::get('/export/domains', 'DomainController@export');

0 commit comments

Comments
 (0)