Skip to content

Commit

Permalink
Merge pull request #1381 from coollabsio/next
Browse files Browse the repository at this point in the history
v4.0.0-beta.109
  • Loading branch information
andrasbacsai authored Nov 6, 2023
2 parents 25f80ab + 6203804 commit 5ce449a
Show file tree
Hide file tree
Showing 71 changed files with 1,020 additions and 310 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/development-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ env:

jobs:
amd64:
runs-on: [self-hosted, x64]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Login to ghcr.io
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/production-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ env:

jobs:
amd64:
runs-on: [self-hosted, x64]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Login to ghcr.io
Expand Down
28 changes: 28 additions & 0 deletions .tinkerwell/snippets/SendEmail.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php
/**
* @label Send Email
* @description Send email to all users
*/

use App\Models\User;
use Illuminate\Support\Facades\Mail;

set_transanctional_email_settings();

$users = User::whereEmail('andras.bacsai@gmail.com');
foreach ($users as $user) {
Mail::send([], [], function ($message) use ($user) {
$message
->to($user->email)
->subject("Testing")
->text(
<<<EOF
Hello,
Welcome to Coolify Cloud.
Here is your user id: $user->id
EOF
);
});
}
20 changes: 10 additions & 10 deletions app/Actions/License/CheckResaleLicense.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,26 @@

use App\Models\InstanceSettings;
use Illuminate\Support\Facades\Http;
use Lorisleiva\Actions\Concerns\AsAction;


