fixed some bugs with sorting

This commit is contained in:
UpstreamData
2022-05-09 09:59:48 -06:00
parent ef336a9e23
commit 1f8d92f6bb
7 changed files with 126 additions and 36 deletions

View File

@@ -98,7 +98,7 @@ class BaseMiner:
"Temperature": 0, "Temperature": 0,
"Pool User": "Unknown", "Pool User": "Unknown",
"Wattage": 0, "Wattage": 0,
"Split": 0, "Split": "0",
"Pool 1": "Unknown", "Pool 1": "Unknown",
"Pool 1 User": "Unknown", "Pool 1 User": "Unknown",
"Pool 2": "", "Pool 2": "",

View File

@@ -226,6 +226,6 @@ class BMMiner(BaseMiner):
data["Pool 2 User"] = pool_2_user data["Pool 2 User"] = pool_2_user
if quota: if quota:
data["Split"] = quota data["Split"] = str(quota)
return data return data

View File

@@ -249,7 +249,7 @@ class BOSMiner(BaseMiner):
"Temperature": 0, "Temperature": 0,
"Pool User": "Unknown", "Pool User": "Unknown",
"Wattage": 0, "Wattage": 0,
"Split": 0, "Split": "0",
"Pool 1": "Unknown", "Pool 1": "Unknown",
"Pool 1 User": "Unknown", "Pool 1 User": "Unknown",
"Pool 2": "", "Pool 2": "",
@@ -337,7 +337,7 @@ class BOSMiner(BaseMiner):
data["Pool 2 User"] = pool_2_user data["Pool 2 User"] = pool_2_user
if quota: if quota:
data["Split"] = quota data["Split"] = str(quota)
if tunerstatus: if tunerstatus:
tuner = tunerstatus.get("TUNERSTATUS") tuner = tunerstatus.get("TUNERSTATUS")

View File

@@ -180,6 +180,6 @@ class BTMiner(BaseMiner):
data["Pool 2 User"] = pool_2_user data["Pool 2 User"] = pool_2_user
if quota: if quota:
data["Split"] = quota data["Split"] = str(quota)
return data return data

View File

@@ -205,6 +205,6 @@ class CGMiner(BaseMiner):
data["Pool 2 User"] = pool_2_user data["Pool 2 User"] = pool_2_user
if quota: if quota:
data["Split"] = quota data["Split"] = str(quota)
return data return data

View File

@@ -15,11 +15,21 @@ TABLE_HEADERS = {
"Wattage", "Wattage",
], ],
"CMD": ["IP", "Model", "Command Output"], "CMD": ["IP", "Model", "Command Output"],
"POOLS": [ "POOLS_ALL": [
"IP",
"Split",
"Pool 1 User",
"Pool 2 User",
],
"POOLS_1": [
"IP", "IP",
"Split", "Split",
"Pool 1", "Pool 1",
"Pool 1 User", "Pool 1 User",
],
"POOLS_2": [
"IP",
"Split",
"Pool 2", "Pool 2",
"Pool 2 User", "Pool 2 User",
], ],
@@ -188,17 +198,18 @@ def get_command_layout():
def get_pools_layout(): def get_pools_layout():
pool_col_width = int((TABLE_TOTAL_WIDTH - (IP_COL_WIDTH + SPLIT_COL_WIDTH)) / 4) pool_col_width = int((TABLE_TOTAL_WIDTH - (IP_COL_WIDTH + SPLIT_COL_WIDTH)) / 2)
col_widths = [ col_widths = [
IP_COL_WIDTH, IP_COL_WIDTH,
SPLIT_COL_WIDTH, SPLIT_COL_WIDTH,
pool_col_width + 5, pool_col_width,
pool_col_width - 5, pool_col_width,
pool_col_width + 5,
pool_col_width - 5,
] ]
pools_layout = [ pools_layout = [
[ [
sg.Button("ALL", key="pools_all"),
sg.Button("REFRESH DATA", key="pools_refresh"),
sg.Button("OPEN IN WEB", key="pools_web"),
sg.Push(), sg.Push(),
sg.Button( sg.Button(
"Miners: 0", "Miners: 0",
@@ -209,24 +220,87 @@ def get_pools_layout():
), ),
], ],
[ [
sg.Button("ALL", key="pools_all"), sg.TabGroup(
sg.Button("REFRESH DATA", key="pools_refresh"), [
sg.Button("OPEN IN WEB", key="pools_web"), [
], sg.Tab(
[ "All",
sg.Table( [
values=[], [
headings=[heading for heading in TABLE_HEADERS["POOLS"]], sg.Table(
auto_size_columns=False, values=[],
max_col_width=15, headings=[
justification="center", heading
key="pools_table", for heading in TABLE_HEADERS["POOLS_ALL"]
background_color="white", ],
text_color="black", auto_size_columns=False,
col_widths=col_widths, max_col_width=15,
size=(0, TABLE_HEIGHT), justification="center",
expand_x=True, key="pools_table",
enable_click_events=True, background_color="white",
text_color="black",
col_widths=col_widths,
size=(0, TABLE_HEIGHT),
expand_x=True,
enable_click_events=True,
)
]
],
)
],
[
sg.Tab(
"Pool 1",
[
[
sg.Table(
values=[],
headings=[
heading
for heading in TABLE_HEADERS["POOLS_1"]
],
auto_size_columns=False,
max_col_width=15,
justification="center",
key="pools_1_table",
background_color="white",
text_color="black",
col_widths=col_widths,
size=(0, TABLE_HEIGHT),
expand_x=True,
enable_click_events=True,
)
]
],
)
],
[
sg.Tab(
"Pool 2",
[
[
sg.Table(
values=[],
headings=[
heading
for heading in TABLE_HEADERS["POOLS_2"]
],
auto_size_columns=False,
max_col_width=15,
justification="center",
key="pools_2_table",
background_color="white",
text_color="black",
col_widths=col_widths,
size=(0, TABLE_HEIGHT),
expand_x=True,
enable_click_events=True,
)
]
],
)
],
]
) )
], ],
] ]

