update delete database option
This commit is contained in:
parent
fc0f2ccc0f
commit
d0f17afc39
|
@ -300,7 +300,7 @@ class ConfigController extends Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function actionReset() {
|
public function actionReset() {
|
||||||
if (Yii::$app->request->isAjax) {
|
if (Yii::$app->request->post()) {
|
||||||
$tempConfig = json_decode(file_get_contents("http://localhost:4004/ReadEngineConfig", false, stream_context_create([
|
$tempConfig = json_decode(file_get_contents("http://localhost:4004/ReadEngineConfig", false, stream_context_create([
|
||||||
'http' => [
|
'http' => [
|
||||||
'header' => "Content-Type: application/json",
|
'header' => "Content-Type: application/json",
|
||||||
|
@ -330,7 +330,17 @@ class ConfigController extends Controller {
|
||||||
])
|
])
|
||||||
]
|
]
|
||||||
]));
|
]));
|
||||||
|
if (Yii::$app->request->post("deleteDB") === "yes") {
|
||||||
|
\Yii::$app->db->createCommand()->truncateTable('capture_logs')->execute();
|
||||||
|
\Yii::$app->db->createCommand()->truncateTable('list_management')->execute();
|
||||||
|
}
|
||||||
return Url::to(['/config']);
|
return Url::to(['/config']);
|
||||||
|
} else {
|
||||||
|
Yii::$app->response->format = "json";
|
||||||
|
return [
|
||||||
|
"title" => "Reset thiết bị",
|
||||||
|
"form" => $this->renderPartial("reset")
|
||||||
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,7 @@ use yii\widgets\ActiveForm;
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="<?php echo yii\helpers\Url::to(['/config/reset']); ?>" onclick="common.reset(this);return false;">
|
<a href="<?php echo yii\helpers\Url::to(['/config/reset']); ?>" onclick="common.resetForm(this);return false;">
|
||||||
<i class="fa fa-refresh"></i> Reset thiết bị
|
<i class="fa fa-refresh"></i> Reset thiết bị
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
|
10
views/config/reset.tpl
Normal file
10
views/config/reset.tpl
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
<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>
|
||||||
|
<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>
|
||||||
|
</div>
|
|
@ -287,12 +287,30 @@ common.success = function (id) {
|
||||||
$("#" + id).addClass("has-success").removeClass("has-error");
|
$("#" + id).addClass("has-success").removeClass("has-error");
|
||||||
$("#" + id).find(".help-block").addClass("hidden");
|
$("#" + id).find(".help-block").addClass("hidden");
|
||||||
};
|
};
|
||||||
common.reset = function (e) {
|
common.resetForm = function (e) {
|
||||||
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.modalBlock(true);
|
common.modalBlock(true);
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: $(e).attr("href"),
|
url: $(e).attr("href"),
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
|
success: function (data) {
|
||||||
|
common.modalBlock(false);
|
||||||
|
common.modalOpen(data.form, false, data.title);
|
||||||
|
},
|
||||||
|
error: function (jqXHR, textStatus, errorThrown) {
|
||||||
|
common.modalBlock(false);
|
||||||
|
common.ajaxError();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
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.modalBlock(true);
|
||||||
|
$.ajax({
|
||||||
|
url: $(e).attr("data-href"),
|
||||||
|
type: 'POST',
|
||||||
|
data: {
|
||||||
|
deleteDB: deleteDB
|
||||||
|
},
|
||||||
success: function (data) {
|
success: function (data) {
|
||||||
window.location = data;
|
window.location = data;
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue
Block a user