ui(files): add pull file modal
This commit is contained in:
parent
01242a805d
commit
3c2a6e1136
14 changed files with 211 additions and 42 deletions
|
@ -247,15 +247,19 @@ class FileController extends ClientApiController
|
|||
/**
|
||||
* Updates file permissions for file(s) in the given root directory.
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException
|
||||
* @throws \Throwable
|
||||
*/
|
||||
public function chmod(ChmodFilesRequest $request, Server $server): Response
|
||||
{
|
||||
$this->fileRepository->setServer($server)
|
||||
->chmodFiles(
|
||||
$request->input('root'),
|
||||
$request->input('files')
|
||||
);
|
||||
$server->audit(AuditLog::SERVER__FILESYSTEM_CHMOD, function (AuditLog $audit, Server $server) use ($request) {
|
||||
$audit->metadata = ['directory' => $request->input('root'), 'files' => $request->input('files')];
|
||||
|
||||
$this->fileRepository->setServer($server)
|
||||
->chmodFiles(
|
||||
$request->input('root'),
|
||||
$request->input('files'),
|
||||
);
|
||||
});
|
||||
|
||||
return $this->returnNoContent();
|
||||
}
|
||||
|
@ -268,9 +272,13 @@ class FileController extends ClientApiController
|
|||
public function pull(PullFileRequest $request, Server $server): Response
|
||||
{
|
||||
$server->audit(AuditLog::SERVER__FILESYSTEM_PULL, function (AuditLog $audit, Server $server) use ($request) {
|
||||
$audit->metadata = ['directory' => $request->input('directory'), 'url' => $request->input('url')];
|
||||
$audit->metadata = ['directory' => $request->input('root'), 'url' => $request->input('url')];
|
||||
|
||||
$this->fileRepository->setServer($server)->pull($request->input('url'), $request->input('directory'));
|
||||
$this->fileRepository->setServer($server)
|
||||
->pull(
|
||||
$request->input('root'),
|
||||
$request->input('url'),
|
||||
);
|
||||
});
|
||||
|
||||
return $this->returnNoContent();
|
||||
|
|
|
@ -19,8 +19,8 @@ class PullFileRequest extends ClientApiRequest implements ClientPermissionsReque
|
|||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'root' => 'sometimes|nullable|string',
|
||||
'url' => 'required|string|url',
|
||||
'directory' => 'sometimes|nullable|string',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,6 +34,9 @@ class AssetComposer
|
|||
'siteKey' => config('recaptcha.website_key') ?? '',
|
||||
],
|
||||
'analytics' => config('app.analytics') ?? '',
|
||||
'features' => [
|
||||
'pullFiles' => config('features.pull_files'),
|
||||
],
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,6 +30,7 @@ class AuditLog extends Model
|
|||
public const SERVER__FILESYSTEM_RENAME = 'server:filesystem.rename';
|
||||
public const SERVER__FILESYSTEM_COMPRESS = 'server:filesystem.compress';
|
||||
public const SERVER__FILESYSTEM_DECOMPRESS = 'server:filesystem.decompress';
|
||||
public const SERVER__FILESYSTEM_CHMOD = 'server:filesystem.chmod';
|
||||
public const SERVER__FILESYSTEM_PULL = 'server:filesystem.pull';
|
||||
public const SERVER__BACKUP_STARTED = 'server:backup.started';
|
||||
public const SERVER__BACKUP_FAILED = 'server:backup.failed';
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
namespace Pterodactyl\Providers;
|
||||
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Illuminate\Cache\RateLimiting\Limit;
|
||||
use Illuminate\Support\Facades\RateLimiter;
|
||||
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
|
||||
|
||||
class RouteServiceProvider extends ServiceProvider
|
||||
|
@ -55,5 +57,9 @@ class RouteServiceProvider extends ServiceProvider
|
|||
Route::middleware(['daemon'])->prefix('/api/remote')
|
||||
->namespace($this->namespace . '\Api\Remote')
|
||||
->group(base_path('routes/api-remote.php'));
|
||||
|
||||
RateLimiter::for('pull', function () {
|
||||
return Limit::perMinute(10);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ class DaemonFileRepository extends DaemonRepository
|
|||
sprintf('/api/servers/%s/files/contents', $this->server->uuid),
|
||||
[
|
||||
'query' => ['file' => $path],
|
||||
]
|
||||
],
|
||||
);
|
||||
} catch (TransferException $exception) {
|
||||
throw new DaemonConnectionException($exception);
|
||||
|
@ -60,7 +60,7 @@ class DaemonFileRepository extends DaemonRepository
|
|||
[
|
||||
'query' => ['file' => $path],
|
||||
'body' => $content,
|
||||
]
|
||||
],
|
||||
);
|
||||
} catch (TransferException $exception) {
|
||||
throw new DaemonConnectionException($exception);
|
||||
|
@ -81,7 +81,7 @@ class DaemonFileRepository extends DaemonRepository
|
|||
sprintf('/api/servers/%s/files/list-directory', $this->server->uuid),
|
||||
[
|
||||
'query' => ['directory' => $path],
|
||||
]
|
||||
],
|
||||
);
|
||||
} catch (TransferException $exception) {
|
||||
throw new DaemonConnectionException($exception);
|
||||
|
@ -107,7 +107,7 @@ class DaemonFileRepository extends DaemonRepository
|
|||
'name' => $name,
|
||||
'path' => $path,
|
||||
],
|
||||
]
|
||||
],
|
||||
);
|
||||
} catch (TransferException $exception) {
|
||||
throw new DaemonConnectionException($exception);
|
||||
|
@ -131,7 +131,7 @@ class DaemonFileRepository extends DaemonRepository
|
|||
'root' => $root ?? '/',
|
||||
'files' => $files,
|
||||
],
|
||||
]
|
||||
],
|
||||
);
|
||||
} catch (TransferException $exception) {
|
||||
throw new DaemonConnectionException($exception);
|
||||
|
@ -154,7 +154,7 @@ class DaemonFileRepository extends DaemonRepository
|
|||
'json' => [
|
||||
'location' => $location,
|
||||
],
|
||||
]
|
||||
],
|
||||
);
|
||||
} catch (TransferException $exception) {
|
||||
throw new DaemonConnectionException($exception);
|
||||
|
@ -178,7 +178,7 @@ class DaemonFileRepository extends DaemonRepository
|
|||
'root' => $root ?? '/',
|
||||
'files' => $files,
|
||||
],
|
||||
]
|
||||
],
|
||||
);
|
||||
} catch (TransferException $exception) {
|
||||
throw new DaemonConnectionException($exception);
|
||||
|
@ -205,7 +205,7 @@ class DaemonFileRepository extends DaemonRepository
|
|||
// Wait for up to 15 minutes for the archive to be completed when calling this endpoint
|
||||
// since it will likely take quite awhile for large directories.
|
||||
'timeout' => 60 * 15,
|
||||
]
|
||||
],
|
||||
);
|
||||
} catch (TransferException $exception) {
|
||||
throw new DaemonConnectionException($exception);
|
||||
|
@ -231,7 +231,7 @@ class DaemonFileRepository extends DaemonRepository
|
|||
'root' => $root ?? '/',
|
||||
'file' => $file,
|
||||
],
|
||||
]
|
||||
],
|
||||
);
|
||||
} catch (TransferException $exception) {
|
||||
throw new DaemonConnectionException($exception);
|
||||
|
@ -255,7 +255,7 @@ class DaemonFileRepository extends DaemonRepository
|
|||
'root' => $root ?? '/',
|
||||
'files' => $files,
|
||||
],
|
||||
]
|
||||
],
|
||||
);
|
||||
} catch (TransferException $exception) {
|
||||
throw new DaemonConnectionException($exception);
|
||||
|
@ -267,7 +267,7 @@ class DaemonFileRepository extends DaemonRepository
|
|||
*
|
||||
* @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException
|
||||
*/
|
||||
public function pull(string $url, ?string $directory): ResponseInterface
|
||||
public function pull(?string $root, string $url): ResponseInterface
|
||||
{
|
||||
Assert::isInstanceOf($this->server, Server::class);
|
||||
|
||||
|
@ -275,8 +275,11 @@ class DaemonFileRepository extends DaemonRepository
|
|||
return $this->getHttpClient()->post(
|
||||
sprintf('/api/servers/%s/files/pull', $this->server->uuid),
|
||||
[
|
||||
'json' => ['url' => $url, 'directory' => $directory ?? '/'],
|
||||
]
|
||||
'json' => [
|
||||
'root' => $root ?? '/',
|
||||
'url' => $url,
|
||||
],
|
||||
],
|
||||
);
|
||||
} catch (TransferException $exception) {
|
||||
throw new DaemonConnectionException($exception);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue