This commit is contained in:
Andras Bacsai
2023-06-16 12:35:40 +02:00
parent 7456fc1ac7
commit 3589b92ec9
84 changed files with 285 additions and 244 deletions

View File

@@ -13,6 +13,11 @@ class Form extends Component
'destination.network' => 'required',
'destination.server.ip' => 'required',
];
protected $validationAttributes = [
'destination.name' => 'name',
'destination.network' => 'network',
'destination.server.ip' => 'IP Address',
];
public function submit()
{
$this->validate();

View File

@@ -22,6 +22,11 @@ class StandaloneDocker extends Component
'network' => 'required|string',
'server_id' => 'required|integer'
];
protected $validationAttributes = [
'name' => 'name',
'network' => 'network',
'server_id' => 'server'
];
public function mount()
{
if (request()->query('server_id')) {

View File

@@ -15,6 +15,11 @@ class Change extends Component
'private_key.description' => 'nullable|string',
'private_key.private_key' => 'required|string'
];
protected $validationAttributes = [
'private_key.name' => 'name',
'private_key.description' => 'description',
'private_key.private_key' => 'private key'
];
public function mount()
{
$this->private_key = PrivateKey::where('uuid', $this->private_key_uuid)->first();

View File

@@ -16,8 +16,8 @@ class Create extends Component
'value' => 'required|string',
];
protected $validationAttributes = [
'name' => 'Name',
'value' => 'Private Key',
'name' => 'name',
'value' => 'private Key',
];
public function createPrivateKey()
{

View File

@@ -14,6 +14,9 @@ class Form extends Component
protected $rules = [
'name' => 'required',
];
protected $validationAttributes = [
'name' => 'name',
];
public function mount()
{
$this->userId = auth()->user()->id;

View File

@@ -18,6 +18,11 @@ class Add extends Component
'value' => 'required|string',
'is_build_time' => 'required|boolean',
];
protected $validationAttributes = [
'key' => 'key',
'value' => 'value',
'is_build_time' => 'build',
];
public function mount()
{
$this->parameters = getRouteParameters();

View File

@@ -15,6 +15,11 @@ class Show extends Component
'env.value' => 'required|string',
'env.is_build_time' => 'required|boolean',
];
protected $validationAttributes = [
'key' => 'key',
'value' => 'value',
'is_build_time' => 'build',
];
public function mount()
{
$this->parameters = getRouteParameters();

View File

@@ -47,6 +47,22 @@ class General extends Component
'application.ports_exposes' => 'required',
'application.ports_mappings' => 'nullable',
];
protected $validationAttributes = [
'application.name' => 'name',
'application.fqdn' => 'FQDN',
'application.git_repository' => 'Git repository',
'application.git_branch' => 'Git branch',
'application.git_commit_sha' => 'Git commit SHA',
'application.install_command' => 'Install command',
'application.build_command' => 'Build command',
'application.start_command' => 'Start command',
'application.build_pack' => 'Build pack',
'application.static_image' => 'Static image',
'application.base_directory' => 'Base directory',
'application.publish_directory' => 'Publish directory',
'application.ports_exposes' => 'Ports exposes',
'application.ports_mappings' => 'Ports mappings',
];
public function instantSave()
{
// @TODO: find another way - if possible

View File

@@ -14,6 +14,9 @@ class Form extends Component
protected $rules = [
'application.preview_url_template' => 'required',
];
protected $validationAttributes = [
'application.preview_url_template' => 'preview url template',
];
public function resetToDefault()
{
$this->application->preview_url_template = '{{pr_id}}.{{domain}}';

View File

@@ -17,6 +17,15 @@ class ResourceLimits extends Component
'application.limits_cpuset' => 'nullable',
'application.limits_cpu_shares' => 'nullable',
];
protected $validationAttributes = [
'application.limits_memory' => 'memory',
'application.limits_memory_swap' => 'swap',
'application.limits_memory_swappiness' => 'swappiness',
'application.limits_memory_reservation' => 'reservation',
'application.limits_cpus' => 'cpus',
'application.limits_cpuset' => 'cpuset',
'application.limits_cpu_shares' => 'cpu shares',
];
public function submit()
{
try {

View File

@@ -16,6 +16,11 @@ class Source extends Component
'application.git_branch' => 'required',
'application.git_commit_sha' => 'nullable',
];
protected $validationAttributes = [
'application.git_repository' => 'repository',
'application.git_branch' => 'branch',
'application.git_commit_sha' => 'commit sha',
];
private function get_private_keys()
{
$this->private_keys = PrivateKey::whereTeamId(session('currentTeam')->id)->get()->reject(function ($key) {

View File

@@ -17,6 +17,11 @@ class Add extends Component
'mount_path' => 'required|string',
'host_path' => 'string|nullable',
];
protected $validationAttributes = [
'name' => 'name',
'mount_path' => 'mount',
'host_path' => 'host',
];
public function mount()
{
$this->parameters = getRouteParameters();

View File

@@ -12,6 +12,11 @@ class Show extends Component
'storage.mount_path' => 'required|string',
'storage.host_path' => 'string|nullable',
];
protected $validationAttributes = [
'name' => 'name',
'mount_path' => 'mount',
'host_path' => 'host',
];
public function submit()
{
$this->validate();

View File

@@ -3,14 +3,12 @@
namespace App\Http\Livewire\Project;
use App\Models\Environment;
use App\Models\Project;
use Livewire\Component;
class DeleteEnvironment extends Component
{
public array $parameters;
public int $environment_id;
public int $resource_count = 0;
public function mount()
{

View File

@@ -9,7 +9,6 @@ class DeleteProject extends Component
{
public array $parameters;
public int $project_id;
public int $resource_count = 0;
public function mount()
{

View File

@@ -37,6 +37,12 @@ class PublicGitRepository extends Component
'is_static' => 'required|boolean',
'publish_directory' => 'nullable|string',
];
protected $validationAttributes = [
'repository_url' => 'repository',
'port' => 'port',
'is_static' => 'static',
'publish_directory' => 'publish directory',
];
public function mount()
{
if (isDev()) {

View File

@@ -16,6 +16,10 @@ class RunCommand extends Component
'server' => 'required',
'command' => 'required',
];
protected $validationAttributes = [
'server' => 'server',
'command' => 'command',
];
public function mount($servers)
{
$this->servers = $servers;

View File

@@ -21,6 +21,15 @@ class Form extends Component
'server.settings.is_reachable' => 'required',
'server.settings.is_part_of_swarm' => 'required'
];
protected $validationAttributes = [
'server.name' => 'name',
'server.description' => 'description',
'server.ip' => 'ip',
'server.user' => 'user',
'server.port' => 'port',
'server.settings.is_reachable' => 'is reachable',
'server.settings.is_part_of_swarm' => 'is part of swarm'
];
public function installDocker()
{
$activity = resolve(InstallDocker::class)($this->server);

View File

@@ -22,11 +22,18 @@ class ByIp extends Component
public bool $is_part_of_swarm = false;
protected $rules = [
'name' => 'required',
'ip' => 'required',
'user' => 'required',
'name' => 'required|string',
'description' => 'nullable|string',
'ip' => 'required|ip',
'user' => 'required|string',
'port' => 'required|integer',
'is_part_of_swarm' => 'required|boolean',
];
protected $validationAttributes = [
'name' => 'name',
'description' => 'description',
'ip' => 'ip',
'user' => 'user',
'port' => 'port',
];
public function mount()
{
@@ -43,11 +50,11 @@ class ByIp extends Component
}
public function submit()
{
$this->validate();
try {
if (!$this->private_key_id) {
return $this->emit('error', 'You must select a private key');
}
$this->validate();
$server = Server::create([
'name' => $this->name,
'description' => $this->description,

View File

@@ -25,6 +25,13 @@ class Configuration extends Component
'settings.public_port_max' => 'required',
'settings.default_redirect_404' => 'nullable',
];
protected $validationAttributes = [
'settings.fqdn' => 'FQDN',
'settings.wildcard_domain' => 'Wildcard domain',
'settings.public_port_min' => 'Public port min',
'settings.public_port_max' => 'Public port max',
'settings.default_redirect_404' => 'Default redirect 404',
];
public function mount()
{
$this->do_not_track = $this->settings->do_not_track;

View File

@@ -10,12 +10,13 @@ class Upgrade extends Component
{
public bool $showProgress = false;
public bool $isUpgradeAvailable = false;
public string $latestVersion = '';
public function checkUpdate()
{
$latestVersion = get_latest_version_of_coolify();
$this->latestVersion = get_latest_version_of_coolify();
$currentVersion = config('version');
version_compare($currentVersion, $latestVersion, '<') ? $this->isUpgradeAvailable = true : $this->isUpgradeAvailable = false;
version_compare($currentVersion, $this->latestVersion, '<') ? $this->isUpgradeAvailable = true : $this->isUpgradeAvailable = false;
if (isDev()) {
$this->isUpgradeAvailable = true;
}
@@ -25,7 +26,7 @@ class Upgrade extends Component
try {
$this->showProgress = true;
resolve(UpdateCoolify::class)(true);
Toaster::success('Upgrading Coolify to latest version...');
Toaster::success("Upgrading Coolify to {$this->latestVersion} version...");
} catch (\Exception $e) {
return general_error_handler(err: $e, that: $this);
}