perf: update automation report template

pull/15051/head
ibuler 2025-03-17 19:20:29 +08:00
parent a784ca29c3
commit c0b548af67
6 changed files with 13 additions and 10 deletions

View File

@ -56,7 +56,7 @@ class DiscoverAccountsExecutionViewSet(AutomationExecutionViewSet):
if not asset_id:
return Response(status=400, data={"asset_id": "This field is required."})
get_object_or_404(Asset, pk=asset_id)
asset = get_object_or_404(Asset, pk=asset_id)
execution = AutomationExecution()
execution.snapshot = {
"assets": [asset_id],
@ -64,7 +64,7 @@ class DiscoverAccountsExecutionViewSet(AutomationExecutionViewSet):
"type": "gather_accounts",
"is_sync_account": False,
"check_risk": True,
"name": "Adhoc gather accounts: {}".format(asset_id),
"name": "Adhoc gather accounts: {}".format(asset.name),
}
execution.save()
execution.start()

View File

@ -45,6 +45,9 @@ class AutomationExecution(AssetAutomationExecution):
('add_backupaccountexecution', _('Can add backup account execution')),
]
def __str__(self):
return '{}: {}'.format(self.snapshot.get('name', ''), self.id)
@property
def manager(self):
from accounts.automations.endpoint import ExecutionManager

View File

@ -14,6 +14,11 @@
</div>
<div class="container-section collapsible-content" id="basic-info-content">
<div class="item">
<span class="item-label">{% trans 'Task name' %}</span>
<span class="item-value">{{ execution.snapshot.name }}</span>
</div>
<div class="item">
<span class="item-label">{% trans 'Date start' %}</span>
<span class="item-value">{{ execution.date_start | date:"Y/m/d H:i:s" }}</span>
@ -29,11 +34,6 @@
<span class="item-value">{{ summary.total_accounts | default:0 }}</span>
</div>
<div class="item">
<span class="item-label">{% trans 'Task name' %}</span>
<span class="item-value">{{ execution.automation.name }}</span>
</div>
<div class="item">
<span class="item-label">{% trans 'Time using' %}</span>
<span class="item-value">{{ execution.duration }}s</span>

View File

@ -16,7 +16,7 @@
<div class="container-section collapsible-content" id="basic-info-content">
<div class="item">
<span class="item-label">{% trans 'Task name' %}</span>
<span class="item-value">{{ execution.automation.name }}</span>
<span class="item-value">{{ execution.snapshot.name }}</span>
</div>
<div class="item">

View File

@ -14,7 +14,7 @@
<div class="container-section collapsible-content" id="basic-info-content">
<div class="item">
<span class="item-label">{% trans 'Task name' %}</span>
<span class="item-value">{{ execution.automation.name }}</span>
<span class="item-value">{{ execution.snapshot.name }}</span>
</div>
<div class="item">

View File

@ -15,7 +15,7 @@
<div class="container-section collapsible-content" id="basic-info-content">
<div class="item">
<span class="item-label">{% trans 'Task name' %}</span>
<span class="item-value">{{ execution.automation.name }}</span>
<span class="item-value">{{ execution.snapshot.name }}</span>
</div>
<div class="item">