diff --git a/app/Http/Livewire/Project/Service/ComposeModal.php b/app/Http/Livewire/Project/Service/ComposeModal.php
new file mode 100644
index 000000000..0c9f5e98f
--- /dev/null
+++ b/app/Http/Livewire/Project/Service/ComposeModal.php
@@ -0,0 +1,19 @@
+emit('warning', "Saving new docker compose...");
+ $this->emit('saveCompose', $this->raw);
+ }
+}
diff --git a/app/Http/Livewire/Project/Service/FileStorage.php b/app/Http/Livewire/Project/Service/FileStorage.php
index e4103f600..91ab8e659 100644
--- a/app/Http/Livewire/Project/Service/FileStorage.php
+++ b/app/Http/Livewire/Project/Service/FileStorage.php
@@ -13,6 +13,7 @@ class FileStorage extends Component
public LocalFileVolume $fileStorage;
public ServiceApplication|ServiceDatabase $service;
public string $fs_path;
+ public ?string $workdir = null;
protected $rules = [
'fileStorage.is_directory' => 'required',
@@ -23,13 +24,13 @@ class FileStorage extends Component
public function mount()
{
$this->service = $this->fileStorage->service;
- $this->fs_path = Str::of($this->fileStorage->fs_path)->beforeLast('/');
- $file = Str::of($this->fileStorage->fs_path)->afterLast('/');
- if (Str::of($this->fs_path)->startsWith('.')) {
- $this->fs_path = Str::of($this->fs_path)->after('.');
- $this->fs_path = $this->service->service->workdir() . $this->fs_path . "/" . $file;
- }
-
+ if (Str::of($this->fileStorage->fs_path)->startsWith('.')) {
+ $this->workdir = $this->service->service->workdir();
+ $this->fs_path = Str::of($this->fileStorage->fs_path)->after('.');
+ } else {
+ $this->workdir = null;
+ $this->fs_path = $this->fileStorage->fs_path;
+ }
}
public function submit()
{
@@ -41,8 +42,6 @@ public function submit()
}
$this->fileStorage->save();
$this->fileStorage->saveStorageOnServer($this->service);
- // ray($this->fileStorage);
- // $this->service->saveFileVolumes();
$this->emit('success', 'File updated successfully.');
} catch (\Throwable $e) {
$this->fileStorage->setRawAttributes($original);
diff --git a/app/Http/Livewire/Project/Service/Index.php b/app/Http/Livewire/Project/Service/Index.php
index c3c6c57c8..18029fb73 100644
--- a/app/Http/Livewire/Project/Service/Index.php
+++ b/app/Http/Livewire/Project/Service/Index.php
@@ -4,7 +4,6 @@
use App\Jobs\ContainerStatusJob;
use App\Models\Service;
-use DanHarrin\LivewireRateLimiting\WithRateLimiting;
use Livewire\Component;
class Index extends Component
@@ -20,7 +19,25 @@ class Index extends Component
'service.name' => 'required',
'service.description' => 'nullable',
];
- public function checkStatus() {
+ protected $listeners = ["saveCompose"];
+ public function render()
+ {
+ return view('livewire.project.service.index');
+ }
+ public function mount()
+ {
+ $this->parameters = get_route_parameters();
+ $this->query = request()->query();
+ $this->service = Service::whereUuid($this->parameters['service_uuid'])->firstOrFail();
+ $this->refreshStack();
+ }
+ public function saveCompose($raw)
+ {
+ $this->service->docker_compose_raw = $raw;
+ $this->submit();
+ }
+ public function checkStatus()
+ {
dispatch_sync(new ContainerStatusJob($this->service->server));
$this->refreshStack();
}
@@ -35,17 +52,8 @@ public function refreshStack()
$database->refresh();
});
}
- public function mount()
- {
- $this->parameters = get_route_parameters();
- $this->query = request()->query();
- $this->service = Service::whereUuid($this->parameters['service_uuid'])->firstOrFail();
- $this->refreshStack();
- }
- public function render()
- {
- return view('livewire.project.service.index');
- }
+
+
public function submit()
{
try {
diff --git a/app/Http/Livewire/Project/Service/Show.php b/app/Http/Livewire/Project/Service/Show.php
index 6f48a1389..ebeb24ebc 100644
--- a/app/Http/Livewire/Project/Service/Show.php
+++ b/app/Http/Livewire/Project/Service/Show.php
@@ -20,18 +20,26 @@ class Show extends Component
public function mount()
{
- $this->services = collect([]);
- $this->parameters = get_route_parameters();
- $this->query = request()->query();
- $this->service = Service::whereUuid($this->parameters['service_uuid'])->firstOrFail();
- $service = $this->service->applications()->whereName($this->parameters['service_name'])->first();
- if ($service) {
- $this->serviceApplication = $service;
- $this->serviceApplication->getFilesFromServer();
- } else {
- $this->serviceDatabase = $this->service->databases()->whereName($this->parameters['service_name'])->first();
- $this->serviceDatabase->getFilesFromServer();
+ try {
+ $this->services = collect([]);
+ $this->parameters = get_route_parameters();
+ $this->query = request()->query();
+ $this->service = Service::whereUuid($this->parameters['service_uuid'])->firstOrFail();
+ $service = $this->service->applications()->whereName($this->parameters['service_name'])->first();
+ if ($service) {
+ $this->serviceApplication = $service;
+ $this->serviceApplication->getFilesFromServer();
+ } else {
+ $this->serviceDatabase = $this->service->databases()->whereName($this->parameters['service_name'])->first();
+ $this->serviceDatabase->getFilesFromServer();
+ }
+ if (is_null($service)) {
+ throw new \Exception("Service not found.");
+ }
+ } catch(\Throwable $e) {
+ return handleError($e, $this);
}
+
}
public function generateDockerCompose()
{
diff --git a/app/Models/LocalFileVolume.php b/app/Models/LocalFileVolume.php
index ebd64c6a2..b45a868aa 100644
--- a/app/Models/LocalFileVolume.php
+++ b/app/Models/LocalFileVolume.php
@@ -31,7 +31,7 @@ public function saveStorageOnServer(ServiceApplication|ServiceDatabase $service)
}
$isFile = instant_remote_process(["test -f $path && echo OK || echo NOK"], $server);
$isDir = instant_remote_process(["test -d $path && echo OK || echo NOK"], $server);
- ray($path);
+ ray($isFile);
if ($isFile == 'OK' && $fileVolume->is_directory) {
throw new \Exception("File $path is a file on the server, but you are trying to mark it as a directory. Please delete the file on the server or mark it as directory.");
} else if ($isDir == 'OK' && !$fileVolume->is_directory) {
diff --git a/app/Models/Service.php b/app/Models/Service.php
index 364e59248..f58529c48 100644
--- a/app/Models/Service.php
+++ b/app/Models/Service.php
@@ -196,6 +196,12 @@ public function parse(bool $isNew = false): Collection
}
}
+ // Check if image changed
+ if ($savedService->image !== $image) {
+ $savedService->image = $image;
+ $savedService->save();
+ }
+
// Collect/create/update networks
if ($serviceNetworks->count() > 0) {
foreach ($serviceNetworks as $networkName => $networkDetails) {
diff --git a/bootstrap/helpers/services.php b/bootstrap/helpers/services.php
index 56a4445e7..7977d4d26 100644
--- a/bootstrap/helpers/services.php
+++ b/bootstrap/helpers/services.php
@@ -73,17 +73,22 @@ function getFilesystemVolumesFromServer(ServiceApplication|ServiceDatabase $oneS
$fileVolumes = $oneService->fileStorages()->get();
$commands = collect([
"mkdir -p $workdir > /dev/null 2>&1 || true",
- "cd $workdir"
+ "cd "
]);
instant_remote_process($commands, $server);
foreach ($fileVolumes as $fileVolume) {
$path = Str::of(data_get($fileVolume, 'fs_path'));
$content = data_get($fileVolume, 'content');
- $isFile = instant_remote_process(["test -f $path && echo OK || echo NOK"], $server);
- $isDir = instant_remote_process(["test -d $path && echo OK || echo NOK"], $server);
-
- if ($isFile == 'OK') {
- $filesystemContent = instant_remote_process(["cat $path"], $server);
+ if ($path->startsWith('.')) {
+ $path = $path->after('.');
+ $fileLocation = $workdir . $path;
+ } else {
+ $fileLocation = $path;
+ }
+ $isFile = instant_remote_process(["test -f $fileLocation && echo OK || echo NOK"], $server);
+ $isDir = instant_remote_process(["test -d $fileLocation && echo OK || echo NOK"], $server);
+ if ($isFile == 'OK' && !$fileVolume->is_directory) {
+ $filesystemContent = instant_remote_process(["cat $fileLocation"], $server);
if (base64_encode($filesystemContent) != base64_encode($content)) {
$fileVolume->content = $filesystemContent;
$fileVolume->save();
diff --git a/config/toaster.php b/config/toaster.php
index 13c9200a8..43565a9c6 100644
--- a/config/toaster.php
+++ b/config/toaster.php
@@ -30,7 +30,7 @@
*
* Minimum: 3000 (in milliseconds)
*/
- 'duration' => 3000,
+ 'duration' => 5000,
/**
* The horizontal position of each toast.
diff --git a/resources/views/components/applications/links.blade.php b/resources/views/components/applications/links.blade.php
index c9f9b0de6..1c716a3af 100644
--- a/resources/views/components/applications/links.blade.php
+++ b/resources/views/components/applications/links.blade.php
@@ -3,7 +3,7 @@