@@ -25,7 +25,6 @@ |
||
| 25 | 25 | |
| 26 | 26 | namespace App\DataTables\Alerting; |
| 27 | 27 | |
| 28 | -use App\Models\Alerting\Alert; |
|
| 29 | 28 | use App\Models\Alerting\Log; |
| 30 | 29 | use Yajra\Datatables\Services\DataTable; |
| 31 | 30 | |
@@ -102,7 +102,8 @@ |
||
| 102 | 102 | } catch(\Exception $e) { |
| 103 | 103 | if(starts_with($e->getMessage(), 'unserialize():')) { |
| 104 | 104 | return $value; |
| 105 | - } else { |
|
| 105 | + } |
|
| 106 | + else { |
|
| 106 | 107 | throw $e; |
| 107 | 108 | } |
| 108 | 109 | } |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | return '<b><span class="fa fa-'.$icon.'" style="color:'.$colour.'"></span> '.$text.'</b>'; |
| 83 | 83 | }) |
| 84 | 84 | ->editColumn('time_logged', function($log) { |
| 85 | - return date('Y-m-d H:i:s', $log->time_logged/1000); |
|
| 85 | + return date('Y-m-d H:i:s', $log->time_logged / 1000); |
|
| 86 | 86 | }) |
| 87 | 87 | ->make(true); |
| 88 | 88 | } |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | */ |
| 95 | 95 | public function query() |
| 96 | 96 | { |
| 97 | - $logs = Log::with('device','rule')->select('alert_log.*'); |
|
| 97 | + $logs = Log::with('device', 'rule')->select('alert_log.*'); |
|
| 98 | 98 | return $this->applyScopes($logs); |
| 99 | 99 | } |
| 100 | 100 | |
@@ -38,7 +38,7 @@ |
||
| 38 | 38 | */ |
| 39 | 39 | public function index(Request $request) |
| 40 | 40 | { |
| 41 | - $data = Log::join('alert_rules', 'alert_rules.id', '=', 'alert_log.rule_id')->where('state', '!=', '0')->groupBy('time_logged')->groupBy('alert_rules.severity')->select('time_logged','alert_rules.severity',\DB::raw('COUNT(alert_log.id) as total'))->get(); |
|
| 41 | + $data = Log::join('alert_rules', 'alert_rules.id', '=', 'alert_log.rule_id')->where('state', '!=', '0')->groupBy('time_logged')->groupBy('alert_rules.severity')->select('time_logged', 'alert_rules.severity', \DB::raw('COUNT(alert_log.id) as total'))->get(); |
|
| 42 | 42 | $output = array(); |
| 43 | 43 | foreach ($data as $log) { |
| 44 | 44 | $output[$log->severity]['label'] = $log->severity; |
@@ -96,7 +96,7 @@ |
||
| 96 | 96 | public function getTimeLoggedAttribute($date) |
| 97 | 97 | { |
| 98 | 98 | if ($date) { |
| 99 | - return strtotime($date)*1000; |
|
| 99 | + return strtotime($date) * 1000; |
|
| 100 | 100 | } |
| 101 | 101 | } |
| 102 | 102 | } |
@@ -27,7 +27,6 @@ |
||
| 27 | 27 | |
| 28 | 28 | use App\Api\Controllers\Controller; |
| 29 | 29 | use App\Models\General\Eventlog; |
| 30 | -use App\Models\Alerting\Log; |
|
| 31 | 30 | use Dingo\Api\Http; |
| 32 | 31 | use Dingo\Api\Routing\Helpers; |
| 33 | 32 | use Illuminate\Http\Request; |
@@ -76,7 +76,7 @@ |
||
| 76 | 76 | */ |
| 77 | 77 | public function query() |
| 78 | 78 | { |
| 79 | - $alerts = Alert::active()->with('device','rule')->select('alerts.*'); |
|
| 79 | + $alerts = Alert::active()->with('device', 'rule')->select('alerts.*'); |
|
| 80 | 80 | return $this->applyScopes($alerts); |
| 81 | 81 | } |
| 82 | 82 | |