mirror of
https://github.com/vitodeploy/vito.git
synced 2025-07-02 14:36:17 +00:00
Migrate to HTMX (#114)
Dropped Livewire Added HTMX Added Blade code lint Drop Mysql and Redis Migrate to SQLite
This commit is contained in:
@ -2,9 +2,6 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Enums\CronjobStatus;
|
||||
use App\Jobs\CronJob\AddToServer;
|
||||
use App\Jobs\CronJob\RemoveFromServer;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
@ -46,10 +43,10 @@ public function server(): BelongsTo
|
||||
return $this->belongsTo(Server::class);
|
||||
}
|
||||
|
||||
public function getCrontabAttribute(): string
|
||||
public static function crontab(Server $server, string $user): string
|
||||
{
|
||||
$data = '';
|
||||
$cronJobs = $this->server->cronJobs()->where('user', $this->user)->get();
|
||||
$cronJobs = $server->cronJobs()->where('user', $user)->get();
|
||||
foreach ($cronJobs as $key => $cronJob) {
|
||||
$data .= $cronJob->frequency.' '.$cronJob->command;
|
||||
if ($key != count($cronJobs) - 1) {
|
||||
@ -60,18 +57,6 @@ public function getCrontabAttribute(): string
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function addToServer(): void
|
||||
{
|
||||
dispatch(new AddToServer($this))->onConnection('ssh');
|
||||
}
|
||||
|
||||
public function removeFromServer(): void
|
||||
{
|
||||
$this->status = CronjobStatus::DELETING;
|
||||
$this->save();
|
||||
dispatch(new RemoveFromServer($this))->onConnection('ssh');
|
||||
}
|
||||
|
||||
public function getFrequencyLabelAttribute(): string
|
||||
{
|
||||
$labels = [
|
||||
|
@ -2,9 +2,6 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Enums\DatabaseStatus;
|
||||
use App\Jobs\Database\CreateOnServer;
|
||||
use App\Jobs\Database\DeleteFromServer;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
@ -54,24 +51,6 @@ public function server(): BelongsTo
|
||||
return $this->belongsTo(Server::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* create database on server
|
||||
*/
|
||||
public function createOnServer(string $queue = 'ssh'): void
|
||||
{
|
||||
dispatch(new CreateOnServer($this))->onConnection($queue);
|
||||
}
|
||||
|
||||
/**
|
||||
* delete database from server
|
||||
*/
|
||||
public function deleteFromServer(string $queue = 'ssh'): void
|
||||
{
|
||||
$this->status = DatabaseStatus::DELETING;
|
||||
$this->save();
|
||||
dispatch(new DeleteFromServer($this))->onConnection($queue);
|
||||
}
|
||||
|
||||
public function backups(): HasMany
|
||||
{
|
||||
return $this->hasMany(Backup::class)->where('type', 'database');
|
||||
|
@ -2,11 +2,6 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Enums\DatabaseStatus;
|
||||
use App\Jobs\DatabaseUser\CreateOnServer;
|
||||
use App\Jobs\DatabaseUser\DeleteFromServer;
|
||||
use App\Jobs\DatabaseUser\LinkUser;
|
||||
use App\Jobs\DatabaseUser\UnlinkUser;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
@ -54,41 +49,6 @@ public function scopeHasDatabase(Builder $query, string $databaseName): Builder
|
||||
return $query->where('databases', 'like', "%\"$databaseName\"%");
|
||||
}
|
||||
|
||||
public function createOnServer(string $queue = 'ssh'): void
|
||||
{
|
||||
dispatch(new CreateOnServer($this))->onConnection($queue);
|
||||
}
|
||||
|
||||
public function deleteFromServer(string $queue = 'ssh'): void
|
||||
{
|
||||
$this->status = DatabaseStatus::DELETING;
|
||||
$this->save();
|
||||
|
||||
dispatch(new DeleteFromServer($this))->onConnection($queue);
|
||||
}
|
||||
|
||||
public function linkNewDatabase(string $name): void
|
||||
{
|
||||
$linkedDatabases = $this->databases ?? [];
|
||||
if (! in_array($name, $linkedDatabases)) {
|
||||
$linkedDatabases[] = $name;
|
||||
$this->databases = $linkedDatabases;
|
||||
$this->unlinkUser();
|
||||
$this->linkUser();
|
||||
$this->save();
|
||||
}
|
||||
}
|
||||
|
||||
public function linkUser(string $queue = 'ssh'): void
|
||||
{
|
||||
dispatch(new LinkUser($this))->onConnection($queue);
|
||||
}
|
||||
|
||||
public function unlinkUser(string $queue = 'ssh'): void
|
||||
{
|
||||
dispatch(new UnlinkUser($this))->onConnection($queue);
|
||||
}
|
||||
|
||||
public function getFullUserAttribute(): string
|
||||
{
|
||||
return $this->username.'@'.$this->host;
|
||||
|
@ -2,9 +2,6 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Enums\FirewallRuleStatus;
|
||||
use App\Jobs\Firewall\AddToServer;
|
||||
use App\Jobs\Firewall\RemoveFromServer;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
@ -49,18 +46,6 @@ public function server(): BelongsTo
|
||||
return $this->belongsTo(Server::class);
|
||||
}
|
||||
|
||||
public function addToServer(): void
|
||||
{
|
||||
dispatch(new AddToServer($this))->onConnection('ssh');
|
||||
}
|
||||
|
||||
public function removeFromServer(): void
|
||||
{
|
||||
$this->status = FirewallRuleStatus::DELETING;
|
||||
$this->save();
|
||||
dispatch(new RemoveFromServer($this))->onConnection('ssh');
|
||||
}
|
||||
|
||||
public function getRealProtocolAttribute(): string
|
||||
{
|
||||
return $this->protocol === 'udp' ? 'udp' : 'tcp';
|
||||
|
@ -2,14 +2,14 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Actions\Server\CheckConnection;
|
||||
use App\Actions\Server\RebootServer;
|
||||
use App\Contracts\ServerType;
|
||||
use App\Enums\ServerStatus;
|
||||
use App\Enums\ServiceStatus;
|
||||
use App\Facades\Notifier;
|
||||
use App\Facades\SSH;
|
||||
use App\Jobs\Installation\Upgrade;
|
||||
use App\Jobs\Server\CheckConnection;
|
||||
use App\Jobs\Server\RebootServer;
|
||||
use App\Notifications\ServerInstallationStarted;
|
||||
use App\Support\Testing\SSHFake;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
@ -384,9 +384,9 @@ public function getServiceUnits(): array
|
||||
return $units;
|
||||
}
|
||||
|
||||
public function checkConnection(): void
|
||||
public function checkConnection(): self
|
||||
{
|
||||
dispatch(new CheckConnection($this))->onConnection('ssh');
|
||||
return app(CheckConnection::class)->check($this);
|
||||
}
|
||||
|
||||
public function installUpdates(): void
|
||||
@ -397,11 +397,9 @@ public function installUpdates(): void
|
||||
dispatch(new Upgrade($this))->onConnection('ssh');
|
||||
}
|
||||
|
||||
public function reboot(): void
|
||||
public function reboot(): self
|
||||
{
|
||||
$this->status = 'disconnected';
|
||||
$this->save();
|
||||
dispatch(new RebootServer($this))->onConnection('ssh');
|
||||
return app(RebootServer::class)->reboot($this);
|
||||
}
|
||||
|
||||
public function getHostnameAttribute(): string
|
||||
|
@ -9,9 +9,7 @@
|
||||
use App\Events\Broadcast;
|
||||
use App\Exceptions\SourceControlIsNotConnected;
|
||||
use App\Facades\Notifier;
|
||||
use App\Jobs\Site\ChangePHPVersion;
|
||||
use App\Jobs\Site\Deploy;
|
||||
use App\Jobs\Site\DeployEnv;
|
||||
use App\Jobs\Site\UpdateBranch;
|
||||
use App\Notifications\SiteInstallationFailed;
|
||||
use App\Notifications\SiteInstallationSucceed;
|
||||
@ -234,7 +232,8 @@ public function php(): ?Service
|
||||
|
||||
public function changePHPVersion($version): void
|
||||
{
|
||||
dispatch(new ChangePHPVersion($this, $version))->onConnection('ssh');
|
||||
$this->php_version = $version;
|
||||
$this->server->webserver()->handler()->changePHPVersion($this, $version);
|
||||
}
|
||||
|
||||
public function getDeploymentScriptTextAttribute(): string
|
||||
@ -288,11 +287,6 @@ public function getEnvAttribute(): string
|
||||
return $typeData['env'];
|
||||
}
|
||||
|
||||
public function deployEnv(): void
|
||||
{
|
||||
dispatch(new DeployEnv($this))->onConnection('ssh');
|
||||
}
|
||||
|
||||
public function activeSsl(): HasOne
|
||||
{
|
||||
return $this->hasOne(Ssl::class)
|
||||
|
Reference in New Issue
Block a user