|
|
@@ -389,6 +389,7 @@
|
|
|
<th>端口</th>
|
|
|
<th>用户名</th>
|
|
|
<th>状态</th>
|
|
|
+ <th>主机组</th>
|
|
|
<th>操作</th>
|
|
|
</tr>
|
|
|
</thead>
|
|
|
@@ -789,7 +790,7 @@
|
|
|
function renderHostsTable() {
|
|
|
const tbody = document.getElementById('hostTableBody');
|
|
|
if (hosts.length === 0) {
|
|
|
- tbody.innerHTML = '<tr><td colspan="6" style="text-align:center;color:#8899a6;padding:30px;">暂无主机,点击右上角添加</td></tr>';
|
|
|
+ tbody.innerHTML = '<tr><td colspan="7" style="text-align:center;color:#8899a6;padding:30px;">暂无主机,点击右上角添加</td></tr>';
|
|
|
return;
|
|
|
}
|
|
|
tbody.innerHTML = hosts.map(h => `
|
|
|
@@ -799,6 +800,7 @@
|
|
|
<td>${h.port || 22}</td>
|
|
|
<td>${h.username}</td>
|
|
|
<td><span class="status ${h.status || 'pending'}">${statusText(h.status)}</span></td>
|
|
|
+ <td>${(h.groups || []).join(', ') || '-'}</td>
|
|
|
<td>
|
|
|
<div class="action-group">
|
|
|
<button class="btn btn-info" id="testBtn_${h.id}" onclick="testConnection('${h.id}')">🔌 测试</button>
|
|
|
@@ -819,7 +821,7 @@
|
|
|
const groupsList = document.getElementById('groupsList');
|
|
|
groupsList.innerHTML = groups.map(g => `
|
|
|
<div style="display: inline-block; background: #2d3748; padding: 10px 15px; border-radius: 8px; margin: 5px;">
|
|
|
- <strong>${g.name}</strong> (${g.hosts?.length || 0}台)
|
|
|
+ <strong>${g.name}</strong> (${g.host_list?.length || 0}台)
|
|
|
<button class="btn btn-danger" onclick="deleteGroup('${g.name}')" style="margin-left: 10px;">删除</button>
|
|
|
</div>
|
|
|
`).join('');
|
|
|
@@ -1136,7 +1138,7 @@
|
|
|
<div class="group-checkbox-item" data-group="${g.name}" data-type="playbook">
|
|
|
<label class="checkbox-item">
|
|
|
<input type="checkbox" name="playbookGroups" value="${g.name}" onchange="toggleGroupHosts('${g.name}', 'playbook', this.checked)">
|
|
|
- <span class="group-toggle" onclick="toggleGroupExpand('${g.name}', 'playbook')">▶ ${g.name} (${g.hosts?.length || 0}台)</span>
|
|
|
+ <span class="group-toggle" onclick="toggleGroupExpand('${g.name}', 'playbook')">▶ ${g.name} (${g.host_list?.length || 0}台)</span>
|
|
|
</label>
|
|
|
<div class="group-hosts" id="playbook_group_${g.name}" style="display:none;margin-left:20px;border-left:2px solid #38444d;padding-left:10px;">
|
|
|
${(g.host_list || []).map(h => `
|
|
|
@@ -1157,7 +1159,7 @@
|
|
|
<div class="group-checkbox-item" data-group="${g.name}" data-type="cmd">
|
|
|
<label class="checkbox-item">
|
|
|
<input type="checkbox" name="cmdGroups" value="${g.name}" onchange="toggleGroupHosts('${g.name}', 'cmd', this.checked)">
|
|
|
- <span class="group-toggle" onclick="toggleGroupExpand('${g.name}', 'cmd')">▶ ${g.name} (${g.hosts?.length || 0}台)</span>
|
|
|
+ <span class="group-toggle" onclick="toggleGroupExpand('${g.name}', 'cmd')">▶ ${g.name} (${g.host_list?.length || 0}台)</span>
|
|
|
</label>
|
|
|
<div class="group-hosts" id="cmd_group_${g.name}" style="display:none;margin-left:20px;border-left:2px solid #38444d;padding-left:10px;">
|
|
|
${(g.host_list || []).map(h => `
|
|
|
@@ -1178,10 +1180,10 @@
|
|
|
const toggle = div.previousElementSibling.querySelector('.group-toggle');
|
|
|
if (div.style.display === 'none') {
|
|
|
div.style.display = 'block';
|
|
|
- toggle.textContent = '▼ ' + groupName + ' (' + (groups.find(g => g.name === groupName)?.hosts?.length || 0) + '台)';
|
|
|
+ toggle.textContent = '▼ ' + groupName + ' (' + (groups.find(g => g.name === groupName)?.host_list?.length || 0) + '台)';
|
|
|
} else {
|
|
|
div.style.display = 'none';
|
|
|
- toggle.textContent = '▶ ' + groupName + ' (' + (groups.find(g => g.name === groupName)?.hosts?.length || 0) + '台)';
|
|
|
+ toggle.textContent = '▶ ' + groupName + ' (' + (groups.find(g => g.name === groupName)?.host_list?.length || 0) + '台)';
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -1399,9 +1401,9 @@
|
|
|
if (groupList.length > 0) {
|
|
|
groupList.forEach(gName => {
|
|
|
const g = groups.find(gr => gr.name === gName);
|
|
|
- if (g && g.hosts) {
|
|
|
- g.hosts.forEach(hName => {
|
|
|
- if (!hostList.includes(hName)) hostList.push(hName);
|
|
|
+ if (g && g.host_list) {
|
|
|
+ g.host_list.forEach(h => {
|
|
|
+ if (!hostList.includes(h.name)) hostList.push(h.name);
|
|
|
});
|
|
|
}
|
|
|
});
|
|
|
@@ -1462,9 +1464,9 @@
|
|
|
if (groupList.length > 0) {
|
|
|
groupList.forEach(gName => {
|
|
|
const g = groups.find(gr => gr.name === gName);
|
|
|
- if (g && g.hosts) {
|
|
|
- g.hosts.forEach(hName => {
|
|
|
- if (!hostList.includes(hName)) hostList.push(hName);
|
|
|
+ if (g && g.host_list) {
|
|
|
+ g.host_list.forEach(h => {
|
|
|
+ if (!hostList.includes(h.name)) hostList.push(h.name);
|
|
|
});
|
|
|
}
|
|
|
});
|