LOGS"
+ "
LOGS'
)
header_checkbox_hyperscript = """
@@ -21,18 +24,55 @@
class ProcessTable(tables.Table):
- """Defines and Process Table for the data from the Process Manager."""
-
- class Meta: # noqa: D106
- orderable = False
-
- uuid = tables.Column(verbose_name="UUID")
- name = tables.Column(verbose_name="Name")
- user = tables.Column(verbose_name="User")
- session = tables.Column(verbose_name="Session")
- status_code = tables.Column(verbose_name="Status Code")
- exit_code = tables.Column(verbose_name="Exit Code")
- logs = tables.TemplateColumn(logs_column_template, verbose_name="Logs")
+ """Defines a Process Table for the data from the Process Manager."""
+
+ uuid = tables.Column(
+ verbose_name="UUID",
+ attrs={"td": {"class": "fw-bold text-break text-start"}},
+ )
+ name = tables.Column(
+ verbose_name="Process Name",
+ attrs={
+ "td": {"class": "fw-bold text-primary text-center"},
+ "th": {"class": "text-center header-style"},
+ },
+ )
+ user = tables.Column(
+ verbose_name="User",
+ attrs={
+ "td": {"class": "text-secondary text-center"},
+ "th": {"class": "text-center header-style"},
+ },
+ )
+ session = tables.Column(
+ verbose_name="Session",
+ attrs={
+ "td": {"class": "text-secondary text-center"},
+ "th": {"class": "text-center header-style"},
+ },
+ )
+ status_code = tables.Column(
+ verbose_name="Status",
+ attrs={
+ "td": {"class": "fw-bold text-center"},
+ "th": {"class": "text-center header-style"},
+ },
+ )
+ exit_code = tables.Column(
+ verbose_name="Exit Code",
+ attrs={
+ "td": {"class": "text-center"},
+ "th": {"class": "text-center header-style"},
+ },
+ )
+ logs = tables.TemplateColumn(
+ logs_column_template,
+ verbose_name="Logs",
+ attrs={
+ "td": {"class": "text-center"},
+ "th": {"class": "text-center header-style"},
+ },
+ )
select = tables.CheckBoxColumn(
accessor="uuid",
verbose_name="Select",
@@ -41,23 +81,39 @@ class Meta: # noqa: D106
"id": "header-checkbox",
"hx-preserve": "true",
"_": header_checkbox_hyperscript,
- }
+ "class": "form-check-input form-check-input-lg",
+ },
+ "td__input": {
+ "class": "form-check-input form-check-input-lg text-center",
+ },
},
)
- def render_select(self, value: str) -> str:
- """Customise behaviour of checkboxes in the select column.
+ class Meta:
+ """Table meta options for rendering behavior and styling."""
- Overriding the default render method for this column is required as the
- hx-preserve attitribute requires all elements to have unique id values. We also
- need to add the hyperscript required for the header checkbox behaviour.
+ orderable: ClassVar[bool] = False
+ attrs: ClassVar[dict[str, str]] = {
+ "class": "table table-striped table-hover table-responsive",
+ }
- Called during table rendering.
+ def render_status_code(self, value: str) -> str:
+ """Render the status_code with custom badge classes."""
+ if value == "DEAD":
+ return mark_safe('
DEAD')
+ elif value == "RUNNING":
+ return mark_safe('
RUNNING')
+ return mark_safe(
+ f'
{value}'
+ )
- Args:
- value: uuid from the table row data
- """
+ def render_select(self, value: str) -> str:
+ """Customize behavior of checkboxes in the select column."""
return mark_safe(
- f'
'
)
diff --git a/process_manager/templates/process_manager/index.html b/process_manager/templates/process_manager/index.html
index 414e0c7..f0ec27c 100644
--- a/process_manager/templates/process_manager/index.html
+++ b/process_manager/templates/process_manager/index.html
@@ -1,18 +1,121 @@
{% extends "main/base.html" %}
+{% load tz %}
{% block title %}
Home
{% endblock title %}
{% block extra_css %}
{% endblock extra_css %}
{% block extra_js %}
@@ -28,76 +131,87 @@
{% endblock extra_js %}
{% block content %}
-
-
-
-
-
diff --git a/process_manager/templates/process_manager/logs.html b/process_manager/templates/process_manager/logs.html
index 37af64f..927f8f1 100644
--- a/process_manager/templates/process_manager/logs.html
+++ b/process_manager/templates/process_manager/logs.html
@@ -3,8 +3,28 @@
Logs
{% endblock title %}
{% block content %}
-
-
{{ log_text }}
-
-
Return to table
+
+
+
+
+ {% for line in log_lines %}
+
+ {{ line }}
+
+ {% endfor %}
+
+
+
+
Return to process list
{% endblock content %}
diff --git a/process_manager/templates/process_manager/partials/message_items.html b/process_manager/templates/process_manager/partials/message_items.html
index b80f716..0058a9a 100644
--- a/process_manager/templates/process_manager/partials/message_items.html
+++ b/process_manager/templates/process_manager/partials/message_items.html
@@ -1,3 +1,7 @@
-
- {% for message in messages %}- {{ message }}
{% endfor %}
+
+ {% for message in messages %}
+ -
+ {{ message }}
+
+ {% endfor %}
diff --git a/process_manager/views/pages.py b/process_manager/views/pages.py
index 6fd3488..fa54dfd 100644
--- a/process_manager/views/pages.py
+++ b/process_manager/views/pages.py
@@ -15,7 +15,7 @@
@login_required
def index(request: HttpRequest) -> HttpResponse:
- """View that renders the index/home page."""
+ """View that renders the index/home page with process table."""
return render(request=request, template_name="process_manager/index.html")
@@ -32,10 +32,12 @@ def logs(request: HttpRequest, uuid: uuid.UUID) -> HttpResponse:
The rendered page.
"""
logs_response = get_process_logs(str(uuid))
- context = dict(log_text="\n".join(val.data.line for val in logs_response))
- return render(
- request=request, context=context, template_name="process_manager/logs.html"
- )
+
+ # Process the log text to exclude empty lines
+ log_lines = [val.data.line for val in logs_response if val.data.line.strip()]
+
+ context = {"log_lines": log_lines}
+ return render(request, "process_manager/logs.html", context)
class BootProcessView(PermissionRequiredMixin, FormView[BootProcessForm]):
diff --git a/tests/process_manager/views/test_page_views.py b/tests/process_manager/views/test_page_views.py
index fed6031..dd3d7a4 100644
--- a/tests/process_manager/views/test_page_views.py
+++ b/tests/process_manager/views/test_page_views.py
@@ -33,7 +33,7 @@ def test_get(self, auth_logs_client, mocker):
assert response.status_code == HTTPStatus.OK
mock.assert_called_once_with(str(self.uuid))
- assert "log_text" in response.context
+ assert "log_lines" in response.context
class TestBootProcess(PermissionRequiredTest):