mirror of
https://github.com/vitodeploy/vito.git
synced 2025-07-02 14:36:17 +00:00
cleanup before release (#391)
This commit is contained in:
@ -5,6 +5,7 @@
|
||||
use App\Enums\FirewallRuleStatus;
|
||||
use App\Enums\ServerProvider;
|
||||
use App\Enums\ServerStatus;
|
||||
use App\Enums\ServerType;
|
||||
use App\Facades\Notifier;
|
||||
use App\Models\Project;
|
||||
use App\Models\Server;
|
||||
@ -33,7 +34,7 @@ public function create(User $creator, Project $project, array $input): Server
|
||||
'ip' => $input['ip'] ?? '',
|
||||
'port' => $input['port'] ?? 22,
|
||||
'os' => $input['os'],
|
||||
'type' => $input['type'],
|
||||
'type' => ServerType::REGULAR,
|
||||
'provider' => $input['provider'],
|
||||
'authentication' => [
|
||||
'user' => config('core.ssh_user'),
|
||||
@ -124,10 +125,6 @@ public static function rules(Project $project, array $input): array
|
||||
'required',
|
||||
Rule::in(config('core.operating_systems')),
|
||||
],
|
||||
'type' => [
|
||||
'required',
|
||||
Rule::in(config('core.server_types')),
|
||||
],
|
||||
'server_provider' => [
|
||||
Rule::when(function () use ($input) {
|
||||
return isset($input['provider']) && $input['provider'] != ServerProvider::CUSTOM;
|
||||
|
@ -2,6 +2,9 @@
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
/**
|
||||
* @deprecated server types will be dropped
|
||||
*/
|
||||
final class ServerType
|
||||
{
|
||||
const REGULAR = 'regular';
|
||||
|
@ -1,34 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Helpers;
|
||||
|
||||
use Illuminate\Http\Response;
|
||||
|
||||
class HtmxResponse extends Response
|
||||
{
|
||||
public function redirect(string $redirect): self
|
||||
{
|
||||
$this->header('HX-Redirect', $redirect);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function back(): self
|
||||
{
|
||||
return $this->redirect(back()->getTargetUrl());
|
||||
}
|
||||
|
||||
public function refresh(): self
|
||||
{
|
||||
$this->header('HX-Refresh', true);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function location(string $location): self
|
||||
{
|
||||
$this->header('HX-Location', $location);
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
@ -18,7 +18,7 @@ public function __invoke()
|
||||
{
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'version' => vito_version(),
|
||||
'version' => config('app.version'),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
@ -8,7 +8,6 @@
|
||||
use App\Enums\Database;
|
||||
use App\Enums\PHP;
|
||||
use App\Enums\ServerProvider;
|
||||
use App\Enums\ServerType;
|
||||
use App\Enums\Webserver;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Resources\ServerResource;
|
||||
@ -52,7 +51,6 @@ public function index(Project $project): ResourceCollection
|
||||
#[BodyParam(name: 'port', description: 'SSH Port if the provider is custom')]
|
||||
#[BodyParam(name: 'name', description: 'The name of the server.', required: true)]
|
||||
#[BodyParam(name: 'os', description: 'The os of the server', required: true)]
|
||||
#[BodyParam(name: 'type', description: 'Server type', required: true, enum: [ServerType::REGULAR, ServerType::DATABASE])]
|
||||
#[BodyParam(name: 'webserver', description: 'Web server', required: true, enum: [Webserver::NONE, Webserver::NGINX])]
|
||||
#[BodyParam(name: 'database', description: 'Database', required: true, enum: [Database::NONE, Database::MYSQL57, Database::MYSQL80, Database::MARIADB103, Database::MARIADB104, Database::MARIADB103, Database::POSTGRESQL12, Database::POSTGRESQL13, Database::POSTGRESQL14, Database::POSTGRESQL15, Database::POSTGRESQL16], )]
|
||||
#[BodyParam(name: 'php', description: 'PHP version', required: true, enum: [PHP::V70, PHP::V71, PHP::V72, PHP::V73, PHP::V74, PHP::V80, PHP::V81, PHP::V82, PHP::V83])]
|
||||
|
@ -11,7 +11,8 @@ public function createRules(array $input): array
|
||||
return [
|
||||
'webserver' => [
|
||||
'required',
|
||||
'in:'.implode(',', config('core.webservers')),
|
||||
Rule::in(config('core.webservers')),
|
||||
|
||||
],
|
||||
'php' => [
|
||||
'required',
|
||||
@ -19,7 +20,7 @@ public function createRules(array $input): array
|
||||
],
|
||||
'database' => [
|
||||
'required',
|
||||
'in:'.implode(',', config('core.databases')),
|
||||
Rule::in(config('core.databases')),
|
||||
],
|
||||
];
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
<?php
|
||||
|
||||
use App\Exceptions\SSHError;
|
||||
use App\Helpers\HtmxResponse;
|
||||
use Filament\Notifications\Actions\Action;
|
||||
use Filament\Notifications\Notification;
|
||||
use Illuminate\Http\Request;
|
||||
@ -32,14 +31,15 @@ function date_with_timezone($date, $timezone): string
|
||||
return $dt->format('Y-m-d H:i:s');
|
||||
}
|
||||
|
||||
function htmx(): HtmxResponse
|
||||
function show_vito_version(): string
|
||||
{
|
||||
return new HtmxResponse;
|
||||
}
|
||||
$version = config('app.version');
|
||||
|
||||
function vito_version(): string
|
||||
{
|
||||
return config('app.version');
|
||||
if (str($version)->contains('-beta')) {
|
||||
return str($version)->before('-beta')->toString();
|
||||
}
|
||||
|
||||
return $version;
|
||||
}
|
||||
|
||||
function convert_time_format($string): string
|
||||
|
@ -45,7 +45,7 @@ protected function getHeaderActions(): array
|
||||
->label('Read the Docs')
|
||||
->icon('heroicon-o-document-text')
|
||||
->color('gray')
|
||||
->url('https://vitodeploy.com/other/scripts.html')
|
||||
->url('https://vitodeploy.com/scripts')
|
||||
->openUrlInNewTab(),
|
||||
Action::make('create')
|
||||
->label('Create a Script')
|
||||
|
@ -38,7 +38,7 @@ protected function getHeaderActions(): array
|
||||
->label('Read the Docs')
|
||||
->icon('heroicon-o-document-text')
|
||||
->color('gray')
|
||||
->url('https://vitodeploy.com/servers/cronjobs.html')
|
||||
->url('https://vitodeploy.com/servers/cronjobs')
|
||||
->openUrlInNewTab(),
|
||||
Action::make('create')
|
||||
->authorize(fn () => auth()->user()?->can('create', [CronJob::class, $this->server]))
|
||||
@ -48,7 +48,7 @@ protected function getHeaderActions(): array
|
||||
TextInput::make('command')
|
||||
->rules(fn (callable $get) => CreateCronJob::rules($get())['command'])
|
||||
->helperText(fn () => view('components.link', [
|
||||
'href' => 'https://vitodeploy.com/servers/cronjobs.html',
|
||||
'href' => 'https://vitodeploy.com/servers/cronjobs',
|
||||
'external' => true,
|
||||
'text' => 'How the command should look like?',
|
||||
])),
|
||||
|
@ -38,7 +38,7 @@ protected function getHeaderActions(): array
|
||||
->label('Read the Docs')
|
||||
->icon('heroicon-o-document-text')
|
||||
->color('gray')
|
||||
->url('https://vitodeploy.com/servers/firewall.html')
|
||||
->url('https://vitodeploy.com/servers/firewall')
|
||||
->openUrlInNewTab(),
|
||||
Action::make('create')
|
||||
->authorize(fn () => auth()->user()?->can('create', [FirewallRule::class, $this->server]))
|
||||
|
@ -3,14 +3,17 @@
|
||||
namespace App\Web\Pages\Servers;
|
||||
|
||||
use App\Actions\Server\CreateServer as CreateServerAction;
|
||||
use App\Enums\Database;
|
||||
use App\Enums\PHP;
|
||||
use App\Enums\ServerProvider;
|
||||
use App\Enums\ServerType;
|
||||
use App\Enums\Webserver;
|
||||
use App\Models\Server;
|
||||
use App\Web\Components\Page;
|
||||
use App\Web\Fields\AlertField;
|
||||
use App\Web\Fields\ProviderField;
|
||||
use App\Web\Pages\Settings\ServerProviders\Actions\Create;
|
||||
use Filament\Forms\Components\Actions\Action;
|
||||
use Filament\Forms\Components\Fieldset;
|
||||
use Filament\Forms\Components\Grid;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
@ -57,7 +60,7 @@ protected function getHeaderActions(): array
|
||||
->label('Read the Docs')
|
||||
->icon('heroicon-o-document-text')
|
||||
->color('gray')
|
||||
->url('https://vitodeploy.com/servers/create-server.html')
|
||||
->url('https://vitodeploy.com')
|
||||
->openUrlInNewTab(),
|
||||
\Filament\Actions\Action::make('create')
|
||||
->label('Create a Server')
|
||||
@ -162,9 +165,20 @@ protected function getHeaderActions(): array
|
||||
->helperText('Run this command on your server as root user')
|
||||
->disabled()
|
||||
->visible(fn ($get) => $get('provider') === ServerProvider::CUSTOM),
|
||||
TextInput::make('name')
|
||||
->label('Name')
|
||||
->rules(fn ($get) => CreateServerAction::rules($project, $get())['name']),
|
||||
Grid::make()
|
||||
->schema([
|
||||
TextInput::make('name')
|
||||
->label('Name')
|
||||
->rules(fn ($get) => CreateServerAction::rules($project, $get())['name']),
|
||||
Select::make('os')
|
||||
->label('OS')
|
||||
->native(false)
|
||||
->rules(fn ($get) => CreateServerAction::rules($project, $get())['os'])
|
||||
->options(
|
||||
collect(config('core.operating_systems'))
|
||||
->mapWithKeys(fn ($value) => [$value => $value])
|
||||
),
|
||||
]),
|
||||
Grid::make()
|
||||
->schema([
|
||||
TextInput::make('ip')
|
||||
@ -175,57 +189,46 @@ protected function getHeaderActions(): array
|
||||
->rules(fn ($get) => CreateServerAction::rules($project, $get())['port']),
|
||||
])
|
||||
->visible(fn ($get) => $get('provider') === ServerProvider::CUSTOM),
|
||||
Grid::make()
|
||||
Fieldset::make('Services')
|
||||
->columns(1)
|
||||
->schema([
|
||||
Select::make('os')
|
||||
->label('OS')
|
||||
->native(false)
|
||||
->rules(fn ($get) => CreateServerAction::rules($project, $get())['os'])
|
||||
->options(
|
||||
collect(config('core.operating_systems'))
|
||||
->mapWithKeys(fn ($value) => [$value => $value])
|
||||
),
|
||||
Select::make('type')
|
||||
->label('Server Type')
|
||||
->native(false)
|
||||
->selectablePlaceholder(false)
|
||||
->rules(fn ($get) => CreateServerAction::rules($project, $get())['type'])
|
||||
->options(
|
||||
collect(config('core.server_types'))
|
||||
->mapWithKeys(fn ($value) => [$value => $value])
|
||||
)
|
||||
->default(ServerType::REGULAR),
|
||||
]),
|
||||
Grid::make(3)
|
||||
->schema([
|
||||
Select::make('webserver')
|
||||
->label('Webserver')
|
||||
->native(false)
|
||||
->selectablePlaceholder(false)
|
||||
->rules(fn ($get) => CreateServerAction::rules($project, $get())['webserver'] ?? [])
|
||||
->options(
|
||||
collect(config('core.webservers'))->mapWithKeys(fn ($value) => [$value => $value])
|
||||
),
|
||||
Select::make('database')
|
||||
->label('Database')
|
||||
->native(false)
|
||||
->selectablePlaceholder(false)
|
||||
->rules(fn ($get) => CreateServerAction::rules($project, $get())['database'] ?? [])
|
||||
->options(
|
||||
collect(config('core.databases_name'))
|
||||
->mapWithKeys(fn ($value, $key) => [
|
||||
$key => $value.' '.config('core.databases_version')[$key],
|
||||
])
|
||||
),
|
||||
Select::make('php')
|
||||
->label('PHP')
|
||||
->native(false)
|
||||
->selectablePlaceholder(false)
|
||||
->rules(fn ($get) => CreateServerAction::rules($project, $get())['php'] ?? [])
|
||||
->options(
|
||||
collect(config('core.php_versions'))
|
||||
->mapWithKeys(fn ($value) => [$value => $value])
|
||||
),
|
||||
AlertField::make('alert')
|
||||
->info()
|
||||
->message('You can install/uninstall services later'),
|
||||
Grid::make(3)
|
||||
->schema([
|
||||
Select::make('webserver')
|
||||
->label('Webserver')
|
||||
->native(false)
|
||||
->selectablePlaceholder(false)
|
||||
->rules(fn ($get) => CreateServerAction::rules($project, $get())['webserver'] ?? [])
|
||||
->default(Webserver::NONE)
|
||||
->options(
|
||||
collect(config('core.webservers'))->mapWithKeys(fn ($value) => [$value => $value])
|
||||
),
|
||||
Select::make('database')
|
||||
->label('Database')
|
||||
->native(false)
|
||||
->selectablePlaceholder(false)
|
||||
->rules(fn ($get) => CreateServerAction::rules($project, $get())['database'] ?? [])
|
||||
->default(Database::NONE)
|
||||
->options(
|
||||
collect(config('core.databases_name'))
|
||||
->mapWithKeys(fn ($value, $key) => [
|
||||
$key => $value.' '.config('core.databases_version')[$key],
|
||||
])
|
||||
),
|
||||
Select::make('php')
|
||||
->label('PHP')
|
||||
->native(false)
|
||||
->selectablePlaceholder(false)
|
||||
->rules(fn ($get) => CreateServerAction::rules($project, $get())['php'] ?? [])
|
||||
->default(PHP::NONE)
|
||||
->options(
|
||||
collect(config('core.php_versions'))
|
||||
->mapWithKeys(fn ($value) => [$value => $value])
|
||||
),
|
||||
]),
|
||||
]),
|
||||
])
|
||||
->modalSubmitActionLabel('Create')
|
||||
|
@ -45,7 +45,7 @@ protected function getHeaderActions(): array
|
||||
->label('Read the Docs')
|
||||
->icon('heroicon-o-document-text')
|
||||
->color('gray')
|
||||
->url('https://vitodeploy.com/sites/create-site.html')
|
||||
->url('https://vitodeploy.com/sites/site-types')
|
||||
->openUrlInNewTab(),
|
||||
Action::make('create')
|
||||
->label('Create a Site')
|
||||
|
@ -38,7 +38,7 @@ protected function getHeaderActions(): array
|
||||
->label('Read the Docs')
|
||||
->icon('heroicon-o-document-text')
|
||||
->color('gray')
|
||||
->url('https://vitodeploy.com/sites/queues.html')
|
||||
->url('https://vitodeploy.com/sites/queues')
|
||||
->openUrlInNewTab(),
|
||||
CreateAction::make('create')
|
||||
->icon('heroicon-o-plus')
|
||||
|
@ -39,7 +39,7 @@ protected function getHeaderActions(): array
|
||||
->label('Read the Docs')
|
||||
->icon('heroicon-o-document-text')
|
||||
->color('gray')
|
||||
->url('https://vitodeploy.com/sites/ssl.html')
|
||||
->url('https://vitodeploy.com/sites/ssl')
|
||||
->openUrlInNewTab(),
|
||||
CreateAction::make('create')
|
||||
->label('New Certificate')
|
||||
|
@ -82,7 +82,7 @@ public function getHeaderActions(): array
|
||||
->label('Read the Docs')
|
||||
->icon('heroicon-o-document-text')
|
||||
->color('gray')
|
||||
->url('https://vitodeploy.com/sites/application.html')
|
||||
->url('https://vitodeploy.com/sites/application')
|
||||
->openUrlInNewTab(),
|
||||
];
|
||||
$actionsGroup = [];
|
||||
|
Reference in New Issue
Block a user