filter in monitor wip

This commit is contained in:
salam committed 2025-12-20 13:47:59 +01:00
1 parent f5221e1d1c
commit da257748ae
17 files changed
+339 -145

No files matched your search

+6 -3
View File
@@ -129,6 +129,7 @@ class Odds
/*************************************************
* CALL
*************************************************/
$counter = 0;
foreach ($_calls as $url) {
$data = Xml::load($url);
@@ -184,6 +185,8 @@ class Odds
Nuh::$_event = Event::firstOrCreate($event, ['starttime' => $event['starttime']]);
$counter++;
foreach ($row->bookmaker as $book) {
Nuh::$bookmaker_id = (int) $book['bid'];
@@ -257,10 +260,10 @@ class Odds
}
}
}
}
if ($debug) {
Notice::note('END '.Nuh::$_event->id, 'g');
}
if ($debug) {
Notice::note('DONE - EVENTS: '.$counter, 'g');
}
}
}
@@ -26,8 +26,6 @@ class CountryResource extends Resource
protected static string|\BackedEnum|null $navigationIcon = 'lucide-flag';
protected static ?string $recordTitleAttribute = 'name';
protected static ?string $cluster = AdministratorCluster::class;
protected static string|\UnitEnum|null $navigationGroup = 'Static Data';
@@ -10,7 +10,9 @@ use Carbon\Carbon;
use Filament\Resources\Resource;
use Filament\Schemas\Schema;
use Filament\Tables\Table;
use Illuminate\Contracts\Support\Htmlable;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
class EventResource extends Resource
{
@@ -22,10 +24,31 @@ class EventResource extends Resource
protected static ?string $modelLabel = '';
protected static ?string $title = '';
protected static ?string $title = 'Monitor';
protected static ?string $pluralModelLabel = '';
// protected static ?string $recordTitleAttribute = 'tx_id';
// public static function getGlobalSearchResultTitle(Model $record): string|Htmlable
// {
// return $record->home->name.' - '.$record->away->name;
// }
// public static function getGlobalSearchResultDetails(Model $record): array
// {
// return [
// 'League' => $record->competition_group->name,
// 'Country' => $record->country->name,
// ];
// }
// public static function getGloballySearchableAttributes(): array
// {
// return ['tx_id', 'betradar_id', 'competition_group.name', 'country.name', 'away.name', 'home.name'];
// }
// public static function getGlobalSearchResultUrl(Symbol|Model $record): string
// {
// return EventResource::getUrl('edit', ['record' => $record]); // Links to the edit page
// }
public static function form(Schema $schema): Schema
{
return EventForm::configure($schema);
@@ -3,19 +3,24 @@
namespace App\Filament\Resources\Events\Tables;
use App\Filament\Tables\Columns\MultilineColumn;
use App\Models\CompetitionGroup;
use App\Models\Country;
use App\Models\Event;
use Carbon\Carbon;
use Filament\Actions\Action;
use Filament\Actions\ActionGroup;
use Filament\Actions\DeleteAction;
use Filament\Actions\EditAction;
use Filament\Forms\Components\Select;
use Filament\Schemas\Components\Utilities\Get;
use Filament\Support\Enums\FontWeight;
use Filament\Support\Enums\IconSize;
use Filament\Tables\Columns\IconColumn;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Enums\FiltersLayout;
use Filament\Tables\Filters\SelectFilter;
use Filament\Tables\Filters\Filter;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
class EventsTable
{
@@ -30,7 +35,11 @@ class EventsTable
->size(IconSize::ExtraLarge)
->icon(fn ($record) => $record->sport->icon)
->tooltip(fn ($record) => $record->id),
TextColumn::make('tx_id')->label('Id')->badge()->copyable()->searchable(),
TextColumn::make('tx_id')
->label('Id')
->badge()
->searchable()
->copyable(),
TextColumn::make('starttime')
->label('Start')
->alignCenter()
@@ -38,40 +47,88 @@ class EventsTable
->weight(FontWeight::Bold)
->description(fn ($state): string => Carbon::createFromDate($state)->format('H:i')),
TextColumn::make('country.name')
->searchable()
->color('gray')
->label('Event')
->icon(fn ($record) => $record->country->icon)
->description(fn ($record) => $record->competition_group->name),
TextColumn::make('home.name')->alignRight()->searchable(),
TextColumn::make('away.name')->searchable(),
MultilineColumn::make('id')
TextColumn::make('home.name')
->searchable()
->label(fn () => view('filament.tables.columns.multiline.label')),
->alignRight(),
TextColumn::make('away.name')
->searchable(),
MultilineColumn::make('id')->label(fn () => view('filament.tables.columns.multiline.label')),
])
->poll('10s')
->defaultSort('starttime', 'ASC')
->filters([
SelectFilter::make('competition_group_id')
->preload()
->label('League')
->multiple()
->searchable()
->options(function () {
Filter::make('events')
->schema([
Select::make('country_id')
->label('Country')
->searchable()
->preload()
->options(function () {
$res = Event::query()->where('starttime', '>', Carbon::now())->groupBy('country_id')->pluck('country_id')->toArray();
$res = Event::with('country')->with('competition_group')->where('starttime', '>', Carbon::now())->groupBy('competition_group_id')->get();
$arr = [];
foreach ($res as $val) {
$arr[$val->competition_group_id] = $val->country->name.' - '.$val->competition_group->name;
}
return Country::query()->whereIn('tx_id', $res)->pluck('name', 'tx_id');
})
->live()
->reactive()
->afterStateUpdated(function (callable $set) {
$set('competition_group_id', null);
}),
Select::make('competition_group_id')
->label('League')
->multiple()
->columnSpan(2)
->searchable()
->options(function (Get $get) {
if ($get('country_id')) {
$res = Event::with('country')->with('competition_group')->where('country_id', $get('country_id'))->where('starttime', '>', Carbon::now())->groupBy('competition_group_id')->get();
} else {
$res = Event::with('country')->with('competition_group')->where('starttime', '>', Carbon::now())->groupBy('competition_group_id')->get();
}
$arr = [];
foreach ($res as $val) {
$arr[$val->competition_group_id] = $val->country->name.' - '.$val->competition_group->name;
}
asort($arr);
asort($arr);
return $arr;
})
->live(),
])
// ->indicateUsing(function (array $data): array {
// $indicators = [];
return $arr;
// if ($data['country_id'] ?? null) {
// $indicators[] = 'Country: '.Country::where('tx_id', $data['country_id'])->pluck('name')->first();
// }
// if ($data['competition_group_id'] ?? null) {
// if (is_array($data['competition_group_id'])) {
// foreach ($data['competition_group_id'] as $competition_group_id) {
// $indicators[] = 'League: '.CompetitionGroup::where('tx_id', $competition_group_id)->pluck('name')->first();
// }
// } else {
// $indicators[] = 'League: '.CompetitionGroup::where('tx_id', $data['competition_group_id'])->pluck('name')->first();
// }
// }
// return $indicators;
// })
->query(function (Builder $query, array $data): Builder {
return $query
->when(
$data['country_id'],
fn (Builder $query, $sport_id) => $query->where('country_id', $sport_id)
)->when(
$data['competition_group_id'],
fn (Builder $query, $competition_group_id) => $query->where('competition_group_id', $competition_group_id)
);
})
->columnSpan(2)
->selectablePlaceholder(false),
->columns(6)->columnSpan(6),
], layout: FiltersLayout::AboveContent)
->filtersFormColumns(6)
->deferFilters(false)
@@ -57,7 +57,7 @@ class MultilineClientsTable
->deferFilters(false)
->filters([
Filter::make('multiline')
->form([
->schema([
Select::make('sport_id')
->label('Sport')
->default(1)
-33
View File
@@ -1,33 +0,0 @@
<?php
namespace App\Livewire;
use App\Models\Client;
use App\Models\User;
use Livewire\Component;
class ClientSwitch extends Component
{
public $clients = [];
public ?string $client = '';
public function mount()
{
$this->clients = Client::pluck('name', 'id')->all();
$this->client = Client::where('id', auth()->user()->client_id)->pluck('name')->first();
}
public function render()
{
return view('livewire.client-switch');
}
public function swop($client_id)
{
User::where('id', auth()->user()->id)->update(['client_id' => $client_id]);
$this->js('window.location.reload()');
}
}
-26
View File
@@ -2,9 +2,7 @@
namespace App\Livewire;
use App\Models\Client;
use App\Models\MultilineSetting;
use App\Models\Sport;
use App\Models\User;
use Livewire\Component;
@@ -12,25 +10,8 @@ class MonitorBettypeSwitch extends Component
{
public $multilines = [];
public $sports = [];
public $sport_id = 0;
public $sporticon = '';
public $iconcolor = '';
public function mount()
{
$cps = Client::where('id', auth()->user()->client_id)->pluck('sport')->first();
$this->sports = Sport::whereIn('id', $cps)->pluck('name', 'id');
$this->sporticon = Sport::where('id', auth()->user()->sport_id)->pluck('icon')->first();
$this->iconcolor = Sport::where('id', auth()->user()->sport_id)->pluck('color')->first();
$this->sport_id = auth()->user()->sport_id;
$this->multilines = [];
@@ -60,11 +41,4 @@ class MonitorBettypeSwitch extends Component
$this->js('window.location.reload()');
}
public function swopSport()
{
User::where('id', auth()->user()->id)->update(['sport_id' => $this->sport_id]);
$this->js('window.location.reload()');
}
}
+64
View File
@@ -0,0 +1,64 @@
<?php
namespace App\Livewire;
use App\Models\Client;
use App\Models\Sport;
use App\Models\User;
use Illuminate\Support\Facades\Route;
use Livewire\Component;
class TopMenuItems extends Component
{
public $clients = [];
public ?string $client = '';
public $sports = [];
public $sport_id = 0;
public $sporticon = '';
public $iconcolor = '';
public $current = '';
public function mount()
{
$cps = Client::where('id', auth()->user()->client_id)->pluck('sport')->first();
$this->sports = Sport::whereIn('id', $cps)->pluck('name', 'id');
$this->sporticon = Sport::where('id', auth()->user()->sport_id)->pluck('icon')->first();
$this->iconcolor = Sport::where('id', auth()->user()->sport_id)->pluck('color')->first();
$this->sport_id = auth()->user()->sport_id;
$this->clients = Client::pluck('name', 'id')->all();
$this->client = Client::where('id', auth()->user()->client_id)->pluck('name')->first();
$this->current = Route::currentRouteName();
}
public function render()
{
return view('livewire.top-menu-items');
}
public function swop($client_id)
{
User::where('id', auth()->user()->id)->update(['client_id' => $client_id]);
$this->js('window.location.reload()');
}
public function swopSport()
{
User::where('id', auth()->user()->id)->update(['sport_id' => $this->sport_id]);
$this->js('window.location.reload()');
}
}
+1 -1
View File
@@ -42,7 +42,7 @@ class AppServiceProvider extends ServiceProvider
FilamentView::registerRenderHook(
PanelsRenderHook::GLOBAL_SEARCH_BEFORE,
fn (): string => Blade::render('@livewire(\'client-switch\')')
fn (): string => Blade::render('@livewire(\'top-menu-items\')')
// fn (): string => auth()->user()->hasRole('konto_switch') ? Blade::render('@livewire(\'konto-switch\')') : false
);
@@ -2,6 +2,7 @@
namespace App\Providers\Filament;
use Agencetwogether\HooksHelper\HooksHelperPlugin;
use Awcodes\LightSwitch\Enums\Alignment;
use Awcodes\LightSwitch\LightSwitchPlugin;
use Filament\Actions\Action;
@@ -44,6 +45,8 @@ class AdminPanelProvider extends PanelProvider
->databaseNotifications()
->profile(isSimple: false)
->default()
->globalSearch(false)
->globalSearchKeyBindings(['command+k', 'ctrl+k'])
->brandLogo(asset('images/nuh-odds.svg'))
->darkModeBrandLogo(asset('images/nuh-odds-d.svg'))
->favicon(asset('images/nuh.svg'))
@@ -91,6 +94,7 @@ class AdminPanelProvider extends PanelProvider
->authMiddleware([
Authenticate::class,
])->plugins([
HooksHelperPlugin::make(),
FilamentEditProfilePlugin::make()->shouldRegisterNavigation(false),
LightSwitchPlugin::make()->position(Alignment::BottomCenter),
FilamentBackgroundsPlugin::make()
+1
View File
@@ -10,6 +10,7 @@
"license": "MIT",
"require": {
"php": "^8.3",
"agencetwogether/hookshelper": "^0.0.3",
"awcodes/light-switch": "^2.0",
"codeat3/blade-phosphor-icons": "^2.0",
"codewithdennis/filament-lucide-icons": "*",
Generated
+74 -1
View File
@@ -4,8 +4,81 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "45deaaab620ed1b3c5cfc7c74d900c94",
"content-hash": "c75c2edc61fdc14a9f9af425bf74c8a0",
"packages": [
{
"name": "agencetwogether/hookshelper",
"version": "0.0.3",
"source": {
"type": "git",
"url": "https://github.com/agencetwogether/hooksHelper.git",
"reference": "18233250c85e544e91a93c73b3b120a9f64b54a1"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/agencetwogether/hooksHelper/zipball/18233250c85e544e91a93c73b3b120a9f64b54a1",
"reference": "18233250c85e544e91a93c73b3b120a9f64b54a1",
"shasum": ""
},
"require": {
"filament/filament": "^3.0|^4.0",
"php": "^8.1",
"spatie/laravel-package-tools": "^1.15.0"
},
"require-dev": {
"laravel/pint": "^1.0",
"nunomaduro/collision": "^7.9",
"orchestra/testbench": "^8.0",
"pestphp/pest": "^2.1",
"pestphp/pest-plugin-arch": "^2.0",
"pestphp/pest-plugin-laravel": "^2.0"
},
"type": "library",
"extra": {
"laravel": {
"providers": [
"Agencetwogether\\HooksHelper\\HooksHelperServiceProvider"
]
}
},
"autoload": {
"psr-4": {
"Agencetwogether\\HooksHelper\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Max",
"email": "contact@agencetwogether.fr",
"role": "Developer"
}
],
"description": "Simple plugin to toggle display hooks available in current page.",
"homepage": "https://github.com/agencetwogether/hookshelper",
"keywords": [
"agencetwogether",
"filament",
"filamentphp",
"helper",
"hooks",
"laravel"
],
"support": {
"issues": "https://github.com/agencetwogether/hookshelper/issues",
"source": "https://github.com/agencetwogether/hookshelper"
},
"funding": [
{
"url": "https://github.com/agencetwogether",
"type": "github"
}
],
"time": "2025-09-25T06:57:44+00:00"
},
{
"name": "anourvalar/eloquent-serialize",
"version": "1.3.5",
+32
View File
@@ -0,0 +1,32 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Render Hook
|--------------------------------------------------------------------------
| You may customize the render hook used to display the hooks visibility
| toggle button. If null, this will be set to 'global-search.before'.
| The 'panels::' prefix will be added automatically if omitted.
|
*/
'render_hook' => 'global-search.before',
/*
|--------------------------------------------------------------------------
| Icon
|--------------------------------------------------------------------------
| You may select a different Heroicon to display for the hooks visibility
| toggle button. If null, the default will be 'heroicon-m-cursor-arrow-rays'.
|
*/
'icon' => 'heroicon-m-cursor-arrow-rays',
/*
|--------------------------------------------------------------------------
| Minify Button
|--------------------------------------------------------------------------
| Setting this to true will only display a small icon as a toggle button.
| Otherwise, the button will display action label to perform.
|
*/
'tiny_toggle' => true,
];
-2
View File
@@ -1990,7 +1990,6 @@
"integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==",
"dev": true,
"license": "MIT",
"peer": true,
"engines": {
"node": ">=12"
},
@@ -2224,7 +2223,6 @@
"integrity": "sha512-dZwN5L1VlUBewiP6H9s2+B3e3Jg96D0vzN+Ry73sOefebhYr9f94wwkMNN/9ouoU8pV1BqA1d1zGk8928cx0rg==",
"dev": true,
"license": "MIT",
"peer": true,
"dependencies": {
"esbuild": "^0.27.0",
"fdir": "^6.5.0",
@@ -1,15 +0,0 @@
<x-filament::dropdown>
<x-slot name="trigger">
<x-filament::button icon="phosphor-user">
{{ $client }}
</x-filament::button>
</x-slot>
<x-filament::dropdown.list>
@foreach ($clients as $id => $name)
<x-filament::dropdown.list.item wire:click="swop({{ $id }})" icon="phosphor-key">
{{ $name }}
</x-filament::dropdown.list.item>
@endforeach
</x-filament::dropdown.list>
</x-filament::dropdown>
@@ -1,42 +1,6 @@
<div class="flex justify-center w-full">
<x-filament::modal width="7xl" icon="heroicon-o-squares-2x2">
<x-slot name="trigger">
<x-filament::button outlined icon="heroicon-o-squares-2x2" color="gray">
Mapper
</x-filament::button>
</x-slot>
<x-slot name="heading">
Event Mapper
</x-slot>
{{-- Modal content --}}
<div class="grid grid-cols-2 gap-4">
<div>
@livewire('mapper-events')
</div>
<div>
@livewire('mapper-clients')
</div>
</div>
</x-filament::modal>
<div class="w-5"></div>
<x-filament::input.wrapper prefix-icon="{{ $sporticon }}" prefix-icon-color="{{ $iconcolor }}">
<x-filament::input.select wire:model="sport_id" wire:change="swopSport">
@foreach ($sports as $id => $name)
<option value="{{ $id }}">{{ $name }}</option>
@endforeach
</x-filament::input.select>
</x-filament::input.wrapper>
{{-- protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedSquares2x2; --}}
<div class="flex gap-4 justify-end">
@foreach ($multilines as $multiline)
<div class="w-5"></div>
@if ($multiline['is_active'] == 1)
<x-filament::button>
{{ $multiline['short'] }}
@@ -0,0 +1,51 @@
<div class="flex flex-1 gap-4">
@if ($this->current == 'filament.admin.resources.events.index')
<x-filament::input.wrapper prefix-icon="{{ $sporticon }}" prefix-icon-color="{{ $iconcolor }}">
<x-filament::input.select wire:model="sport_id" wire:change="swopSport">
@foreach ($sports as $id => $name)
<option value="{{ $id }}">{{ $name }}</option>
@endforeach
</x-filament::input.select>
</x-filament::input.wrapper>
<x-filament::modal width="7xl" icon="heroicon-o-squares-2x2">
<x-slot name="trigger">
<x-filament::button outlined icon="heroicon-o-squares-2x2" color="gray">
Event Mapper
</x-filament::button>
</x-slot>
<x-slot name="heading">
Event Mapper
</x-slot>
{{-- Modal content --}}
<div class="grid grid-cols-2 gap-4">
<div>
@livewire('mapper-events')
</div>
<div>
@livewire('mapper-clients')
</div>
</div>
</x-filament::modal>
@endif
<x-filament::dropdown>
<x-slot name="trigger">
<x-filament::button icon="phosphor-user">
{{ $client }}
</x-filament::button>
</x-slot>
<x-filament::dropdown.list>
@foreach ($clients as $id => $name)
<x-filament::dropdown.list.item wire:click="swop({{ $id }})" icon="phosphor-key">
{{ $name }}
</x-filament::dropdown.list.item>
@endforeach
</x-filament::dropdown.list>
</x-filament::dropdown>
</div>