Add more info at status page

This commit is contained in:
Pig Fang 2019-08-28 16:04:26 +08:00
parent fb3f58856c
commit c9cdc6640c
7 changed files with 61 additions and 7 deletions

View File

@ -14,6 +14,7 @@ use Illuminate\Support\Arr;
use Illuminate\Support\Str;
use App\Services\OptionForm;
use Illuminate\Http\Request;
use App\Services\PluginManager;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Redis;
@ -362,12 +363,21 @@ class AdminController extends Controller
->with('forms', compact('resources', 'redis', 'cache'));
}
public function status(Request $request)
public function status(Request $request, PluginManager $plugins)
{
$db = get_db_config();
$enabledPlugins = $plugins->getEnabledPlugins()->map(function ($plugin) {
return ['title' => trans($plugin->title), 'version' => $plugin->version];
});
return view('admin.status')
->with('detail', [
'bs' => [
'version' => config('app.version'),
'env' => config('app.env'),
'debug' => config('app.debug') ? trans('general.yes') : trans('general.no'),
'laravel' => app()->version(),
],
'server' => [
'php' => PHP_VERSION,
'web' => $request->server('SERVER_SOFTWARE', trans('general.unknown')),
@ -381,7 +391,8 @@ class AdminController extends Controller
'database' => Arr::get($db, 'database'),
'prefix' => Arr::get($db, 'prefix'),
],
]);
])
->with('plugins', $enabledPlugins);
}
public function getUserData(Request $request, User $users)

View File

@ -85,6 +85,14 @@ customize:
black-light: Black Light
status:
info: Information
health: Health
bs:
name: Blessing Skin
version: Version
env: Application Environment
debug: Debugging or Not?
laravel: Laravel Version
server:
name: Server
php: PHP Version
@ -98,6 +106,7 @@ status:
username: Username
database: Database
prefix: Table Prefix
plugins: Enabled Plugins (:amount)
plugins:
name: Name

View File

@ -43,6 +43,8 @@ reset: Reset
submit: Submit
cancel: Cancel
yes: Yes
no: No
op-success: Operated successfully.
unknown: Unknown

View File

@ -85,6 +85,14 @@ customize:
black-light: 黑色主题 - 白色侧边栏
status:
info: 信息
health: 健康
bs:
name: Blessing Skin
version: 版本
env: 应用环境
debug: 是否处于调试状态
laravel: Laravel 版本
server:
name: 服务器
php: PHP 版本
@ -98,6 +106,7 @@ status:
username: 用户名
database: 数据库
prefix: 数据表前缀
plugins: 已开启的插件 (:amount)
plugins:
name: 名称

View File

@ -43,6 +43,8 @@ reset: 重置
submit: 提交
cancel: 取消
yes:
no:
op-success: 操作成功
unknown: 未知

View File

@ -10,10 +10,11 @@
<section class="content">
<div class="row">
<div class="col-md-2"></div>
<div class="col-md-8">
<div class="col-md-6">
<div class="box">
<div class="box-header"></div>
<div class="box-header">
<h3 class="box-title">@lang('admin.status.info')</h3>
</div>
<div class="box-body">
<table class="table table-bordered table-striped">
<tbody>
@ -28,12 +29,21 @@
</tr>
@endforeach
@endforeach
<tr>
<th colspan="2">@lang('admin.status.plugins', ['amount' => $plugins->count()])</th>
</tr>
@foreach ($plugins as $plugin)
<tr>
<td>{{ $plugin['title'] }}</td>
<td>{{ $plugin['version'] }}</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
</div>
<div class="col-md-2"></div>
<div class="col-md-6"></div>
</div>
</section>
</div>

View File

@ -7,6 +7,7 @@ use App\Models\User;
use App\Models\Player;
use App\Notifications;
use App\Models\Texture;
use App\Services\Plugin;
use Illuminate\Support\Str;
use Illuminate\Foundation\Testing\WithoutMiddleware;
use Illuminate\Foundation\Testing\DatabaseTransactions;
@ -118,9 +119,19 @@ class AdminControllerTest extends TestCase
public function testStatus()
{
$this->mock(\App\Services\PluginManager::class, function ($mock) {
$mock->shouldReceive('getEnabledPlugins')
->andReturn(collect([
'a' => new Plugin('', ['title' => 'MyPlugin', 'version' => '0.0.0'])
]));
});
$this->get('/admin/status')
->assertSee(PHP_VERSION)
->assertSee(humanize_db_type());
->assertSee(humanize_db_type())
->assertSee('(1)')
->assertSee('MyPlugin')
->assertSee('0.0.0');
}
public function testUsers()