mirror of
https://github.com/pdxlocations/contact.git
synced 2026-06-29 06:21:16 +02:00
add is_licensed
This commit is contained in:
+5
-5
@@ -40,11 +40,11 @@ def save_changes(interface, menu_path, modified_settings):
|
||||
|
||||
elif menu_path[1] == "User Settings": # for user configs
|
||||
config_category = "User Settings"
|
||||
long_name = modified_settings.get("longName", None)
|
||||
short_name = modified_settings.get("shortName", None)
|
||||
#TODO add is_licensed
|
||||
node.setOwner(long_name, short_name, is_licensed=False)
|
||||
logging.info(f"Updated {config_category} with Long Name: {long_name} and Short Name {short_name}")
|
||||
long_name = modified_settings.get("longName")
|
||||
short_name = modified_settings.get("shortName")
|
||||
is_licensed = modified_settings.get("isLicensed")
|
||||
node.setOwner(long_name, short_name, is_licensed)
|
||||
logging.info(f"Updated {config_category} with Long Name: {long_name} and Short Name {short_name} and Licensed Mode {is_licensed}")
|
||||
return
|
||||
|
||||
|
||||
|
||||
+27
-11
@@ -111,47 +111,63 @@ def settings_menu(stdscr, interface):
|
||||
selected_option = options[selected_index]
|
||||
|
||||
if selected_option == "Exit":
|
||||
stdscr.clear()
|
||||
break
|
||||
elif selected_option == "Reboot":
|
||||
confirmation = get_bool_selection("Are you sure you want to Reboot?", 0)
|
||||
if confirmation == "True":
|
||||
settings_reboot(interface)
|
||||
logging.info(f"Node Reboot Requested by menu")
|
||||
stdscr.clear()
|
||||
break
|
||||
elif selected_option == "Reset Node DB":
|
||||
confirmation = get_bool_selection("Are you sure you want to Reset Node DB?", 0)
|
||||
if confirmation == "True":
|
||||
settings_reset_nodedb(interface)
|
||||
logging.info(f"Node DB Reset Requested by menu")
|
||||
stdscr.clear()
|
||||
break
|
||||
elif selected_option == "Shutdown":
|
||||
confirmation = get_bool_selection("Are you sure you want to Shutdown?", 0)
|
||||
if confirmation == "True":
|
||||
settings_shutdown(interface)
|
||||
logging.info(f"Node Shutdown Requested by menu")
|
||||
stdscr.clear()
|
||||
break
|
||||
elif selected_option == "Factory Reset":
|
||||
confirmation = get_bool_selection("Are you sure you want to Factory Reset?", 0)
|
||||
if confirmation == "True":
|
||||
settings_factory_reset(interface)
|
||||
logging.info(f"Factory Reset Requested by menu")
|
||||
stdscr.clear()
|
||||
break
|
||||
|
||||
field_info = current_menu.get(selected_option)
|
||||
|
||||
if isinstance(field_info, tuple):
|
||||
field, current_value = field_info
|
||||
|
||||
if selected_option == 'longName' or selected_option == 'shortName':
|
||||
new_value = get_user_input(f"Current value for {selected_option}: {current_value}")
|
||||
|
||||
modified_settings[selected_option] = (new_value)
|
||||
current_menu[selected_option] = (field, new_value)
|
||||
if selected_option in ['longName', 'shortName', 'isLicensed']:
|
||||
if selected_option in ['longName', 'shortName']:
|
||||
new_value = get_user_input(f"Current value for {selected_option}: {current_value}")
|
||||
current_menu[selected_option] = (field, new_value)
|
||||
|
||||
elif selected_option == 'isLicensed':
|
||||
new_value = get_bool_selection(f"Current value for {selected_option}: {current_value}", str(current_value))
|
||||
try:
|
||||
if isinstance(new_value, str):
|
||||
new_value_lower = new_value.lower()
|
||||
if new_value_lower in ("true", "yes", "1", "on"):
|
||||
new_value = True
|
||||
elif new_value_lower in ("false", "no", "0", "off"):
|
||||
new_value = False
|
||||
else:
|
||||
raise ValueError("Invalid string for boolean")
|
||||
else:
|
||||
new_value = bool(new_value)
|
||||
except ValueError as e:
|
||||
logging.error(f"Invalid input for boolean: {e}")
|
||||
new_value = current_value # Keep the current value if the input is invalid
|
||||
|
||||
current_menu[selected_option] = (field, new_value)
|
||||
|
||||
for option, (field, value) in current_menu.items():
|
||||
modified_settings[option] = value
|
||||
|
||||
|
||||
elif field.type == 8: # Handle boolean type
|
||||
new_value = get_bool_selection(selected_option, str(current_value))
|
||||
|
||||
+2
-1
@@ -61,7 +61,8 @@ def generate_menu_from_protobuf(interface):
|
||||
|
||||
menu_structure["Main Menu"]["User Settings"] = {
|
||||
"longName": (None, current_user_config.get("longName", "Not Set")),
|
||||
"shortName": (None, current_user_config.get("shortName", "Not Set"))
|
||||
"shortName": (None, current_user_config.get("shortName", "Not Set")),
|
||||
"isLicensed": (None, current_user_config.get("isLicened", "False"))
|
||||
}
|
||||
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user