ads
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Alias</th>
|
||||
<th>Path</th>
|
||||
<th>Status</th>
|
||||
<th>Last Updated</th>
|
||||
@@ -26,7 +27,7 @@
|
||||
</thead>
|
||||
<tbody id="servicesTable">
|
||||
<tr>
|
||||
<td colspan="5" class="text-center">Loading...</td>
|
||||
<td colspan="6" class="text-center">Loading...</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
@@ -51,6 +52,38 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Edit Alias Modal -->
|
||||
<div class="modal fade" id="editAliasModal" tabindex="-1">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">Edit Service Alias</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form id="editAliasForm">
|
||||
<input type="hidden" id="editServiceId">
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Service Name</label>
|
||||
<input type="text" class="form-control" id="editServiceName" readonly>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Alias (Scoreboard Name)</label>
|
||||
<input type="text" class="form-control" id="editServiceAlias"
|
||||
placeholder="e.g. test_gevent_service_1">
|
||||
<small class="form-text text-muted">Enter the service name as it appears on the
|
||||
scoreboard</small>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button>
|
||||
<button type="button" class="btn btn-primary" onclick="saveAlias()">Save</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
{% block extra_js %}
|
||||
@@ -64,14 +97,22 @@
|
||||
? '<span class="badge bg-success">Running</span>'
|
||||
: '<span class="badge bg-secondary">Stopped</span>';
|
||||
|
||||
let aliasDisplay = service.alias
|
||||
? `<code>${service.alias}</code>`
|
||||
: '<span class="text-muted">Not set</span>';
|
||||
|
||||
html += `
|
||||
<tr>
|
||||
<td><strong>${service.name}</strong></td>
|
||||
<td>${aliasDisplay}</td>
|
||||
<td><code>${service.path}</code></td>
|
||||
<td>${statusBadge}</td>
|
||||
<td>${new Date(service.last_updated).toLocaleString()}</td>
|
||||
<td>
|
||||
<div class="btn-group btn-group-sm">
|
||||
<button class="btn btn-primary" onclick="editAlias(${service.id}, '${service.name}', '${service.alias || ''}')">
|
||||
<i class="bi bi-pencil"></i>
|
||||
</button>
|
||||
<button class="btn btn-success" onclick="serviceAction(${service.id}, 'start')">
|
||||
<i class="bi bi-play-fill"></i>
|
||||
</button>
|
||||
@@ -91,7 +132,7 @@
|
||||
});
|
||||
$('#servicesTable').html(html);
|
||||
} else {
|
||||
$('#servicesTable').html('<tr><td colspan="5" class="text-center text-muted">No services registered</td></tr>');
|
||||
$('#servicesTable').html('<tr><td colspan="6" class="text-center text-muted">No services registered</td></tr>');
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -121,6 +162,33 @@
|
||||
});
|
||||
}
|
||||
|
||||
function editAlias(serviceId, serviceName, currentAlias) {
|
||||
$('#editServiceId').val(serviceId);
|
||||
$('#editServiceName').val(serviceName);
|
||||
$('#editServiceAlias').val(currentAlias);
|
||||
new bootstrap.Modal(document.getElementById('editAliasModal')).show();
|
||||
}
|
||||
|
||||
function saveAlias() {
|
||||
const serviceId = $('#editServiceId').val();
|
||||
const alias = $('#editServiceAlias').val().trim();
|
||||
|
||||
$.ajax({
|
||||
url: `/api/services/${serviceId}/update`,
|
||||
method: 'PATCH',
|
||||
contentType: 'application/json',
|
||||
data: JSON.stringify({ alias: alias }),
|
||||
success: function (data) {
|
||||
alert('Alias updated successfully!');
|
||||
bootstrap.Modal.getInstance(document.getElementById('editAliasModal')).hide();
|
||||
loadServices();
|
||||
},
|
||||
error: function (xhr) {
|
||||
alert(`Failed to update alias: ${xhr.responseJSON?.detail || 'Unknown error'}`);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$(document).ready(function () {
|
||||
loadServices();
|
||||
$('#refreshServices').click(loadServices);
|
||||
|
||||
Reference in New Issue
Block a user