jqh 4 роки тому
батько
коміт
4a190ed2aa

+ 0 - 60
config/admin.php

@@ -260,59 +260,12 @@ return [
         'menu_model' => Dcat\Admin\Models\Menu::class,
 
         // Pivot table for table above.
-        'operation_log_table'    => 'admin_operation_log',
         'role_users_table'       => 'admin_role_users',
         'role_permissions_table' => 'admin_role_permissions',
         'role_menu_table'        => 'admin_role_menu',
         'permission_menu_table'  => 'admin_permission_menu',
     ],
 
-    /*
-    |--------------------------------------------------------------------------
-    | User operation log setting
-    |--------------------------------------------------------------------------
-    |
-    | By setting this option to open or close operation log in dcat-admin.
-    |
-    */
-    'operation_log' => [
-
-        'enable' => true,
-
-        // Only logging allowed methods in the list
-        'allowed_methods' => ['GET', 'HEAD', 'POST', 'PUT', 'DELETE', 'CONNECT', 'OPTIONS', 'TRACE', 'PATCH'],
-
-        'secret_fields' => [
-            'password',
-            'password_confirmation',
-        ],
-
-        // Routes that will not log to database.
-        // All method to path like: auth/logs/*/edit
-        // or specific method to path like: get:auth/logs.
-        'except' => [
-            'auth/logs*',
-        ],
-    ],
-
-    /*
-    |--------------------------------------------------------------------------
-    | Admin map field provider
-    |--------------------------------------------------------------------------
-    |
-    | Supported: "tencent", "google", "yandex", "baidu".
-    |
-    */
-    'map' => [
-        'provider' => 'baidu',
-
-        'keys' => [
-            'tencent' => env('TENCENT_MAP_API_KEY'),
-            'google' => env('GOOGLE_API_KEY'),
-            'baidu' => env('BAIDU_MAP_API_KEY'),
-        ],
-    ],
-
     /*
     |--------------------------------------------------------------------------
     | Application layout
@@ -363,17 +316,4 @@ return [
     | the extension files will be generated in this directory.
     */
     'extension_dir' => app_path('Admin/Extensions'),
-
-    /*
-    |--------------------------------------------------------------------------
-    | Settings for extensions.
-    |--------------------------------------------------------------------------
-    |
-    | You can find all available extensions here
-    | https://github.com/dcat-admin-extensions.
-    |
-    */
-    'extensions' => [
-
-    ],
 ];

+ 0 - 1
src/Admin.php

@@ -204,7 +204,6 @@ class Admin
                     /* @var \Illuminate\Routing\Router $router */
                     $router->resource('auth/users', 'UserController');
                     $router->resource('auth/menu', 'MenuController', ['except' => ['create', 'show']]);
