[Bugfix] 修复task 列表、

pull/3796/head
ibuler 5 years ago
parent a41988d2b5
commit d0fac3f838

@ -182,6 +182,7 @@ class AdHoc(OrgModelMixin):
id=hid, adhoc=self, task=self.task,
task_display=str(self.task),
date_start=timezone.now(),
hosts_amount=self.hosts.count(),
)
execution.save()
return execution.start()

@ -39,6 +39,7 @@ class AdHocExecutionExcludeResultSerializer(AdHocExecutionSerializer):
class TaskSerializer(serializers.ModelSerializer):
summary = serializers.ReadOnlyField(source='history_summary')
latest_execution = AdHocExecutionExcludeResultSerializer(read_only=True)
class Meta:
@ -46,12 +47,12 @@ class TaskSerializer(serializers.ModelSerializer):
fields = [
'id', 'name', 'interval', 'crontab', 'is_periodic',
'is_deleted', 'comment', 'date_created',
'date_updated', 'latest_execution',
'date_updated', 'latest_execution', 'summary',
]
read_only_fields = [
'is_deleted', 'date_created', 'date_updated',
'latest_adhoc', 'latest_execution', 'total_run_amount',
'success_run_amount',
'success_run_amount', 'summary',
]

@ -35,7 +35,7 @@ $(document).ready(function () {
$(td).html(innerHtml);
}},
{targets: 2, createdCell: function (td, cellData) {
var summary = cellData ? cellData.stat : {failed: 0, success: 0, total: 0};
var summary = cellData || {failed: 0, success: 0, total: 0};
var innerHtml = '<span class="text-danger">failed</span>/<span class="text-navy">success</span>/total';
innerHtml = innerHtml.replace('failed', summary.failed)
.replace('success', summary.success)
@ -79,7 +79,7 @@ $(document).ready(function () {
ajax_url: '{% url "api-ops:task-list" %}',
columns: [
{data: "id"}, {data: "name", className: "text-left"},
{data: "latest_execution", orderable: false},
{data: "summary", orderable: false},
{data: "latest_execution", orderable: false},
{data: "latest_execution", orderable: false}, {data: "latest_execution"},
{data: "latest_execution", orderable:false}, {data: "id", orderable: false},

Loading…
Cancel
Save