mirror of
https://github.com/kokororin/typecho-plugin-Access.git
synced 2025-01-14 06:10:06 +08:00
feat: delete more than one page logs requires confirmation
This commit is contained in:
parent
0a2c0ee97e
commit
74f2c32cbb
@ -142,6 +142,7 @@ class Access_Logs {
|
||||
$cid = $this->request->get('cid', '');
|
||||
$path = $this->request->get('path', '');
|
||||
$robot = $this->request->get('robot', '');
|
||||
$force = $this->request->get('force', '');
|
||||
if ($ids) {
|
||||
$ids = Json::decode($ids, true);
|
||||
if (!is_array($ids)) {
|
||||
@ -165,7 +166,12 @@ class Access_Logs {
|
||||
}
|
||||
|
||||
$resp['count'] = $this->db->fetchAll($counterQuery)[0]['count'];
|
||||
$this->db->query($operatorQuery);
|
||||
// delete more than one page requires 2nd time confirmation
|
||||
if ($resp['count'] <= $this->config->pageSize || $force) {
|
||||
$this->db->query($operatorQuery);
|
||||
} else {
|
||||
$resp['requireForce'] = true;
|
||||
}
|
||||
|
||||
return $resp;
|
||||
}
|
||||
|
@ -264,42 +264,62 @@ $(document).ready(function () {
|
||||
}
|
||||
});
|
||||
if (ids.length != 0) {
|
||||
$.ajax({
|
||||
url: "/access/logs",
|
||||
method: "post",
|
||||
dataType: "json",
|
||||
data: {
|
||||
rpc: 'delete',
|
||||
ids: JSON.stringify(ids),
|
||||
},
|
||||
success: function (res) {
|
||||
if (res.code == 0) {
|
||||
swal({
|
||||
icon: "success",
|
||||
title: "删除成功",
|
||||
text: "成功删除" + res.data.count + "条记录",
|
||||
});
|
||||
$.each(ids, function (index, elem) {
|
||||
$('.typecho-list-table tbody tr[data-id="' + elem + '"]')
|
||||
.fadeOut(500)
|
||||
.remove();
|
||||
});
|
||||
} else {
|
||||
function action(force) {
|
||||
$.ajax({
|
||||
url: "/access/logs",
|
||||
method: "post",
|
||||
dataType: "json",
|
||||
data: {
|
||||
rpc: 'delete',
|
||||
ids: JSON.stringify(ids),
|
||||
force: force,
|
||||
},
|
||||
success: function (res) {
|
||||
if (res.code == 0) {
|
||||
if (res.data.requireForce) {
|
||||
swal({
|
||||
title: "你确定?",
|
||||
text: "本次操作将删除" + res.data.count + "条记录,你确认要删除这些记录吗?",
|
||||
icon: "warning",
|
||||
buttons: {
|
||||
cancel: "算啦",
|
||||
confirm: "是的",
|
||||
},
|
||||
}).then((value) => {
|
||||
if (value === true) {
|
||||
action(true);
|
||||
}
|
||||
})
|
||||
} else {
|
||||
swal({
|
||||
icon: "success",
|
||||
title: "删除成功",
|
||||
text: "成功删除" + res.data.count + "条记录",
|
||||
});
|
||||
$.each(ids, function (index, elem) {
|
||||
$('.typecho-list-table tbody tr[data-id="' + elem + '"]')
|
||||
.fadeOut(500)
|
||||
.remove();
|
||||
});
|
||||
}
|
||||
} else {
|
||||
swal({
|
||||
icon: "error",
|
||||
title: "错误",
|
||||
text: "删除出错啦",
|
||||
});
|
||||
}
|
||||
},
|
||||
error: function (xhr, status, error) {
|
||||
swal({
|
||||
icon: "error",
|
||||
title: "错误",
|
||||
text: "删除出错啦",
|
||||
text: "请求错误 code: " + xhr.status,
|
||||
});
|
||||
}
|
||||
},
|
||||
error: function (xhr, status, error) {
|
||||
swal({
|
||||
icon: "error",
|
||||
title: "错误",
|
||||
text: "请求错误 code: " + xhr.status,
|
||||
});
|
||||
},
|
||||
});
|
||||
},
|
||||
});
|
||||
}
|
||||
action(false);
|
||||
} else {
|
||||
return swal({
|
||||
icon: "warning",
|
||||
|
Loading…
Reference in New Issue
Block a user