@@ -25,8 +25,9 @@ function renderContainerRow($nameHash, $return)
2525 $ containerSettings = apiRequest ('database-getContainerFromHash ' , ['hash ' => $ nameHash ])['result ' ];
2626 $ logo = getIcon ($ process ['inspect ' ]);
2727 $ notificationIcon = '<i id="disableNotifications-icon- ' . $ nameHash . '" class="fas fa-bell-slash text-muted" title="Notifications disabled for this container" style="display: ' . ($ containerSettings ['disableNotifications ' ] ? 'inline-block ' : 'none ' ) . '"></i> ' ;
28+ $ isRunning = $ process ['State ' ] == 'running ' ;
2829
29- if ($ process [ ' State ' ] == ' running ' ) {
30+ if ($ isRunning ) {
3031 $ control = '<i style=" ' . ($ skipActions ? 'display: none; ' : '' ) . ' cursor: pointer;" id="restart-btn- ' . $ nameHash . '" class="fas fa-sync-alt text-success container-restart-btn me-2" title="Restart" onclick="$( \'#massTrigger- ' . $ nameHash . '\').prop( \'checked \', true); $( \'#massContainerTrigger \').val(2); massApplyContainerTrigger();"></i> ' ;
3132 $ control .= '<i style=" ' . ($ skipActions ? 'display: none; ' : '' ) . ' cursor: pointer;" id="stop-btn- ' . $ nameHash . '" class="fas fa-power-off text-danger container-stop-btn" title="Stop" onclick="$( \'#massTrigger- ' . $ nameHash . '\').prop( \'checked \', true); $( \'#massContainerTrigger \').val(3); massApplyContainerTrigger();"></i> ' ;
3233 } else {
@@ -106,14 +107,19 @@ function renderContainerRow($nameHash, $return)
106107 }
107108 }
108109
109- $ portList = $ previewPort = '' ;
110+ $ portList = $ previewPort = $ tcpPort = '' ;
110111 if ($ process ['inspect ' ][0 ]['HostConfig ' ]['PortBindings ' ]) {
111112 $ ports = [];
112113
113114 foreach ($ process ['inspect ' ][0 ]['HostConfig ' ]['PortBindings ' ] as $ internalBind => $ portBinds ) {
114115 foreach ($ portBinds as $ portBind ) {
115116 if ($ portBind ['HostPort ' ]) {
116117 $ ports [] = $ internalBind . ' → ' . $ portBind ['HostPort ' ];
118+
119+ //-- TODO: This is likely not the best way to find the right port when multiple ports are used
120+ if (str_contains ($ internalBind , 'tcp ' )) {
121+ $ tcpPort = $ portBind ['HostPort ' ];
122+ }
117123 }
118124 }
119125 }
@@ -136,6 +142,10 @@ function renderContainerRow($nameHash, $return)
136142 }
137143 }
138144
145+ if ($ tcpPort ) {
146+ $ containerLink = $ _SERVER ['REQUEST_SCHEME ' ] . ':// ' . $ _SERVER ['SERVER_NAME ' ] . ': ' . $ tcpPort ;
147+ }
148+
139149 $ envList = $ previewEnv = '' ;
140150 if ($ process ['inspect ' ][0 ]['Config ' ]['Env ' ]) {
141151 $ env = [];
@@ -187,7 +197,9 @@ function renderContainerRow($nameHash, $return)
187197 $ network = 'container: ' . $ docker ->findContainer (['id ' => $ containerId , 'data ' => $ processList ]);
188198 }
189199
190- $ isCompose = isComposeContainer ($ process ['Names ' ]) ? '<i class="fab fa-octopus-deploy me-2 text-muted" title="This container has a compose file"></i> ' : '' ;
200+ $ isCompose = isComposeContainer ($ process ['Names ' ]) ? '<i class="fab fa-octopus-deploy me-2 text-muted" title="This container has a compose file"></i> ' : '' ;
201+ //-- TODO: This is likely not to work in every scenario (other networks, reverse proxies, etc)
202+ $ openLink = $ isRunning && $ tcpPort && !$ isDockwatch ? ' <i style="cursor:pointer;" class="text-primary fas fa-external-link-alt fa-xs" title="Open container" onclick="window.open( \'' . $ containerLink . '\')"></i> ' : '' ;
191203 ?>
192204 <tr id="<?= $ nameHash ?> " <?= $ groupHash ? 'class=" ' . $ groupHash . ' container-group-row bg-primary" style="display: none;" ' : '' ?> >
193205 <!-- COLUMN: CHECKBOX -->
@@ -200,9 +212,9 @@ function renderContainerRow($nameHash, $return)
200212 <!-- STOP/START ICONS -->
201213 <div class="col-sm-12 col-lg-1" id="<?= $ nameHash ?> -control"><?= $ control ?> </div>
202214 <!-- NAME, REPOSITORY -->
203- <div class="col-sm-12 col-lg-10" style="cursor:pointer;" onclick="containerInfo(' <?= $ nameHash ?> ')" >
204- <span> <?= $ notificationIcon . $ isCompose . $ process ['Names ' ] ?> </span>
205- <br><span class="text-muted small-text" title="<?= $ docker ->isIO ($ process ['inspect ' ][0 ]['Config ' ]['Image ' ]) ?> "><?= truncateMiddle ($ docker ->isIO ($ process ['inspect ' ][0 ]['Config ' ]['Image ' ]), 30 ) ?> </span>
215+ <div class="col-sm-12 col-lg-10">
216+ <span style="cursor:pointer;" onclick="containerInfo(' <?= $ nameHash ?> ')"> <?= $ notificationIcon . $ isCompose . $ process ['Names ' ] ?> </span> <?= $ openLink ? >
217+ <br><span style="cursor:pointer;" onclick="containerInfo(' <?= $ nameHash ?> ')" class="text-muted small-text" title="<?= $ docker ->isIO ($ process ['inspect ' ][0 ]['Config ' ]['Image ' ]) ?> "><?= truncateMiddle ($ docker ->isIO ($ process ['inspect ' ][0 ]['Config ' ]['Image ' ]), 30 ) ?> </span>
206218 </div>
207219 </div>
208220 </td>
0 commit comments