Skip to content

Commit

Permalink
controllers
Browse files Browse the repository at this point in the history
  • Loading branch information
Olav van Schie committed Jan 11, 2020
1 parent 65a23a7 commit 6b89f0d
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 29 deletions.
25 changes: 17 additions & 8 deletions dist/js/tool.js
Original file line number Diff line number Diff line change
Expand Up @@ -18813,10 +18813,8 @@ var render = function() {
_vm._v(" "),
_vm.showStatus
? _c(
"card",
{
staticClass: "w-full p-4 mt-4 bg-black text-white"
},
"div",
{ staticClass: "w-full mt-4 text-white" },
[
_c("heading", { staticClass: "text-white mb-4" }, [
_vm._v(
Expand All @@ -18830,15 +18828,15 @@ var render = function() {
_vm._v(_vm._s(_vm.status.cache_full))
])
]),
_c("p"),
_vm._v(" "),
_c("p", { staticClass: "mb-2" }, [
_vm._v("Restart pending: "),
_c("strong", [
_vm._v(_vm._s(_vm.status.restart_pending))
])
]),
_vm._v(" "),
_c("p", { staticClass: "mb-4" }, [
_c("p", { staticClass: "mb-2" }, [
_vm._v("Restart in progress: "),
_c("strong", [
_vm._v(_vm._s(_vm.status.restart_in_progress))
Expand All @@ -18847,6 +18845,7 @@ var render = function() {
_vm._v(" "),
_c("p", { staticClass: "mb-2" }, [
_vm._v("Start time: "),
_c("br"),
_c("strong", [
_vm._v(
_vm._s(
Expand All @@ -18858,8 +18857,9 @@ var render = function() {
])
]),
_vm._v(" "),
_c("p", { staticClass: "mb-4" }, [
_c("p", { staticClass: "mb-2" }, [
_vm._v("Last restart time: "),
_c("br"),
_c("strong", [
_vm._v(
_vm._s(
Expand Down Expand Up @@ -18970,7 +18970,16 @@ var render = function() {
_vm.status.opcache_statistics.num_cached_scripts
)
)
])
]),
_vm._v(
" (max " +
_vm._s(
_vm.config.directives[
"opcache.max_accelerated_files"
]
) +
")"
)
]),
_vm._v(" "),
_c("p", { staticClass: "mb-2" }, [
Expand Down
14 changes: 7 additions & 7 deletions resources/js/components/Tool.vue
Original file line number Diff line number Diff line change
Expand Up @@ -49,19 +49,19 @@
<button class="underline" @click="showStatus = !showStatus">Status info</button>
</div>

<card class="w-full p-4 mt-4 bg-black text-white" v-if="showStatus">
<div class="w-full mt-4 text-white" v-if="showStatus">
<heading class="text-white mb-4">
Status
</heading>
<p class="mb-2">Cache full: <strong>{{ status.cache_full }}</strong><p>
<p class="mb-2">Cache full: <strong>{{ status.cache_full }}</strong></p>
<p class="mb-2">Restart pending: <strong>{{ status.restart_pending }}</strong></p>
<p class="mb-4">Restart in progress: <strong>{{ status.restart_in_progress }}</strong></p>
<p class="mb-2">Start time: <strong>{{ new Date(status.opcache_statistics.start_time) }}</strong></p>
<p class="mb-4">Last restart time: <strong>{{ new Date(status.opcache_statistics.last_restart_time) }}</strong</p>
<p class="mb-2">Restart in progress: <strong>{{ status.restart_in_progress }}</strong></p>
<p class="mb-2">Start time: <br /><strong>{{ new Date(status.opcache_statistics.start_time) }}</strong></p>
<p class="mb-2">Last restart time: <br /><strong>{{ new Date(status.opcache_statistics.last_restart_time) }}</strong</p>
<p class="mb-2">Oom restarts: <strong>{{ status.opcache_statistics.oom_restarts }}</strong></p>
<p class="mb-2">Hash restarts: <strong>{{ status.opcache_statistics.hash_restarts }}</strong></p>
<p class="mb-2">Manual restarts: <strong>{{ status.opcache_statistics.manual_restarts }}</strong></p>
</card>
</div>
</card>
</div>

Expand Down Expand Up @@ -90,7 +90,7 @@
<heading class="text-white mb-4">
Cached
</heading>
<p class="mb-2">Scripts: <strong>{{ status.opcache_statistics.num_cached_scripts}}</strong></p>
<p class="mb-2">Scripts: <strong>{{ status.opcache_statistics.num_cached_scripts}}</strong> (max {{ config.directives['opcache.max_accelerated_files']}})</p>
<p class="mb-2">Keys: <strong>{{ status.opcache_statistics.num_cached_keys}}</strong> (max {{ status.opcache_statistics.max_cached_keys}})</p>
</card>
</div>
Expand Down
18 changes: 4 additions & 14 deletions routes/api.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
<?php

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;
use Appstract\Opcache\OpcacheFacade as OPcache;

/*
|--------------------------------------------------------------------------
Expand All @@ -15,18 +13,10 @@
|
*/

Route::get('/status', function (Request $request) {
return response()->json(OPcache::getStatus());
});
Route::get('/clear', 'NovaOpcacheController@clear');

Route::get('/config', function (Request $request) {
return response()->json(OPcache::getConfig());
});
Route::get('/config', 'NovaOpcacheController@config');

Route::get('/clear', function (Request $request) {
return response()->json(OPcache::clear());
});
Route::get('/status', 'NovaOpcacheController@status');

Route::get('/compile', function (Request $request) {
return response()->json(OPcache::compile(true));
});
Route::get('/compile', 'NovaOpcacheController@compile');
52 changes: 52 additions & 0 deletions src/Http/Controllers/NovaOpcacheController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php

namespace Appstract\NovaOpcache\Http\Controllers;

use Appstract\Opcache\OpcacheFacade as OPcache;
use Illuminate\Routing\Controller as BaseController;

/**
* Class OpcacheController.
*/
class NovaOpcacheController extends BaseController
{
/**
* Clear the OPcache.
*
* @return \Illuminate\Http\JsonResponse
*/
public function clear()
{
return response()->json(OPcache::clear());
}

/**
* Get config values.
*
* @return \Illuminate\Http\JsonResponse
*/
public function config()
{
return response()->json(OPcache::getConfig());
}

/**
* Get status info.
*
* @return \Illuminate\Http\JsonResponse
*/
public function status()
{
return response()->json(OPcache::getStatus());
}

/**
* Compile.
*
* @return \Illuminate\Http\JsonResponse
*/
public function compile()
{
return response()->json(OPcache::compile(true));
}
}
1 change: 1 addition & 0 deletions src/ToolServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ protected function routes()

Route::middleware(['nova', Authorize::class])
->prefix('nova-vendor/nova-opcache')
->namespace('Appstract\NovaOpcache\Http\Controllers')
->group(__DIR__.'/../routes/api.php');
}

Expand Down

0 comments on commit 6b89f0d

Please sign in to comment.