added new text buttons to show total hashrate and current sort key
This commit is contained in:
@@ -14,7 +14,7 @@ TABLE_HEADERS = {
|
||||
"Pool User",
|
||||
"Wattage",
|
||||
],
|
||||
"CMD": ["IP", "Model", "Command Output"],
|
||||
"CMD": ["IP", "Model", "Output"],
|
||||
"POOLS_ALL": [
|
||||
"IP",
|
||||
"Split",
|
||||
@@ -48,6 +48,19 @@ MINER_COUNT_BUTTONS = [
|
||||
"pools_miner_count",
|
||||
]
|
||||
|
||||
SORT_KEY_BUTTONS = [
|
||||
"scan_sort_key",
|
||||
"cmd_sort_key",
|
||||
"cfg_sort_key",
|
||||
"pools_sort_key",
|
||||
]
|
||||
|
||||
HASHRATE_TOTAL_BUTTONS = [
|
||||
"scan_total_hashrate",
|
||||
"cfg_total_hashrate",
|
||||
"pools_total_hashrate",
|
||||
]
|
||||
|
||||
BUTTON_KEYS = [
|
||||
"btn_scan",
|
||||
"btn_cmd",
|
||||
@@ -114,6 +127,20 @@ def get_scan_layout():
|
||||
sg.InputText(key="scan_ip", size=(31, 1)),
|
||||
sg.Button("Scan", key="btn_scan"),
|
||||
sg.Push(),
|
||||
sg.Button(
|
||||
"Sort: IP",
|
||||
disabled=True,
|
||||
button_color=("black", "white smoke"),
|
||||
disabled_button_color=("black", "white smoke"),
|
||||
key="scan_sort_key",
|
||||
),
|
||||
sg.Button(
|
||||
"Hashrate: 0 TH/s",
|
||||
disabled=True,
|
||||
button_color=("black", "white smoke"),
|
||||
disabled_button_color=("black", "white smoke"),
|
||||
key="scan_total_hashrate",
|
||||
),
|
||||
sg.Button(
|
||||
"Miners: 0",
|
||||
disabled=True,
|
||||
@@ -161,6 +188,13 @@ def get_command_layout():
|
||||
sg.InputText(key="cmd_txt", expand_x=True),
|
||||
sg.Button("Send Command", key="btn_cmd"),
|
||||
sg.Push(),
|
||||
sg.Button(
|
||||
"Sort: IP",
|
||||
disabled=True,
|
||||
button_color=("black", "white smoke"),
|
||||
disabled_button_color=("black", "white smoke"),
|
||||
key="cmd_sort_key",
|
||||
),
|
||||
sg.Button(
|
||||
"Miners: 0",
|
||||
disabled=True,
|
||||
@@ -211,6 +245,20 @@ def get_pools_layout():
|
||||
sg.Button("REFRESH DATA", key="pools_refresh"),
|
||||
sg.Button("OPEN IN WEB", key="pools_web"),
|
||||
sg.Push(),
|
||||
sg.Button(
|
||||
"Sort: IP",
|
||||
disabled=True,
|
||||
button_color=("black", "white smoke"),
|
||||
disabled_button_color=("black", "white smoke"),
|
||||
key="pools_sort_key",
|
||||
),
|
||||
sg.Button(
|
||||
"Hashrate: 0 TH/s",
|
||||
disabled=True,
|
||||
button_color=("black", "white smoke"),
|
||||
disabled_button_color=("black", "white smoke"),
|
||||
key="pools_total_hashrate",
|
||||
),
|
||||
sg.Button(
|
||||
"Miners: 0",
|
||||
disabled=True,
|
||||
@@ -314,6 +362,20 @@ def get_config_layout():
|
||||
sg.Button("CONFIG", key="cfg_config"),
|
||||
sg.Button("GENERATE", key="cfg_generate"),
|
||||
sg.Push(),
|
||||
sg.Button(
|
||||
"Sort: IP",
|
||||
disabled=True,
|
||||
button_color=("black", "white smoke"),
|
||||
disabled_button_color=("black", "white smoke"),
|
||||
key="cfg_sort_key",
|
||||
),
|
||||
sg.Button(
|
||||
"Hashrate: 0 TH/s",
|
||||
disabled=True,
|
||||
button_color=("black", "white smoke"),
|
||||
disabled_button_color=("black", "white smoke"),
|
||||
key="cfg_total_hashrate",
|
||||
),
|
||||
sg.Button(
|
||||
"Miners: 0",
|
||||
disabled=True,
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
from tools.cfg_util.layout import (
|
||||
MINER_COUNT_BUTTONS,
|
||||
HASHRATE_TOTAL_BUTTONS,
|
||||
SORT_KEY_BUTTONS,
|
||||
TABLE_KEYS,
|
||||
TABLE_HEADERS,
|
||||
window,
|
||||
@@ -14,6 +16,20 @@ def update_miner_count(count):
|
||||
window[button].update(f"Miners: {count}")
|
||||
|
||||
|
||||
def update_total_hr(hashrate: float):
|
||||
if hashrate > 999:
|
||||
hashrate = f"{round(hashrate/1000, 2)} PH/s"
|
||||
else:
|
||||
hashrate = f"{round(hashrate)} TH/s"
|
||||
for button in HASHRATE_TOTAL_BUTTONS:
|
||||
window[button].update(f"Hashrate: {hashrate}")
|
||||
|
||||
|
||||
def update_sort_key_btns():
|
||||
for button in SORT_KEY_BUTTONS:
|
||||
window[button].update(f"Sort: {TableManager().sort_key}")
|
||||
|
||||
|
||||
def update_tables(data: list or None = None):
|
||||
TableManager().update_data(data)
|
||||
|
||||
@@ -22,14 +38,6 @@ def clear_tables():
|
||||
TableManager().clear_tables()
|
||||
|
||||
|
||||
async def update_tree(data: list):
|
||||
for item in data:
|
||||
if not item.get("IP"):
|
||||
continue
|
||||
table_manager = TableManager()
|
||||
table_manager.update_tree_by_key(item, "IP")
|
||||
|
||||
|
||||
class Singleton(type):
|
||||
_instances = {}
|
||||
|
||||
@@ -59,6 +67,7 @@ class TableManager(metaclass=Singleton):
|
||||
if self.sort_key == sort_key:
|
||||
self.sort_reverse = not self.sort_reverse
|
||||
self.sort_key = sort_key
|
||||
update_sort_key_btns()
|
||||
self.update_tables()
|
||||
|
||||
def update_item(self, data: dict):
|
||||
@@ -122,8 +131,20 @@ class TableManager(metaclass=Singleton):
|
||||
window["cmd_table"].update(treedata)
|
||||
|
||||
update_miner_count(len(self.data))
|
||||
total_hr = 0
|
||||
for key in self.data.keys():
|
||||
hashrate = 0
|
||||
if not self.data[key]["Hashrate"] == "":
|
||||
hashrate = (
|
||||
self.data[key]["Hashrate"].replace(" ", "").replace("TH/s", "")
|
||||
)
|
||||
total_hr += float(hashrate)
|
||||
update_total_hr(round(total_hr))
|
||||
|
||||
def _get_sort(self, data_key: str):
|
||||
if self.sort_key not in self.data[data_key]:
|
||||
return ""
|
||||
|
||||
if self.sort_key == "IP":
|
||||
return ipaddress.ip_address(self.data[data_key]["IP"])
|
||||
|
||||
|
||||
@@ -55,12 +55,11 @@ async def ui():
|
||||
sys.exit()
|
||||
|
||||
if isinstance(event, tuple):
|
||||
if len(window["scan_table"].Values) > 0:
|
||||
if event[0].endswith("_table"):
|
||||
if event[2][0] == -1:
|
||||
mgr = TableManager()
|
||||
table = window[event[0]].Widget
|
||||
mgr.update_sort_key(table.heading(event[2][1])["text"])
|
||||
if event[0].endswith("_table"):
|
||||
if event[2][0] == -1:
|
||||
mgr = TableManager()
|
||||
table = window[event[0]].Widget
|
||||
mgr.update_sort_key(table.heading(event[2][1])["text"])
|
||||
|
||||
# scan tab
|
||||
|
||||
|
||||
Reference in New Issue
Block a user