mirror of
https://github.com/ntop/ntopng.git
synced 2026-05-06 03:45:26 +00:00
replaced endpoint/recipient name as primary key in GUI
This commit is contained in:
parent
9e508a7382
commit
5db42ecec4
7 changed files with 42 additions and 21 deletions
|
|
@ -1,5 +1,6 @@
|
|||
$(document).ready(function () {
|
||||
|
||||
const DEFAULT_ENDPOINT_CONF_ID = 0;
|
||||
const INDEX_COLUMN_ENDPOINT_TYPE = 1;
|
||||
|
||||
function getTypesCount(configs) {
|
||||
|
|
@ -128,6 +129,7 @@ $(document).ready(function () {
|
|||
beforeSumbit: function () {
|
||||
const body = makeFormData(`#edit-endpoint-modal form`);
|
||||
body.action = 'edit';
|
||||
body.endpoint_conf_id = $(`#edit-endpoint-modal form [name='endpoint_conf_id']`).val();
|
||||
return body;
|
||||
},
|
||||
loadFormData: function () {
|
||||
|
|
@ -140,6 +142,7 @@ $(document).ready(function () {
|
|||
$(`#endpoint-type`).html(data.endpoint_conf_name);
|
||||
/* load the values inside the template */
|
||||
$(`#edit-endpoint-modal form [name='name']`).val(data.endpoint_conf_name);
|
||||
$(`#edit-endpoint-modal form [name='endpoint_conf_id']`).val(data.endpoint_conf_id || DEFAULT_ENDPOINT_CONF_ID);
|
||||
$(`#edit-endpoint-modal form .endpoint-template-container [name]`).each(function(i, input) {
|
||||
$(this).val(data.endpoint_conf[$(this).attr('name')]);
|
||||
});
|
||||
|
|
@ -217,7 +220,7 @@ $(document).ready(function () {
|
|||
beforeSumbit: () => {
|
||||
return {
|
||||
action: 'remove',
|
||||
endpoint_conf_name: removeModalData.endpoint_conf_name
|
||||
endpoint_conf_id: removeModalData.endpoint_conf_id || DEFAULT_ENDPOINT_CONF_ID
|
||||
};
|
||||
},
|
||||
onModalInit: function (data) {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
// @ts-nocheck
|
||||
$(document).ready(function () {
|
||||
|
||||
const DEFAULT_RECIPIENT_ID = 0;
|
||||
const INDEX_COLUMN_ENDPOINT_TYPE = 2;
|
||||
|
||||
let editRowData = null;
|
||||
|
|
@ -127,15 +128,9 @@ $(document).ready(function () {
|
|||
className: 'text-center',
|
||||
data: null,
|
||||
render: function (data, type, row) {
|
||||
|
||||
let editButton = "";
|
||||
const endpointType = row.endpoint_conf.endpoint_key
|
||||
// if the template is empty then disabled the edit button
|
||||
const editButtonDisabled = $.trim($(`#${endpointType}-template`).html()) == "";
|
||||
|
||||
return (`
|
||||
<div class='btn-group btn-group-sm'>
|
||||
<a data-toggle='modal' href='#edit-recipient-modal' class="btn btn-info ${editButtonDisabled ? 'disabled' : ''}" >
|
||||
<a data-toggle='modal' href='#edit-recipient-modal' class="btn btn-info" >
|
||||
<i class='fas fa-edit'></i>
|
||||
</a>
|
||||
<a data-toggle='modal' href='#remove-recipient-modal' class="btn btn-danger">
|
||||
|
|
@ -169,6 +164,7 @@ $(document).ready(function () {
|
|||
beforeSumbit: function () {
|
||||
const data = makeFormData(`#edit-recipient-modal form`);
|
||||
data.action = 'edit';
|
||||
data.recipient_id = $(`#edit-recipient-modal form [name='recipient_id']`).val();
|
||||
return data;
|
||||
},
|
||||
onModalInit: function (data) {
|
||||
|
|
@ -176,10 +172,14 @@ $(document).ready(function () {
|
|||
const $cloned = loadTemplate(editRowData.endpoint_conf.endpoint_key);
|
||||
/* load the right template from templates */
|
||||
if ($cloned) {
|
||||
$(`#edit-recipient-modal form .recipient-template-container`).empty().append($cloned).show();
|
||||
$(`#edit-recipient-modal form .recipient-template-container`).empty().append($(`<hr>`)).append($cloned).show();
|
||||
}
|
||||
else {
|
||||
$(`#edit-recipient-modal form .recipient-template-container`).empty().hide();
|
||||
}
|
||||
$(`#edit-recipient-name`).text(editRowData.recipient_name);
|
||||
/* load the values inside the template */
|
||||
$(`#edit-recipient-modal form [name='recipient_id']`).val(editRowData.recipient_id || DEFAULT_RECIPIENT_ID);
|
||||
$(`#edit-recipient-modal form [name='recipient_name']`).val(editRowData.recipient_name);
|
||||
$(`#edit-recipient-modal form [name='endpoint_conf_name']`).val(editRowData.endpoint_conf.endpoint_conf_name);
|
||||
$(`#edit-recipient-modal form .recipient-template-container [name]`).each(function (i, input) {
|
||||
|
|
@ -284,7 +284,7 @@ $(document).ready(function () {
|
|||
beforeSumbit: function () {
|
||||
return {
|
||||
action: 'remove',
|
||||
recipient_name: removeRowData.recipient_name
|
||||
recipient_id: removeRowData.recipient_id || DEFAULT_RECIPIENT_ID
|
||||
}
|
||||
},
|
||||
onSubmitSuccess: function (response) {
|
||||
|
|
|
|||
|
|
@ -19,7 +19,15 @@
|
|||
</div>
|
||||
<form>
|
||||
<div class="modal-body">
|
||||
<input type="text" hidden name="name">
|
||||
<input type="text" hidden name="endpoint_conf_id">
|
||||
<div class="form-group row">
|
||||
<label class="col-form-label col-sm-3" for="endpoint-name-input">
|
||||
<b>{{ i18n("endpoint_notifications.name") }}</b>
|
||||
</label>
|
||||
<div class="col-sm-5">
|
||||
<input data-validation-empty-message="{{ i18n('validation.empty_name') }}" required name="name" type="text" class="form-control" id="edit-endpoint-name-input">
|
||||
</div>
|
||||
</div>
|
||||
<div class="endpoint-template-container pt-2">
|
||||
</div>
|
||||
<span class="invalid-feedback"></span>
|
||||
|
|
|
|||
|
|
@ -21,10 +21,10 @@
|
|||
<div class="modal-body">
|
||||
<div class="form-group row">
|
||||
<label class="col-form-label col-sm-3" for="recipient-name-input">
|
||||
<b>{{ i18n("endpoint_notifications.recipient_name") }}</b>:
|
||||
<b>{{ i18n("endpoint_notifications.recipient_name") }}</b>
|
||||
</label>
|
||||
<div class="col-sm-5">
|
||||
<input pattern=".*\S+.*" maxlength="32" minlength="4" required name="recipient_name" type="text" class="form-control" id="recipient-name-input">
|
||||
<input minlength="1" required name="recipient_name" type="text" class="form-control" id="recipient-name-input">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
|
|
|
|||
|
|
@ -19,8 +19,16 @@
|
|||
</div>
|
||||
<form>
|
||||
<div class="modal-body">
|
||||
<input type="text" hidden name="recipient_name">
|
||||
<input type="number" hidden name="recipient_id">
|
||||
<input type="text" hidden name="endpoint_conf_name">
|
||||
<div class="form-group row">
|
||||
<label class="col-form-label col-sm-3" for="recipient-name-input">
|
||||
<b>{{ i18n("endpoint_notifications.recipient_name") }}</b>:
|
||||
</label>
|
||||
<div class="col-sm-5">
|
||||
<input maxlength="32" minlength="1" required name="recipient_name" type="text" class="form-control" id="recipient-name-input">
|
||||
</div>
|
||||
</div>
|
||||
<div class="recipient-template-container">
|
||||
</div>
|
||||
<span class="invalid-feedback"></span>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue