mirror of
https://github.com/pelican-dev/panel.git
synced 2026-02-19 19:08:24 +03:00
Compare commits
6 Commits
lance/2132
...
lance/2163
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0da15d483c | ||
|
|
b1a39f1724 | ||
|
|
6a548c09a0 | ||
|
|
55bda569cc | ||
|
|
adf1249086 | ||
|
|
dbf77bf146 |
@@ -30,6 +30,7 @@ use App\Traits\Filament\CanCustomizeTabs;
|
||||
use Exception;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\ActionGroup;
|
||||
use Filament\Forms\Components\Checkbox;
|
||||
use Filament\Forms\Components\CheckboxList;
|
||||
use Filament\Forms\Components\FileUpload;
|
||||
use Filament\Forms\Components\Hidden;
|
||||
@@ -1106,9 +1107,13 @@ class EditServer extends EditRecord
|
||||
->modalHeading(trans('filament-actions::delete.single.modal.heading', ['label' => $this->getRecordTitle()]))
|
||||
->modalSubmitActionLabel(trans('filament-actions::delete.single.label'))
|
||||
->requiresConfirmation()
|
||||
->action(function (Server $server, ServerDeletionService $service) {
|
||||
->form(fn (Server $server) => $server->backups()->where('is_locked', false)->exists() ? [
|
||||
Checkbox::make('delete_backups')
|
||||
->label(trans('admin/server.delete_backups', ['count' => $server->backups()->where('is_locked', false)->count()])),
|
||||
] : [])
|
||||
->action(function (array $data, Server $server, ServerDeletionService $service) {
|
||||
try {
|
||||
$service->handle($server);
|
||||
$service->withDeleteBackups($data['delete_backups'] ?? false)->handle($server);
|
||||
|
||||
return redirect(ListServers::getUrl(panel: 'admin'));
|
||||
} catch (ConnectionException) {
|
||||
@@ -1132,9 +1137,13 @@ class EditServer extends EditRecord
|
||||
->modalHeading(trans('filament-actions::force-delete.single.modal.heading', ['label' => $this->getRecordTitle()]))
|
||||
->modalSubmitActionLabel(trans('filament-actions::force-delete.single.label'))
|
||||
->requiresConfirmation()
|
||||
->action(function (Server $server, ServerDeletionService $service) {
|
||||
->form(fn (Server $server) => $server->backups()->where('is_locked', false)->exists() ? [
|
||||
Checkbox::make('delete_backups')
|
||||
->label(trans('admin/server.delete_backups', ['count' => $server->backups()->where('is_locked', false)->count()])),
|
||||
] : [])
|
||||
->action(function (array $data, Server $server, ServerDeletionService $service) {
|
||||
try {
|
||||
$service->withForce()->handle($server);
|
||||
$service->withForce()->withDeleteBackups($data['delete_backups'] ?? false)->handle($server);
|
||||
|
||||
return redirect(ListServers::getUrl(panel: 'admin'));
|
||||
} catch (ConnectionException) {
|
||||
|
||||
@@ -78,11 +78,15 @@ class Console extends Page
|
||||
$feature = data_get($data, 'key');
|
||||
|
||||
$feature = $this->featureService->get($feature);
|
||||
if (!$feature || $this->getMountedAction()) {
|
||||
if (!$feature) {
|
||||
return;
|
||||
}
|
||||
$this->mountAction($feature->getId());
|
||||
sleep(2); // TODO find a better way
|
||||
|
||||
if ($this->getMountedAction()) {
|
||||
$this->replaceMountedAction($feature->getId());
|
||||
} else {
|
||||
$this->mountAction($feature->getId());
|
||||
}
|
||||
}
|
||||
|
||||
public function getWidgetData(): array
|
||||
|
||||
@@ -209,16 +209,18 @@ class ListFiles extends ListRecords
|
||||
->required()
|
||||
->live(),
|
||||
TextEntry::make('new_location')
|
||||
->state(fn (Get $get, File $file) => resolve_path(join_paths($this->path, $get('location') ?? '/', $file->name))),
|
||||
->state(fn (Get $get, File $file) => resolve_path(join_paths($this->path, str_ends_with($get('location') ?? '/', '/') ? join_paths($get('location') ?? '/', $file->name) : $get('location') ?? '/'))),
|
||||
])
|
||||
->action(function ($data, File $file) {
|
||||
$location = $data['location'];
|
||||
$files = [['to' => join_paths($location, $file->name), 'from' => $file->name]];
|
||||
$endsWithSlash = str_ends_with($location, '/');
|
||||
$to = $endsWithSlash ? join_paths($location, $file->name) : $location;
|
||||
$files = [['to' => $to, 'from' => $file->name]];
|
||||
|
||||
$this->getDaemonFileRepository()->renameFiles($this->path, $files);
|
||||
|
||||
$oldLocation = join_paths($this->path, $file->name);
|
||||
$newLocation = resolve_path(join_paths($this->path, $location, $file->name));
|
||||
$newLocation = resolve_path(join_paths($this->path, $to));
|
||||
|
||||
Activity::event('server:file.rename')
|
||||
->property('directory', $this->path)
|
||||
|
||||
@@ -74,7 +74,7 @@ class OAuthController extends Controller
|
||||
$email = $oauthUser->getEmail();
|
||||
|
||||
if (!$email) {
|
||||
return $this->errorRedirect();
|
||||
return $this->errorRedirect('No email was linked to your account on the OAuth provider.');
|
||||
}
|
||||
|
||||
$user = User::whereEmail($email)->first();
|
||||
|
||||
@@ -358,7 +358,7 @@ class Node extends Model implements Validatable
|
||||
'disk_used' => 0,
|
||||
];
|
||||
|
||||
return cache()->remember("nodes.$this->id.statistics", now()->addSeconds(360), function () use ($default) {
|
||||
return cache()->flexible("nodes.$this->id.statistics", [5, 30], function () use ($default) {
|
||||
try {
|
||||
|
||||
$data = Http::daemon($this)
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace App\Services\Servers;
|
||||
use App\Exceptions\DisplayException;
|
||||
use App\Models\Server;
|
||||
use App\Repositories\Daemon\DaemonServerRepository;
|
||||
use App\Services\Backups\DeleteBackupService;
|
||||
use App\Services\Databases\DatabaseManagementService;
|
||||
use Exception;
|
||||
use Illuminate\Database\ConnectionInterface;
|
||||
@@ -16,13 +17,16 @@ class ServerDeletionService
|
||||
{
|
||||
protected bool $force = false;
|
||||
|
||||
protected bool $deleteBackups = false;
|
||||
|
||||
/**
|
||||
* ServerDeletionService constructor.
|
||||
*/
|
||||
public function __construct(
|
||||
private ConnectionInterface $connection,
|
||||
private DaemonServerRepository $daemonServerRepository,
|
||||
private DatabaseManagementService $databaseManagementService
|
||||
private DatabaseManagementService $databaseManagementService,
|
||||
private DeleteBackupService $deleteBackupService
|
||||
) {}
|
||||
|
||||
/**
|
||||
@@ -35,6 +39,16 @@ class ServerDeletionService
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set if unlocked backups should be deleted from storage when the server is deleted.
|
||||
*/
|
||||
public function withDeleteBackups(bool $bool = true): self
|
||||
{
|
||||
$this->deleteBackups = $bool;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a server from the panel and remove any associated databases from hosts.
|
||||
*
|
||||
@@ -78,6 +92,22 @@ class ServerDeletionService
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->deleteBackups) {
|
||||
foreach ($server->backups()->where('is_locked', false)->get() as $backup) {
|
||||
try {
|
||||
$this->deleteBackupService->handle($backup);
|
||||
} catch (Exception $exception) {
|
||||
if (!$this->force) {
|
||||
throw $exception;
|
||||
}
|
||||
|
||||
$backup->delete();
|
||||
|
||||
logger()->warning($exception);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$server->allocations()->update([
|
||||
'server_id' => null,
|
||||
'notes' => null,
|
||||
|
||||
@@ -98,6 +98,7 @@ return [
|
||||
'delete_db' => 'Are you sure you want to delete :name ?',
|
||||
'delete_db_heading' => 'Delete Database?',
|
||||
'backups' => 'Backups',
|
||||
'delete_backups' => 'Also delete :count backup(s) from storage',
|
||||
'egg' => 'Egg',
|
||||
'mounts' => 'Mounts',
|
||||
'no_mounts' => 'No Mounts exist for this Node',
|
||||
|
||||
@@ -5,6 +5,10 @@
|
||||
|
||||
RewriteEngine On
|
||||
|
||||
# Handle X-Forwarded-Proto Header
|
||||
RewriteCond %{HTTP:X-Forwarded-Proto} =https [NC]
|
||||
RewriteRule .* - [E=HTTPS:on]
|
||||
|
||||
# Handle Authorization Header
|
||||
RewriteCond %{HTTP:Authorization} .
|
||||
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
|
||||
|
||||
Reference in New Issue
Block a user