@ -25,7 +25,7 @@
< a href = "{% url 'ops:task-history' pk=object.pk %}" class = "text-center" > < i class = "fa fa-laptop" > < / i > {% trans 'Run history' %} < / a >
< / li >
< li >
< a class = "text-center celery-task-log" onclick = "window.open('{% url 'ops:celery-task-log' pk=object.latest_history.pk %}','', 'width=800,height=600,left=400,top=400')" > < i class = "fa fa-laptop" > < / i > {% trans 'Last run output' %} < / a >
< a class = "text-center celery-task-log" > < i class = "fa fa-laptop" > < / i > {% trans 'Last run output' %} < / a >
< / li >
< / ul >
< / div >
@ -78,52 +78,60 @@
{% endblock %}
{% block custom_foot_js %}
< script >
$(document).ready(function () {
var options = {
ele: $('#task-version-list-table'),
buttons: [],
order: [],
select: [],
columnDefs: [
{targets: 1, createdCell: function (td, cellData, rowData) {
< script >
$(document).ready(function () {
var options = {
ele: $('#task-version-list-table'),
buttons: [],
order: [],
select: [],
columnDefs: [
{targets: 1, createdCell: function (td, cellData, rowData) {
{# var detail_btn = '< a href = "' + cellData + ' < / a > ';#}
$(td).html(cellData);
}},
{targets: 2, createdCell: function (td, cellData, rowData) {
var dataLength = cellData.length;
$(td).html(dataLength);
}},
{targets: 4, createdCell: function (td, cellData) {
if (!cellData) {
$(td).html("Admin")
} else {
$(td).html(cellData)
}
}},
{targets: 5, createdCell: function (td, cellData, rowData) {
if (!cellData) {
$(td).html("")
} else {
$(td).html(cellData.user)
}
}},
{targets: 6, createdCell: function (td, cellData) {
var d = new Date(cellData);
$(td).html(d.toLocaleString())
}},
{targets: 7, createdCell: function (td, cellData, rowData) {
var detail_btn = '< a class = "btn btn-xs btn-primary m-l-xs btn-run" href = "{% url 'ops:adhoc-detail' pk=DEFAULT_PK %}" > {% trans "Detail" %}< / a > '.replace('{{ DEFAULT_PK }}', cellData);
if (cellData) {
$(td).html(detail_btn);
}
}}
],
ajax_url: '{% url "api-ops:adhoc-list" %}?task={{ object.pk }}',
columns: [{data: function(){return ""}}, {data: "short_id" }, {data: "hosts"}, {data: "pattern"},
{data: "run_as"}, {data: "become"}, {data: "date_created"}, {data: "id"}]
};
jumpserver.initDataTable(options);
})
< / script >
$(td).html(cellData);
}},
{targets: 2, createdCell: function (td, cellData, rowData) {
var dataLength = cellData.length;
$(td).html(dataLength);
}},
{targets: 4, createdCell: function (td, cellData) {
if (!cellData) {
$(td).html("Admin")
} else {
$(td).html(cellData)
}
}},
{targets: 5, createdCell: function (td, cellData, rowData) {
if (!cellData) {
$(td).html("")
} else {
$(td).html(cellData.user)
}
}},
{targets: 6, createdCell: function (td, cellData) {
var d = new Date(cellData);
$(td).html(d.toLocaleString())
}},
{targets: 7, createdCell: function (td, cellData, rowData) {
var detail_btn = '< a class = "btn btn-xs btn-primary m-l-xs btn-run" href = "{% url 'ops:adhoc-detail' pk=DEFAULT_PK %}" > {% trans "Detail" %}< / a > '.replace('{{ DEFAULT_PK }}', cellData);
if (cellData) {
$(td).html(detail_btn);
}
}}
],
ajax_url: '{% url "api-ops:adhoc-list" %}?task={{ object.pk }}',
columns: [{data: function(){return ""}}, {data: "short_id" }, {data: "hosts"}, {data: "pattern"},
{data: "run_as"}, {data: "become"}, {data: "date_created"}, {data: "id"}]
};
jumpserver.initDataTable(options);
}).on('click', '.celery-task-log', function () {
var history_pk = "{{ object.latest_history.pk }}";
if (!history_pk) {
alert("没有运行历史");
return
}
var url = '{% url 'ops:celery-task-log' pk=DEFAULT_PK %}'.replace('{{ DEFAULT_PK }}', history_pk);
window.open(url, '', 'width=800,height=600,left=400,top=400')
})
< / script >
{% endblock %}