文件收集任务 日志记录 前端

This commit is contained in:
Chenx221 2024-04-06 13:53:08 +08:00
parent 0aed2c7738
commit 6d72678b34
Signed by: chenx221
GPG Key ID: D7A9EC07024C3021
3 changed files with 83 additions and 3 deletions

View File

@ -2,6 +2,7 @@
namespace app\controllers;
use app\models\CollectionUploadedSearch;
use app\models\DownloadLogs;
use app\models\LoginLogs;
use app\models\SiteConfig;
@ -35,7 +36,7 @@ class AdminController extends Controller
'rules' => [
[
'allow' => true,
'actions' => ['index', 'system', 'user', 'info', 'user-view', 'user-create', 'user-update', 'user-delete', 'user-totpoff', 'user-pwdreset', 'login-log','access-log'],
'actions' => ['index', 'system', 'user', 'info', 'user-view', 'user-create', 'user-update', 'user-delete', 'user-totpoff', 'user-pwdreset', 'login-log', 'access-log', 'collection-up-log'],
'roles' => ['admin'], // only admin can do these
]
],
@ -55,6 +56,7 @@ class AdminController extends Controller
'user-pwdreset' => ['POST'],
'login-log' => ['GET'],
'access-log' => ['GET'],
'collection-up-log' => ['GET'],
],
],
]
@ -409,4 +411,17 @@ class AdminController extends Controller
'dataProvider' => $dataProvider,
]);
}
/**
* @return string
*/
public function actionCollectionUpLog(): string
{
$collectionUploadedSearch = new CollectionUploadedSearch();
$dataProvider = $collectionUploadedSearch->search($this->request->queryParams);
return $this->render('collection_up_log', [
'searchModel' => $collectionUploadedSearch,
'dataProvider' => $dataProvider,
]);
}
}

View File

@ -0,0 +1,64 @@
<?php
use yii\bootstrap5\Html;
use yii\bootstrap5\LinkPager;
use yii\grid\GridView;
use yii\widgets\Pjax;
/** @var yii\web\View $this */
/** @var app\models\CollectionUploadedSearch $searchModel */
/** @var yii\data\ActiveDataProvider $dataProvider */
$this->title = '文件收集上传日志';
?>
<div class="access-logs">
<h1><?= Html::encode($this->title) ?></h1>
<br>
<?php Pjax::begin(); ?>
<?= GridView::widget([
'dataProvider' => $dataProvider,
'columns' => [
[
'attribute' => 'user_id',
'label' => '用户',
'format' => 'html',
'value' => function ($model) {
return nl2br($model->user_id ? $model->user->username . "\n(ID:" . $model->user_id . ')' : '访客');
},
],
[
'attribute' => 'uploaded_at',
'label' => '上传时间',
'format' => 'html',
'enableSorting' => false,
'value' => function ($model) {
return nl2br($model->uploaded_at . "\n(" . Yii::$app->formatter->asRelativeTime(new DateTime($model->uploaded_at, new DateTimeZone('GMT+8'))) . ")");
},
],
[
'attribute' => 'task_id',
],
[
'attribute' => 'uploader_ip',
'label' => 'IP地址',
'format' => 'raw',
'value' => function ($model) {
return Html::a($model->uploader_ip, 'https://ipinfo.io/' . $model->uploader_ip, ['target' => '_blank']);
},
],
[
'attribute' => 'user_agent',
'label' => 'User Agent',
],
],
'pager' => [
'class' => LinkPager::class,
],
]);
?>
<?php Pjax::end(); ?>
</div>

View File

@ -76,8 +76,9 @@ $this->registerCssFile('@web/css/fuckyou-navpadding.css');
['label' => '用户管理', 'url' => ['/admin/user']],
['label' => '个人设置', 'url' => ['/admin/info']],
['label' => '日志管理', 'items' => [
['label' => '用户登录', 'url' => ['/admin/login-log']],
['label' => '分享访问', 'url' => ['/admin/access-log']]
['label' => '用户登录日志', 'url' => ['/admin/login-log']],
['label' => '分享访问日志', 'url' => ['/admin/access-log']],
['label' => '文件收集上传日志', 'url' => ['/admin/collection-up-log']],
],
],
['label' => '系统设置', 'url' => ['/admin/system']],