update
This commit is contained in:
@@ -0,0 +1,120 @@
|
||||
@php use Illuminate\Support\Carbon; @endphp
|
||||
@php use App\Http\Helpers\Helper; @endphp
|
||||
<div class="box clients-summary__box p-4">
|
||||
|
||||
<div class="row form-group">
|
||||
<table class="form" width="100%" border="0" cellspacing="2" cellpadding="3">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="fieldlabel">Order #</td>
|
||||
<td class="fieldarea">
|
||||
<strong>{{ $product->Order->id }}</strong> -
|
||||
<a href="{{ route('admin.order.edit', ['id' => $product->order->id]) }}">View Order</a>
|
||||
</td>
|
||||
<td class="fieldlabel">Registration Date</td>
|
||||
<td class="fieldarea">
|
||||
{!! Carbon::parse($product->Order->date)->format('d-m-Y') !!}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="fieldlabel">Product/Service</td>
|
||||
<td class="fieldarea">
|
||||
@isset($productName->name)
|
||||
{{ $productName->name }}
|
||||
@endisset
|
||||
</td>
|
||||
<td class="fieldlabel">Quantity</td>
|
||||
<td class="fieldarea"><strong>1</strong></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="fieldlabel">Server</td>
|
||||
<td class="fieldarea">
|
||||
|
||||
@if ($product->server)
|
||||
{{ $product->server->name }}
|
||||
@else
|
||||
Not Found
|
||||
@endif
|
||||
</td>
|
||||
<td class="fieldlabel">First Payment Amount</td>
|
||||
<td class="fieldarea">
|
||||
<input type="number" class="form-control" readonly name="first_payment"
|
||||
value="{{ $product->first_payment }}" id="">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="fieldlabel">Domain</td>
|
||||
<td class="fieldarea">
|
||||
<input type="text" class="form-control change-validate" placeholder="abc.com" name="name"
|
||||
value="{{ $product->name }}" id="">
|
||||
</td>
|
||||
<td class="fieldlabel">Recurring Amount</td>
|
||||
<td class="fieldarea">
|
||||
<input type="number" class="form-control" readonly name="first_payment"
|
||||
value="{{ $product->next_payment }}" id="">
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="fieldlabel">Billing Cycle</td>
|
||||
<td class="fieldarea">
|
||||
{!! $invoice_item ? $invoice_item->getBilling() : 'N/A' !!}
|
||||
</td>
|
||||
<td class="fieldlabel">Next Due Date</td>
|
||||
<td class="fieldarea">
|
||||
<input type="text" name="next_due_date" id="next_due_date"
|
||||
class="form-control datetime-picker" placeholder="dd/mm/yy"
|
||||
value=" {{ Carbon::parse($product->next_due_date)->format('d/m/Y') }}">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="fieldlabel">Payment Method</td>
|
||||
<td class="fieldarea">
|
||||
{{ $product->Order->Payment->name }}
|
||||
</td>
|
||||
<td class="fieldlabel">Status</td>
|
||||
<td class="fieldarea">
|
||||
{!! $product->getStatus() !!}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="fieldlabel">Username</td>
|
||||
<td class="fieldarea">
|
||||
<input type="text" class="form-control" name="username" value="{{ $product->username }}">
|
||||
</td>
|
||||
<td class="fieldlabel">Password</td>
|
||||
<td class="fieldarea">
|
||||
<input type="text" class="form-control" name="password"
|
||||
value="{{ $product->password ? SignRSA::DecryptFunc($product->password) : '' }}">
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="row form-group">
|
||||
<div class="col">
|
||||
<form action="{{ route('task.manager') }}" method="post">
|
||||
@csrf
|
||||
<input type="hidden" name="type" value="{{ $type }}">
|
||||
<input type="hidden" name="product" value="{{ $product->id }}">
|
||||
<input type="hidden" name="userid" value="{{ $userid }}">
|
||||
<input type="hidden" name="domain" value="{{ $product->name }}">
|
||||
<input type="hidden" name="action" value="create">
|
||||
<button type="submit" {{ $product->status === 0 ? '' : 'disabled' }}
|
||||
class="btn btn-block btn-outline-secondary">Create
|
||||
</button>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
<div class="col">
|
||||
<button type="button" class="btn btn-block btn-outline-secondary">Suspend</button>
|
||||
</div>
|
||||
<div class="col">
|
||||
<button type="button" class="btn btn-block btn-outline-secondary">Unsuspend</button>
|
||||
</div>
|
||||
<div class="col">
|
||||
<button type="button" class="btn btn-block btn-outline-secondary">Change Password</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@@ -0,0 +1,569 @@
|
||||
<script>
|
||||
const productId = {{ $product->id }};
|
||||
const vmId = '{{ $product->vmware_id }}';
|
||||
|
||||
// Cấu hình toast nếu có thể
|
||||
if (typeof FuiToast !== 'undefined' && FuiToast.config) {
|
||||
FuiToast.config({
|
||||
position: 'top-center'
|
||||
});
|
||||
}
|
||||
|
||||
function showNotification(message, type = 'success') {
|
||||
if (typeof FuiToast !== 'undefined') {
|
||||
if (type === 'success') {
|
||||
FuiToast.success(message);
|
||||
} else {
|
||||
FuiToast.error(message);
|
||||
}
|
||||
} else {
|
||||
alert(message);
|
||||
}
|
||||
}
|
||||
|
||||
async function startVirtualMachine() {
|
||||
const startBtn = document.getElementById('startVMButton');
|
||||
if (startBtn.disabled) return;
|
||||
|
||||
const accessToken = '{{ request()->cookie('accessToken') }}';
|
||||
if (!accessToken) {
|
||||
showNotification('Chưa đăng nhập, vui lòng đăng nhập lại', 'error');
|
||||
setTimeout(() => {
|
||||
window.location.href = '/login';
|
||||
}, 2000);
|
||||
return;
|
||||
}
|
||||
|
||||
const requestBody = {
|
||||
vm_id: vmId
|
||||
};
|
||||
|
||||
const headers = {
|
||||
'Content-Type': 'application/json',
|
||||
'Accept': 'application/json',
|
||||
'X-CSRF-TOKEN': '{{ csrf_token() }}',
|
||||
'Authorization': 'Bearer ' + accessToken
|
||||
};
|
||||
|
||||
const startPromise = fetch('/api/v1/start-virtual-machine', {
|
||||
method: 'POST',
|
||||
headers: headers,
|
||||
body: JSON.stringify(requestBody),
|
||||
credentials: 'same-origin'
|
||||
}).then(async (response) => {
|
||||
if (response.redirected || response.status === 401) {
|
||||
throw new Error('Phiên đăng nhập đã hết hạn, vui lòng đăng nhập lại');
|
||||
}
|
||||
|
||||
let data;
|
||||
try {
|
||||
data = await response.json();
|
||||
} catch (parseError) {
|
||||
throw new Error('Lỗi định dạng dữ liệu từ máy chủ');
|
||||
}
|
||||
|
||||
if (!data.error) {
|
||||
setTimeout(() => {
|
||||
location.reload();
|
||||
}, 2000);
|
||||
return data.message;
|
||||
} else {
|
||||
if (data.type === 'com.vmware.vapi.std.errors.already_in_desired_state' ||
|
||||
(data.message && data.message.error_type === 'ALREADY_IN_DESIRED_STATE')) {
|
||||
setTimeout(() => {
|
||||
location.reload();
|
||||
}, 2000);
|
||||
return 'Máy chủ đã được bật';
|
||||
} else {
|
||||
let errorMessage = 'Có lỗi xảy ra';
|
||||
if (data.message) {
|
||||
if (typeof data.message === 'object') {
|
||||
if (data.message.messages && data.message.messages.length > 0) {
|
||||
errorMessage = data.message.messages[0].default_message || data.message
|
||||
.messages[0]
|
||||
.message || 'Có lỗi xảy ra';
|
||||
} else if (data.message.error_type) {
|
||||
errorMessage = `Lỗi: ${data.message.error_type}`;
|
||||
} else {
|
||||
errorMessage = 'Có lỗi xảy ra từ hệ thống';
|
||||
}
|
||||
} else {
|
||||
errorMessage = data.message;
|
||||
}
|
||||
} else if (data.value && data.value.messages && data.value.messages.length > 0) {
|
||||
errorMessage = data.value.messages[0].default_message;
|
||||
} else if (typeof data === 'string') {
|
||||
errorMessage = data;
|
||||
} else if (data.error) {
|
||||
if (typeof data.error === 'object') {
|
||||
if (data.error.message) {
|
||||
errorMessage = data.error.message;
|
||||
} else if (data.error.toString && data.error.toString() !==
|
||||
'[object Object]') {
|
||||
errorMessage = data.error.toString();
|
||||
} else {
|
||||
errorMessage = 'Có lỗi xảy ra từ hệ thống';
|
||||
}
|
||||
} else {
|
||||
errorMessage = data.error;
|
||||
}
|
||||
}
|
||||
throw new Error(errorMessage);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (typeof FuiToast !== 'undefined' && FuiToast.promise) {
|
||||
FuiToast.promise(
|
||||
startPromise, {
|
||||
loading: 'Đang khởi động máy ảo...',
|
||||
success: (data) => {
|
||||
console.log(data);
|
||||
return data;
|
||||
},
|
||||
error: (error) => {
|
||||
console.error(error);
|
||||
return error.message || 'Có lỗi xảy ra khi khởi động máy ảo';
|
||||
}
|
||||
}, {
|
||||
isClose: true
|
||||
}
|
||||
);
|
||||
} else {
|
||||
showNotification('Đang khởi động máy ảo...', 'success');
|
||||
startPromise.then(data => {
|
||||
showNotification(data, 'success');
|
||||
}).catch(error => {
|
||||
showNotification(error.message || 'Có lỗi xảy ra khi khởi động máy ảo', 'error');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
async function stopVirtualMachine() {
|
||||
const stopBtn = document.getElementById('stopVMButton');
|
||||
if (stopBtn.disabled) return;
|
||||
|
||||
const accessToken = '{{ request()->cookie('accessToken') }}';
|
||||
if (!accessToken) {
|
||||
showNotification('Chưa đăng nhập, vui lòng đăng nhập lại', 'error');
|
||||
setTimeout(() => {
|
||||
window.location.href = '/login';
|
||||
}, 2000);
|
||||
return;
|
||||
}
|
||||
|
||||
const requestBody = {
|
||||
vm_id: vmId
|
||||
};
|
||||
|
||||
const headers = {
|
||||
'Content-Type': 'application/json',
|
||||
'Accept': 'application/json',
|
||||
'X-CSRF-TOKEN': '{{ csrf_token() }}',
|
||||
'Authorization': 'Bearer ' + accessToken
|
||||
};
|
||||
|
||||
const stopPromise = fetch('/api/v1/stop-virtual-machine', {
|
||||
method: 'POST',
|
||||
headers: headers,
|
||||
body: JSON.stringify(requestBody),
|
||||
credentials: 'same-origin'
|
||||
}).then(async (response) => {
|
||||
if (response.redirected || response.status === 401) {
|
||||
throw new Error('Phiên đăng nhập đã hết hạn, vui lòng đăng nhập lại');
|
||||
}
|
||||
|
||||
let data;
|
||||
try {
|
||||
data = await response.json();
|
||||
} catch (parseError) {
|
||||
throw new Error('Lỗi định dạng dữ liệu từ máy chủ');
|
||||
}
|
||||
|
||||
if (!data.error) {
|
||||
setTimeout(() => {
|
||||
location.reload();
|
||||
}, 2000);
|
||||
return data.message;
|
||||
} else {
|
||||
if (data.type === 'com.vmware.vapi.std.errors.already_in_desired_state' ||
|
||||
(data.message && data.message.error_type === 'ALREADY_IN_DESIRED_STATE')) {
|
||||
setTimeout(() => {
|
||||
location.reload();
|
||||
}, 2000);
|
||||
return 'Máy chủ đã được tắt';
|
||||
} else {
|
||||
let errorMessage = 'Có lỗi xảy ra';
|
||||
if (data.message) {
|
||||
if (typeof data.message === 'object') {
|
||||
if (data.message.messages && data.message.messages.length > 0) {
|
||||
errorMessage = data.message.messages[0].default_message || data.message
|
||||
.messages[0]
|
||||
.message || 'Có lỗi xảy ra';
|
||||
} else if (data.message.error_type) {
|
||||
errorMessage = `Lỗi: ${data.message.error_type}`;
|
||||
} else {
|
||||
errorMessage = 'Có lỗi xảy ra từ hệ thống';
|
||||
}
|
||||
} else {
|
||||
errorMessage = data.message;
|
||||
}
|
||||
} else if (data.value && data.value.messages && data.value.messages.length > 0) {
|
||||
errorMessage = data.value.messages[0].default_message;
|
||||
} else if (typeof data === 'string') {
|
||||
errorMessage = data;
|
||||
} else if (data.error) {
|
||||
if (typeof data.error === 'object') {
|
||||
if (data.error.message) {
|
||||
errorMessage = data.error.message;
|
||||
} else if (data.error.toString && data.error.toString() !==
|
||||
'[object Object]') {
|
||||
errorMessage = data.error.toString();
|
||||
} else {
|
||||
errorMessage = 'Có lỗi xảy ra từ hệ thống';
|
||||
}
|
||||
} else {
|
||||
errorMessage = data.error;
|
||||
}
|
||||
}
|
||||
throw new Error(errorMessage);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (typeof FuiToast !== 'undefined' && FuiToast.promise) {
|
||||
FuiToast.promise(
|
||||
stopPromise, {
|
||||
loading: 'Đang dừng máy ảo...',
|
||||
success: (data) => {
|
||||
console.log(data);
|
||||
return data;
|
||||
},
|
||||
error: (error) => {
|
||||
console.error(error);
|
||||
return error.message || 'Có lỗi xảy ra khi dừng máy ảo';
|
||||
}
|
||||
}, {
|
||||
isClose: true
|
||||
}
|
||||
);
|
||||
} else {
|
||||
showNotification('Đang dừng máy ảo...', 'success');
|
||||
stopPromise.then(data => {
|
||||
showNotification(data, 'success');
|
||||
}).catch(error => {
|
||||
showNotification(error.message || 'Có lỗi xảy ra khi dừng máy ảo', 'error');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
async function restartVirtualMachine() {
|
||||
const restartBtn = document.getElementById('restartVMButton');
|
||||
if (restartBtn.disabled) return;
|
||||
|
||||
const restartPromise = fetch(`/api/v1/restart-virtual-machine`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'X-CSRF-TOKEN': '{{ csrf_token() }}'
|
||||
},
|
||||
body: JSON.stringify({
|
||||
vm_id: vmId
|
||||
})
|
||||
}).then(async (response) => {
|
||||
let data;
|
||||
try {
|
||||
data = await response.json();
|
||||
} catch (parseError) {
|
||||
throw new Error('Lỗi định dạng dữ liệu từ máy chủ');
|
||||
}
|
||||
|
||||
if (data.success) {
|
||||
setTimeout(() => {
|
||||
location.reload();
|
||||
}, 2000);
|
||||
return data.message;
|
||||
} else {
|
||||
let errorMessage = 'Có lỗi xảy ra';
|
||||
if (data.message) {
|
||||
if (typeof data.message === 'object') {
|
||||
if (data.message.messages && data.message.messages.length > 0) {
|
||||
errorMessage = data.message.messages[0].default_message || data.message
|
||||
.messages[0]
|
||||
.message || 'Có lỗi xảy ra';
|
||||
} else if (data.message.error_type) {
|
||||
errorMessage = `Lỗi: ${data.message.error_type}`;
|
||||
} else {
|
||||
errorMessage = 'Có lỗi xảy ra từ hệ thống';
|
||||
}
|
||||
} else {
|
||||
errorMessage = data.message;
|
||||
}
|
||||
} else if (data.error) {
|
||||
if (typeof data.error === 'object') {
|
||||
if (data.error.message) {
|
||||
errorMessage = data.error.message;
|
||||
} else if (data.error.toString && data.error.toString() !== '[object Object]') {
|
||||
errorMessage = data.error.toString();
|
||||
} else {
|
||||
errorMessage = 'Có lỗi xảy ra từ hệ thống';
|
||||
}
|
||||
} else {
|
||||
errorMessage = data.error;
|
||||
}
|
||||
} else if (typeof data === 'string') {
|
||||
errorMessage = data;
|
||||
}
|
||||
throw new Error(errorMessage);
|
||||
}
|
||||
});
|
||||
|
||||
if (typeof FuiToast !== 'undefined' && FuiToast.promise) {
|
||||
FuiToast.promise(
|
||||
restartPromise, {
|
||||
loading: 'Đang khởi động lại máy ảo...',
|
||||
success: (data) => {
|
||||
console.log(data);
|
||||
return data;
|
||||
},
|
||||
error: (error) => {
|
||||
console.error(error);
|
||||
return error.message || 'Có lỗi xảy ra khi khởi động lại máy ảo';
|
||||
}
|
||||
}, {
|
||||
isClose: true
|
||||
}
|
||||
);
|
||||
} else {
|
||||
showNotification('Đang khởi động lại máy ảo...', 'success');
|
||||
restartPromise.then(data => {
|
||||
showNotification(data, 'success');
|
||||
}).catch(error => {
|
||||
showNotification(error.message || 'Có lỗi xảy ra khi khởi động lại máy ảo', 'error');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
async function suspendVirtualMachine() {
|
||||
const suspendBtn = document.getElementById('suspendVMButton');
|
||||
if (suspendBtn.disabled) return;
|
||||
|
||||
const suspendPromise = fetch(`/api/v1/suspend-virtual-machine`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'X-CSRF-TOKEN': '{{ csrf_token() }}'
|
||||
},
|
||||
body: JSON.stringify({
|
||||
vm_id: vmId
|
||||
})
|
||||
}).then(async (response) => {
|
||||
let data;
|
||||
try {
|
||||
data = await response.json();
|
||||
} catch (parseError) {
|
||||
throw new Error('Lỗi định dạng dữ liệu từ máy chủ');
|
||||
}
|
||||
|
||||
if (data.success) {
|
||||
setTimeout(() => {
|
||||
location.reload();
|
||||
}, 2000);
|
||||
return data.message;
|
||||
} else {
|
||||
let errorMessage = 'Có lỗi xảy ra';
|
||||
if (data.message) {
|
||||
if (typeof data.message === 'object') {
|
||||
if (data.message.messages && data.message.messages.length > 0) {
|
||||
errorMessage = data.message.messages[0].default_message || data.message
|
||||
.messages[0]
|
||||
.message || 'Có lỗi xảy ra';
|
||||
} else if (data.message.error_type) {
|
||||
errorMessage = `Lỗi: ${data.message.error_type}`;
|
||||
} else {
|
||||
errorMessage = 'Có lỗi xảy ra từ hệ thống';
|
||||
}
|
||||
} else {
|
||||
errorMessage = data.message;
|
||||
}
|
||||
} else if (data.error) {
|
||||
if (typeof data.error === 'object') {
|
||||
if (data.error.message) {
|
||||
errorMessage = data.error.message;
|
||||
} else if (data.error.toString && data.error.toString() !== '[object Object]') {
|
||||
errorMessage = data.error.toString();
|
||||
} else {
|
||||
errorMessage = 'Có lỗi xảy ra từ hệ thống';
|
||||
}
|
||||
} else {
|
||||
errorMessage = data.error;
|
||||
}
|
||||
} else if (typeof data === 'string') {
|
||||
errorMessage = data;
|
||||
}
|
||||
throw new Error(errorMessage);
|
||||
}
|
||||
});
|
||||
|
||||
if (typeof FuiToast !== 'undefined' && FuiToast.promise) {
|
||||
FuiToast.promise(
|
||||
suspendPromise, {
|
||||
loading: 'Đang tạm dừng máy ảo...',
|
||||
success: (data) => {
|
||||
console.log(data);
|
||||
return data;
|
||||
},
|
||||
error: (error) => {
|
||||
console.error(error);
|
||||
return error.message || 'Có lỗi xảy ra khi tạm dừng máy ảo';
|
||||
}
|
||||
}, {
|
||||
isClose: true
|
||||
}
|
||||
);
|
||||
} else {
|
||||
showNotification('Đang tạm dừng máy ảo...', 'success');
|
||||
suspendPromise.then(data => {
|
||||
showNotification(data, 'success');
|
||||
}).catch(error => {
|
||||
showNotification(error.message || 'Có lỗi xảy ra khi tạm dừng máy ảo', 'error');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
async function shutdownVirtualMachine() {
|
||||
const shutdownBtn = document.getElementById('shutdownVMButton');
|
||||
if (shutdownBtn.disabled) return;
|
||||
|
||||
const shutdownPromise = fetch(`/api/v1/shutdown-virtual-machine`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'X-CSRF-TOKEN': '{{ csrf_token() }}'
|
||||
},
|
||||
body: JSON.stringify({
|
||||
vm_id: vmId
|
||||
})
|
||||
}).then(async (response) => {
|
||||
let data;
|
||||
try {
|
||||
data = await response.json();
|
||||
} catch (parseError) {
|
||||
throw new Error('Lỗi định dạng dữ liệu từ máy chủ');
|
||||
}
|
||||
|
||||
if (data.success) {
|
||||
setTimeout(() => {
|
||||
location.reload();
|
||||
}, 2000);
|
||||
return data.message;
|
||||
} else {
|
||||
let errorMessage = 'Có lỗi xảy ra';
|
||||
if (data.message) {
|
||||
if (typeof data.message === 'object') {
|
||||
if (data.message.messages && data.message.messages.length > 0) {
|
||||
errorMessage = data.message.messages[0].default_message || data.message
|
||||
.messages[0]
|
||||
.message || 'Có lỗi xảy ra';
|
||||
} else if (data.message.error_type) {
|
||||
errorMessage = `Lỗi: ${data.message.error_type}`;
|
||||
} else {
|
||||
errorMessage = 'Có lỗi xảy ra từ hệ thống';
|
||||
}
|
||||
} else {
|
||||
errorMessage = data.message;
|
||||
}
|
||||
} else if (data.error) {
|
||||
if (typeof data.error === 'object') {
|
||||
if (data.error.message) {
|
||||
errorMessage = data.error.message;
|
||||
} else if (data.error.toString && data.error.toString() !== '[object Object]') {
|
||||
errorMessage = data.error.toString();
|
||||
} else {
|
||||
errorMessage = 'Có lỗi xảy ra từ hệ thống';
|
||||
}
|
||||
} else {
|
||||
errorMessage = data.error;
|
||||
}
|
||||
} else if (typeof data === 'string') {
|
||||
errorMessage = data;
|
||||
}
|
||||
throw new Error(errorMessage);
|
||||
}
|
||||
});
|
||||
|
||||
if (typeof FuiToast !== 'undefined' && FuiToast.promise) {
|
||||
FuiToast.promise(
|
||||
shutdownPromise, {
|
||||
loading: 'Đang shutdown máy ảo...',
|
||||
success: (data) => {
|
||||
console.log(data);
|
||||
return data;
|
||||
},
|
||||
error: (error) => {
|
||||
console.error(error);
|
||||
return error.message || 'Có lỗi xảy ra khi shutdown máy ảo';
|
||||
}
|
||||
}, {
|
||||
isClose: true
|
||||
}
|
||||
);
|
||||
} else {
|
||||
showNotification('Đang shutdown máy ảo...', 'success');
|
||||
shutdownPromise.then(data => {
|
||||
showNotification(data, 'success');
|
||||
}).catch(error => {
|
||||
showNotification(error.message || 'Có lỗi xảy ra khi shutdown máy ảo', 'error');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// DOM ready
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
const startBtn = document.getElementById('startVMButton');
|
||||
const stopBtn = document.getElementById('stopVMButton');
|
||||
const restartBtn = document.getElementById('restartVMButton');
|
||||
const suspendBtn = document.getElementById('suspendVMButton');
|
||||
const shutdownBtn = document.getElementById('shutdownVMButton');
|
||||
|
||||
if (startBtn) {
|
||||
startBtn.addEventListener('click', function(e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
startVirtualMachine();
|
||||
});
|
||||
}
|
||||
|
||||
if (stopBtn) {
|
||||
stopBtn.addEventListener('click', function(e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
stopVirtualMachine();
|
||||
});
|
||||
}
|
||||
|
||||
if (restartBtn) {
|
||||
restartBtn.addEventListener('click', function(e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
restartVirtualMachine();
|
||||
});
|
||||
}
|
||||
|
||||
if (suspendBtn) {
|
||||
suspendBtn.addEventListener('click', function(e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
suspendVirtualMachine();
|
||||
});
|
||||
}
|
||||
|
||||
if (shutdownBtn) {
|
||||
shutdownBtn.addEventListener('click', function(e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
shutdownVirtualMachine();
|
||||
});
|
||||
}
|
||||
});
|
||||
</script>
|
||||
@@ -0,0 +1,431 @@
|
||||
<div class="box clients-summary__box p-4">
|
||||
<div class="row form-group">
|
||||
<table class="form" width="100%" border="0" cellspacing="2" cellpadding="3">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="fieldlabel">Order #</td>
|
||||
<td class="fieldarea">
|
||||
<strong>{{ $product->order->id }}</strong> -
|
||||
<a href="{{ route('admin.order.edit', ['id' => $product->order->id]) }}">View Order</a>
|
||||
</td>
|
||||
<td class="fieldlabel">Registration Date</td>
|
||||
<td class="fieldarea">
|
||||
@isset($product->order->date)
|
||||
@time($product->order->date)
|
||||
@endisset
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="fieldlabel">Product/Service</td>
|
||||
<td class="fieldarea">
|
||||
@isset($productName->name)
|
||||
{{ $productName->name }}
|
||||
@endisset
|
||||
</td>
|
||||
<td class="fieldlabel">Quantity</td>
|
||||
<td class="fieldarea"><strong>1</strong></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="fieldlabel">Server</td>
|
||||
<td class="fieldarea">
|
||||
@isset($product->ipaddress->host->datacenter->vCenter->host)
|
||||
{{ $product->ipaddress->host->datacenter->vCenter->host }}
|
||||
@endisset
|
||||
</td>
|
||||
<td class="fieldlabel">First Payment Amount</td>
|
||||
<td class="fieldarea">
|
||||
<input type="number" class="form-control" readonly name="first_payment"
|
||||
value="{{ $product->first_payment }}" id="">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="fieldlabel">IP Address</td>
|
||||
<td class="fieldarea">
|
||||
@isset($product->ipaddress->ip)
|
||||
{{ $product->ipaddress->ip }}
|
||||
@endisset
|
||||
</td>
|
||||
<td class="fieldlabel">Recurring Amount</td>
|
||||
<td class="fieldarea">
|
||||
<input type="number" class="form-control" name="next_payment_input"
|
||||
value="{{ $product->next_payment }}" id="">
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="fieldlabel">Billing Cycle</td>
|
||||
<td class="fieldarea">
|
||||
{{-- {{ Helpers::BillingCycle($product->getInvoiceItem()->billing) }} --}}
|
||||
{!! $invoice_item ? $invoice_item->getBilling() : 'N/A' !!}
|
||||
</td>
|
||||
<td class="fieldlabel">Next Due Date</td>
|
||||
<td class="fieldarea">
|
||||
<input type="text" name="next_due_date_input" id="next_due_date"
|
||||
class="form-control datetime-picker" placeholder="dd/mm/yy" value="@time($product->next_due_date_input)">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="fieldlabel">Payment Method</td>
|
||||
<td class="fieldarea">
|
||||
@isset($product->order->payment->name)
|
||||
{{ $product->order->payment->name }}
|
||||
@endisset
|
||||
</td>
|
||||
<td class="fieldlabel">Status</td>
|
||||
<td class="fieldarea">
|
||||
<select name="select_status" class="form-control">
|
||||
<option value="1" @selected($product->status == 1)>Active</option>
|
||||
<option value="2" @selected($product->status == 2)>Suspend</option>
|
||||
<option value="3" @selected($product->status == 3)>Pending</option>
|
||||
<option value="0" @selected($product->status == 0)>Power Off</option>
|
||||
<option value="4" @selected($product->status == 4)>Expiry</option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="fieldlabel">Username</td>
|
||||
<td class="fieldarea">
|
||||
<input type="text" class="form-control" readonly name="username"
|
||||
value="{{ $product->user }}">
|
||||
</td>
|
||||
<td class="fieldlabel">Password</td>
|
||||
<td class="fieldarea">
|
||||
<input type="text" class="form-control" readonly name="password"
|
||||
value="{{ $product->password ? SignRSA::DecryptFunc($product->password) : '' }}">
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<!-- VM Information Section -->
|
||||
<div class="card mt-4">
|
||||
<div class="card-header">
|
||||
<h5 class="mb-0">Thông tin máy ảo</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<table class="table table-sm table-borderless">
|
||||
<tr>
|
||||
<td class="text-muted">Tên VM:</td>
|
||||
<td>{{ $product->name ?? 'Chưa đặt tên' }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="text-muted">Trạng thái:</td>
|
||||
<td>
|
||||
@if ($product->status == 1)
|
||||
<span class="badge badge-success">Đang chạy</span>
|
||||
@elseif($product->status == 2)
|
||||
<span class="badge badge-warning">Tạm dừng</span>
|
||||
@elseif($product->status == 3)
|
||||
<span class="badge badge-info">Đang khởi tạo</span>
|
||||
@elseif($product->status == 0)
|
||||
<span class="badge badge-danger">Đã dừng</span>
|
||||
@elseif($product->status == 4)
|
||||
<span class="badge badge-secondary">Hết hạn</span>
|
||||
@else
|
||||
<span class="badge badge-secondary">Không xác định</span>
|
||||
@endif
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="text-muted">Hostname:</td>
|
||||
<td>{{ $product->hostname ?? 'N/A' }}</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<table class="table table-sm table-borderless">
|
||||
<tr>
|
||||
<td width="30%" class="text-muted">IP Address:</td>
|
||||
<td><code>{{ $product->ipaddress->ip ?? 'N/A' }}</code></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="text-muted">Username:</td>
|
||||
<td>{{ $product->user ?? 'N/A' }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="text-muted">Hệ điều hành:</td>
|
||||
<td>
|
||||
@if (isset($product->os) && isset($product->os->osGroup))
|
||||
{{ $product->os->osGroup->name ?? 'Unknown' }} {{ $product->os->version ?? '' }}
|
||||
@else
|
||||
N/A
|
||||
@endif
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="text-muted">vCenter:</td>
|
||||
<td>
|
||||
@if (
|
||||
isset($product->ipaddress) &&
|
||||
isset($product->ipaddress->host) &&
|
||||
isset($product->ipaddress->host->datacenter) &&
|
||||
isset($product->ipaddress->host->datacenter->vCenter)
|
||||
)
|
||||
{{ $product->ipaddress->host->datacenter->vCenter->host ?? 'N/A' }}
|
||||
@else
|
||||
N/A
|
||||
@endif
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Windows Login Info -->
|
||||
@if (isset($product->os) && isset($product->os->osGroup) && $product->os->osGroup->name == 'Windows')
|
||||
<div class="alert alert-info mt-3">
|
||||
<h6><i class="fas fa-info-circle"></i> Thông tin đăng nhập Windows</h6>
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<strong>Username:</strong> <code>administrator</code>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<strong>Password:</strong> <code>TGS@123</code>
|
||||
<button type="button" onclick="navigator.clipboard.writeText('TGS@123')"
|
||||
class="btn btn-sm btn-outline-primary ml-2">Copy</button>
|
||||
</div>
|
||||
</div>
|
||||
<small class="text-muted">* Đổi mật khẩu sau khi đăng nhập lần đầu để bảo mật tốt hơn.</small>
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- VM Control Section -->
|
||||
<div class="card mt-4">
|
||||
<div class="card-header">
|
||||
<h5 class="mb-0">Điều khiển VM</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="row">
|
||||
<!-- Power On -->
|
||||
<div class="col-md-3 col-sm-6 mb-2">
|
||||
<button type="button" id="startVMButton" class="btn btn-success btn-block">
|
||||
<i class="fas fa-play"></i> Khởi động
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- Power Off -->
|
||||
<div class="col-md-3 col-sm-6 mb-2">
|
||||
<button type="button" id="stopVMButton" class="btn btn-danger btn-block">
|
||||
<i class="fas fa-stop"></i> Tắt máy
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- Shutdown Guest -->
|
||||
<div class="col-md-3 col-sm-6 mb-2">
|
||||
<button type="button" id="shutdownVMButton" class="btn btn-warning btn-block">
|
||||
<i class="fas fa-power-off"></i> Shutdown
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- Suspend -->
|
||||
<div class="col-md-3 col-sm-6 mb-2">
|
||||
<button type="button" id="suspendVMButton" class="btn btn-secondary btn-block"
|
||||
{{ $product->status === 2 ? 'disabled' : '' }}>
|
||||
<i class="fas fa-pause"></i> Tạm dừng
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- Restart -->
|
||||
<div class="col-md-3 col-sm-6 mb-2">
|
||||
<button type="button" id="restartVMButton" class="btn btn-info btn-block">
|
||||
<i class="fas fa-redo"></i> Khởi động lại
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- Console -->
|
||||
<div class="col-md-3 col-sm-6 mb-2">
|
||||
<a href="{{ route('task.console', ['product' => $product->id, 'vmware-id' => $product->vmware_id]) }}"
|
||||
target="_blank" class="btn btn-dark btn-block">
|
||||
<i class="fas fa-terminal"></i> Console
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<!-- Reinstall -->
|
||||
<div class="col-md-3 col-sm-6 mb-2">
|
||||
<button type="button" data-toggle="modal" data-target="#modal-lg"
|
||||
class="btn btn-outline-secondary btn-block" data-ajax="{{ route('task.reinstall') }}">
|
||||
Cài lại
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Status Info -->
|
||||
<div class="mt-3 p-3 bg-light">
|
||||
<h6 class="mb-2">Thông tin chi tiết:</h6>
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<small class="text-muted">Trạng thái VM:</small>
|
||||
@if ($product->status == 1)
|
||||
<span class="badge badge-success ml-1">Đang chạy</span>
|
||||
@elseif($product->status == 2)
|
||||
<span class="badge badge-warning ml-1">Tạm dừng</span>
|
||||
@elseif($product->status == 3)
|
||||
<span class="badge badge-info ml-1">Đang khởi tạo</span>
|
||||
@elseif($product->status == 0)
|
||||
<span class="badge badge-danger ml-1">Đã dừng</span>
|
||||
@elseif($product->status == 4)
|
||||
<span class="badge badge-secondary ml-1">Hết hạn</span>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mt-1">
|
||||
<div class="col-md-6">
|
||||
<small class="text-muted">IP Address:</small>
|
||||
<code>{{ $product->ipaddress->ip ?? 'N/A' }}</code>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<small class="text-muted">Ngày tạo:</small>
|
||||
{{ $product->order->date ? \Carbon\Carbon::parse($product->order->date)->format('d/m/Y H:i') : 'N/A' }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Notes -->
|
||||
<div class="alert alert-light mt-3 mb-0">
|
||||
<small>
|
||||
<strong>Lưu ý:</strong><br>
|
||||
• Các thao tác có thể mất vài giây để hoàn thành<br>
|
||||
• VM sẽ được khởi động lại sau khi thay đổi cấu hình<br>
|
||||
• Vui lòng đợi thao tác hoàn thành trước khi thực hiện tiếp<br>
|
||||
• Console sẽ mở trong tab mới
|
||||
</small>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<form action="{{ route('customer.product.update') }}" method="post">
|
||||
<div class="box bg-white rounded p-3">
|
||||
@csrf
|
||||
@method('put')
|
||||
|
||||
<input type="hidden" name="next_due_date"
|
||||
value="{{ (session('next_due_date') ? \Carbon\Carbon::parse(session('next_due_date'))->format('d/m/Y') : null) ?? ($product->next_due_date ? \Carbon\Carbon::parse($product->next_due_date)->format('d/m/Y') : null) }}">
|
||||
<input type="hidden" name="next_payment"
|
||||
value="{{ session('next_payment') ?? $product->next_payment }}">
|
||||
<input type="hidden" name="product_id" value="{{ session('product_id') ?? $product->id }}">
|
||||
<input type="hidden" name="product_type" value="4">
|
||||
<input type="hidden" name="status" value="{{ session('status') ?? $product->status }}">
|
||||
|
||||
{{-- Vmware Name --}}
|
||||
<div class="row form-group align-items-center mb-0">
|
||||
<label for="name" class="col-md-3 text-right">VM Name</label>
|
||||
<div class="col-md-9 p-1 bg-customer">
|
||||
<input type="text" name="name" class="form-control" id="name"
|
||||
value="{{ session('name') ?? $product->name }}">
|
||||
</div>
|
||||
</div>
|
||||
{{-- Vmware Hostname --}}
|
||||
<div class="row form-group align-items-center mb-0">
|
||||
<label for="hostname" class="col-md-3 text-right">VM Hostname</label>
|
||||
<div class="col-md-9 p-1 bg-customer">
|
||||
<input type="text" name="hostname" class="form-control" id="hostname"
|
||||
value="{{ session('hostname') ?? $product->hostname }}">
|
||||
</div>
|
||||
</div>
|
||||
{{-- Vmware Port --}}
|
||||
<div class="row form-group align-items-center mb-0">
|
||||
<label for="port" class="col-md-3 text-right">VM Port</label>
|
||||
<div class="col-md-9 p-1 bg-customer">
|
||||
<input type="text" name="port" class="form-control" id="port"
|
||||
value="{{ session('port') ?? $product->port }}">
|
||||
</div>
|
||||
</div>
|
||||
{{-- Username --}}
|
||||
<div class="row form-group align-items-center mb-0">
|
||||
<label for="user" class="col-md-3 text-right">Username</label>
|
||||
<div class="col-md-9 p-1 bg-customer">
|
||||
<input type="text" name="user" class="form-control" id="user"
|
||||
value="{{ session('user') ?? $product->user }}">
|
||||
</div>
|
||||
</div>
|
||||
{{-- Password --}}
|
||||
<div class="row form-group align-items-center mb-0">
|
||||
<label for="password" class="col-md-3 text-right">Password</label>
|
||||
<div class="col-md-9 p-1 bg-customer">
|
||||
<input type="text" name="password" class="form-control" id="password"
|
||||
value="{{ session('password') ?? ($product->password ? SignRSA::DecryptFunc($product->password) : '') }}">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{-- vmware_id --}}
|
||||
<div class="row form-group align-items-center mb-0">
|
||||
<label for="vmware_id" class="col-md-3 text-right">VirtualMachine ID</label>
|
||||
<div class="col-md-9 p-1 bg-customer">
|
||||
<input type="text" name="vmware_id" class="form-control" id="vmware_id"
|
||||
value="{{ session('vmware_id') ?? $product->vmware_id }}">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{-- vCenter --}}
|
||||
<x-module.v-center :model="$product" />
|
||||
|
||||
{{-- Datacenter --}}
|
||||
<x-module.datacenter :model="$product" />
|
||||
|
||||
{{-- Host --}}
|
||||
<x-module.host :model="$product" />
|
||||
|
||||
{{-- Network --}}
|
||||
<x-module.network :model="$product" />
|
||||
|
||||
{{-- IP Address --}}
|
||||
<x-module.ip-address :model="$product" />
|
||||
|
||||
{{-- OS Group --}}
|
||||
<x-module.os :model="$product" />
|
||||
|
||||
{{-- OS Version --}}
|
||||
<x-module.os-version :model="$product" />
|
||||
</div>
|
||||
<div class="card-footer text-center">
|
||||
<button type="submit" class="btn bg-gradient-success">
|
||||
<i class="far fa-check-circle"></i>
|
||||
Save
|
||||
</button>
|
||||
<a href="{{ route('customer.index') }}" class="btn bg-gradient-secondary">Cancel
|
||||
</a>
|
||||
</div>
|
||||
</form>
|
||||
<div class="modal fade" id="modal-lg">
|
||||
<div class="modal-dialog modal-lg">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title">Configuration for create VPS</h4>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<form action="{{ route('task.manager') }}" method="post">
|
||||
@csrf
|
||||
<div class="modal-body">
|
||||
<input type="hidden" name="type" value="{{ $type }}">
|
||||
<input type="hidden" name="product" value="{{ $product->id }}">
|
||||
<input type="hidden" name="userid" value="{{ $userid }}">
|
||||
<input type="hidden" class="form-action" name="action" value="create">
|
||||
|
||||
<x-module.v-center :model="null" />
|
||||
<x-module.datacenter :model="null" />
|
||||
<x-module.host :model="null" />
|
||||
<x-module.network :model="null" />
|
||||
<x-module.os :model="null" />
|
||||
{{-- <x-module.os-version :model="null" /> --}}
|
||||
</div>
|
||||
<div class="modal-footer justify-content-between">
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
|
||||
<button type="submit" class="btn btn-primary">Save changes</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<!-- /.modal-content -->
|
||||
</div>
|
||||
<!-- /.modal-dialog -->
|
||||
</div>
|
||||
@include('admin.customer.action.addon')
|
||||
</div>
|
||||
|
||||
@include('admin.customer.form.scripts.vps')
|
||||
Reference in New Issue
Block a user