Skip to content

Commit

Permalink
UI stuffs
Browse files Browse the repository at this point in the history
  • Loading branch information
andrasbacsai committed Jul 13, 2023
1 parent 3cc1731 commit a0b2868
Show file tree
Hide file tree
Showing 43 changed files with 618 additions and 427 deletions.
3 changes: 3 additions & 0 deletions app/Http/Livewire/Project/Application/Danger.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,17 @@

use App\Models\Application;
use Livewire\Component;
use Visus\Cuid2\Cuid2;

class Danger extends Component
{
public Application $application;
public array $parameters;
public string|null $modalId = null;

public function mount()
{
$this->modalId = new Cuid2(7);
$this->parameters = getRouteParameters();
}
public function delete()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,15 @@ public function mount()
}
public function submit()
{
ray('submitting');
$this->validate();
$this->emitUp('submit', [
'key' => $this->key,
'value' => $this->value,
'is_build_time' => $this->is_build_time,
'is_preview' => $this->is_preview,
]);
$this->clear();
}
public function clear()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,29 @@
use App\Models\Application;
use App\Models\EnvironmentVariable;
use Livewire\Component;
use Visus\Cuid2\Cuid2;

class All extends Component
{
public Application $application;
public string|null $modalId = null;
protected $listeners = ['refreshEnvs', 'submit'];
public function mount()
{
$this->modalId = new Cuid2(7);
}
public function refreshEnvs()
{
$this->application->refresh();
}
public function submit($data)
{
try {
$found = $this->application->environment_variables()->where('key', $data['key'])->first();
if ($found) {
$this->emit('error', 'Environment variable already exists.');
return;
}
EnvironmentVariable::create([
'key' => $data['key'],
'value' => $data['value'],
Expand All @@ -27,7 +38,6 @@ public function submit($data)
$this->application->refresh();

$this->emit('success', 'Environment variable added successfully.');
$this->emit('clearAddEnv');
} catch (\Exception $e) {
return general_error_handler(err: $e, that: $this);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@

use App\Models\EnvironmentVariable as ModelsEnvironmentVariable;
use Livewire\Component;
use Visus\Cuid2\Cuid2;

class Show extends Component
{
public $parameters;
public ModelsEnvironmentVariable $env;

public string|null $modalId = null;
protected $rules = [
'env.key' => 'required|string',
'env.value' => 'required|string',
Expand All @@ -22,6 +23,7 @@ class Show extends Component
];
public function mount()
{
$this->modalId = new Cuid2(7);
$this->parameters = getRouteParameters();
}
public function submit()
Expand Down
6 changes: 6 additions & 0 deletions app/Http/Livewire/Project/Application/Storages/Show.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
namespace App\Http\Livewire\Project\Application\Storages;

use Livewire\Component;
use Visus\Cuid2\Cuid2;

class Show extends Component
{
public $storage;
public string|null $modalId = null;
protected $rules = [
'storage.name' => 'required|string',
'storage.mount_path' => 'required|string',
Expand All @@ -17,6 +19,10 @@ class Show extends Component
'mount_path' => 'mount',
'host_path' => 'host',
];
public function mount()
{
$this->modalId = new Cuid2(7);
}
public function submit()
{
$this->validate();
Expand Down
5 changes: 4 additions & 1 deletion app/Http/Livewire/Server/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use App\Actions\Server\InstallDocker;
use App\Models\Server;
use Livewire\Component;
use Visus\Cuid2\Cuid2;

class Form extends Component
{
Expand All @@ -13,6 +14,7 @@ class Form extends Component
public $dockerVersion;
public string|null $wildcard_domain = null;
public int $cleanup_after_percentage;
public string|null $modalId = null;

protected $rules = [
'server.name' => 'required|min:6',
Expand All @@ -35,6 +37,7 @@ class Form extends Component
];
public function mount()
{
$this->modalId = new Cuid2(7);
$this->wildcard_domain = $this->server->settings->wildcard_domain;
$this->cleanup_after_percentage = $this->server->settings->cleanup_after_percentage;
}
Expand Down Expand Up @@ -98,4 +101,4 @@ public function submit()
$this->server->save();
$this->emit('success', 'Server updated successfully.');
}
}
}
30 changes: 30 additions & 0 deletions app/View/Components/Forms/Button.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

namespace App\View\Components\Forms;

use Closure;
use Illuminate\Contracts\View\View;
use Illuminate\View\Component;

class Button extends Component
{
/**
* Create a new component instance.
*/
public function __construct(
public bool $disabled = false,
public bool $isModal = false,
public string|null $modalId = null,
public string $defaultClass = "btn btn-primary btn-xs text-white normal-case no-animation rounded border-none"
) {
//
}

/**
* Get the view / contents that represent the component.
*/
public function render(): View|Closure|string
{
return view('components.forms.button');
}
}
34 changes: 34 additions & 0 deletions app/View/Components/Forms/Checkbox.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

namespace App\View\Components\Forms;

use Closure;
use Illuminate\Contracts\View\View;
use Illuminate\View\Component;

class Checkbox extends Component
{
/**
* Create a new component instance.
*/
public function __construct(
public string|null $id = null,
public string|null $name = null,
public string|null $value = null,
public string|null $label = null,
public string|null $helper = null,
public bool $instantSave = false,
public bool $disabled = false,
public string $defaultClass = "toggle toggle-xs toggle-warning rounded disabled:bg-coolgray-200 disabled:opacity-50 placeholder:text-neutral-700"
) {
//
}

/**
* Get the view / contents that represent the component.
*/
public function render(): View|Closure|string
{
return view('components.forms.checkbox');
}
}
4 changes: 2 additions & 2 deletions app/View/Components/Forms/Input.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ public function __construct(
public bool $disabled = false,
public bool $readonly = false,
public string|null $helper = null,
public bool $noDirty = false,
public bool $cannotPeakPassword = false,
public bool $allowToPeak = true,
public string $defaultClass = "input input-sm bg-coolgray-200 rounded text-white w-full disabled:bg-coolgray-200/50 disabled:border-none"
) {
}

Expand Down
38 changes: 38 additions & 0 deletions app/View/Components/Forms/Select.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

namespace App\View\Components\Forms;

use Closure;
use Illuminate\Contracts\View\View;
use Illuminate\View\Component;
use Visus\Cuid2\Cuid2;
use Illuminate\Support\Str;

class Select extends Component
{
/**
* Create a new component instance.
*/
public function __construct(
public string|null $id = null,
public string|null $name = null,
public string|null $label = null,
public string|null $helper = null,
public bool $required = false,
public string $defaultClass = "select select-sm w-full rounded text-white text-sm bg-coolgray-200 font-normal"
) {
//
}

/**
* Get the view / contents that represent the component.
*/
public function render(): View|Closure|string
{
if (is_null($this->id)) $this->id = new Cuid2(7);
if (is_null($this->name)) $this->name = $this->id;

$this->label = Str::title($this->label);
return view('components.forms.select');
}
}
43 changes: 43 additions & 0 deletions app/View/Components/Forms/Textarea.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

namespace App\View\Components\Forms;

use Closure;
use Illuminate\Contracts\View\View;
use Illuminate\View\Component;
use Visus\Cuid2\Cuid2;
use Illuminate\Support\Str;

class Textarea extends Component
{
/**
* Create a new component instance.
*/
public function __construct(
public string|null $id = null,
public string|null $name = null,
public string|null $type = 'text',
public string|null $value = null,
public string|null $label = null,
public string|null $placeholder = null,
public bool $required = false,
public bool $disabled = false,
public bool $readonly = false,
public string|null $helper = null,
public string $defaultClass = "textarea bg-coolgray-200 rounded text-white scrollbar disabled:bg-coolgray-200/50 disabled:border-none"
) {
//
}

/**
* Get the view / contents that represent the component.
*/
public function render(): View|Closure|string
{
if (is_null($this->id)) $this->id = new Cuid2(7);
if (is_null($this->name)) $this->name = $this->id;

$this->label = Str::title($this->label);
return view('components.forms.textarea');
}
}
33 changes: 33 additions & 0 deletions app/View/Components/Modal.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

namespace App\View\Components;

use Closure;
use Illuminate\Contracts\View\View;
use Illuminate\View\Component;
use Visus\Cuid2\Cuid2;

class Modal extends Component
{
/**
* Create a new component instance.
*/
public function __construct(
public string $modalId,
public string $modalTitle,
public string|null $modalBody = null,
public string|null $modalSubmit = null,
public bool $yesOrNo = false,
public string $action = 'delete'
) {
//
}

/**
* Get the view / contents that represent the component.
*/
public function render(): View|Closure|string
{
return view('components.modal');
}
}
15 changes: 8 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"dependencies": {
"@tailwindcss/typography": "0.5.9",
"alpinejs": "3.12.2",
"daisyui": "3.0.3",
"daisyui": "3.2.1",
"tailwindcss-scrollbar": "0.1.0"
}
}
Loading

0 comments on commit a0b2868

Please sign in to comment.