more try blocks - issue #87

This commit is contained in:
lllllllillllllillll 2024-06-18 17:40:27 -07:00
parent c31131fef5
commit fc963b662d
1 changed files with 7 additions and 7 deletions

View File

@ -3,16 +3,18 @@ import { docker } from '../server.js';
export const Networks = async function(req, res) {
let container_networks = [];
let network_name = '';
// List all containers
let containers = await docker.listContainers({ all: true });
for (let i = 0; i < containers.length; i++) {
let network_name = containers[i].HostConfig.NetworkMode;
try { container_networks.push(containers[i].NetworkSettings.Networks[network_name].NetworkID) } catch {}
// try { network_name = Object.keys(containers[i].NetworkSettings.Networks)[0] }
try { network_name += containers[i].HostConfig.NetworkMode; } catch {}
try { container_networks.push(containers[i].NetworkSettings.Networks[network_name].NetworkID); } catch {}
}
let networks = await docker.listNetworks({ all: true });
let network_list = `
@ -35,9 +37,7 @@ export const Networks = async function(req, res) {
// let created = date.toLocaleDateString('en-US', { month: 'long', day: 'numeric', year: 'numeric' });
let status = '';
if (container_networks.includes(networks[i].Id)) {
status = `In use`;
}
try { if (container_networks.includes(networks[i].Id)) { status = `In use`; } } catch {}
let details = `
<tr>