thay doi co che reset thiet bi
This commit is contained in:
parent
ef59255c52
commit
45be07f772
|
@ -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/*.*"));
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
<div class="text-center">
|
||||
<h4>BẠN CÓ MUỐN XÓA DỮ LIỆU LƯU TRỮ TRONG THIẾT BỊ KHÔNG?</h4>
|
||||
<div class="text-left">
|
||||
<input type="checkbox" name="DeleteDatabase" checked="" style="width: inherit;"> Xóa dữ liệu lưu trữ trong thiết bị
|
||||
<br>
|
||||
<button class="btn btn-danger" onclick="common.reset(this, 'yes');" data-href="{yii\helpers\Url::to(['/config/reset'])}">
|
||||
Có
|
||||
</button>
|
||||
<button class="btn btn-default" onclick="common.reset(this, 'no');" data-href="{yii\helpers\Url::to(['/config/reset'])}">
|
||||
Không
|
||||
</button>
|
||||
<input type="checkbox" name="ResetDevice" checked="" style="width: inherit;"> Reset cấu hình thiết bị
|
||||
</div>
|
||||
<div class="text-center">
|
||||
<button class="btn btn-danger" onclick="common.reset(this);" data-href="{yii\helpers\Url::to(['/config/reset'])}">
|
||||
Đồng ý
|
||||
</button>
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal">Hủy bỏ</button>
|
||||
</div>
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue
Block a user