Skip to content

Commit

Permalink
sprinkle some css
Browse files Browse the repository at this point in the history
  • Loading branch information
andrasbacsai committed May 12, 2023
1 parent 0731b1f commit d6dc540
Show file tree
Hide file tree
Showing 21 changed files with 282 additions and 172 deletions.
2 changes: 0 additions & 2 deletions app/Http/Livewire/CheckUpdate.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

namespace App\Http\Livewire;

use App\Models\Server;
use Illuminate\Support\Facades\Http;
use Livewire\Component;

class CheckUpdate extends Component
Expand Down
4 changes: 3 additions & 1 deletion app/Http/Livewire/Destination/New/StandaloneDocker.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ public function mount()
if (request()->query('server_id')) {
$this->server_id = request()->query('server_id');
} else {
$this->server_id = Server::validated()->first()->id;
if ($this->servers->count() > 0) {
$this->server_id = $this->servers->first()->id;
}
}
}
$this->network = new Cuid2(7);
Expand Down
19 changes: 9 additions & 10 deletions app/Http/Livewire/PrivateKey/Create.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@
namespace App\Http\Livewire\PrivateKey;

use App\Models\PrivateKey;
use Illuminate\Routing\Route as RoutingRoute;
use Illuminate\Support\Facades\Route;
use Livewire\Component;

class Create extends Component
{
public $private_key_value;
public $private_key_name;
public $private_key_description;
public string $name;
public string|null $description;
public string $value;
public string $currentRoute;

public function mount()
Expand All @@ -20,14 +19,14 @@ public function mount()
}
public function createPrivateKey()
{
$this->private_key_value = trim($this->private_key_value);
if (!str_ends_with($this->private_key_value, "\n")) {
$this->private_key_value .= "\n";
$this->value = trim($this->value);
if (!str_ends_with($this->value, "\n")) {
$this->value .= "\n";
}
$new_private_key = PrivateKey::create([
'name' => $this->private_key_name,
'description' => $this->private_key_description,
'private_key' => $this->private_key_value,
'name' => $this->name,
'description' => $this->description,
'private_key' => $this->value,
'team_id' => session('currentTeam')->id
]);
session('currentTeam')->privateKeys = PrivateKey::where('team_id', session('currentTeam')->id)->get();
Expand Down
18 changes: 11 additions & 7 deletions app/Http/Livewire/RunCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,28 @@

class RunCommand extends Component
{
public $command;
public string $command;
public $server;
public $servers = [];

protected $rules = [
'server' => 'required',
'command' => 'required',
];
public function mount()
public function mount($servers)
{
$this->servers = Server::where('team_id', session('currentTeam')->id)->get();
$this->server = $this->servers[0]->uuid;
$this->servers = $servers;
$this->server = $servers[0]->uuid;
}

public function runCommand()
{
$this->validate();
$activity = remoteProcess([$this->command], Server::where('uuid', $this->server)->first(), ActivityTypes::INLINE->value);
$this->emit('newMonitorActivity', $activity->id);
try {
$this->validate();
$activity = remoteProcess([$this->command], Server::where('uuid', $this->server)->first(), ActivityTypes::INLINE->value);
$this->emit('newMonitorActivity', $activity->id);
} catch (\Exception $e) {
return generalErrorHandler($e);
}
}
}
40 changes: 25 additions & 15 deletions app/Http/Livewire/Server/New/ByIp.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
class ByIp extends Component
{
public $private_keys;
public int $private_key_id;
public int|null $private_key_id = null;
public $new_private_key_name;
public $new_private_key_description;
public $new_private_key_value;
Expand All @@ -20,30 +20,40 @@ class ByIp extends Component
public string $user = 'root';
public int $port = 22;

protected $rules = [
'name' => 'required',
'ip' => 'required',
'user' => 'required',
'port' => 'required|integer',
];
public function mount()
{
$this->name = generateRandomName();
$this->private_keys = PrivateKey::where('team_id', session('currentTeam')->id)->get();
}
public function setPrivateKey($private_key_id)
public function setPrivateKey(string $private_key_id)
{
$this->private_key_id = $private_key_id;
}
public function submit()
{
if (!$this->private_key_id) {
$this->addError('private_key_id', 'The private key field is required.');
return;
try {
if (!$this->private_key_id) {
return $this->emit('error', 'You must select a private key');
}
$this->validate();
$server = Server::create([
'name' => $this->name,
'description' => $this->description,
'ip' => $this->ip,
'user' => $this->user,
'port' => $this->port,
'team_id' => session('currentTeam')->id,
'private_key_id' => $this->private_key_id
]);
return redirect()->route('server.show', $server->uuid);
} catch (\Exception $e) {
return generalErrorHandler($e);
}
$server = Server::create([
'name' => $this->name,
'description' => $this->description,
'ip' => $this->ip,
'user' => $this->user,
'port' => $this->port,
'team_id' => session('currentTeam')->id,
'private_key_id' => $this->private_key_id
]);
return redirect()->route('server.show', $server->uuid);
}
}
2 changes: 1 addition & 1 deletion bootstrap/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function generalErrorHandler(\Throwable $e, $that = null, $isJson = false)
'error' => $error->getMessage(),
]);
} else {
dump('Duplicate entry found.');
dump($error);
}
}
}
Expand Down
29 changes: 18 additions & 11 deletions resources/css/app.css
Original file line number Diff line number Diff line change
@@ -1,39 +1,46 @@
/* @tailwind base; */
@tailwind base;
@tailwind components;
@tailwind utilities;

