pull/109/head
midoks 5 years ago
parent 4d0f8f4728
commit 68a8e39120
  1. 2
      class/core/config_api.py
  2. 34
      class/core/crontab_api.py
  3. 15
      route/static/app/crontab.js
  4. 3
      route/templates/default/crontab.html

@ -17,7 +17,7 @@ class config_api:
# 本版解决自启动问题 # 本版解决自启动问题
# 文件管理重命名 # 文件管理重命名
__version = '0.8.5' __version = '0.8.6'
def __init__(self): def __init__(self):
pass pass

@ -21,8 +21,15 @@ class crontab_api:
##### ----- start ----- ### ##### ----- start ----- ###
def listApi(self): def listApi(self):
_list = mw.M('crontab').where('', ()).field(self.field).limit( p = request.form.get('p', 1)
'0,30').order('id desc').select() psize = 3
startPage = (p - 1) * psize
pageInfo = str(startPage) + ',' + str(psize)
_list = mw.M('crontab').where('', ()).field(
self.field).limit(pageInfo).order('id desc').select()
data = [] data = []
for i in range(len(_list)): for i in range(len(_list)):
@ -68,9 +75,11 @@ class crontab_api:
count = mw.M('crontab').where('', ()).count() count = mw.M('crontab').where('', ()).count()
_page = {} _page = {}
_page['count'] = count _page['count'] = count
_page['tojs'] = 'remind' _page['p'] = p
_page['row'] = psize
_page['tojs'] = "getCronData"
_ret['page'] = mw.getPage(_page) _ret['list'] = mw.getPage(_page)
return mw.getJson(_ret) return mw.getJson(_ret)
# 设置计划任务状态 # 设置计划任务状态
@ -194,25 +203,26 @@ class crontab_api:
} }
# print params # print params
cuonConfig, get, name = self.getCrondCycle(params) cronConfig, get, name = self.getCrondCycle(params)
cronPath = mw.getServerDir() + '/cron' cronPath = mw.getServerDir() + '/cron'
cronName = self.getShell(params) cronName = self.getShell(params)
# print cuonConfig, _params, name # print cronConfig, _params, name
# print cronPath, cronName # print 'vv', cronPath, cronName
# print stype # print 'stype', stype
if type(cronName) == dict: if type(cronName) == dict:
return cronName return cronName
cuonConfig += ' ' + cronPath + '/' + cronName + \ cronConfig += ' ' + cronPath + '/' + cronName + \
' >> ' + cronPath + '/' + cronName + '.log 2>&1' ' >> ' + cronPath + '/' + cronName + '.log 2>&1'
wRes = self.writeShell(cuonConfig)
if not mw.isAppleSystem():
wRes = self.writeShell(cronConfig)
if type(wRes) != bool: if type(wRes) != bool:
return wRes return wRes
self.crondReload() self.crondReload()
addData = mw.M('crontab').add('name,type,where1,where_hour,where_minute,echo,addtime,status,save,backup_to,stype,sname,sbody,urladdress', (iname, field_type, where1, hour, minute, cronName, time.strftime( addData = mw.M('crontab').add('name,type,where1,where_hour,where_minute,echo,addtime,status,save,backup_to,stype,sname,sbody,urladdress', (iname, field_type, where1, hour, minute, cronName, time.strftime(
'%Y-%m-%d %X', time.localtime()), 1, save, backup_to, stype, sname, sbody, urladdress)) '%Y-%m-%d %X', time.localtime()), 1, save, backup_to, stype, sname, sbody, urladdress))
@ -451,7 +461,7 @@ echo "--------------------------------------------------------------------------
if not os.path.exists(file): if not os.path.exists(file):
mw.writeFile(file, '') mw.writeFile(file, '')
conf = mw.readFile(file) conf = mw.readFile(file)
conf += config + "\n" conf += str(config) + "\n"
if mw.writeFile(file, conf): if mw.writeFile(file, conf):
if not os.path.exists(u_file): if not os.path.exists(u_file):
mw.execShell("chmod 600 '" + file + mw.execShell("chmod 600 '" + file +

@ -40,9 +40,9 @@ function getLogs(id){
},'json'); },'json');
} }
function getCronData(){ function getCronData(page){
var load = layer.msg(lan.public.the,{icon:16,time:0,shade: [0.3, '#000']}); var load = layer.msg(lan.public.the,{icon:16,time:0,shade: [0.3, '#000']});
$.post('/crontab/list', '', function(rdata){ $.post('/crontab/list?p='+str(page),'', function(rdata){
layer.close(load); layer.close(load);
var cbody = ""; var cbody = "";
if(rdata == ""){ if(rdata == ""){
@ -73,6 +73,7 @@ function getCronData(){
} }
} }
$('#cronbody').html(cbody); $('#cronbody').html(cbody);
$('#softPage').html(rdata.list)
},'json'); },'json');
} }
@ -86,7 +87,7 @@ function setTaskStatus(id,status){
layer.close(confirm); layer.close(confirm);
layer.msg(rdata.data,{icon:rdata.status?1:2}); layer.msg(rdata.data,{icon:rdata.status?1:2});
if(rdata.status) { if(rdata.status) {
getCronData(); getCronData(1);
} }
},'json'); },'json');
} }
@ -123,7 +124,7 @@ function planDel(id,name){
$.post('/crontab/del',data,function(rdata){ $.post('/crontab/del',data,function(rdata){
layer.close(load); layer.close(load);
showMsg(rdata.msg, function(){ showMsg(rdata.msg, function(){
getCronData(); getCronData(1);
},{icon:rdata.status?1:2,time:2000}); },{icon:rdata.status?1:2,time:2000});
},'json'); },'json');
}); });
@ -312,7 +313,7 @@ function planAdd(){
} }
layer.closeAll(); layer.closeAll();
layer.msg(rdata.msg,{icon:rdata.status?1:2}); layer.msg(rdata.msg,{icon:rdata.status?1:2});
getCronData(); getCronData(1);
},'json'); },'json');
} }
@ -347,7 +348,7 @@ function allAddCrontab(dataList,successCount,errorMsg){
layer.close(loadT); layer.close(loadT);
if(frdata.status){ if(frdata.status){
successCount++; successCount++;
getCronData(); getCronData(1);
}else{ }else{
if(!errorMsg){ if(!errorMsg){
errorMsg = '<br><p>'+lan.crontab.backup_all_err+'</p>'; errorMsg = '<br><p>'+lan.crontab.backup_all_err+'</p>';
@ -802,7 +803,7 @@ function editTaskInfo(id){
layer.msg('正在保存编辑内容,请稍后...',{icon:16,time:0,shade: [0.3, '#000']}); layer.msg('正在保存编辑内容,请稍后...',{icon:16,time:0,shade: [0.3, '#000']});
$.post('/crontab/modify_crond',obj.from,function(rdata){ $.post('/crontab/modify_crond',obj.from,function(rdata){
layer.closeAll(); layer.closeAll();
getCronData(); getCronData(1);
layer.msg(rdata.msg,{icon:rdata.status?1:2}); layer.msg(rdata.msg,{icon:rdata.status?1:2});
},'json'); },'json');
}); });

@ -132,6 +132,9 @@
</thead> </thead>
<tbody id="cronbody"></tbody> <tbody id="cronbody"></tbody>
</table> </table>
<div class="dataTables_paginate paging_bootstrap pagination">
<ul id="softPage" class="page"></ul>
</div>
</div> </div>
</div> </div>
</div> </div>

Loading…
Cancel
Save