feat: Implement VM console access, display VM power state, and add VM statistics retrieval.

This commit is contained in:
pbao9
2026-02-14 16:28:13 +07:00
parent 449502e290
commit 498a57b499
6 changed files with 610 additions and 23 deletions
@@ -1,46 +1,92 @@
@extends("administrator.layout.master")
@section('breadcrumb')
@php
$breadcrumbItems = [
['label' => 'Modules'],
['label' => 'Package vCenter'],
['label' => 'Virtual Machine', 'route' => 'package.vm.index'],
['label' => $vm->name ?? $vm->vm_id ?? 'Edit', 'active' => true],
];
@endphp
<x-admin-breadcrumb :items="$breadcrumbItems" />
@endsection
@section("content")
@if(auth()->guard('admins')->user()->can("add module vcenter"))
<div class="card card-outline card-primary">
<form action="{{ route('package.host.update',['id' => $host->id]) }}" method="post">
<form action="{{ route('package.vm.update',['id' => $vm->id]) }}" method="post">
@csrf
@method('put')
<div class="card-body">
<x-module.v-center :model="$host->datacenter" />
<x-module.datacenter :model="$host" />
{{--Name--}}
<div class="row form-group align-items-center mb-0">
<label for="name" class="col-md-3 text-right">Name</label>
<div class="col-md-9 p-1 bg-customer">
<input type="text" id="name" name="name" placeholder="" value="{{ $host->name}}" class="form-control">
<input type="text" id="name" name="name" placeholder="" value="{{ $vm->name}}" class="form-control">
</div>
</div>
{{--Host ID--}}
{{--VM ID--}}
<div class="row form-group align-items-center mb-0">
<label for="host_id" class="col-md-3 text-right">Host ID</label>
<label for="vm_id" class="col-md-3 text-right">VM ID</label>
<div class="col-md-9 p-1 bg-customer">
<input type="text" id="host_id" name="host_id" placeholder="" value="{{ $host->host_id}}" class="form-control">
<input type="text" id="vm_id" name="vm_id" placeholder="" value="{{ $vm->vm_id}}" class="form-control">
</div>
</div>
{{--Template ID--}}
{{--Power State--}}
<div class="row form-group align-items-center mb-0">
<label for="template" class="col-md-3 text-right">Template ID</label>
<label for="power_state" class="col-md-3 text-right">Power State</label>
<div class="col-md-9 p-1 bg-customer">
<input type="text" id="template" name="template" placeholder="" value="{{ $host->template}}" class="form-control">
@if($vm->power_state == 'POWERED_ON')
<span class="badge bg-success">Đang bật</span>
@elseif($vm->power_state == 'POWERED_OFF')
<span class="badge bg-secondary">Đang tắt</span>
@else
{{ $vm->power_state }}
@endif
</div>
</div>
{{--Console ID--}}
{{--CPU--}}
<div class="row form-group align-items-center mb-0">
<label for="console" class="col-md-3 text-right">Console Name</label>
<label for="cpu" class="col-md-3 text-right">CPU</label>
<div class="col-md-9 p-1 bg-customer">
<input type="text" id="console" name="console" placeholder="consolenode129.tgs.com.vn" value="{{ $host->console}}" class="form-control">
<input type="text" id="cpu" name="cpu" placeholder="" value="{{ $vm->cpu}}" class="form-control">
</div>
</div>
{{--RAM (MB)--}}
<div class="row form-group align-items-center mb-0">
<label for="ram_mb" class="col-md-3 text-right">RAM (MB)</label>
<div class="col-md-9 p-1 bg-customer">
<input type="text" id="ram_mb" name="ram_mb" placeholder="" value="{{ $vm->ram_mb}}" class="form-control">
</div>
</div>
{{--Datacenter--}}
<div class="row form-group align-items-center mb-0">
<label for="datacenter_id" class="col-md-3 text-right">Datacenter</label>
<div class="col-md-9 p-1 bg-customer">
<input type="text" id="datacenter_id" name="datacenter_id" placeholder="" value="{{ $vm->datacenter_id}}" class="form-control">
</div>
</div>
{{--Host--}}
<div class="row form-group align-items-center mb-0">
<label for="host_id" class="col-md-3 text-right">Host</label>
<div class="col-md-9 p-1 bg-customer">
<input type="text" id="host_id" name="host_id" placeholder="" value="{{ $vm->host_id}}" class="form-control">
</div>
</div>
</div>
<div class="card-footer">
<a href="{{ route('package.host.index') }}" class="btn btn-outline-secondary">Trở về</a>
<button type="submit" class="btn btn-outline-primary">Lưu dữ liệu</button>
<a href="{{ route('package.vm.index') }}" class="btn btn-secondary">Back</a>
<button type="submit" class="btn btn-primary">Save</button>
@if($vm->vm_id && $vm->power_state == 'POWERED_ON')
<a href="{{ route('admin.vm.console', ['vm_id' => $vm->vm_id]) }}" target="_blank" class="btn btn-info">
<i class="fas fa-terminal"></i> Console
</a>
@elseif($vm->vm_id)
<span class="btn btn-secondary disabled">
<i class="fas fa-terminal"></i> Console (Off)
</span>
@endif
</div>
</form>
</div>