diff --git a/netbox/extras/scripts.py b/netbox/extras/scripts.py index 0994bc66f..6aed2d032 100644 --- a/netbox/extras/scripts.py +++ b/netbox/extras/scripts.py @@ -273,7 +273,7 @@ class BaseScript(object): def __init__(self): self._results = {} self.failed = False - self._current_method = 'main' + self._current_method = 'total' # Initiate the log self.logger = logging.getLogger(f"netbox.scripts.{self.__module__}.{self.__class__.__name__}") @@ -283,7 +283,7 @@ class BaseScript(object): self.request = None # Compile test methods and initialize results skeleton - self._results['main'] = { + self._results['total'] = { 'success': 0, 'info': 0, 'warning': 0, @@ -454,8 +454,8 @@ class BaseScript(object): if log_level != LogLevelChoices.LOG_DEFAULT: self._results[self._current_method][log_level] += 1 - if self._current_method != 'main': - self._results['main'][log_level] += 1 + if self._current_method != 'total': + self._results['total'][log_level] += 1 if obj: self.logger.log(level, f"{log_level.capitalize()} | {obj}: {message}") diff --git a/netbox/templates/extras/htmx/script_result.html b/netbox/templates/extras/htmx/script_result.html index 2fb0de468..f79fb8e48 100644 --- a/netbox/templates/extras/htmx/script_result.html +++ b/netbox/templates/extras/htmx/script_result.html @@ -1,6 +1,5 @@ {% load humanize %} {% load helpers %} -{% load log_levels %} {% load i18n %}
@@ -17,40 +16,62 @@ {% badge job.get_status_display job.get_status_color %}
{% if job.completed %} -{% trans "Line" %} | -{% trans "Level" %} | -{% trans "Message" %} | -||
---|---|---|---|---|
{{ forloop.counter }} | -{% log_level log.status %} | -{{ log.message|markdown }} | -||
- {% trans "No log output" %} + | {{ method }} | ++ {{ data.success }} + {{ data.info }} + {{ data.warning }} + {{ data.failure }} |
{{ job.data.output }}- {% else %} -
{% trans "None" %}
- {% endif %} +{% trans "Time" %} | +{% trans "Level" %} | +{% trans "Object" %} | +{% trans "Message" %} | +
---|---|---|---|
+ {{ method }} + | +|||
{{ time }} | ++ + | ++ {% if obj and url %} + {{ obj }} + {% elif obj %} + {{ obj }} + {% else %} + {{ ''|placeholder }} + {% endif %} + | +{{ message|markdown }} | +
{{ file_path }}
could not be loaded.
- {% endblocktrans %}
- {% trans "Name" %} | {% trans "Description" %} | {% trans "Last Run" %} | -{% trans "Status" %} | +{% trans "Status" %} | +|||
---|---|---|---|---|---|---|---|
- {{ script_class.name }} - | -- {{ script_class.Meta.description|markdown|placeholder }} - | - {% with last_result=jobs|get_key:script_class.class_name %} - {% if last_result %} + {% for script_name, script in module.scripts.items %} + {% with last_job=jobs|get_key:script.class_name %} +||||||
+ {{ script.name }} + | +{{ script.description|markdown|placeholder }} | + {% if last_job %}- {{ last_result.created|annotated_date }} + {{ last_job.created|annotated_date }} | -- {% badge last_result.get_status_display last_result.get_status_color %} + | + {% badge last_job.get_status_display last_job.get_status_color %} | {% else %}{% trans "Never" %} | -{{ ''|placeholder }} | ++ {% if script.is_valid %} + {{ ''|placeholder }} + {% else %} + + {% trans "Invalid" %} + + {% endif %} + | {% endif %} - {% endwith %} -
+ {% if perms.extras.run_script and script.is_valid %}
+
+
+
+ {% endif %}
+ |
+
+ {% for method, stats in last_job.data.items %}
+
+ {{ method }} + | ++ {{ stats.success }} + {{ stats.info }} + {{ stats.warning }} + {{ stats.failure }} + | +