Skip to content

Commit

Permalink
Added preference to change the default Dashboard page
Browse files Browse the repository at this point in the history
  • Loading branch information
MatteoBiscosi committed Sep 19, 2024
1 parent d844bad commit 7549771
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 0 deletions.
4 changes: 4 additions & 0 deletions include/Prefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class Prefs {
char **deferred_interfaces_to_register, *cli, *ciphers_list;
char *http_binding_address1, *http_binding_address2;
char *https_binding_address1, *https_binding_address2;
char *http_index_page;
bool enable_client_x509_auth, reproduce_at_original_speed, disable_purge;
char* zmq_publish_events_url, *http_log_path;
const char *clickhouse_client, *clickhouse_cluster_name;
Expand Down Expand Up @@ -559,6 +560,9 @@ class Prefs {
inline u_int32_t get_pkt_ifaces_flow_max_idle() {
return (pkt_ifaces_flow_max_idle);
};
inline char *getHttpIndexPage() {
return http_index_page;
};
inline bool are_top_talkers_enabled() { return (enable_top_talkers); };
inline bool flow_table_duration_or_last_seen() { return (flow_table_time); };
inline bool is_active_local_host_cache_enabled() {
Expand Down
5 changes: 5 additions & 0 deletions include/ntop_defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -759,6 +759,11 @@
NTOPNG_PREFS_PREFIX ".behaviour_analysis_learning_status_during_learning"
#define CONST_PREFS_BEHAVIOUR_ANALYSIS_STATUS_POST_LEARNING \
NTOPNG_PREFS_PREFIX ".behaviour_analysis_learning_status_post_learning"

#define CONST_PREFS_HTTP_INDEX_PAGE \
NTOPNG_PREFS_PREFIX ".http_index_page"
#define DEFAULT_HTTP_INDEX_PAGE \
""

#define CONST_PREFS_IEC60870_ANALYSIS_LEARNING_PERIOD \
NTOPNG_PREFS_PREFIX ".iec60870_learning_period"
Expand Down
2 changes: 2 additions & 0 deletions scripts/locales/en.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6790,6 +6790,8 @@ local lang = {
["ignored_interfaces_description"] = "When 'Ingress Interface' is selected as disaggregation criterion, do not add to a dynamic interface any flow having its %%INPUT_SNMP in this list. When 'Interface' disaggregation is selected, do not add to the first (second) dynamic interface any flow having its %%INPUT_SNMP (%%OUTPUT_SNMP) in this list. Specify one or more comma-separated SNMP interface ids. Changes require %{product} restart.",
["ignored_interfaces_title"] = "Ignored interfaces",
["incompatible_influxdb_version_found"] = "Incompatible InfluxDB version: required \"%{required}\", found \"%{found}\". Please install an updated version from the <a href='%{url}'>official site</a>.",
["http_index_page"] = "Index Page",
["http_index_page_description"] = "An ntopng page, used to be redirected whenever the ntopng index page is requested. By default it's the /index page, containing the main Dashboard (e.g. set /lua/pro/enterprise/snmpdevices_stats.lua to set the SNMP page as the default one instead of the Dashboard)",
["influxdb_auth_description"] = "Enable InfluxDB authentication.",
["influxdb_auth_title"] = "InfluxDB Authentication",
["influxdb_create_error"] = "Could not create \"%{db}\" database: %{msg}",
Expand Down
14 changes: 14 additions & 0 deletions scripts/lua/admin/prefs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,21 @@ if auth.has_capability(auth.capabilities.preferences) then
pref = "is_interface_name_only"
})

-- #####################

prefsInputFieldPrefs(subpage_active.entries["http_index_page"].title, subpage_active.entries["http_index_page"].description,
"ntopng.prefs.", "http_index_page", prefs.http_index_page, false, nil, nil, nil, {
style = {
width = "25em;"
},
attributes = {
spellcheck = "false",
maxlength = 256,
}
})

printMenuEntriesPrefs()
tprint(prefs)

print(
'<tr><th colspan=2 style="text-align:right;"><button type="submit" class="btn btn-primary" style="width:115px" disabled="disabled">' ..
Expand Down
1 change: 1 addition & 0 deletions scripts/lua/modules/http_lint.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2380,6 +2380,7 @@ local known_parameters = {
["max_ui_strlen"] = validateNumber,
["ntopng_host_address"] = validateSingleWord,
["http_acl_management_port"] = validateACLNetworksList,
["http_index_page"] = validateUnquoted,
["safe_search_dns"] = validateIPV4,
["global_dns"] = validateEmptyOr(validateIPV4),
["secondary_dns"] = validateEmptyOr(validateIPV4),
Expand Down
4 changes: 4 additions & 0 deletions scripts/lua/modules/prefs_menu.lua
Original file line number Diff line number Diff line change
Expand Up @@ -842,6 +842,10 @@ local menu_subpages = {{
product = info.product