@@ -43,13 +43,13 @@ discard block |
||
| 43 | 43 | $location = $device->location ?? null; |
| 44 | 44 | |
| 45 | 45 | //If the location exists then set the pagination page to be where the device is located |
| 46 | - if ($location != null) |
|
| 47 | - $request->merge(['page' => $device->dashPageNum(4)]); |
|
| 46 | + if ($location != null) { |
|
| 47 | + $request->merge(['page' => $device->dashPageNum(4)]); |
|
| 48 | + } |
|
| 48 | 49 | $site_id = $location->site_id ?? 0; |
| 49 | 50 | $location_id = $location->id ?? 0; |
| 50 | 51 | $device_id = $device->id ?? 0; |
| 51 | - } |
|
| 52 | - else |
|
| 52 | + } else |
|
| 53 | 53 | { |
| 54 | 54 | //Get the active site, location, and device ids |
| 55 | 55 | $site_id = $request->site_id ?? 0; |
@@ -83,8 +83,9 @@ discard block |
||
| 83 | 83 | { |
| 84 | 84 | //If the original device with the given device id was not found |
| 85 | 85 | //Then assign the the first device in the device list as the active device |
| 86 | - if ($active_device == null) |
|
| 87 | - $active_device = $devices[0]; |
|
| 86 | + if ($active_device == null) { |
|
| 87 | + $active_device = $devices[0]; |
|
| 88 | + } |
|
| 88 | 89 | |
| 89 | 90 | //Add an attribute to each device defining if it is stale |
| 90 | 91 | $devices->transform(function ($item) |
@@ -98,9 +99,9 @@ discard block |
||
| 98 | 99 | { |
| 99 | 100 | $imageStaleMins = ceil(($item->image_rate * 3) / 60) + 1; |
| 100 | 101 | $item['isImageStale'] = ($item->image_updated_at <= Carbon::now()->subMinute($imageStaleMins)) ? true : false; |
| 102 | + } else { |
|
| 103 | + $item['isImageStale'] = false; |
|
| 101 | 104 | } |
| 102 | - else |
|
| 103 | - $item['isImageStale'] = false; |
|
| 104 | 105 | |
| 105 | 106 | return $item; |
| 106 | 107 | }); |
@@ -112,12 +113,13 @@ discard block |
||
| 112 | 113 | //Use the device_list.blade.php to generate the device table html |
| 113 | 114 | $html_device_table = view('dashboard.device_list', ['devices' => $devices, 'active_data' => $active_data])->render(); |
| 114 | 115 | |
| 115 | - if (\Request::ajax()) |
|
| 116 | - return response()->json([ 'active_data' => $active_data, 'devices' => $devices, 'locations' => $locations, |
|
| 116 | + if (\Request::ajax()) { |
|
| 117 | + return response()->json([ 'active_data' => $active_data, 'devices' => $devices, 'locations' => $locations, |
|
| 117 | 118 | 'sites' => $sites, 'html_device_table' => $html_device_table ]); |
| 118 | - else |
|
| 119 | - return view('dashboard.index', [ 'active_data' => $active_data, 'devices' => $devices, |
|
| 119 | + } else { |
|
| 120 | + return view('dashboard.index', [ 'active_data' => $active_data, 'devices' => $devices, |
|
| 120 | 121 | 'locations' => $locations, 'sites' => $sites ]); |
| 122 | + } |
|
| 121 | 123 | } |
| 122 | 124 | |
| 123 | 125 | /** |