update dhcp check

This commit is contained in:
dongpd 2022-11-18 09:46:24 +07:00
parent 8954a2fc25
commit 5450124be9
6 changed files with 67 additions and 50 deletions

View File

@ -2,6 +2,7 @@
return [
'adminEmail' => 'admin@example.com',
"type" => "BiFace", // BiFace, BiTable
"maxLogs" => 50000,
"maxPicture" => 9999,
"version" => "1.0.7",

View File

@ -159,6 +159,8 @@ class ConfigController extends Controller {
public function actionIndex() {
$this->view->title = Yii::t("app", "CAU_HINH_MAY_CHU");
if (Yii::$app->params['type'] != "BiFace")
return $this->redirect(['cau-hinh-ip']);
$options = [
'http' => [
'header' => "Content-Type: application/json",
@ -260,6 +262,8 @@ class ConfigController extends Controller {
return true;
} else {
$this->view->title = Yii::t("app", "CAU_HINH_NHAN_DIEN");
if (Yii::$app->params['type'] != "BiFace")
return $this->redirect(['cau-hinh-ip']);
$tempConfig = json_decode(file_get_contents("http://localhost:4004/ReadEngineConfig", false, stream_context_create([
'http' => [
'header' => "Content-Type: application/json",
@ -424,6 +428,8 @@ class ConfigController extends Controller {
public function actionCauHinhThietBi() {
$this->view->title = Yii::t("app", "CAU_HINH_THIET_BI");
if (Yii::$app->params['type'] != "BiFace")
return $this->redirect(['cau-hinh-ip']);
$tempConfig = json_decode(file_get_contents("http://localhost:4004/ReadEngineConfig", false, stream_context_create([
'http' => [
@ -529,9 +535,9 @@ class ConfigController extends Controller {
if (Yii::$app->request->post()) {
Yii::$app->response->format = "json";
$post = Yii::$app->request->post();
if (!isset($this->subnet[$post['subnet_mask']]))
if (!$post['dhcp'] && !isset($this->subnet[$post['subnet_mask']]))
return ["status" => false];
$post['subnet_mask'] = $this->subnet[$post['subnet_mask']];
$post['subnet_mask'] = isset($this->subnet[$post['subnet_mask']]) ? $this->subnet[$post['subnet_mask']] : "";
$options = [
'http' => [
'header' => "Content-Type: application/json",

View File

@ -41,6 +41,7 @@ use yii\widgets\ActiveForm;
<i class="fa fa-cogs"></i> <?php echo Yii::t("app", "CAU_HINH"); ?>
</a>
</li>
<?php if (Yii::$app->params['type'] === "BiFace") { ?>
<li>
<a href="<?php echo yii\helpers\Url::to(['/config/reset']); ?>" onclick="common.resetForm(this);return false;">
<i class="fa fa-refresh"></i> <?php echo Yii::t("app", "RESET_THIET_BI"); ?>
@ -61,6 +62,7 @@ use yii\widgets\ActiveForm;
<li><a href="<?php echo \yii\helpers\Url::to(['/capture-logs/face-comparison']); ?>"><i class="fa fa-users"></i> <?php echo Yii::t("app", "SO_SANH_MAT"); ?></a></li>
</ul>
</li>
<?php } ?>
</ul>
</div>
<div class="navbar-custom-menu">

View File

@ -23,6 +23,9 @@
<br>
<div class="row">
<div class="col-md-3">
<div class="form-group" id="dhcp">
<input type='checkbox' name='dhcp' id='dhcp_check' value="" {if $network.dhcp=="yes"}checked=""{/if}> DHCP
</div>
<div class="form-group" id="device_ip">
<div class="input-group">
<div class="input-group-addon">{Yii::t("app", "IP Address")}</div>
@ -44,13 +47,13 @@
<div class="form-group" id="dns1">
<div class="input-group">
<div class="input-group-addon">{Yii::t("app", "DNS1")}</div>
<input type="input" class="form-control" name="dns1" value="{$network.dns[0]|default:""}">
<input type="input" class="form-control" name="dns1" value="{$network.dns1|default:""}">
</div>
</div>
<div class="form-group" id="dns2">
<div class="input-group">
<div class="input-group-addon">{Yii::t("app", "DNS2")}</div>
<input type="input" class="form-control" name="dns2" value="{$network.dns[1]|default:""}">
<input type="input" class="form-control" name="dns2" value="{$network.dns2|default:""}">
</div>
</div>
<div class="text-center">

View File

@ -1,5 +1,6 @@
{use class="yii\helpers\Url"}
<div class="mt-element-step">
{if Yii::$app->params["type"]==="BiFace"}
<div class="mt-element-step">
<div class="row step-thin">
<div class="col-md-3 bg-grey mt-step-col {if $tab=="device_config"}active{/if}">
<div class="mt-step-number bg-white font-grey">1</div>
@ -30,4 +31,5 @@
<div class="mt-step-content font-grey-cascade">{Yii::t("app", "IP_CONFIG")}</div>
</div>
</div>
</div>
</div>
{/if}

View File

@ -125,6 +125,8 @@ function ValidateIPaddress(ipaddress) {
function validData(inputName) {
var ip = $("input[name='" + inputName + "']").val();
if (ip == "" && document.getElementById('dhcp_check').checked)
return true;
if (!ValidateIPaddress(ip)) {
common.error(inputName, "");
return false;
@ -160,6 +162,7 @@ function changeIP(e) {
gateway: $("input[name='gateway']").val(),
dns1: $("input[name='dns1']").val(),
dns2: $("input[name='dns2']").val(),
dhcp: document.getElementById('dhcp_check').checked
},
success: function (data) {
common.modalBlock(false);