update
This commit is contained in:
parent
b851f4c76f
commit
752ed3aa1c
|
@ -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'])];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
<project-private xmlns="http://www.netbeans.org/ns/project-private/1">
|
||||
<editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/2" lastBookmarkId="0"/>
|
||||
<open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2">
|
||||
<group/>
|
||||
<group>
|
||||
<file>file:/E:/BiFace_Server_Lite/controllers/ConfigController.php</file>
|
||||
</group>
|
||||
</open-files>
|
||||
</project-private>
|
||||
|
|
|
@ -46,6 +46,11 @@ use yii\widgets\ActiveForm;
|
|||
<i class="fa fa-cogs"></i> Cấu hình
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="<?php echo yii\helpers\Url::to(['/config/reset']); ?>" onclick="common.reset(this);return false;">
|
||||
<i class="fa fa-refresh"></i> Reset thiết bị
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="navbar-custom-menu">
|
||||
|
|
|
@ -572,6 +572,11 @@
|
|||
<label class="tree_label" for="c64">height</label>:
|
||||
<div contenteditable="" id="text-c64" class="editform">{$config_json.screen.height}</div>
|
||||
</li>
|
||||
<li>
|
||||
<input type="checkbox" checked="checked" id="c65" />
|
||||
<label class="tree_label" for="c65">banner</label>:
|
||||
<div contenteditable="" id="text-c65" class="editform">{$config_json.screen.banner}</div>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li {if $username!='admin'}class='hidden'{/if}>
|
||||
|
|
|
@ -42,9 +42,15 @@
|
|||
<div class="col-md-4">
|
||||
<div class="form-group">
|
||||
<div class="input-group">
|
||||
<div class="input-group-addon">server IP</div>
|
||||
<input type="input" class="form-control" name="servermqtt" value="{$ip}">
|
||||
</div>
|
||||
<div class="input-group-addon">server_mqtt</div>
|
||||
<input type="input" class="form-control" name="servermqtt" value="{$servermqtt}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="input-group">
|
||||
<div class="input-group-addon">url</div>
|
||||
<input type="input" class="form-control" name="url" value="{$url}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="text-center">
|
||||
<button class="btn btn-primary" onclick="saveStep1(this);" data-href="{Url::to(['/config/cau-hinh-may-chu'])}">
|
||||
|
@ -54,4 +60,5 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{/block}
|
|
@ -279,6 +279,22 @@ common.success = function (id) {
|
|||
$("#" + id).addClass("has-success").removeClass("has-error");
|
||||
$("#" + id).find(".help-block").addClass("hidden");
|
||||
};
|
||||
common.reset = function (e) {
|
||||
if (confirm("Bạn có chắc chắn muốn reset thiết bị về cấu hình mặc định không?")) {
|
||||
common.modalBlock(true);
|
||||
$.ajax({
|
||||
url: $(e).attr("href"),
|
||||
type: 'POST',
|
||||
success: function (data) {
|
||||
window.location = data;
|
||||
},
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
common.modalBlock(false);
|
||||
common.ajaxError();
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
/**
|
||||
* =========================
|
||||
*/
|
||||
|
|
|
@ -7,12 +7,23 @@ function saveStep1(e) {
|
|||
url: $(e).attr("data-href"),
|
||||
type: 'POST',
|
||||
data: {
|
||||
server: $("input[name='servermqtt']").val()
|
||||
servermqtt: $("input[name='servermqtt']").val(),
|
||||
url: $("input[name='url']").val()
|
||||
},
|
||||
success: function (data) {
|
||||
setTimeout(function () {
|
||||
window.location = data;
|
||||
}, 2000);
|
||||
setInterval(function () {
|
||||
$.ajax({
|
||||
url: data,
|
||||
type: 'POST',
|
||||
success: function (data) {
|
||||
if (data.status)
|
||||
window.location = data.url;
|
||||
},
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
common.ajaxError();
|
||||
}
|
||||
});
|
||||
}, 1000);
|
||||
},
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
common.modalBlock(false);
|
||||
|
@ -114,7 +125,8 @@ function saveStep2(e) {
|
|||
"show_video": parseInt($("#text-c61").html()),
|
||||
"full_screen": parseInt($("#text-c62").html()),
|
||||
"width": parseInt($("#text-c63").html()),
|
||||
"height": parseInt($("#text-c64").html())
|
||||
"height": parseInt($("#text-c64").html()),
|
||||
"banner": parseInt($("#text-c65").html())
|
||||
},
|
||||
"id_city": parseInt($("#text-c7").html()),
|
||||
"open_door": {
|
||||
|
|
Loading…
Reference in New Issue
Block a user