Skip to content

Commit e4fa6af

Browse files
committed
add own resource for srv targets
1 parent 9cba829 commit e4fa6af

12 files changed

Lines changed: 91 additions & 81 deletions

File tree

subdomains/lang/de/notifications.php

Lines changed: 0 additions & 8 deletions
This file was deleted.

subdomains/lang/de/strings.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,15 @@
1616
'record_type' => 'Record Typ',
1717
'is_synced' => 'Ist synchronisiert?',
1818
'srv_target' => 'SRV Ziel',
19+
'no_srv_target' => 'Kein SRV Ziel',
1920

2021
'sync' => 'Synchronisieren',
21-
'set_srv_target' => 'SRV Ziel setzen',
2222

2323
'api_token' => 'Cloudflare API Token',
2424
'api_token_help' => 'Der Token benötigt Leseberechtigung für Zone.Zone und Schreibberechtigung für Zone.Dns. Für eine verbesserte Sicherheit können mit "Zone Resources" bestimmte Domains ausgeschlossen werden und die Panel-IP zum "Client IP Adress Filtering" hinzugefügt werden.',
25+
26+
'notifications' => [
27+
'synced' => 'Domain wurde erfolgreich mit Cloudflare synchronisiert',
28+
'not_synced' => 'Domain konnte nicht mit Cloudflare synchronisiert werden',
29+
],
2530
];

subdomains/lang/en/notifications.php

Lines changed: 0 additions & 8 deletions
This file was deleted.

subdomains/lang/en/strings.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,15 @@
1616
'record_type' => 'Record type',
1717
'is_synced' => 'Is Synced?',
1818
'srv_target' => 'SRV target',
19+
'no_srv_target' => 'No SRV target',
1920

2021
'sync' => 'Sync',
21-
'set_srv_target' => 'Set SRV target',
2222

2323
'api_token' => 'Cloudflare API Token',
2424
'api_token_help' => 'The token needs to have read permissions for Zone.Zone and write for Zone.Dns. For better security you can also set the "Zone Resources" to exclude certain domains and add the panel ip to the "Client IP Adress Filtering".',
25+
26+
'notifications' => [
27+
'synced' => 'Domain synced with cloudflare',
28+
'not_synced' => 'Could not sync domain with cloudflare',
29+
],
2530
];

subdomains/src/Filament/Admin/Resources/CloudflareDomains/CloudflareDomainResource.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public static function getPluralModelLabel(): string
4141

4242
public static function getNavigationGroup(): ?string
4343
{
44-
return trans('admin/dashboard.advanced');
44+
return trans_choice('subdomains::strings.subdomain', 2);
4545
}
4646

4747
public static function getNavigationBadge(): ?string
@@ -76,12 +76,12 @@ public static function table(Table $table): Table
7676
$domain->fetchCloudflareId();
7777

7878
Notification::make()
79-
->title(trans('subdomains::notifications.synced'))
79+
->title(trans('subdomains::strings.synced'))
8080
->success()
8181
->send();
8282
} catch (Exception $exception) {
8383
Notification::make()
84-
->title(trans('subdomains::notifications.not_synced'))
84+
->title(trans('subdomains::strings.not_synced'))
8585
->body($exception->getMessage())
8686
->danger()
8787
->persistent()

subdomains/src/Filament/Admin/Resources/CloudflareDomains/Pages/ManageCloudflareDomains.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,15 @@ protected function getHeaderActions(): array
1818
return [
1919
CreateAction::make()
2020
->createAnother(false)
21+
->hidden(fn () => is_null(config('subdomains.token')))
2122
->using(function (array $data) {
2223
try {
2324
return CloudflareDomain::create($data);
2425
} catch (Exception $exception) {
2526
Notification::make()
26-
->title(trans('subdomains::notifications.not_synced'))
27+
->title(trans('subdomains::strings.not_synced'))
2728
->body($exception->getMessage())
28-
->danger()
29+
->warning()
2930
->persistent()
3031
->send();
3132
}

subdomains/src/Filament/Admin/Resources/Servers/RelationManagers/SubdomainRelationManager.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public function table(Table $table): Table
4646
return $service->handle($data, $subdomain);
4747
} catch (Exception $exception) {
4848
Notification::make()
49-
->title(trans('subdomains::notifications.not_synced'))
49+
->title(trans('subdomains::strings.not_synced'))
5050
->body($exception->getMessage())
5151
->danger()
5252
->persistent()
@@ -89,7 +89,7 @@ public function table(Table $table): Table
8989
return $service->handle($data);
9090
} catch (Exception $exception) {
9191
Notification::make()
92-
->title(trans('subdomains::notifications.not_synced'))
92+
->title(trans('subdomains::strings.not_synced'))
9393
->body($exception->getMessage())
9494
->danger()
9595
->persistent()
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
3+
namespace Boy132\Subdomains\Filament\Admin\Resources\SrvTargets\Pages;
4+
5+
use Boy132\Subdomains\Filament\Admin\Resources\SrvTargets\SrvTargetResource;
6+
use Filament\Resources\Pages\ManageRecords;
7+
8+
class ManageSrvTargets extends ManageRecords
9+
{
10+
protected static string $resource = SrvTargetResource::class;
11+
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?php
2+
3+
namespace Boy132\Subdomains\Filament\Admin\Resources\SrvTargets;
4+
5+
use App\Filament\Admin\Resources\Nodes\Pages\EditNode;
6+
use App\Models\Node;
7+
use Boy132\Subdomains\Filament\Admin\Resources\SrvTargets\Pages\ManageSrvTargets;
8+
use Filament\Resources\Resource;
9+
use Filament\Tables\Columns\TextColumn;
10+
use Filament\Tables\Columns\TextInputColumn;
11+
use Filament\Tables\Table;
12+
13+
class SrvTargetResource extends Resource
14+
{
15+
protected static ?string $model = Node::class;
16+
17+
protected static ?string $slug = 'srv-targets';
18+
19+
protected static string|\BackedEnum|null $navigationIcon = 'tabler-world-www';
20+
21+
public static function getModelLabel(): string
22+
{
23+
return trans('subdomains::strings.srv_target');
24+
}
25+
26+
public static function getNavigationGroup(): ?string
27+
{
28+
return trans_choice('subdomains::strings.subdomain', 2);
29+
}
30+
31+
public static function table(Table $table): Table
32+
{
33+
return $table
34+
->columns([
35+
TextColumn::make('name')
36+
->label(trans('subdomains::strings.name'))
37+
->url(fn (Node $node) => EditNode::getUrl(['record' => $node])),
38+
TextInputColumn::make('srv_target')
39+
->label(trans('subdomains::strings.srv_target'))
40+
->placeholder(trans('subdomains::strings.no_srv_target'))
41+
->updateStateUsing(function (Node $node, $state) {
42+
$node->forceFill([
43+
'srv_target' => $state,
44+
])->save();
45+
}),
46+
])
47+
->emptyStateIcon('tabler-world-www')
48+
->emptyStateDescription('')
49+
->emptyStateHeading(trans('admin/node.no_nodes'));
50+
}
51+
52+
public static function getPages(): array
53+
{
54+
return [
55+
'index' => ManageSrvTargets::route('/'),
56+
];
57+
}
58+
}

subdomains/src/Filament/Components/Actions/SetSrvTargetAction.php

Lines changed: 0 additions & 49 deletions
This file was deleted.

0 commit comments

Comments
 (0)