fixed add active monitoring with ipv4 and ports combination (#4677)

This commit is contained in:
gabryon99 2020-11-06 17:02:09 +01:00
parent edb215487b
commit 9dfed97e56
7 changed files with 26 additions and 6 deletions

View file

@ -187,6 +187,7 @@ $(document).ready(function() {
const $addHostModalHandler = $(`#am-add-form`).modalHandler({
method: 'post',
endpoint: `${http_prefix}/plugins/edit_active_monitoring_host.lua`,
resetAfterSubmit: false,
csrf: am_csrf,
onModalInit: function () {
const $dialog = $('#am-add-modal');
@ -214,6 +215,8 @@ $(document).ready(function() {
const threshold = $("#input-add-threshold").val();
const pool = $(`#select-add-pool`).val();
$(`#add-invalid-feedback`).hide();
return {
action: 'add',
am_host: host,
@ -236,7 +239,10 @@ $(document).ready(function() {
$(`#am-add-modal`).modal('hide');
$amTable.ajax.reload();
return;
}
$(`#add-invalid-feedback`).show().text(response.error);
}
});
@ -300,6 +306,8 @@ $(document).ready(function() {
$(`#am-edit-modal`).modal('hide');
$amTable.ajax.reload();
return;
}
}
});
@ -438,7 +446,7 @@ $(document).ready(function() {
sortable: false,
render: function(data, type, row) {
if(type === 'display' || type === 'filter') {
if(row.last_measure)
if (row.last_measure)
return `${row.last_measure} ${row.unit}`
else
return "";

View file

@ -81,7 +81,7 @@
<li>{{ dialog.note_alert }}</li>
</ul>
</div>
<span class="invalid-feedback"></span>
<span id="add-invalid-feedback" class="invalid-feedback"></span>
</div>
<div class="modal-footer">
<button type="submit" class="btn btn-primary">{{ i18n("add") }}</button>

View file

@ -28,7 +28,7 @@ local function reportError(msg)
end
local function isValidHostMeasurementCombination(host, measurement)
local host_v4 = isIPv4(host)
local host_v4 = isIPv4(host) or isIPv4WithPort(host)
local host_v6 = isIPv6(host)
local expected_ipv = ternary((measurement == "icmp6"), 6, 4)