Add Superuser Logging Dashboard
This commit is contained in:
@@ -3,11 +3,11 @@
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Requests\DataTableRequest;
|
||||
use App\Models\Login;
|
||||
use App\Models\Logging;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Http\Request;
|
||||
use Inertia\Inertia;
|
||||
|
||||
use Illuminate\Support\Facades\Log;
|
||||
class LoggingController extends Controller
|
||||
{
|
||||
/**
|
||||
@@ -26,22 +26,10 @@ class LoggingController extends Controller
|
||||
{
|
||||
$request->validated();
|
||||
|
||||
return Logging::join('users', 'login_activities.user_id', '=', 'users.id')
|
||||
->where(function (Builder $query) use ($request) {
|
||||
$search = '%' . $request->search . '%';
|
||||
$rec = Logging::today()->select(['*'])->paginate($request->per_page ?: 30);
|
||||
|
||||
$query->where('users.name', 'like', $search)
|
||||
->orWhere('users.username', 'like', $search)
|
||||
->orWhere('login_activities.ip_address', 'like', $search)
|
||||
->orWhere('login_activities.browser', 'like', $search)
|
||||
->orWhere('login_activities.platform', 'like', $search)
|
||||
->orWhere('login_activities.created_at', 'like', $search);
|
||||
})
|
||||
->when(!$request->user()->hasRole('superuser'), function (Builder $query) use ($request) {
|
||||
$query->where('users.id', $request->user()->id);
|
||||
})
|
||||
->select(['users.*', 'login_activities.*'])
|
||||
->orderBy($request->input('order.key') ?: 'login_activities.created_at', $request->input('order.dir') ?: 'desc')
|
||||
->paginate($request->per_page ?: 10);
|
||||
Log::info("message",["rec" => $rec]);
|
||||
|
||||
return $rec;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,8 +25,9 @@ class ProductsCompareController extends Controller
|
||||
$countries = $request->input("countries");
|
||||
$online = $request->input("online");
|
||||
$text = $request->input("text");
|
||||
$country = $request->input("country");
|
||||
|
||||
Log::channel('db')->info("{codes} {countries} {online} {text} {ip} {referer}", ["codes" => $codes, "countries" => $countries, "online" => $online, "text" => $text, "ip" => $request->ip(), $request->headers->get('referer')]);
|
||||
Log::channel('db')->info("{codes} {countries} {country} {online} {text} {ip} {referer}", ["codes" => $codes, "countries" => $countries, "country" => $country, "online" => $online, "text" => $text, "ip" => $request->ip(), $request->headers->get('referer')]);
|
||||
|
||||
$codes = collect($codes);
|
||||
$countries = collect($countries);
|
||||
|
||||
21
app/Models/Logging.php
Normal file
21
app/Models/Logging.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Logging extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'log_messages';
|
||||
|
||||
protected function today() {
|
||||
return $this->whereDate('logged_at',Carbon::today());
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@
|
||||
"license": "MIT",
|
||||
"require": {
|
||||
"php": "^8.0.2",
|
||||
"alfrasc/laravel-matomo-tracker": "^1.0",
|
||||
"beyondcode/laravel-websockets": "^1.13",
|
||||
"guzzlehttp/guzzle": "^7.2",
|
||||
"hisorange/browser-detect": "^4.5",
|
||||
|
||||
123
composer.lock
generated
123
composer.lock
generated
@@ -4,8 +4,73 @@
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "31ac3d5515d95b8df2c3e650f681dfe2",
|
||||
"content-hash": "932b0270f36b70f4585461c8c5e49167",
|
||||
"packages": [
|
||||
{
|
||||
"name": "alfrasc/laravel-matomo-tracker",
|
||||
"version": "v1.0.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/alfrasc/laravel-matomo-tracker.git",
|
||||
"reference": "dd9e82ceb6388ea5f5b80eba28d1d99a17c68305"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/alfrasc/laravel-matomo-tracker/zipball/dd9e82ceb6388ea5f5b80eba28d1d99a17c68305",
|
||||
"reference": "dd9e82ceb6388ea5f5b80eba28d1d99a17c68305",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"matomo/matomo-php-tracker": "^3.0.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"mockery/mockery": "^1.1",
|
||||
"orchestra/testbench": "~3.0",
|
||||
"phpunit/phpunit": "~7.0",
|
||||
"sempro/phpunit-pretty-print": "^1.0"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"laravel": {
|
||||
"providers": [
|
||||
"Alfrasc\\MatomoTracker\\LaravelMatomoTrackerServiceProvider"
|
||||
],
|
||||
"aliases": {
|
||||
"LaravelMatomoTracker": "Alfrasc\\MatomoTracker\\Facades\\LaravelMatomoTracker"
|
||||
}
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Alfrasc\\MatomoTracker\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"BSD-3-Clause"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Alexander Schmidhuber",
|
||||
"email": "alexander.schmidhuber@gmail.com",
|
||||
"homepage": "https://schmidhuber.co.at"
|
||||
}
|
||||
],
|
||||
"description": "A Laravel facade/wrapper for the matomo/matomo-php-tracker for server side Matomo tracking.",
|
||||
"homepage": "https://github.com/alfrasc/matomotracker",
|
||||
"keywords": [
|
||||
"Matomo PHP Tracker",
|
||||
"Piwik PHP Tracker",
|
||||
"laravel",
|
||||
"piwik",
|
||||
"server side tracking"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/alfrasc/laravel-matomo-tracker/issues",
|
||||
"source": "https://github.com/alfrasc/laravel-matomo-tracker/tree/v1.0.0"
|
||||
},
|
||||
"time": "2021-11-18T11:36:18+00:00"
|
||||
},
|
||||
{
|
||||
"name": "bacon/bacon-qr-code",
|
||||
"version": "2.0.8",
|
||||
@@ -3465,6 +3530,62 @@
|
||||
},
|
||||
"time": "2024-02-16T16:26:57+00:00"
|
||||
},
|
||||
{
|
||||
"name": "matomo/matomo-php-tracker",
|
||||
"version": "3.2.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/matomo-org/matomo-php-tracker.git",
|
||||
"reference": "c9e7816d63ddf99bffb1414cfbe45f4c4edf1d4b"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/matomo-org/matomo-php-tracker/zipball/c9e7816d63ddf99bffb1414cfbe45f4c4edf1d4b",
|
||||
"reference": "c9e7816d63ddf99bffb1414cfbe45f4c4edf1d4b",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"ext-json": "*",
|
||||
"php": "^7.0 || ^8.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^9.3"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-curl": "Using this extension to issue the HTTPS request to Matomo"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
"."
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"BSD-3-Clause"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "The Matomo Team",
|
||||
"email": "hello@matomo.org",
|
||||
"homepage": "https://matomo.org/team/"
|
||||
}
|
||||
],
|
||||
"description": "PHP Client for Matomo Analytics Tracking API",
|
||||
"homepage": "https://matomo.org",
|
||||
"keywords": [
|
||||
"analytics",
|
||||
"matomo",
|
||||
"piwik",
|
||||
"tracker"
|
||||
],
|
||||
"support": {
|
||||
"forum": "https://forum.matomo.org/",
|
||||
"issues": "https://github.com/matomo-org/matomo-php-tracker/issues",
|
||||
"source": "https://github.com/matomo-org/matomo-php-tracker"
|
||||
},
|
||||
"time": "2023-03-24T15:16:22+00:00"
|
||||
},
|
||||
{
|
||||
"name": "mobiledetect/mobiledetectlib",
|
||||
"version": "2.8.45",
|
||||
|
||||
29
config/matomotracker.php
Normal file
29
config/matomotracker.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/**
|
||||
* The URL of your Matomo install
|
||||
*/
|
||||
'url' => env('MATOMO_URL', 'https://matomo.soson.eu'),
|
||||
|
||||
/**
|
||||
* The id of the site that should be tracked
|
||||
*/
|
||||
'idSite' => env('MATOMO_SITE_ID', 3),
|
||||
|
||||
/**
|
||||
* The auth token of your user
|
||||
*/
|
||||
'tokenAuth' => env('MATOMO_AUTH_TOKEN', ''),
|
||||
|
||||
/**
|
||||
* For queuing the tracking you can use custom queue names. Use 'default' if you want to run the queued items within the standard queue.
|
||||
*/
|
||||
'queue' => env('MATOMO_QUEUE', 'matomotracker'),
|
||||
|
||||
/**
|
||||
* Optionally set a custom queue connection. Laravel defaults to "sync".
|
||||
*/
|
||||
'queueConnection' => env('MATOMO_QUEUE_CONNECTION', 'default'),
|
||||
];
|
||||
@@ -137,5 +137,6 @@
|
||||
"error: request failed with status code 419": "Error: Request failed with status code 419",
|
||||
"error: network error": "Error: Network Error",
|
||||
"error: ziggy error: route 'products.count' is not in the route list.": "Error: Ziggy error: route 'products.count' is not in the route list.",
|
||||
"doc": "Doc"
|
||||
"doc": "Doc",
|
||||
"firefox 125": "Firefox 125"
|
||||
}
|
||||
@@ -21,6 +21,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@coreui/vue": "^4.10.2",
|
||||
"@inertiajs/vue3": "^1.0.15",
|
||||
"@vueform/multiselect": "^2.5.1",
|
||||
"flag-icons": "^7.2.0",
|
||||
"flowbite": "^2.1.1",
|
||||
|
||||
0
resources/adminer/plugins/.gitignore
vendored
Normal file
0
resources/adminer/plugins/.gitignore
vendored
Normal file
@@ -21,6 +21,10 @@ import {
|
||||
FwbFooterLinkGroup,
|
||||
} from 'flowbite-vue';
|
||||
|
||||
import { Link, usePage } from '@inertiajs/vue3'
|
||||
|
||||
const isAuth = computed(() => page.props.auth.user)
|
||||
|
||||
import Multiselect from "vue-multiselect";
|
||||
import { settingsStore } from '../settingsStore.js';
|
||||
const menu = ref([])
|
||||
@@ -33,6 +37,7 @@ const currencyHash = ref([])
|
||||
|
||||
const ccountry = ref([])
|
||||
|
||||
|
||||
const ccountry_list = computed(() => {
|
||||
let computed_list = settingsStore.ccountry_list.filter((c) => (c.offline == (settingsStore.online ? 'N' : 'Y')) || settingsStore.online == true);
|
||||
console.log('COMPUTED_LIST',computed_list);
|
||||
@@ -221,6 +226,13 @@ onMounted(fetch_menu);
|
||||
<fwb-navbar-link :link="route(menu[0].route_or_url)">
|
||||
Home
|
||||
</fwb-navbar-link>
|
||||
<fwb-navbar-link v-if="$page.props.user" :link="route('profile.show')">
|
||||
Profile
|
||||
</fwb-navbar-link>
|
||||
<fwb-navbar-link v-if="!$page.props.user" :link="route('login')">
|
||||
Login
|
||||
</fwb-navbar-link>
|
||||
|
||||
<fwb-mega-menu link="#">
|
||||
<template #default>{{ tsettings }}</template>
|
||||
</fwb-mega-menu>
|
||||
|
||||
@@ -404,6 +404,7 @@ const showRow = async (item) => {
|
||||
currency: settingsStore.currency,
|
||||
online: settingsStore.online,
|
||||
text: settingsStore.text,
|
||||
country: settingsStore.country.code,
|
||||
});
|
||||
|
||||
products.value = response.data.products;
|
||||
|
||||
115
resources/js/Pages/Superuser/Activity/Logging.vue
Normal file
115
resources/js/Pages/Superuser/Activity/Logging.vue
Normal file
@@ -0,0 +1,115 @@
|
||||
<script setup>
|
||||
import DashboardLayout from '@/Layouts/DashboardLayout.vue';
|
||||
import Card from '@/Components/Card.vue';
|
||||
import Icon from '@/Components/Icon.vue';
|
||||
import Builder from '@/Components/DataTable/Builder.vue';
|
||||
import Th from '@/Components/DataTable/Th.vue';
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<DashboardLayout
|
||||
title="Logging Activity"
|
||||
>
|
||||
<Card class="bg-white dark:bg-gray-700 dark:text-gray-200">
|
||||
<template #header>
|
||||
<div class="flex items-center space-x-2 bg-gray-200 dark:bg-gray-800 p-2">
|
||||
<p class="lowercase first-letter:capitalize font-semibold">
|
||||
Logging
|
||||
</p>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<template #body>
|
||||
<Builder
|
||||
:url="route('superuser.activity.logging')"
|
||||
>
|
||||
<template #thead="table">
|
||||
<tr class="bg-gray-200 dark:bg-gray-800 border-gray-300 dark:border-gray-900">
|
||||
<Th
|
||||
:table="table"
|
||||
:sort="false"
|
||||
name="id"
|
||||
class="border p-2 text-center"
|
||||
>
|
||||
ID
|
||||
</Th>
|
||||
|
||||
<Th
|
||||
:table="table"
|
||||
:sort="true"
|
||||
name="level_name"
|
||||
class="border px-3 py-2 text-center whitespace-nowrap"
|
||||
>
|
||||
Level Name
|
||||
</Th>
|
||||
|
||||
<Th
|
||||
:table="table"
|
||||
:sort="true"
|
||||
name="message"
|
||||
class="border px-3 py-2 text-center whitespace-nowrap"
|
||||
>
|
||||
Message
|
||||
</Th>
|
||||
|
||||
<Th
|
||||
:table="table"
|
||||
:sort="true"
|
||||
name="context"
|
||||
class="border px-3 py-2 text-center whitespace-nowrap"
|
||||
>
|
||||
Context
|
||||
</Th>
|
||||
|
||||
<Th
|
||||
:table="table"
|
||||
:sort="true"
|
||||
name="logged_at"
|
||||
class="border px-3 py-2 text-center whitespace-nowrap"
|
||||
>
|
||||
Logged At
|
||||
</Th>
|
||||
</tr>
|
||||
</template>
|
||||
|
||||
|
||||
|
||||
<template #tbody="{ data }">
|
||||
<TransitionGroup
|
||||
enterActiveClass="transition-all duration-100"
|
||||
leaveActiveClass="transition-all duration-50"
|
||||
enterFromClass="opacity-0 -scale-y-100"
|
||||
leaveToClass="opacity-0 -scale-y-100"
|
||||
>
|
||||
<tr
|
||||
v-for="(rec, i) in data"
|
||||
:key="i"
|
||||
class="dark:hover:bg-gray-600 dark:border-gray-800 transition-all duration-300"
|
||||
>
|
||||
<td class="px-2 py-1 border border-inherit text-center">
|
||||
{{ rec.id }}
|
||||
</td>
|
||||
|
||||
<td class="px-2 py-1 border border-inherit uppercase">
|
||||
{{ rec.level_name }}
|
||||
</td>
|
||||
|
||||
<td class="px-2 py-1 border border-inherit uppercase">
|
||||
{{ rec.message }}
|
||||
</td>
|
||||
|
||||
<td class="px-2 py-1 border border-inherit uppercase">
|
||||
{{ rec.context }}
|
||||
</td>
|
||||
|
||||
<td class="px-2 py-1 border border-inherit uppercase">
|
||||
{{ rec.logged_at }}
|
||||
</td>
|
||||
</tr>
|
||||
</TransitionGroup>
|
||||
</template>
|
||||
</Builder>
|
||||
</template>
|
||||
</Card>
|
||||
</DashboardLayout>
|
||||
</template>
|
||||
@@ -12,6 +12,8 @@ use App\Http\Controllers\FeedbackController;
|
||||
use App\Http\Controllers\SettingsController;
|
||||
use App\Http\Controllers\OnlineCompareController;
|
||||
use App\Http\Controllers\ProductsCountController;
|
||||
use App\Http\Controllers\LoggingController;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Web Routes
|
||||
@@ -54,9 +56,9 @@ Route::get('phpmyinfo', function () {
|
||||
})->name('phpmyinfo');
|
||||
|
||||
Route::middleware(['auth:sanctum', config('jetstream.auth_session'), 'verified'])->group(function () {
|
||||
// Route::get('/', function () {
|
||||
// return Inertia::render('Dashboard');
|
||||
// })->name('dashboard');
|
||||
Route::get('/dashboard', function () {
|
||||
return Inertia::render('Dashboard');
|
||||
})->name('dashboard');
|
||||
|
||||
Route::prefix('/superuser')->name('superuser.')->group(function () {
|
||||
Route::resource('permission', App\Http\Controllers\Superuser\PermissionController::class)->only([
|
||||
@@ -89,7 +91,8 @@ Route::middleware(['auth:sanctum', config('jetstream.auth_session'), 'verified']
|
||||
Route::patch('/', 'update')->name('update');
|
||||
});
|
||||
|
||||
Route::get('/activity/login', [App\Http\Controllers\ActivityController::class, 'login'])->name('activity.login');
|
||||
Route::get('/activity/login', [App\Http\Controllers\ActivityController::class, 'login'])->name('gin');
|
||||
Route::get('/activity/logging', [App\Http\Controllers\LoggingController::class, 'logging'])->name('activity.logging');
|
||||
|
||||
Route::get('/user/{user}/menu', fn (App\Models\User $user) => $user->menus())->name('user.menu');
|
||||
Route::get('/permission/get', [App\Http\Controllers\Superuser\PermissionController::class, 'get'])->name('permission');
|
||||
@@ -97,6 +100,7 @@ Route::middleware(['auth:sanctum', config('jetstream.auth_session'), 'verified']
|
||||
Route::post('/role/paginate', [App\Http\Controllers\Superuser\RoleController::class, 'paginate'])->name('role.paginate');
|
||||
Route::post('/user/paginate', [App\Http\Controllers\Superuser\UserController::class, 'paginate'])->name('user.paginate');
|
||||
Route::post('/activity/login', [App\Http\Controllers\ActivityController::class, 'logins'])->name('activity.login.post');
|
||||
Route::post('/activity/logging', [App\Http\Controllers\LoggingController::class, 'records'])->name('activity.logging.post');
|
||||
Route::get('/menu/get', [App\Http\Controllers\Superuser\MenuController::class, 'get'])->name('menu');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user