update change up from server lite

This commit is contained in:
2022-10-20 10:34:27 +07:00
parent c8e0bb7795
commit 8954a2fc25
11 changed files with 250 additions and 84 deletions

View File

@@ -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
]);
}
}
}