class CheckResaleLicense
{
public function __invoke()
use AsAction;
public function handle()
{
try {
$settings = InstanceSettings::get();
$settings->update([
'is_resale_license_active' => false,
]);
if (isDev()) {
$settings->update([
'is_resale_license_active' => true,
]);
return;
}
if (!$settings->resale_license) {
return;
}
// if (!$settings->resale_license) {
// return;
// }
$base_url = config('coolify.license_url');
if (isDev()) {
$base_url = 'http://host.docker.internal:8787';
}
$instance_id = config('app.id');

ray("Checking license key against $base_url/lemon/validate");
Expand Down
1 change: 0 additions & 1 deletion app/Actions/Service/StopService.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use Lorisleiva\Actions\Concerns\AsAction;
use App\Models\Service;
use App\Notifications\Application\StatusChanged;

class StopService
{
Expand Down
49 changes: 28 additions & 21 deletions app/Console/Commands/ResourcesDelete.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,14 @@ private function deleteServer()

foreach ($serversToDelete as $server) {
$toDelete = $servers->where('id', $server)->first();
$this->info($toDelete);
$confirmed = confirm("Are you sure you want to delete all selected resources?");
if (!$confirmed) {
break;
if ($toDelete) {
$this->info($toDelete);
$confirmed = confirm("Are you sure you want to delete all selected resources?");
if (!$confirmed) {
break;
}
$toDelete->delete();
}
$toDelete->delete();
}
}
private function deleteApplication()
Expand All @@ -82,14 +84,15 @@ private function deleteApplication()
);

foreach ($applicationsToDelete as $application) {
ray($application);
$toDelete = $applications->where('id', $application)->first();
$this->info($toDelete);
$confirmed = confirm("Are you sure you want to delete all selected resources? ");
if (!$confirmed) {
break;
if ($toDelete) {
$this->info($toDelete);
$confirmed = confirm("Are you sure you want to delete all selected resources? ");
if (!$confirmed) {
break;
}
$toDelete->delete();
}
$toDelete->delete();
}
}
private function deleteDatabase()
Expand All @@ -106,12 +109,14 @@ private function deleteDatabase()

foreach ($databasesToDelete as $database) {
$toDelete = $databases->where('id', $database)->first();
$this->info($toDelete);
$confirmed = confirm("Are you sure you want to delete all selected resources?");
if (!$confirmed) {
return;
if ($toDelete) {
$this->info($toDelete);
$confirmed = confirm("Are you sure you want to delete all selected resources?");
if (!$confirmed) {
return;
}
$toDelete->delete();
}
$toDelete->delete();
}
}
private function deleteService()
Expand All @@ -128,12 +133,14 @@ private function deleteService()

foreach ($servicesToDelete as $service) {
$toDelete = $services->where('id', $service)->first();
$this->info($toDelete);
$confirmed = confirm("Are you sure you want to delete all selected resources?");
if (!$confirmed) {
return;
if ($toDelete) {
$this->info($toDelete);
$confirmed = confirm("Are you sure you want to delete all selected resources?");
if (!$confirmed) {
return;
}
$toDelete->delete();
}
$toDelete->delete();
}
}
}
4 changes: 2 additions & 2 deletions app/Console/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ protected function schedule(Schedule $schedule): void
// Instance Jobs
$schedule->command('horizon:snapshot')->everyMinute();
$schedule->job(new CleanupInstanceStuffsJob)->everyMinute()->onOneServer();

// $schedule->job(new CheckResaleLicenseJob)->hourly()->onOneServer();
// Server Jobs
$this->check_scheduled_backups($schedule);
$this->check_resources($schedule);
Expand All @@ -34,7 +34,7 @@ protected function schedule(Schedule $schedule): void
// Instance Jobs
$schedule->command('horizon:snapshot')->everyFiveMinutes();
$schedule->job(new CleanupInstanceStuffsJob)->everyTwoMinutes()->onOneServer();
$schedule->job(new CheckResaleLicenseJob)->hourly()->onOneServer();
// $schedule->job(new CheckResaleLicenseJob)->hourly()->onOneServer();

// Server Jobs
$this->instance_auto_update($schedule);
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/ApplicationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function deployments()
if (!$application) {
return redirect()->route('dashboard');
}
['deployments' => $deployments, 'count' => $count] = $application->deployments(0, 8);
['deployments' => $deployments, 'count' => $count] = $application->deployments(0, 40);
return view('project.application.deployments', ['application' => $application, 'deployments' => $deployments, 'deployments_count' => $count]);
}

Expand Down
8 changes: 7 additions & 1 deletion app/Http/Controllers/MagicController.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,14 @@ public function projects()

public function environments()
{
$project = Project::ownedByCurrentTeam()->whereUuid(request()->query('project_uuid'))->first();
if (!$project) {
return response()->json([
'environments' => []
]);
}
return response()->json([
'environments' => Project::ownedByCurrentTeam()->whereUuid(request()->query('project_uuid'))->first()->environments
'environments' => $project->environments
]);
}

Expand Down
2 changes: 1 addition & 1 deletion app/Http/Livewire/Boarding/Index.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ public function saveServer()
{
$this->validate([
'remoteServerName' => 'required',
'remoteServerHost' => 'required|ip',
'remoteServerHost' => 'required',
'remoteServerPort' => 'required|integer',
'remoteServerUser' => 'required',
]);
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Livewire/CheckLicense.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function submit()
$this->settings->save();
if ($this->settings->resale_license) {
try {
resolve(CheckResaleLicense::class)();
CheckResaleLicense::run();
$this->emit('reloadWindow');
} catch (\Throwable $e) {
session()->flash('error', 'Something went wrong. Please contact support. <br>Error: ' . $e->getMessage());
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Livewire/Destination/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class Form extends Component
protected $validationAttributes = [
'destination.name' => 'name',
'destination.network' => 'network',
'destination.server.ip' => 'IP Address',
'destination.server.ip' => 'IP Address/Domain',
];

public function submit()
Expand Down
16 changes: 12 additions & 4 deletions app/Http/Livewire/Project/Application/Deployments.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,31 @@
namespace App\Http\Livewire\Project\Application;

use App\Models\Application;
use Illuminate\Support\Collection;
use Livewire\Component;

class Deployments extends Component
{
public Application $application;
public $deployments = [];
public Array|Collection $deployments = [];
public int $deployments_count = 0;
public string $current_url;
public int $skip = 0;
public int $default_take = 8;
public int $default_take = 40;
public bool $show_next = false;

public ?string $pull_request_id = null;
protected $queryString = ['pull_request_id'];
public function mount()
{
$this->current_url = url()->current();
$this->show_pull_request_only();
$this->show_more();
}

private function show_pull_request_only() {
if ($this->pull_request_id) {
$this->deployments = $this->deployments->where('pull_request_id', $this->pull_request_id);
}
}
private function show_more()
{
if (count($this->deployments) !== 0) {
Expand All @@ -47,6 +54,7 @@ public function load_deployments(int|null $take = null)
['deployments' => $deployments, 'count' => $count] = $this->application->deployments($this->skip, $take);
$this->deployments = $deployments;
$this->deployments_count = $count;
$this->show_pull_request_only();
$this->show_more();
}
}
2 changes: 1 addition & 1 deletion app/Http/Livewire/Project/Application/General.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ public function getWildcardDomain()
$fqdn = generateFqdn($server, $this->application->uuid);
$this->application->fqdn = $fqdn;
$this->application->save();
$this->emit('success', 'Application settings updated!');
$this->updatedApplicationFqdn();
}
}
public function resetDefaultLabels($showToaster = true)
Expand Down
14 changes: 14 additions & 0 deletions app/Http/Livewire/Project/Application/Heading.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,18 @@ public function stop()
$this->application->save();
$this->application->refresh();
}
public function restart() {
$this->setDeploymentUuid();
queue_application_deployment(
application_id: $this->application->id,
deployment_uuid: $this->deploymentUuid,
restart_only: true,
);
return redirect()->route('project.application.deployment', [
'project_uuid' => $this->parameters['project_uuid'],
'application_uuid' => $this->parameters['application_uuid'],
'deployment_uuid' => $this->deploymentUuid,
'environment_name' => $this->parameters['environment_name'],
]);
}
}
1 change: 0 additions & 1 deletion app/Http/Livewire/Project/New/GithubPrivateRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Route;
use Livewire\Component;
use Spatie\Url\Url;

class GithubPrivateRepository extends Component
{
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Livewire/Project/Service/Index.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class Index extends Component
public $databases;
public array $parameters;
public array $query;
protected $listeners = ["refreshStacks","checkStatus"];
protected $listeners = ["refreshStacks", "checkStatus"];
public function render()
{
return view('livewire.project.service.index');
Expand Down
10 changes: 4 additions & 6 deletions app/Http/Livewire/Project/Service/Navbar.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use App\Actions\Service\StartService;
use App\Actions\Service\StopService;
use App\Jobs\ContainerStatusJob;
use App\Models\Service;
use Livewire\Component;

Expand All @@ -13,15 +12,14 @@ class Navbar extends Component
public Service $service;
public array $parameters;
public array $query;
protected $listeners = ["checkStatus"];

public function render()
{
return view('livewire.project.service.navbar');
}

public function checkStatus()
{
$this->emit('checkStatus');
public function checkStatus() {
$this->service->refresh();
}
public function deploy()
{
Expand All @@ -34,6 +32,6 @@ public function stop()
StopService::run($this->service);
$this->service->refresh();
$this->emit('success', 'Service stopped successfully.');
$this->checkStatus();
$this->emit('checkStatus');
}
}
4 changes: 2 additions & 2 deletions app/Http/Livewire/Project/Shared/Danger.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace App\Http\Livewire\Project\Shared;

use App\Jobs\StopResourceJob;
use App\Jobs\DeleteResourceJob;
use Livewire\Component;
use Visus\Cuid2\Cuid2;

Expand All @@ -21,7 +21,7 @@ public function mount()
public function delete()
{
try {
StopResourceJob::dispatchSync($this->resource);
DeleteResourceJob::dispatchSync($this->resource);
return redirect()->route('project.resources', [
'project_uuid' => $this->parameters['project_uuid'],
'environment_name' => $this->parameters['environment_name']
Expand Down
Loading

0 comments on commit 5ce449a

Please sign in to comment.