diff --git a/controllers/ConfigController.php b/controllers/ConfigController.php index a3d146a4..2a2103d0 100644 --- a/controllers/ConfigController.php +++ b/controllers/ConfigController.php @@ -174,7 +174,8 @@ class ConfigController extends Controller { } return $this->render('index', [ "servermqtt" => $servermqtt === "" ? $ip . ":1883" : $servermqtt, - "url" => isset($temp[2]) ? $temp[2] : $ip . ":5001" + "url" => isset($temp[2]) ? $temp[2] : $ip . ":5001", + "menu" => $this->renderPartial("menu", ["tab" => "server_config"]) ]); } @@ -290,7 +291,8 @@ class ConfigController extends Controller { $config_json = json_decode($checkConfig['data'], true); return $this->render('config', [ - "config_json" => \app\widgets\ConfigTree::widget(['configLists' => $config_json, 'isRoot' => true, 'parent_id' => 'node', 'parent_key' => '']) + "config_json" => \app\widgets\ConfigTree::widget(['configLists' => $config_json, 'isRoot' => true, 'parent_id' => 'node', 'parent_key' => '']), + "menu" => $this->renderPartial("menu", ["tab" => "engine_config"]) ]); } } @@ -452,7 +454,8 @@ class ConfigController extends Controller { } return $this->render('device', [ "server_api" => \app\models\SyncUrl::findOne(['key_config' => 'server_api']), - "device_id" => \app\models\SyncUrl::findOne(['key_config' => 'device_id']) + "device_id" => \app\models\SyncUrl::findOne(['key_config' => 'device_id']), + "menu" => $this->renderPartial("menu", ["tab" => "device_config"]) ]); } @@ -486,4 +489,72 @@ class ConfigController extends Controller { } } + public $subnet = [ + "0.0.0.0" => "/0", + "128.0.0.0" => "/1", + "192.0.0.0" => "/2", + "224.0.0.0" => "/3", + "240.0.0.0" => "/4", + "248.0.0.0" => "/5", + "252.0.0.0" => "/6", + "254.0.0.0" => "/7", + "255.0.0.0" => "/8", + "255.128.0.0" => "/9", + "255.192.0.0" => "/10", + "255.224.0.0" => "/11", + "255.240.0.0" => "/12", + "255.248.0.0" => "/13", + "255.252.0.0" => "/14", + "255.254.0.0" => "/15", + "255.255.0.0" => "/16", + "255.255.128.0" => "/17", + "255.255.192.0" => "/18", + "255.255.224.0" => "/19", + "255.255.240.0" => "/20", + "255.255.248.0" => "/21", + "255.255.252.0" => "/22", + "255.255.254.0" => "/23", + "255.255.255.0" => "/24", + "255.255.255.128" => "/25", + "255.255.255.192" => "/26", + "255.255.255.224" => "/27", + "255.255.255.240" => "/28", + "255.255.255.248" => "/29", + "255.255.255.252" => "/30", + "255.255.255.254" => "/31", + "255.255.255.255" => "/32" + ]; + + public function actionCauHinhIp() { + if (Yii::$app->request->post()) { + Yii::$app->response->format = "json"; + $post = Yii::$app->request->post(); + if (!isset($this->subnet[$post['subnet_mask']])) + return ["status" => false]; + $post['subnet_mask'] = $this->subnet[$post['subnet_mask']]; + $options = [ + 'http' => [ + 'header' => "Content-Type: application/json", + 'method' => "POST", + 'content' => json_encode($post), + ] + ]; + json_decode(@file_get_contents("http://localhost:4004/SetIP", false, stream_context_create($options)), true); + return ["status" => true, "url" => "http://" . $post['device_ip']]; + } else { + $this->view->title = Yii::t("app", "CAU_HINH_IP"); + $options = [ + 'http' => [ + 'header' => "Content-Type: application/json", + 'method' => "POST" + ] + ]; + $network = json_decode(@file_get_contents("http://localhost:4004/Network", false, stream_context_create($options)), true); + return $this->render('ip', [ + "menu" => $this->renderPartial("menu", ["tab" => "ip_config"]), + "network" => $network + ]); + } + } + } diff --git a/messages/en/app.php b/messages/en/app.php index 11c987f2..ad061347 100644 --- a/messages/en/app.php +++ b/messages/en/app.php @@ -11,9 +11,11 @@ return [ "CAU_HINH_THIET_BI" => "Device Configuration", "CAU_HINH_MAY_CHU" => "Server Configuration", "CAU_HINH_NHAN_DIEN" => "Recognition Configuration", + "CAU_HINH_IP" => "IP Configuration", "DEVICE_CONFIG" => "", "SERVER_CONFIG" => "", "ENGINE_CONFIG" => "", + "IP_CONFIG" => "", "SERVER_MQTT" => "server_mqtt", "URL" => "url", "LUU_LAI" => "Save", @@ -157,5 +159,6 @@ return [ "AP_DUNG_CHO_TAT_CA_DOI_TUONG_DA_CHON" => "Apply to all selected objects", "XOA_LICH_TRINH" => "Delete schedule", "BAN_CO_CHAC_CHAN_MUON_XOA_LICH_TRINH_NAY_KHONG" => "Are you sure you want to delete this schedule?", - "SO_SANH_MAT" => "Face comparison" + "SO_SANH_MAT" => "Face comparison", + "BAN_CO_CHAC_CHAN_MUON_DOI_IP_KHONG" => "Are you sure you want to change the device's IP address?" ]; diff --git a/messages/ja/app.php b/messages/ja/app.php index 887358ff..04fb0e72 100644 --- a/messages/ja/app.php +++ b/messages/ja/app.php @@ -11,9 +11,11 @@ return [ "CAU_HINH_THIET_BI" => "デバイス構成", "CAU_HINH_MAY_CHU" => " サーバ構成", "CAU_HINH_NHAN_DIEN" => "認識構成", + "CAU_HINH_IP" => "IP 構成", "DEVICE_CONFIG" => "Device config", "SERVER_CONFIG" => "Server config", "ENGINE_CONFIG" => "Engine config", + "IP_CONFIG" => "IP config", "SERVER_MQTT" => "server_mqtt", "URL" => "url", "LUU_LAI" => "保存する", @@ -157,5 +159,6 @@ return [ "AP_DUNG_CHO_TAT_CA_DOI_TUONG_DA_CHON" => "選択したすべてのオブジェクトに適用", "XOA_LICH_TRINH" => "スケジュールを削除", "BAN_CO_CHAC_CHAN_MUON_XOA_LICH_TRINH_NAY_KHONG" => "このスケジュールを削除してもよろしいですか?", - "SO_SANH_MAT" => "顔比較" + "SO_SANH_MAT" => "顔比較", + "BAN_CO_CHAC_CHAN_MUON_DOI_IP_KHONG" => "デバイスの IP アドレスを変更してもよろしいですか?" ]; diff --git a/messages/vi/app.php b/messages/vi/app.php index 4d721d49..a2541676 100644 --- a/messages/vi/app.php +++ b/messages/vi/app.php @@ -11,9 +11,11 @@ return [ "CAU_HINH_THIET_BI" => "Cấu hình thiết bị", "CAU_HINH_MAY_CHU" => "Cấu hình máy chủ", "CAU_HINH_NHAN_DIEN" => "Cấu hình nhận diện", + "CAU_HINH_IP" => "Cấu hình IP", "DEVICE_CONFIG" => "Device config", "SERVER_CONFIG" => "Server config", "ENGINE_CONFIG" => "Engine config", + "IP_CONFIG" => "IP config", "SERVER_MQTT" => "server_mqtt", "URL" => "url", "LUU_LAI" => "Lưu lại", @@ -157,5 +159,6 @@ return [ "AP_DUNG_CHO_TAT_CA_DOI_TUONG_DA_CHON" => "Áp dụng cho tất cả đối tượng đã chọn", "XOA_LICH_TRINH" => "Xóa lịch trình", "BAN_CO_CHAC_CHAN_MUON_XOA_LICH_TRINH_NAY_KHONG" => "Bạn có chắc chắn muốn xóa lịch trình này không?", - "SO_SANH_MAT" => "So sánh mặt" + "SO_SANH_MAT" => "So sánh mặt", + "BAN_CO_CHAC_CHAN_MUON_DOI_IP_KHONG" => "Bạn có chắc chắn muốn thay đổi địa chỉ IP của thiết bị không?" ]; diff --git a/views/config/config.tpl b/views/config/config.tpl index 1029d7cd..8d8244d1 100644 --- a/views/config/config.tpl +++ b/views/config/config.tpl @@ -142,32 +142,8 @@