mirror of
https://github.com/ntop/ntopng.git
synced 2026-05-03 01:10:10 +00:00
Restyle timeseries: restyle consts.lua; add new network_details page; restyle page-stats props
This commit is contained in:
parent
1d2bd8de20
commit
9c004f1ab7
11 changed files with 142 additions and 83 deletions
|
|
@ -146,17 +146,18 @@ const ui_types = {
|
|||
|
||||
const sources_types = [
|
||||
{
|
||||
regex_page_url: "lua\/if_stats",
|
||||
label: "Interface",
|
||||
sources_url: "lua/rest/v2/get/ntopng/interfaces.lua",
|
||||
value: "ifid",
|
||||
ui_type: ui_types.select,
|
||||
table_value: "interface",
|
||||
query: "ifid",
|
||||
query: "iface",
|
||||
},
|
||||
{
|
||||
regex_page_url: "lua\/host_details",
|
||||
label: "Host",
|
||||
disable_url: true,
|
||||
//sources_url: "lua/rest/v2/get/ntopng/interfaces.lua",
|
||||
value: "host",
|
||||
regex_type: "ip",
|
||||
sources_sub_url: "lua/rest/v2/get/ntopng/interfaces.lua",
|
||||
|
|
@ -167,9 +168,9 @@ const sources_types = [
|
|||
query: "host",
|
||||
},
|
||||
{
|
||||
regex_page_url: "lua\/mac_details",
|
||||
label: "Mac",
|
||||
disable_url: true,
|
||||
//sources_url: "lua/rest/v2/get/ntopng/interfaces.lua",
|
||||
value_url: "host",
|
||||
value: "mac",
|
||||
regex_type: "macAddress",
|
||||
|
|
@ -179,6 +180,19 @@ const sources_types = [
|
|||
ui_type: ui_types.select_and_input,
|
||||
query: "mac",
|
||||
},
|
||||
{
|
||||
regex_page_url: "lua\/network_details",
|
||||
label: "Network",
|
||||
disable_url: true,
|
||||
// value_url: "subnet",
|
||||
value: "subnet",
|
||||
regex_type: "text",
|
||||
sources_sub_url: "lua/rest/v2/get/ntopng/interfaces.lua",
|
||||
sub_value: "ifid",
|
||||
sub_label: "Interface",
|
||||
ui_type: ui_types.select_and_input,
|
||||
query: "subnet",
|
||||
},
|
||||
];
|
||||
|
||||
const get_source_type_from_value = (source_type_value) => {
|
||||
|
|
@ -259,6 +273,16 @@ const get_sources = async (http_prefix, source_type) => {
|
|||
return sources.sort(NtopUtils.sortAlphabetically)
|
||||
};
|
||||
|
||||
function get_source_type_key_value_url(source_type) {
|
||||
if (source_type.value_url != null) { return source_type.value_url; }
|
||||
return source_type.value;
|
||||
}
|
||||
|
||||
function get_source_type_key_sub_value_url(source_type) {
|
||||
if (source_type.sub_value_url != null) { return source_type.sub_value_url; }
|
||||
return source_type.sub_value;
|
||||
}
|
||||
|
||||
const get_default_source_value = (source_type) => {
|
||||
if (source_type == null) {
|
||||
source_type = get_current_page_source_type();
|
||||
|
|
@ -315,13 +339,19 @@ const get_metrics = async (http_prefix, source_type, source) => {
|
|||
|
||||
const get_current_page_source_type = () => {
|
||||
let pathname = window.location.pathname;
|
||||
if (/lua\/if_stats/.test(pathname) == true) {
|
||||
return sources_types[0];
|
||||
} else if (/lua\/host_details/.test(pathname) == true) {
|
||||
return sources_types[1];
|
||||
} else if (/lua\/mac_details/.test(pathname) == true) {
|
||||
return sources_types[2];
|
||||
for (let i = 0; i < sources_types.length; i += 1) {
|
||||
let regExp = new RegExp(sources_types[i].regex_page_url);
|
||||
if (regExp.test(pathname) == true) {
|
||||
return sources_types[i];
|
||||
}
|
||||
}
|
||||
// if (/lua\/if_stats/.test(pathname) == true) {
|
||||
// return sources_types[0];
|
||||
// } else if (/lua\/host_details/.test(pathname) == true) {
|
||||
// return sources_types[1];
|
||||
// } else if (/lua\/mac_details/.test(pathname) == true) {
|
||||
// return sources_types[2];
|
||||
// }
|
||||
throw `source_type not found for ${pathname}`;
|
||||
};
|
||||
|
||||
|
|
@ -368,6 +398,9 @@ const metricsManager = function() {
|
|||
get_metrics_from_schema,
|
||||
get_default_metric,
|
||||
|
||||
get_source_type_key_value_url,
|
||||
get_source_type_key_sub_value_url,
|
||||
|
||||
ui_types,
|
||||
};
|
||||
}();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue