Skip to content

Commit cfc4960

Browse files
pteroca-comksroga
andauthored
Added name field to server entity (#82)
Co-authored-by: Konrad Sroga <[email protected]>
1 parent 937aee1 commit cfc4960

23 files changed

+126
-48
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace DoctrineMigrations;
6+
7+
use Doctrine\DBAL\Schema\Schema;
8+
use Doctrine\Migrations\AbstractMigration;
9+
10+
final class Version20251011101804 extends AbstractMigration
11+
{
12+
public function getDescription(): string
13+
{
14+
return 'Add name column to server table';
15+
}
16+
17+
public function up(Schema $schema): void
18+
{
19+
$this->addSql('ALTER TABLE server ADD name VARCHAR(255) DEFAULT NULL AFTER pterodactyl_server_id');
20+
}
21+
22+
public function down(Schema $schema): void
23+
{
24+
$this->addSql('ALTER TABLE server DROP name');
25+
}
26+
}

src/Core/Controller/API/ServerConfigurationController.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,11 @@ public function updateServerDetails(
102102
$variableData['value'] ?? null,
103103
);
104104

105+
$serverConfigurationDetailsService->updateServerEntityName(
106+
$server,
107+
$variableData['key'],
108+
);
109+
105110
$this->serverLogService->logServerAction(
106111
$this->getUser(),
107112
$server,

src/Core/Controller/Panel/ServerCrudController.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ public function configureFields(string $pageName): iterable
5555
->onlyOnForms(),
5656
TextField::new('pterodactylServerIdentifier', $this->translator->trans('pteroca.crud.server.pterodactyl_server_identifier'))
5757
->setDisabled(),
58+
TextField::new('name', $this->translator->trans('pteroca.crud.server.name'))
59+
->formatValue(function ($value, Server $entity) {
60+
return $value ?: $entity->getServerProduct()->getName();
61+
}),
5862
AssociationField::new('serverProduct', $this->translator->trans('pteroca.crud.server.product_server_build'))
5963
->setDisabled(),
6064
AssociationField::new('user', $this->translator->trans('pteroca.crud.server.user'))
@@ -66,7 +70,7 @@ public function configureFields(string $pageName): iterable
6670
->hideOnIndex(),
6771

6872
NumberField::new('serverProduct.diskSpace', sprintf('%s (MB)', $this->translator->trans('pteroca.crud.product.disk_space')))
69-
->onlyOnIndex(),
73+
->onlyOnDetail(),
7074
NumberField::new('serverProduct.memory', sprintf('%s (MB)', $this->translator->trans('pteroca.crud.product.memory')))
7175
->onlyOnIndex(),
7276
NumberField::new('serverProduct.io', $this->translator->trans('pteroca.crud.product.io'))

src/Core/Controller/Panel/ServerProductCrudController.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ public function configureFields(string $pageName): iterable
8484
->setDisabled(),
8585
TextField::new('server.user', $this->translator->trans('pteroca.crud.server.user'))
8686
->setDisabled(),
87+
TextField::new('server.name', $this->translator->trans('pteroca.crud.server.name'))
88+
->setDisabled(),
8789
DateTimeField::new('server.createdAt', $this->translator->trans('pteroca.crud.server.created_at'))
8890
->hideOnForm(),
8991
DateTimeField::new('server.deletedAt', $this->translator->trans('pteroca.crud.server.deleted_at'))

src/Core/Entity/Server.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ class Server
2222
#[ORM\Column(type: 'string')]
2323
private string $pterodactylServerIdentifier;
2424

25+
#[ORM\Column(type: 'string', nullable: true)]
26+
private ?string $name = null;
27+
2528
#[ORM\OneToOne(targetEntity: ServerProduct::class, mappedBy: 'server', cascade: ['persist', 'remove'])]
2629
private ServerProduct $serverProduct;
2730

@@ -77,6 +80,17 @@ public function setPterodactylServerIdentifier(string $pterodactylServerIdentifi
7780
return $this;
7881
}
7982

83+
public function getName(): ?string
84+
{
85+
return $this->name;
86+
}
87+
88+
public function setName(?string $name): self
89+
{
90+
$this->name = $name;
91+
return $this;
92+
}
93+
8094
public function getServerProduct(): ServerProduct
8195
{
8296
return $this->serverProduct;

src/Core/Resources/translations/messages.cn.yaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -730,9 +730,10 @@ pteroca:
730730
show_archived: '显示已归档'
731731
server:
732732
pterodactyl_server_id: 'Pterodactyl 服务器 ID'
733-
pterodactyl_server_identifier: 'Pterodactyl 服务器标识符'
733+
pterodactyl_server_identifier: 'Pterodactyl 标识符'
734+
name: '服务器名称'
734735
product: '产品'
735-
user: '用户'
736+
user: '所有者'
736737
created_at: '创建于'
737738
expires_at: '到期于'
738739
is_suspended: '已暂停'
@@ -743,7 +744,7 @@ pteroca:
743744
show_server_dashboard: '显示服务器仪表板'
744745
auto_renewal: '自动续订'
745746
server_product_edit: '编辑构建配置'
746-
product_server_build: '服务器构建配置'
747+
product_server_build: '构建配置'
747748
server_edit: '更改服务器所有者'
748749
server_product_detail: '显示服务器详细信息'
749750
show_server_logs: '显示服务器日志'

src/Core/Resources/translations/messages.de.yaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -730,9 +730,10 @@ pteroca:
730730
show_archived: 'Archivierte anzeigen'
731731
server:
732732
pterodactyl_server_id: 'Pterodactyl-Server-ID'
733-
pterodactyl_server_identifier: 'Pterodactyl-Server-Identifier'
733+
pterodactyl_server_identifier: 'Pterodactyl-Identifier'
734+
name: 'Servername'
734735
product: 'Produkt'
735-
user: 'Benutzer'
736+
user: 'Besitzer'
736737
created_at: 'Erstellt am'
737738
expires_at: 'Läuft ab am'
738739
is_suspended: 'Gesperrt'
@@ -743,7 +744,7 @@ pteroca:
743744
show_server_dashboard: 'Server-Dashboard anzeigen'
744745
auto_renewal: 'Automatische Verlängerung'
745746
server_product_edit: 'Build-Konfiguration bearbeiten'
746-
product_server_build: 'Server-Build-Konfiguration'
747+
product_server_build: 'Build-Konfiguration'
747748
server_edit: 'Besitzer ändern'
748749
server_product_detail: 'Serverdetails anzeigen'
749750
show_server_logs: 'Serverprotokolle anzeigen'

src/Core/Resources/translations/messages.de_CH.yaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -724,9 +724,10 @@ pteroca:
724724
show_archived: 'Archivierte anzeigen'
725725
server:
726726
pterodactyl_server_id: 'Pterodactyl Server ID'
727-
pterodactyl_server_identifier: 'Pterodactyl Server-Identifikator'
727+
pterodactyl_server_identifier: 'Pterodactyl-Identifikator'
728+
name: 'Servername'
728729
product: 'Produkt'
729-
user: 'Benutzer'
730+
user: 'Besitzer'
730731
created_at: 'Erstellt am'
731732
expires_at: 'Lauft ab am'
732733
is_suspended: 'Pausiert'
@@ -737,7 +738,7 @@ pteroca:
737738
show_server_dashboard: 'Server-Dashboard anzeigen'
738739
auto_renewal: 'Auto-Erneuerung'
739740
server_product_edit: 'Build-Konfiguration bearbeiten'
740-
product_server_build: 'Server-Build-Konfiguration'
741+
product_server_build: 'Build-Konfiguration'
741742
server_edit: 'Serverbesitzer ändern'
742743
server_product_detail: 'Serverdetails anzeigen'
743744
show_server_logs: 'Serverprotokolle anzeigen'

src/Core/Resources/translations/messages.en.yaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -730,9 +730,10 @@ pteroca:
730730
confirm: 'Copy Product'
731731
server:
732732
pterodactyl_server_id: 'Pterodactyl Server ID'
733-
pterodactyl_server_identifier: 'Pterodactyl Server Identifier'
733+
pterodactyl_server_identifier: 'Pterodactyl Identifier'
734+
name: 'Server Name'
734735
product: 'Product'
735-
user: 'User'
736+
user: 'Owner'
736737
created_at: 'Created at'
737738
expires_at: 'Expires at'
738739
is_suspended: 'Suspended'
@@ -743,7 +744,7 @@ pteroca:
743744
show_server_dashboard: 'Show server dashboard'
744745
auto_renewal: 'Auto renewal'
745746
server_product_edit: 'Edit build configuration'
746-
product_server_build: 'Server build configuration'
747+
product_server_build: 'Build Configuration'
747748
server_edit: 'Change server owner'
748749
server_product_detail: 'Show server details'
749750
show_server_logs: 'Show server logs'

src/Core/Resources/translations/messages.es.yaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -730,9 +730,10 @@ pteroca:
730730
show_archived: 'Mostrar archivados'
731731
server:
732732
pterodactyl_server_id: 'ID del servidor Pterodactyl'
733-
pterodactyl_server_identifier: 'Identificador del servidor Pterodactyl'
733+
pterodactyl_server_identifier: 'Identificador de Pterodactyl'
734+
name: 'Nombre del servidor'
734735
product: 'Producto'
735-
user: 'Usuario'
736+
user: 'Propietario'
736737
created_at: 'Creado el'
737738
expires_at: 'Expira el'
738739
is_suspended: 'Suspendido'
@@ -743,7 +744,7 @@ pteroca:
743744
show_server_dashboard: 'Mostrar panel del servidor'
744745
auto_renewal: 'Renovación automática'
745746
server_product_edit: 'Editar configuración de compilación'
746-
product_server_build: 'Configuración de compilación del servidor'
747+
product_server_build: 'Configuración de compilación'
747748
server_edit: 'Cambiar propietario del servidor'
748749
server_product_detail: 'Mostrar detalles del servidor'
749750
show_server_logs: 'Mostrar registros del servidor'

0 commit comments

Comments
 (0)