mirror of
https://github.com/tobychui/zoraxy.git
synced 2025-06-04 22:57:20 +02:00
Fix existings containers list in docker popup
This commit is contained in:
parent
1d965da7d0
commit
1b3a9de378
@ -34,7 +34,7 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
const lines = {};
|
const lines = {};
|
||||||
const linesAded = [];
|
const linesAded = {};
|
||||||
|
|
||||||
function getDockerContainers() {
|
function getDockerContainers() {
|
||||||
const hostRequest = $.get("/api/proxy/list?type=host");
|
const hostRequest = $.get("/api/proxy/list?type=host");
|
||||||
@ -54,7 +54,9 @@
|
|||||||
Config: [{ Gateway: gateway }],
|
Config: [{ Gateway: gateway }],
|
||||||
},
|
},
|
||||||
} = bridge;
|
} = bridge;
|
||||||
const existedDomains = hostData.map(({ Domain }) => Domain);
|
const existedDomains = hostData.reduce((acc, { ActiveOrigins }) => {
|
||||||
|
return acc.concat(ActiveOrigins.map(({ OriginIpOrDomain }) => OriginIpOrDomain));
|
||||||
|
}, []);
|
||||||
|
|
||||||
for (const container of containers) {
|
for (const container of containers) {
|
||||||
const {
|
const {
|
||||||
@ -63,19 +65,20 @@
|
|||||||
} = container;
|
} = container;
|
||||||
|
|
||||||
for (const portObject of Ports.filter(
|
for (const portObject of Ports.filter(
|
||||||
({ IP: ip }) => ip === "::"
|
({ IP: ip }) => ip === "::" || ip === '0.0.0.0'
|
||||||
)) {
|
)) {
|
||||||
const { IP: ip, PublicPort: port } = portObject;
|
const { IP: ip, PublicPort: port } = portObject;
|
||||||
const key = `${name}-${port}`;
|
const key = `${name}-${port}`;
|
||||||
|
|
||||||
if (
|
if (
|
||||||
existedDomains.some((item) => item === `${gateway}:${port}`)
|
existedDomains.some((item) => item === `${gateway}:${port}`) &&
|
||||||
|
!linesAded[key]
|
||||||
) {
|
) {
|
||||||
linesAded.push({
|
linesAded[key] = {
|
||||||
name: name.replace(/^\//, ""),
|
name: name.replace(/^\//, ""),
|
||||||
ip: gateway,
|
ip: gateway,
|
||||||
port,
|
port,
|
||||||
});
|
};
|
||||||
} else if (!lines[key]) {
|
} else if (!lines[key]) {
|
||||||
lines[key] = {
|
lines[key] = {
|
||||||
name: name.replace(/^\//, ""),
|
name: name.replace(/^\//, ""),
|
||||||
@ -100,7 +103,7 @@
|
|||||||
</div>`
|
</div>`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
for (const line of linesAded) {
|
for (const [key, line] of Object.entries(linesAded)) {
|
||||||
$("#containersAddedList").append(
|
$("#containersAddedList").append(
|
||||||
`<div class="item">
|
`<div class="item">
|
||||||
<div class="content">
|
<div class="content">
|
||||||
@ -111,7 +114,7 @@
|
|||||||
</div>`
|
</div>`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
linesAded.length &&
|
Object.entries(linesAded).length &&
|
||||||
$("#containersAddedListHeader").removeAttr("hidden");
|
$("#containersAddedListHeader").removeAttr("hidden");
|
||||||
$("#containersList .loader").removeClass("active");
|
$("#containersList .loader").removeClass("active");
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user