mirror of https://github.com/1099438829/apeblog
修正还原
This commit is contained in:
parent
ea845ed9f8
commit
ad78a38601
|
|
@ -93,25 +93,26 @@ class Databases extends AuthController
|
||||||
}
|
}
|
||||||
$extension = strtoupper(pathinfo($file->getFilename(), PATHINFO_EXTENSION));
|
$extension = strtoupper(pathinfo($file->getFilename(), PATHINFO_EXTENSION));
|
||||||
$info['compress'] = ($extension === 'SQL') ? '-' : $extension;
|
$info['compress'] = ($extension === 'SQL') ? '-' : $extension;
|
||||||
$info['time'] = strtotime("{$date} {$time}");
|
$info['time'] = "{$date} {$time}";
|
||||||
|
$info['key'] = strtotime("{$date} {$time}");
|
||||||
$list["{$date} {$time}"] = $info;
|
$list[] = $info;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$title = '数据还原';
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* 数据备份 */
|
/* 数据备份 */
|
||||||
case 'export':
|
case 'export':
|
||||||
$list = Db::query('SHOW TABLE STATUS');
|
$list = Db::query('SHOW TABLE STATUS');
|
||||||
$list = array_map('array_change_key_case', $list);
|
$list = array_map('array_change_key_case', $list);
|
||||||
$title = '数据备份';
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
$this->error('参数错误!');
|
$this->error('参数错误!');
|
||||||
}
|
}
|
||||||
return app("json")->layui($list);
|
$result = [
|
||||||
|
"data" => $list,
|
||||||
|
"count" => count($list)
|
||||||
|
];
|
||||||
|
return app("json")->layui($result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -170,19 +171,15 @@ class Databases extends AuthController
|
||||||
*/
|
*/
|
||||||
public function delOne(){
|
public function delOne(){
|
||||||
$data = Util::postMore([
|
$data = Util::postMore([
|
||||||
['time',''],
|
['key',''],
|
||||||
]);
|
]);
|
||||||
if ($data['time'] == "") return app("json")->fail("参数错误");
|
if ($data['key'] == "") return app("json")->fail("参数错误");
|
||||||
$name = date('Ymd-His', $data['time']) . '-*.sql*';
|
$name = date('Ymd-His', $data['key']) . '-*.sql*';
|
||||||
$path = realpath(system_config('data_backup_path')) . DIRECTORY_SEPARATOR . $name;
|
$path = realpath(system_config('data_backup_path')) . DIRECTORY_SEPARATOR . $name;
|
||||||
array_map("unlink", glob($path));
|
array_map("unlink", glob($path));
|
||||||
return !count(glob($path)) ? app("json")->success("备份文件删除成功",'code') : app("json")->fail("备份文件删除失败,请检查权限");
|
return !count(glob($path)) ? app("json")->success("备份文件删除成功",'code') : app("json")->fail("备份文件删除失败,请检查权限");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 备份数据库
|
* 备份数据库
|
||||||
* @return mixed
|
* @return mixed
|
||||||
|
|
@ -275,13 +272,13 @@ class Databases extends AuthController
|
||||||
*/
|
*/
|
||||||
public function import(){
|
public function import(){
|
||||||
$data = Util::postMore([
|
$data = Util::postMore([
|
||||||
['time',''],
|
['key',''],
|
||||||
['part',''],
|
['part',''],
|
||||||
['start',''],
|
['start',''],
|
||||||
]);
|
]);
|
||||||
if(is_numeric($data['time']) && is_null($data['part']) && is_null($data['start'])){ //初始化
|
if(is_numeric($data['key']) && is_null($data['part']) && is_null($data['start'])){ //初始化
|
||||||
//获取备份文件信息
|
//获取备份文件信息
|
||||||
$name = date('Ymd-His', $data['time']) . '-*.sql*';
|
$name = date('Ymd-His', $data['key']) . '-*.sql*';
|
||||||
$path = realpath(system_config('data_backup_path')) . DIRECTORY_SEPARATOR . $name;
|
$path = realpath(system_config('data_backup_path')) . DIRECTORY_SEPARATOR . $name;
|
||||||
$files = glob($path);
|
$files = glob($path);
|
||||||
$list = array();
|
$list = array();
|
||||||
|
|
|
||||||
|
|
@ -62,17 +62,11 @@
|
||||||
"rows": res.data,
|
"rows": res.data,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
pagination: true,
|
pagination: false,
|
||||||
queryParams: function(params) {
|
queryParams: function(params) {
|
||||||
let temp = toArrayList($(".searchForm").serializeArray());
|
let temp = toArrayList($(".searchForm").serializeArray());
|
||||||
temp['limit'] = params.limit;
|
|
||||||
temp['page'] = (params.offset / params.limit) + 1;
|
|
||||||
return temp;
|
return temp;
|
||||||
},
|
},
|
||||||
sidePagination: "server",
|
|
||||||
pageNumber: 1,
|
|
||||||
pageSize: 10,
|
|
||||||
pageList: [10, 20, 50, 100],
|
|
||||||
columns: [{
|
columns: [{
|
||||||
checkbox: true, // 是否显示复选框
|
checkbox: true, // 是否显示复选框
|
||||||
},{
|
},{
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@
|
||||||
<head>
|
<head>
|
||||||
<title>{$mate_title} - {:system_config("title")}</title>
|
<title>{$mate_title} - {:system_config("title")}</title>
|
||||||
{include file="public/header" /}
|
{include file="public/header" /}
|
||||||
<link rel="stylesheet" href="__ADMIN_PATH__css/more.css">
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="container-fluid p-t-15">
|
<div class="container-fluid p-t-15">
|
||||||
|
|
@ -24,139 +23,121 @@
|
||||||
|
|
||||||
{include file="public/footer"/}
|
{include file="public/footer"/}
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
// tree-grid使用
|
$('#tb_departments').bootstrapTable({
|
||||||
var $treeTable = $('#tree-table');
|
classes: 'table table-bordered table-hover table-striped',
|
||||||
$treeTable.bootstrapTable({
|
url: '/admin/databases/Lst?type=import',
|
||||||
url: '/admin/category/lst',
|
|
||||||
method: 'post',
|
method: 'post',
|
||||||
|
dataType : 'json', // 因为本示例中是跨域的调用,所以涉及到ajax都采用jsonp,
|
||||||
|
uniqueId: 'id',
|
||||||
|
idField: 'id', // 每行的唯一标识字段
|
||||||
|
toolbar: '#toolbar', // 工具按钮容器
|
||||||
|
showColumns: false, // 是否显示所有的列
|
||||||
|
showRefresh: false, // 是否显示刷新按钮
|
||||||
responseHandler: function (res) {
|
responseHandler: function (res) {
|
||||||
return {
|
return {
|
||||||
|
"total": res.count,
|
||||||
"rows": res.data,
|
"rows": res.data,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
pagination: false,
|
||||||
queryParams: function(params) {
|
queryParams: function(params) {
|
||||||
var temp = toArrayList($(".searchForm").serializeArray());
|
let temp = toArrayList($(".searchForm").serializeArray());
|
||||||
return temp;
|
return temp;
|
||||||
},
|
},
|
||||||
idField: 'id',
|
columns: [{
|
||||||
uniqueId: 'id',
|
field: 'time',
|
||||||
dataType: 'json',
|
title: '备份时间'
|
||||||
toolbar: '#toolbar2',
|
}, {
|
||||||
showColumns: true, // 是否显示所有的列
|
field: 'part',
|
||||||
showRefresh: true, // 是否显示刷新按钮
|
title: '卷数',
|
||||||
columns: [
|
}, {
|
||||||
// {
|
field: 'compress',
|
||||||
// field: 'check',
|
title: '压缩'
|
||||||
// checkbox: true
|
},{
|
||||||
// },
|
field: 'size',
|
||||||
{
|
title: '数据大小',
|
||||||
field: 'title',
|
formatter:function (value,row,index) {
|
||||||
title: '名称',
|
return renderSize(value);
|
||||||
|
}
|
||||||
|
},{
|
||||||
|
field: 'status',
|
||||||
|
title: '状态',
|
||||||
|
}, {
|
||||||
|
field: 'operate',
|
||||||
|
title: '操作',
|
||||||
|
formatter:function (value,row,index) {
|
||||||
|
let html = '<a href="#!" class="btn btn-xs btn-default m-r-5 btn-import" title="还原" data-toggle="tooltip" data-trigger="hover"><i class="mdi mdi-lock-reset"></i></a> \n' +
|
||||||
|
'<a class="btn btn-xs btn-default btn-delete" href="#!" title="删除" data-toggle="tooltip" data-trigger="hover"><i class="mdi mdi-delete"></i></a>';
|
||||||
|
return html;
|
||||||
},
|
},
|
||||||
{
|
events: {
|
||||||
field: 'id',
|
'click .btn-import': function (event, value, row, index) {
|
||||||
title: 'ID',
|
var self = this, status = ".";
|
||||||
},
|
$.get("/admin/databases/import", success, "json");
|
||||||
{
|
window.onbeforeunload = function(){ return "正在还原数据库,请不要关闭!" }
|
||||||
field: 'display',
|
return false;
|
||||||
title: '可见性',
|
|
||||||
formatter: function (value, row, index) {
|
function success(data){
|
||||||
if (value == 0) {
|
if(data.code){
|
||||||
is_checked = '';
|
if(data.gz){
|
||||||
} else if (value == 1){
|
data.msg += status;
|
||||||
is_checked = 'checked="checked"';
|
if(status.length === 5){
|
||||||
}
|
status = ".";
|
||||||
var field = "display";
|
} else {
|
||||||
result = '<label class="lyear-switch switch-primary switch-solid lyear-status"><input type="checkbox" '+ is_checked +'><span onClick="updateStatus('+ row.id +', '+ value +', \''+ field +'\')"></span></label>';
|
status += ".";
|
||||||
return result;
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
field: 'sort',
|
|
||||||
title: '排序',
|
|
||||||
sortable: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
field: 'operate',
|
|
||||||
title: '操作',
|
|
||||||
align: 'center',
|
|
||||||
events : {
|
|
||||||
'click .category-add': function (e, value, row, index) {
|
|
||||||
location.href = '/admin/category/add?pid='+row.id;
|
|
||||||
},
|
|
||||||
'click .article-add': function (e, value, row, index) {
|
|
||||||
location.href = '/admin/article/add?category_id='+row.id;
|
|
||||||
},
|
|
||||||
'click .category-delete': function (e, value, row, index) {
|
|
||||||
$.alert({
|
|
||||||
title: '系统提示',
|
|
||||||
content: '删除提醒',
|
|
||||||
buttons: {
|
|
||||||
confirm: {
|
|
||||||
text: '确认',
|
|
||||||
btnClass: 'btn-primary',
|
|
||||||
action: function(){
|
|
||||||
$.post(url="/admin/category/del",data={"id":row.id},function (res) {
|
|
||||||
if (res.code == 200) {parent.lightyear.notify('删除成功', 'success', 3000, 'mdi mdi-emoticon-happy', 'top', 'center');$("#tree-table").bootstrapTable('refresh');}
|
|
||||||
else parent.lightyear.notify('删除失败', 'danger', 3000, 'mdi mdi-emoticon-happy', 'top', 'center');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
|
||||||
cancel: {
|
|
||||||
text: '取消'
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
$(self).parent().prev().text(data.msg);
|
||||||
},
|
if(data.data.part){
|
||||||
'click .category-edit': function (e, value, row, index) {
|
$.get(self.href,
|
||||||
iframe.createIframe('修改分类','/admin/category/edit?id='+row.id)
|
{"part" : data.data.part, "start" : data.data.start},
|
||||||
|
success,
|
||||||
|
"json"
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
window.onbeforeunload = function(){ return null; }
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
top.layer.msg(data.msg?data.msg:'操作失败',{icon: 2,time:data.wait*1000});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
formatter: operateFormatter
|
'click .btn-delete': function (event, value, row, index) {
|
||||||
}
|
$.ajax({
|
||||||
],
|
type: "post",
|
||||||
treeShowField: 'title',
|
url: "/admin/databases/delOne",
|
||||||
parentIdField: 'pid',
|
data: {key:row.key},
|
||||||
|
success: function (res) {
|
||||||
onResetView: function(data) {
|
if (res.code == 200 || res.status == 200) {
|
||||||
$treeTable.treegrid({
|
parent.lightyear.notify(res.msg, 'success', 3000, 'mdi mdi-emoticon-happy', 'top', 'center');
|
||||||
initialState: 'collapsed', // 所有节点都折叠
|
$("#tb_departments").bootstrapTable('refresh');
|
||||||
treeColumn: 1,
|
} else{
|
||||||
//expanderExpandedClass: 'mdi mdi-folder-open', // 可自定义图标样式
|
parent.lightyear.notify(res.msg, 'danger', 3000, 'mdi mdi-emoticon-happy', 'top', 'center');
|
||||||
//expanderCollapsedClass: 'mdi mdi-folder',
|
}
|
||||||
onChange: function() {
|
},
|
||||||
$treeTable.bootstrapTable('resetWidth');
|
complete: function () {
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
}],
|
||||||
// 只展开树形的第一集节点
|
onLoadSuccess: function(data){
|
||||||
$treeTable.treegrid('getRootNodes').treegrid('expand');
|
$("[data-toggle='tooltip']").tooltip();
|
||||||
},
|
}
|
||||||
onCheck: function(row) {
|
|
||||||
var datas = $treeTable.bootstrapTable('getData');
|
|
||||||
|
|
||||||
selectChilds(datas, row, 'id', 'pid', true); // 选择子类
|
|
||||||
|
|
||||||
selectParentChecked(datas, row, 'id', 'pid'); // 选择父类
|
|
||||||
|
|
||||||
$treeTable.bootstrapTable('load', datas);
|
|
||||||
},
|
|
||||||
|
|
||||||
onUncheck: function(row) {
|
|
||||||
var datas = $treeTable.bootstrapTable('getData');
|
|
||||||
selectChilds(datas, row, 'id', 'pid', false);
|
|
||||||
$treeTable.bootstrapTable('load', datas);
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// 操作按钮
|
//格式化文件大小
|
||||||
function operateFormatter(value, row, index) {
|
function renderSize(value){
|
||||||
return [
|
if(null==value||value==''){
|
||||||
'<a type="button" class="category-add btn btn-xs btn-default m-r-5" title="编辑" data-toggle="tooltip"><i class="mdi mdi-plus"></i></a>',
|
return "0 Bytes";
|
||||||
'<a type="button" class="article-add btn btn-xs btn-default m-r-5" title="添加文章" data-toggle="tooltip"><i class="mdi mdi-pencil-box"></i></a>',
|
}
|
||||||
'<a type="button" class="category-edit btn btn-xs btn-default m-r-5" title="修改" data-toggle="tooltip"><i class="mdi mdi-pencil"></i></a>',
|
var unitArr = new Array("Bytes","KB","MB","GB","TB","PB","EB","ZB","YB");
|
||||||
'<a type="button" class="category-delete btn btn-xs btn-default" title="删除" data-toggle="tooltip"><i class="mdi mdi-delete"></i></a>'
|
var index=0;
|
||||||
].join('');
|
var srcsize = parseFloat(value);
|
||||||
|
index=Math.floor(Math.log(srcsize)/Math.log(1024));
|
||||||
|
var size =srcsize/Math.pow(1024,index);
|
||||||
|
size=size.toFixed(2);//保留的小数位数
|
||||||
|
return size+unitArr[index];
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue