update alert when reset device failed
CR: sonhh (fake)
This commit is contained in:
parent
66357b25d5
commit
61e82f68ca
|
@ -296,6 +296,7 @@ class ConfigController extends Controller {
|
|||
}
|
||||
|
||||
public function actionReset() {
|
||||
Yii::$app->response->format = "json";
|
||||
if (Yii::$app->request->post()) {
|
||||
if (Yii::$app->request->post("deleteDB") === "true") {
|
||||
\Yii::$app->db->createCommand()->truncateTable('capture_logs')->execute();
|
||||
|
@ -315,7 +316,7 @@ class ConfigController extends Controller {
|
|||
if ($device_id)
|
||||
$id_camera = intval($device_id->data);
|
||||
try {
|
||||
file_get_contents($ip . "/api/model/reset_log_model", false, stream_context_create([
|
||||
$res = json_decode(file_get_contents($ip . "/api/model/reset_log_model", false, stream_context_create([
|
||||
'http' => [
|
||||
'header' => "Content-Type: application/json",
|
||||
'method' => "POST",
|
||||
|
@ -324,9 +325,17 @@ class ConfigController extends Controller {
|
|||
"isCloud" => 0
|
||||
])
|
||||
]
|
||||
]));
|
||||
])), true);
|
||||
if ($res['status'] != 10000)
|
||||
return [
|
||||
"status" => false,
|
||||
"btnText" => Yii::t("app", "THU_LAI")
|
||||
];
|
||||
} catch (Exception $ex) {
|
||||
|
||||
return [
|
||||
"status" => false,
|
||||
"btnText" => Yii::t("app", "THU_LAI")
|
||||
];
|
||||
}
|
||||
}
|
||||
if (Yii::$app->request->post("resetDevice") === "true") {
|
||||
|
@ -361,9 +370,11 @@ class ConfigController extends Controller {
|
|||
]));
|
||||
}
|
||||
\app\models\SyncUrl::deleteAll(['IN', 'key_config', ['server_api', 'device_id']]);
|
||||
return Url::to(['/config/cau-hinh-thiet-bi']);
|
||||
return [
|
||||
"status" => true,
|
||||
"url" => Url::to(['/config/cau-hinh-thiet-bi'])
|
||||
];
|
||||
} else {
|
||||
Yii::$app->response->format = "json";
|
||||
return [
|
||||
"title" => Yii::t("app", "RESET_THIET_BI"),
|
||||
"form" => $this->renderPartial("reset")
|
||||
|
|
|
@ -133,5 +133,7 @@ return [
|
|||
"CO_LOI_XAY_RA_HAY_THU_LAI" => "An error occurred, check the network connection and try again",
|
||||
"ENGINE_KHONG_HOAT_DONG" => "Engine is not running",
|
||||
"DANG_NHAP" => "Login",
|
||||
"MAT_KHAU" => "Password"
|
||||
"MAT_KHAU" => "Password",
|
||||
"RESET_THIET_BI_LOI" => "Error connecting to the server. Please check your internet connection and try again.",
|
||||
"THU_LAI" => "Try again"
|
||||
];
|
||||
|
|
|
@ -133,5 +133,7 @@ return [
|
|||
"CO_LOI_XAY_RA_HAY_THU_LAI" => "おそらくネットワーク接続が原因でエラーが発生しました。再試行してください",
|
||||
"ENGINE_KHONG_HOAT_DONG" => "Engine不活動",
|
||||
"DANG_NHAP" => "ログイン",
|
||||
"MAT_KHAU" => "パスワード"
|
||||
"MAT_KHAU" => "パスワード",
|
||||
"RESET_THIET_BI_LOI" => "サーバーへの接続中にエラーが発生しました。インターネット接続を確認して、もう一度お試しください",
|
||||
"THU_LAI" => "再試行"
|
||||
];
|
||||
|
|
|
@ -133,5 +133,7 @@ return [
|
|||
"CO_LOI_XAY_RA_HAY_THU_LAI" => "Có lỗi xảy ra, có thể do đường truyền mạng, xin vui lòng thử lại",
|
||||
"ENGINE_KHONG_HOAT_DONG" => "Engine không hoạt động",
|
||||
"DANG_NHAP" => "Đăng nhập",
|
||||
"MAT_KHAU" => "Mật khẩu"
|
||||
"MAT_KHAU" => "Mật khẩu",
|
||||
"RESET_THIET_BI_LOI" => "Lỗi kết nối đến server. Hãy kiểm tra lại kết nối internet và thử lại.",
|
||||
"THU_LAI" => "Thử lại"
|
||||
];
|
||||
|
|
|
@ -1,11 +1,14 @@
|
|||
<div class="alert alert-danger hidden" id="reset-error">
|
||||
<i class="fa fa-info-circle"></i> {Yii::t("app", "RESET_THIET_BI_LOI")}
|
||||
</div>
|
||||
<div class="text-left">
|
||||
<input type="checkbox" name="DeleteDatabase" checked="" style="width: inherit;"> {Yii::t("app", "XOA_DU_LIEU_LUU_TRU_TRONG_THIET_BI")}
|
||||
<br>
|
||||
<input type="checkbox" name="ResetDevice" checked="" style="width: inherit;"> {Yii::t("app", "RESET_CAU_HINH_THIET_BI")}
|
||||
</div>
|
||||
<div class="text-center">
|
||||
<button class="btn btn-danger" onclick="common.reset(this);" data-href="{yii\helpers\Url::to(['/config/reset'])}">
|
||||
<button class="btn btn-danger" onclick="common.reset(this);" data-href="{yii\helpers\Url::to(['/config/reset'])}" id="reset-accept">
|
||||
{Yii::t("app", "DONG_Y")}
|
||||
</button>
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal">{Yii::t("app", "HUY_BO")}</button>
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal" id="reset-close">{Yii::t("app", "HUY_BO")}</button>
|
||||
</div>
|
|
@ -328,7 +328,14 @@ common.reset = function (e) {
|
|||
resetDevice: resetDevice
|
||||
},
|
||||
success: function (data) {
|
||||
window.location = data;
|
||||
common.modalBlock(false);
|
||||
if (data.status)
|
||||
window.location = data.url;
|
||||
else {
|
||||
$("#reset-error").removeClass("hidden");
|
||||
$("#reset-close").addClass("hidden");
|
||||
$("#reset-accept").html(data.btnText);
|
||||
}
|
||||
},
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
common.modalBlock(false);
|
||||
|
|
Loading…
Reference in New Issue
Block a user