diff --git a/app/Http/Livewire/UserTable.php b/app/Http/Livewire/UserTable.php new file mode 100644 index 0000000..eff6be9 --- /dev/null +++ b/app/Http/Livewire/UserTable.php @@ -0,0 +1,127 @@ +setPrimaryKey('id'); + } + + public function columns(): array + { + return [ + Column::make("Id", "id") + ->sortable() + ->searchable(), + Column::make("Name", "name") + ->sortable() + ->searchable(), + Column::make("Email", "email") + ->sortable() + ->searchable(), + Column::make("Littlelink name", "littlelink_name") + ->sortable() + ->searchable() + ->format(function ($value, $row, Column $column) { + if (!$row->littlelink_name == NULL) { + return "littlelink_name . "' target='_blank' class='text-info'>  " . $row->littlelink_name . " "; + } else { + return 'N/A'; + } + }) + ->html(), + Column::make("Role", "role") + ->sortable() + ->searchable(), + Column::make("Test", "id") + ->sortable() + ->format(function ($value, $row) { + $linkCount = Link::where('user_id', $row->id)->count(); + return $linkCount; + }), + Column::make("Clicks Sum", "id") + ->sortable() + ->format(function ($value, $row) { + $clicksSum = Link::where('user_id', $row->id)->sum('click_number'); + return $clicksSum; + }), + Column::make("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 '
-
'; + } else { + $verifyLink = route('verifyUser', [ + 'verify' => '-' . $row->email_verified_at, + 'id' => $row->id + ]); + if ($row->email_verified_at == '') { + return '' . __('messages.Pending') . ''; + } else { + return '' . __('messages.Verified') . ''; + } + } + } else { + return '
-
'; + } + return ''; + })->html(), + Column::make("Blocked", "block") + ->sortable() + ->format(function ($value, $row, Column $column) { + if ($row->role === 'admin' && $row->id === 1) { + return '
-
'; + } else { + $route = route('blockUser', ['block' => $row->block, 'id' => $row->id]); + if ($row->block === 'yes') { + $badge = ''.__('messages.Pending').''; + } elseif ($row->block === 'no') { + $badge = ''.__('messages.Approved').''; + } + return "$badge"; + } + }) + ->html(), + Column::make("Created at", "created_at") + ->sortable() + ->format(function ($value) { + if ($value) { + return $value->format('d/m/y'); + } else { + return ''; + } + }), + Column::make("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('Actions', "id") + ->format(function ($value, $row, Column $column) { + return view('components.table-components.action', ['user' => $row]); + }), + ]; + } +} diff --git a/config/livewire-tables.php b/config/livewire-tables.php new file mode 100644 index 0000000..eb949f7 --- /dev/null +++ b/config/livewire-tables.php @@ -0,0 +1,8 @@ + 'bootstrap-5', +]; diff --git a/config/livewire.php b/config/livewire.php new file mode 100644 index 0000000..60be6db --- /dev/null +++ b/config/livewire.php @@ -0,0 +1,158 @@ + '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' => url(''), + + /* + |-------------------------------------------------------------------------- + | 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 + | "/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, + +]; diff --git a/resources/views/components/table-components/action.blade.php b/resources/views/components/table-components/action.blade.php new file mode 100644 index 0000000..3036f30 --- /dev/null +++ b/resources/views/components/table-components/action.blade.php @@ -0,0 +1,39 @@ +@if($user->role == 'admin' and $user->id == 1)
-
+@else +
+ + + + + + + + + + + + + + + + + + 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"> + + + + + + + + + + + + + + + + +
+@endif \ No newline at end of file diff --git a/resources/views/layouts/sidebar.blade.php b/resources/views/layouts/sidebar.blade.php index e504803..74fb1a2 100755 --- a/resources/views/layouts/sidebar.blade.php +++ b/resources/views/layouts/sidebar.blade.php @@ -19,6 +19,7 @@ $usrhandl = Auth::user()->littlelink_name; + @livewireStyles @include('layouts.analytics') @stack('sidebar-stylesheets') @include('layouts.notifications') @@ -791,7 +792,7 @@ $usrhandl = Auth::user()->littlelink_name; - +@livewireScripts @stack('sidebar-scripts') diff --git a/resources/views/panel/users.blade.php b/resources/views/panel/users.blade.php index 3484957..1e73909 100755 --- a/resources/views/panel/users.blade.php +++ b/resources/views/panel/users.blade.php @@ -6,6 +6,10 @@ + +
@@ -19,131 +23,10 @@

{{__('messages.Manage Users')}}

- -
- @csrf -
-
-
- -
- -
-
-
-
-
{{__('messages.Users:')}} - All - - User - - Vip - - Admin - -
- - - - - - - - - - - - - @if(env('REGISTER_AUTH') !== 'auth')@endif - - - - - - @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 - - - - - - - - - - - @if(env('REGISTER_AUTH') !== 'auth') - - @endif - @endif - - - - @endforeach - -
{{__('messages.ID')}}{{__('messages.Name')}}{{__('messages.E-Mail')}}{{__('messages.Page')}}{{__('messages.Role')}}{{__('messages.Links')}}{{__('messages.Clicks')}}{{__('messages.Created at')}}{{__('messages.Last seen')}}{{__('messages.E-Mail')}}{{__('messages.Status')}}{{__('messages.Action')}}
{{ $user->id }} {{ $user->name }} {{ $user->email }} @if(isset($user->littlelink_name))  {{ $user->littlelink_name }} @else {{__('messages.N/A')}} @endif{{ $user->role }}{{$user->links}}{{$user->clicks}}{{$date}}{{$daysAgo}}@if($user->role == 'admin' and $user->email_verified_at != '')
-
@else - @if($user->email_verified_at == ''){{__('messages.Pending')}}@else{{__('messages.Verified')}}@endif
@if($user->role == 'admin' and $user->id == 1)
-
@else@if($user->block == 'yes') {{__('messages.Pending')}} @elseif($user->block == 'no') {{__('messages.Approved')}} @endif@endif
- @if($user->role == 'admin' and $user->id == 1)
-
- @else - - @endif -
-
+ + + + {{__('messages.Add new user')}} +@endpush + @push('sidebar-scripts') - + + @endpush @endsection \ No newline at end of file