update alert when reset device failed
CR: sonhh (fake)
This commit is contained in:
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user