重新初始化
This commit is contained in:
@@ -1,134 +0,0 @@
|
||||
{extend name="admin/base"/}
|
||||
{block name="body"}
|
||||
<div class="box box-primary">
|
||||
<header class="box-header with-border">
|
||||
<!-- 标题栏 -->
|
||||
<h3 class="box-title">数据备份</h3>
|
||||
<div class="pull-right">
|
||||
<a id="export" class="btn btn-primary" href="javascript:;" autocomplete="off">立即备份</a>
|
||||
<a id="optimize" class="btn btn-success" href="{:url('optimize')}">优化表</a>
|
||||
<a id="repair" class="btn btn-warning" href="{:url('repair')}">修复表</a>
|
||||
</div>
|
||||
</header>
|
||||
<div class="box-body">
|
||||
<form id="export-form" method="post" action="{:url('export')}">
|
||||
<div class="table-responsive clearfix">
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th width="48">
|
||||
<input class="check-all" checked="chedked" type="checkbox" value=""></th>
|
||||
<th>表名</th>
|
||||
<th width="120">数据量</th>
|
||||
<th width="120">数据大小</th>
|
||||
<th width="180">创建时间</th>
|
||||
<th width="160">备份状态</th>
|
||||
<th width="120">操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{volist name="list" id="table"}
|
||||
<tr>
|
||||
<td class="num">
|
||||
<input class="ids" checked="chedked" type="checkbox" name="tables[]" value="{$table.name}"></td>
|
||||
<td>{$table.name}</td>
|
||||
<td>{$table.rows}</td>
|
||||
<td>{$table.data_length|format_bytes}</td>
|
||||
<td>{$table.create_time}</td>
|
||||
<td class="info">未备份</td>
|
||||
<td class="action">
|
||||
<a class="ajax-get no-refresh" href="{:url('optimize?tables='.$table['name'])}">优化表</a>
|
||||
|
||||
<a class="ajax-get no-refresh" href="{:url('repair?tables='.$table['name'])}">修复表</a>
|
||||
</td>
|
||||
</tr>
|
||||
{/volist}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
{/block}
|
||||
|
||||
{block name="script"}
|
||||
<script type="text/javascript">
|
||||
(function($){
|
||||
var $form = $("#export-form"), $export = $("#export"), tables
|
||||
$optimize = $("#optimize"), $repair = $("#repair");
|
||||
|
||||
$optimize.add($repair).click(function(){
|
||||
$.post(this.href, $form.serialize(), function(data){
|
||||
if(data.code){
|
||||
updateAlert(data.msg,'alert-success');
|
||||
} else {
|
||||
updateAlert(data.msg,'alert-error');
|
||||
}
|
||||
setTimeout(function(){
|
||||
$('#top-alert').find('button').click();
|
||||
$(that).removeClass('disabled').prop('disabled',false);
|
||||
},1500);
|
||||
}, "json");
|
||||
return false;
|
||||
});
|
||||
|
||||
$export.click(function(){
|
||||
$export.parent().children().addClass("disabled");
|
||||
$export.html("正在发送备份请求...");
|
||||
$.post(
|
||||
$form.attr("action"),
|
||||
$form.serialize(),
|
||||
function(data){
|
||||
if(data.code){
|
||||
tables = data.data.tables;
|
||||
$export.html(data.msg + "开始备份,请不要关闭本页面!");
|
||||
backup(data.data.tab);
|
||||
window.onbeforeunload = function(){ return "正在备份数据库,请不要关闭!" }
|
||||
} else {
|
||||
updateAlert(data.msg,'alert-error');
|
||||
$export.parent().children().removeClass("disabled");
|
||||
$export.html("立即备份");
|
||||
setTimeout(function(){
|
||||
$('#top-alert').find('button').click();
|
||||
$(that).removeClass('disabled').prop('disabled',false);
|
||||
},1500);
|
||||
}
|
||||
},
|
||||
"json"
|
||||
);
|
||||
return false;
|
||||
});
|
||||
|
||||
function backup(tab, status){
|
||||
status && showmsg(tab.id, "开始备份...(0%)");
|
||||
$.get($form.attr("action"), tab, function(data){
|
||||
if(data.code){
|
||||
var info = data.data;
|
||||
showmsg(tab.id, data.msg);
|
||||
|
||||
if(!$.isPlainObject(info.tab)){
|
||||
$export.parent().children().removeClass("disabled");
|
||||
$export.html("备份完成,点击重新备份");
|
||||
window.onbeforeunload = function(){ return null }
|
||||
return;
|
||||
}
|
||||
backup(info.tab, tab.id != info.tab.id);
|
||||
} else {
|
||||
updateAlert(data.msg,'alert-error');
|
||||
$export.parent().children().removeClass("disabled");
|
||||
$export.html("立即备份");
|
||||
setTimeout(function(){
|
||||
$('#top-alert').find('button').click();
|
||||
$(that).removeClass('disabled').prop('disabled',false);
|
||||
},1500);
|
||||
}
|
||||
}, "json");
|
||||
|
||||
}
|
||||
|
||||
function showmsg(id, msg){
|
||||
$form.find("input[value=" + tables[id] + "]").closest("tr").find(".info").html(msg);
|
||||
}
|
||||
})(jQuery);
|
||||
</script>
|
||||
{/block}
|
||||
@@ -1,85 +0,0 @@
|
||||
{extend name="admin/base"/}
|
||||
|
||||
{block name="body"}
|
||||
<div class="box box-primary">
|
||||
<header class="box-header with-border">
|
||||
<!-- 标题栏 -->
|
||||
<h3 class="box-title">数据恢复</h3>
|
||||
<div class="pull-right">
|
||||
</div>
|
||||
</header>
|
||||
<div class="box-body">
|
||||
|
||||
<div class="table-responsive clearfix">
|
||||
<!-- 应用列表 -->
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th width="200">备份名称</th>
|
||||
<th width="80">卷数</th>
|
||||
<th width="80">压缩</th>
|
||||
<th width="80">数据大小</th>
|
||||
<th width="200">备份时间</th>
|
||||
<th>状态</th>
|
||||
<th width="120">操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{volist name="list" id="item"}
|
||||
<tr>
|
||||
<td>{$item['time']}</td>
|
||||
<td>{$item['part']}</td>
|
||||
<td>{$item['compress']}</td>
|
||||
<td>{$item['size']|format_bytes}</td>
|
||||
<td>{$key}</td>
|
||||
<td>-</td>
|
||||
<td class="action">
|
||||
<a class="db-import" href="{:url('import?time='.$item['time'])}">还原</a>
|
||||
|
||||
<a class="ajax-get confirm" href="{:url('del?time='.$item['time'])}">删除</a>
|
||||
</td>
|
||||
</tr>
|
||||
{/volist}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<!-- /应用列表 -->
|
||||
</div>
|
||||
{/block}
|
||||
|
||||
{block name="script"}
|
||||
<script type="text/javascript">
|
||||
$(".db-import").click(function(){
|
||||
var self = this, status = ".";
|
||||
$.get(self.href, success, "json");
|
||||
window.onbeforeunload = function(){ return "正在还原数据库,请不要关闭!" }
|
||||
return false;
|
||||
|
||||
function success(data){
|
||||
if(data.code){
|
||||
if(data.data.gz){
|
||||
data.msg += status;
|
||||
if(status.length === 5){
|
||||
status = ".";
|
||||
} else {
|
||||
status += ".";
|
||||
}
|
||||
}
|
||||
$(self).parent().prev().text(data.msg);
|
||||
if(data.data.part){
|
||||
$.get(self.href,
|
||||
{"part" : data.data.part, "start" : data.data.start},
|
||||
success,
|
||||
"json"
|
||||
);
|
||||
} else {
|
||||
window.onbeforeunload = function(){ return null; }
|
||||
}
|
||||
} else {
|
||||
updateAlert(data.msg,'alert-error');
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
{/block}
|
||||
Reference in New Issue
Block a user