diff --git a/kiauh/components/webui_client/client_dialogs.py b/kiauh/components/webui_client/client_dialogs.py index e723274..c4ef7f0 100644 --- a/kiauh/components/webui_client/client_dialogs.py +++ b/kiauh/components/webui_client/client_dialogs.py @@ -7,82 +7,57 @@ # This file may be distributed under the terms of the GNU GPLv3 license # # ======================================================================= # -import textwrap from typing import List from components.webui_client.base_data import BaseWebClient -from core.menus.base_menu import print_back_footer -from utils.constants import COLOR_CYAN, COLOR_YELLOW, RESET_FORMAT from utils.logger import DialogType, Logger def print_moonraker_not_found_dialog(): - line1 = f"{COLOR_YELLOW}WARNING:{RESET_FORMAT}" - line2 = f"{COLOR_YELLOW}No local Moonraker installation was found!{RESET_FORMAT}" - dialog = textwrap.dedent( - f""" - /=======================================================\\ - | {line1:<63}| - | {line2:<63}| - |-------------------------------------------------------| - | It is possible to install Mainsail without a local | - | Moonraker installation. If you continue, you need to | - | make sure, that Moonraker is installed on another | - | machine in your network. Otherwise Mainsail will NOT | - | work correctly. | - """ - )[1:] - - print(dialog, end="") - print_back_footer() + Logger.print_dialog( + DialogType.WARNING, + [ + "No local Moonraker installation was found!", + "\n\n", + "It is possible to install Mainsail without a local Moonraker installation. " + "If you continue, you need to make sure, that Moonraker is installed on " + "another machine in your network. Otherwise Mainsail will NOT work " + "correctly.", + ], + padding_top=0, + padding_bottom=0, + ) def print_client_already_installed_dialog(name: str): - line1 = f"{COLOR_YELLOW}WARNING:{RESET_FORMAT}" - line2 = f"{COLOR_YELLOW}{name} seems to be already installed!{RESET_FORMAT}" - line3 = f"If you continue, your current {name}" - dialog = textwrap.dedent( - f""" - /=======================================================\\ - | {line1:<63}| - | {line2:<63}| - |-------------------------------------------------------| - | {line3:<54}| - | installation will be overwritten. | - """ - )[1:] - - print(dialog, end="") - print_back_footer() + Logger.print_dialog( + DialogType.WARNING, + [ + f"{name} seems to be already installed!", + f"If you continue, your current {name} installation will be overwritten.", + ], + padding_top=0, + padding_bottom=0, + ) def print_client_port_select_dialog(name: str, port: int, ports_in_use: List[int]): - port = f"{COLOR_CYAN}{port}{RESET_FORMAT}" - line1 = f"Please select the port, {name} should be served on." - line2 = f"In case you need {name} to be served on a specific" - dialog = textwrap.dedent( - f""" - /=======================================================\\ - | {line1:<54}| - | If you are unsure what to select, hit Enter to apply | - | the suggested value of: {port:38} | - | | - | {line2:<54}| - | port, you can set it now. Make sure the port is not | - | used by any other application on your system! | - """ - )[1:] - - if len(ports_in_use) > 0: - dialog += "|-------------------------------------------------------|\n" - dialog += "| The following ports were found to be in use already: |\n" - for port in ports_in_use: - port = f"{COLOR_CYAN}● {port}{RESET_FORMAT}" - dialog += f"| {port:60} |\n" - - dialog += "\\=======================================================/\n" - - print(dialog, end="") + Logger.print_dialog( + DialogType.CUSTOM, + [ + f"Please select the port, {name} should be served on. If your are unsure " + f"what to select, hit Enter to apply the suggested value of: {port}", + "\n\n", + f"In case you need {name} to be served on a specific port, you can set it " + f"now. Make sure that the port is not already used by another application " + f"on your system!", + "\n\n", + "The following ports were found to be in use already:", + *[f"● {port}" for port in ports_in_use], + ], + padding_top=0, + padding_bottom=0, + ) def print_install_client_config_dialog(client: BaseWebClient) -> None: @@ -100,6 +75,8 @@ def print_install_client_config_dialog(client: BaseWebClient) -> None: "If you already use these macros skip this step. Otherwise you should " "consider to answer with 'Y' to download the recommended macros.", ], + padding_top=0, + padding_bottom=0, ) diff --git a/kiauh/components/webui_client/client_setup.py b/kiauh/components/webui_client/client_setup.py index b1eda56..ec38cd9 100644 --- a/kiauh/components/webui_client/client_setup.py +++ b/kiauh/components/webui_client/client_setup.py @@ -73,10 +73,7 @@ def install_client(client: BaseWebClient) -> None: enable_remotemode = False if not mr_instances: print_moonraker_not_found_dialog() - if not get_confirm( - f"Continue {client.display_name} installation?", - allow_go_back=True, - ): + if not get_confirm(f"Continue {client.display_name} installation?"): return # if moonraker is not installed or multiple instances