mirror of
https://github.com/dw-0/kiauh.git
synced 2025-12-25 00:33:37 +05:00
refactor: client dialog improvements
Signed-off-by: Dominik Willner <th33xitus@gmail.com>
This commit is contained in:
@@ -7,82 +7,57 @@
|
|||||||
# This file may be distributed under the terms of the GNU GPLv3 license #
|
# This file may be distributed under the terms of the GNU GPLv3 license #
|
||||||
# ======================================================================= #
|
# ======================================================================= #
|
||||||
|
|
||||||
import textwrap
|
|
||||||
from typing import List
|
from typing import List
|
||||||
|
|
||||||
from components.webui_client.base_data import BaseWebClient
|
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
|
from utils.logger import DialogType, Logger
|
||||||
|
|
||||||
|
|
||||||
def print_moonraker_not_found_dialog():
|
def print_moonraker_not_found_dialog():
|
||||||
line1 = f"{COLOR_YELLOW}WARNING:{RESET_FORMAT}"
|
Logger.print_dialog(
|
||||||
line2 = f"{COLOR_YELLOW}No local Moonraker installation was found!{RESET_FORMAT}"
|
DialogType.WARNING,
|
||||||
dialog = textwrap.dedent(
|
[
|
||||||
f"""
|
"No local Moonraker installation was found!",
|
||||||
/=======================================================\\
|
"\n\n",
|
||||||
| {line1:<63}|
|
"It is possible to install Mainsail without a local Moonraker installation. "
|
||||||
| {line2:<63}|
|
"If you continue, you need to make sure, that Moonraker is installed on "
|
||||||
|-------------------------------------------------------|
|
"another machine in your network. Otherwise Mainsail will NOT work "
|
||||||
| It is possible to install Mainsail without a local |
|
"correctly.",
|
||||||
| Moonraker installation. If you continue, you need to |
|
],
|
||||||
| make sure, that Moonraker is installed on another |
|
padding_top=0,
|
||||||
| machine in your network. Otherwise Mainsail will NOT |
|
padding_bottom=0,
|
||||||
| work correctly. |
|
)
|
||||||
"""
|
|
||||||
)[1:]
|
|
||||||
|
|
||||||
print(dialog, end="")
|
|
||||||
print_back_footer()
|
|
||||||
|
|
||||||
|
|
||||||
def print_client_already_installed_dialog(name: str):
|
def print_client_already_installed_dialog(name: str):
|
||||||
line1 = f"{COLOR_YELLOW}WARNING:{RESET_FORMAT}"
|
Logger.print_dialog(
|
||||||
line2 = f"{COLOR_YELLOW}{name} seems to be already installed!{RESET_FORMAT}"
|
DialogType.WARNING,
|
||||||
line3 = f"If you continue, your current {name}"
|
[
|
||||||
dialog = textwrap.dedent(
|
f"{name} seems to be already installed!",
|
||||||
f"""
|
f"If you continue, your current {name} installation will be overwritten.",
|
||||||
/=======================================================\\
|
],
|
||||||
| {line1:<63}|
|
padding_top=0,
|
||||||
| {line2:<63}|
|
padding_bottom=0,
|
||||||
|-------------------------------------------------------|
|
)
|
||||||
| {line3:<54}|
|
|
||||||
| installation will be overwritten. |
|
|
||||||
"""
|
|
||||||
)[1:]
|
|
||||||
|
|
||||||
print(dialog, end="")
|
|
||||||
print_back_footer()
|
|
||||||
|
|
||||||
|
|
||||||
def print_client_port_select_dialog(name: str, port: int, ports_in_use: List[int]):
|
def print_client_port_select_dialog(name: str, port: int, ports_in_use: List[int]):
|
||||||
port = f"{COLOR_CYAN}{port}{RESET_FORMAT}"
|
Logger.print_dialog(
|
||||||
line1 = f"Please select the port, {name} should be served on."
|
DialogType.CUSTOM,
|
||||||
line2 = f"In case you need {name} to be served on a specific"
|
[
|
||||||
dialog = textwrap.dedent(
|
f"Please select the port, {name} should be served on. If your are unsure "
|
||||||
f"""
|
f"what to select, hit Enter to apply the suggested value of: {port}",
|
||||||
/=======================================================\\
|
"\n\n",
|
||||||
| {line1:<54}|
|
f"In case you need {name} to be served on a specific port, you can set it "
|
||||||
| If you are unsure what to select, hit Enter to apply |
|
f"now. Make sure that the port is not already used by another application "
|
||||||
| the suggested value of: {port:38} |
|
f"on your system!",
|
||||||
| |
|
"\n\n",
|
||||||
| {line2:<54}|
|
"The following ports were found to be in use already:",
|
||||||
| port, you can set it now. Make sure the port is not |
|
*[f"● {port}" for port in ports_in_use],
|
||||||
| used by any other application on your system! |
|
],
|
||||||
"""
|
padding_top=0,
|
||||||
)[1:]
|
padding_bottom=0,
|
||||||
|
)
|
||||||
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="")
|
|
||||||
|
|
||||||
|
|
||||||
def print_install_client_config_dialog(client: BaseWebClient) -> None:
|
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 "
|
"If you already use these macros skip this step. Otherwise you should "
|
||||||
"consider to answer with 'Y' to download the recommended macros.",
|
"consider to answer with 'Y' to download the recommended macros.",
|
||||||
],
|
],
|
||||||
|
padding_top=0,
|
||||||
|
padding_bottom=0,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -73,10 +73,7 @@ def install_client(client: BaseWebClient) -> None:
|
|||||||
enable_remotemode = False
|
enable_remotemode = False
|
||||||
if not mr_instances:
|
if not mr_instances:
|
||||||
print_moonraker_not_found_dialog()
|
print_moonraker_not_found_dialog()
|
||||||
if not get_confirm(
|
if not get_confirm(f"Continue {client.display_name} installation?"):
|
||||||
f"Continue {client.display_name} installation?",
|
|
||||||
allow_go_back=True,
|
|
||||||
):
|
|
||||||
return
|
return
|
||||||
|
|
||||||
# if moonraker is not installed or multiple instances
|
# if moonraker is not installed or multiple instances
|
||||||
|
|||||||
Reference in New Issue
Block a user