Update conditional statements in app.blade.php and navbar.blade.php

This commit is contained in:
Andras Bacsai 2024-03-25 14:44:31 +01:00
parent 995c303f27
commit 2be2a2621e
4 changed files with 340 additions and 366 deletions

View File

@ -15,7 +15,7 @@ class Index extends Component
{
protected $listeners = ['serverInstalled' => 'validateServer'];
public string $state = 'welcome';
public string $currentState = 'welcome';
public ?string $selectedServerType = null;
public ?Collection $privateKeys = null;
@ -66,25 +66,25 @@ uZx9iFkCELtxrh31QJ68AAAAEXNhaWxANzZmZjY2ZDJlMmRkAQIDBA==
$this->remoteServerDescription = 'Created by Coolify';
$this->remoteServerHost = 'coolify-testing-host';
}
if ($this->state === 'create-project') {
$this->getProjects();
}
if ($this->state === 'create-resource') {
$this->selectExistingServer();
$this->selectExistingProject();
}
if ($this->state === 'private-key') {
$this->setServerType('remote');
}
if ($this->state === 'create-server') {
$this->selectExistingPrivateKey();
}
if ($this->state === 'validate-server') {
$this->selectExistingServer();
}
if ($this->state === 'select-existing-server') {
$this->selectExistingServer();
}
// if ($this->currentState === 'create-project') {
// $this->getProjects();
// }
// if ($this->currentState === 'create-resource') {
// $this->selectExistingServer();
// $this->selectExistingProject();
// }
// if ($this->currentState === 'private-key') {
// $this->setServerType('remote');
// }
// if ($this->currentState === 'create-server') {
// $this->selectExistingPrivateKey();
// }
// if ($this->currentState === 'validate-server') {
// $this->selectExistingServer();
// }
// if ($this->currentState === 'select-existing-server') {
// $this->selectExistingServer();
// }
}
public function explanation()
@ -92,7 +92,7 @@ uZx9iFkCELtxrh31QJ68AAAAEXNhaWxANzZmZjY2ZDJlMmRkAQIDBA==
if (isCloud()) {
return $this->setServerType('remote');
}
$this->state = 'select-server-type';
$this->currentState = 'select-server-type';
}
public function restartBoarding()
@ -131,10 +131,10 @@ uZx9iFkCELtxrh31QJ68AAAAEXNhaWxANzZmZjY2ZDJlMmRkAQIDBA==
$this->servers = Server::ownedByCurrentTeam(['name'])->where('id', '!=', 0)->get();
if ($this->servers->count() > 0) {
$this->selectedExistingServer = $this->servers->first()->id;
$this->state = 'select-existing-server';
$this->currentState = 'select-existing-server';
return;
}
$this->state = 'private-key';
$this->currentState = 'private-key';
}
}
public function selectExistingServer()
@ -142,12 +142,12 @@ uZx9iFkCELtxrh31QJ68AAAAEXNhaWxANzZmZjY2ZDJlMmRkAQIDBA==
$this->createdServer = Server::find($this->selectedExistingServer);
if (!$this->createdServer) {
$this->dispatch('error', 'Server is not found.');
$this->state = 'private-key';
$this->currentState = 'private-key';
return;
}
$this->selectedExistingPrivateKey = $this->createdServer->privateKey->id;
$this->serverPublicKey = $this->createdServer->privateKey->publicKey();
$this->state = 'validate-server';
$this->currentState = 'validate-server';
}
public function getProxyType()
{
@ -155,7 +155,7 @@ uZx9iFkCELtxrh31QJ68AAAAEXNhaWxANzZmZjY2ZDJlMmRkAQIDBA==
$this->selectProxy(ProxyTypes::TRAEFIK_V2->value);
// $proxyTypeSet = $this->createdServer->proxy->type;
// if (!$proxyTypeSet) {
// $this->state = 'select-proxy';
// $this->currentState = 'select-proxy';
// return;
// }
$this->getProjects();
@ -168,12 +168,12 @@ uZx9iFkCELtxrh31QJ68AAAAEXNhaWxANzZmZjY2ZDJlMmRkAQIDBA==
}
$this->createdPrivateKey = PrivateKey::find($this->selectedExistingPrivateKey);
$this->privateKey = $this->createdPrivateKey->private_key;
$this->state = 'create-server';
$this->currentState = 'create-server';
}
public function createNewServer()
{
$this->selectedExistingServer = null;
$this->state = 'private-key';
$this->currentState = 'private-key';
}
public function setPrivateKey(string $type)
{
@ -182,7 +182,7 @@ uZx9iFkCELtxrh31QJ68AAAAEXNhaWxANzZmZjY2ZDJlMmRkAQIDBA==
if ($type === 'create') {
$this->createNewPrivateKey();
}
$this->state = 'create-private-key';
$this->currentState = 'create-private-key';
}
public function savePrivateKey()
{
@ -197,7 +197,7 @@ uZx9iFkCELtxrh31QJ68AAAAEXNhaWxANzZmZjY2ZDJlMmRkAQIDBA==
'team_id' => currentTeam()->id
]);
$this->createdPrivateKey->save();
$this->state = 'create-server';
$this->currentState = 'create-server';
}
public function saveServer()
{
@ -226,7 +226,7 @@ uZx9iFkCELtxrh31QJ68AAAAEXNhaWxANzZmZjY2ZDJlMmRkAQIDBA==
$this->createdServer->settings->save();
$this->createdServer->addInitialNetwork();
$this->selectedExistingServer = $this->createdServer->id;
$this->state = 'validate-server';
$this->currentState = 'validate-server';
}
public function installServer()
{
@ -253,7 +253,7 @@ uZx9iFkCELtxrh31QJ68AAAAEXNhaWxANzZmZjY2ZDJlMmRkAQIDBA==
$dockerVersion = instant_remote_process(["docker version|head -2|grep -i version| awk '{print $2}'"], $this->createdServer, true);
$dockerVersion = checkMinimumDockerEngineVersion($dockerVersion);
if (is_null($dockerVersion)) {
$this->state = 'validate-server';
$this->currentState = 'validate-server';
throw new \Exception('Docker not found or old version is installed.');
}
$this->createdServer->settings()->update([
@ -281,12 +281,12 @@ uZx9iFkCELtxrh31QJ68AAAAEXNhaWxANzZmZjY2ZDJlMmRkAQIDBA==
if ($this->projects->count() > 0) {
$this->selectedProject = $this->projects->first()->id;
}
$this->state = 'create-project';
$this->currentState = 'create-project';
}
public function selectExistingProject()
{
$this->createdProject = Project::find($this->selectedProject);
$this->state = 'create-resource';
$this->currentState = 'create-resource';
}
public function createNewProject()
{
@ -294,7 +294,7 @@ uZx9iFkCELtxrh31QJ68AAAAEXNhaWxANzZmZjY2ZDJlMmRkAQIDBA==
'name' => "My first project",
'team_id' => currentTeam()->id
]);
$this->state = 'create-resource';
$this->currentState = 'create-resource';
}
public function showNewResource()
{

View File

@ -12,7 +12,7 @@
<ul role="list" class="flex flex-col flex-1 gap-y-7">
<li class="flex-1 ">
<ul role="list" class="flex flex-col h-full space-y-1.5">
@if (isSubscribed())
@if (isSubscribed() || !isCloud())
<li>
<a title="Dashboard" href="/"
class="{{ request()->is('/') ? 'menu-item-active menu-item' : 'menu-item' }}">
@ -263,7 +263,7 @@
<livewire:help />
</x-modal-input>
</li>
<li >
<li>
<form action="/logout" method="POST">
@csrf
<button title="Logout" type="submit" class="gap-2 mb-6 menu-item">

View File

@ -1,7 +1,7 @@
@extends('layouts.base')
@section('body')
@parent
@if (isSubscribed())
@if (isSubscribed() || !isCloud())
<livewire:layout-popups />
@endif
@auth

View File

@ -1,17 +1,15 @@
@php use App\Enums\ProxyTypes; @endphp
<section class="flex flex-col h-full lg:items-center lg:justify-center">
<div class="flex flex-col items-center justify-center px-6 py-8 mx-auto max-w-7xl lg:py-0">
@if ($state === 'welcome')
@if ($currentState === 'welcome')
<h1 class="text-3xl font-bold lg:text-5xl">Welcome to Coolify</h1>
<p class="py-6 text-base text-center lg:text-xl">Let me help you set up the basics.</p>
<div class="flex justify-center ">
<x-forms.button class="justify-center w-64 box" wire:click="$set('state','explanation')">Get
<x-forms.button class="justify-center w-64 box" wire:click="$set('currentState','explanation')">Get
Started
</x-forms.button>
</div>
@endif
<div>
@if ($state === 'explanation')
@elseif ($currentState === 'explanation')
<x-boarding-step title="What is Coolify?">
<x-slot:question>
Coolify is an all-in-one application to automate tasks on your servers, deploy application with
@ -39,8 +37,7 @@
</x-forms.button>
</x-slot:actions>
</x-boarding-step>
@endif
@if ($state === 'select-server-type')
@elseif ($currentState === 'select-server-type')
<x-boarding-step title="Server">
<x-slot:question>
Do you want to deploy your resources to your <x-highlighted text="Localhost" />
@ -82,10 +79,7 @@
provider.</p>
</x-slot:explanation>
</x-boarding-step>
@endif
</div>
<div>
@if ($state === 'private-key')
@elseif ($currentState === 'private-key')
<x-boarding-step title="SSH Key">
<x-slot:question>
Do you have your own SSH Private Key?
@ -118,10 +112,7 @@
</p>
</x-slot:explanation>
</x-boarding-step>
@endif
</div>
<div>
@if ($state === 'select-existing-server')
@elseif ($currentState === 'select-existing-server')
<x-boarding-step title="Select a server">
<x-slot:question>
There are already servers available for your Team. Do you want to use one of them?
@ -155,8 +146,7 @@
'root' or skip the boarding process and add a new private key manually to Coolify and to the
server.
<x-forms.input readonly id="serverPublicKey"></x-forms.input>
<x-forms.button class="w-64 box" wire:target="validateServer"
wire:click="validateServer">Check
<x-forms.button class="w-64 box" wire:target="validateServer" wire:click="validateServer">Check
again
</x-forms.button>
@endif
@ -169,10 +159,7 @@
</p>
</x-slot:explanation>
</x-boarding-step>
@endif
</div>
<div>
@if ($state === 'create-private-key')
@elseif ($currentState === 'create-private-key')
<x-boarding-step title="Create Private Key">
<x-slot:question>
Please let me know your key details.
@ -183,8 +170,8 @@
label="Name" id="privateKeyName" />
<x-forms.input placeholder="Description, so others will know more about this."
label="Description" id="privateKeyDescription" />
<x-forms.textarea required placeholder="-----BEGIN OPENSSH PRIVATE KEY-----"
label="Private Key" id="privateKey" />
<x-forms.textarea required placeholder="-----BEGIN OPENSSH PRIVATE KEY-----" label="Private Key"
id="privateKey" />
@if ($privateKeyType === 'create')
<x-forms.textarea rows="7" readonly label="Public Key" id="publicKey" />
<span class="font-bold dark:text-warning">ACTION REQUIRED: Copy the 'Public Key' to your
@ -203,10 +190,7 @@
</p>
</x-slot:explanation>
</x-boarding-step>
@endif
</div>
<div>
@if ($state === 'create-server')
@elseif ($currentState === 'create-server')
<x-boarding-step title="Create Server">
<x-slot:question>
Please let me know your server details.
@ -220,13 +204,12 @@
label="Description" id="remoteServerDescription" />
</div>
<div class="flex flex-col gap-2 lg:flex-row ">
<x-forms.input required placeholder="127.0.0.1" label="IP Address"
id="remoteServerHost" />
<x-forms.input required placeholder="127.0.0.1" label="IP Address" id="remoteServerHost" />
<x-forms.input required placeholder="Port number of your server. Default is 22."
label="Port" id="remoteServerPort" />
<x-forms.input required readonly
placeholder="Username to connect to your server. Default is root."
label="Username" id="remoteServerUser" />
placeholder="Username to connect to your server. Default is root." label="Username"
id="remoteServerUser" />
</div>
<div class="lg:w-64">
<x-forms.checkbox
@ -241,10 +224,7 @@
non-root users.</p>
</x-slot:explanation>
</x-boarding-step>
@endif
</div>
<div>
@if ($state === 'validate-server')
@elseif ($currentState === 'validate-server')
<x-boarding-step title="Validate & Configure Server">
<x-slot:question>
I need to validate your server (connection, Docker Engine, etc) and configure if something is
@ -271,10 +251,7 @@
documentation</a>.</p>
</x-slot:explanation>
</x-boarding-step>
@endif
</div>
<div>
@if ($state === 'create-project')
@elseif ($currentState === 'create-project')
<x-boarding-step title="Project">
<x-slot:question>
@if (count($projects) > 0)
@ -309,10 +286,7 @@
staging version of the same application, but grouped separately.</p>
</x-slot:explanation>
</x-boarding-step>
@endif
</div>
<div>
@if ($state === 'create-resource')
@elseif ($currentState === 'create-resource')
<x-boarding-step title="Resources">
<x-slot:question>
Let's go to the new resource page, where you can create your first resource.