diff --git a/controllers/ConfigController.php b/controllers/ConfigController.php index e85c2334..d9fc57a4 100644 --- a/controllers/ConfigController.php +++ b/controllers/ConfigController.php @@ -301,36 +301,38 @@ class ConfigController extends Controller { public function actionReset() { if (Yii::$app->request->post()) { - $tempConfig = json_decode(file_get_contents("http://localhost:4004/ReadEngineConfig", false, stream_context_create([ - 'http' => [ - 'header' => "Content-Type: application/json", - 'method' => "POST" - ] - ])), true); - if ($tempConfig['status']) { - if ($tempConfig['data'] !== "") { - $engineConfig = json_decode($tempConfig['data'], true); - if (count($engineConfig['data']['engines']) == 0) { - $path = ""; + if (Yii::$app->request->post("resetDevice") === "true") { + $tempConfig = json_decode(file_get_contents("http://localhost:4004/ReadEngineConfig", false, stream_context_create([ + 'http' => [ + 'header' => "Content-Type: application/json", + 'method' => "POST" + ] + ])), true); + if ($tempConfig['status']) { + if ($tempConfig['data'] !== "") { + $engineConfig = json_decode($tempConfig['data'], true); + if (count($engineConfig['data']['engines']) == 0) { + $path = ""; + } else { + $path = $engineConfig['data']['engines'][0]['path']; + } } else { - $path = $engineConfig['data']['engines'][0]['path']; + $path = ""; } } else { $path = ""; } - } else { - $path = ""; + file_get_contents("http://localhost:4004/Reset", false, stream_context_create([ + 'http' => [ + 'header' => "Content-Type: application/json", + 'method' => "POST", + 'content' => json_encode([ + 'path' => $path + ]) + ] + ])); } - file_get_contents("http://localhost:4004/Reset", false, stream_context_create([ - 'http' => [ - 'header' => "Content-Type: application/json", - 'method' => "POST", - 'content' => json_encode([ - 'path' => $path - ]) - ] - ])); - if (Yii::$app->request->post("deleteDB") === "yes") { + if (Yii::$app->request->post("deleteDB") === "true") { \Yii::$app->db->createCommand()->truncateTable('capture_logs')->execute(); \Yii::$app->db->createCommand()->truncateTable('list_management')->execute(); array_map('unlink', glob("/var/www/html/BiFace_Server_Lite/web/data/uploads/face/*.*")); diff --git a/views/config/reset.tpl b/views/config/reset.tpl index e029f16d..2d0d6db4 100644 --- a/views/config/reset.tpl +++ b/views/config/reset.tpl @@ -1,10 +1,11 @@ -
-

BẠN CÓ MUỐN XÓA DỮ LIỆU LƯU TRỮ TRONG THIẾT BỊ KHÔNG?

+
+ Xóa dữ liệu lưu trữ trong thiết bị
- -
+
+ +
\ No newline at end of file diff --git a/web/js/common.js b/web/js/common.js index 32a169d7..1c439ef7 100644 --- a/web/js/common.js +++ b/web/js/common.js @@ -302,14 +302,25 @@ common.resetForm = function (e) { } }); }; -common.reset = function (e, deleteDB) { - if (confirm("Bạn có chắc chắn muốn reset thiết bị về cấu hình mặc định không?")) { +common.reset = function (e) { + var deleteDB = false; + var resetDevice = false; + if ($("input[name='DeleteDatabase']").is(':checked')) + deleteDB = true; + if ($("input[name='ResetDevice']").is(':checked')) + resetDevice = true; + if (!deleteDB && !resetDevice) { + alert("Hãy lựa chọn thao tác!"); + return; + } + if (confirm("Bạn có chắc chắn muốn reset thiết bị không?")) { common.modalBlock(true); $.ajax({ url: $(e).attr("data-href"), type: 'POST', data: { - deleteDB: deleteDB + deleteDB: deleteDB, + resetDevice: resetDevice }, success: function (data) { window.location = data;