added indicators of what function is running
This commit is contained in:
@@ -4,7 +4,7 @@ from tools.cfg_util.cfg_util_qt.tables import TableManager
|
||||
from tools.cfg_util.cfg_util_qt.decorators import disable_buttons
|
||||
|
||||
|
||||
@disable_buttons
|
||||
@disable_buttons("Flashing Lights")
|
||||
async def btn_light(ip_idxs: list):
|
||||
table_manager = TableManager()
|
||||
_table = window["cmd_table"].Widget
|
||||
@@ -26,7 +26,7 @@ async def btn_light(ip_idxs: list):
|
||||
table_manager.update_tables()
|
||||
|
||||
|
||||
@disable_buttons
|
||||
@disable_buttons("Rebooting")
|
||||
async def btn_reboot(ip_idxs: list):
|
||||
table_manager = TableManager()
|
||||
_table = window["cmd_table"].Widget
|
||||
@@ -43,7 +43,7 @@ async def btn_reboot(ip_idxs: list):
|
||||
table_manager.update_tables()
|
||||
|
||||
|
||||
@disable_buttons
|
||||
@disable_buttons("Restarting Backend")
|
||||
async def btn_backend(ip_idxs: list):
|
||||
table_manager = TableManager()
|
||||
_table = window["cmd_table"].Widget
|
||||
@@ -62,7 +62,7 @@ async def btn_backend(ip_idxs: list):
|
||||
table_manager.update_tables()
|
||||
|
||||
|
||||
@disable_buttons
|
||||
@disable_buttons("Sending Command")
|
||||
async def btn_command(ip_idxs: list, command: str):
|
||||
table_manager = TableManager()
|
||||
_table = window["cmd_table"].Widget
|
||||
|
||||
@@ -12,7 +12,7 @@ from tools.cfg_util.cfg_util_qt.general import update_miners_data
|
||||
progress_bar_len = 0
|
||||
|
||||
|
||||
@disable_buttons
|
||||
@disable_buttons("Importing")
|
||||
async def btn_import(table, selected):
|
||||
if not len(selected) > 0:
|
||||
return
|
||||
@@ -23,7 +23,7 @@ async def btn_import(table, selected):
|
||||
window["cfg_config_txt"].update(config)
|
||||
|
||||
|
||||
@disable_buttons
|
||||
@disable_buttons("Configuring")
|
||||
async def btn_config(table, selected, config: str, last_oct_ip: bool):
|
||||
ips = [window[table].Values[row][0] for row in selected]
|
||||
await send_config(ips, config, last_oct_ip)
|
||||
|
||||
@@ -2,18 +2,23 @@ from tools.cfg_util.cfg_util_qt.layout import window
|
||||
from tools.cfg_util.cfg_util_qt.layout import BUTTON_KEYS
|
||||
|
||||
|
||||
def disable_buttons(func):
|
||||
# handle the inner function that the decorator is wrapping
|
||||
async def inner(*args, **kwargs):
|
||||
# disable the buttons
|
||||
for button in BUTTON_KEYS:
|
||||
window[button].Update(disabled=True)
|
||||
def disable_buttons(status: str = ""):
|
||||
def decorator(func):
|
||||
# handle the inner function that the decorator is wrapping
|
||||
async def inner(*args, **kwargs):
|
||||
# disable the buttons
|
||||
for button in BUTTON_KEYS:
|
||||
window[button].Update(disabled=True)
|
||||
window["status"].update(status)
|
||||
|
||||
# call the original wrapped function
|
||||
await func(*args, **kwargs)
|
||||
# call the original wrapped function
|
||||
await func(*args, **kwargs)
|
||||
|
||||
# re-enable the buttons after the wrapped function completes
|
||||
for button in BUTTON_KEYS:
|
||||
window[button].Update(disabled=False)
|
||||
# re-enable the buttons after the wrapped function completes
|
||||
for button in BUTTON_KEYS:
|
||||
window[button].Update(disabled=False)
|
||||
window["status"].update("")
|
||||
|
||||
return inner
|
||||
return inner
|
||||
|
||||
return decorator
|
||||
|
||||
@@ -48,7 +48,7 @@ def btn_web(table, selected):
|
||||
webbrowser.open("http://" + window[table].Values[row][0])
|
||||
|
||||
|
||||
@disable_buttons
|
||||
@disable_buttons("Refreshing")
|
||||
async def btn_refresh(table, selected):
|
||||
ips = [window[table].Values[row][0] for row in selected]
|
||||
if not len(selected) > 0:
|
||||
|
||||
@@ -279,11 +279,11 @@ def get_config_layout():
|
||||
|
||||
layout = [
|
||||
[
|
||||
sg.Text("", size=(10, 1), key="status"),
|
||||
sg.Text("", size=(20, 1), key="status"),
|
||||
sg.ProgressBar(
|
||||
max_value=100, size_px=(0, 20), expand_x=True, key="progress_bar"
|
||||
),
|
||||
sg.Text("", size=(10, 1), key="progress_percent"),
|
||||
sg.Text("", size=(20, 1), key="progress_percent", justification="r"),
|
||||
],
|
||||
[
|
||||
sg.TabGroup(
|
||||
|
||||
@@ -41,7 +41,7 @@ async def btn_scan(scan_ip: str):
|
||||
asyncio.create_task(_scan_miners(network))
|
||||
|
||||
|
||||
@disable_buttons
|
||||
@disable_buttons("Scanning")
|
||||
async def _scan_miners(network: MinerNetwork):
|
||||
clear_tables()
|
||||
scan_generator = network.scan_network_generator()
|
||||
|
||||
Reference in New Issue
Block a user