Fix styling
This commit is contained in:
committed by
github-actions[bot]
parent
41fb6a1fc9
commit
d86274cc37
@@ -2,40 +2,57 @@
|
||||
|
||||
namespace App\Livewire\Project\Database;
|
||||
|
||||
use Livewire\Component;
|
||||
use App\Models\Server;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Livewire\Component;
|
||||
|
||||
class Import extends Component
|
||||
{
|
||||
public bool $unsupported = false;
|
||||
|
||||
public $resource;
|
||||
|
||||
public $parameters;
|
||||
|
||||
public $containers;
|
||||
|
||||
public bool $scpInProgress = false;
|
||||
|
||||
public bool $importRunning = false;
|
||||
|
||||
public ?string $filename = null;
|
||||
|
||||
public ?string $filesize = null;
|
||||
|
||||
public bool $isUploading = false;
|
||||
|
||||
public int $progress = 0;
|
||||
|
||||
public bool $error = false;
|
||||
|
||||
public Server $server;
|
||||
|
||||
public string $container;
|
||||
|
||||
public array $importCommands = [];
|
||||
|
||||
public string $postgresqlRestoreCommand = 'pg_restore -U $POSTGRES_USER -d $POSTGRES_DB';
|
||||
|
||||
public string $mysqlRestoreCommand = 'mysql -u $MYSQL_USER -p$MYSQL_PASSWORD $MYSQL_DATABASE';
|
||||
|
||||
public string $mariadbRestoreCommand = 'mariadb -u $MARIADB_USER -p$MARIADB_PASSWORD $MARIADB_DATABASE';
|
||||
|
||||
public string $mongodbRestoreCommand = 'mongorestore --authenticationDatabase=admin --username $MONGO_INITDB_ROOT_USERNAME --password $MONGO_INITDB_ROOT_PASSWORD --uri mongodb://localhost:27017 --gzip --archive=';
|
||||
|
||||
public function getListeners()
|
||||
{
|
||||
$userId = auth()->user()->id;
|
||||
|
||||
return [
|
||||
"echo-private:user.{$userId},DatabaseStatusChanged" => '$refresh',
|
||||
];
|
||||
}
|
||||
|
||||
public function mount()
|
||||
{
|
||||
$this->parameters = get_route_parameters();
|
||||
@@ -45,7 +62,7 @@ class Import extends Component
|
||||
public function getContainers()
|
||||
{
|
||||
$this->containers = collect();
|
||||
if (!data_get($this->parameters, 'database_uuid')) {
|
||||
if (! data_get($this->parameters, 'database_uuid')) {
|
||||
abort(404);
|
||||
}
|
||||
$resource = getResourceByUuid($this->parameters['database_uuid'], data_get(auth()->user()->currentTeam(), 'id'));
|
||||
@@ -74,16 +91,18 @@ class Import extends Component
|
||||
|
||||
if ($this->filename == '') {
|
||||
$this->dispatch('error', 'Please select a file to import.');
|
||||
|
||||
return;
|
||||
}
|
||||
try {
|
||||
$uploadedFilename = "upload/{$this->resource->uuid}/restore";
|
||||
$path = Storage::path($uploadedFilename);
|
||||
if (!Storage::exists($uploadedFilename)) {
|
||||
if (! Storage::exists($uploadedFilename)) {
|
||||
$this->dispatch('error', 'The file does not exist or has been deleted.');
|
||||
|
||||
return;
|
||||
}
|
||||
$tmpPath = '/tmp/' . basename($uploadedFilename);
|
||||
$tmpPath = '/tmp/'.basename($uploadedFilename);
|
||||
instant_scp($path, $tmpPath, $this->server);
|
||||
Storage::delete($uploadedFilename);
|
||||
$this->importCommands[] = "docker cp {$tmpPath} {$this->container}:{$tmpPath}";
|
||||
@@ -110,7 +129,7 @@ class Import extends Component
|
||||
$this->importCommands[] = "docker exec {$this->container} sh -c 'rm {$tmpPath}'";
|
||||
$this->importCommands[] = "docker exec {$this->container} sh -c 'echo \"Import finished with exit code $?\"'";
|
||||
|
||||
if (!empty($this->importCommands)) {
|
||||
if (! empty($this->importCommands)) {
|
||||
$activity = remote_process($this->importCommands, $this->server, ignore_errors: true);
|
||||
$this->dispatch('activityMonitor', $activity->id);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user