Skip to content

Commit da537d5

Browse files
committed
[ui] Highlight command status with colors #812
Made command status easier to read by adding colors - green for success, red for failed, and gray for in-progress. Also made the text bold so it stands out more.
1 parent faec934 commit da537d5

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

openwisp_controller/connection/admin.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,8 @@ class CommandInline(admin.StackedInline):
103103
model = Command
104104
verbose_name = _("Recent Commands")
105105
verbose_name_plural = verbose_name
106-
fields = ["status", "type", "input_data", "output_data", "created", "modified"]
107-
readonly_fields = ["input_data", "output_data"]
106+
fields = ["status_display", "type", "input_data", "output_data", "created", "modified"]
107+
readonly_fields = ["status_display", "type", "input_data", "output_data", "created", "modified"]
108108
formset = LimitedCommandResults
109109

110110
def get_queryset(self, request, select_related=True):
@@ -133,8 +133,18 @@ def output_data(self, obj):
133133
)
134134
return obj.output
135135

136+
def status_display(self, obj):
137+
status_value = obj.status
138+
css_class = f"command-status-{status_value}"
139+
return format_html(
140+
'<span class="{0}">{1}</span>',
141+
css_class,
142+
obj.get_status_display()
143+
)
144+
136145
input_data.short_description = _("input")
137146
output_data.short_description = _("output")
147+
status_display.short_description = _("status")
138148

139149
def _get_conditional_queryset(self, request, obj, select_related=False):
140150
return self.get_queryset(request, select_related=select_related).exists()

openwisp_controller/connection/static/connection/css/command-inline.css

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,3 +231,19 @@ li.commands:not(.recent) {
231231
width: 3.125em;
232232
margin: 0.2em 0;
233233
}
234+
235+
/* Command status highlighting */
236+
.command-status-success {
237+
color: #417927;
238+
font-weight: bold;
239+
}
240+
241+
.command-status-failed {
242+
color: #ba2121;
243+
font-weight: bold;
244+
}
245+
246+
.command-status-in-progress {
247+
color: #666;
248+
font-weight: bold;
249+
}

0 commit comments

Comments
 (0)