fix bug
This commit is contained in:
parent
52abd21183
commit
0656c688ec
|
@ -161,8 +161,8 @@ class ConfigController extends Controller {
|
|||
$servermqtt = $t['servermqtt'];
|
||||
}
|
||||
return $this->render('index', [
|
||||
"servermqtt" => $servermqtt,
|
||||
"url" => isset($temp[2]) ? $temp[2] : ""
|
||||
"servermqtt" => $servermqtt === "" ? $ip . ":1883" : $servermqtt,
|
||||
"url" => isset($temp[2]) ? $temp[2] : $ip . ":5001"
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -260,16 +260,20 @@ class ConfigController extends Controller {
|
|||
'method' => "POST"
|
||||
]
|
||||
])), true);
|
||||
if (!$tempConfig['status'])
|
||||
return $this->redirect(['/config']);
|
||||
|
||||
$engineConfig = json_decode($tempConfig['data'], true);
|
||||
if (count($engineConfig['data']['engines']) == 0) {
|
||||
$path = "";
|
||||
if ($tempConfig['status']) {
|
||||
if ($tempConfig['data'] !== "") {
|
||||
$engineConfig = json_decode($tempConfig['data'], true);
|
||||
if (count($engineConfig['data']['engines']) == 0) {
|
||||
$path = "";
|
||||
} else {
|
||||
$path = $engineConfig['data']['engines'][0]['path'];
|
||||
}
|
||||
} else {
|
||||
$path = "";
|
||||
}
|
||||
} else {
|
||||
$path = $engineConfig['data']['engines'][0]['path'];
|
||||
$path = "";
|
||||
}
|
||||
|
||||
file_get_contents("http://localhost:4004/Reset", false, stream_context_create([
|
||||
'http' => [
|
||||
'header' => "Content-Type: application/json",
|
||||
|
@ -293,7 +297,10 @@ class ConfigController extends Controller {
|
|||
]
|
||||
])), true);
|
||||
if (!$tempConfig['status'])
|
||||
return ['status' => false];
|
||||
return ['status' => false, 'text' => ''];
|
||||
|
||||
if ($tempConfig['data'] === "")
|
||||
return ['status' => false, 'text' => 'Cấu hình ip chưa đúng!'];
|
||||
|
||||
$engineConfig = json_decode($tempConfig['data'], true);
|
||||
if (count($engineConfig['data']['engines']) == 0)
|
||||
|
@ -310,7 +317,7 @@ class ConfigController extends Controller {
|
|||
])), true);
|
||||
|
||||
if (!$checkConfig['status']) {
|
||||
return ['status' => false];
|
||||
return ['status' => false, 'text' => ''];
|
||||
} else {
|
||||
return ['status' => true, 'url' => Url::to(['cau-hinh-nhan-dien'])];
|
||||
}
|
||||
|
|
|
@ -2,13 +2,23 @@ $(function () {
|
|||
|
||||
});
|
||||
function saveStep1(e) {
|
||||
var servermqtt = $("input[name='servermqtt']").val();
|
||||
if (servermqtt === "") {
|
||||
alert("Hãy nhập thông tin!");
|
||||
return;
|
||||
}
|
||||
var url = $("input[name='url']").val();
|
||||
if (url === "") {
|
||||
alert("Hãy nhập thông tin!");
|
||||
return;
|
||||
}
|
||||
common.modalBlock(true);
|
||||
$.ajax({
|
||||
url: $(e).attr("data-href"),
|
||||
type: 'POST',
|
||||
data: {
|
||||
servermqtt: $("input[name='servermqtt']").val(),
|
||||
url: $("input[name='url']").val()
|
||||
servermqtt: servermqtt,
|
||||
url: url
|
||||
},
|
||||
success: function (data) {
|
||||
setInterval(function () {
|
||||
|
@ -16,8 +26,14 @@ function saveStep1(e) {
|
|||
url: data,
|
||||
type: 'POST',
|
||||
success: function (data) {
|
||||
if (data.status)
|
||||
if (data.status) {
|
||||
window.location = data.url;
|
||||
} else {
|
||||
if (data.text !== "") {
|
||||
alert(data.text);
|
||||
window.location.reload(true);
|
||||
}
|
||||
}
|
||||
},
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
common.ajaxError();
|
||||
|
|
Loading…
Reference in New Issue
Block a user