View File

@@ -80,7 +80,9 @@ class TableManager(metaclass=Singleton):
tables = { tables = {
"SCAN": [["" for _ in TABLE_HEADERS["SCAN"]] for _ in self.data], "SCAN": [["" for _ in TABLE_HEADERS["SCAN"]] for _ in self.data],
"CMD": [["" for _ in TABLE_HEADERS["CMD"]] for _ in self.data], "CMD": [["" for _ in TABLE_HEADERS["CMD"]] for _ in self.data],
"POOLS": [["" for _ in TABLE_HEADERS["POOLS"]] for _ in self.data], "POOLS_ALL": [["" for _ in TABLE_HEADERS["POOLS_ALL"]] for _ in self.data],
"POOLS_1": [["" for _ in TABLE_HEADERS["POOLS_1"]] for _ in self.data],
"POOLS_2": [["" for _ in TABLE_HEADERS["POOLS_2"]] for _ in self.data],
"CONFIG": [["" for _ in TABLE_HEADERS["CONFIG"]] for _ in self.data], "CONFIG": [["" for _ in TABLE_HEADERS["CONFIG"]] for _ in self.data],
} }
@@ -105,7 +107,9 @@ class TableManager(metaclass=Singleton):
tables[table][data_idx][idx] = item[key] tables[table][data_idx][idx] = item[key]
window["scan_table"].update(tables["SCAN"]) window["scan_table"].update(tables["SCAN"])
window["pools_table"].update(tables["POOLS"]) window["pools_table"].update(tables["POOLS_ALL"])
window["pools_1_table"].update(tables["POOLS_1"])
window["pools_2_table"].update(tables["POOLS_2"])
window["cfg_table"].update(tables["CONFIG"]) window["cfg_table"].update(tables["CONFIG"])
treedata = sg.TreeData() treedata = sg.TreeData()
@@ -124,16 +128,28 @@ class TableManager(metaclass=Singleton):
return ipaddress.ip_address(self.data[data_key]["IP"]) return ipaddress.ip_address(self.data[data_key]["IP"])
if self.sort_key == "Hashrate": if self.sort_key == "Hashrate":
if self.data[data_key]["Hashrate"] == "":
return -1
if not isinstance(self.data[data_key]["Hashrate"], str):
return self.data[data_key]["Hashrate"]
return float( return float(
self.data[data_key]["Hashrate"].replace(" ", "").replace("TH/s", "") self.data[data_key]["Hashrate"].replace(" ", "").replace("TH/s", "")
) )
if self.sort_key in ["Wattage", "Temperature"]: if self.sort_key in ["Wattage", "Temperature"]:
if isinstance(self.data[data_key][self.sort_key], str): if isinstance(self.data[data_key][self.sort_key], str):
if self.sort_reverse: return -300
return -100000000 # large negative number to place it at the bottom
else: if self.sort_key == "Split":
return 1000000000 # large number to place it at the bottom if self.data[data_key][self.sort_key] == "":
return -1
if "/" not in self.data[data_key][self.sort_key]:
return 0
if not self.sort_reverse:
return int(self.data[data_key][self.sort_key].split("/")[0])
else:
return int(self.data[data_key][self.sort_key].split("/")[1])
return self.data[data_key][self.sort_key] return self.data[data_key][self.sort_key]