forked from Support/sp-hydra-veil-gui
Compare commits
No commits in common. "5996a117b33f20b31002baf7544966e890d891c1" and "a0b39365a3bd8a731094666458ac7173fc463454" have entirely different histories.
5996a117b3
...
a0b39365a3
7 changed files with 13 additions and 40 deletions
|
|
@ -56,8 +56,3 @@ def navigate_to_singbox_setup() -> Result:
|
||||||
return Result(valid=False, error_type=ResultError.NAVIGATE_TO, navigate_to="networking_setup")
|
return Result(valid=False, error_type=ResultError.NAVIGATE_TO, navigate_to="networking_setup")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@register_action(ResultError.NODE_ERROR)
|
|
||||||
def down_location_edit_page():
|
|
||||||
print(f"going to the edit page and boolean_value as true, for the location being down.")
|
|
||||||
return Result(valid=False, data=True, error_type=ResultError.NAVIGATE_TO, navigate_to="editor")
|
|
||||||
|
|
|
||||||
|
|
@ -349,15 +349,12 @@ def disconnect_active(ui_caller: Optional[Callable] = None) -> Result:
|
||||||
else:
|
else:
|
||||||
return Result(valid=True)
|
return Result(valid=True)
|
||||||
|
|
||||||
def sync_now(ui_caller: Callable, force_all: bool = False):
|
def sync_now(ui_caller: Callable):
|
||||||
if force_all:
|
|
||||||
logger.info("Performing sync with force all")
|
|
||||||
take_action(
|
take_action(
|
||||||
action=new_sync,
|
action=new_sync,
|
||||||
ui_caller=ui_caller,
|
ui_caller=ui_caller,
|
||||||
client_observer=client_observer,
|
client_observer=client_observer,
|
||||||
connection_observer=connection_observer,
|
connection_observer=connection_observer
|
||||||
force_all=force_all
|
|
||||||
)
|
)
|
||||||
|
|
||||||
def delete_profile_action(profile_id: int, ui_caller: Callable) -> Result:
|
def delete_profile_action(profile_id: int, ui_caller: Callable) -> Result:
|
||||||
|
|
|
||||||
|
|
@ -16,14 +16,13 @@ def create_profile(potential_data: dict, ui_caller: Callable):
|
||||||
)
|
)
|
||||||
|
|
||||||
@type_checker
|
@type_checker
|
||||||
def edit_profile(profile_id: int, location_down: bool, potential_data: dict, ui_caller: Callable):
|
def edit_profile(profile_id: int, potential_data: dict, ui_caller: Callable):
|
||||||
"""Pass the data through the plumbing, to edit a profile."""
|
"""Pass the data through the plumbing, to edit a profile."""
|
||||||
take_action(
|
take_action(
|
||||||
action=update_profile,
|
action=update_profile,
|
||||||
ui_caller=ui_caller,
|
ui_caller=ui_caller,
|
||||||
profile_id=profile_id,
|
profile_id=profile_id,
|
||||||
new_choices=potential_data,
|
new_choices=potential_data
|
||||||
server_location_change=location_down
|
|
||||||
)
|
)
|
||||||
|
|
||||||
def get_all_profiles(ui_caller: Callable):
|
def get_all_profiles(ui_caller: Callable):
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@ class Navigator(QObject):
|
||||||
return getattr(module, class_name)
|
return getattr(module, class_name)
|
||||||
|
|
||||||
|
|
||||||
def _instantiate(self, name, prepared=None, profile_id=None, location_down=None):
|
def _instantiate(self, name, prepared=None, profile_id=None):
|
||||||
cls = self.get_class(name)
|
cls = self.get_class(name)
|
||||||
|
|
||||||
# 1. Inspect the constructor's parameters
|
# 1. Inspect the constructor's parameters
|
||||||
|
|
@ -70,10 +70,6 @@ class Navigator(QObject):
|
||||||
if "prepared" in params:
|
if "prepared" in params:
|
||||||
kwargs["prepared"] = prepared
|
kwargs["prepared"] = prepared
|
||||||
|
|
||||||
# Only add location_down if the class accepts it
|
|
||||||
if location_down is not None and "location_down" in params:
|
|
||||||
kwargs["location_down"] = location_down
|
|
||||||
|
|
||||||
# 3. Instantiate using the filtered dictionary
|
# 3. Instantiate using the filtered dictionary
|
||||||
return cls(**kwargs)
|
return cls(**kwargs)
|
||||||
|
|
||||||
|
|
@ -82,7 +78,7 @@ class Navigator(QObject):
|
||||||
self.page_stack.addWidget(page)
|
self.page_stack.addWidget(page)
|
||||||
self._instances[name] = page
|
self._instances[name] = page
|
||||||
|
|
||||||
def navigate(self, name, profile_id = None, location_down = None):
|
def navigate(self, name, profile_id = None):
|
||||||
page = self._instances.get(name)
|
page = self._instances.get(name)
|
||||||
|
|
||||||
if page is None:
|
if page is None:
|
||||||
|
|
@ -97,10 +93,6 @@ class Navigator(QObject):
|
||||||
logger.info(f"Navigator is setting profile_id data of {profile_id}")
|
logger.info(f"Navigator is setting profile_id data of {profile_id}")
|
||||||
page.profile_id = profile_id
|
page.profile_id = profile_id
|
||||||
|
|
||||||
if location_down is not None:
|
|
||||||
logger.info(f"Navigator is setting location_down data of {location_down}")
|
|
||||||
page.location_down = location_down
|
|
||||||
|
|
||||||
# Make it visible:
|
# Make it visible:
|
||||||
self.page_stack.setCurrentIndex(self.page_stack.indexOf(page))
|
self.page_stack.setCurrentIndex(self.page_stack.indexOf(page))
|
||||||
return page
|
return page
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ class PreEdit:
|
||||||
|
|
||||||
|
|
||||||
class RegistrationState:
|
class RegistrationState:
|
||||||
def __init__(self, btn_path, profile_id: Optional[int] = None, location_down: Optional[bool] = False):
|
def __init__(self, btn_path, profile_id: Optional[int] = None):
|
||||||
self.btn_path = btn_path
|
self.btn_path = btn_path
|
||||||
self.all_options = {}
|
self.all_options = {}
|
||||||
self.selections = {}
|
self.selections = {}
|
||||||
|
|
@ -36,7 +36,6 @@ class RegistrationState:
|
||||||
self.proceed = False
|
self.proceed = False
|
||||||
self.warnings_dict = {}
|
self.warnings_dict = {}
|
||||||
self.key_choices = []
|
self.key_choices = []
|
||||||
self.location_down = location_down
|
|
||||||
|
|
||||||
# Maps a category to the function that validates its current selection.
|
# Maps a category to the function that validates its current selection.
|
||||||
self._filter_map = {
|
self._filter_map = {
|
||||||
|
|
@ -342,8 +341,7 @@ class RegistrationState:
|
||||||
# 2. Map keys to their specific warning messages
|
# 2. Map keys to their specific warning messages
|
||||||
WARNING_MESSAGES = {
|
WARNING_MESSAGES = {
|
||||||
"location": lambda: "If you change the location, it wipes the subscription, proceed?"
|
"location": lambda: "If you change the location, it wipes the subscription, proceed?"
|
||||||
if not self.location_down
|
if not profile_can_respawn(self.profile_id).valid
|
||||||
and not profile_can_respawn(self.profile_id).valid
|
|
||||||
and profile_can_respawn(self.profile_id).error_type != ResultError.SUBSCRIPTION
|
and profile_can_respawn(self.profile_id).error_type != ResultError.SUBSCRIPTION
|
||||||
else None,
|
else None,
|
||||||
"browser": lambda: "If you change the browser, it wipes the cookies/bookmarks, proceed?"
|
"browser": lambda: "If you change the browser, it wipes the cookies/bookmarks, proceed?"
|
||||||
|
|
|
||||||
|
|
@ -17,10 +17,9 @@ from typing import Optional
|
||||||
|
|
||||||
|
|
||||||
class EditPage(Page):
|
class EditPage(Page):
|
||||||
def __init__(self, page_stack, main_window, prepared=None, profile_id: Optional[int] = None, location_down: Optional[bool] = False):
|
def __init__(self, page_stack, main_window, prepared=None, profile_id: Optional[int] = None):
|
||||||
super().__init__("EditPage", page_stack, main_window)
|
super().__init__("EditPage", page_stack, main_window)
|
||||||
self.profile_id = profile_id
|
self.profile_id = profile_id
|
||||||
self.location_down = location_down
|
|
||||||
|
|
||||||
# 1. Permanent Structure: Created once in init
|
# 1. Permanent Structure: Created once in init
|
||||||
self.content_area = QWidget()
|
self.content_area = QWidget()
|
||||||
|
|
@ -63,7 +62,7 @@ class EditPage(Page):
|
||||||
|
|
||||||
# 2. State Reset: Wipe old widgets and old state
|
# 2. State Reset: Wipe old widgets and old state
|
||||||
self.clear_ui()
|
self.clear_ui()
|
||||||
self.state = RegistrationState(btn_path=self.btn_path, profile_id=profile_id, location_down=self.location_down)
|
self.state = RegistrationState(btn_path=self.btn_path, profile_id=profile_id)
|
||||||
print("Created a new RegistrationState")
|
print("Created a new RegistrationState")
|
||||||
|
|
||||||
# 3. Create groups, passing the category string and the state object
|
# 3. Create groups, passing the category string and the state object
|
||||||
|
|
@ -144,19 +143,18 @@ class EditPage(Page):
|
||||||
|
|
||||||
def proceed_with_edit(self, different_content):
|
def proceed_with_edit(self, different_content):
|
||||||
|
|
||||||
print(f"different_content is {different_content} and self.location_down is {self.location_down}")
|
print(f"different_content is {different_content}")
|
||||||
|
|
||||||
edit_profile(
|
edit_profile(
|
||||||
profile_id=self.profile_id,
|
profile_id=self.profile_id,
|
||||||
potential_data=different_content,
|
potential_data=different_content,
|
||||||
location_down=self.location_down,
|
|
||||||
ui_caller=self.after_submission
|
ui_caller=self.after_submission
|
||||||
)
|
)
|
||||||
self.created_display = False
|
self.created_display = False
|
||||||
|
|
||||||
|
|
||||||
def submit_edits(self):
|
def submit_edits(self):
|
||||||
print(f"submit_edits with self.location as {self.location_down}")
|
print("submit_edits")
|
||||||
# name
|
# name
|
||||||
input_text = self.group_name.text_input.text()
|
input_text = self.group_name.text_input.text()
|
||||||
if not input_text:
|
if not input_text:
|
||||||
|
|
|
||||||
|
|
@ -684,13 +684,7 @@ class MenuPage(Page):
|
||||||
def deal_with_errors(self, result: Result):
|
def deal_with_errors(self, result: Result):
|
||||||
if result.error_type == ResultError.NAVIGATE_TO:
|
if result.error_type == ResultError.NAVIGATE_TO:
|
||||||
print(f"We are auto-navigating to page {result.navigate_to}")
|
print(f"We are auto-navigating to page {result.navigate_to}")
|
||||||
if result.navigate_to == "editor" and result.data:
|
self.custom_window.navigator.navigate(result.navigate_to)
|
||||||
print("going to editor page with a different location")
|
|
||||||
profile_id = self.reverse_id
|
|
||||||
print(f"profile_id is {profile_id}")
|
|
||||||
self.custom_window.navigator.navigate(name="editor", profile_id=profile_id, location_down=result.data)
|
|
||||||
else:
|
|
||||||
self.custom_window.navigator.navigate(name=result.navigate_to)
|
|
||||||
|
|
||||||
elif result.error_type == ResultError.SUBSCRIPTION:
|
elif result.error_type == ResultError.SUBSCRIPTION:
|
||||||
print("We are navigating to the subscription page")
|
print("We are navigating to the subscription page")
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue