|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Yaro\Jarboe\Http\Controllers; |
|
4
|
|
|
|
|
5
|
|
|
use Illuminate\Routing\Controller; |
|
6
|
|
|
use Yaro\Jarboe\Helpers\System; |
|
7
|
|
|
use Yaro\Jarboe\Table\CRUD; |
|
8
|
|
|
|
|
9
|
|
|
class CommonController extends Controller |
|
10
|
|
|
{ |
|
11
|
|
|
public function resetPanelSettings() |
|
12
|
|
|
{ |
|
13
|
|
|
setcookie('body_class', null, -1, '/'); |
|
14
|
|
|
|
|
15
|
|
|
/** @var CRUD $crud */ |
|
16
|
|
|
$crud = app(CRUD::class); |
|
17
|
|
|
$crud->preferences()->resetAll(); |
|
18
|
|
|
|
|
19
|
|
|
return redirect()->back(); |
|
20
|
|
|
} |
|
21
|
|
|
|
|
22
|
|
|
public function refreshSystemValues() |
|
|
|
|
|
|
23
|
|
|
{ |
|
24
|
|
|
$system = new System(); |
|
25
|
|
|
|
|
26
|
|
|
$swapExplanation = 'NA'; |
|
27
|
|
|
if (!is_null($system->swapTotal())) { |
|
28
|
|
|
$swapExplanation = $system->readableSize($system->swapUsed()) .' / '. $system->readableSize($system->swapTotal()); |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
$memoryExplanation = 'NA'; |
|
32
|
|
|
if (!is_null($system->memoryTotal())) { |
|
33
|
|
|
$memoryExplanation = $system->readableSize($system->memoryUsed()) .' / '. $system->readableSize($system->memoryTotal()); |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
return response()->json([ |
|
|
|
|
|
|
37
|
|
|
'swap' => [ |
|
38
|
|
|
'explanation' => $swapExplanation, |
|
39
|
|
|
'percentage' => $system->swapPercentage(), |
|
40
|
|
|
], |
|
41
|
|
|
'memory' => [ |
|
42
|
|
|
'explanation' => $memoryExplanation, |
|
43
|
|
|
'percentage' => $system->memoryPercentage(), |
|
44
|
|
|
], |
|
45
|
|
|
'load_average' => [ |
|
46
|
|
|
'explanation' => implode(' ', $system->systemLoadSamples()), |
|
47
|
|
|
'percentages' => $system->systemLoadSamplesInPercentages(), |
|
48
|
|
|
], |
|
49
|
|
|
]); |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
public function notFoundPage() |
|
|
|
|
|
|
53
|
|
|
{ |
|
54
|
|
|
return response()->view('jarboe::errors.404')->setStatusCode(404); |
|
|
|
|
|
|
55
|
|
|
} |
|
56
|
|
|
} |
|
57
|
|
|
|
Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a
@returnannotation as described here.