From 79c1e81d2cd1a79cd0d2b2a3848d5a85d2b4f64c Mon Sep 17 00:00:00 2001 From: midoks Date: Sun, 18 Dec 2022 15:46:12 +0800 Subject: [PATCH] up --- class/core/config_api.py | 2 +- route/static/app/crontab.js | 335 ++++++++++++++------------- route/static/app/public.js | 38 +-- route/templates/default/crontab.html | 2 +- 4 files changed, 198 insertions(+), 179 deletions(-) diff --git a/class/core/config_api.py b/class/core/config_api.py index bded838a7..08d7a229c 100755 --- a/class/core/config_api.py +++ b/class/core/config_api.py @@ -27,7 +27,7 @@ from flask import request class config_api: - __version = '0.11.4.8' + __version = '0.11.4.9' __api_addr = 'data/api.json' def __init__(self): diff --git a/route/static/app/crontab.js b/route/static/app/crontab.js index eab010dba..a88d91774 100755 --- a/route/static/app/crontab.js +++ b/route/static/app/crontab.js @@ -61,7 +61,7 @@ function getCronData(page){ } var cron_backupto = '-'; - if (rdata.data[i]['stype'] == 'site' || rdata.data[i]['stype']=='database' || rdata.data[i]['stype'].indexOf('database_')>-1 ){ + if (rdata.data[i]['stype'] == 'site' || rdata.data[i]['stype']=='path' || rdata.data[i]['stype']=='database' || rdata.data[i]['stype'].indexOf('database_')>-1 ){ cron_backupto = '本地磁盘'; if (rdata.data[i]['backup_to'] != 'localhost'){ cron_backupto = getBackupName(rdata['backup_hook'],rdata.data[i]['backup_to']); @@ -297,7 +297,6 @@ function planAdd(){ $("#set-Config input[name='sName']").val(sName); layer.msg('正在添加,请稍候...!',{icon:16,time:0,shade: [0.3, '#000']}); var data = $("#set-Config").serialize() + '&sBody='+sBody + '&urladdress=' + urladdress; - // console.log(data); $.post('/crontab/add',data,function(rdata){ if(!rdata.status) { layer.msg(rdata.msg,{icon:2, time:2000}); @@ -500,11 +499,11 @@ function toBackup(type){ var changeDir = ''; if (sType == 'path'){ - changeDir = ''; + changeDir = ''; } - var sBody = ''; $("#implement").html(sBody); getselectname(); + + $('.changePathDir').click(function(){ + changePathCallback($('#sName').val(),function(select_dir){ + $(".planname input[name='name']").val('备份目录['+select_dir+']'); + $('#implement .sname b').attr('val',select_dir).text(select_dir); + }); + }); + + $(".dropdown ul li a").click(function(){ var sName = $("#sName").attr("val"); if(!sName) return; @@ -618,7 +626,7 @@ function editTaskInfo(id){ var changeDir = ''; if (obj.from.stype == 'path'){ - changeDir = ''; + changeDir = ''; } layer.open({ @@ -707,165 +715,174 @@ function editTaskInfo(id){
\
保存编辑
\
\ - ' - ,cancel: function(){ - initDropdownMenu(); - } - }); - setTimeout(function(){ - if(obj.from.stype == 'toShell'){ - $('.site_list').hide(); - }else if(obj.from.stype == 'rememory'){ - $('.site_list').hide(); - }else if( obj.from.stype == 'toUrl'){ - $('.site_list').hide(); - }else{ - $('.site_list').show(); - } + ', + + success:function(){ + + $('.changePathDir').click(function(){ + changePathCallback($('#sName').val(),function(select_dir){ + $('input[name="name"]').val('备份目录['+select_dir+']'); + $('.sName_btn button b').attr('val',select_dir).text(select_dir); + }); + }); + + if(obj.from.stype == 'toShell'){ + $('.site_list').hide(); + }else if(obj.from.stype == 'rememory'){ + $('.site_list').hide(); + }else if( obj.from.stype == 'toUrl'){ + $('.site_list').hide(); + }else{ + $('.site_list').show(); + } - obj.from.minute = $('.minute_create').val(); - obj.from.hour = $('.hour_create').val(); - obj.from.where1 = $('.where1_create').val(); + obj.from.minute = $('.minute_create').val(); + obj.from.hour = $('.hour_create').val(); + obj.from.where1 = $('.where1_create').val(); - $('.sName_create').blur(function () { - obj.from.name = $(this).val(); - }); - $('.where1_create').blur(function () { - obj.from.where1 = $(this).val(); - }); - - $('.hour_create').blur(function () { - obj.from.hour = $(this).val(); - }); - - $('.minute_create').blur(function () { - obj.from.minute = $(this).val(); - }); - - $('.save_create').blur(function () { - obj.from.save = $(this).val(); - }); - - $('.sBody_create').blur(function () { - obj.from.sbody = $(this).val(); - }); - $('.url_create').blur(function () { - obj.from.urladdress = $(this).val(); - }); - - $('[aria-labelledby="cycle"] a').unbind().click(function () { - $('.cycle_btn').find('b').attr('val',$(this).attr('value')).html($(this).html()); - var type = $(this).attr('value'); - switch(type){ - case 'day': - $('.week_btn').hide(); - $('.where1_input').hide(); - $('.hour_input').show().find('input').val('1'); - $('.minute_input').show().find('input').val('30'); - obj.from.week = ''; - obj.from.type = ''; - obj.from.hour = 1; - obj.from.minute = 30; - break; - case 'day-n': - $('.week_btn').hide(); - $('.where1_input').show().find('input').val('1'); - $('.hour_input').show().find('input').val('1'); - $('.minute_input').show().find('input').val('30'); - obj.from.week = ''; - obj.from.where1 = 1; - obj.from.hour = 1; - obj.from.minute = 30; - break; - case 'hour': - $('.week_btn').hide(); - $('.where1_input').hide(); - $('.hour_input').hide(); - $('.minute_input').show().find('input').val('30'); - obj.from.week = ''; - obj.from.where1 = ''; - obj.from.hour = ''; - obj.from.minute = 30; - break; - case 'hour-n': - $('.week_btn').hide(); - $('.where1_input').hide(); - $('.hour_input').show().find('input').val('1'); - $('.minute_input').show().find('input').val('30'); - obj.from.week = ''; - obj.from.where1 = ''; - obj.from.hour = 1; - obj.from.minute = 30; - break; - case 'minute-n': - $('.week_btn').hide(); - $('.where1_input').hide(); - $('.hour_input').hide(); - $('.minute_input').show(); - obj.from.week = ''; - obj.from.where1 = ''; + $('.sName_create').blur(function () { + obj.from.name = $(this).val(); + }); + $('.where1_create').blur(function () { + obj.from.where1 = $(this).val(); + }); + + $('.hour_create').blur(function () { + obj.from.hour = $(this).val(); + }); + + $('.minute_create').blur(function () { + obj.from.minute = $(this).val(); + }); + + $('.save_create').blur(function () { + obj.from.save = $(this).val(); + }); + + $('.sBody_create').blur(function () { + obj.from.sbody = $(this).val(); + }); + $('.url_create').blur(function () { + obj.from.urladdress = $(this).val(); + }); + + $('[aria-labelledby="cycle"] a').unbind().click(function () { + $('.cycle_btn').find('b').attr('val',$(this).attr('value')).html($(this).html()); + var type = $(this).attr('value'); + switch(type){ + case 'day': + $('.week_btn').hide(); + $('.where1_input').hide(); + $('.hour_input').show().find('input').val('1'); + $('.minute_input').show().find('input').val('30'); + obj.from.week = ''; + obj.from.type = ''; + obj.from.hour = 1; + obj.from.minute = 30; + break; + case 'day-n': + $('.week_btn').hide(); + $('.where1_input').show().find('input').val('1'); + $('.hour_input').show().find('input').val('1'); + $('.minute_input').show().find('input').val('30'); + obj.from.week = ''; + obj.from.where1 = 1; + obj.from.hour = 1; + obj.from.minute = 30; + break; + case 'hour': + $('.week_btn').hide(); + $('.where1_input').hide(); + $('.hour_input').hide(); + $('.minute_input').show().find('input').val('30'); + obj.from.week = ''; + obj.from.where1 = ''; + obj.from.hour = ''; + obj.from.minute = 30; + break; + case 'hour-n': + $('.week_btn').hide(); + $('.where1_input').hide(); + $('.hour_input').show().find('input').val('1'); + $('.minute_input').show().find('input').val('30'); + obj.from.week = ''; + obj.from.where1 = ''; + obj.from.hour = 1; + obj.from.minute = 30; + break; + case 'minute-n': + $('.week_btn').hide(); + $('.where1_input').hide(); + $('.hour_input').hide(); + $('.minute_input').show(); + obj.from.week = ''; + obj.from.where1 = ''; + obj.from.hour = ''; + obj.from.minute = 30; + console.log(obj.from); + break; + case 'week': + $('.week_btn').show(); + $('.where1_input').hide(); + $('.hour_input').show(); + $('.minute_input').show(); + obj.from.week = 1; + obj.from.where1 = ''; + obj.from.hour = 1; + obj.from.minute = 30; + break; + case 'month': + $('.week_btn').hide(); + $('.where1_input').show(); + $('.hour_input').show(); + $('.minute_input').show(); + obj.from.week = ''; + obj.from.where1 = 1; + obj.from.hour = 1; + obj.from.minute = 30; + break; + } + obj.from.type = $(this).attr('value'); + }); + + $('[aria-labelledby="week"] a').unbind().click(function () { + $('.week_btn').find('b').attr('val',$(this).attr('value')).html($(this).html()); + obj.from.week = $(this).attr('value'); + }); + + $('[aria-labelledby="backupTo"] a').unbind().click(function () { + $('.backup_btn').find('b').attr('val',$(this).attr('value')).html($(this).html()); + obj.from.backup_to = $(this).attr('value'); + }); + $('.plan-submits').unbind().click(function(){ + if(obj.from.type == 'hour-n'){ + obj.from.where1 = obj.from.hour; obj.from.hour = ''; - obj.from.minute = 30; - console.log(obj.from); - break; - case 'week': - $('.week_btn').show(); - $('.where1_input').hide(); - $('.hour_input').show(); - $('.minute_input').show(); - obj.from.week = 1; - obj.from.where1 = ''; - obj.from.hour = 1; - obj.from.minute = 30; - break; - case 'month': - $('.week_btn').hide(); - $('.where1_input').show(); - $('.hour_input').show(); - $('.minute_input').show(); - obj.from.week = ''; - obj.from.where1 = 1; - obj.from.hour = 1; - obj.from.minute = 30; - break; - } - obj.from.type = $(this).attr('value'); - }); - - $('[aria-labelledby="week"] a').unbind().click(function () { - $('.week_btn').find('b').attr('val',$(this).attr('value')).html($(this).html()); - obj.from.week = $(this).attr('value'); - }); - - $('[aria-labelledby="backupTo"] a').unbind().click(function () { - $('.backup_btn').find('b').attr('val',$(this).attr('value')).html($(this).html()); - obj.from.backup_to = $(this).attr('value'); - }); - $('.plan-submits').unbind().click(function(){ - if(obj.from.type == 'hour-n'){ - obj.from.where1 = obj.from.hour; - obj.from.hour = ''; - } else if(obj.from.type == 'minute-n') { - obj.from.where1 = obj.from.minute; - obj.from.minute = ''; - } - var loadT = layer.msg('正在保存编辑内容,请稍后...',{icon:16,time:0,shade: [0.3, '#000']}); - $.post('/crontab/modify_crond',obj.from,function(rdata){ - - if (!rdata.status){ - layer.msg(rdata.msg,{icon:rdata.status?1:2}); - return; + } else if(obj.from.type == 'minute-n') { + obj.from.where1 = obj.from.minute; + obj.from.minute = ''; } + var loadT = layer.msg('正在保存编辑内容,请稍后...',{icon:16,time:0,shade: [0.3, '#000']}); + $.post('/crontab/modify_crond',obj.from,function(rdata){ - showMsg(rdata.msg, function(){ - layer.closeAll(); - getCronData(1); - initDropdownMenu(); - },{icon:rdata.status?1:2}, 2000); + if (!rdata.status){ + layer.msg(rdata.msg,{icon:rdata.status?1:2}); + return; + } - },'json'); - }); - },100); + showMsg(rdata.msg, function(){ + layer.closeAll(); + getCronData(1); + initDropdownMenu(); + },{icon:rdata.status?1:2}, 2000); + + },'json'); + }); + } + ,cancel: function(){ + initDropdownMenu(); + } + }); }); },'json'); } diff --git a/route/static/app/public.js b/route/static/app/public.js index f2c0fd587..08b576838 100755 --- a/route/static/app/public.js +++ b/route/static/app/public.js @@ -220,7 +220,7 @@ function getFormatTime(tm, format) { -function changePathCallback() { +function changePathCallback(default_dir, callback) { var c = layer.open({ type: 1, @@ -236,26 +236,27 @@ function changePathCallback() { 文件名修改时间权限所有者\
\ \ - \ - \ + \ + \
", - success:function(){ - + success:function(layero,layer_index){ + $('.btn-close').click(function(){ + layer.close(layer_index); + }); + + $('.btn-choose').click(function(){ + var a = $("#PathPlace").find("span").text(); + a = a.replace(new RegExp(/(\\)/g), "/"); + a_len = a.length; + if (a[a_len-1] == '/'){ + a = a.substr(0,a_len-1); + } + callback(a); + layer.close(layer_index); + }); } }); - setCookie("changePath", c); - var b = $("#" + d).val(); - tmp = b.split("."); - if(tmp[tmp.length - 1] == "gz") { - tmp = b.split("/"); - b = ""; - for(var a = 0; a < tmp.length - 1; a++) { - b += "/" + tmp[a] - } - setCookie("SetName", tmp[tmp.length - 1]) - } - b = b.replace(/\/\//g, "/"); - getDiskList(b); + getDiskList(default_dir); activeDisk(); } @@ -462,6 +463,7 @@ function getfilePath() { $("#" + getCookie("SetId")).val(a + getCookie("SetName")); layer.close(getCookie("changePath")); + return a; } function setCookie(a, c) { diff --git a/route/templates/default/crontab.html b/route/templates/default/crontab.html index b9cb0acac..b1f24ecad 100755 --- a/route/templates/default/crontab.html +++ b/route/templates/default/crontab.html @@ -106,7 +106,7 @@ - +