Procházet zdrojové kódy

Container links now use ServerIP address

lllllllillllllillll před 1 rokem
rodič
revize
23ec95c6a6
3 změnil soubory, kde provedl 13 přidání a 11 odebrání
  1. 1 1
      app.js
  2. 2 2
      components/dashCard.js
  3. 10 8
      functions/system.js

+ 1 - 1
app.js

@@ -39,7 +39,7 @@ app.use([
 
 // Start Express server
 const server = app.listen(PORT, async () => {
-    console.log(`App listening on port ${PORT}`);   
+    console.log(`App listening on port ${PORT}`);
 });
 
 // Start Socket.io

+ 2 - 2
components/dashCard.js

@@ -1,6 +1,6 @@
 module.exports.dashCard = function dashCard(data) {
   
-  let { name, service, id, state, image, external_port, internal_port, ports, volumes, environment_variables, labels } = data;
+  let { name, service, id, state, image, external_port, internal_port, ports, volumes, environment_variables, labels, IPv4 } = data;
   
   //disable controls for a docker container depending on its name
   let enabled = "";
@@ -160,7 +160,7 @@ module.exports.dashCard = function dashCard(data) {
           </div>
           <div class="d-flex align-items-baseline">
             <div class="h1 me-2" title="${name}">
-              <a href="http://localhost:${external_port}" target="_blank">
+              <a href="http://${IPv4}:${external_port}" target="_blank">
                 ${shortened_name}
               </a>
             </div>

+ 10 - 8
functions/system.js

@@ -6,20 +6,21 @@ const { Readable } = require('stream');
 
 const Containers = require('../database/ContainerSettings');
 
+// export docker
+module.exports.docker = docker;
+
+
+let IPv4 = '';
+networkInterfaces().then(data => {
+    IPv4 = data[0].ip4;
+});
+
 let hidden = '';
 module.exports.hiddenContainers = async function () {
     hidden = await Containers.findAll({ where: {visibility:false}});
     hidden = hidden.map(a => a.name);
 }
 
-async () => {
-let netif = await networkInterfaces();
-console.log(netif);
-}
-
-// export docker
-module.exports.docker = docker;
-
 module.exports.serverStats = async function () {
     const cpuUsage = await currentLoad();
     const ramUsage = await mem();
@@ -164,6 +165,7 @@ module.exports.containerList = async function () {
                 volumes: volumes_list,
                 environment_variables: environment_variables,
                 labels: labels,
+                IPv4: IPv4
             }
 
             let dockerCard = dashCard(container_info);