Skip to content

Commit a8d0dca

Browse files
committed
fix: improve containers page command column display
- Truncate long commands with ellipsis, click to show full command in modal - Sort containers by state: running first, then created, then exited
1 parent 060657e commit a8d0dca

File tree

3 files changed

+37
-1
lines changed

3 files changed

+37
-1
lines changed

public/css/modern-style.css

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,15 @@ footer strong {
197197
border-radius: 3px;
198198
}
199199

200+
/* Command Cell Truncation */
201+
.command-cell {
202+
max-width: 150px;
203+
overflow: hidden;
204+
text-overflow: ellipsis;
205+
white-space: nowrap;
206+
cursor: pointer;
207+
}
208+
200209
/* Container Stats */
201210
.container-stats {
202211
font-family: 'Courier New', monospace;

routes/containers.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ const returnContainersRouter = (io) => {
1111
res.locals.formatName = (str) => {
1212
return str[0].split('/')[1];
1313
};
14+
const stateOrder = {running: 0, created: 1, exited: 2};
15+
containers.sort((a, b) => (stateOrder[a.State] ?? 3) - (stateOrder[b.State] ?? 3));
1416
docker.listImages(null, (err, listImages) => {
1517
res.render('containers',
1618
{

views/containers.html

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
<tr>
3232
<td class="text-break"><%= formatName(container.Names) %></td>
3333
<td class="text-break"><%= container.Image %></td>
34-
<td class="text-break"><%= container.Command %></td>
34+
<td class="command-cell" data-toggle="modal" data-target="#commandModal" data-command="<%= container.Command %>"><%= container.Command %></td>
3535
<td>
3636
<% if(container.Ports && container.Ports[0]){ %>
3737
[TCP] <%= container.Ports[0].PrivatePort %>
@@ -174,4 +174,29 @@ <h4 class="modal-title" id="myModalLabel">New container</h4>
174174
</div>
175175
</div>
176176
</div>
177+
<!-- Command Detail Modal -->
178+
<div class="modal fade" id="commandModal" tabindex="-1" role="dialog" aria-labelledby="commandModalLabel">
179+
<div class="modal-dialog" role="document">
180+
<div class="modal-content">
181+
<div class="modal-header">
182+
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
183+
<span aria-hidden="true">&times;</span>
184+
</button>
185+
<h4 class="modal-title" id="commandModalLabel">Command</h4>
186+
</div>
187+
<div class="modal-body">
188+
<pre id="commandContent" style="white-space: pre-wrap; word-break: break-all;"></pre>
189+
</div>
190+
<div class="modal-footer">
191+
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
192+
</div>
193+
</div>
194+
</div>
195+
</div>
177196
<%- include('include/footer.html') %>
197+
<script>
198+
$('#commandModal').on('show.bs.modal', function (e) {
199+
var command = $(e.relatedTarget).data('command');
200+
$('#commandContent').text(command);
201+
});
202+
</script>

0 commit comments

Comments
 (0)