mirror of
https://github.com/ntop/ntopng.git
synced 2026-04-29 07:29:32 +00:00
Added Vite to frontend builds
This commit is contained in:
parent
daf007c161
commit
2b5d2d7949
118 changed files with 10172 additions and 34001 deletions
|
|
@ -1,25 +1,27 @@
|
|||
export function makeUniqueValidator(items_function) {
|
||||
return function(field) {
|
||||
var cmp_name = field.val();
|
||||
var count = 0;
|
||||
const cmp_name = field.val();
|
||||
let count = 0;
|
||||
|
||||
// this will be checked separately, with 'required' argument
|
||||
if(! cmp_name)
|
||||
if (! cmp_name) {
|
||||
return true;
|
||||
}
|
||||
|
||||
items_function(field).each(function() {
|
||||
var name = $(this).val();
|
||||
if (name == cmp_name)
|
||||
const name = $(this).val();
|
||||
if (name == cmp_name) {
|
||||
count = count + 1;
|
||||
}
|
||||
});
|
||||
|
||||
return count == 1;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export function memberValueValidator(input) {
|
||||
var member = input.val();
|
||||
if (member === "") return true;
|
||||
const member = input.val();
|
||||
if (member === '') return true;
|
||||
|
||||
return NtopUtils.is_mac_address(member) || NtopUtils.is_network_mask(member, true);
|
||||
}
|
||||
|
|
@ -27,83 +29,85 @@ export function memberValueValidator(input) {
|
|||
export function makePasswordPatternValidator(pattern) {
|
||||
return function passwordPatternValidator(input) {
|
||||
// required is checked separately
|
||||
if(!input.val()) return true;
|
||||
if (!input.val()) return true;
|
||||
return $(input).val().match(pattern);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export function passwordMatchValidator(input) {
|
||||
var other_input = $(input).closest("form").find("[data-passwordmatch]").not(input);
|
||||
if(!input.val() || !other_input.val()) return true;
|
||||
const other_input = $(input).closest('form').find('[data-passwordmatch]').not(input);
|
||||
if (!input.val() || !other_input.val()) return true;
|
||||
return other_input.val() === input.val();
|
||||
}
|
||||
|
||||
export function poolnameValidator(input) {
|
||||
// required is checked separately
|
||||
if(!input.val()) return true;
|
||||
if (!input.val()) return true;
|
||||
return $(input).val().match(/^[a-z0-9_]*$/);
|
||||
}
|
||||
|
||||
export function passwordMatchRecheck(form) {
|
||||
var items = $(form).find("[data-passwordmatch]");
|
||||
var not_empty = 0;
|
||||
const items = $(form).find('[data-passwordmatch]');
|
||||
let not_empty = 0;
|
||||
|
||||
items.each(function() {
|
||||
if($(this).val() != "") not_empty++;
|
||||
if ($(this).val() != '') not_empty++;
|
||||
});
|
||||
|
||||
if(not_empty == items.length) items.trigger('input');
|
||||
if (not_empty == items.length) items.trigger('input');
|
||||
}
|
||||
|
||||
export function hostOrMacValidator(input) {
|
||||
var host = input.val();
|
||||
const host = input.val();
|
||||
|
||||
/* Handled separately */
|
||||
if (host === "") return true;
|
||||
if (host === '') return true;
|
||||
|
||||
return NtopUtils.is_mac_address(host) || NtopUtils.is_good_ipv4(host) || NtopUtils.is_good_ipv6(host);
|
||||
}
|
||||
|
||||
export function ipAddressValidator(input) {
|
||||
var host = input.val();
|
||||
const host = input.val();
|
||||
|
||||
/* Handled separately */
|
||||
if (host === "") return true;
|
||||
if (host === '') return true;
|
||||
|
||||
return NtopUtils.is_good_ipv4(host) || NtopUtils.is_good_ipv6(host);
|
||||
}
|
||||
|
||||
var filters_to_validate = {};
|
||||
const filters_to_validate = {};
|
||||
|
||||
export function bpfValidator(filter_field, sync = false) {
|
||||
var filter = filter_field.val();
|
||||
const filter = filter_field.val();
|
||||
|
||||
if (filter.trim() === "") {
|
||||
if (filter.trim() === '') {
|
||||
return true;
|
||||
}
|
||||
|
||||
var key = filter_field.attr("name");
|
||||
var timeout = 250;
|
||||
const key = filter_field.attr('name');
|
||||
const timeout = 250;
|
||||
|
||||
if (!filters_to_validate[key])
|
||||
filters_to_validate[key] = {ajax_obj:null, valid:true, timer:null, submit_remind:false, last_val:null};
|
||||
var status = filters_to_validate[key];
|
||||
if (!filters_to_validate[key]) {
|
||||
filters_to_validate[key] = {ajax_obj: null, valid: true, timer: null, submit_remind: false, last_val: null};
|
||||
}
|
||||
const status = filters_to_validate[key];
|
||||
|
||||
var sendAjax = function () {
|
||||
const sendAjax = function() {
|
||||
status.timer = null;
|
||||
|
||||
var finally_check = function (valid) {
|
||||
const finally_check = function(valid) {
|
||||
status.ajax_obj = null;
|
||||
status.valid = valid;
|
||||
status.last_val = filter;
|
||||
}
|
||||
};
|
||||
|
||||
if (status.last_val !== filter) {
|
||||
if (status.ajax_obj)
|
||||
if (status.ajax_obj) {
|
||||
status.ajax_obj.abort();
|
||||
}
|
||||
|
||||
status.ajax_obj = $.ajax({
|
||||
type: "GET",
|
||||
type: 'GET',
|
||||
url: `${http_prefix}/lua/pro/rest/v2/check/filter.lua`,
|
||||
async: !sync,
|
||||
data: {
|
||||
|
|
@ -111,9 +115,9 @@ export function bpfValidator(filter_field, sync = false) {
|
|||
}, error: function() {
|
||||
finally_check(status.valid);
|
||||
}, success: function(data) {
|
||||
var valid = data.response ? true : false;
|
||||
const valid = data.response ? true : false;
|
||||
finally_check(valid);
|
||||
}
|
||||
},
|
||||
});
|
||||
} else {
|
||||
// possibly process the reminder
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue