wip
This commit is contained in:
1 parent
884b468839
commit
d46fa5c51c
13 files changed
+331
-261
No files matched your search
@@ -17,7 +17,6 @@ use Filament\Forms\Components\Hidden;
|
||||
use Filament\Forms\Components\Radio;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\Slider;
|
||||
use Filament\Forms\Components\ToggleButtons;
|
||||
use Filament\Pages\Dashboard as BaseDashboard;
|
||||
use Filament\Pages\Dashboard\Concerns\HasFiltersForm;
|
||||
use Filament\Schemas\Components\Grid;
|
||||
@@ -89,72 +88,16 @@ class Statistic extends BaseDashboard
|
||||
->keyBindings(['esc'])
|
||||
->action('resetFilters'),
|
||||
Action::make('calculator')
|
||||
// ->modalHeading('')
|
||||
->modalHeading('')
|
||||
->modalSubmitAction(false) // Hides the submit button
|
||||
->modalCancelAction(false) // Optional: hides the cancel button too
|
||||
->label('Calculate')
|
||||
->icon('icon-player')
|
||||
->color(fn (): string => $this->filters['team_id'] ? 'primary' : 'gray')
|
||||
->disabled(fn (): string => $this->filters['team_id'] ? false : true)
|
||||
->color(fn(): string => $this->filters['team_id'] ? 'primary' : 'gray')
|
||||
->disabled(fn(): string => $this->filters['team_id'] ? false : true)
|
||||
->slideOverPosition(SlideOverPosition::Start)
|
||||
->modalWidth(Width::SevenExtraLarge)
|
||||
->modalWidth(Width::SixExtraLarge)
|
||||
->slideOver()
|
||||
->schema([
|
||||
Grid::make(2)
|
||||
->extraAttributes([
|
||||
'class' => 'justify-between w-full gap-4',
|
||||
])
|
||||
->schema([
|
||||
ToggleButtons::make('status')
|
||||
->live()
|
||||
->hiddenLabel()
|
||||
->multiple()
|
||||
->inline()
|
||||
->default('attack')
|
||||
->options([
|
||||
'attack' => 'Attack',
|
||||
'midfield' => 'Midfield',
|
||||
'defence' => 'Defence',
|
||||
'goalkeeper' => 'Goalkeeper',
|
||||
])
|
||||
->colors([
|
||||
'attack' => 'warning',
|
||||
'midfield' => 'info',
|
||||
'defence' => 'success',
|
||||
'goalkeeper' => 'gray',
|
||||
])
|
||||
->afterStateUpdated(function (ToggleButtons $component, $state, $livewire) {
|
||||
// 1. Fetch the enabled options array
|
||||
$livewireComponent = $component->getLivewire();
|
||||
$data = json_encode($livewireComponent->mountedActions);
|
||||
$livewire->js('toggle_type(\''.$data.'\')');
|
||||
|
||||
}),
|
||||
Grid::make(5)
|
||||
->schema([
|
||||
Action::make('restart')
|
||||
->extraAttributes([
|
||||
'class' => 'w-30',
|
||||
])
|
||||
->color('warning')
|
||||
->icon('phosphor-arrow-counter-clockwise'),
|
||||
Action::make('copy')
|
||||
->extraAttributes([
|
||||
'class' => 'w-30',
|
||||
])
|
||||
->color('success')
|
||||
->icon('phosphor-copy'),
|
||||
Action::make('calculate')
|
||||
->extraAttributes([
|
||||
'class' => 'w-30',
|
||||
])
|
||||
->icon('phosphor-calculator'),
|
||||
])
|
||||
->extraAttributes([
|
||||
'class' => 'flex justify-center items-center gap-0',
|
||||
]),
|
||||
]),
|
||||
])
|
||||
->modalContentFooter(view('filament.modals.player-calculator-modal', ['filters' => $this->filters])),
|
||||
];
|
||||
}
|
||||
@@ -193,10 +136,10 @@ class Statistic extends BaseDashboard
|
||||
->live()
|
||||
->preload()
|
||||
->searchable(false)
|
||||
->prefixIconColor(fn (Get $get): string => $get('sofascore_category_id') ? 'success' : 'danger')
|
||||
->prefixIconColor(fn(Get $get): string => $get('sofascore_category_id') ? 'success' : 'danger')
|
||||
->prefixIcon('phosphor-globe-fill')
|
||||
->hiddenLabel()
|
||||
->options(fn () => LoadSofaScoreCategory::load())
|
||||
->options(fn() => LoadSofaScoreCategory::load())
|
||||
->placeholder('Country')
|
||||
->afterStateUpdated(function (callable $set, $state) {
|
||||
$set('seasonmode', SofaScoreCategory::where('id', $state)->value('season_mode'));
|
||||
@@ -209,10 +152,10 @@ class Statistic extends BaseDashboard
|
||||
Select::make('league_id')
|
||||
->live()
|
||||
->preload()
|
||||
->prefixIconColor(fn (Get $get): string => $get('league_id') ? 'success' : 'danger')
|
||||
->prefixIconColor(fn(Get $get): string => $get('league_id') ? 'success' : 'danger')
|
||||
->prefixIcon('phosphor-trophy-fill')
|
||||
->hiddenLabel()
|
||||
->options(fn (Get $get) => LoadStatisticFixturesLeaguesOptions::load($get('sofascore_category_id')))
|
||||
->options(fn(Get $get) => LoadStatisticFixturesLeaguesOptions::load($get('sofascore_category_id')))
|
||||
->placeholder('League')
|
||||
->afterStateUpdated(function (callable $set) {
|
||||
$set('match_id', null);
|
||||
@@ -223,7 +166,7 @@ class Statistic extends BaseDashboard
|
||||
Select::make('match_id')
|
||||
->live()
|
||||
->hiddenLabel()
|
||||
->prefixIconColor(fn (Get $get): string => $get('match_id') ? 'success' : 'danger')
|
||||
->prefixIconColor(fn(Get $get): string => $get('match_id') ? 'success' : 'danger')
|
||||
->prefixIcon('phosphor-calendar-check-fill')
|
||||
->options(function (Get $get) {
|
||||
return LoadStatisticFixturesMatchOptions::load($get('league_id'));
|
||||
@@ -248,7 +191,7 @@ class Statistic extends BaseDashboard
|
||||
}
|
||||
})
|
||||
->prefixIcon('phosphor-users-three-fill')
|
||||
->hidden(fn (Get $get) => $get('similar_past_matches') != 'none')
|
||||
->hidden(fn(Get $get) => $get('similar_past_matches') != 'none')
|
||||
->options(function (Get $get) {
|
||||
if ($get('match_id')) {
|
||||
$res = StatisticFixtures::where('id', $get('match_id'))->first();
|
||||
@@ -277,9 +220,9 @@ class Statistic extends BaseDashboard
|
||||
Action::make('iconInfo')
|
||||
->color('success')
|
||||
->icon('phosphor-question-fill')
|
||||
->tooltip(fn () => 'Team Position')
|
||||
->tooltip(fn() => 'Team Position')
|
||||
)
|
||||
->hidden(fn (Get $get) => $get('similar_past_matches') != 'none')
|
||||
->hidden(fn(Get $get) => $get('similar_past_matches') != 'none')
|
||||
->default('all')
|
||||
->selectablePlaceholder(false)
|
||||
->options([
|
||||
@@ -335,17 +278,17 @@ class Statistic extends BaseDashboard
|
||||
->hiddenLabel()
|
||||
->suffixAction(Action::make('reset')
|
||||
->icon('phosphor-x-circle')
|
||||
->action(fn (callable $set) => $set('similar_past_matches', 'none'))
|
||||
->color(fn (Get $get): string => $get('similar_past_matches') != 'none' ? 'info' : 'gray'))
|
||||
->action(fn(callable $set) => $set('similar_past_matches', 'none'))
|
||||
->color(fn(Get $get): string => $get('similar_past_matches') != 'none' ? 'info' : 'gray'))
|
||||
->placeholder('Similar Past Matches')
|
||||
->suffix(fn (Get $get): string|HtmlString => $get('similar_past_matches') != 'none' ? new HtmlString('<div class="text-center w-24 font-bold rounded p-1 bg-blue-600 dark:bg-blue-700 text-white dark:text-gray-300">± '.$get('accuracy').'</div>') : '')
|
||||
->suffix(fn(Get $get): string|HtmlString => $get('similar_past_matches') != 'none' ? new HtmlString('<div class="text-center w-24 font-bold rounded p-1 bg-blue-600 dark:bg-blue-700 text-white dark:text-gray-300">± ' . $get('accuracy') . '</div>') : '')
|
||||
->prefix('SPM')
|
||||
->prefixAction(
|
||||
Action::make('iconInfo')
|
||||
->icon('phosphor-question-fill')
|
||||
// ->color(fn(Get $get): string => $get('similar_past_matches') != 'none' ? 'success' : 'primary')
|
||||
->color('success')
|
||||
->tooltip(fn () => $this->tooltip_similar_past_matches())
|
||||
->tooltip(fn() => $this->tooltip_similar_past_matches())
|
||||
)
|
||||
->default('none')
|
||||
->selectablePlaceholder(false)
|
||||
@@ -365,7 +308,7 @@ class Statistic extends BaseDashboard
|
||||
Slider::make('accuracy')
|
||||
->live()
|
||||
->hiddenLabel()
|
||||
->hidden(fn (Get $get) => $get('similar_past_matches') == 'none')
|
||||
->hidden(fn(Get $get) => $get('similar_past_matches') == 'none')
|
||||
->fillTrack()
|
||||
->minValue(0)
|
||||
->maxValue(0.25)
|
||||
@@ -384,17 +327,17 @@ class Statistic extends BaseDashboard
|
||||
->hiddenLabel()
|
||||
->allowHtml()
|
||||
->placeholder('Player')
|
||||
->hidden(fn (Get $get) => $get('similar_past_matches') != 'none')
|
||||
->prefixIconColor(fn (Get $get): string => $get('similar_past_matches') == 'none' ? 'success' : '')
|
||||
->hidden(fn(Get $get) => $get('similar_past_matches') != 'none')
|
||||
->prefixIconColor(fn(Get $get): string => $get('similar_past_matches') == 'none' ? 'success' : '')
|
||||
->prefixIcon('icon-player')
|
||||
->preload()
|
||||
->searchable()
|
||||
->extraAttributes(fn () => ['id' => 'player_selector'])
|
||||
->extraAttributes(fn() => ['id' => 'player_selector'])
|
||||
->suffixAction(
|
||||
Action::make('iconInfo')
|
||||
->icon('phosphor-question-fill')
|
||||
->color('success')
|
||||
->tooltip(fn () => $this->tooltip_player_info())
|
||||
->tooltip(fn() => $this->tooltip_player_info())
|
||||
)
|
||||
->options(function (Get $get) {
|
||||
$team_id = $get('team_id');
|
||||
@@ -411,7 +354,7 @@ class Statistic extends BaseDashboard
|
||||
->placeholder('Time on field')
|
||||
->prefixIcon('phosphor-watch-fill')
|
||||
->default('all')
|
||||
->hidden(fn (Get $get) => ! $get('ss_player_id'))
|
||||
->hidden(fn(Get $get) => ! $get('ss_player_id'))
|
||||
->prefixIconColor('success')
|
||||
->selectablePlaceholder(false)
|
||||
->options([
|
||||
@@ -431,7 +374,7 @@ class Statistic extends BaseDashboard
|
||||
->extraAttributes([
|
||||
'class' => 'radio-statistic-group',
|
||||
])
|
||||
->hidden(fn (Get $get) => $get('similar_past_matches') != 'none')
|
||||
->hidden(fn(Get $get) => $get('similar_past_matches') != 'none')
|
||||
->columnSpan([
|
||||
'default' => 4,
|
||||
'sm' => 4,
|
||||
@@ -455,7 +398,7 @@ class Statistic extends BaseDashboard
|
||||
->multiple()
|
||||
->placeholder('Current Season')
|
||||
->prefixIconColor('success')
|
||||
->hidden(fn (Get $get) => $get('seasonmode') == 'halfyear' || $get('season_or_date') == 'date' || $get('similar_past_matches') != 'none')
|
||||
->hidden(fn(Get $get) => $get('seasonmode') == 'halfyear' || $get('season_or_date') == 'date' || $get('similar_past_matches') != 'none')
|
||||
->prefixIcon('phosphor-calendar-star-fill')
|
||||
->options([
|
||||
'2026' => '2026',
|
||||
@@ -475,7 +418,7 @@ class Statistic extends BaseDashboard
|
||||
->multiple()
|
||||
->placeholder('Current Season')
|
||||
->prefixIconColor('success')
|
||||
->hidden(fn (Get $get) => $get('seasonmode') == 'fullyear' || $get('season_or_date') == 'date' || $get('similar_past_matches') != 'none')
|
||||
->hidden(fn(Get $get) => $get('seasonmode') == 'fullyear' || $get('season_or_date') == 'date' || $get('similar_past_matches') != 'none')
|
||||
->prefixIcon('phosphor-calendar-star-fill')
|
||||
->options([
|
||||
'26/27' => '26/27',
|
||||
@@ -491,30 +434,30 @@ class Statistic extends BaseDashboard
|
||||
DatePicker::make('start_date')
|
||||
->live()
|
||||
->hiddenLabel()
|
||||
->hidden(fn (Get $get) => $get('season_or_date') == 'season')
|
||||
->hidden(fn(Get $get) => $get('season_or_date') == 'season')
|
||||
->native(false)
|
||||
->prefixIconColor(fn (Get $get): string => $get('start_date') ? 'success' : 'primary')
|
||||
->prefixIconColor(fn(Get $get): string => $get('start_date') ? 'success' : 'primary')
|
||||
->prefixIcon('phosphor-calendar-fill')
|
||||
->prefix('Start')
|
||||
->suffixAction(
|
||||
Action::make('clear_start')
|
||||
->icon('phosphor-x')
|
||||
->color('gray')
|
||||
->action(fn (Set $set) => $set('start_date', null))
|
||||
->action(fn(Set $set) => $set('start_date', null))
|
||||
),
|
||||
DatePicker::make('end_date')
|
||||
->live()
|
||||
->hiddenLabel()
|
||||
->hidden(fn (Get $get) => $get('season_or_date') == 'season')
|
||||
->hidden(fn(Get $get) => $get('season_or_date') == 'season')
|
||||
->native(false)
|
||||
->prefixIconColor(fn (Get $get): string => $get('end_date') ? 'success' : 'primary')
|
||||
->prefixIconColor(fn(Get $get): string => $get('end_date') ? 'success' : 'primary')
|
||||
->prefixIcon('phosphor-calendar-fill')
|
||||
->prefix('End')
|
||||
->suffixAction(
|
||||
Action::make('clear_end')
|
||||
->icon('phosphor-x')
|
||||
->color('gray')
|
||||
->action(fn (Set $set) => $set('end_date', null))
|
||||
->action(fn(Set $set) => $set('end_date', null))
|
||||
),
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ namespace App\Livewire;
|
||||
|
||||
use App\Filament\Pages\Selections\Helper\GetSeason;
|
||||
use App\Filament\Pages\Selections\LoadPositions;
|
||||
use App\Livewire\Mapper\LoadGridPositions;
|
||||
use App\Models\SofaScorePlayerPerSeason;
|
||||
use App\Models\StatistikoEvent;
|
||||
use Filament\Widgets\Concerns\InteractsWithPageFilters;
|
||||
@@ -14,41 +13,11 @@ class PlayerCalculator extends Component
|
||||
{
|
||||
use InteractsWithPageFilters;
|
||||
|
||||
public $grid = [];
|
||||
public $players = [];
|
||||
|
||||
public function mount(array $filters)
|
||||
{
|
||||
$pos = array_chunk(LoadGridPositions::load(), 5);
|
||||
$pla = array_chunk(self::load($filters), 5);
|
||||
|
||||
$i = 1;
|
||||
while ($v = array_shift($pos)) {
|
||||
array_splice($pla, $i, 0, [$v]);
|
||||
$i += 2;
|
||||
}
|
||||
$x = 1;
|
||||
$y = 1;
|
||||
foreach ($pla as $ele) {
|
||||
foreach ($ele as $val) {
|
||||
$tmp = [];
|
||||
if (is_array($val)) {
|
||||
foreach ($val as $key => $value) {
|
||||
$tmp[$key] = $value;
|
||||
}
|
||||
$tmp['type'] = '';
|
||||
} else {
|
||||
$tmp['type'] = $val != 0 ? $val : '';
|
||||
}
|
||||
$tmp['x'] = 104 * $x;
|
||||
$tmp['y'] = 104 * $y;
|
||||
$this->grid[] = $tmp;
|
||||
$x++;
|
||||
if ($x > 10) {
|
||||
$x = 1;
|
||||
$y++;
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->players = self::load($filters);
|
||||
}
|
||||
|
||||
public static function load(array $filters)
|
||||
@@ -137,7 +106,7 @@ class PlayerCalculator extends Component
|
||||
|
||||
$name = $val['player_name'];
|
||||
$preferred_foot = $val['preferred_foot'] ?? '-';
|
||||
$everage_minutes = round($minues_played / $events_played).' min';
|
||||
$everage_minutes = round($minues_played / $events_played) . ' min';
|
||||
if ($colorlevel > 1 && $events_played < $colorlevel) {
|
||||
$color = 'danger';
|
||||
} elseif ($events_played < $colorlevel * 2) {
|
||||
@@ -148,20 +117,14 @@ class PlayerCalculator extends Component
|
||||
|
||||
$result[] = [
|
||||
'player_id' => $player_id,
|
||||
'name' => $name,
|
||||
'player_name' => $name,
|
||||
'position' => $position,
|
||||
'position_color' => $position_color,
|
||||
'color' => $color,
|
||||
'info' => 'Ev '.$events_played.', '.$preferred_foot.', '.$everage_minutes,
|
||||
'info' => 'Ev ' . $events_played . ', ' . $preferred_foot . ', ' . $everage_minutes,
|
||||
];
|
||||
}
|
||||
|
||||
$maxlength = 35;
|
||||
$len = count($result);
|
||||
if ($len < $maxlength) {
|
||||
$result += array_fill($len, $maxlength - $len, [0, 0, 0, 0, 0, 0, 0]);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use App\Filament\Pages\Statistic;
|
||||
use App\Filament\Resources\Events\Pages\ListEvents;
|
||||
use Carbon\Carbon;
|
||||
use Filament\Support\Assets\Css;
|
||||
@@ -38,9 +37,8 @@ class AppServiceProvider extends ServiceProvider
|
||||
|
||||
FilamentAsset::register([
|
||||
Css::make('font-stylesheet', __DIR__ . '/../../resources/css/font.css'),
|
||||
Js::make('example-external-script', 'https://cdn.jsdelivr.net/npm/interactjs@latest'),
|
||||
Js::make('number-animator', __DIR__ . '/../../resources/js/number-animator.js'),
|
||||
Js::make('dragndrop', __DIR__ . '/../../resources/js/dragndrop.js'),
|
||||
Js::make('dragndrop', __DIR__ . '/../../resources/js/dragndrop-store.js'),
|
||||
]);
|
||||
|
||||
FilamentView::registerRenderHook(
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
namespace App\Providers\Filament;
|
||||
|
||||
use Agencetwogether\HooksHelper\HooksHelperPlugin;
|
||||
use App\Filament\Exports\BetfairExporter;
|
||||
use App\Filament\Pages\Statistic;
|
||||
use App\Http\Middleware\RecordUserActivity;
|
||||
@@ -21,6 +20,8 @@ use Filament\Http\Middleware\DisableBladeIconComponents;
|
||||
use Filament\Http\Middleware\DispatchServingFilamentEvent;
|
||||
use Filament\Panel;
|
||||
use Filament\PanelProvider;
|
||||
use Filament\Support\Assets\Css;
|
||||
use Filament\Support\Assets\Js;
|
||||
use Filament\Support\Enums\Width;
|
||||
use Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse;
|
||||
use Illuminate\Cookie\Middleware\EncryptCookies;
|
||||
@@ -29,6 +30,7 @@ use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken;
|
||||
use Illuminate\Routing\Middleware\SubstituteBindings;
|
||||
use Illuminate\Session\Middleware\StartSession;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Vite;
|
||||
use Illuminate\View\Middleware\ShareErrorsFromSession;
|
||||
use Joaopaulolndev\FilamentEditProfile\FilamentEditProfilePlugin;
|
||||
use Joaopaulolndev\FilamentEditProfile\Pages\EditProfilePage;
|
||||
@@ -46,6 +48,11 @@ class AdminPanelProvider extends PanelProvider
|
||||
->middleware([
|
||||
RecordUserActivity::class,
|
||||
])
|
||||
->assets([
|
||||
// Point directly to the source files on disk relative to this provider
|
||||
Css::make('dragula-css', base_path('resources/js/filament-dragula.js')), // Vite extracts CSS imported here
|
||||
Js::make('filament-dragula', Vite::asset('resources/js/filament-dragula.js'))->module(),
|
||||
])
|
||||
->userMenuItems([
|
||||
ExportAction::make('download_betfair')
|
||||
->columnMapping(false)
|
||||
|
||||
Reference in new issue
Block a user