update change ip gateway

This commit is contained in:
dongpd 2020-10-22 11:06:01 +07:00
parent f65c064f04
commit ad885eacd2
3 changed files with 22 additions and 1 deletions

View File

@ -251,11 +251,13 @@ class DeviceController extends Controller {
"OldIPAddress" => $OldIpAddress,
"NewIPAddress" => $data["Ip"],
"NetMask" => $data["SubnetMask"],
"GATEIPAddress" => $data["Gateway"],
"MAC" => $model->mac_address
]);
if ($res == 0) {
$model->ip_address = $data["Ip"];
$model->subnet_mask = $data["SubnetMask"];
$model->gateway = $data["Gateway"];
$model->save();
return ["status" => true];
}

View File

@ -31,6 +31,13 @@
</div>
<span class="help-block hidden"></span>
</div>
<div class="form-group" id="gateway">
<div class="input-group">
<div class="input-group-addon">Gateway</div>
<input type="text" class="form-control" value="{$model->gateway|default:""}" name="Gateway">
</div>
<span class="help-block hidden"></span>
</div>
<div class="text-right">
<button class="btn btn-primary" onclick="changeIP(this);" data-href="{$url}">
<i class="fa fa-floppy-o"></i> Lưu

View File

@ -208,6 +208,17 @@ function validateChangeIP() {
} else {
common.success("subnet_mask");
}
var Gateway = $("input[name='Gateway']").val();
if (Gateway === "") {
common.error("gateway", "Gateway không được để trống");
error++;
} else if (!common.validateIp(Gateway)) {
common.error("gateway", "Định dạng Gateway không đúng");
error++;
} else {
common.success("gateway");
}
return error == 0 ? true : false;
}
@ -219,7 +230,8 @@ function changeIP(e) {
type: 'POST',
data: {
Ip: $("input[name='IpNew']").val(),
SubnetMask: $("input[name='SubnetMask']").val()
SubnetMask: $("input[name='SubnetMask']").val(),
Gateway: $("input[name='Gateway']").val()
},
success: function (data) {
common.modalBlock(false);