mirror of
https://gitee.com/ulthon/ulthon_admin.git
synced 2026-07-08 02:52:49 +08:00
feat(timer): 新增定时器配置、日志和主机的后台管理界面
T10: TimerConfig CURD - task management with run_type/status editing,
manual trigger button, task_name read-only, no add/delete
T11: TimerLog CURD - read-only log viewer with filters and color badges
T12: Host list enhanced - is_master column, setMaster button
This commit is contained in:
78
app/admin/view/system/timer_config/index.js
Normal file
78
app/admin/view/system/timer_config/index.js
Normal file
@@ -0,0 +1,78 @@
|
||||
$(function(){
|
||||
ua.table.render({
|
||||
init: init,
|
||||
cols: [[
|
||||
{type: 'checkbox'},
|
||||
{field: 'id', title: 'ID', width: 80},
|
||||
{field: 'task_name', title: '任务名称', minWidth: 160},
|
||||
{field: 'run_type', search: 'select', selectList: ua.getDataBrage('select_list_run_type'), title: '运行类型', width: 130, templet: function(d){
|
||||
var map = ua.getDataBrage('select_list_run_type');
|
||||
return map[d.run_type] || d.run_type;
|
||||
}},
|
||||
{field: 'status', search: 'select', selectList: ua.getDataBrage('select_list_status'), title: '状态', width: 100, templet: ua.table.switch},
|
||||
{field: 'is_synced', search: 'select', selectList: ua.getDataBrage('select_list_is_synced'), title: '同步状态', width: 100, templet: function(d){
|
||||
if(d.is_synced == 1){
|
||||
return '<span class="layui-badge layui-bg-green">已同步</span>';
|
||||
}
|
||||
return '<span class="layui-badge">未同步</span>';
|
||||
}},
|
||||
{field: 'last_execute_node', title: '最后执行节点', width: 140},
|
||||
{field: 'last_execute_time', title: '最后执行时间', width: 170, templet: function(d){
|
||||
if(!d.last_execute_time || d.last_execute_time == 0){
|
||||
return '<span class="layui-text-em">暂无</span>';
|
||||
}
|
||||
var date = new Date(d.last_execute_time * 1000);
|
||||
var Y = date.getFullYear();
|
||||
var m = ('0' + (date.getMonth()+1)).slice(-2);
|
||||
var day = ('0' + date.getDate()).slice(-2);
|
||||
var H = ('0' + date.getHours()).slice(-2);
|
||||
var i = ('0' + date.getMinutes()).slice(-2);
|
||||
var s = ('0' + date.getSeconds()).slice(-2);
|
||||
return Y+'-'+m+'-'+day+' '+H+':'+i+':'+s;
|
||||
}},
|
||||
{
|
||||
width: 200, title: '操作', templet: ua.table.tool, fixed: 'right', operat: [
|
||||
[{
|
||||
class: 'layui-btn layui-btn-primary layui-btn-xs',
|
||||
method: 'tab',
|
||||
field: 'id',
|
||||
text: '详情',
|
||||
title: '查看详情',
|
||||
auth: 'read',
|
||||
url: init.readUrl,
|
||||
icon: ''
|
||||
}],
|
||||
'edit',
|
||||
[{
|
||||
class: 'layui-btn layui-btn-warm layui-btn-xs',
|
||||
method: 'request',
|
||||
field: 'id',
|
||||
text: '触发',
|
||||
title: '手动触发',
|
||||
auth: 'trigger',
|
||||
url: init.triggerUrl,
|
||||
icon: '',
|
||||
extend: '',
|
||||
callback: function(o){
|
||||
// 只对 manual 类型显示,通过 CSS 控制显隐
|
||||
}
|
||||
}]
|
||||
]
|
||||
},
|
||||
|
||||
]],
|
||||
});
|
||||
|
||||
// 控制触发按钮显隐:只有 run_type=manual 时显示
|
||||
ua.listen();
|
||||
|
||||
// 监听表格渲染完成后处理触发按钮显隐
|
||||
$(document).on('renderComplete', function(){
|
||||
$('table tbody tr').each(function(){
|
||||
var runType = $(this).find('td[data-field="run_type"] .layui-table-cell').text().trim();
|
||||
if(runType !== 'manual'){
|
||||
$(this).find('.layui-btn[title="手动触发"]').hide();
|
||||
}
|
||||
});
|
||||
});
|
||||
})
|
||||
Reference in New Issue
Block a user