Fix styling
This commit is contained in:
committed by
github-actions[bot]
parent
41fb6a1fc9
commit
d86274cc37
@@ -17,16 +17,21 @@ use Livewire\Component;
|
||||
class ConfigurationChecker extends Component
|
||||
{
|
||||
public bool $isConfigurationChanged = false;
|
||||
|
||||
public Application|Service|StandaloneRedis|StandalonePostgresql|StandaloneMongodb|StandaloneMysql|StandaloneMariadb|StandaloneKeydb|StandaloneDragonfly|StandaloneClickhouse $resource;
|
||||
|
||||
protected $listeners = ['configurationChanged'];
|
||||
|
||||
public function mount()
|
||||
{
|
||||
$this->configurationChanged();
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.project.shared.configuration-checker');
|
||||
}
|
||||
|
||||
public function configurationChanged()
|
||||
{
|
||||
$this->isConfigurationChanged = $this->resource->isConfigurationChanged();
|
||||
|
||||
@@ -9,9 +9,13 @@ use Visus\Cuid2\Cuid2;
|
||||
class Danger extends Component
|
||||
{
|
||||
public $resource;
|
||||
|
||||
public $projectUuid;
|
||||
|
||||
public $environmentName;
|
||||
|
||||
public bool $delete_configurations = true;
|
||||
|
||||
public ?string $modalId = null;
|
||||
|
||||
public function mount()
|
||||
@@ -21,15 +25,17 @@ class Danger extends Component
|
||||
$this->projectUuid = data_get($parameters, 'project_uuid');
|
||||
$this->environmentName = data_get($parameters, 'environment_name');
|
||||
}
|
||||
|
||||
public function delete()
|
||||
{
|
||||
try {
|
||||
// $this->authorize('delete', $this->resource);
|
||||
$this->resource->delete();
|
||||
DeleteResourceJob::dispatch($this->resource, $this->delete_configurations);
|
||||
|
||||
return redirect()->route('project.resource.index', [
|
||||
'project_uuid' => $this->projectUuid,
|
||||
'environment_name' => $this->environmentName
|
||||
'environment_name' => $this->environmentName,
|
||||
]);
|
||||
} catch (\Throwable $e) {
|
||||
return handleError($e, $this);
|
||||
|
||||
@@ -14,19 +14,23 @@ use Visus\Cuid2\Cuid2;
|
||||
class Destination extends Component
|
||||
{
|
||||
public $resource;
|
||||
|
||||
public $networks = [];
|
||||
|
||||
public function getListeners()
|
||||
{
|
||||
$teamId = auth()->user()->currentTeam()->id;
|
||||
|
||||
return [
|
||||
"echo-private:team.{$teamId},ApplicationStatusChanged" => 'loadData',
|
||||
];
|
||||
}
|
||||
|
||||
public function mount()
|
||||
{
|
||||
$this->loadData();
|
||||
}
|
||||
|
||||
public function loadData()
|
||||
{
|
||||
$all_networks = collect([]);
|
||||
@@ -48,16 +52,19 @@ class Destination extends Component
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public function stop(int $server_id)
|
||||
{
|
||||
$server = Server::find($server_id);
|
||||
StopApplicationOneServer::run($this->resource, $server);
|
||||
$this->refreshServers();
|
||||
}
|
||||
|
||||
public function redeploy(int $network_id, int $server_id)
|
||||
{
|
||||
if ($this->resource->additional_servers->count() > 0 && str($this->resource->docker_registry_image_name)->isEmpty()) {
|
||||
$this->dispatch('error', 'Failed to deploy.', 'Before deploying to multiple servers, you must first set a Docker image in the General tab.<br>More information here: <a target="_blank" class="underline" href="https://coolify.io/docs/knowledge-base/server/multiple-servers">documentation</a>');
|
||||
|
||||
return;
|
||||
}
|
||||
$deployment_uuid = new Cuid2(7);
|
||||
@@ -71,6 +78,7 @@ class Destination extends Component
|
||||
only_this_server: true,
|
||||
no_questions_asked: true,
|
||||
);
|
||||
|
||||
return redirect()->route('project.application.deployment.show', [
|
||||
'project_uuid' => data_get($this->resource, 'environment.project.uuid'),
|
||||
'application_uuid' => data_get($this->resource, 'uuid'),
|
||||
@@ -78,6 +86,7 @@ class Destination extends Component
|
||||
'environment_name' => data_get($this->resource, 'environment.name'),
|
||||
]);
|
||||
}
|
||||
|
||||
public function promote(int $network_id, int $server_id)
|
||||
{
|
||||
$main_destination = $this->resource->destination;
|
||||
@@ -89,6 +98,7 @@ class Destination extends Component
|
||||
$this->resource->additional_networks()->attach($main_destination->id, ['server_id' => $main_destination->server->id]);
|
||||
$this->refreshServers();
|
||||
}
|
||||
|
||||
public function refreshServers()
|
||||
{
|
||||
GetContainersStatus::run($this->resource->destination->server);
|
||||
@@ -97,16 +107,19 @@ class Destination extends Component
|
||||
$this->dispatch('refresh');
|
||||
ApplicationStatusChanged::dispatch(data_get($this->resource, 'environment.project.team.id'));
|
||||
}
|
||||
|
||||
public function addServer(int $network_id, int $server_id)
|
||||
{
|
||||
$this->resource->additional_networks()->attach($network_id, ['server_id' => $server_id]);
|
||||
$this->loadData();
|
||||
ApplicationStatusChanged::dispatch(data_get($this->resource, 'environment.project.team.id'));
|
||||
}
|
||||
|
||||
public function removeServer(int $network_id, int $server_id)
|
||||
{
|
||||
if ($this->resource->destination->server->id == $server_id && $this->resource->destination->id == $network_id) {
|
||||
$this->dispatch('error', 'You cannot remove this destination server.', 'You are trying to remove the main server.');
|
||||
|
||||
return;
|
||||
}
|
||||
$server = Server::find($server_id);
|
||||
|
||||
@@ -7,15 +7,23 @@ use Livewire\Component;
|
||||
class Add extends Component
|
||||
{
|
||||
public $parameters;
|
||||
|
||||
public bool $shared = false;
|
||||
|
||||
public bool $is_preview = false;
|
||||
|
||||
public string $key;
|
||||
|
||||
public ?string $value = null;
|
||||
|
||||
public bool $is_build_time = false;
|
||||
|
||||
public bool $is_multiline = false;
|
||||
|
||||
public bool $is_literal = false;
|
||||
|
||||
protected $listeners = ['clearAddEnv' => 'clear'];
|
||||
|
||||
protected $rules = [
|
||||
'key' => 'required|string',
|
||||
'value' => 'nullable',
|
||||
@@ -23,6 +31,7 @@ class Add extends Component
|
||||
'is_multiline' => 'required|boolean',
|
||||
'is_literal' => 'required|boolean',
|
||||
];
|
||||
|
||||
protected $validationAttributes = [
|
||||
'key' => 'key',
|
||||
'value' => 'value',
|
||||
@@ -40,9 +49,10 @@ class Add extends Component
|
||||
{
|
||||
$this->validate();
|
||||
if (str($this->value)->startsWith('{{') && str($this->value)->endsWith('}}')) {
|
||||
$type = str($this->value)->after("{{")->before(".")->value;
|
||||
if (!collect(SHARED_VARIABLE_TYPES)->contains($type)) {
|
||||
$this->dispatch('error', 'Invalid shared variable type.', "Valid types are: team, project, environment.");
|
||||
$type = str($this->value)->after('{{')->before('.')->value;
|
||||
if (! collect(SHARED_VARIABLE_TYPES)->contains($type)) {
|
||||
$this->dispatch('error', 'Invalid shared variable type.', 'Valid types are: team, project, environment.');
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,16 +9,24 @@ use Visus\Cuid2\Cuid2;
|
||||
class All extends Component
|
||||
{
|
||||
public $resource;
|
||||
|
||||
public string $resourceClass;
|
||||
|
||||
public bool $showPreview = false;
|
||||
|
||||
public ?string $modalId = null;
|
||||
|
||||
public ?string $variables = null;
|
||||
|
||||
public ?string $variablesPreview = null;
|
||||
|
||||
public string $view = 'normal';
|
||||
|
||||
protected $listeners = [
|
||||
'refreshEnvs',
|
||||
'saveKey' => 'submit',
|
||||
];
|
||||
|
||||
protected $rules = [
|
||||
'resource.settings.is_env_sorting_enabled' => 'required|boolean',
|
||||
];
|
||||
@@ -27,8 +35,8 @@ class All extends Component
|
||||
{
|
||||
$this->resourceClass = get_class($this->resource);
|
||||
$resourceWithPreviews = ['App\Models\Application'];
|
||||
$simpleDockerfile = !is_null(data_get($this->resource, 'dockerfile'));
|
||||
if (str($this->resourceClass)->contains($resourceWithPreviews) && !$simpleDockerfile) {
|
||||
$simpleDockerfile = ! is_null(data_get($this->resource, 'dockerfile'));
|
||||
if (str($this->resourceClass)->contains($resourceWithPreviews) && ! $simpleDockerfile) {
|
||||
$this->showPreview = true;
|
||||
}
|
||||
$this->modalId = new Cuid2(7);
|
||||
@@ -49,6 +57,7 @@ class All extends Component
|
||||
}
|
||||
$this->getDevView();
|
||||
}
|
||||
|
||||
public function instantSave()
|
||||
{
|
||||
if ($this->resourceClass === 'App\Models\Application' && data_get($this->resource, 'build_pack') !== 'dockercompose') {
|
||||
@@ -57,6 +66,7 @@ class All extends Component
|
||||
$this->sortMe();
|
||||
}
|
||||
}
|
||||
|
||||
public function getDevView()
|
||||
{
|
||||
$this->variables = $this->resource->environment_variables->map(function ($item) {
|
||||
@@ -66,6 +76,7 @@ class All extends Component
|
||||
if ($item->is_multiline) {
|
||||
return "$item->key=(multiline, edit in normal view)";
|
||||
}
|
||||
|
||||
return "$item->key=$item->value";
|
||||
})->join('
|
||||
');
|
||||
@@ -77,11 +88,13 @@ class All extends Component
|
||||
if ($item->is_multiline) {
|
||||
return "$item->key=(multiline, edit in normal view)";
|
||||
}
|
||||
|
||||
return "$item->key=$item->value";
|
||||
})->join('
|
||||
');
|
||||
}
|
||||
}
|
||||
|
||||
public function switch()
|
||||
{
|
||||
if ($this->view === 'normal') {
|
||||
@@ -91,6 +104,7 @@ class All extends Component
|
||||
}
|
||||
$this->sortMe();
|
||||
}
|
||||
|
||||
public function saveVariables($isPreview)
|
||||
{
|
||||
if ($isPreview) {
|
||||
@@ -113,22 +127,25 @@ class All extends Component
|
||||
}
|
||||
$found->value = $variable;
|
||||
if (str($found->value)->startsWith('{{') && str($found->value)->endsWith('}}')) {
|
||||
$type = str($found->value)->after("{{")->before(".")->value;
|
||||
if (!collect(SHARED_VARIABLE_TYPES)->contains($type)) {
|
||||
$this->dispatch('error', 'Invalid shared variable type.', "Valid types are: team, project, environment.");
|
||||
$type = str($found->value)->after('{{')->before('.')->value;
|
||||
if (! collect(SHARED_VARIABLE_TYPES)->contains($type)) {
|
||||
$this->dispatch('error', 'Invalid shared variable type.', 'Valid types are: team, project, environment.');
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
$found->save();
|
||||
|
||||
continue;
|
||||
} else {
|
||||
$environment = new EnvironmentVariable();
|
||||
$environment->key = $key;
|
||||
$environment->value = $variable;
|
||||
if (str($environment->value)->startsWith('{{') && str($environment->value)->endsWith('}}')) {
|
||||
$type = str($environment->value)->after("{{")->before(".")->value;
|
||||
if (!collect(SHARED_VARIABLE_TYPES)->contains($type)) {
|
||||
$this->dispatch('error', 'Invalid shared variable type.', "Valid types are: team, project, environment.");
|
||||
$type = str($environment->value)->after('{{')->before('.')->value;
|
||||
if (! collect(SHARED_VARIABLE_TYPES)->contains($type)) {
|
||||
$this->dispatch('error', 'Invalid shared variable type.', 'Valid types are: team, project, environment.');
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -177,6 +194,7 @@ class All extends Component
|
||||
}
|
||||
$this->refreshEnvs();
|
||||
}
|
||||
|
||||
public function refreshEnvs()
|
||||
{
|
||||
$this->resource->refresh();
|
||||
@@ -189,6 +207,7 @@ class All extends Component
|
||||
$found = $this->resource->environment_variables()->where('key', $data['key'])->first();
|
||||
if ($found) {
|
||||
$this->dispatch('error', 'Environment variable already exists.');
|
||||
|
||||
return;
|
||||
}
|
||||
$environment = new EnvironmentVariable();
|
||||
|
||||
@@ -10,14 +10,21 @@ use Visus\Cuid2\Cuid2;
|
||||
class Show extends Component
|
||||
{
|
||||
public $parameters;
|
||||
|
||||
public ModelsEnvironmentVariable|SharedEnvironmentVariable $env;
|
||||
|
||||
public ?string $modalId = null;
|
||||
|
||||
public bool $isDisabled = false;
|
||||
|
||||
public bool $isLocked = false;
|
||||
|
||||
public bool $isSharedVariable = false;
|
||||
|
||||
public string $type;
|
||||
|
||||
protected $listeners = [
|
||||
"compose_loaded" => '$refresh',
|
||||
'compose_loaded' => '$refresh',
|
||||
];
|
||||
|
||||
protected $rules = [
|
||||
@@ -29,6 +36,7 @@ class Show extends Component
|
||||
'env.is_shown_once' => 'required|boolean',
|
||||
'env.real_value' => 'nullable',
|
||||
];
|
||||
|
||||
protected $validationAttributes = [
|
||||
'env.key' => 'Key',
|
||||
'env.value' => 'Value',
|
||||
@@ -47,6 +55,7 @@ class Show extends Component
|
||||
$this->parameters = get_route_parameters();
|
||||
$this->checkEnvs();
|
||||
}
|
||||
|
||||
public function checkEnvs()
|
||||
{
|
||||
$this->isDisabled = false;
|
||||
@@ -57,6 +66,7 @@ class Show extends Component
|
||||
$this->isLocked = true;
|
||||
}
|
||||
}
|
||||
|
||||
public function serialize()
|
||||
{
|
||||
data_forget($this->env, 'real_value');
|
||||
@@ -64,6 +74,7 @@ class Show extends Component
|
||||
data_forget($this->env, 'is_build_time');
|
||||
}
|
||||
}
|
||||
|
||||
public function lock()
|
||||
{
|
||||
$this->env->is_shown_once = true;
|
||||
@@ -72,10 +83,12 @@ class Show extends Component
|
||||
$this->checkEnvs();
|
||||
$this->dispatch('refreshEnvs');
|
||||
}
|
||||
|
||||
public function instantSave()
|
||||
{
|
||||
$this->submit();
|
||||
}
|
||||
|
||||
public function submit()
|
||||
{
|
||||
try {
|
||||
@@ -89,9 +102,10 @@ class Show extends Component
|
||||
$this->validate();
|
||||
}
|
||||
if (str($this->env->value)->startsWith('{{') && str($this->env->value)->endsWith('}}')) {
|
||||
$type = str($this->env->value)->after("{{")->before(".")->value;
|
||||
if (!collect(SHARED_VARIABLE_TYPES)->contains($type)) {
|
||||
$this->dispatch('error', 'Invalid shared variable type.', "Valid types are: team, project, environment.");
|
||||
$type = str($this->env->value)->after('{{')->before('.')->value;
|
||||
if (! collect(SHARED_VARIABLE_TYPES)->contains($type)) {
|
||||
$this->dispatch('error', 'Invalid shared variable type.', 'Valid types are: team, project, environment.');
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,13 +11,21 @@ use Livewire\Component;
|
||||
class ExecuteContainerCommand extends Component
|
||||
{
|
||||
public string $command;
|
||||
|
||||
public string $container;
|
||||
|
||||
public Collection $containers;
|
||||
|
||||
public $parameters;
|
||||
|
||||
public $resource;
|
||||
|
||||
public string $type;
|
||||
|
||||
public string $workDir = '';
|
||||
|
||||
public Server $server;
|
||||
|
||||
public Collection $servers;
|
||||
|
||||
protected $rules = [
|
||||
@@ -43,9 +51,9 @@ class ExecuteContainerCommand extends Component
|
||||
$this->servers = $this->servers->push($server);
|
||||
}
|
||||
}
|
||||
} else if (data_get($this->parameters, 'database_uuid')) {
|
||||
} elseif (data_get($this->parameters, 'database_uuid')) {
|
||||
$this->type = 'database';
|
||||
$resource = getResourceByUuid($this->parameters['database_uuid'], data_get(auth()->user()->currentTeam(),'id'));
|
||||
$resource = getResourceByUuid($this->parameters['database_uuid'], data_get(auth()->user()->currentTeam(), 'id'));
|
||||
if (is_null($resource)) {
|
||||
abort(404);
|
||||
}
|
||||
@@ -55,14 +63,14 @@ class ExecuteContainerCommand extends Component
|
||||
}
|
||||
$this->container = $this->resource->uuid;
|
||||
$this->containers->push($this->container);
|
||||
} else if (data_get($this->parameters, 'service_uuid')) {
|
||||
} elseif (data_get($this->parameters, 'service_uuid')) {
|
||||
$this->type = 'service';
|
||||
$this->resource = Service::where('uuid', $this->parameters['service_uuid'])->firstOrFail();
|
||||
$this->resource->applications()->get()->each(function ($application) {
|
||||
$this->containers->push(data_get($application, 'name') . '-' . data_get($this->resource, 'uuid'));
|
||||
$this->containers->push(data_get($application, 'name').'-'.data_get($this->resource, 'uuid'));
|
||||
});
|
||||
$this->resource->databases()->get()->each(function ($database) {
|
||||
$this->containers->push(data_get($database, 'name') . '-' . data_get($this->resource, 'uuid'));
|
||||
$this->containers->push(data_get($database, 'name').'-'.data_get($this->resource, 'uuid'));
|
||||
});
|
||||
if ($this->resource->server->isFunctional()) {
|
||||
$this->servers = $this->servers->push($this->resource->server);
|
||||
@@ -72,6 +80,7 @@ class ExecuteContainerCommand extends Component
|
||||
$this->container = $this->containers->first();
|
||||
}
|
||||
}
|
||||
|
||||
public function loadContainers()
|
||||
{
|
||||
foreach ($this->servers as $server) {
|
||||
@@ -79,8 +88,8 @@ class ExecuteContainerCommand extends Component
|
||||
if ($server->isSwarm()) {
|
||||
$containers = collect([
|
||||
[
|
||||
'Names' => $this->resource->uuid . '_' . $this->resource->uuid,
|
||||
]
|
||||
'Names' => $this->resource->uuid.'_'.$this->resource->uuid,
|
||||
],
|
||||
]);
|
||||
} else {
|
||||
$containers = getCurrentApplicationContainerStatus($server, $this->resource->id, includePullrequests: true);
|
||||
@@ -122,8 +131,8 @@ class ExecuteContainerCommand extends Component
|
||||
if ($server->isForceDisabled()) {
|
||||
throw new \RuntimeException('Server is disabled.');
|
||||
}
|
||||
$cmd = "sh -c 'if [ -f ~/.profile ]; then . ~/.profile; fi; " . str_replace("'", "'\''", $this->command) . "'";
|
||||
if (!empty($this->workDir)) {
|
||||
$cmd = "sh -c 'if [ -f ~/.profile ]; then . ~/.profile; fi; ".str_replace("'", "'\''", $this->command)."'";
|
||||
if (! empty($this->workDir)) {
|
||||
$exec = "docker exec -w {$this->workDir} {$container_name} {$cmd}";
|
||||
} else {
|
||||
$exec = "docker exec {$container_name} {$cmd}";
|
||||
@@ -134,6 +143,7 @@ class ExecuteContainerCommand extends Component
|
||||
return handleError($e, $this);
|
||||
}
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.project.shared.execute-container-command');
|
||||
|
||||
@@ -21,19 +21,28 @@ use Livewire\Component;
|
||||
class GetLogs extends Component
|
||||
{
|
||||
public string $outputs = '';
|
||||
|
||||
public string $errors = '';
|
||||
|
||||
public Application|Service|StandalonePostgresql|StandaloneRedis|StandaloneMongodb|StandaloneMysql|StandaloneMariadb|StandaloneKeydb|StandaloneDragonfly|StandaloneClickhouse|null $resource = null;
|
||||
|
||||
public ServiceApplication|ServiceDatabase|null $servicesubtype = null;
|
||||
|
||||
public Server $server;
|
||||
|
||||
public ?string $container = null;
|
||||
|
||||
public ?string $pull_request = null;
|
||||
|
||||
public ?bool $streamLogs = false;
|
||||
|
||||
public ?bool $showTimeStamps = true;
|
||||
|
||||
public int $numberOfLines = 100;
|
||||
|
||||
public function mount()
|
||||
{
|
||||
if (!is_null($this->resource)) {
|
||||
if (! is_null($this->resource)) {
|
||||
if ($this->resource->getMorphClass() === 'App\Models\Application') {
|
||||
$this->showTimeStamps = $this->resource->settings->is_include_timestamps;
|
||||
} else {
|
||||
@@ -45,18 +54,20 @@ class GetLogs extends Component
|
||||
}
|
||||
if ($this->resource?->getMorphClass() === 'App\Models\Application') {
|
||||
if (str($this->container)->contains('-pr-')) {
|
||||
$this->pull_request = "Pull Request: " . str($this->container)->afterLast('-pr-')->beforeLast('_')->value();
|
||||
$this->pull_request = 'Pull Request: '.str($this->container)->afterLast('-pr-')->beforeLast('_')->value();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function doSomethingWithThisChunkOfOutput($output)
|
||||
{
|
||||
$this->outputs .= removeAnsiColors($output);
|
||||
}
|
||||
|
||||
public function instantSave()
|
||||
{
|
||||
if (!is_null($this->resource)) {
|
||||
if (! is_null($this->resource)) {
|
||||
if ($this->resource->getMorphClass() === 'App\Models\Application') {
|
||||
$this->resource->settings->is_include_timestamps = $this->showTimeStamps;
|
||||
$this->resource->settings->save();
|
||||
@@ -77,13 +88,16 @@ class GetLogs extends Component
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function getLogs($refresh = false)
|
||||
{
|
||||
if (!$this->server->isFunctional()) {
|
||||
if (! $this->server->isFunctional()) {
|
||||
return;
|
||||
}
|
||||
if (!$refresh && ($this->resource?->getMorphClass() === 'App\Models\Service' || str($this->container)->contains('-pr-'))) return;
|
||||
if (!$this->numberOfLines) {
|
||||
if (! $refresh && ($this->resource?->getMorphClass() === 'App\Models\Service' || str($this->container)->contains('-pr-'))) {
|
||||
return;
|
||||
}
|
||||
if (! $this->numberOfLines) {
|
||||
$this->numberOfLines = 1000;
|
||||
}
|
||||
if ($this->container) {
|
||||
@@ -130,11 +144,13 @@ class GetLogs extends Component
|
||||
$this->outputs = str($this->outputs)->split('/\n/')->sort(function ($a, $b) {
|
||||
$a = explode(' ', $a);
|
||||
$b = explode(' ', $b);
|
||||
|
||||
return $a[0] <=> $b[0];
|
||||
})->join("\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.project.shared.get-logs');
|
||||
|
||||
@@ -6,8 +6,8 @@ use Livewire\Component;
|
||||
|
||||
class HealthChecks extends Component
|
||||
{
|
||||
|
||||
public $resource;
|
||||
|
||||
protected $rules = [
|
||||
'resource.health_check_enabled' => 'boolean',
|
||||
'resource.health_check_path' => 'string',
|
||||
@@ -24,11 +24,13 @@ class HealthChecks extends Component
|
||||
'resource.custom_healthcheck_found' => 'boolean',
|
||||
|
||||
];
|
||||
|
||||
public function instantSave()
|
||||
{
|
||||
$this->resource->save();
|
||||
$this->dispatch('success', 'Health check updated.');
|
||||
}
|
||||
|
||||
public function submit()
|
||||
{
|
||||
try {
|
||||
@@ -39,6 +41,7 @@ class HealthChecks extends Component
|
||||
return handleError($e, $this);
|
||||
}
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.project.shared.health-checks');
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
namespace App\Livewire\Project\Shared;
|
||||
|
||||
use App\Models\Application;
|
||||
use App\Models\Server;
|
||||
use App\Models\Service;
|
||||
use App\Models\StandaloneClickhouse;
|
||||
use App\Models\StandaloneDragonfly;
|
||||
@@ -19,27 +18,37 @@ use Livewire\Component;
|
||||
class Logs extends Component
|
||||
{
|
||||
public ?string $type = null;
|
||||
|
||||
public Application|Service|StandalonePostgresql|StandaloneRedis|StandaloneMongodb|StandaloneMysql|StandaloneMariadb|StandaloneKeydb|StandaloneDragonfly|StandaloneClickhouse $resource;
|
||||
|
||||
public Collection $servers;
|
||||
|
||||
public Collection $containers;
|
||||
|
||||
public $container = [];
|
||||
|
||||
public $parameters;
|
||||
|
||||
public $query;
|
||||
|
||||
public $status;
|
||||
|
||||
public $serviceSubType;
|
||||
|
||||
public $cpu;
|
||||
|
||||
public function loadContainers($server_id)
|
||||
{
|
||||
try {
|
||||
$server = $this->servers->firstWhere('id', $server_id);
|
||||
if (!$server->isFunctional()) {
|
||||
if (! $server->isFunctional()) {
|
||||
return;
|
||||
}
|
||||
if ($server->isSwarm()) {
|
||||
$containers = collect([
|
||||
[
|
||||
'Names' => $this->resource->uuid . '_' . $this->resource->uuid,
|
||||
]
|
||||
'Names' => $this->resource->uuid.'_'.$this->resource->uuid,
|
||||
],
|
||||
]);
|
||||
} else {
|
||||
$containers = getCurrentApplicationContainerStatus($server, $this->resource->id, includePullrequests: true);
|
||||
@@ -49,6 +58,7 @@ class Logs extends Component
|
||||
return handleError($e, $this);
|
||||
}
|
||||
}
|
||||
|
||||
public function loadMetrics()
|
||||
{
|
||||
return;
|
||||
@@ -57,6 +67,7 @@ class Logs extends Component
|
||||
$this->cpu = $server->getMetrics();
|
||||
}
|
||||
}
|
||||
|
||||
public function mount()
|
||||
{
|
||||
try {
|
||||
@@ -76,7 +87,7 @@ class Logs extends Component
|
||||
$this->servers = $this->servers->push($server);
|
||||
}
|
||||
}
|
||||
} else if (data_get($this->parameters, 'database_uuid')) {
|
||||
} elseif (data_get($this->parameters, 'database_uuid')) {
|
||||
$this->type = 'database';
|
||||
$resource = getResourceByUuid($this->parameters['database_uuid'], data_get(auth()->user()->currentTeam(), 'id'));
|
||||
if (is_null($resource)) {
|
||||
@@ -89,21 +100,21 @@ class Logs extends Component
|
||||
}
|
||||
$this->container = $this->resource->uuid;
|
||||
$this->containers->push($this->container);
|
||||
} else if (data_get($this->parameters, 'service_uuid')) {
|
||||
} elseif (data_get($this->parameters, 'service_uuid')) {
|
||||
$this->type = 'service';
|
||||
$this->resource = Service::where('uuid', $this->parameters['service_uuid'])->firstOrFail();
|
||||
$this->resource->applications()->get()->each(function ($application) {
|
||||
$this->containers->push(data_get($application, 'name') . '-' . data_get($this->resource, 'uuid'));
|
||||
$this->containers->push(data_get($application, 'name').'-'.data_get($this->resource, 'uuid'));
|
||||
});
|
||||
$this->resource->databases()->get()->each(function ($database) {
|
||||
$this->containers->push(data_get($database, 'name') . '-' . data_get($this->resource, 'uuid'));
|
||||
$this->containers->push(data_get($database, 'name').'-'.data_get($this->resource, 'uuid'));
|
||||
});
|
||||
if ($this->resource->server->isFunctional()) {
|
||||
$this->servers = $this->servers->push($this->resource->server);
|
||||
}
|
||||
}
|
||||
$this->containers = $this->containers->sort();
|
||||
if (data_get($this->query,'pull_request_id')) {
|
||||
if (data_get($this->query, 'pull_request_id')) {
|
||||
$this->containers = $this->containers->filter(function ($container) {
|
||||
return str_contains($container, $this->query['pull_request_id']);
|
||||
});
|
||||
|
||||
@@ -7,6 +7,7 @@ use Livewire\Component;
|
||||
class ResourceLimits extends Component
|
||||
{
|
||||
public $resource;
|
||||
|
||||
protected $rules = [
|
||||
'resource.limits_memory' => 'required|string',
|
||||
'resource.limits_memory_swap' => 'required|string',
|
||||
@@ -16,6 +17,7 @@ class ResourceLimits extends Component
|
||||
'resource.limits_cpuset' => 'nullable',
|
||||
'resource.limits_cpu_shares' => 'nullable',
|
||||
];
|
||||
|
||||
protected $validationAttributes = [
|
||||
'resource.limits_memory' => 'memory',
|
||||
'resource.limits_memory_swap' => 'swap',
|
||||
@@ -29,22 +31,22 @@ class ResourceLimits extends Component
|
||||
public function submit()
|
||||
{
|
||||
try {
|
||||
if (!$this->resource->limits_memory) {
|
||||
$this->resource->limits_memory = "0";
|
||||
if (! $this->resource->limits_memory) {
|
||||
$this->resource->limits_memory = '0';
|
||||
}
|
||||
if (!$this->resource->limits_memory_swap) {
|
||||
$this->resource->limits_memory_swap = "0";
|
||||
if (! $this->resource->limits_memory_swap) {
|
||||
$this->resource->limits_memory_swap = '0';
|
||||
}
|
||||
if (is_null($this->resource->limits_memory_swappiness)) {
|
||||
$this->resource->limits_memory_swappiness = "60";
|
||||
$this->resource->limits_memory_swappiness = '60';
|
||||
}
|
||||
if (!$this->resource->limits_memory_reservation) {
|
||||
$this->resource->limits_memory_reservation = "0";
|
||||
if (! $this->resource->limits_memory_reservation) {
|
||||
$this->resource->limits_memory_reservation = '0';
|
||||
}
|
||||
if (!$this->resource->limits_cpus) {
|
||||
$this->resource->limits_cpus = "0";
|
||||
if (! $this->resource->limits_cpus) {
|
||||
$this->resource->limits_cpus = '0';
|
||||
}
|
||||
if ($this->resource->limits_cpuset === "") {
|
||||
if ($this->resource->limits_cpuset === '') {
|
||||
$this->resource->limits_cpuset = null;
|
||||
}
|
||||
if (is_null($this->resource->limits_cpu_shares)) {
|
||||
|
||||
@@ -12,9 +12,13 @@ use Visus\Cuid2\Cuid2;
|
||||
class ResourceOperations extends Component
|
||||
{
|
||||
public $resource;
|
||||
|
||||
public $projectUuid;
|
||||
|
||||
public $environmentName;
|
||||
|
||||
public $projects;
|
||||
|
||||
public $servers;
|
||||
|
||||
public function mount()
|
||||
@@ -25,28 +29,29 @@ class ResourceOperations extends Component
|
||||
$this->projects = Project::ownedByCurrentTeam()->get();
|
||||
$this->servers = currentTeam()->servers;
|
||||
}
|
||||
|
||||
public function cloneTo($destination_id)
|
||||
{
|
||||
$new_destination = StandaloneDocker::find($destination_id);
|
||||
if (!$new_destination) {
|
||||
if (! $new_destination) {
|
||||
$new_destination = SwarmDocker::find($destination_id);
|
||||
}
|
||||
if (!$new_destination) {
|
||||
if (! $new_destination) {
|
||||
return $this->addError('destination_id', 'Destination not found.');
|
||||
}
|
||||
$uuid = (string)new Cuid2(7);
|
||||
$uuid = (string) new Cuid2(7);
|
||||
$server = $new_destination->server;
|
||||
if ($this->resource->getMorphClass() === 'App\Models\Application') {
|
||||
$new_resource = $this->resource->replicate()->fill([
|
||||
'uuid' => $uuid,
|
||||
'name' => $this->resource->name . '-clone-' . $uuid,
|
||||
'name' => $this->resource->name.'-clone-'.$uuid,
|
||||
'fqdn' => generateFqdn($server, $uuid),
|
||||
'status' => 'exited',
|
||||
'destination_id' => $new_destination->id,
|
||||
]);
|
||||
$new_resource->save();
|
||||
if ($new_resource->destination->server->proxyType() !== 'NONE') {
|
||||
$customLabels = str(implode("|", generateLabelsApplication($new_resource)))->replace("|", "\n");
|
||||
$customLabels = str(implode('|', generateLabelsApplication($new_resource)))->replace('|', "\n");
|
||||
$new_resource->custom_labels = base64_encode($customLabels);
|
||||
$new_resource->save();
|
||||
}
|
||||
@@ -60,7 +65,7 @@ class ResourceOperations extends Component
|
||||
$persistentVolumes = $this->resource->persistentStorages()->get();
|
||||
foreach ($persistentVolumes as $volume) {
|
||||
$newPersistentVolume = $volume->replicate()->fill([
|
||||
'name' => $new_resource->uuid . '-' . str($volume->name)->afterLast('-'),
|
||||
'name' => $new_resource->uuid.'-'.str($volume->name)->afterLast('-'),
|
||||
'resource_id' => $new_resource->id,
|
||||
]);
|
||||
$newPersistentVolume->save();
|
||||
@@ -69,9 +74,10 @@ class ResourceOperations extends Component
|
||||
'project_uuid' => $this->projectUuid,
|
||||
'environment_name' => $this->environmentName,
|
||||
'application_uuid' => $new_resource->uuid,
|
||||
]) . "#resource-operations";
|
||||
]).'#resource-operations';
|
||||
|
||||
return redirect()->to($route);
|
||||
} else if (
|
||||
} elseif (
|
||||
$this->resource->getMorphClass() === 'App\Models\StandalonePostgresql' ||
|
||||
$this->resource->getMorphClass() === 'App\Models\StandaloneMongodb' ||
|
||||
$this->resource->getMorphClass() === 'App\Models\StandaloneMysql' ||
|
||||
@@ -81,10 +87,10 @@ class ResourceOperations extends Component
|
||||
$this->resource->getMorphClass() === 'App\Models\StandaloneDragonfly' ||
|
||||
$this->resource->getMorphClass() === 'App\Models\StandaloneClickhouse'
|
||||
) {
|
||||
$uuid = (string)new Cuid2(7);
|
||||
$uuid = (string) new Cuid2(7);
|
||||
$new_resource = $this->resource->replicate()->fill([
|
||||
'uuid' => $uuid,
|
||||
'name' => $this->resource->name . '-clone-' . $uuid,
|
||||
'name' => $this->resource->name.'-clone-'.$uuid,
|
||||
'status' => 'exited',
|
||||
'started_at' => null,
|
||||
'destination_id' => $new_destination->id,
|
||||
@@ -95,29 +101,30 @@ class ResourceOperations extends Component
|
||||
$payload = [];
|
||||
if ($this->resource->type() === 'standalone-postgresql') {
|
||||
$payload['standalone_postgresql_id'] = $new_resource->id;
|
||||
} else if ($this->resource->type() === 'standalone-redis') {
|
||||
} elseif ($this->resource->type() === 'standalone-redis') {
|
||||
$payload['standalone_redis_id'] = $new_resource->id;
|
||||
} else if ($this->resource->type() === 'standalone-mongodb') {
|
||||
} elseif ($this->resource->type() === 'standalone-mongodb') {
|
||||
$payload['standalone_mongodb_id'] = $new_resource->id;
|
||||
} else if ($this->resource->type() === 'standalone-mysql') {
|
||||
} elseif ($this->resource->type() === 'standalone-mysql') {
|
||||
$payload['standalone_mysql_id'] = $new_resource->id;
|
||||
} else if ($this->resource->type() === 'standalone-mariadb') {
|
||||
} elseif ($this->resource->type() === 'standalone-mariadb') {
|
||||
$payload['standalone_mariadb_id'] = $new_resource->id;
|
||||
}
|
||||
$newEnvironmentVariable = $environmentVarible->replicate()->fill($payload);
|
||||
$newEnvironmentVariable = $environmentVarible->replicate()->fill($payload);
|
||||
$newEnvironmentVariable->save();
|
||||
}
|
||||
$route = route('project.database.configuration', [
|
||||
'project_uuid' => $this->projectUuid,
|
||||
'environment_name' => $this->environmentName,
|
||||
'database_uuid' => $new_resource->uuid,
|
||||
]) . "#resource-operations";
|
||||
]).'#resource-operations';
|
||||
|
||||
return redirect()->to($route);
|
||||
} else if ($this->resource->type() === 'service') {
|
||||
$uuid = (string)new Cuid2(7);
|
||||
} elseif ($this->resource->type() === 'service') {
|
||||
$uuid = (string) new Cuid2(7);
|
||||
$new_resource = $this->resource->replicate()->fill([
|
||||
'uuid' => $uuid,
|
||||
'name' => $this->resource->name . '-clone-' . $uuid,
|
||||
'name' => $this->resource->name.'-clone-'.$uuid,
|
||||
'destination_id' => $new_destination->id,
|
||||
]);
|
||||
$new_resource->save();
|
||||
@@ -136,44 +143,50 @@ class ResourceOperations extends Component
|
||||
'project_uuid' => $this->projectUuid,
|
||||
'environment_name' => $this->environmentName,
|
||||
'service_uuid' => $new_resource->uuid,
|
||||
]) . "#resource-operations";
|
||||
]).'#resource-operations';
|
||||
|
||||
return redirect()->to($route);
|
||||
}
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
public function moveTo($environment_id)
|
||||
{
|
||||
try {
|
||||
$new_environment = Environment::findOrFail($environment_id);
|
||||
$this->resource->update([
|
||||
'environment_id' => $environment_id
|
||||
'environment_id' => $environment_id,
|
||||
]);
|
||||
if ($this->resource->type() === 'application') {
|
||||
$route = route('project.application.configuration', [
|
||||
'project_uuid' => $new_environment->project->uuid,
|
||||
'environment_name' => $new_environment->name,
|
||||
'application_uuid' => $this->resource->uuid,
|
||||
]) . "#resource-operations";
|
||||
]).'#resource-operations';
|
||||
|
||||
return redirect()->to($route);
|
||||
} else if (str($this->resource->type())->startsWith('standalone-')) {
|
||||
} elseif (str($this->resource->type())->startsWith('standalone-')) {
|
||||
$route = route('project.database.configuration', [
|
||||
'project_uuid' => $new_environment->project->uuid,
|
||||
'environment_name' => $new_environment->name,
|
||||
'database_uuid' => $this->resource->uuid,
|
||||
]) . "#resource-operations";
|
||||
]).'#resource-operations';
|
||||
|
||||
return redirect()->to($route);
|
||||
} else if ($this->resource->type() === 'service') {
|
||||
} elseif ($this->resource->type() === 'service') {
|
||||
$route = route('project.service.configuration', [
|
||||
'project_uuid' => $new_environment->project->uuid,
|
||||
'environment_name' => $new_environment->name,
|
||||
'service_uuid' => $this->resource->uuid,
|
||||
]) . "#resource-operations";
|
||||
]).'#resource-operations';
|
||||
|
||||
return redirect()->to($route);
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
return handleError($e, $this);
|
||||
}
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.project.shared.resource-operations');
|
||||
|
||||
@@ -8,20 +8,28 @@ use Livewire\Component;
|
||||
class Add extends Component
|
||||
{
|
||||
public $parameters;
|
||||
|
||||
public string $type;
|
||||
|
||||
public Collection $containerNames;
|
||||
|
||||
public string $name;
|
||||
|
||||
public string $command;
|
||||
|
||||
public string $frequency;
|
||||
|
||||
public ?string $container = '';
|
||||
|
||||
protected $listeners = ['clearScheduledTask' => 'clear'];
|
||||
|
||||
protected $rules = [
|
||||
'name' => 'required|string',
|
||||
'command' => 'required|string',
|
||||
'frequency' => 'required|string',
|
||||
'container' => 'nullable|string',
|
||||
];
|
||||
|
||||
protected $validationAttributes = [
|
||||
'name' => 'name',
|
||||
'command' => 'command',
|
||||
@@ -42,8 +50,9 @@ class Add extends Component
|
||||
try {
|
||||
$this->validate();
|
||||
$isValid = validate_cron_expression($this->frequency);
|
||||
if (!$isValid) {
|
||||
if (! $isValid) {
|
||||
$this->dispatch('error', 'Invalid Cron / Human expression.');
|
||||
|
||||
return;
|
||||
}
|
||||
if (empty($this->container) || $this->container == 'null') {
|
||||
|
||||
@@ -9,9 +9,13 @@ use Livewire\Component;
|
||||
class All extends Component
|
||||
{
|
||||
public $resource;
|
||||
|
||||
public Collection $containerNames;
|
||||
|
||||
public ?string $variables = null;
|
||||
|
||||
public array $parameters;
|
||||
|
||||
protected $listeners = ['refreshTasks', 'saveScheduledTask' => 'submit'];
|
||||
|
||||
public function mount()
|
||||
@@ -23,13 +27,14 @@ class All extends Component
|
||||
} elseif ($this->resource->type() == 'application') {
|
||||
if ($this->resource->build_pack === 'dockercompose') {
|
||||
$parsed = $this->resource->parseCompose();
|
||||
$containers = collect(data_get($parsed,'services'))->keys();
|
||||
$containers = collect(data_get($parsed, 'services'))->keys();
|
||||
$this->containerNames = $containers;
|
||||
} else {
|
||||
$this->containerNames = collect([]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function refreshTasks()
|
||||
{
|
||||
$this->resource->refresh();
|
||||
|
||||
@@ -2,17 +2,18 @@
|
||||
|
||||
namespace App\Livewire\Project\Shared\ScheduledTask;
|
||||
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Livewire\Component;
|
||||
|
||||
class Executions extends Component
|
||||
{
|
||||
public $executions = [];
|
||||
|
||||
public $selectedKey;
|
||||
|
||||
public function getListeners()
|
||||
{
|
||||
return [
|
||||
"selectTask",
|
||||
'selectTask',
|
||||
];
|
||||
}
|
||||
|
||||
@@ -20,6 +21,7 @@ class Executions extends Component
|
||||
{
|
||||
if ($key == $this->selectedKey) {
|
||||
$this->selectedKey = null;
|
||||
|
||||
return;
|
||||
}
|
||||
$this->selectedKey = $key;
|
||||
|
||||
@@ -2,18 +2,22 @@
|
||||
|
||||
namespace App\Livewire\Project\Shared\ScheduledTask;
|
||||
|
||||
use App\Models\ScheduledTask as ModelsScheduledTask;
|
||||
use Livewire\Component;
|
||||
use App\Models\Application;
|
||||
use App\Models\ScheduledTask as ModelsScheduledTask;
|
||||
use App\Models\Service;
|
||||
use Livewire\Component;
|
||||
use Visus\Cuid2\Cuid2;
|
||||
|
||||
class Show extends Component
|
||||
{
|
||||
public $parameters;
|
||||
|
||||
public Application|Service $resource;
|
||||
|
||||
public ModelsScheduledTask $task;
|
||||
|
||||
public ?string $modalId = null;
|
||||
|
||||
public string $type;
|
||||
|
||||
protected $rules = [
|
||||
@@ -23,6 +27,7 @@ class Show extends Component
|
||||
'task.frequency' => 'required|string',
|
||||
'task.container' => 'nullable|string',
|
||||
];
|
||||
|
||||
protected $validationAttributes = [
|
||||
'name' => 'name',
|
||||
'command' => 'command',
|
||||
@@ -37,7 +42,7 @@ class Show extends Component
|
||||
if (data_get($this->parameters, 'application_uuid')) {
|
||||
$this->type = 'application';
|
||||
$this->resource = Application::where('uuid', $this->parameters['application_uuid'])->firstOrFail();
|
||||
} else if (data_get($this->parameters, 'service_uuid')) {
|
||||
} elseif (data_get($this->parameters, 'service_uuid')) {
|
||||
$this->type = 'service';
|
||||
$this->resource = Service::where('uuid', $this->parameters['service_uuid'])->firstOrFail();
|
||||
}
|
||||
@@ -53,6 +58,7 @@ class Show extends Component
|
||||
$this->dispatch('success', 'Scheduled task updated.');
|
||||
$this->dispatch('refreshTasks');
|
||||
}
|
||||
|
||||
public function submit()
|
||||
{
|
||||
$this->validate();
|
||||
|
||||
@@ -9,15 +9,25 @@ use Livewire\Component;
|
||||
class Add extends Component
|
||||
{
|
||||
public $resource;
|
||||
|
||||
public $uuid;
|
||||
|
||||
public $parameters;
|
||||
|
||||
public $isSwarm = false;
|
||||
|
||||
public string $name;
|
||||
|
||||
public string $mount_path;
|
||||
|
||||
public ?string $host_path = null;
|
||||
|
||||
public string $file_storage_path;
|
||||
|
||||
public ?string $file_storage_content = null;
|
||||
|
||||
public string $file_storage_directory_source;
|
||||
|
||||
public string $file_storage_directory_destination;
|
||||
|
||||
public $rules = [
|
||||
@@ -44,13 +54,13 @@ class Add extends Component
|
||||
|
||||
public function mount()
|
||||
{
|
||||
$this->file_storage_directory_source = application_configuration_dir() . "/{$this->resource->uuid}";
|
||||
$this->file_storage_directory_source = application_configuration_dir()."/{$this->resource->uuid}";
|
||||
$this->uuid = $this->resource->uuid;
|
||||
$this->parameters = get_route_parameters();
|
||||
if (data_get($this->parameters, 'application_uuid')) {
|
||||
$applicationUuid = $this->parameters['application_uuid'];
|
||||
$application = Application::where('uuid', $applicationUuid)->first();
|
||||
if (!$application) {
|
||||
if (! $application) {
|
||||
abort(404);
|
||||
}
|
||||
if ($application->destination->server->isSwarm()) {
|
||||
@@ -59,6 +69,7 @@ class Add extends Component
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function submitFileStorage()
|
||||
{
|
||||
try {
|
||||
@@ -69,7 +80,7 @@ class Add extends Component
|
||||
$this->file_storage_path = trim($this->file_storage_path);
|
||||
$this->file_storage_path = str($this->file_storage_path)->start('/')->value();
|
||||
if ($this->resource->getMorphClass() === 'App\Models\Application') {
|
||||
$fs_path = application_configuration_dir() . '/' . $this->resource->uuid . $this->file_storage_path;
|
||||
$fs_path = application_configuration_dir().'/'.$this->resource->uuid.$this->file_storage_path;
|
||||
}
|
||||
LocalFileVolume::create(
|
||||
[
|
||||
@@ -78,7 +89,7 @@ class Add extends Component
|
||||
'content' => $this->file_storage_content,
|
||||
'is_directory' => false,
|
||||
'resource_id' => $this->resource->id,
|
||||
'resource_type' => get_class($this->resource)
|
||||
'resource_type' => get_class($this->resource),
|
||||
],
|
||||
);
|
||||
$this->dispatch('refresh_storages');
|
||||
@@ -87,6 +98,7 @@ class Add extends Component
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function submitFileStorageDirectory()
|
||||
{
|
||||
try {
|
||||
@@ -104,7 +116,7 @@ class Add extends Component
|
||||
'mount_path' => $this->file_storage_directory_destination,
|
||||
'is_directory' => true,
|
||||
'resource_id' => $this->resource->id,
|
||||
'resource_type' => get_class($this->resource)
|
||||
'resource_type' => get_class($this->resource),
|
||||
],
|
||||
);
|
||||
$this->dispatch('refresh_storages');
|
||||
@@ -113,6 +125,7 @@ class Add extends Component
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function submitPersistentVolume()
|
||||
{
|
||||
try {
|
||||
@@ -121,7 +134,7 @@ class Add extends Component
|
||||
'mount_path' => 'required|string',
|
||||
'host_path' => 'string|nullable',
|
||||
]);
|
||||
$name = $this->uuid . '-' . $this->name;
|
||||
$name = $this->uuid.'-'.$this->name;
|
||||
$this->dispatch('addNewVolume', [
|
||||
'name' => $name,
|
||||
'mount_path' => $this->mount_path,
|
||||
|
||||
@@ -7,5 +7,6 @@ use Livewire\Component;
|
||||
class All extends Component
|
||||
{
|
||||
public $resource;
|
||||
|
||||
protected $listeners = ['refresh_storages' => '$refresh'];
|
||||
}
|
||||
|
||||
@@ -9,10 +9,15 @@ use Visus\Cuid2\Cuid2;
|
||||
class Show extends Component
|
||||
{
|
||||
public LocalPersistentVolume $storage;
|
||||
|
||||
public bool $isReadOnly = false;
|
||||
|
||||
public ?string $modalId = null;
|
||||
|
||||
public bool $isFirst = true;
|
||||
|
||||
public bool $isService = false;
|
||||
|
||||
public ?string $startedAt = null;
|
||||
|
||||
protected $rules = [
|
||||
@@ -20,6 +25,7 @@ class Show extends Component
|
||||
'storage.mount_path' => 'required|string',
|
||||
'storage.host_path' => 'string|nullable',
|
||||
];
|
||||
|
||||
protected $validationAttributes = [
|
||||
'name' => 'name',
|
||||
'mount_path' => 'mount',
|
||||
|
||||
@@ -8,27 +8,35 @@ use Livewire\Component;
|
||||
class Tags extends Component
|
||||
{
|
||||
public $resource = null;
|
||||
|
||||
public ?string $new_tag = null;
|
||||
|
||||
public $tags = [];
|
||||
|
||||
protected $listeners = [
|
||||
'refresh' => '$refresh',
|
||||
];
|
||||
|
||||
protected $rules = [
|
||||
'resource.tags.*.name' => 'required|string|min:2',
|
||||
'new_tag' => 'required|string|min:2'
|
||||
'new_tag' => 'required|string|min:2',
|
||||
];
|
||||
|
||||
protected $validationAttributes = [
|
||||
'new_tag' => 'tag'
|
||||
'new_tag' => 'tag',
|
||||
];
|
||||
|
||||
public function mount()
|
||||
{
|
||||
$this->tags = Tag::ownedByCurrentTeam()->get();
|
||||
}
|
||||
|
||||
public function addTag(string $id, string $name)
|
||||
{
|
||||
try {
|
||||
if ($this->resource->tags()->where('id', $id)->exists()) {
|
||||
$this->dispatch('error', 'Duplicate tags.', "Tag <span class='dark:text-warning'>$name</span> already added.");
|
||||
|
||||
return;
|
||||
}
|
||||
$this->resource->tags()->syncWithoutDetaching($id);
|
||||
@@ -37,13 +45,14 @@ class Tags extends Component
|
||||
return handleError($e, $this);
|
||||
}
|
||||
}
|
||||
|
||||
public function deleteTag(string $id)
|
||||
{
|
||||
try {
|
||||
$this->resource->tags()->detach($id);
|
||||
|
||||
$found_more_tags = Tag::where(['id' => $id, 'team_id' => currentTeam()->id])->first();
|
||||
if ($found_more_tags->applications()->count() == 0 && $found_more_tags->services()->count() == 0){
|
||||
if ($found_more_tags->applications()->count() == 0 && $found_more_tags->services()->count() == 0) {
|
||||
$found_more_tags->delete();
|
||||
}
|
||||
$this->refresh();
|
||||
@@ -51,29 +60,32 @@ class Tags extends Component
|
||||
return handleError($e, $this);
|
||||
}
|
||||
}
|
||||
|
||||
public function refresh()
|
||||
{
|
||||
$this->resource->load(['tags']);
|
||||
$this->tags = Tag::ownedByCurrentTeam()->get();
|
||||
$this->new_tag = null;
|
||||
}
|
||||
|
||||
public function submit()
|
||||
{
|
||||
try {
|
||||
$this->validate([
|
||||
'new_tag' => 'required|string|min:2'
|
||||
'new_tag' => 'required|string|min:2',
|
||||
]);
|
||||
$tags = str($this->new_tag)->trim()->explode(' ');
|
||||
foreach ($tags as $tag) {
|
||||
if ($this->resource->tags()->where('name', $tag)->exists()) {
|
||||
$this->dispatch('error', 'Duplicate tags.', "Tag <span class='dark:text-warning'>$tag</span> already added.");
|
||||
|
||||
continue;
|
||||
}
|
||||
$found = Tag::where(['name' => $tag, 'team_id' => currentTeam()->id])->first();
|
||||
if (!$found) {
|
||||
if (! $found) {
|
||||
$found = Tag::create([
|
||||
'name' => $tag,
|
||||
'team_id' => currentTeam()->id
|
||||
'team_id' => currentTeam()->id,
|
||||
]);
|
||||
}
|
||||
$this->resource->tags()->syncWithoutDetaching($found->id);
|
||||
@@ -83,6 +95,7 @@ class Tags extends Component
|
||||
return handleError($e, $this);
|
||||
}
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.project.shared.tags');
|
||||
|
||||
@@ -7,27 +7,35 @@ use Livewire\Component;
|
||||
class Webhooks extends Component
|
||||
{
|
||||
public $resource;
|
||||
|
||||
public ?string $deploywebhook = null;
|
||||
|
||||
public ?string $githubManualWebhook = null;
|
||||
|
||||
public ?string $gitlabManualWebhook = null;
|
||||
|
||||
public ?string $bitbucketManualWebhook = null;
|
||||
|
||||
public ?string $giteaManualWebhook = null;
|
||||
|
||||
protected $rules = [
|
||||
'resource.manual_webhook_secret_github' => 'nullable|string',
|
||||
'resource.manual_webhook_secret_gitlab' => 'nullable|string',
|
||||
'resource.manual_webhook_secret_bitbucket' => 'nullable|string',
|
||||
'resource.manual_webhook_secret_gitea' => 'nullable|string',
|
||||
];
|
||||
|
||||
public function saveSecret()
|
||||
{
|
||||
try {
|
||||
$this->validate();
|
||||
$this->resource->save();
|
||||
$this->dispatch('success','Secret Saved.');
|
||||
$this->dispatch('success', 'Secret Saved.');
|
||||
} catch (\Exception $e) {
|
||||
return handleError($e, $this);
|
||||
}
|
||||
}
|
||||
|
||||
public function mount()
|
||||
{
|
||||
$this->deploywebhook = generateDeployWebhook($this->resource);
|
||||
@@ -36,6 +44,7 @@ class Webhooks extends Component
|
||||
$this->bitbucketManualWebhook = generateGitManualWebhook($this->resource, 'bitbucket');
|
||||
$this->giteaManualWebhook = generateGitManualWebhook($this->resource, 'gitea');
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.project.shared.webhooks');
|
||||
|
||||
Reference in New Issue
Block a user