|
|
@@ -16473,17 +16473,93 @@ function renderServicesTable() {
|
|
|
return `
|
|
|
<tr class="hover:bg-slate-800/40 transition">
|
|
|
<td class="py-3 px-4 font-bold text-white uppercase">${s.name}</td>
|
|
|
- <td class="py-3 px-4 text-cyan-400 font-mono">${s.port}</td>
|
|
|
+ <td class="py-3 px-4">
|
|
|
+ <div class="flex items-center gap-2">
|
|
|
+ <span class="text-cyan-400 font-mono font-bold">${s.port}</span>
|
|
|
+ <button onclick="openEditServiceModal('${s.name}', ${s.port}, ${s.disabled})" title="Edit Port" class="text-slate-500 hover:text-cyan-400 p-1 rounded hover:bg-slate-800/80 transition">
|
|
|
+ <svg class="w-3.5 h-3.5" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15.232 5.232l3.536 3.536m-2.036-5.036a2.5 2.5 0 113.536 3.536L6.5 21.036H3v-3.572L16.732 3.732z"/></svg>
|
|
|
+ </button>
|
|
|
+ </div>
|
|
|
+ </td>
|
|
|
<td class="py-3 px-4">${statusBadge}</td>
|
|
|
<td class="py-3 px-4 text-slate-400 text-xs font-sans">${s.comment || '-'}</td>
|
|
|
<td class="py-3 px-4 text-right">
|
|
|
- ${toggleBtn}
|
|
|
+ <div class="flex items-center justify-end gap-2">
|
|
|
+ <button onclick="openEditServiceModal('${s.name}', ${s.port}, ${s.disabled})" class="px-2.5 py-1 rounded-lg bg-slate-800 hover:bg-slate-700 text-slate-300 hover:text-white border border-slate-700 text-[11px] font-medium transition inline-flex items-center gap-1">
|
|
|
+ <svg class="w-3.5 h-3.5 text-slate-400" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15.232 5.232l3.536 3.536m-2.036-5.036a2.5 2.5 0 113.536 3.536L6.5 21.036H3v-3.572L16.732 3.732z"/></svg>
|
|
|
+ <span>Edit Port</span>
|
|
|
+ </button>
|
|
|
+ ${toggleBtn}
|
|
|
+ </div>
|
|
|
</td>
|
|
|
</tr>
|
|
|
`;
|
|
|
}).join('');
|
|
|
}
|
|
|
|
|
|
+function openEditServiceModal(serviceName, currentPort, isDisabled) {
|
|
|
+ document.getElementById('modal-service-name').value = serviceName;
|
|
|
+ document.getElementById('modal-service-disabled').value = String(isDisabled);
|
|
|
+ document.getElementById('modal-service-display-name').textContent = serviceName.toUpperCase();
|
|
|
+ document.getElementById('modal-service-port').value = currentPort;
|
|
|
+
|
|
|
+ const hintEl = document.getElementById('modal-service-port-hint');
|
|
|
+ const warnEl = document.getElementById('modal-service-warning');
|
|
|
+
|
|
|
+ if (serviceName === 'www') {
|
|
|
+ hintEl.textContent = 'Default HTTP web port: 80';
|
|
|
+ warnEl.classList.remove('hidden');
|
|
|
+ } else if (serviceName === 'telnet') {
|
|
|
+ hintEl.textContent = 'Default Telnet / debtik-cli console port: 8282';
|
|
|
+ warnEl.classList.add('hidden');
|
|
|
+ } else if (serviceName === 'ssh') {
|
|
|
+ hintEl.textContent = 'Default CLI SSH port: 2222';
|
|
|
+ warnEl.classList.add('hidden');
|
|
|
+ } else {
|
|
|
+ hintEl.textContent = '';
|
|
|
+ warnEl.classList.add('hidden');
|
|
|
+ }
|
|
|
+
|
|
|
+ const modal = document.getElementById('modal-service-edit');
|
|
|
+ modal.classList.remove('hidden');
|
|
|
+ setTimeout(() => document.getElementById('modal-service-port').focus(), 50);
|
|
|
+}
|
|
|
+
|
|
|
+function closeEditServiceModal() {
|
|
|
+ const modal = document.getElementById('modal-service-edit');
|
|
|
+ if (modal) modal.classList.add('hidden');
|
|
|
+}
|
|
|
+
|
|
|
+async function submitSaveServicePort(event) {
|
|
|
+ event.preventDefault();
|
|
|
+ const name = document.getElementById('modal-service-name').value;
|
|
|
+ const disabled = document.getElementById('modal-service-disabled').value === 'true';
|
|
|
+ const port = parseInt(document.getElementById('modal-service-port').value, 10);
|
|
|
+
|
|
|
+ if (isNaN(port) || port < 1 || port > 65535) {
|
|
|
+ showToast('Invalid Port', 'Port must be a valid number between 1 and 65535', 'error');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ try {
|
|
|
+ const res = await fetch(`${API_BASE}/system/services/${name}`, {
|
|
|
+ method: 'POST',
|
|
|
+ headers: { 'Content-Type': 'application/json' },
|
|
|
+ body: JSON.stringify({ port: port, disabled: disabled })
|
|
|
+ });
|
|
|
+ if (!res.ok) {
|
|
|
+ const errData = await res.json();
|
|
|
+ throw new Error(errData.message || 'Failed to update service port');
|
|
|
+ }
|
|
|
+
|
|
|
+ closeEditServiceModal();
|
|
|
+ showToast('Port Updated', `Service ${name.toUpperCase()} port changed to ${port}`, 'success');
|
|
|
+ await loadServices();
|
|
|
+ } catch (err) {
|
|
|
+ showToast('Error', err.message, 'error');
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
async function toggleServiceState(serviceName, newDisabled) {
|
|
|
if (serviceName === 'www' && newDisabled) {
|
|
|
if (!confirm("WARNING: Disabling the Web service ('www') will turn off this Web UI and REST API. You will only be able to re-enable it via SSH (port 2222) or Telnet (port 8282) using 'ip service enable www'. Continue?")) {
|