update
This commit is contained in:
@@ -126,7 +126,8 @@ class ConfigController extends Controller {
|
||||
"show_video" => 1,
|
||||
"full_screen" => 1,
|
||||
"width" => 1920,
|
||||
"height" => 1080
|
||||
"height" => 1080,
|
||||
"banner" => "Have a nice day!"
|
||||
],
|
||||
"id_city" => 1581130,
|
||||
"open_door" => [
|
||||
@@ -156,11 +157,12 @@ class ConfigController extends Controller {
|
||||
$tempConfig = json_decode(file_get_contents("http://localhost:4004/ReadAPIConfig", false, stream_context_create($options)), true);
|
||||
if ($tempConfig['status']) {
|
||||
$t = json_decode($tempConfig['data'], true);
|
||||
$temp = explode(":", $t['servermqtt']);
|
||||
$ip = $temp[0];
|
||||
$temp = explode("/", $t['url']);
|
||||
$servermqtt = $t['servermqtt'];
|
||||
}
|
||||
return $this->render('index', [
|
||||
"ip" => $ip
|
||||
"servermqtt" => $servermqtt,
|
||||
"url" => $temp[2]
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -172,13 +174,13 @@ class ConfigController extends Controller {
|
||||
'header' => "Content-Type: application/json",
|
||||
'method' => "POST",
|
||||
'content' => json_encode([
|
||||
"servermqtt" => $post['server'] . ":1883",
|
||||
"url" => "http://" . $post['server'] . ":5001/api/box/getConfig"
|
||||
"servermqtt" => $post['servermqtt'],
|
||||
"url" => "http://" . $post['url'] . "/api/box/getConfig"
|
||||
]),
|
||||
]
|
||||
];
|
||||
json_decode(file_get_contents("http://localhost:4004/SaveAPIConfig", false, stream_context_create($options)), true);
|
||||
return Url::to(['cau-hinh-nhan-dien']);
|
||||
return Url::to(['check-engine']);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -224,6 +226,9 @@ class ConfigController extends Controller {
|
||||
return $this->redirect(['/config']);
|
||||
|
||||
$engineConfig = json_decode($tempConfig['data'], true);
|
||||
if (count($engineConfig['data']['engines']) == 0)
|
||||
return $this->redirect(['/config']);
|
||||
|
||||
$checkConfig = json_decode(file_get_contents("http://localhost:4004/ReadConfig", false, stream_context_create([
|
||||
'http' => [
|
||||
'header' => "Content-Type: application/json",
|
||||
@@ -233,10 +238,10 @@ class ConfigController extends Controller {
|
||||
])
|
||||
]
|
||||
])), true);
|
||||
|
||||
|
||||
if (!$checkConfig['status'])
|
||||
return $this->redirect(['/config']);
|
||||
|
||||
|
||||
$config_json = $this->config_json;
|
||||
if ($checkConfig['status'])
|
||||
$config_json = json_decode($checkConfig['data'], true);
|
||||
@@ -247,4 +252,69 @@ class ConfigController extends Controller {
|
||||
}
|
||||
}
|
||||
|
||||
public function actionReset() {
|
||||
if (Yii::$app->request->isAjax) {
|
||||
$tempConfig = json_decode(file_get_contents("http://localhost:4004/ReadEngineConfig", false, stream_context_create([
|
||||
'http' => [
|
||||
'header' => "Content-Type: application/json",
|
||||
'method' => "POST"
|
||||
]
|
||||
])), true);
|
||||
if (!$tempConfig['status'])
|
||||
return $this->redirect(['/config']);
|
||||
|
||||
$engineConfig = json_decode($tempConfig['data'], true);
|
||||
if (count($engineConfig['data']['engines']) == 0) {
|
||||
$path = "";
|
||||
} else {
|
||||
$path = $engineConfig['data']['engines'][0]['path'];
|
||||
}
|
||||
|
||||
file_get_contents("http://localhost:4004/Reset", false, stream_context_create([
|
||||
'http' => [
|
||||
'header' => "Content-Type: application/json",
|
||||
'method' => "POST",
|
||||
'content' => json_encode([
|
||||
'path' => $path
|
||||
])
|
||||
]
|
||||
]));
|
||||
return Url::to(['/config']);
|
||||
}
|
||||
}
|
||||
|
||||
public function actionCheckEngine() {
|
||||
if (Yii::$app->request->isAjax) {
|
||||
Yii::$app->response->format = "json";
|
||||
$tempConfig = json_decode(file_get_contents("http://localhost:4004/ReadEngineConfig", false, stream_context_create([
|
||||
'http' => [
|
||||
'header' => "Content-Type: application/json",
|
||||
'method' => "POST"
|
||||
]
|
||||
])), true);
|
||||
if (!$tempConfig['status'])
|
||||
return ['status' => false];
|
||||
|
||||
$engineConfig = json_decode($tempConfig['data'], true);
|
||||
if (count($engineConfig['data']['engines']) == 0)
|
||||
return ['status' => false];
|
||||
|
||||
$checkConfig = json_decode(file_get_contents("http://localhost:4004/ReadConfig", false, stream_context_create([
|
||||
'http' => [
|
||||
'header' => "Content-Type: application/json",
|
||||
'method' => "POST",
|
||||
'content' => json_encode([
|
||||
'path' => $engineConfig['data']['engines'][0]['path']
|
||||
])
|
||||
]
|
||||
])), true);
|
||||
|
||||
if (!$checkConfig['status']) {
|
||||
return ['status' => false];
|
||||
} else {
|
||||
return ['status' => true, 'url' => Url::to(['cau-hinh-nhan-dien'])];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user