Skip to content

Commit 3778852

Browse files
committed
feat: Add EPG map bypass options to channels and EPG Maps
Resolves #416
1 parent 67098e4 commit 3778852

File tree

6 files changed

+91
-2
lines changed

6 files changed

+91
-2
lines changed

app/Filament/Resources/Channels/ChannelResource.php

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
use Filament\Schemas\Components\Utilities\Set;
4242
use Filament\Schemas\Schema;
4343
use Filament\Support\Enums\Width;
44+
use Filament\Tables\Columns\IconColumn;
4445
use Filament\Tables\Columns\ImageColumn;
4546
use Filament\Tables\Columns\SelectColumn;
4647
use Filament\Tables\Columns\TextColumn;
@@ -278,6 +279,10 @@ public static function getTableColumns($showGroup = true, $showPlaylist = true):
278279
}
279280
})
280281
->sortable(),
282+
IconColumn::make('epg_map_enabled')
283+
->label('Mapping Enabled')
284+
->sortable()
285+
->boolean(),
281286
TextColumn::make('epgChannel.name')
282287
->label('EPG Channel')
283288
->toggleable()
@@ -783,6 +788,47 @@ public static function getTableBulkActions($addToCustom = true): array
783788
->modalIcon('heroicon-o-arrow-uturn-left')
784789
->modalDescription('Reset Find & Replace results back to playlist defaults for the selected channels. This will remove any custom values set in the selected column.')
785790
->modalSubmitActionLabel('Reset now'),
791+
BulkAction::make('enable-epg-mapping')
792+
->label('Enable EPG mapping')
793+
->action(function (Collection $records, array $data): void {
794+
$records->each(fn ($channel) => $channel->update([
795+
'epg_map_enabled' => true,
796+
]));
797+
})->after(function () {
798+
Notification::make()
799+
->success()
800+
->title('EPG map re-enabled for selected channels')
801+
->body('The EPG map has been re-enabled for the selected channels.')
802+
->send();
803+
})
804+
->hidden(fn () => ! $addToCustom)
805+
->deselectRecordsAfterCompletion()
806+
->requiresConfirmation()
807+
->icon('heroicon-o-calendar')
808+
->modalIcon('heroicon-o-calendar')
809+
->modalDescription('Allow mapping EPG to selected channels when running EPG mapping jobs.')
810+
->modalSubmitActionLabel('Enable now'),
811+
BulkAction::make('disable-epg-mapping')
812+
->label('Disabled EPG mapping')
813+
->color('warning')
814+
->action(function (Collection $records, array $data): void {
815+
$records->each(fn ($channel) => $channel->update([
816+
'epg_map_enabled' => false,
817+
]));
818+
})->after(function () {
819+
Notification::make()
820+
->success()
821+
->title('EPG map disabled for selected channels')
822+
->body('The EPG map has been disabled for the selected channels.')
823+
->send();
824+
})
825+
->hidden(fn () => ! $addToCustom)
826+
->deselectRecordsAfterCompletion()
827+
->requiresConfirmation()
828+
->icon('heroicon-o-calendar')
829+
->modalIcon('heroicon-o-calendar')
830+
->modalDescription('Don\'t map EPG to selected channels when running EPG mapping jobs.')
831+
->modalSubmitActionLabel('Disable now'),
786832
BulkAction::make('enable')
787833
->label('Enable selected')
788834
->action(function (Collection $records): void {

app/Filament/Resources/EpgMaps/EpgMapResource.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,13 @@ public static function getForm(
269269
->columns(2)
270270
->columnSpanFull()
271271
->schema([
272+
Toggle::make('settings.skip_missing')
273+
->label('Skip channels without EPG ID')
274+
->columnSpanFull()
275+
->inline(true)
276+
->live()
277+
->default(false)
278+
->helperText('When enabled, channels that do not have "epg_channel_id" or "tvg-id" will be skipped during the mapping process. Disable this to attempt to match all channels, even those without an EPG ID.'),
272279
Toggle::make('settings.use_regex')
273280
->label('Use regex for filtering')
274281
->columnSpanFull()

app/Jobs/MapPlaylistChannelsToEpg.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,10 @@ public function handle(): void
109109
->whereNotNull('epg_channel_id')
110110
->count();
111111
$channels = Channel::whereIn('id', $this->channels)
112-
->where('is_vod', false)
112+
->where([
113+
['is_vod', false],
114+
['epg_map_enabled', true],
115+
])
113116
->when(! $this->force, function ($query) {
114117
$query->where('epg_channel_id', null);
115118
});
@@ -120,7 +123,10 @@ public function handle(): void
120123
->whereNotNull('epg_channel_id')
121124
->count();
122125
$channels = $playlist->channels()
123-
->where('is_vod', false)
126+
->where([
127+
['is_vod', false],
128+
['epg_map_enabled', true],
129+
])
124130
->when(! $this->force, function ($query) {
125131
$query->where('epg_channel_id', null);
126132
});

app/Models/Channel.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ class Channel extends Model
4646
'movie_data' => 'array',
4747
'sync_settings' => 'array',
4848
'last_metadata_fetch' => 'datetime',
49+
'epg_map_enabled' => 'boolean',
4950
'logo_type' => ChannelLogoType::class,
5051
];
5152

app/Models/EpgMap.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ class EpgMap extends Model
2727
'mapped_count' => 'integer',
2828
'settings' => 'array',
2929
'channels' => 'array',
30+
'skip_missing_epg_id' => 'boolean',
3031
'status' => Status::class,
3132
];
3233

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Support\Facades\Schema;
6+
7+
return new class extends Migration
8+
{
9+
/**
10+
* Run the migrations.
11+
*/
12+
public function up(): void
13+
{
14+
Schema::table('channels', function (Blueprint $table) {
15+
$table->boolean('epg_map_enabled')->default(true)->after('epg_channel_id');
16+
});
17+
}
18+
19+
/**
20+
* Reverse the migrations.
21+
*/
22+
public function down(): void
23+
{
24+
Schema::table('channels', function (Blueprint $table) {
25+
$table->dropColumn('epg_map_enabled');
26+
});
27+
}
28+
};

0 commit comments

Comments
 (0)