mirror of
https://github.com/vitodeploy/vito.git
synced 2025-04-19 09:51:37 +00:00
adding Projects feature (#85)
This commit is contained in:
parent
fd2244d382
commit
10a6bb57a8
36
app/Actions/Projects/CreateProject.php
Normal file
36
app/Actions/Projects/CreateProject.php
Normal file
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions\Projects;
|
||||
|
||||
use App\Models\Project;
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
|
||||
class CreateProject
|
||||
{
|
||||
public function create(User $user, array $input): Project
|
||||
{
|
||||
$this->validate($user, $input);
|
||||
|
||||
$project = new Project([
|
||||
'user_id' => $user->id,
|
||||
'name' => $input['name'],
|
||||
]);
|
||||
|
||||
$project->save();
|
||||
|
||||
return $project;
|
||||
}
|
||||
|
||||
private function validate(User $user, array $input): void
|
||||
{
|
||||
Validator::make($input, [
|
||||
'name' => [
|
||||
'required',
|
||||
'string',
|
||||
'max:255',
|
||||
'unique:projects,name,NULL,id,user_id,'.$user->id,
|
||||
],
|
||||
])->validate();
|
||||
}
|
||||
}
|
31
app/Actions/Projects/DeleteProject.php
Normal file
31
app/Actions/Projects/DeleteProject.php
Normal file
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions\Projects;
|
||||
|
||||
use App\Models\Project;
|
||||
use App\Models\User;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
|
||||
class DeleteProject
|
||||
{
|
||||
public function delete(User $user, int $projectId): void
|
||||
{
|
||||
/** @var Project $project */
|
||||
$project = $user->projects()->findOrFail($projectId);
|
||||
|
||||
if ($user->projects()->count() === 1) {
|
||||
throw ValidationException::withMessages([
|
||||
'project' => __('Cannot delete the last project.'),
|
||||
]);
|
||||
}
|
||||
|
||||
if ($user->current_project_id == $project->id) {
|
||||
/** @var Project $randomProject */
|
||||
$randomProject = $user->projects()->where('id', '!=', $project->id)->first();
|
||||
$user->current_project_id = $randomProject->id;
|
||||
$user->save();
|
||||
}
|
||||
|
||||
$project->delete();
|
||||
}
|
||||
}
|
33
app/Actions/Projects/UpdateProject.php
Normal file
33
app/Actions/Projects/UpdateProject.php
Normal file
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions\Projects;
|
||||
|
||||
use App\Models\Project;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class UpdateProject
|
||||
{
|
||||
public function update(Project $project, array $input): Project
|
||||
{
|
||||
$this->validate($project, $input);
|
||||
|
||||
$project->name = $input['name'];
|
||||
|
||||
$project->save();
|
||||
|
||||
return $project;
|
||||
}
|
||||
|
||||
private function validate(Project $project, array $input): void
|
||||
{
|
||||
Validator::make($input, [
|
||||
'name' => [
|
||||
'required',
|
||||
'string',
|
||||
'max:255',
|
||||
Rule::unique('projects')->ignore($project->id),
|
||||
],
|
||||
])->validate();
|
||||
}
|
||||
}
|
@ -26,6 +26,7 @@ public function create(User $creator, array $input): Server
|
||||
$this->validateInputs($input);
|
||||
|
||||
$server = new Server([
|
||||
'project_id' => $creator->currentProject->id,
|
||||
'user_id' => $creator->id,
|
||||
'name' => $input['name'],
|
||||
'ssh_user' => config('core.server_providers_default_user')[$input['provider']][$input['os']],
|
||||
|
29
app/Http/Controllers/ProjectController.php
Normal file
29
app/Http/Controllers/ProjectController.php
Normal file
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Project;
|
||||
use App\Models\User;
|
||||
use Illuminate\Contracts\View\View;
|
||||
|
||||
class ProjectController extends Controller
|
||||
{
|
||||
public function index(): View
|
||||
{
|
||||
return view('projects.index');
|
||||
}
|
||||
|
||||
public function switch($projectId)
|
||||
{
|
||||
/** @var User $user */
|
||||
$user = auth()->user();
|
||||
|
||||
/** @var Project $project */
|
||||
$project = $user->projects()->findOrFail($projectId);
|
||||
|
||||
$user->current_project_id = $project->id;
|
||||
$user->save();
|
||||
|
||||
return redirect()->route('servers');
|
||||
}
|
||||
}
|
37
app/Http/Livewire/Projects/CreateProject.php
Normal file
37
app/Http/Livewire/Projects/CreateProject.php
Normal file
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire\Projects;
|
||||
|
||||
use App\Traits\HasToast;
|
||||
use App\Traits\RefreshComponentOnBroadcast;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Livewire\Component;
|
||||
|
||||
class CreateProject extends Component
|
||||
{
|
||||
use HasToast;
|
||||
use RefreshComponentOnBroadcast;
|
||||
|
||||
public bool $open = false;
|
||||
|
||||
public array $inputs = [];
|
||||
|
||||
public function create(): void
|
||||
{
|
||||
app(\App\Actions\Projects\CreateProject::class)
|
||||
->create(auth()->user(), $this->inputs);
|
||||
|
||||
$this->emitTo(ProjectsList::class, '$refresh');
|
||||
|
||||
$this->dispatchBrowserEvent('created', true);
|
||||
}
|
||||
|
||||
public function render(): View
|
||||
{
|
||||
if (request()->query('create')) {
|
||||
$this->open = true;
|
||||
}
|
||||
|
||||
return view('livewire.projects.create-project');
|
||||
}
|
||||
}
|
37
app/Http/Livewire/Projects/EditProject.php
Normal file
37
app/Http/Livewire/Projects/EditProject.php
Normal file
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire\Projects;
|
||||
|
||||
use App\Actions\Projects\UpdateProject;
|
||||
use App\Models\Project;
|
||||
use App\Traits\RefreshComponentOnBroadcast;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Livewire\Component;
|
||||
|
||||
class EditProject extends Component
|
||||
{
|
||||
use RefreshComponentOnBroadcast;
|
||||
|
||||
public Project $project;
|
||||
|
||||
public array $inputs = [];
|
||||
|
||||
public function save(): void
|
||||
{
|
||||
app(UpdateProject::class)->update($this->project, $this->inputs);
|
||||
|
||||
$this->redirect(route('projects'));
|
||||
}
|
||||
|
||||
public function mount(): void
|
||||
{
|
||||
$this->inputs = [
|
||||
'name' => $this->project->name,
|
||||
];
|
||||
}
|
||||
|
||||
public function render(): View
|
||||
{
|
||||
return view('livewire.projects.edit-project');
|
||||
}
|
||||
}
|
42
app/Http/Livewire/Projects/ProjectsList.php
Normal file
42
app/Http/Livewire/Projects/ProjectsList.php
Normal file
@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire\Projects;
|
||||
|
||||
use App\Actions\Projects\DeleteProject;
|
||||
use App\Traits\HasToast;
|
||||
use App\Traits\RefreshComponentOnBroadcast;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
use Livewire\Component;
|
||||
|
||||
class ProjectsList extends Component
|
||||
{
|
||||
use HasToast;
|
||||
use RefreshComponentOnBroadcast;
|
||||
|
||||
protected $listeners = [
|
||||
'$refresh',
|
||||
];
|
||||
|
||||
public int $deleteId;
|
||||
|
||||
public function delete(): void
|
||||
{
|
||||
try {
|
||||
app(DeleteProject::class)->delete(auth()->user(), $this->deleteId);
|
||||
|
||||
$this->redirect(route('projects'));
|
||||
|
||||
return;
|
||||
} catch (ValidationException $e) {
|
||||
$this->toast()->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function render(): View
|
||||
{
|
||||
return view('livewire.projects.projects-list', [
|
||||
'projects' => auth()->user()->projects()->orderByDesc('id')->get(),
|
||||
]);
|
||||
}
|
||||
}
|
@ -2,7 +2,7 @@
|
||||
|
||||
namespace App\Http\Livewire\Servers;
|
||||
|
||||
use App\Models\Server;
|
||||
use App\Models\User;
|
||||
use App\Traits\RefreshComponentOnBroadcast;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Livewire\Component;
|
||||
@ -13,8 +13,12 @@ class ServersList extends Component
|
||||
|
||||
public function render(): View
|
||||
{
|
||||
/** @var User $user */
|
||||
$user = auth()->user();
|
||||
$servers = $user->currentProject->servers()->orderByDesc('created_at')->get();
|
||||
|
||||
return view('livewire.servers.servers-list', [
|
||||
'servers' => Server::all(),
|
||||
'servers' => $servers,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
56
app/Models/Project.php
Normal file
56
app/Models/Project.php
Normal file
@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
/**
|
||||
* @property int $id
|
||||
* @property int $user_id
|
||||
* @property string $name
|
||||
* @property Carbon $created_at
|
||||
* @property Carbon $updated_at
|
||||
* @property User $user
|
||||
* @property Collection<Server> $servers
|
||||
* @property Collection<NotificationChannel> $notificationChannels
|
||||
*/
|
||||
class Project extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'user_id',
|
||||
'name',
|
||||
];
|
||||
|
||||
public static function boot(): void
|
||||
{
|
||||
parent::boot();
|
||||
|
||||
static::deleting(function (Project $project) {
|
||||
$project->servers()->each(function (Server $server) {
|
||||
$server->delete();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
public function servers(): HasMany
|
||||
{
|
||||
return $this->hasMany(Server::class);
|
||||
}
|
||||
|
||||
public function notificationChannels(): HasMany
|
||||
{
|
||||
return $this->hasMany(NotificationChannel::class);
|
||||
}
|
||||
}
|
@ -18,6 +18,7 @@
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* @property int $project_id
|
||||
* @property int $user_id
|
||||
* @property string $name
|
||||
* @property string $ssh_user
|
||||
@ -38,6 +39,7 @@
|
||||
* @property int $security_updates
|
||||
* @property int $progress
|
||||
* @property string $progress_step
|
||||
* @property Project $project
|
||||
* @property User $creator
|
||||
* @property ServerProvider $serverProvider
|
||||
* @property ServerLog[] $logs
|
||||
@ -59,6 +61,7 @@ class Server extends AbstractModel
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'project_id',
|
||||
'user_id',
|
||||
'name',
|
||||
'ssh_user',
|
||||
@ -82,6 +85,7 @@ class Server extends AbstractModel
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'project_id' => 'integer',
|
||||
'user_id' => 'integer',
|
||||
'type_data' => 'json',
|
||||
'port' => 'integer',
|
||||
@ -125,6 +129,11 @@ public static function boot(): void
|
||||
});
|
||||
}
|
||||
|
||||
public function project(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Project::class, 'project_id');
|
||||
}
|
||||
|
||||
public function creator(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'user_id');
|
||||
|
@ -28,6 +28,9 @@
|
||||
* @property Collection $tokens
|
||||
* @property string $profile_photo_url
|
||||
* @property string $timezone
|
||||
* @property int $current_project_id
|
||||
* @property Project $currentProject
|
||||
* @property Collection<Project> $projects
|
||||
*/
|
||||
class User extends Authenticatable
|
||||
{
|
||||
@ -41,6 +44,7 @@ class User extends Authenticatable
|
||||
'email',
|
||||
'password',
|
||||
'timezone',
|
||||
'current_project_id',
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
@ -53,6 +57,20 @@ class User extends Authenticatable
|
||||
protected $appends = [
|
||||
];
|
||||
|
||||
public static function boot(): void
|
||||
{
|
||||
parent::boot();
|
||||
|
||||
static::created(function (User $user) {
|
||||
$user->createDefaultProject();
|
||||
});
|
||||
}
|
||||
|
||||
public function servers(): HasMany
|
||||
{
|
||||
return $this->hasMany(Server::class);
|
||||
}
|
||||
|
||||
public function sshKeys(): HasMany
|
||||
{
|
||||
return $this->hasMany(SshKey::class);
|
||||
@ -105,4 +123,36 @@ public function connectedSourceControls(): array
|
||||
|
||||
return $connectedSourceControls;
|
||||
}
|
||||
|
||||
public function projects(): HasMany
|
||||
{
|
||||
return $this->hasMany(Project::class);
|
||||
}
|
||||
|
||||
public function currentProject(): HasOne
|
||||
{
|
||||
return $this->HasOne(Project::class, 'id', 'current_project_id');
|
||||
}
|
||||
|
||||
public function isMemberOfProject(Project $project): bool
|
||||
{
|
||||
return $project->user_id === $this->id;
|
||||
}
|
||||
|
||||
public function createDefaultProject(): Project
|
||||
{
|
||||
$project = $this->projects()->first();
|
||||
|
||||
if (! $project) {
|
||||
$project = new Project();
|
||||
$project->user_id = $this->id;
|
||||
$project->name = 'Default';
|
||||
$project->save();
|
||||
}
|
||||
|
||||
$this->current_project_id = $project->id;
|
||||
$this->save();
|
||||
|
||||
return $project;
|
||||
}
|
||||
}
|
||||
|
25
database/factories/ProjectFactory.php
Normal file
25
database/factories/ProjectFactory.php
Normal file
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Project;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Carbon;
|
||||
|
||||
/**
|
||||
* @extends Factory<Project>
|
||||
*/
|
||||
class ProjectFactory extends Factory
|
||||
{
|
||||
protected $model = Project::class;
|
||||
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'user_id' => $this->faker->randomNumber(),
|
||||
'name' => $this->faker->name(),
|
||||
'created_at' => Carbon::now(),
|
||||
'updated_at' => Carbon::now(),
|
||||
];
|
||||
}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('projects', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->bigInteger('user_id');
|
||||
$table->string('name');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('projects');
|
||||
}
|
||||
};
|
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('servers', function (Blueprint $table) {
|
||||
$table->unsignedBigInteger('project_id')->nullable()->after('id');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('servers', function (Blueprint $table) {
|
||||
$table->dropColumn('project_id');
|
||||
});
|
||||
}
|
||||
};
|
27
database/migrations/2024_01_01_235900_update_users_table.php
Normal file
27
database/migrations/2024_01_01_235900_update_users_table.php
Normal file
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->unsignedBigInteger('current_project_id')->nullable()->after('timezone');
|
||||
});
|
||||
User::query()->each(function (User $user) {
|
||||
$project = $user->createDefaultProject();
|
||||
$user->servers()->update(['project_id' => $project->id]);
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->dropColumn('current_project_id');
|
||||
});
|
||||
}
|
||||
};
|
@ -22,6 +22,7 @@ public function run(): void
|
||||
]);
|
||||
$server = Server::factory()->create([
|
||||
'user_id' => $user->id,
|
||||
'project_id' => $user->currentProject->id,
|
||||
]);
|
||||
$server->services()->create([
|
||||
'type' => 'database',
|
||||
|
File diff suppressed because one or more lines are too long
1
public/build/assets/app-f482c864.css
Normal file
1
public/build/assets/app-f482c864.css
Normal file
File diff suppressed because one or more lines are too long
@ -1,6 +1,6 @@
|
||||
{
|
||||
"resources/css/app.css": {
|
||||
"file": "assets/app-328222da.css",
|
||||
"file": "assets/app-f482c864.css",
|
||||
"isEntry": true,
|
||||
"src": "resources/css/app.css"
|
||||
},
|
||||
|
File diff suppressed because one or more lines are too long
@ -37,111 +37,121 @@
|
||||
<div
|
||||
class="left-0 top-0 min-h-screen w-64 flex-none bg-gray-800 dark:bg-gray-800/50 p-3 dark:border-r-2 dark:border-gray-800">
|
||||
<div class="h-16 block">
|
||||
<div class="flex items-center justify-start text-3xl font-extrabold text-white">
|
||||
<x-application-logo class="w-10 h-10 rounded-md"/>
|
||||
<div class="flex items-center justify-start text-2xl font-extrabold text-white">
|
||||
<x-application-logo class="w-7 h-7 rounded-md" />
|
||||
<span class="ml-1">Deploy</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mb-5 space-y-2">
|
||||
@include('layouts.partials.server-select', ['server' => isset($server) ? $server : null])
|
||||
<div class="mb-5">
|
||||
<div class="uppercase text-gray-300 text-sm font-semibold">{{ __("Projects") }}</div>
|
||||
<div class="mt-2">
|
||||
@include('layouts.partials.project-select', ['project' => auth()->user()->currentProject])
|
||||
</div>
|
||||
|
||||
<div class="mt-5 uppercase text-gray-300 text-sm font-semibold">{{ __("Servers") }}</div>
|
||||
<div class="mt-2">
|
||||
@include('layouts.partials.server-select', ['server' => isset($server) ? $server : null])
|
||||
</div>
|
||||
|
||||
@if (isset($server))
|
||||
<x-sidebar-link :href="route('servers.show', ['server' => $server])" :active="request()->routeIs('servers.show')">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5"
|
||||
stroke="currentColor" class="w-6 h-6">
|
||||
<path stroke-linecap="round" stroke-linejoin="round"
|
||||
d="M2.25 12l8.954-8.955c.44-.439 1.152-.439 1.591 0L21.75 12M4.5 9.75v10.125c0 .621.504 1.125 1.125 1.125H9.75v-4.875c0-.621.504-1.125 1.125-1.125h2.25c.621 0 1.125.504 1.125 1.125V21h4.125c.621 0 1.125-.504 1.125-1.125V9.75M8.25 21h8.25" />
|
||||
</svg>
|
||||
<span class="ml-2 text-gray-50">{{ __('Overview') }}</span>
|
||||
</x-sidebar-link>
|
||||
@if ($server->isReady())
|
||||
@if ($server->webserver())
|
||||
<x-sidebar-link :href="route('servers.sites', ['server' => $server])" :active="request()->routeIs('servers.sites') || request()->is('servers/*/sites/*')">
|
||||
<div class="mt-3 space-y-1">
|
||||
<x-sidebar-link :href="route('servers.show', ['server' => $server])" :active="request()->routeIs('servers.show')">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5"
|
||||
stroke="currentColor" class="w-6 h-6">
|
||||
<path stroke-linecap="round" stroke-linejoin="round"
|
||||
d="M2.25 12l8.954-8.955c.44-.439 1.152-.439 1.591 0L21.75 12M4.5 9.75v10.125c0 .621.504 1.125 1.125 1.125H9.75v-4.875c0-.621.504-1.125 1.125-1.125h2.25c.621 0 1.125.504 1.125 1.125V21h4.125c.621 0 1.125-.504 1.125-1.125V9.75M8.25 21h8.25" />
|
||||
</svg>
|
||||
<span class="ml-2 text-gray-50">{{ __('Overview') }}</span>
|
||||
</x-sidebar-link>
|
||||
@if ($server->isReady())
|
||||
@if ($server->webserver())
|
||||
<x-sidebar-link :href="route('servers.sites', ['server' => $server])" :active="request()->routeIs('servers.sites') || request()->is('servers/*/sites/*')">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"
|
||||
stroke-width="1.5" stroke="currentColor" class="w-6 h-6">
|
||||
<path stroke-linecap="round" stroke-linejoin="round"
|
||||
d="M12 21a9.004 9.004 0 008.716-6.747M12 21a9.004 9.004 0 01-8.716-6.747M12 21c2.485 0 4.5-4.03 4.5-9S14.485 3 12 3m0 18c-2.485 0-4.5-4.03-4.5-9S9.515 3 12 3m0 0a8.997 8.997 0 017.843 4.582M12 3a8.997 8.997 0 00-7.843 4.582m15.686 0A11.953 11.953 0 0112 10.5c-2.998 0-5.74-1.1-7.843-2.918m15.686 0A8.959 8.959 0 0121 12c0 .778-.099 1.533-.284 2.253m0 0A17.919 17.919 0 0112 16.5c-3.162 0-6.133-.815-8.716-2.247m0 0A9.015 9.015 0 013 12c0-1.605.42-3.113 1.157-4.418" />
|
||||
</svg>
|
||||
<span class="ml-2 text-gray-50">{{ __('Sites') }}</span>
|
||||
</x-sidebar-link>
|
||||
@endif
|
||||
@if ($server->database())
|
||||
<x-sidebar-link :href="route('servers.databases', ['server' => $server])" :active="request()->routeIs('servers.databases') ||
|
||||
request()->routeIs('servers.databases.backups')">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"
|
||||
stroke-width="1.5" stroke="currentColor" class="w-6 h-6">
|
||||
<path stroke-linecap="round" stroke-linejoin="round"
|
||||
d="M20.25 6.375c0 2.278-3.694 4.125-8.25 4.125S3.75 8.653 3.75 6.375m16.5 0c0-2.278-3.694-4.125-8.25-4.125S3.75 4.097 3.75 6.375m16.5 0v11.25c0 2.278-3.694 4.125-8.25 4.125s-8.25-1.847-8.25-4.125V6.375m16.5 0v3.75m-16.5-3.75v3.75m16.5 0v3.75C20.25 16.153 16.556 18 12 18s-8.25-1.847-8.25-4.125v-3.75m16.5 0c0 2.278-3.694 4.125-8.25 4.125s-8.25-1.847-8.25-4.125" />
|
||||
</svg>
|
||||
<span class="ml-2 text-gray-50">{{ __('Databases') }}</span>
|
||||
</x-sidebar-link>
|
||||
@endif
|
||||
@if ($server->php())
|
||||
<x-sidebar-link :href="route('servers.php', ['server' => $server])" :active="request()->routeIs('servers.php')">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"
|
||||
stroke-width="1.5" stroke="currentColor" class="w-6 h-6">
|
||||
<path stroke-linecap="round" stroke-linejoin="round"
|
||||
d="M17.25 6.75L22.5 12l-5.25 5.25m-10.5 0L1.5 12l5.25-5.25m7.5-3l-4.5 16.5" />
|
||||
</svg>
|
||||
<span class="ml-2 text-gray-50">{{ __('PHP') }}</span>
|
||||
</x-sidebar-link>
|
||||
@endif
|
||||
@if ($server->firewall())
|
||||
<x-sidebar-link :href="route('servers.firewall', ['server' => $server])" :active="request()->routeIs('servers.firewall')">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"
|
||||
stroke-width="1.5" stroke="currentColor" class="w-6 h-6">
|
||||
<path stroke-linecap="round" stroke-linejoin="round"
|
||||
d="M15.362 5.214A8.252 8.252 0 0112 21 8.25 8.25 0 016.038 7.048 8.287 8.287 0 009 9.6a8.983 8.983 0 013.361-6.867 8.21 8.21 0 003 2.48z" />
|
||||
<path stroke-linecap="round" stroke-linejoin="round"
|
||||
d="M12 18a3.75 3.75 0 00.495-7.467 5.99 5.99 0 00-1.925 3.546 5.974 5.974 0 01-2.133-1A3.75 3.75 0 0012 18z" />
|
||||
</svg>
|
||||
<span class="ml-2 text-gray-50">{{ __('Firewall') }}</span>
|
||||
</x-sidebar-link>
|
||||
@endif
|
||||
<x-sidebar-link :href="route('servers.cronjobs', ['server' => $server])" :active="request()->routeIs('servers.cronjobs')">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"
|
||||
stroke-width="1.5" stroke="currentColor" class="w-6 h-6">
|
||||
<path stroke-linecap="round" stroke-linejoin="round"
|
||||
d="M12 21a9.004 9.004 0 008.716-6.747M12 21a9.004 9.004 0 01-8.716-6.747M12 21c2.485 0 4.5-4.03 4.5-9S14.485 3 12 3m0 18c-2.485 0-4.5-4.03-4.5-9S9.515 3 12 3m0 0a8.997 8.997 0 017.843 4.582M12 3a8.997 8.997 0 00-7.843 4.582m15.686 0A11.953 11.953 0 0112 10.5c-2.998 0-5.74-1.1-7.843-2.918m15.686 0A8.959 8.959 0 0121 12c0 .778-.099 1.533-.284 2.253m0 0A17.919 17.919 0 0112 16.5c-3.162 0-6.133-.815-8.716-2.247m0 0A9.015 9.015 0 013 12c0-1.605.42-3.113 1.157-4.418" />
|
||||
d="M12 6v6h4.5m4.5 0a9 9 0 11-18 0 9 9 0 0118 0z" />
|
||||
</svg>
|
||||
<span class="ml-2 text-gray-50">{{ __('Sites') }}</span>
|
||||
<span class="ml-2 text-gray-50">{{ __('Cronjobs') }}</span>
|
||||
</x-sidebar-link>
|
||||
@endif
|
||||
@if ($server->database())
|
||||
<x-sidebar-link :href="route('servers.databases', ['server' => $server])" :active="request()->routeIs('servers.databases') ||
|
||||
request()->routeIs('servers.databases.backups')">
|
||||
<x-sidebar-link :href="route('servers.ssh-keys', ['server' => $server])" :active="request()->routeIs('servers.ssh-keys')">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"
|
||||
stroke-width="1.5" stroke="currentColor" class="w-6 h-6">
|
||||
<path stroke-linecap="round" stroke-linejoin="round"
|
||||
d="M20.25 6.375c0 2.278-3.694 4.125-8.25 4.125S3.75 8.653 3.75 6.375m16.5 0c0-2.278-3.694-4.125-8.25-4.125S3.75 4.097 3.75 6.375m16.5 0v11.25c0 2.278-3.694 4.125-8.25 4.125s-8.25-1.847-8.25-4.125V6.375m16.5 0v3.75m-16.5-3.75v3.75m16.5 0v3.75C20.25 16.153 16.556 18 12 18s-8.25-1.847-8.25-4.125v-3.75m16.5 0c0 2.278-3.694 4.125-8.25 4.125s-8.25-1.847-8.25-4.125" />
|
||||
d="M15.75 5.25a3 3 0 013 3m3 0a6 6 0 01-7.029 5.912c-.563-.097-1.159.026-1.563.43L10.5 17.25H8.25v2.25H6v2.25H2.25v-2.818c0-.597.237-1.17.659-1.591l6.499-6.499c.404-.404.527-1 .43-1.563A6 6 0 1121.75 8.25z" />
|
||||
</svg>
|
||||
<span class="ml-2 text-gray-50">{{ __('Databases') }}</span>
|
||||
<span class="ml-2 text-gray-50">{{ __('SSH Keys') }}</span>
|
||||
</x-sidebar-link>
|
||||
@endif
|
||||
@if ($server->php())
|
||||
<x-sidebar-link :href="route('servers.php', ['server' => $server])" :active="request()->routeIs('servers.php')">
|
||||
<x-sidebar-link :href="route('servers.services', ['server' => $server])" :active="request()->routeIs('servers.services')">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"
|
||||
stroke-width="1.5" stroke="currentColor" class="w-6 h-6">
|
||||
<path stroke-linecap="round" stroke-linejoin="round"
|
||||
d="M17.25 6.75L22.5 12l-5.25 5.25m-10.5 0L1.5 12l5.25-5.25m7.5-3l-4.5 16.5" />
|
||||
d="M9.594 3.94c.09-.542.56-.94 1.11-.94h2.593c.55 0 1.02.398 1.11.94l.213 1.281c.063.374.313.686.645.87.074.04.147.083.22.127.324.196.72.257 1.075.124l1.217-.456a1.125 1.125 0 011.37.49l1.296 2.247a1.125 1.125 0 01-.26 1.431l-1.003.827c-.293.24-.438.613-.431.992a6.759 6.759 0 010 .255c-.007.378.138.75.43.99l1.005.828c.424.35.534.954.26 1.43l-1.298 2.247a1.125 1.125 0 01-1.369.491l-1.217-.456c-.355-.133-.75-.072-1.076.124a6.57 6.57 0 01-.22.128c-.331.183-.581.495-.644.869l-.213 1.28c-.09.543-.56.941-1.11.941h-2.594c-.55 0-1.02-.398-1.11-.94l-.213-1.281c-.062-.374-.312-.686-.644-.87a6.52 6.52 0 01-.22-.127c-.325-.196-.72-.257-1.076-.124l-1.217.456a1.125 1.125 0 01-1.369-.49l-1.297-2.247a1.125 1.125 0 01.26-1.431l1.004-.827c.292-.24.437-.613.43-.992a6.932 6.932 0 010-.255c.007-.378-.138-.75-.43-.99l-1.004-.828a1.125 1.125 0 01-.26-1.43l1.297-2.247a1.125 1.125 0 011.37-.491l1.216.456c.356.133.751.072 1.076-.124.072-.044.146-.087.22-.128.332-.183.582-.495.644-.869l.214-1.281z" />
|
||||
<path stroke-linecap="round" stroke-linejoin="round"
|
||||
d="M15 12a3 3 0 11-6 0 3 3 0 016 0z" />
|
||||
</svg>
|
||||
<span class="ml-2 text-gray-50">{{ __('PHP') }}</span>
|
||||
<span class="ml-2 text-gray-50">{{ __('Services') }}</span>
|
||||
</x-sidebar-link>
|
||||
@endif
|
||||
@if ($server->firewall())
|
||||
<x-sidebar-link :href="route('servers.firewall', ['server' => $server])" :active="request()->routeIs('servers.firewall')">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"
|
||||
stroke-width="1.5" stroke="currentColor" class="w-6 h-6">
|
||||
<path stroke-linecap="round" stroke-linejoin="round"
|
||||
d="M15.362 5.214A8.252 8.252 0 0112 21 8.25 8.25 0 016.038 7.048 8.287 8.287 0 009 9.6a8.983 8.983 0 013.361-6.867 8.21 8.21 0 003 2.48z" />
|
||||
<path stroke-linecap="round" stroke-linejoin="round"
|
||||
d="M12 18a3.75 3.75 0 00.495-7.467 5.99 5.99 0 00-1.925 3.546 5.974 5.974 0 01-2.133-1A3.75 3.75 0 0012 18z" />
|
||||
</svg>
|
||||
<span class="ml-2 text-gray-50">{{ __('Firewall') }}</span>
|
||||
</x-sidebar-link>
|
||||
@endif
|
||||
<x-sidebar-link :href="route('servers.cronjobs', ['server' => $server])" :active="request()->routeIs('servers.cronjobs')">
|
||||
<x-sidebar-link :href="route('servers.settings', ['server' => $server])" :active="request()->routeIs('servers.settings')">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"
|
||||
stroke-width="1.5" stroke="currentColor" class="w-6 h-6">
|
||||
<path stroke-linecap="round" stroke-linejoin="round"
|
||||
d="M12 6v6h4.5m4.5 0a9 9 0 11-18 0 9 9 0 0118 0z" />
|
||||
d="M11.42 15.17L17.25 21A2.652 2.652 0 0021 17.25l-5.877-5.877M11.42 15.17l2.496-3.03c.317-.384.74-.626 1.208-.766M11.42 15.17l-4.655 5.653a2.548 2.548 0 11-3.586-3.586l6.837-5.63m5.108-.233c.55-.164 1.163-.188 1.743-.14a4.5 4.5 0 004.486-6.336l-3.276 3.277a3.004 3.004 0 01-2.25-2.25l3.276-3.276a4.5 4.5 0 00-6.336 4.486c.091 1.076-.071 2.264-.904 2.95l-.102.085m-1.745 1.437L5.909 7.5H4.5L2.25 3.75l1.5-1.5L7.5 4.5v1.409l4.26 4.26m-1.745 1.437l1.745-1.437m6.615 8.206L15.75 15.75M4.867 19.125h.008v.008h-.008v-.008z" />
|
||||
</svg>
|
||||
<span class="ml-2 text-gray-50">{{ __('Cronjobs') }}</span>
|
||||
<span class="ml-2 text-gray-50">{{ __('Settings') }}</span>
|
||||
</x-sidebar-link>
|
||||
<x-sidebar-link :href="route('servers.ssh-keys', ['server' => $server])" :active="request()->routeIs('servers.ssh-keys')">
|
||||
<x-sidebar-link :href="route('servers.logs', ['server' => $server])" :active="request()->routeIs('servers.logs')">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"
|
||||
stroke-width="1.5" stroke="currentColor" class="w-6 h-6">
|
||||
<path stroke-linecap="round" stroke-linejoin="round"
|
||||
d="M15.75 5.25a3 3 0 013 3m3 0a6 6 0 01-7.029 5.912c-.563-.097-1.159.026-1.563.43L10.5 17.25H8.25v2.25H6v2.25H2.25v-2.818c0-.597.237-1.17.659-1.591l6.499-6.499c.404-.404.527-1 .43-1.563A6 6 0 1121.75 8.25z" />
|
||||
d="M6.429 9.75L2.25 12l4.179 2.25m0-4.5l5.571 3 5.571-3m-11.142 0L2.25 7.5 12 2.25l9.75 5.25-4.179 2.25m0 0L21.75 12l-4.179 2.25m0 0l4.179 2.25L12 21.75 2.25 16.5l4.179-2.25m11.142 0l-5.571 3-5.571-3" />
|
||||
</svg>
|
||||
<span class="ml-2 text-gray-50">{{ __('SSH Keys') }}</span>
|
||||
<span class="ml-2 text-gray-50">{{ __('Logs') }}</span>
|
||||
</x-sidebar-link>
|
||||
<x-sidebar-link :href="route('servers.services', ['server' => $server])" :active="request()->routeIs('servers.services')">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"
|
||||
stroke-width="1.5" stroke="currentColor" class="w-6 h-6">
|
||||
<path stroke-linecap="round" stroke-linejoin="round"
|
||||
d="M9.594 3.94c.09-.542.56-.94 1.11-.94h2.593c.55 0 1.02.398 1.11.94l.213 1.281c.063.374.313.686.645.87.074.04.147.083.22.127.324.196.72.257 1.075.124l1.217-.456a1.125 1.125 0 011.37.49l1.296 2.247a1.125 1.125 0 01-.26 1.431l-1.003.827c-.293.24-.438.613-.431.992a6.759 6.759 0 010 .255c-.007.378.138.75.43.99l1.005.828c.424.35.534.954.26 1.43l-1.298 2.247a1.125 1.125 0 01-1.369.491l-1.217-.456c-.355-.133-.75-.072-1.076.124a6.57 6.57 0 01-.22.128c-.331.183-.581.495-.644.869l-.213 1.28c-.09.543-.56.941-1.11.941h-2.594c-.55 0-1.02-.398-1.11-.94l-.213-1.281c-.062-.374-.312-.686-.644-.87a6.52 6.52 0 01-.22-.127c-.325-.196-.72-.257-1.076-.124l-1.217.456a1.125 1.125 0 01-1.369-.49l-1.297-2.247a1.125 1.125 0 01.26-1.431l1.004-.827c.292-.24.437-.613.43-.992a6.932 6.932 0 010-.255c.007-.378-.138-.75-.43-.99l-1.004-.828a1.125 1.125 0 01-.26-1.43l1.297-2.247a1.125 1.125 0 011.37-.491l1.216.456c.356.133.751.072 1.076-.124.072-.044.146-.087.22-.128.332-.183.582-.495.644-.869l.214-1.281z" />
|
||||
<path stroke-linecap="round" stroke-linejoin="round"
|
||||
d="M15 12a3 3 0 11-6 0 3 3 0 016 0z" />
|
||||
</svg>
|
||||
<span class="ml-2 text-gray-50">{{ __('Services') }}</span>
|
||||
</x-sidebar-link>
|
||||
@endif
|
||||
<x-sidebar-link :href="route('servers.settings', ['server' => $server])" :active="request()->routeIs('servers.settings')">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"
|
||||
stroke-width="1.5" stroke="currentColor" class="w-6 h-6">
|
||||
<path stroke-linecap="round" stroke-linejoin="round"
|
||||
d="M11.42 15.17L17.25 21A2.652 2.652 0 0021 17.25l-5.877-5.877M11.42 15.17l2.496-3.03c.317-.384.74-.626 1.208-.766M11.42 15.17l-4.655 5.653a2.548 2.548 0 11-3.586-3.586l6.837-5.63m5.108-.233c.55-.164 1.163-.188 1.743-.14a4.5 4.5 0 004.486-6.336l-3.276 3.277a3.004 3.004 0 01-2.25-2.25l3.276-3.276a4.5 4.5 0 00-6.336 4.486c.091 1.076-.071 2.264-.904 2.95l-.102.085m-1.745 1.437L5.909 7.5H4.5L2.25 3.75l1.5-1.5L7.5 4.5v1.409l4.26 4.26m-1.745 1.437l1.745-1.437m6.615 8.206L15.75 15.75M4.867 19.125h.008v.008h-.008v-.008z" />
|
||||
</svg>
|
||||
<span class="ml-2 text-gray-50">{{ __('Settings') }}</span>
|
||||
</x-sidebar-link>
|
||||
<x-sidebar-link :href="route('servers.logs', ['server' => $server])" :active="request()->routeIs('servers.logs')">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"
|
||||
stroke-width="1.5" stroke="currentColor" class="w-6 h-6">
|
||||
<path stroke-linecap="round" stroke-linejoin="round"
|
||||
d="M6.429 9.75L2.25 12l4.179 2.25m0-4.5l5.571 3 5.571-3m-11.142 0L2.25 7.5 12 2.25l9.75 5.25-4.179 2.25m0 0L21.75 12l-4.179 2.25m0 0l4.179 2.25L12 21.75 2.25 16.5l4.179-2.25m11.142 0l-5.571 3-5.571-3" />
|
||||
</svg>
|
||||
<span class="ml-2 text-gray-50">{{ __('Logs') }}</span>
|
||||
</x-sidebar-link>
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
|
@ -20,11 +20,14 @@
|
||||
<div class="min-h-screen flex flex-col sm:justify-center items-center pt-6 sm:pt-0 bg-gray-100 dark:bg-gray-900">
|
||||
<div>
|
||||
<a href="/">
|
||||
<x-application-logo class="w-20 h-20 fill-current text-gray-500 rounded-lg" />
|
||||
<div class="flex items-center justify-start text-3xl font-extrabold">
|
||||
<x-application-logo class="w-9 h-9 rounded-md" />
|
||||
<span class="ml-1">Deploy</span>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="w-full sm:max-w-md mt-6 px-6 py-4 bg-white dark:bg-gray-800 shadow-md overflow-hidden rounded-lg">
|
||||
<div class="w-full sm:max-w-md mt-10 px-6 py-4 bg-white dark:bg-gray-800 shadow-md overflow-hidden rounded-lg">
|
||||
{{ $slot }}
|
||||
</div>
|
||||
</div>
|
||||
|
90
resources/views/layouts/partials/project-select.blade.php
Normal file
90
resources/views/layouts/partials/project-select.blade.php
Normal file
@ -0,0 +1,90 @@
|
||||
<div x-data="projectCombobox()">
|
||||
<div class="relative">
|
||||
<div @click="open = !open" class="z-0 w-full cursor-pointer px-4 py-3 pr-10 text-md leading-5 text-gray-100 focus:ring-1 focus:ring-gray-700 bg-gray-900 rounded-md h-10 flex items-center" x-text="selected.name ?? 'Select Project'"></div>
|
||||
<button type="button" @click="open = !open" class="z-0 absolute inset-y-0 right-0 flex items-center pr-2">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true" class="h-5 w-5 text-gray-400"><path fill-rule="evenodd" d="M10 3a.75.75 0 01.55.24l3.25 3.5a.75.75 0 11-1.1 1.02L10 4.852 7.3 7.76a.75.75 0 01-1.1-1.02l3.25-3.5A.75.75 0 0110 3zm-3.76 9.2a.75.75 0 011.06.04l2.7 2.908 2.7-2.908a.75.75 0 111.1 1.02l-3.25 3.5a.75.75 0 01-1.1 0l-3.25-3.5a.75.75 0 01.04-1.06z" clip-rule="evenodd"></path></svg>
|
||||
</button>
|
||||
<div
|
||||
x-show="open"
|
||||
@click.away="open = false"
|
||||
class="z-10 absolute mt-1 w-full overflow-auto rounded-md pb-1 bg-white dark:bg-gray-700 text-base shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none sm:text-sm">
|
||||
<div class="p-2 relative">
|
||||
<input x-model="query"
|
||||
@input="filterProjectsAndOpen"
|
||||
placeholder="Filter"
|
||||
class="w-full py-2 pl-3 pr-10 text-sm leading-5 dark:text-gray-100 focus:ring-1 focus:ring-gray-400 dark:focus:ring-800 bg-gray-200 dark:bg-gray-900 rounded-md"
|
||||
>
|
||||
</div>
|
||||
<div class="relative max-h-[350px] overflow-y-auto">
|
||||
<template x-for="(project, index) in filteredProjects" :key="index">
|
||||
<div
|
||||
@click="selectProject(project); open = false"
|
||||
:class="project.id === selected.id ? 'cursor-default bg-primary-600 text-white' : 'cursor-pointer'"
|
||||
class="relative select-none py-2 px-4 text-gray-700 dark:text-white hover:bg-primary-600 hover:text-white">
|
||||
<span class="block truncate" x-text="project.name"></span>
|
||||
<template x-if="project.id === selected.id">
|
||||
<span class="absolute inset-y-0 right-0 flex items-center pr-3 text-white">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true" class="h-5 w-5"><path fill-rule="evenodd" d="M16.704 4.153a.75.75 0 01.143 1.052l-8 10.5a.75.75 0 01-1.127.075l-4.5-4.5a.75.75 0 011.06-1.06l3.894 3.893 7.48-9.817a.75.75 0 011.05-.143z" clip-rule="evenodd"></path></svg>
|
||||
</span>
|
||||
</template>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
<div
|
||||
x-show="filteredProjects.length === 0"
|
||||
class="relative cursor-default select-none py-2 px-4 text-gray-700 dark:text-white block truncate">
|
||||
No projects found!
|
||||
</div>
|
||||
<div class="py-1">
|
||||
<hr class="border-gray-300 dark:border-gray-600">
|
||||
</div>
|
||||
<div>
|
||||
<a
|
||||
href="{{ route('projects') }}"
|
||||
class="relative select-none py-2 px-4 text-gray-700 dark:text-white hover:bg-primary-600 hover:text-white block cursor-pointer">
|
||||
<span class="block truncate">Projects List</span>
|
||||
</a>
|
||||
</div>
|
||||
<div>
|
||||
<a
|
||||
href="{{ route('projects', ['create' => true]) }}"
|
||||
class="relative select-none py-2 px-4 text-gray-700 dark:text-white hover:bg-primary-600 hover:text-white block cursor-pointer">
|
||||
<span class="block truncate">Create a Project</span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function projectCombobox() {
|
||||
const projects = @json(auth()->user()->projects()->select('id', 'name')->get());
|
||||
return {
|
||||
open: false,
|
||||
query: '',
|
||||
projects: projects,
|
||||
selected: @if(isset($project)) @json($project->only('id', 'name')) @else {} @endif,
|
||||
filteredProjects: projects,
|
||||
selectProject(project) {
|
||||
if (this.selected.id !== project.id) {
|
||||
this.selected = project;
|
||||
window.location.href = '{{ url('/settings/projects/') }}/' + project.id
|
||||
}
|
||||
},
|
||||
filterProjectsAndOpen() {
|
||||
if (this.query === '') {
|
||||
this.filteredProjects = this.projects;
|
||||
this.open = false;
|
||||
} else {
|
||||
this.filteredProjects = this.projects.filter((project) =>
|
||||
project.name
|
||||
.toLowerCase()
|
||||
.replace(/\s+/g, '')
|
||||
.includes(this.query.toLowerCase().replace(/\s+/g, ''))
|
||||
);
|
||||
this.open = true;
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
</script>
|
@ -1,13 +1,13 @@
|
||||
<div x-data="serverCombobox()">
|
||||
<div class="relative">
|
||||
<div @click="open = !open" class="w-full cursor-pointer px-4 py-3 pr-10 text-md leading-5 text-gray-100 focus:ring-1 focus:ring-gray-700 bg-gray-900 rounded-md h-10 flex items-center" x-text="selected.name ?? 'Select Server'"></div>
|
||||
<button type="button" @click="open = !open" class="absolute inset-y-0 right-0 flex items-center pr-2">
|
||||
<div @click="open = !open" class="z-0 w-full cursor-pointer px-4 py-3 pr-10 text-md leading-5 text-gray-100 focus:ring-1 focus:ring-gray-700 bg-gray-900 rounded-md h-10 flex items-center" x-text="selected.name ?? 'Select Server'"></div>
|
||||
<button type="button" @click="open = !open" class="z-0 absolute inset-y-0 right-0 flex items-center pr-2">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true" class="h-5 w-5 text-gray-400"><path fill-rule="evenodd" d="M10 3a.75.75 0 01.55.24l3.25 3.5a.75.75 0 11-1.1 1.02L10 4.852 7.3 7.76a.75.75 0 01-1.1-1.02l3.25-3.5A.75.75 0 0110 3zm-3.76 9.2a.75.75 0 011.06.04l2.7 2.908 2.7-2.908a.75.75 0 111.1 1.02l-3.25 3.5a.75.75 0 01-1.1 0l-3.25-3.5a.75.75 0 01.04-1.06z" clip-rule="evenodd"></path></svg>
|
||||
</button>
|
||||
<div
|
||||
x-show="open"
|
||||
@click.away="open = false"
|
||||
class="absolute mt-1 w-full overflow-auto rounded-md pb-1 bg-white dark:bg-gray-700 text-base shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none sm:text-sm">
|
||||
class="z-10 absolute mt-1 w-full overflow-auto rounded-md pb-1 bg-white dark:bg-gray-700 text-base shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none sm:text-sm">
|
||||
<div class="p-2 relative">
|
||||
<input x-model="query"
|
||||
@input="filterServersAndOpen"
|
||||
@ -58,7 +58,7 @@ class="relative select-none py-2 px-4 text-gray-700 dark:text-white hover:bg-pri
|
||||
|
||||
<script>
|
||||
function serverCombobox() {
|
||||
const servers = @json(\App\Models\Server::query()->select('id', 'name')->get());
|
||||
const servers = @json(auth()->user()->currentProject->servers()->select('id', 'name')->get());
|
||||
return {
|
||||
open: false,
|
||||
query: '',
|
||||
|
@ -16,6 +16,12 @@
|
||||
</svg>
|
||||
{{ __('Profile') }}
|
||||
</x-secondary-sidebar-link>
|
||||
<x-secondary-sidebar-link :href="route('projects')" :active="request()->routeIs('projects')">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-6 h-6 mr-2">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" d="m7.875 14.25 1.214 1.942a2.25 2.25 0 0 0 1.908 1.058h2.006c.776 0 1.497-.4 1.908-1.058l1.214-1.942M2.41 9h4.636a2.25 2.25 0 0 1 1.872 1.002l.164.246a2.25 2.25 0 0 0 1.872 1.002h2.092a2.25 2.25 0 0 0 1.872-1.002l.164-.246A2.25 2.25 0 0 1 16.954 9h4.636M2.41 9a2.25 2.25 0 0 0-.16.832V12a2.25 2.25 0 0 0 2.25 2.25h15A2.25 2.25 0 0 0 21.75 12V9.832c0-.287-.055-.57-.16-.832M2.41 9a2.25 2.25 0 0 1 .382-.632l3.285-3.832a2.25 2.25 0 0 1 1.708-.786h8.43c.657 0 1.281.287 1.709.786l3.284 3.832c.163.19.291.404.382.632M4.5 20.25h15A2.25 2.25 0 0 0 21.75 18v-2.625c0-.621-.504-1.125-1.125-1.125H3.375c-.621 0-1.125.504-1.125 1.125V18a2.25 2.25 0 0 0 2.25 2.25Z" />
|
||||
</svg>
|
||||
{{ __('Projects') }}
|
||||
</x-secondary-sidebar-link>
|
||||
<x-secondary-sidebar-link :href="route('server-providers')" :active="request()->routeIs('server-providers')">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-6 h-6 mr-2">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" d="M5.25 14.25h13.5m-13.5 0a3 3 0 01-3-3m3 3a3 3 0 100 6h13.5a3 3 0 100-6m-16.5-3a3 3 0 013-3h13.5a3 3 0 013 3m-19.5 0a4.5 4.5 0 01.9-2.7L5.737 5.1a3.375 3.375 0 012.7-1.35h7.126c1.062 0 2.062.5 2.7 1.35l2.587 3.45a4.5 4.5 0 01.9 2.7m0 0a3 3 0 01-3 3m0 3h.008v.008h-.008v-.008zm0-6h.008v.008h-.008v-.008zm-3 6h.008v.008h-.008v-.008zm0-6h.008v.008h-.008v-.008z" />
|
||||
|
31
resources/views/livewire/projects/create-project.blade.php
Normal file
31
resources/views/livewire/projects/create-project.blade.php
Normal file
@ -0,0 +1,31 @@
|
||||
<div>
|
||||
<x-primary-button x-data="" x-on:click.prevent="$dispatch('open-modal', 'create-project')">
|
||||
{{ __('Connect') }}
|
||||
</x-primary-button>
|
||||
|
||||
<x-modal name="create-project" :show="$open">
|
||||
<form wire:submit.prevent="create" class="p-6">
|
||||
<h2 class="text-lg font-medium text-gray-900 dark:text-gray-100">
|
||||
{{ __('Create Project') }}
|
||||
</h2>
|
||||
|
||||
<div class="mt-6">
|
||||
<x-input-label for="name" value="Name" />
|
||||
<x-text-input wire:model.defer="inputs.name" id="name" name="name" type="text" class="mt-1 w-full" />
|
||||
@error('name')
|
||||
<x-input-error class="mt-2" :messages="$message" />
|
||||
@enderror
|
||||
</div>
|
||||
|
||||
<div class="mt-6 flex justify-end">
|
||||
<x-secondary-button type="button" x-on:click="$dispatch('close')">
|
||||
{{ __('Cancel') }}
|
||||
</x-secondary-button>
|
||||
|
||||
<x-primary-button class="ml-3" @created.window="$dispatch('close')">
|
||||
{{ __('Create') }}
|
||||
</x-primary-button>
|
||||
</div>
|
||||
</form>
|
||||
</x-modal>
|
||||
</div>
|
31
resources/views/livewire/projects/edit-project.blade.php
Normal file
31
resources/views/livewire/projects/edit-project.blade.php
Normal file
@ -0,0 +1,31 @@
|
||||
<div>
|
||||
<x-icon-button x-data="" x-on:click.prevent="$dispatch('open-modal', 'edit-project-{{ $project->id }}')">
|
||||
{{ __('Edit') }}
|
||||
</x-icon-button>
|
||||
|
||||
<x-modal name="edit-project-{{ $project->id }}">
|
||||
<form wire:submit.prevent="save" class="p-6 text-left">
|
||||
<h2 class="text-lg font-medium text-gray-900 dark:text-gray-100">
|
||||
{{ __('Edit Project') }}
|
||||
</h2>
|
||||
|
||||
<div class="mt-6">
|
||||
<x-input-label for="edit-name-{{ $project->id }}" value="Name" />
|
||||
<x-text-input wire:model.defer="inputs.name" id="edit-name-{{ $project->id }}" name="name" type="text" class="mt-1 w-full" />
|
||||
@error('name')
|
||||
<x-input-error class="mt-2" :messages="$message" />
|
||||
@enderror
|
||||
</div>
|
||||
|
||||
<div class="mt-6 flex justify-end">
|
||||
<x-secondary-button type="button" x-on:click="$dispatch('close')">
|
||||
{{ __('Cancel') }}
|
||||
</x-secondary-button>
|
||||
|
||||
<x-primary-button class="ml-3" @created.window="$dispatch('close')">
|
||||
{{ __('Save') }}
|
||||
</x-primary-button>
|
||||
</div>
|
||||
</form>
|
||||
</x-modal>
|
||||
</div>
|
38
resources/views/livewire/projects/projects-list.blade.php
Normal file
38
resources/views/livewire/projects/projects-list.blade.php
Normal file
@ -0,0 +1,38 @@
|
||||
<div>
|
||||
<x-card-header>
|
||||
<x-slot name="title">{{ __("Projects") }}</x-slot>
|
||||
<x-slot name="description">{{ __("Here you can manage your projects") }}</x-slot>
|
||||
<x-slot name="aside">
|
||||
<livewire:projects.create-project />
|
||||
</x-slot>
|
||||
</x-card-header>
|
||||
<div x-data="" class="space-y-3">
|
||||
@foreach($projects as $project)
|
||||
<x-item-card>
|
||||
<div class="ml-3 flex flex-grow flex-col items-start justify-center">
|
||||
<div class="mb-1 flex items-center">
|
||||
{{ $project->name }}
|
||||
@if($project->id == auth()->user()->current_project_id)
|
||||
<x-status status="success" class="ml-1">{{ __('Current') }}</x-status>
|
||||
@endif
|
||||
</div>
|
||||
<span class="text-sm text-gray-400">
|
||||
<x-datetime :value="$project->created_at" />
|
||||
</span>
|
||||
</div>
|
||||
<div class="flex items-center">
|
||||
<livewire:projects.edit-project :project="$project" />
|
||||
<x-icon-button x-on:click="$wire.deleteId = '{{ $project->id }}'; $dispatch('open-modal', 'delete-project')">
|
||||
Delete
|
||||
</x-icon-button>
|
||||
</div>
|
||||
</x-item-card>
|
||||
@endforeach
|
||||
<x-confirm-modal
|
||||
name="delete-project"
|
||||
:title="__('Confirm')"
|
||||
:description="__('Deleting a project will delete all of its servers, sites, etc. Are you sure you want to delete this project?')"
|
||||
method="delete"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
5
resources/views/projects/index.blade.php
Normal file
5
resources/views/projects/index.blade.php
Normal file
@ -0,0 +1,5 @@
|
||||
<x-profile-layout>
|
||||
<x-slot name="pageTitle">{{ __("Projects") }}</x-slot>
|
||||
|
||||
<livewire:projects.projects-list />
|
||||
</x-profile-layout>
|
@ -5,6 +5,7 @@
|
||||
use App\Http\Controllers\DatabaseController;
|
||||
use App\Http\Controllers\FirewallController;
|
||||
use App\Http\Controllers\PHPController;
|
||||
use App\Http\Controllers\ProjectController;
|
||||
use App\Http\Controllers\ServerController;
|
||||
use App\Http\Controllers\ServerSettingController;
|
||||
use App\Http\Controllers\ServiceController;
|
||||
@ -19,6 +20,8 @@
|
||||
Route::middleware('auth')->group(function () {
|
||||
Route::prefix('/settings')->group(function () {
|
||||
Route::view('/profile', 'profile.index')->name('profile');
|
||||
Route::get('/projects', [ProjectController::class, 'index'])->name('projects');
|
||||
Route::get('/projects/{projectId}', [ProjectController::class, 'switch'])->name('projects.switch');
|
||||
Route::view('/server-providers', 'server-providers.index')->name('server-providers');
|
||||
Route::view('/source-controls', 'source-controls.index')->name('source-controls');
|
||||
Route::view('/storage-providers', 'storage-providers.index')->name('storage-providers');
|
||||
|
83
tests/Feature/Http/ProjectsTest.php
Normal file
83
tests/Feature/Http/ProjectsTest.php
Normal file
@ -0,0 +1,83 @@
|
||||
<?php
|
||||
|
||||
namespace Feature\Http;
|
||||
|
||||
use App\Http\Livewire\Projects\CreateProject;
|
||||
use App\Http\Livewire\Projects\EditProject;
|
||||
use App\Http\Livewire\Projects\ProjectsList;
|
||||
use App\Models\Project;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Livewire\Livewire;
|
||||
use Tests\TestCase;
|
||||
|
||||
class ProjectsTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
public function test_create_project(): void
|
||||
{
|
||||
$this->actingAs($this->user);
|
||||
|
||||
Livewire::test(CreateProject::class)
|
||||
->set('inputs.name', 'test')
|
||||
->call('create')
|
||||
->assertSuccessful();
|
||||
|
||||
$this->assertDatabaseHas('projects', [
|
||||
'name' => 'test',
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_see_projects_list(): void
|
||||
{
|
||||
$this->actingAs($this->user);
|
||||
|
||||
$project = Project::factory()->create([
|
||||
'user_id' => $this->user->id,
|
||||
]);
|
||||
|
||||
Livewire::test(ProjectsList::class)
|
||||
->assertSee([
|
||||
$project->name,
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_delete_project(): void
|
||||
{
|
||||
$this->actingAs($this->user);
|
||||
|
||||
$project = Project::factory()->create([
|
||||
'user_id' => $this->user->id,
|
||||
]);
|
||||
|
||||
Livewire::test(ProjectsList::class)
|
||||
->set('deleteId', $project->id)
|
||||
->call('delete')
|
||||
->assertSuccessful();
|
||||
|
||||
$this->assertDatabaseMissing('projects', [
|
||||
'id' => $project->id,
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_edit_project(): void
|
||||
{
|
||||
$this->actingAs($this->user);
|
||||
|
||||
$project = Project::factory()->create([
|
||||
'user_id' => $this->user->id,
|
||||
]);
|
||||
|
||||
Livewire::test(EditProject::class, [
|
||||
'project' => $project,
|
||||
])
|
||||
->set('inputs.name', 'test')
|
||||
->call('save')
|
||||
->assertSuccessful();
|
||||
|
||||
$this->assertDatabaseHas('projects', [
|
||||
'id' => $project->id,
|
||||
'name' => 'test',
|
||||
]);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user