Merge pull request #610 from LinkStackOrg/user-management

Update users table
This commit is contained in:
Julian Prieber 2023-10-26 11:40:49 +02:00 committed by GitHub
commit e9d4759583
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 626 additions and 184 deletions

View File

@ -223,6 +223,21 @@ public function SendTestMail(Request $request)
return redirect('admin/users/all');
}
//Delete existing user with POST request
public function deleteTableUser(request $request)
{
$id = $request->id;
Link::where('user_id', $id)->delete();
Schema::disableForeignKeyConstraints();
$user = User::find($id);
$user->forceDelete();
Schema::enableForeignKeyConstraints();
}
//Show user to edit
public function showUser(request $request)
{

View File

@ -0,0 +1,127 @@
<?php
namespace App\Http\Livewire;
use App\Http\Livewire;
use Rappasoft\LaravelLivewireTables\DataTableComponent;
use Rappasoft\LaravelLivewireTables\Views\Column;
use App\Models\User;
use App\Models\Link;
class UserTable extends DataTableComponent
{
protected $model = User::class;
public function configure(): void
{
$this->setPrimaryKey('id');
$this->setPerPageAccepted([50, 100, 250, 500, 1000, -1]);
$this->setColumnSelectEnabled();
}
public function columns(): array
{
return [
Column::make(__('messages.ID'), "id")
->sortable()
->searchable(),
Column::make(__('messages.Name'), "name")
->sortable()
->searchable(),
Column::make(__('messages.E-Mail'), "email")
->sortable()
->searchable(),
Column::make(__('messages.Page'), "littlelink_name")
->sortable()
->searchable()
->format(function ($value, $row, Column $column) {
if (!$row->littlelink_name == NULL) {
return "<a href='" . url('') . "/@" . $row->littlelink_name . "' target='_blank' class='text-info'><i class='bi bi-box-arrow-up-right'></i>&nbsp; " . $row->littlelink_name . " </a>";
} else {
return 'N/A';
}
})
->html(),
Column::make(__('messages.Role'), "role")
->sortable()
->searchable(),
Column::make(__('messages.Links'), "id")
->format(function ($value, $row) {
$linkCount = Link::where('user_id', $row->id)->count();
return $linkCount;
}),
Column::make(__('messages.Clicks'), "id")
->format(function ($value, $row) {
$clicksSum = Link::where('user_id', $row->id)->sum('click_number');
return $clicksSum;
}),
Column::make(__('messages.E-Mail'), "email_verified_at")
->sortable()
->format(function ($value, $row, Column $column) {
if (env('REGISTER_AUTH') !== 'auth') {
if ($row->role == 'admin' && $row->email_verified_at != '') {
return '<center>-</center>';
} else {
$verifyLink = route('verifyUser', [
'verify' => '-' . $row->email_verified_at,
'id' => $row->id
]);
if ($row->email_verified_at == '') {
return '<a style="cursor:pointer" data-id="'.$verifyLink.'" class="user-email text-danger"><span class="badge bg-danger">' . __('messages.Pending') . '</span></a>';
} else {
return '<a style="cursor:pointer" data-id="'.$verifyLink.'" class="user-email text-danger"><span class="badge bg-success">' . __('messages.Verified') . '</span></a>';
}
}
} else {
return '<center>-</center>';
}
return '';
})->html(),
Column::make(__('messages.Status'), "block")
->sortable()
->format(function ($value, $row, Column $column) {
if ($row->role === 'admin' && $row->id === 1) {
return '<center>-</center>';
} else {
$route = route('blockUser', ['block' => $row->block, 'id' => $row->id]);
if ($row->block === 'yes') {
$badge = '<a style="cursor:pointer" data-id="'.$route.'" class="user-block text-danger"><span class="badge bg-danger">'.__('messages.Pending').'</span></a>';
} elseif ($row->block === 'no') {
$badge = '<a style="cursor:pointer" data-id="'.$route.'" class="user-block text-danger"><span class="badge bg-success">'.__('messages.Approved').'</span></a>';
}
return "<a href=\"$route\">$badge</a>";
}
})
->html(),
Column::make(__('messages.Created at'), "created_at")
->sortable()
->format(function ($value) {
if ($value) {
return $value->format('d/m/y');
} else {
return '';
}
}),
Column::make(__('messages.Last seen'), "updated_at")
->sortable()
->format(function ($value) {
$now = now();
$diff = $now->diff($value);
if ($diff->d < 1 && $diff->h < 1) {
return 'Now';
} elseif ($diff->d < 1 && $diff->h < 24) {
return $diff->h . ' hours ago';
} elseif ($diff->d < 365) {
return $diff->d . ' days ago';
} else {
return $diff->y . ' years ago';
}
}),
Column::make(__('messages.Action'), "id")
->format(function ($value, $row, Column $column) {
return view('components.table-components.action', ['user' => $row]);
}),
];
}
}

View File

@ -0,0 +1,14 @@
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
class LivewireServiceProvider extends ServiceProvider
{
public function register()
{
$assetUrl = url('');
config(['livewire.asset_url' => $assetUrl]);
}
}

5
assets/js/cdn.min.js vendored Normal file

File diff suppressed because one or more lines are too long

8
assets/js/livewire-sortable.js vendored Normal file

File diff suppressed because one or more lines are too long

View File

@ -18,6 +18,8 @@
"laravel/framework": "^9.52.4",
"laravel/socialite": "^5.5",
"laravel/tinker": "^2.5",
"livewire/livewire": "^2.12",
"rappasoft/laravel-livewire-tables": "^2.15",
"spatie/laravel-backup": "^8.17"
},
"require-dev": {

147
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "f681cfe300acd922f41ba6210924fd7f",
"content-hash": "b2eafc10eb774aaa9bb7ce8353b44da2",
"packages": [
{
"name": "awssat/laravel-visits",
@ -2962,6 +2962,79 @@
],
"time": "2021-06-28T04:27:21+00:00"
},
{
"name": "livewire/livewire",
"version": "v2.12.6",
"source": {
"type": "git",
"url": "https://github.com/livewire/livewire.git",
"reference": "7d3a57b3193299cf1a0639a3935c696f4da2cf92"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/livewire/livewire/zipball/7d3a57b3193299cf1a0639a3935c696f4da2cf92",
"reference": "7d3a57b3193299cf1a0639a3935c696f4da2cf92",
"shasum": ""
},
"require": {
"illuminate/database": "^7.0|^8.0|^9.0|^10.0",
"illuminate/support": "^7.0|^8.0|^9.0|^10.0",
"illuminate/validation": "^7.0|^8.0|^9.0|^10.0",
"league/mime-type-detection": "^1.9",
"php": "^7.2.5|^8.0",
"symfony/http-kernel": "^5.0|^6.0"
},
"require-dev": {
"calebporzio/sushi": "^2.1",
"laravel/framework": "^7.0|^8.0|^9.0|^10.0",
"mockery/mockery": "^1.3.1",
"orchestra/testbench": "^5.0|^6.0|^7.0|^8.0",
"orchestra/testbench-dusk": "^5.2|^6.0|^7.0|^8.0",
"phpunit/phpunit": "^8.4|^9.0",
"psy/psysh": "@stable"
},
"type": "library",
"extra": {
"laravel": {
"providers": [
"Livewire\\LivewireServiceProvider"
],
"aliases": {
"Livewire": "Livewire\\Livewire"
}
}
},
"autoload": {
"files": [
"src/helpers.php"
],
"psr-4": {
"Livewire\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Caleb Porzio",
"email": "calebporzio@gmail.com"
}
],
"description": "A front-end framework for Laravel.",
"support": {
"issues": "https://github.com/livewire/livewire/issues",
"source": "https://github.com/livewire/livewire/tree/v2.12.6"
},
"funding": [
{
"url": "https://github.com/livewire",
"type": "github"
}
],
"time": "2023-08-11T04:02:34+00:00"
},
{
"name": "monolog/monolog",
"version": "2.9.1",
@ -4460,6 +4533,78 @@
],
"time": "2023-04-15T23:01:58+00:00"
},
{
"name": "rappasoft/laravel-livewire-tables",
"version": "v2.15.0",
"source": {
"type": "git",
"url": "https://github.com/rappasoft/laravel-livewire-tables.git",
"reference": "26c596d4d4bb0e0efdfcd48de16071fc5ed969ef"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/rappasoft/laravel-livewire-tables/zipball/26c596d4d4bb0e0efdfcd48de16071fc5ed969ef",
"reference": "26c596d4d4bb0e0efdfcd48de16071fc5ed969ef",
"shasum": ""
},
"require": {
"illuminate/contracts": "^8.0|^9.0|^10.0",
"livewire/livewire": "^2.6",
"php": "^7.4|^8.0|^8.1|^8.2",
"spatie/laravel-package-tools": "^1.4.3"
},
"require-dev": {
"brianium/paratest": "^4.0|^5.0|^6.0|^7.0",
"ext-sqlite3": "*",
"nunomaduro/collision": "^4.0|^5.0|^6.0|^7.0",
"orchestra/testbench": "^6.0|^7.0|^8.0",
"phpunit/phpunit": "^9.0|^10.0"
},
"type": "library",
"extra": {
"laravel": {
"providers": [
"Rappasoft\\LaravelLivewireTables\\LaravelLivewireTablesServiceProvider"
]
}
},
"autoload": {
"psr-4": {
"Rappasoft\\LaravelLivewireTables\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Anthony Rappa",
"email": "rappa819@gmail.com",
"role": "Developer"
}
],
"description": "A dynamic table component for Laravel Livewire",
"homepage": "https://github.com/rappasoft/laravel-livewire-tables",
"keywords": [
"datatables",
"laravel",
"livewire",
"rappasoft",
"tables"
],
"support": {
"issues": "https://github.com/rappasoft/laravel-livewire-tables/issues",
"source": "https://github.com/rappasoft/laravel-livewire-tables/tree/v2.15.0"
},
"funding": [
{
"url": "https://github.com/rappasoft",
"type": "github"
}
],
"time": "2023-07-15T19:50:12+00:00"
},
{
"name": "spatie/db-dumper",
"version": "3.4.0",

View File

@ -181,6 +181,7 @@ return [
Illuminate\Validation\ValidationServiceProvider::class,
Illuminate\View\ViewServiceProvider::class,
Laravel\Socialite\SocialiteServiceProvider::class,
App\Providers\LivewireServiceProvider::class,

View File

@ -0,0 +1,8 @@
<?php
return [
/**
* Options: tailwind | bootstrap-4 | bootstrap-5.
*/
'theme' => 'bootstrap-5',
];

158
config/livewire.php Normal file
View File

@ -0,0 +1,158 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Class Namespace
|--------------------------------------------------------------------------
|
| This value sets the root namespace for Livewire component classes in
| your application. This value affects component auto-discovery and
| any Livewire file helper commands, like `artisan make:livewire`.
|
| After changing this item, run: `php artisan livewire:discover`.
|
*/
'class_namespace' => 'App\\Http\\Livewire',
/*
|--------------------------------------------------------------------------
| View Path
|--------------------------------------------------------------------------
|
| This value sets the path for Livewire component views. This affects
| file manipulation helper commands like `artisan make:livewire`.
|
*/
'view_path' => resource_path('views/livewire'),
/*
|--------------------------------------------------------------------------
| Layout
|--------------------------------------------------------------------------
| The default layout view that will be used when rendering a component via
| Route::get('/some-endpoint', SomeComponent::class);. In this case the
| the view returned by SomeComponent will be wrapped in "layouts.app"
|
*/
'layout' => 'layouts.app',
/*
|--------------------------------------------------------------------------
| Livewire Assets URL
|--------------------------------------------------------------------------
|
| This value sets the path to Livewire JavaScript assets, for cases where
| your app's domain root is not the correct path. By default, Livewire
| will load its JavaScript assets from the app's "relative root".
|
| Examples: "/assets", "myurl.com/app".
|
*/
'asset_url' => null,
/*
|--------------------------------------------------------------------------
| Livewire App URL
|--------------------------------------------------------------------------
|
| This value should be used if livewire assets are served from CDN.
| Livewire will communicate with an app through this url.
|
| Examples: "https://my-app.com", "myurl.com/app".
|
*/
'app_url' => null,
/*
|--------------------------------------------------------------------------
| Livewire Endpoint Middleware Group
|--------------------------------------------------------------------------
|
| This value sets the middleware group that will be applied to the main
| Livewire "message" endpoint (the endpoint that gets hit everytime
| a Livewire component updates). It is set to "web" by default.
|
*/
'middleware_group' => 'web',
/*
|--------------------------------------------------------------------------
| Livewire Temporary File Uploads Endpoint Configuration
|--------------------------------------------------------------------------
|
| Livewire handles file uploads by storing uploads in a temporary directory
| before the file is validated and stored permanently. All file uploads
| are directed to a global endpoint for temporary storage. The config
| items below are used for customizing the way the endpoint works.
|
*/
'temporary_file_upload' => [
'disk' => null, // Example: 'local', 's3' Default: 'default'
'rules' => null, // Example: ['file', 'mimes:png,jpg'] Default: ['required', 'file', 'max:12288'] (12MB)
'directory' => null, // Example: 'tmp' Default 'livewire-tmp'
'middleware' => null, // Example: 'throttle:5,1' Default: 'throttle:60,1'
'preview_mimes' => [ // Supported file types for temporary pre-signed file URLs.
'png', 'gif', 'bmp', 'svg', 'wav', 'mp4',
'mov', 'avi', 'wmv', 'mp3', 'm4a',
'jpg', 'jpeg', 'mpga', 'webp', 'wma',
],
'max_upload_time' => 5, // Max duration (in minutes) before an upload gets invalidated.
],
/*
|--------------------------------------------------------------------------
| Manifest File Path
|--------------------------------------------------------------------------
|
| This value sets the path to the Livewire manifest file.
| The default should work for most cases (which is
| "<app_root>/bootstrap/cache/livewire-components.php"), but for specific
| cases like when hosting on Laravel Vapor, it could be set to a different value.
|
| Example: for Laravel Vapor, it would be "/tmp/storage/bootstrap/cache/livewire-components.php".
|
*/
'manifest_path' => null,
/*
|--------------------------------------------------------------------------
| Back Button Cache
|--------------------------------------------------------------------------
|
| This value determines whether the back button cache will be used on pages
| that contain Livewire. By disabling back button cache, it ensures that
| the back button shows the correct state of components, instead of
| potentially stale, cached data.
|
| Setting it to "false" (default) will disable back button cache.
|
*/
'back_button_cache' => false,
/*
|--------------------------------------------------------------------------
| Render On Redirect
|--------------------------------------------------------------------------
|
| This value determines whether Livewire will render before it's redirected
| or not. Setting it to "false" (default) will mean the render method is
| skipped when redirecting. And "true" will mean the render method is
| run before redirecting. Browsers bfcache can store a potentially
| stale view if render is skipped on redirect.
|
*/
'render_on_redirect' => false,
];

View File

@ -0,0 +1,39 @@
@if($user->role == 'admin' and $user->id == 1)<center>-</center>
@else
<div class="flex align-items-center list-user-action">
<a class="btn btn-sm btn-icon btn-success" data-bs-toggle="tooltip" data-bs-placement="top" data-original-title="{{__('messages.tt.All links')}}" href="{{ route('showLinksUser', $user->id ) }}" aria-label="All links" data-bs-original-title="All links">
<span class="btn-inner">
<svg class="icon-20" width="20" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<circle cx="11.7669" cy="11.7666" r="8.98856" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></circle>
<path d="M18.0186 18.4851L21.5426 22" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path>
</svg>
</span>
</a>
<a class="btn btn-sm btn-icon btn-warning" data-bs-toggle="tooltip" data-bs-placement="top" data-original-title="{{__('messages.tt.Edit')}}" href="{{ route('editUser', $user->id ) }}" aria-label="Edit" data-bs-original-title="Edit">
<span class="btn-inner">
<svg class="icon-20" width="20" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M11.4925 2.78906H7.75349C4.67849 2.78906 2.75049 4.96606 2.75049 8.04806V16.3621C2.75049 19.4441 4.66949 21.6211 7.75349 21.6211H16.5775C19.6625 21.6211 21.5815 19.4441 21.5815 16.3621V12.3341" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path>
<path fill-rule="evenodd" clip-rule="evenodd" d="M8.82812 10.921L16.3011 3.44799C17.2321 2.51799 18.7411 2.51799 19.6721 3.44799L20.8891 4.66499C21.8201 5.59599 21.8201 7.10599 20.8891 8.03599L13.3801 15.545C12.9731 15.952 12.4211 16.181 11.8451 16.181H8.09912L8.19312 12.401C8.20712 11.845 8.43412 11.315 8.82812 10.921Z" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path>
<path d="M15.1655 4.60254L19.7315 9.16854" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path>
</svg>
</span>
</a>
<a class="btn btn-sm btn-icon btn-primary" style="@if(!$user->adminUser && Auth::user()->id !== $user->id && $user->block !== 'yes' && ($user->email_verified_at != '' || env('REGISTER_AUTH') == 'auth')) background:#3a57e8;border-color:#3a57e8; @else background:#6c757d;border-color:#6c757d; @endif" data-bs-toggle="tooltip" data-bs-placement="top" data-original-title="{{__('messages.tt.Impersonate')}}" @if(!$user->adminUser && Auth::user()->id !== $user->id && $user->block !== 'yes' && ($user->email_verified_at != '' || env('REGISTER_AUTH') == 'auth')) href="{{ route('authAsID', $user->id ) }}" @endif aria-label="Impersonate" data-bs-original-title="Impersonate">
<span class="btn-inner">
<svg class="icon-20" width="20" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M9.59151 15.2068C13.2805 15.2068 16.4335 15.7658 16.4335 17.9988C16.4335 20.2318 13.3015 20.8068 9.59151 20.8068C5.90151 20.8068 2.74951 20.2528 2.74951 18.0188C2.74951 15.7848 5.88051 15.2068 9.59151 15.2068Z" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path>
<path fill-rule="evenodd" clip-rule="evenodd" d="M9.59157 12.0198C7.16957 12.0198 5.20557 10.0568 5.20557 7.63476C5.20557 5.21276 7.16957 3.24976 9.59157 3.24976C12.0126 3.24976 13.9766 5.21276 13.9766 7.63476C13.9856 10.0478 12.0356 12.0108 9.62257 12.0198H9.59157Z" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path> <path d="M16.4829 10.8815C18.0839 10.6565 19.3169 9.28253 19.3199 7.61953C19.3199 5.98053 18.1249 4.62053 16.5579 4.36353" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path> <path d="M18.5952 14.7322C20.1462 14.9632 21.2292 15.5072 21.2292 16.6272C21.2292 17.3982 20.7192 17.8982 19.8952 18.2112" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path>
</svg>
</span>
</a>
<a class="btn btn-sm btn-icon btn-danger confirmation" data-bs-toggle="tooltip" data-bs-placement="top" data-original-title="{{__('messages.tt.Delete')}}" href="{{ route('deleteUser', ['id' => $user->id] ) }}" aria-label="Delete" data-bs-original-title="Delete">
<span class="btn-inner">
<svg class="icon-20" width="20" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" stroke="currentColor">
<path d="M19.3248 9.46826C19.3248 9.46826 18.7818 16.2033 18.4668 19.0403C18.3168 20.3953 17.4798 21.1893 16.1088 21.2143C13.4998 21.2613 10.8878 21.2643 8.27979 21.2093C6.96079 21.1823 6.13779 20.3783 5.99079 19.0473C5.67379 16.1853 5.13379 9.46826 5.13379 9.46826" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path>
<path d="M20.708 6.23975H3.75" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path>
<path d="M17.4406 6.23973C16.6556 6.23973 15.9796 5.68473 15.8256 4.91573L15.5826 3.69973C15.4326 3.13873 14.9246 2.75073 14.3456 2.75073H10.1126C9.53358 2.75073 9.02558 3.13873 8.87558 3.69973L8.63258 4.91573C8.47858 5.68473 7.80258 6.23973 7.01758 6.23973" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path>
</svg>
</span>
</a>
</div>
@endif

View File

@ -791,7 +791,6 @@ $usrhandl = Auth::user()->littlelink_name;
<script src="{{ asset('assets/js/jquery-block-ui.js') }}"></script>
<script src="{{ asset('assets/js/main-dashboard.js') }}"></script>
@stack('sidebar-scripts')
</body>

View File

@ -4,7 +4,9 @@
@section('content')
<style>#cs{cursor: pointer;}.delete{color:transparent; background-color:tomato; border-radius:5px; padding:8px 12px; cursor: pointer;}.delete:hover{color:transparent;background-color:#f13d1d;}html,body{max-width:100%;overflow-x:hidden;}.shorten{cursor:help;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:150px;}</style>
<style>
[x-cloak] { display: none !important; }
</style>
<div class="conatiner-fluid content-inner mt-n5 py-0">
<div class="row">
@ -20,141 +22,98 @@
<h2 class="mb-4 card-header"><i class="bi bi-person"> {{__('messages.Manage Users')}}</i></h2>
<div class="card-body p-0 p-md-3">
<form action="{{ route('searchUser') }}" method="post">
@csrf
<div class="row">
<div class="col-lg-8">
<div class="input-group mb-3">
<input type="text" name="name" placeholder="{{__('messages.Search user')}}" class="form-control">
<div class="input-group-append">
<button type="submit" class="btn btn-primary"><i class="bi bi-search"></i></button>
</div>
</div>
</div>
</div>
</form>
{{__('messages.Users:')}}
<a href="{{ url('') }}/admin/users/all">All</a> -
<a href="{{ url('') }}/admin/users/user">User</a> -
<a href="{{ url('') }}/admin/users/vip">Vip</a> -
<a href="{{ url('') }}/admin/users/admin">Admin</a>
<livewire:user-table />
<div class="row"><div class="table-responsive">
<table id="sortable" class="table table-stripped">
<thead>
<tr>
<th id="cs" scope="col" data-sort="id" data-order="asc">{{__('messages.ID')}}</th>
<th id="cs" scope="col" data-sort="name" data-order="asc">{{__('messages.Name')}}</th>
<th id="cs" scope="col" data-sort="email" data-order="asc">{{__('messages.E-Mail')}}</th>
<th id="cs" scope="col" data-sort="page" data-order="asc">{{__('messages.Page')}}</th>
<th id="cs" scope="col" data-sort="role" data-order="asc">{{__('messages.Role')}}</th>
<th id="cs" scope="col" data-sort="links" data-order="asc">{{__('messages.Links')}}</th>
<th id="cs" scope="col" data-sort="clicks" data-order="asc">{{__('messages.Clicks')}}</th>
<th id="cs" scope="col" data-sort="created" data-order="asc">{{__('messages.Created at')}}</th>
<th id="cs" scope="col" data-sort="last" data-order="asc">{{__('messages.Last seen')}}</th>
@if(env('REGISTER_AUTH') !== 'auth')<th id="cs" scope="col">{{__('messages.E-Mail')}}</th>@endif
<th id="cs" scope="col" data-sort="block" data-order="asc">{{__('messages.Status')}}</th>
<th scope="col" data-sortable="false">{{__('messages.Action')}}</th>
</tr>
</thead>
<tbody>
@foreach($users as $user)
@php
$dateFormat = __('messages.date.format');
$date = date($dateFormat, strtotime($user->created_at));
if(!isset($user->created_at)){$date = __('messages.N/A');}
$lastSeen = $user->updated_at;
$lastSeenDate = date($dateFormat, strtotime($lastSeen));
$timezone = new DateTimeZone(date_default_timezone_get());
$datetime = new DateTime($lastSeen, $timezone);
$now = new DateTime(null, $timezone);
$interval = $now->diff($datetime);
$daysAgo = $interval->days." ".__('messages.days ago');
if($interval->days == 1) $daysAgo = __('messages.1 day ago');
if($interval->days == 0) $daysAgo = __('messages.Today');
if ($interval->days >= 365) {
$yearsAgo = floor($interval->days / 365);
if ($yearsAgo == 1) {
$daysAgo = __('messages.1 year ago');
} else {
$daysAgo = $yearsAgo . __('messages.years ago');
}}
@endphp
<tr>
<td data-id>{{ $user->id }}</td>
<td class="shorten" title="{{ $user->name }}" data-name> {{ $user->name }} </td>
<td class="shorten" title="{{ $user->email }}" data-email> {{ $user->email }} </td>
<td class="shorten" title="{{ $user->littlelink_name }}" data-page>@if(isset($user->littlelink_name))<a href="{{ url('') }}/@<?= $user->littlelink_name ?>" target="_blank" class="text-info"><i class="bi bi-box-arrow-up-right"></i>&nbsp; {{ $user->littlelink_name }} </a>@else {{__('messages.N/A')}} @endif</td>
<td data-role>{{ $user->role }}</td>
<td data-links>{{$user->links}}</td>
<td data-clicks>{{$user->clicks}}</td>
<td data-created>{{$date}}</td>
<td class="shorten" data-last title="{{ $lastSeenDate }}">{{$daysAgo}}</td>
@if(env('REGISTER_AUTH') !== 'auth')
<td>@if($user->role == 'admin' and $user->email_verified_at != '')<center>-</center> @else
<a href="{{ route('verifyUser', ['verify' => '-' . $user->email_verified_at, 'id' => $user->id] ) }}" class="text-danger">@if($user->email_verified_at == '')<span class="badge bg-danger">{{__('messages.Pending')}}</span>@else<span class="badge bg-success">{{__('messages.Verified')}}</span></a>@endif</td>
@endif
@endif
<td>@if($user->role == 'admin' and $user->id == 1)<center>-</center>@else<a href="{{ route('blockUser', ['block' => $user->block, 'id' => $user->id] ) }}">@if($user->block == 'yes') <span class="badge bg-danger">{{__('messages.Pending')}}</span> @elseif($user->block == 'no') <span class="badge bg-success">{{__('messages.Approved')}}</span> @endif</a>@endif</td>
<td>
@if($user->role == 'admin' and $user->id == 1)<center>-</center>
@else
<div class="flex align-items-center list-user-action">
<a class="btn btn-sm btn-icon btn-success" data-bs-toggle="tooltip" data-bs-placement="top" data-original-title="{{__('messages.tt.All links')}}" href="{{ route('showLinksUser', $user->id ) }}" aria-label="All links" data-bs-original-title="All links">
<span class="btn-inner">
<svg class="icon-20" width="20" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<circle cx="11.7669" cy="11.7666" r="8.98856" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></circle>
<path d="M18.0186 18.4851L21.5426 22" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path>
</svg>
</span>
</a>
<a class="btn btn-sm btn-icon btn-warning" data-bs-toggle="tooltip" data-bs-placement="top" data-original-title="{{__('messages.tt.Edit')}}" href="{{ route('editUser', $user->id ) }}" aria-label="Edit" data-bs-original-title="Edit">
<span class="btn-inner">
<svg class="icon-20" width="20" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M11.4925 2.78906H7.75349C4.67849 2.78906 2.75049 4.96606 2.75049 8.04806V16.3621C2.75049 19.4441 4.66949 21.6211 7.75349 21.6211H16.5775C19.6625 21.6211 21.5815 19.4441 21.5815 16.3621V12.3341" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path>
<path fill-rule="evenodd" clip-rule="evenodd" d="M8.82812 10.921L16.3011 3.44799C17.2321 2.51799 18.7411 2.51799 19.6721 3.44799L20.8891 4.66499C21.8201 5.59599 21.8201 7.10599 20.8891 8.03599L13.3801 15.545C12.9731 15.952 12.4211 16.181 11.8451 16.181H8.09912L8.19312 12.401C8.20712 11.845 8.43412 11.315 8.82812 10.921Z" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path>
<path d="M15.1655 4.60254L19.7315 9.16854" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path>
</svg>
</span>
</a>
<a class="btn btn-sm btn-icon btn-primary" style="@if(!$user->adminUser && Auth::user()->id !== $user->id && $user->block !== 'yes' && ($user->email_verified_at != '' || env('REGISTER_AUTH') == 'auth')) background:#3a57e8;border-color:#3a57e8; @else background:#6c757d;border-color:#6c757d; @endif" data-bs-toggle="tooltip" data-bs-placement="top" data-original-title="{{__('messages.tt.Impersonate')}}" @if(!$user->adminUser && Auth::user()->id !== $user->id && $user->block !== 'yes' && ($user->email_verified_at != '' || env('REGISTER_AUTH') == 'auth')) href="{{ route('authAsID', $user->id ) }}" @endif aria-label="Impersonate" data-bs-original-title="Impersonate">
<span class="btn-inner">
<svg class="icon-20" width="20" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M9.59151 15.2068C13.2805 15.2068 16.4335 15.7658 16.4335 17.9988C16.4335 20.2318 13.3015 20.8068 9.59151 20.8068C5.90151 20.8068 2.74951 20.2528 2.74951 18.0188C2.74951 15.7848 5.88051 15.2068 9.59151 15.2068Z" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path>
<path fill-rule="evenodd" clip-rule="evenodd" d="M9.59157 12.0198C7.16957 12.0198 5.20557 10.0568 5.20557 7.63476C5.20557 5.21276 7.16957 3.24976 9.59157 3.24976C12.0126 3.24976 13.9766 5.21276 13.9766 7.63476C13.9856 10.0478 12.0356 12.0108 9.62257 12.0198H9.59157Z" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path> <path d="M16.4829 10.8815C18.0839 10.6565 19.3169 9.28253 19.3199 7.61953C19.3199 5.98053 18.1249 4.62053 16.5579 4.36353" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path> <path d="M18.5952 14.7322C20.1462 14.9632 21.2292 15.5072 21.2292 16.6272C21.2292 17.3982 20.7192 17.8982 19.8952 18.2112" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path>
</svg>
</span>
</a>
<a class="btn btn-sm btn-icon btn-danger confirmation" data-bs-toggle="tooltip" data-bs-placement="top" data-original-title="{{__('messages.tt.Delete')}}" href="{{ route('deleteUser', ['id' => $user->id] ) }}" aria-label="Delete" data-bs-original-title="Delete">
<span class="btn-inner">
<svg class="icon-20" width="20" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" stroke="currentColor">
<path d="M19.3248 9.46826C19.3248 9.46826 18.7818 16.2033 18.4668 19.0403C18.3168 20.3953 17.4798 21.1893 16.1088 21.2143C13.4998 21.2613 10.8878 21.2643 8.27979 21.2093C6.96079 21.1823 6.13779 20.3783 5.99079 19.0473C5.67379 16.1853 5.13379 9.46826 5.13379 9.46826" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path>
<path d="M20.708 6.23975H3.75" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path>
<path d="M17.4406 6.23973C16.6556 6.23973 15.9796 5.68473 15.8256 4.91573L15.5826 3.69973C15.4326 3.13873 14.9246 2.75073 14.3456 2.75073H10.1126C9.53358 2.75073 9.02558 3.13873 8.87558 3.69973L8.63258 4.91573C8.47858 5.68473 7.80258 6.23973 7.01758 6.23973" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path>
</svg>
</span>
</a>
</div>
@endif
</td>
</tr>
@endforeach
</tbody>
</table>
</div></div></div>
<a href="{{ url('') }}/admin/new-user">+ {{__('messages.Add new user')}}</a>
<script type="text/javascript">
// Function to confirm and delete users
var elems = document.getElementsByClassName('confirmation');
var confirmIt = function (e) {
if (!confirm("{{__('messages.confirm.delete.user')}}")) e.preventDefault();
e.preventDefault();
if (confirm("{{ __('messages.confirm.delete.user') }}")) {
var userId = this.getAttribute('data-id');
deleteUserData(userId);
}
};
var deleteUserData = function(userId) {
var url = "{{ route('deleteTableUser', ['id' => ':id']) }}".replace(':id', userId);
var xhr = new XMLHttpRequest();
xhr.open('POST', url, true);
xhr.setRequestHeader('X-CSRF-TOKEN', '{{ csrf_token() }}');
xhr.setRequestHeader('Content-Type', 'application/json;charset=UTF-8');
xhr.onreadystatechange = function () {
if (xhr.readyState === 4 && xhr.status === 200) {
refreshLivewireTable();
}
};
var data = JSON.stringify({ id: userId });
xhr.send(data);
};
// Function to refresh the Livewire table
var refreshLivewireTable = function () {
Livewire.components.getComponentsByName('user-table')[0].$wire.$refresh()
};
// Attach click event listeners to elements with class 'confirmation'
for (var i = 0, l = elems.length; i < l; i++) {
elems[i].addEventListener('click', confirmIt, false);
}
</script>
<script type="text/javascript">
// Function to handle user verification requests
var elems = document.getElementsByClassName('user-email');
var handleUserClick = function (e) {
e.preventDefault();
var userId = this.getAttribute('data-id');
sendVerificationRequest(userId);
};
var sendVerificationRequest = function(userId) {
var xhr = new XMLHttpRequest();
xhr.open('GET', userId, true);
xhr.onreadystatechange = function () {
if (xhr.readyState === 4 && xhr.status === 200) {
refreshLivewireTable();
}
};
xhr.send();
};
// Attach click event listeners to elements with class 'user-email'
for (var i = 0, l = elems.length; i < l; i++) {
elems[i].addEventListener('click', handleUserClick, false);
}
</script>
<script type="text/javascript">
// Function to handle user blocking
var elems = document.getElementsByClassName('user-block');
var handleUserClick = function (e) {
e.preventDefault();
var userId = this.getAttribute('data-id');
sendVerificationRequest(userId);
};
var sendVerificationRequest = function(userId) {
var xhr = new XMLHttpRequest();
xhr.open('GET', userId, true);
xhr.onreadystatechange = function () {
if (xhr.readyState === 4 && xhr.status === 200) {
refreshLivewireTable();
}
};
xhr.send();
};
// Attach click event listeners to elements with class 'user-block'
for (var i = 0, l = elems.length; i < l; i++) {
elems[i].addEventListener('click', handleUserClick, false);
}
</script>
</div>
</section>
@ -169,53 +128,14 @@
</div>
</div>
@push('sidebar-stylesheets')
<script defer src="{{url('assets/js/cdn.min.js')}}"></script>
<script src="{{url('vendor/livewire/livewire/dist/livewire.js')}}"></script>
@endpush
@push('sidebar-scripts')
<script>
const getCellValue = (tr, idx) => tr.children[idx].innerText || tr.children[idx].textContent;
const comparer = (idx, asc) => (a, b) =>
((v1, v2) =>
v1 !== '' && v2 !== '' && !isNaN(v1) && !isNaN(v2) ? v1 - v2 : v1.toString().localeCompare(v2)
)(getCellValue(asc ? a : b, idx), getCellValue(asc ? b : a, idx));
document.addEventListener('DOMContentLoaded', () => {
// Find the sortable table and its headers
const table = document.querySelector('#sortable.table.table-stripped');
const headers = table.querySelectorAll('th[data-sort]');
// Add caret icon to initial header element
const initialHeader = table.querySelector('[data-order]');
initialHeader.innerHTML = `${initialHeader.innerText} <i class="bi bi-caret-down-fill"></i>`;
// Attach click event listener to all sortable headers
headers.forEach(th => th.addEventListener('click', function() {
// Get the clicked header's index, sort order, and sortable attribute
const thIndex = Array.from(th.parentNode.children).indexOf(th);
const isAscending = this.asc = !this.asc;
const isSortable = th.getAttribute('data-sortable') !== 'false';
// If the column is not sortable, do nothing
if (!isSortable) {
return;
}
// Remove caret icon and active class from all headers
headers.forEach(h => {
h.classList.remove('active');
h.innerHTML = h.innerText;
});
// Add caret icon and active class to clicked header
th.classList.add('active');
th.innerHTML = `${th.innerText} ${isAscending ? '<i class="bi bi-caret-down-fill"></i>' : '<i class="bi bi-caret-up-fill"></i>'}`;
// Sort the table rows based on the clicked header
Array.from(table.querySelectorAll('tbody tr'))
.sort(comparer(thIndex, isAscending))
.forEach(tr => table.querySelector('tbody').appendChild(tr));
}));
});
</script>
<livewire:scripts />
<script src="{{url('assets/js/livewire-sortable.js')}}"></script>
@endpush
@endsection

View File

@ -171,6 +171,7 @@ Route::group([
Route::post('/admin/edit-user/{id}', [AdminController::class, 'editUser'])->name('editUser');
Route::get('/admin/new-user', [AdminController::class, 'createNewUser'])->name('createNewUser')->middleware('max.users');
Route::get('/admin/delete-user/{id}', [AdminController::class, 'deleteUser'])->name('deleteUser');
Route::post('/admin/delete-table-user/{id}', [AdminController::class, 'deleteTableUser'])->name('deleteTableUser');
Route::get('/admin/pages', [AdminController::class, 'showSitePage'])->name('showSitePage');
Route::post('/admin/pages', [AdminController::class, 'editSitePage'])->name('editSitePage');
Route::get('/admin/advanced-config', [AdminController::class, 'showFileEditor'])->name('showFileEditor');