- 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.
78 lines
2.4 KiB
PHP
78 lines
2.4 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Hypervisor;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Models\Hypervisor;
|
|
use App\Models\VmTemplate;
|
|
use Illuminate\Http\Request;
|
|
use Inertia\Inertia;
|
|
|
|
class TemplateController extends Controller
|
|
{
|
|
public function index()
|
|
{
|
|
return Inertia::render('Hypervisor/Templates', [
|
|
'templates' => VmTemplate::with('hypervisor')->orderBy('name')->paginate(20),
|
|
]);
|
|
}
|
|
|
|
public function create()
|
|
{
|
|
return Inertia::render('Hypervisor/TemplateCreate', [
|
|
'hypervisors' => Hypervisor::where('status', 'online')->get(),
|
|
]);
|
|
}
|
|
|
|
public function store(Request $request)
|
|
{
|
|
$validated = $request->validate([
|
|
'name' => 'required|string|max:100',
|
|
'hypervisor_id' => 'nullable|exists:hypervisors,id',
|
|
'os_type' => 'required|string',
|
|
'cpu_count' => 'integer|min:1',
|
|
'memory_mb' => 'integer|min:512',
|
|
'disk_gb' => 'integer|min:1',
|
|
'customization' => 'nullable|array',
|
|
'provision_script' => 'nullable|string',
|
|
]);
|
|
VmTemplate::create([...$validated, 'created_by' => auth()->id()]);
|
|
return redirect()->route('templates.index')->with('success', 'Template created.');
|
|
}
|
|
|
|
public function show(VmTemplate $template)
|
|
{
|
|
return Inertia::render('Hypervisor/TemplateShow', ['template' => $template->load('hypervisor')]);
|
|
}
|
|
|
|
public function edit(VmTemplate $template)
|
|
{
|
|
return Inertia::render('Hypervisor/TemplateEdit', [
|
|
'template' => $template,
|
|
'hypervisors' => Hypervisor::where('status', 'online')->get(),
|
|
]);
|
|
}
|
|
|
|
public function update(Request $request, VmTemplate $template)
|
|
{
|
|
$template->update($request->except('_token'));
|
|
return redirect()->route('templates.show', $template)->with('success', 'Template updated.');
|
|
}
|
|
|
|
public function destroy(VmTemplate $template)
|
|
{
|
|
$template->delete();
|
|
return redirect()->route('templates.index')->with('success', 'Template deleted.');
|
|
}
|
|
|
|
public function deploy(Request $request, VmTemplate $template)
|
|
{
|
|
$data = $request->validate([
|
|
'vm_name' => 'required|string',
|
|
'hypervisor_id' => 'required|exists:hypervisors,id',
|
|
]);
|
|
// Dispatch deploy job
|
|
return back()->with('success', 'Deployment queued.');
|
|
}
|
|
}
|