lasthourcloud/app/Livewire/Server/Proxy/DynamicConfigurationNavbar.php

43 lines
1.1 KiB
PHP
Raw Normal View History

<?php
namespace App\Livewire\Server\Proxy;
use App\Models\Server;
use Livewire\Component;
class DynamicConfigurationNavbar extends Component
{
public $server_id;
2024-06-10 20:43:34 +00:00
public $fileName = '';
2024-06-10 20:43:34 +00:00
public $value = '';
2024-06-10 20:43:34 +00:00
public $newFile = false;
2024-06-10 20:43:34 +00:00
public function delete(string $fileName)
{
$server = Server::ownedByCurrentTeam()->whereId($this->server_id)->first();
2024-03-11 14:08:05 +00:00
$proxy_path = $server->proxyPath();
2024-03-11 16:31:28 +00:00
$proxy_type = $server->proxyType();
$file = str_replace('|', '.', $fileName);
2024-06-10 20:43:34 +00:00
if ($proxy_type === 'CADDY' && $file === 'Caddyfile') {
2024-03-11 16:31:28 +00:00
$this->dispatch('error', 'Cannot delete Caddyfile.');
2024-06-10 20:43:34 +00:00
2024-03-11 16:31:28 +00:00
return;
}
instant_remote_process(["rm -f {$proxy_path}/dynamic/{$file}"], $server);
2024-03-11 16:31:28 +00:00
if ($proxy_type === 'CADDY') {
$server->reloadCaddy();
2024-03-11 16:31:28 +00:00
}
2024-02-22 13:53:42 +00:00
$this->dispatch('success', 'File deleted.');
$this->dispatch('loadDynamicConfigurations');
$this->dispatch('refresh');
}
2024-06-10 20:43:34 +00:00
public function render()
{
return view('livewire.server.proxy.dynamic-configuration-navbar');
}
}