@@ -101,6 +107,7 @@
const $existingList = $("#existingList");
const $searchbar = $("#searchbar");
+ const $showOnlyRunning = $("#showOnlyRunning");
const $showUnexposed = $("#showUnexposed");
// objects to store container entries
@@ -122,6 +129,22 @@
localStorage.setItem("showUnexposed", $showUnexposed.prop("checked"));
}
+ // load showOnlyRunning checkbox state from local storage
+ function loadShowOnlyRunningState() {
+ const storedState = localStorage.getItem("showOnlyRunning");
+ if (storedState !== null) {
+ $showOnlyRunning.prop("checked", storedState === "true");
+ }
+ }
+
+ // save showOnlyRunning checkbox state to local storage
+ function saveShowOnlyRunningState() {
+ localStorage.setItem(
+ "showOnlyRunning",
+ $showOnlyRunning.prop("checked")
+ );
+ }
+
// fetch docker containers
function getDockerContainers() {
$networkedList.html('
');
@@ -182,6 +205,14 @@
// process each container
containers.forEach((container) => {
+ // skip containers that are not running, if the checkbox is checked
+ if (
+ $showOnlyRunning.is(":checked") &&
+ container.State !== "running"
+ ) {
+ return;
+ }
+
// skip containers in network mode "none"
if (container.HostConfig.NetworkMode === "none") {
return;
@@ -227,8 +258,9 @@
// add the container to the networked list, using it's name as address
container.Ports.forEach((portObject) => {
// skip unexposed ports if the checkbox is not checked
- if (!portObject.PublicPort && !$showUnexposed.is(":checked"))
+ if (!portObject.PublicPort && !$showUnexposed.is(":checked")) {
return;
+ }
const port = portObject.PublicPort || portObject.PrivatePort;
@@ -389,6 +421,11 @@
getDockerContainers();
});
+ $showOnlyRunning.on("change", () => {
+ saveShowOnlyRunningState(); // save the new state to local storage
+ getDockerContainers();
+ });
+
// debounce searchbar input with 300ms delay, then filter list
// this prevents excessive calls to the filter function
$searchbar.on(