update
This commit is contained in:
parent
b9e8c6da2f
commit
7c19fe58a6
43
app.js
43
app.js
@ -299,9 +299,11 @@ function renderContainers(containers) {
|
|||||||
containerList.innerHTML = ''; // Clear the current list
|
containerList.innerHTML = ''; // Clear the current list
|
||||||
|
|
||||||
containers.forEach((container) => {
|
containers.forEach((container) => {
|
||||||
const name = container.Names[0].replace(/^\//, ''); // Remove leading slash from container names
|
const name = container.Names[0].replace(/^\//, ''); // Remove leading slash
|
||||||
const image = container.Image;
|
const image = container.Image;
|
||||||
const containerId = container.Id;
|
const containerId = container.Id;
|
||||||
|
const ipAddress = container.ipAddress || '-'; // Use the IP address field
|
||||||
|
|
||||||
const row = document.createElement('tr');
|
const row = document.createElement('tr');
|
||||||
row.dataset.containerId = containerId; // Store container ID for reference
|
row.dataset.containerId = containerId; // Store container ID for reference
|
||||||
row.innerHTML = `
|
row.innerHTML = `
|
||||||
@ -310,37 +312,32 @@ function renderContainers(containers) {
|
|||||||
<td>${container.State}</td>
|
<td>${container.State}</td>
|
||||||
<td class="cpu">0</td>
|
<td class="cpu">0</td>
|
||||||
<td class="memory">0</td>
|
<td class="memory">0</td>
|
||||||
<td class="ip-address">-</td>
|
<td class="ip-address">${ipAddress}</td>
|
||||||
<td>
|
<td>
|
||||||
<button class="btn btn-success btn-sm action-start" ${container.State === 'running' ? 'disabled' : ''}>
|
<button class="btn btn-success btn-sm action-start" ${container.State === 'running' ? 'disabled' : ''}>
|
||||||
<i class="fas fa-play"></i>
|
<i class="fas fa-play"></i>
|
||||||
</button>
|
</button>
|
||||||
<button class="btn btn-warning btn-sm action-stop" ${container.State !== 'running' ? 'disabled' : ''}>
|
<button class="btn btn-warning btn-sm action-stop" ${container.State !== 'running' ? 'disabled' : ''}>
|
||||||
<i class="fas fa-stop"></i>
|
<i class="fas fa-stop"></i>
|
||||||
</button>
|
</button>
|
||||||
<button class="btn btn-danger btn-sm action-remove">
|
<button class="btn btn-danger btn-sm action-remove">
|
||||||
<i class="fas fa-trash"></i>
|
<i class="fas fa-trash"></i>
|
||||||
</button>
|
</button>
|
||||||
<button class="btn btn-primary btn-sm action-terminal" ${container.State !== 'running' ? 'disabled' : ''}>
|
<button class="btn btn-primary btn-sm action-terminal" ${container.State !== 'running' ? 'disabled' : ''}>
|
||||||
<i class="fas fa-terminal"></i>
|
<i class="fas fa-terminal"></i>
|
||||||
</button>
|
</button>
|
||||||
<button class="btn btn-secondary btn-sm action-duplicate">
|
<button class="btn btn-secondary btn-sm action-duplicate">
|
||||||
<i class="fas fa-clone"></i>
|
<i class="fas fa-clone"></i>
|
||||||
</button>
|
</button>
|
||||||
</td>
|
</td>
|
||||||
`;
|
`;
|
||||||
containerList.appendChild(row);
|
containerList.appendChild(row);
|
||||||
|
|
||||||
// Add event listeners for action buttons
|
// Add event listeners for action buttons
|
||||||
addActionListeners(row, container);
|
addActionListeners(row, container);
|
||||||
|
|
||||||
// Add event listener for duplicate button
|
|
||||||
const duplicateBtn = row.querySelector('.action-duplicate');
|
|
||||||
duplicateBtn.addEventListener('click', () => openDuplicateModal(container));
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Add event listeners to action buttons
|
// Add event listeners to action buttons
|
||||||
function addActionListeners(row, container) {
|
function addActionListeners(row, container) {
|
||||||
const startBtn = row.querySelector('.action-start');
|
const startBtn = row.querySelector('.action-start');
|
||||||
|
@ -59,7 +59,19 @@ swarm.on('connection', (peer) => {
|
|||||||
case 'listContainers':
|
case 'listContainers':
|
||||||
console.log('[INFO] Handling \'listContainers\' command');
|
console.log('[INFO] Handling \'listContainers\' command');
|
||||||
const containers = await docker.listContainers({ all: true });
|
const containers = await docker.listContainers({ all: true });
|
||||||
response = { type: 'containers', data: containers };
|
|
||||||
|
// Fetch detailed network info for each container
|
||||||
|
const detailedContainers = await Promise.all(
|
||||||
|
containers.map(async (container) => {
|
||||||
|
const details = await docker.getContainer(container.Id).inspect();
|
||||||
|
const ipAddress = details.NetworkSettings.Networks
|
||||||
|
? Object.values(details.NetworkSettings.Networks)[0].IPAddress
|
||||||
|
: '-';
|
||||||
|
return { ...container, ipAddress }; // Add IP address to container data
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
response = { type: 'containers', data: detailedContainers };
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'inspectContainer':
|
case 'inspectContainer':
|
||||||
|
Loading…
Reference in New Issue
Block a user