diff --git a/controllers/ConfigController.php b/controllers/ConfigController.php index 6361cdc8..88cfa50a 100644 --- a/controllers/ConfigController.php +++ b/controllers/ConfigController.php @@ -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") diff --git a/messages/en/app.php b/messages/en/app.php index 6775a3dd..0ba515a9 100644 --- a/messages/en/app.php +++ b/messages/en/app.php @@ -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" ]; diff --git a/messages/ja/app.php b/messages/ja/app.php index e4be8a65..78459ee3 100644 --- a/messages/ja/app.php +++ b/messages/ja/app.php @@ -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" => "再試行" ]; diff --git a/messages/vi/app.php b/messages/vi/app.php index a478ce09..b6b3d58d 100644 --- a/messages/vi/app.php +++ b/messages/vi/app.php @@ -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" ]; diff --git a/views/config/reset.tpl b/views/config/reset.tpl index 2f44a181..ee021b93 100644 --- a/views/config/reset.tpl +++ b/views/config/reset.tpl @@ -1,11 +1,14 @@ +