mirror of
https://github.com/kiddin9/op-packages.git
synced 2026-11-10 13:57:51 +08:00
🎈 Sync 2026-05-22 14:28:32
This commit is contained in:
1 parent
7f7b99cc2f
commit
5635d6c1ec
70 files changed
+7296
-4358
No files matched your search
@@ -250,8 +250,12 @@ return dm2.dv.extend({
|
||||
if (!portBindings || typeof portBindings !== 'object') return [];
|
||||
const ports = [];
|
||||
for (const [containerPort, bindings] of Object.entries(portBindings)) {
|
||||
if (Array.isArray(bindings) && bindings.length > 0 && bindings[0]?.HostPort) {
|
||||
ports.push(`${bindings[0].HostPort}:${containerPort}`);
|
||||
if (Array.isArray(bindings)) {
|
||||
for (const b of bindings) {
|
||||
if (!b?.HostPort) continue;
|
||||
const ip = (b.HostIp && b.HostIp !== '0.0.0.0' && b.HostIp !== '::') ? b.HostIp + ':' : '';
|
||||
ports.push(`${ip}${b.HostPort}:${containerPort}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
return ports;
|
||||
@@ -306,8 +310,9 @@ return dm2.dv.extend({
|
||||
Name: name,
|
||||
NetworkID: netid,
|
||||
DNSNames: net?.DNSNames || '',
|
||||
IPv4Address: net?.IPAMConfig?.IPv4Address || '',
|
||||
IPv4Address: net?.IPAMConfig?.IPv4Address || net?.IPAddress || '',
|
||||
IPv6Address: net?.IPAMConfig?.IPv6Address || '',
|
||||
Aliases: net?.Aliases || '',
|
||||
});
|
||||
}
|
||||
|
||||
@@ -315,6 +320,7 @@ return dm2.dv.extend({
|
||||
},
|
||||
|
||||
render([this_container, images, networks, cpus_mem, ps_top, stats_data, changes_data]) {
|
||||
this.networks = networks;
|
||||
const view = this;
|
||||
const containerName = this_container.Name?.substring(1) || this_container.Id || '';
|
||||
const containerIdShort = (this_container.Id || '').substring(0, 12);
|
||||
@@ -359,7 +365,7 @@ return dm2.dv.extend({
|
||||
}
|
||||
|
||||
// Stop button
|
||||
if (containerStatus === 'running' || containerStatus === 'paused') {
|
||||
if (containerStatus === 'running' || containerStatus === 'paused' || containerStatus === 'restarting') {
|
||||
const stopBtn = E('button', {
|
||||
'class': 'cbi-button cbi-button-reset',
|
||||
'click': (ev) => this.executeAction(ev, 'stop', this_container.Id)
|
||||
@@ -368,7 +374,7 @@ return dm2.dv.extend({
|
||||
}
|
||||
|
||||
// Kill button
|
||||
if (containerStatus === 'running') {
|
||||
if (containerStatus === 'running' || containerStatus === 'restarting') {
|
||||
const killBtn = E('button', {
|
||||
'class': 'cbi-button',
|
||||
'style': 'background-color: #dc3545;',
|
||||
@@ -581,6 +587,8 @@ return dm2.dv.extend({
|
||||
|
||||
o = ss.option(form.DummyValue, 'DNSNames', _('DNS Names'));
|
||||
|
||||
o = ss.option(form.DummyValue, 'Aliases', _('Aliases'));
|
||||
|
||||
ss.handleAdd = function(ev) {
|
||||
ev.preventDefault();
|
||||
view.executeNetworkAction('connect', null, null, this_container);
|
||||
@@ -1849,7 +1857,7 @@ return dm2.dv.extend({
|
||||
dm2.network_disconnect,
|
||||
{
|
||||
id: networkID,
|
||||
body: { Container: view.containerId, Force: false }
|
||||
body: { Container: this_container.Id, Force: false }
|
||||
},
|
||||
_('Disconnect network'),
|
||||
{
|
||||
@@ -1883,7 +1891,7 @@ return dm2.dv.extend({
|
||||
|
||||
const ip4Input = E('input', {
|
||||
'type': 'text',
|
||||
'id': 'network-ip',
|
||||
'id': 'network-ip4',
|
||||
'class': 'cbi-input-text',
|
||||
'placeholder': 'e.g., 172.18.0.5',
|
||||
'style': 'width:100%; margin-top:5px;'
|
||||
@@ -1891,18 +1899,29 @@ return dm2.dv.extend({
|
||||
|
||||
const ip6Input = E('input', {
|
||||
'type': 'text',
|
||||
'id': 'network-ip',
|
||||
'id': 'network-ip6',
|
||||
'class': 'cbi-input-text',
|
||||
'placeholder': 'e.g., 2001:db8:1::1',
|
||||
'style': 'width:100%; margin-top:5px;'
|
||||
});
|
||||
|
||||
const aliasesInput = E('input', {
|
||||
'type': 'text',
|
||||
'id': 'network-aliases',
|
||||
'class': 'cbi-input-text',
|
||||
'placeholder': 'e.g., database,db (comma-separated)',
|
||||
'style': 'width:100%; margin-top:5px;'
|
||||
});
|
||||
|
||||
const modalBody = E('div', { 'class': 'cbi-section' }, [
|
||||
E('p', {}, _('Select network to connect:')),
|
||||
networkSelect,
|
||||
E('label', { 'style': 'display:block; margin-top:10px;' }, _('IP Address (optional):')),
|
||||
E('label', { 'style': 'display:block; margin-top:10px;' }, _('IPv4 Address (optional):')),
|
||||
ip4Input,
|
||||
E('label', { 'style': 'display:block; margin-top:10px;' }, _('IPv6 Address (optional):')),
|
||||
ip6Input,
|
||||
E('label', { 'style': 'display:block; margin-top:10px;' }, _('Aliases (optional):')),
|
||||
aliasesInput,
|
||||
]);
|
||||
|
||||
ui.showModal(_('Connect Network'), [
|
||||
@@ -1918,7 +1937,9 @@ return dm2.dv.extend({
|
||||
'click': () => {
|
||||
const selectedNetwork = networkSelect.value;
|
||||
const ip4Address = ip4Input.value || '';
|
||||
// const ip6Address = ip6Input.value || '';
|
||||
const ip6Address = ip6Input.value || '';
|
||||
const aliasesRaw = aliasesInput.value || '';
|
||||
const aliases = aliasesRaw.split(',').map(a => a.trim()).filter(Boolean);
|
||||
|
||||
if (!selectedNetwork) {
|
||||
view.showNotification(_('Error'), [_('No network selected')], 5000, 'error');
|
||||
@@ -1927,8 +1948,14 @@ return dm2.dv.extend({
|
||||
|
||||
ui.hideModal();
|
||||
|
||||
const body = { Container: view.containerId };
|
||||
body.EndpointConfig = { IPAMConfig: { IPv4Address: ip4Address } }; //, IPv6Address: ip6Address || null
|
||||
const body = { Container: this_container.Id };
|
||||
body.EndpointConfig = {
|
||||
IPAMConfig: {
|
||||
IPv4Address: ip4Address || null,
|
||||
IPv6Address: ip6Address || null
|
||||
},
|
||||
Aliases: aliases.length > 0 ? aliases : null
|
||||
};
|
||||
|
||||
view.executeDockerAction(
|
||||
dm2.network_connect,
|
||||
|
||||
Reference in new issue
Block a user