mirror of
https://github.com/midoks/mdserver-web.git
synced 2026-10-10 04:19:26 +08:00
update
This commit is contained in:
@@ -21,8 +21,47 @@ class crontab_api:
|
||||
def listApi(self):
|
||||
_list = public.M('crontab').where('', ()).field('id,name,type,where1,where_hour,where_minute,echo,addtime,status,save,backup_to,stype,sname,sbody,urladdress').limit(
|
||||
'0,5').order('id desc').select()
|
||||
|
||||
data = []
|
||||
for i in range(len(_list)):
|
||||
tmp = _list[i]
|
||||
if _list[i]['type'] == "day":
|
||||
tmp['type'] = '每天'
|
||||
tmp['cycle'] = public.getInfo('每天, {1}点{2}分 执行', (str(
|
||||
_list[i]['where_hour']), str(_list[i]['where_minute'])))
|
||||
elif _list[i]['type'] == "day-n":
|
||||
tmp['type'] = public.getInfo(
|
||||
'每{1}天', (str(_list[i]['where1']),))
|
||||
tmp['cycle'] = public.getInfo('每隔{1}天, {2}点{3}分 执行', (str(
|
||||
_list[i]['where1']), str(_list[i]['where_hour']), str(_list[i]['where_minute'])))
|
||||
elif _list[i]['type'] == "hour":
|
||||
tmp['type'] = '每小时'
|
||||
tmp['cycle'] = public.getInfo(
|
||||
'每小时, 第{1}分钟 执行', (str(_list[i]['where_minute']),))
|
||||
elif _list[i]['type'] == "hour-n":
|
||||
tmp['type'] = public.getInfo(
|
||||
'每{1}小时', (str(_list[i]['where1']),))
|
||||
tmp['cycle'] = public.getInfo('每{1}小时, 第{2}分钟 执行', (str(
|
||||
_list[i]['where1']), str(_list[i]['where_minute'])))
|
||||
elif _list[i]['type'] == "minute-n":
|
||||
tmp['type'] = public.getInfo(
|
||||
'每{1}分钟', (str(_list[i]['where1']),))
|
||||
tmp['cycle'] = public.getInfo(
|
||||
'每隔{1}分钟执行', (str(_list[i]['where1']),))
|
||||
elif _list[i]['type'] == "week":
|
||||
tmp['type'] = '每周'
|
||||
if not _list[i]['where1']:
|
||||
_list[i]['where1'] = '0'
|
||||
tmp['cycle'] = public.getInfo('每周{1}, {2}点{3}分执行', (self.toWeek(int(
|
||||
_list[i]['where1'])), str(_list[i]['where_hour']), str(_list[i]['where_minute'])))
|
||||
elif _list[i]['type'] == "month":
|
||||
tmp['type'] = '每月'
|
||||
tmp['cycle'] = public.getInfo('每月, {1}日 {2}点{3}分执行', (str(_list[i]['where1']), str(
|
||||
_list[i]['where_hour']), str(_list[i]['where_minute'])))
|
||||
data.append(tmp)
|
||||
|
||||
_ret = {}
|
||||
_ret['data'] = _list
|
||||
_ret['data'] = data
|
||||
|
||||
count = public.M('crontab').where('', ()).count()
|
||||
_page = {}
|
||||
@@ -32,6 +71,9 @@ class crontab_api:
|
||||
_ret['page'] = public.getPage(_page)
|
||||
return public.getJson(_ret)
|
||||
|
||||
def logsApi(self):
|
||||
return public.returnJson(False, '添加失败')
|
||||
|
||||
def addApi(self):
|
||||
name = request.form.get('name', '')
|
||||
type = request.form.get('type', '')
|
||||
@@ -44,6 +86,7 @@ class crontab_api:
|
||||
sName = request.form.get('sName', '')
|
||||
sBody = request.form.get('sBody', '')
|
||||
urladdress = request.form.get('urladdress', '')
|
||||
|
||||
if len(name) < 1:
|
||||
return public.returnJson(False, '任务名称不能为空!')
|
||||
|
||||
@@ -62,3 +105,19 @@ class crontab_api:
|
||||
except Exception as e:
|
||||
return public.returnJson(False, '删除失败')
|
||||
##### ----- start ----- ###
|
||||
|
||||
# 转换大写星期
|
||||
def toWeek(self, num):
|
||||
wheres = {
|
||||
0: '日',
|
||||
1: '一',
|
||||
2: '二',
|
||||
3: '三',
|
||||
4: '四',
|
||||
5: '五',
|
||||
6: '六'
|
||||
}
|
||||
try:
|
||||
return wheres[num]
|
||||
except:
|
||||
return ''
|
||||
|
||||
+20
-14
@@ -1,9 +1,9 @@
|
||||
var num = 0;
|
||||
//查看任务日志
|
||||
function getLogs(id){
|
||||
layer.msg(lan.public.the_get,{icon:16,time:0,shade: [0.3, '#000']});
|
||||
var data='&id='+id
|
||||
$.post('/crontab?action=GetLogs',data,function(rdata){
|
||||
layer.msg('正在获取,请稍候...',{icon:16,time:0,shade: [0.3, '#000']});
|
||||
var data='&id='+id;
|
||||
$.post('/crontab/logs', data, function(rdata){
|
||||
layer.closeAll();
|
||||
if(!rdata.status) {
|
||||
layer.msg(rdata.msg,{icon:2});
|
||||
@@ -18,39 +18,45 @@ function getLogs(id){
|
||||
content:'<div class="setchmod bt-form pd20 pb70">'
|
||||
+'<pre id="crontab-log" style="overflow: auto; border: 0px none; padding: 15px; margin: 0px; height: 410px; background-color: rgb(255, 255, 255);"></pre>'
|
||||
+'<div class="bt-form-submit-btn" style="margin-top: 0px;">'
|
||||
+'<button type="button" class="btn btn-success btn-sm" onclick="CloseLogs('+id+')">'+lan.public.empty+'</button>'
|
||||
+'<button type="button" class="btn btn-danger btn-sm" onclick="layer.closeAll()">'+lan.public.close+'</button>'
|
||||
+'<button type="button" class="btn btn-success btn-sm" onclick="CloseLogs('+id+')">清空</button>'
|
||||
+'<button type="button" class="btn btn-danger btn-sm" onclick="layer.closeAll()">关闭</button>'
|
||||
+'</div>'
|
||||
+'</div>'
|
||||
});
|
||||
|
||||
|
||||
setTimeout(function(){
|
||||
$("#crontab-log").text(rdata.msg);
|
||||
},200)
|
||||
},200);
|
||||
});
|
||||
}
|
||||
|
||||
function getCronData(){
|
||||
var laid=layer.msg(lan.public.the,{icon:16,time:0,shade: [0.3, '#000']});
|
||||
$.post('/crontab/list','',function(rdata){
|
||||
layer.close(laid);
|
||||
var load = layer.msg(lan.public.the,{icon:16,time:0,shade: [0.3, '#000']});
|
||||
$.post('/crontab/list', '', function(rdata){
|
||||
layer.close(load);
|
||||
console.log(rdata);
|
||||
var cbody = "";
|
||||
if(rdata == ""){
|
||||
cbody="<tr><td colspan='6'>"+lan.crontab.task_empty+"</td></tr>";
|
||||
}else{
|
||||
for(var i=0;i<rdata.data.length;i++){
|
||||
//状态
|
||||
var status = rdata.data[i]['status'] == '1'? '正常':'停用';
|
||||
|
||||
cbody += "<tr>\
|
||||
<td><input type='checkbox' onclick='checkSelect();' title='"+rdata.data[i].name+"' name='id' value='"+rdata.data[i].id+"'></td>\
|
||||
<td>"+rdata.data[i].name+"</td>\
|
||||
<td>"+status+"</td>\
|
||||
<td>"+rdata.data[i].type+"</td>\
|
||||
<td>"+rdata.data[i].cycle+"</td>\
|
||||
<td>-</td>\
|
||||
<td>--</td>\
|
||||
<td>"+rdata.data[i].addtime+"</td>\
|
||||
<td>\
|
||||
<a href=\"javascript:startTask("+rdata.data[i].id+");\" class='btlink'>"+lan.public.exec+"</a> | \
|
||||
<a href=\"javascript:onlineEditFile(0,'/www/server/cron/"+rdata.data[i].echo+"');\" class='btlink'>"+lan.public.script+"</a> | \
|
||||
<a href=\"javascript:getLogs("+rdata.data[i].id+");\" class='btlink'>"+lan.public.log+"</a> | \
|
||||
<a href=\"javascript:planDel("+rdata.data[i].id+" ,'"+rdata.data[i].name.replace('\\','\\\\').replace("'","\\'").replace('"','')+"');\" class='btlink'>"+lan.public.del+"</a>\
|
||||
<a href=\"javascript:startTask("+rdata.data[i].id+");\" class='btlink'>执行</a> | \
|
||||
<a href=\"javascript:onlineEditFile(0,'/www/server/cron/"+rdata.data[i].echo+"');\" class='btlink'>脚本</a> | \
|
||||
<a href=\"javascript:getLogs("+rdata.data[i].id+");\" class='btlink'>日志</a> | \
|
||||
<a href=\"javascript:planDel("+rdata.data[i].id+" ,'"+rdata.data[i].name.replace('\\','\\\\').replace("'","\\'").replace('"','')+"');\" class='btlink'>删除</a>\
|
||||
</td>\
|
||||
</tr>";
|
||||
}
|
||||
|
||||
@@ -149,7 +149,10 @@
|
||||
<th>状态</th>
|
||||
<th>周期</th>
|
||||
<th>执行时机</th>
|
||||
<th width="190">保存数量</th>
|
||||
<th>保存数量</th>
|
||||
<th>备份到</th>
|
||||
<th>添加时间</th>
|
||||
<th width="190">操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="cronbody"></tbody>
|
||||
|
||||
Reference in New Issue
Block a user