mirror of https://github.com/jumpserver/jumpserver
[Bugfix] 修复adhoc 日志查看的bug, 修改config example (#2230)
parent
a1b80f5f0b
commit
08945f0a19
|
@ -168,7 +168,10 @@ class AdHoc(models.Model):
|
|||
|
||||
@property
|
||||
def tasks(self):
|
||||
return json.loads(self._tasks)
|
||||
try:
|
||||
return json.loads(self._tasks)
|
||||
except:
|
||||
return []
|
||||
|
||||
@tasks.setter
|
||||
def tasks(self, item):
|
||||
|
|
|
@ -186,6 +186,19 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% include 'users/_user_update_pk_modal.html' %}
|
||||
{% endblock %}
|
||||
{% block custom_foot_js %}
|
||||
<script>
|
||||
$(document).ready(function () {
|
||||
}).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 %}
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
<a href="{% url 'ops:adhoc-history-detail' pk=object.pk %}" class="text-center"><i class="fa fa-laptop"></i> {% trans 'Run history detail' %} </a>
|
||||
</li>
|
||||
<li>
|
||||
<a class="text-center celery-task-log" onclick="window.open('{% url 'ops:celery-task-log' pk=object.pk %}','', 'width=800,height=600,left=400,top=400')"><i class="fa fa-laptop"></i> {% trans 'Output' %} </a>
|
||||
<a class="text-center celery-task-log" ><i class="fa fa-laptop"></i> {% trans 'Output' %} </a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
@ -141,4 +141,14 @@
|
|||
</div>
|
||||
{% include 'users/_user_update_pk_modal.html' %}
|
||||
{% endblock %}
|
||||
{% block custom_foot_js %}
|
||||
<script>
|
||||
$(document).ready(function () {
|
||||
}).on('click', '.celery-task-log', function () {
|
||||
var url = '{% url 'ops:celery-task-log' pk=object.pk %}';
|
||||
window.open(url, '', 'width=800,height=600,left=400,top=400')
|
||||
})
|
||||
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
||||
|
|
|
@ -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 %}
|
||||
|
|
|
@ -26,7 +26,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>
|
||||
|
@ -165,4 +165,19 @@
|
|||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
{% block custom_foot_js %}
|
||||
<script>
|
||||
$(document).ready(function () {
|
||||
}).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 %}
|
||||
|
||||
|
|
|
@ -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>
|
||||
|
@ -148,6 +148,14 @@ function initTable() {
|
|||
|
||||
$(document).ready(function () {
|
||||
initTable();
|
||||
}).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>
|
||||
|
|
|
@ -78,7 +78,7 @@ class Config:
|
|||
REDIS_HOST = '127.0.0.1'
|
||||
REDIS_PORT = 6379
|
||||
# REDIS_PASSWORD = ''
|
||||
# REDIS_DB_CELERY_BROKER = 3
|
||||
# REDIS_DB_CELERY = 3
|
||||
# REDIS_DB_CACHE = 4
|
||||
|
||||
# Use OpenID authorization
|
||||
|
|
Loading…
Reference in New Issue