|
|
|
|
@ -1,4 +1,4 @@
|
|
|
|
|
const tabs = ['basic', 'service', 'backups', 'jobs', 'invoices'];
|
|
|
|
|
const tabs = ['overview', 'service', 'configuration', 'backups', 'jobs'];
|
|
|
|
|
|
|
|
|
|
function el(tag, className = '', text) {
|
|
|
|
|
const node = document.createElement(tag);
|
|
|
|
|
@ -118,10 +118,10 @@ export function createAdminInstanceDetail({
|
|
|
|
|
const uuid = el('span', 'admin-instance-ip text-break');
|
|
|
|
|
uuid.append(el('span', 'admin-mono', text(vm.uuid)));
|
|
|
|
|
if (vm.uuid) uuid.append(copyButton(vm.uuid, '复制 UUID'));
|
|
|
|
|
const basic = byId('instance-panel-basic');
|
|
|
|
|
const overview = byId('instance-panel-overview');
|
|
|
|
|
const configuration = typeof renderConfiguration === 'function'
|
|
|
|
|
? renderConfiguration(vm) : [];
|
|
|
|
|
basic.replaceChildren(infoList([
|
|
|
|
|
overview.replaceChildren(infoList([
|
|
|
|
|
['实例编号', `#${vm.id}`], ['UUID', uuid], ['Agent 标识', text(vm.agent_name, '未记录')],
|
|
|
|
|
['生命周期', vm.display?.lifecycle], ['所属用户', text(vm.user_name, `用户 #${vm.user_id}`)],
|
|
|
|
|
['用户 ID', vm.user_id], ['宿主机', text(vm.host_name)], ['地区', text(vm.region, '未记录')],
|
|
|
|
|
@ -130,8 +130,10 @@ export function createAdminInstanceDetail({
|
|
|
|
|
['DNS', Array.isArray(vm.dns_servers) ? text(vm.dns_servers.join('、'), '未记录') : text(vm.dns_servers, '未记录')],
|
|
|
|
|
['带宽上限', vm.bandwidth_mbps ? `${vm.bandwidth_mbps} Mbps` : '未记录'],
|
|
|
|
|
['创建时间', date(vm.created_at)],
|
|
|
|
|
]), ...configuration);
|
|
|
|
|
byId('instance-panel-service').replaceChildren(infoList([
|
|
|
|
|
]));
|
|
|
|
|
byId('instance-panel-configuration').replaceChildren(...configuration);
|
|
|
|
|
const service = byId('instance-panel-service');
|
|
|
|
|
service.replaceChildren(infoList([
|
|
|
|
|
['套餐', text(vm.plan_name, '无关联套餐')], ['服务状态', vm.display?.service], ['网络状态', vm.display?.network],
|
|
|
|
|
['服务到期', vm.service_status === 'exempt' ? '免计费' : date(vm.service_expires_at)],
|
|
|
|
|
['剩余期限', vm.display?.expiry], ['本周期用量', vm.display?.traffic],
|
|
|
|
|
@ -154,7 +156,11 @@ export function createAdminInstanceDetail({
|
|
|
|
|
}
|
|
|
|
|
if (!payload.jobs?.length) jobs.append(el('p', 'text-muted py-3', '暂无任务记录。'));
|
|
|
|
|
if (payload.jobs_truncated) jobs.append(el('p', 'text-muted fs-12', '仅展示最近的任务记录。'));
|
|
|
|
|
const invoices = byId('instance-panel-invoices'); invoices.replaceChildren();
|
|
|
|
|
const invoiceSection = el('section', 'admin-instance-invoices mt-4 pt-4 border-top');
|
|
|
|
|
invoiceSection.append(el('div', 'd-flex align-items-center justify-content-between gap-2 mb-3'));
|
|
|
|
|
invoiceSection.firstChild.append(el('h3', 'h6 fw-semibold mb-0', '关联账单'),
|
|
|
|
|
el('span', 'badge text-bg-light', `${(payload.invoices || []).length} 笔`));
|
|
|
|
|
const invoices = el('div');
|
|
|
|
|
for (const invoice of payload.invoices || []) {
|
|
|
|
|
const card = el('article', 'card mb-3'); const body = el('div', 'card-body');
|
|
|
|
|
const purpose = ({ provision: '实例开通', renewal: '实例续费', upgrade: '实例升级' })[invoice.purpose]
|
|
|
|
|
@ -169,6 +175,7 @@ export function createAdminInstanceDetail({
|
|
|
|
|
}
|
|
|
|
|
if (!payload.invoices?.length) invoices.append(el('p', 'text-muted py-3', '暂无关联账单;导入或免计费实例可能没有开通账单。'));
|
|
|
|
|
if (payload.invoices_truncated) invoices.append(el('p', 'text-muted fs-12', '仅展示最近的关联账单。'));
|
|
|
|
|
invoiceSection.append(invoices); service.append(invoiceSection);
|
|
|
|
|
const control = byId('instance-control-link');
|
|
|
|
|
if (control instanceof HTMLAnchorElement && vm.detail_url) {
|
|
|
|
|
const link = safeLink(vm.detail_url, '');
|
|
|
|
|
@ -234,7 +241,7 @@ export function createAdminInstanceDetail({
|
|
|
|
|
byId('instance-detail-title').textContent = `实例 #${id}`;
|
|
|
|
|
const control = byId('instance-control-link'); if (control) control.hidden = true;
|
|
|
|
|
tabs.forEach(tab => byId(`instance-panel-${tab}`).replaceChildren());
|
|
|
|
|
chooseTab('basic'); notice('正在读取详情…');
|
|
|
|
|
chooseTab('overview'); notice('正在读取详情…');
|
|
|
|
|
if (!dialog.open) { lockScroll(); window.VenixDrawerMotion.openDrawerWithMotion(dialog); }
|
|
|
|
|
try {
|
|
|
|
|
const payload = await read(`/api/v1/admin/instances/${id}`, controller);
|
|
|
|
|
|