-                    $router->resource('auth/logs', 'LogController', ['only' => ['index', 'destroy']]);
 
                     if (config('admin.permission.enable')) {
                         $router->resource('auth/roles', 'RoleController');

+ 0 - 2
src/AdminServiceProvider.php

@@ -51,7 +51,6 @@ class AdminServiceProvider extends ServiceProvider
     protected $routeMiddleware = [
         'admin.auth'       => Middleware\Authenticate::class,
         'admin.pjax'       => Middleware\Pjax::class,
-        'admin.log'        => Middleware\LogOperation::class,
         'admin.permission' => Middleware\Permission::class,
         'admin.bootstrap'  => Middleware\Bootstrap::class,
         'admin.session'    => Middleware\Session::class,
@@ -66,7 +65,6 @@ class AdminServiceProvider extends ServiceProvider
         'admin' => [
             'admin.auth',
             'admin.pjax',
-            'admin.log',
             'admin.bootstrap',
             'admin.permission',
             'admin.session',

+ 0 - 60
src/Console/stubs/config.stub

@@ -260,59 +260,12 @@ return [
         'menu_model' => Dcat\Admin\Models\Menu::class,
 
         // Pivot table for table above.
-        'operation_log_table'    => 'admin_operation_log',
         'role_users_table'       => 'admin_role_users',
         'role_permissions_table' => 'admin_role_permissions',
         'role_menu_table'        => 'admin_role_menu',
         'permission_menu_table'  => 'admin_permission_menu',
     ],
 
-    /*
-    |--------------------------------------------------------------------------
-    | User operation log setting
-    |--------------------------------------------------------------------------
-    |
-    | By setting this option to open or close operation log in dcat-admin.
-    |
-    */
-    'operation_log' => [
-
-        'enable' => true,
-
-        // Only logging allowed methods in the list
-        'allowed_methods' => ['GET', 'HEAD', 'POST', 'PUT', 'DELETE', 'CONNECT', 'OPTIONS', 'TRACE', 'PATCH'],
-
-        'secret_fields' => [
-            'password',
-            'password_confirmation',
-        ],
-
-        // Routes that will not log to database.
-        // All method to path like: auth/logs/*/edit
-        // or specific method to path like: get:auth/logs.
-        'except' => [
-            'auth/logs*',
-        ],
-    ],
-
-    /*
-	|--------------------------------------------------------------------------
-	| Admin map field provider
-	|--------------------------------------------------------------------------
-	|
-	| Supported: "tencent", "google", "yandex", "baidu".
-	|
-	*/
-	'map' => [
-		'provider' => 'baidu',
-
-		'keys' => [
-			'tencent' => env('TENCENT_MAP_API_KEY'),
-			'google' => env('GOOGLE_API_KEY'),
-			'baidu' => env('BAIDU_MAP_API_KEY'),
-		],
-	],
-
     /*
     |--------------------------------------------------------------------------
     | Application layout
@@ -353,17 +306,4 @@ return [
     | Whether enable default breadcrumb for every page content.
     */
     'enable_default_breadcrumb' => true,
-
-    /*
-    |--------------------------------------------------------------------------
-    | Settings for extensions.
-    |--------------------------------------------------------------------------
-    |
-    | You can find all available extensions here
-    | https://github.com/dcat-admin-extensions.
-    |
-    */
-    'extensions' => [
-
-    ],
 ];

+ 0 - 4
src/Controllers/AdminController.php

@@ -56,10 +56,6 @@ class AdminController extends Controller
      */
     public function index(Content $content)
     {
-        if (request(Grid::IFRAME_QUERY_NAME)) {
-            return $content->full()->body($this->iFrameGrid());
-        }
-
         return $content
             ->title($this->title())
             ->description($this->description()['index'] ?? trans('admin.list'))

+ 0 - 108
src/Controllers/LogController.php

@@ -1,108 +0,0 @@
-<?php
-
-namespace Dcat\Admin\Controllers;
-
-use Dcat\Admin\Grid;
-use Dcat\Admin\Layout\Content;
-use Dcat\Admin\Models\OperationLog as OperationLogModel;
-use Dcat\Admin\Models\Repositories\OperationLog;
-use Illuminate\Routing\Controller;
-use Illuminate\Support\Arr;
-
-class LogController extends Controller
-{
-    public function index(Content $content)
-    {
-        return $content
-            ->title(trans('admin.operation_log'))
-            ->description(trans('admin.list'))
-            ->body($this->grid());
-    }
-
-    protected function grid()
-    {
-        return new Grid(new OperationLog(), function (Grid $grid) {
-            $grid->column('id', 'ID')->sortable();
-            $grid->column('user', trans('admin.user'))
-                ->get('name')
-                ->link(function () {
-                    if ($this->user) {
-                        return admin_url('auth/users/'.$this->user['id']);
-                    }
-                })
-                ->responsive();
-
-            $grid->column('method', trans('admin.method'))
-                ->responsive()
-                ->label(OperationLogModel::$methodColors)
-                ->filterByValue();
-
-            $grid->column('path', trans('admin.uri'))->responsive()->display(function ($v) {
-                return "<code>$v</code>";
-            })->filterByValue();
-
-            $grid->column('ip', 'IP')->filterByValue()->responsive();
-
-            $grid->column('input')->responsive()->display(function ($input) {
-                $input = json_decode($input, true);
-
-                if (empty($input)) {
-                    return;
-                }
-
-                $input = Arr::except($input, ['_pjax', '_token', '_method', '_previous_']);
-
-                if (empty($input)) {
-                    return;
-                }
-
-                return '<pre class="dump">'.json_encode($input, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE).'</pre>';
-            });
-
-            $grid->column('created_at', trans('admin.created_at'))->responsive();
-
-            $grid->model()->with('user')->orderBy('id', 'DESC');
-
-            $grid->disableCreateButton();
-            $grid->disableQuickEditButton();
-            $grid->disableEditButton();
-            $grid->disableViewButton();
-            $grid->setActionClass(Grid\Displayers\Actions::class);
-
-            $grid->filter(function (Grid\Filter $filter) {
-                $userModel = config('admin.database.users_model');
-
-                $filter->in('user_id', trans('admin.user'))
-                    ->multipleSelect($userModel::pluck('name', 'id'));
-
-                $filter->equal('method', trans('admin.method'))
-                    ->select(
-                        array_combine(OperationLogModel::$methods, OperationLogModel::$methods)
-                    );
-
-                $filter->like('path', trans('admin.uri'));
-                $filter->equal('ip', 'IP');
-                $filter->between('created_at')->datetime();
-            });
-        });
-    }
-
-    public function destroy($id)
-    {
-        $ids = explode(',', $id);
-
-        if (OperationLogModel::destroy(array_filter($ids))) {
-            $data = [
-                'status'  => true,
-                'message' => trans('admin.delete_succeeded'),
-            ];
-        } else {
-            $data = [
-                'status'  => false,
-                'message' => trans('admin.delete_failed'),
-            ];
-        }
-
-        return response()->json($data);
-    }
-}

+ 0 - 119
src/Middleware/LogOperation.php

@@ -1,119 +0,0 @@
-<?php
-
-namespace Dcat\Admin\Middleware;
-
-use Dcat\Admin\Admin;
-use Dcat\Admin\Models\OperationLog as OperationLogModel;
-use Dcat\Admin\Support\Helper;
-use Illuminate\Http\Request;
-use Illuminate\Support\Str;
-
-class LogOperation
-{
-    /**
-     * Handle an incoming request.
-     *
-     * @param \Illuminate\Http\Request $request
-     * @param \Closure                 $next
-     *
-     * @return mixed
-     */
-    public function handle(Request $request, \Closure $next)
-    {
-        if ($this->shouldLogOperation($request)) {
-            $user = Admin::user();
-
-            $log = [
-                'user_id' => $user ? $user->id : 0,
-                'path'    => substr($request->path(), 0, 255),
-                'method'  => $request->method(),
-                'ip'      => $request->getClientIp(),
-                'input'   => $this->formatInput($request->input()),
-            ];
-
-            try {
-                OperationLogModel::create($log);
-            } catch (\Exception $exception) {
-                // pass
-            }
-        }
-
-        return $next($request);
-    }
-
-    /**
-     * @param array $input
-     *
-     * @return string
-     */
-    protected function formatInput(array $input)
-    {
-        foreach ((array) config('admin.operation_log.secret_fields') as $field) {
-            if ($field && ! empty($input[$field])) {
-                $input[$field] = Str::limit($input[$field], 3, '******');
-            }
-        }
-
-        return json_encode($input);
-    }
-
-    /**
-     * @param Request $request
-     *
-     * @return bool
-     */
-    protected function shouldLogOperation(Request $request)
-    {
-        return config('admin.operation_log.enable')
-            && ! $this->inExceptArray($request)
-            && $this->inAllowedMethods($request->method());
-    }
-
-    /**
-     * Whether requests using this method are allowed to be logged.
-     *
-     * @param string $method
-     *
-     * @return bool
-     */
-    protected function inAllowedMethods($method)
-    {
-        $allowedMethods = collect(config('admin.operation_log.allowed_methods'))->filter();
-
-        if ($allowedMethods->isEmpty()) {
-            return true;
-        }
-
-        return $allowedMethods->map(function ($method) {
-            return strtoupper($method);
-        })->contains($method);
-    }
-
-    /**
-     * Determine if the request has a URI that should pass through CSRF verification.
-     *
-     * @param \Illuminate\Http\Request $request
-     *
-     * @return bool
-     */
-    protected function inExceptArray($request)
-    {
-        if ($request->routeIs(admin_api_route('value'))) {
-            return true;
-        }
-
-        foreach (config('admin.operation_log.except') as $except) {
-            $except = admin_base_path($except);
-
-            if ($except !== '/') {
-                $except = trim($except, '/');
-            }
-
-            if (Helper::matchRequestPath($except)) {
-                return true;
-            }
-        }
-
-        return false;
-    }
-}

+ 0 - 11
src/Models/Repositories/OperationLog.php

@@ -1,11 +0,0 @@
-<?php
-
-namespace Dcat\Admin\Models\Repositories;
-
-use Dcat\Admin\Models\OperationLog as OperationLogModel;
-use Dcat\Admin\Repositories\EloquentRepository;
-
-class OperationLog extends EloquentRepository
-{
-    protected $eloquentClass = OperationLogModel::class;
-}