feat: initialize Infra Manager with React, Tailwind CSS, and Inertia.js
- Added main application entry point (app.jsx) and bootstrap file for React setup. - Created Wiki index page (Index.jsx) for documentation and file management. - Implemented utility functions for formatting and status handling in utils.js. - Set up Blade template (app.blade.php) for Inertia.js integration. - Defined API routes for metrics and terminal access in api.php. - Established console commands for scheduled tasks in console.php. - Created web routes for various application features including authentication, hypervisors, containers, cloud accounts, security, backups, and wiki management in web.php. - Developed setup scripts for Windows (setup.ps1) and Linux (setup.sh) environments. - Configured Tailwind CSS for styling with custom themes and animations in tailwind.config.js. - Set up Vite for asset bundling and development server in vite.config.js.
This commit is contained in:
54
app/Http/Controllers/Container/ContainerController.php
Normal file
54
app/Http/Controllers/Container/ContainerController.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Container;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Container;
|
||||
use App\Models\DockerEndpoint;
|
||||
use App\Services\Container\DockerManager;
|
||||
use Illuminate\Http\Request;
|
||||
use Inertia\Inertia;
|
||||
|
||||
class ContainerController extends Controller
|
||||
{
|
||||
public function __construct(private DockerManager $docker) {}
|
||||
|
||||
public function index()
|
||||
{
|
||||
return Inertia::render('Container/Index', [
|
||||
'containers' => Container::with('endpoint')->orderBy('name')->paginate(50),
|
||||
'endpoints' => DockerEndpoint::orderBy('name')->get(),
|
||||
]);
|
||||
}
|
||||
|
||||
public function show(Container $container)
|
||||
{
|
||||
return Inertia::render('Container/Show', ['container' => $container->load('endpoint')]);
|
||||
}
|
||||
|
||||
public function action(Request $request, Container $container)
|
||||
{
|
||||
$action = $request->validate(['action' => 'required|string'])['action'];
|
||||
$this->docker->action($container->endpoint, $container->container_id, $action);
|
||||
return back()->with('success', "Container {$action} executed.");
|
||||
}
|
||||
|
||||
public function logs(Container $container)
|
||||
{
|
||||
$logs = $this->docker->logs($container->endpoint, $container->container_id);
|
||||
return Inertia::render('Container/Logs', ['container' => $container, 'logs' => $logs]);
|
||||
}
|
||||
|
||||
public function stats(Container $container)
|
||||
{
|
||||
$stats = $this->docker->stats($container->endpoint, $container->container_id);
|
||||
return response()->json($stats);
|
||||
}
|
||||
|
||||
public function destroy(Container $container)
|
||||
{
|
||||
$this->docker->removeContainer($container->endpoint, $container->container_id, true);
|
||||
$container->delete();
|
||||
return redirect()->route('containers.index')->with('success', 'Container removed.');
|
||||
}
|
||||
}
|
||||
68
app/Http/Controllers/Container/StackController.php
Normal file
68
app/Http/Controllers/Container/StackController.php
Normal file
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Container;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\DockerEndpoint;
|
||||
use App\Models\Stack;
|
||||
use App\Services\Container\DockerManager;
|
||||
use Illuminate\Http\Request;
|
||||
use Inertia\Inertia;
|
||||
|
||||
class StackController extends Controller
|
||||
{
|
||||
public function __construct(private DockerManager $docker) {}
|
||||
|
||||
public function index()
|
||||
{
|
||||
return Inertia::render('Container/Stacks', [
|
||||
'stacks' => Stack::with('endpoint')->orderBy('name')->paginate(20),
|
||||
'endpoints' => DockerEndpoint::all(),
|
||||
]);
|
||||
}
|
||||
|
||||
public function create()
|
||||
{
|
||||
return Inertia::render('Container/StackCreate', ['endpoints' => DockerEndpoint::all()]);
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
$validated = $request->validate([
|
||||
'name' => 'required|string|max:100',
|
||||
'endpoint_id' => 'required|exists:docker_endpoints,id',
|
||||
'compose_content' => 'required|string',
|
||||
'env_vars' => 'nullable|array',
|
||||
]);
|
||||
Stack::create([...$validated, 'created_by' => auth()->id()]);
|
||||
return redirect()->route('stacks.index')->with('success', 'Stack created.');
|
||||
}
|
||||
|
||||
public function show(Stack $stack)
|
||||
{
|
||||
return Inertia::render('Container/StackShow', ['stack' => $stack->load('endpoint')]);
|
||||
}
|
||||
|
||||
public function edit(Stack $stack)
|
||||
{
|
||||
return Inertia::render('Container/StackEdit', ['stack' => $stack, 'endpoints' => DockerEndpoint::all()]);
|
||||
}
|
||||
|
||||
public function update(Request $request, Stack $stack)
|
||||
{
|
||||
$stack->update($request->only('name', 'compose_content', 'env_vars'));
|
||||
return redirect()->route('stacks.show', $stack)->with('success', 'Stack updated.');
|
||||
}
|
||||
|
||||
public function destroy(Stack $stack)
|
||||
{
|
||||
$stack->delete();
|
||||
return redirect()->route('stacks.index')->with('success', 'Stack deleted.');
|
||||
}
|
||||
|
||||
public function deploy(Stack $stack)
|
||||
{
|
||||
$this->docker->deployStack($stack->endpoint, $stack->name, $stack->compose_content, $stack->env_vars ?? []);
|
||||
return back()->with('success', 'Stack deployed.');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user