body {
@apply bg-neutral-900 text-white font-sans;
}
a, a:visited {
@apply text-neutral-300 hover:text-purple-500;
@apply bg-coolgray-100 text-white font-sans;
}

input, textarea {
@apply border-none p-2 bg-neutral-800 text-white disabled:text-neutral-600 read-only:text-neutral-600 read-only:select-none
@apply border-none p-2 bg-coolgray-200 text-white disabled:text-neutral-600 read-only:text-neutral-600 read-only:select-none outline-none ;
}
select {
@apply border-none p-2 bg-neutral-800 text-white disabled:text-neutral-600 read-only:select-none
@apply border-none p-2 bg-coolgray-200 text-white disabled:text-neutral-600 read-only:select-none outline-none;
}

button {
@apply border-none px-2 p-1 cursor-pointer;
}
.main-menu {
@apply relative float-left ;
@apply relative float-left;
}
.main-menu:after {
content: '/';
@apply absolute right-0 top-0 text-neutral-400 px-2 pt-1;
@apply absolute right-0 top-0 text-neutral-400 px-2 pt-[0.3rem];
}
.magic-input {
@apply w-96 rounded shadow outline-none focus:bg-neutral-700;
@apply w-[25rem] rounded shadow outline-none focus:bg-neutral-700 text-white;
}
.magic-items {
@apply text-xs absolute top-11 w-[25rem] bg-neutral-800;
@apply absolute top-14 w-[25rem] bg-coolgray-200 border-b-2 border-r-2 border-l-2 border-solid border-coolgray-100 rounded-b;
}
.magic-item {
@apply m-2 py-2 pl-4 cursor-pointer hover:bg-neutral-700 text-neutral-300 hover:text-white;
}
.magic-item-focused {
@apply bg-neutral-700 text-white;
}
h1 {
@apply text-3xl font-bold py-4;
}
h2 {
@apply text-xl font-bold py-4;
}
.box {
@apply flex items-center justify-center text-sm rounded cursor-pointer h-14 bg-coolgray-200 hover:bg-coollabs p-2;
}
2 changes: 1 addition & 1 deletion resources/views/command-center.blade.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<x-layout>
<livewire:run-command />
<livewire:run-command :servers="$servers" />
</x-layout>
8 changes: 4 additions & 4 deletions resources/views/components/inputs/button.blade.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
@props([
'isWarning' => null,
'disabled' => null,
'defaultClass' => 'text-white bg-neutral-800 hover:bg-violet-600 h-8',
'defaultWarningClass' => 'text-white bg-red-500 hover:bg-red-600 h-8',
'disabledClass' => 'text-neutral-400 bg-neutral-900 h-8',
'loadingClass' => 'text-black bg-green-500 h-8',
'defaultClass' => 'text-white hover:bg-coollabs h-8 rounded transition-colors',
'defaultWarningClass' => 'text-white bg-red-500 hover:bg-red-600 h-8 rounded',
'disabledClass' => 'text-coolgray-200 h-8 rounded',
'loadingClass' => 'text-black bg-green-500 h-8 rounded',
'confirm' => null,
'confirmAction' => null,
])
Expand Down
7 changes: 5 additions & 2 deletions resources/views/components/inputs/input.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
'instantSave' => $attributes->has('instantSave'),
'noLabel' => $attributes->has('noLabel'),
'noDirty' => $attributes->has('noDirty'),
'hidden' => $attributes->has('hidden'),
])

<span @class([
Expand All @@ -14,7 +15,7 @@
])>
@if (!$noLabel)
<label for={{ $id }} @if (!$noDirty) wire:dirty.class="text-amber-300" @endif
wire:target={{ $id }}>
@if ($hidden) class="hidden" @endif wire:target={{ $id }}>
@if ($label)
{{ $label }}
@else
Expand All @@ -23,6 +24,7 @@
@if ($required)
*
@endif

</label>
@endif
@if ($type === 'textarea')
Expand All @@ -32,7 +34,8 @@
<input {{ $attributes }} @if ($required) required @endif
@if (!$noDirty) wire:dirty.class="text-black bg-amber-300" @endif
type={{ $type }} id={{ $id }} name={{ $id }}
@if ($instantSave) wire:click='instantSave' wire:model.defer={{ $id }} @else wire:model.defer={{ $value ?? $id }} @endif />
@if ($instantSave) wire:click='instantSave' wire:model.defer={{ $id }} @else wire:model.defer={{ $value ?? $id }} @endif
@if ($hidden) class="hidden" @endif />
@endif
@error($id)
<div class="text-red-500">{{ $message }}</div>
Expand Down
4 changes: 3 additions & 1 deletion resources/views/components/layout.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="preconnect" href="https://api.fonts.coollabs.io" crossorigin>
<link href="https://api.fonts.coollabs.io/css2?family=Inter&display=swap" rel="stylesheet">
@env('local')
<title>Coolify - localhost</title>
@endenv
Expand All @@ -28,7 +30,7 @@ class="fixed text-xs cursor-pointer left-2 bottom-1 opacity-20 hover:opacity-100
@auth
<x-navbar />
@endauth
<main>
<main class="max-w-6xl pt-10 mx-auto">
{{ $slot }}
</main>

Expand Down
Loading

0 comments on commit d6dc540

Please sign in to comment.