added basic framework for boards in config util
This commit is contained in:
@@ -14,6 +14,11 @@ DEFAULT_DATA = [
|
|||||||
"Hostname",
|
"Hostname",
|
||||||
"Hashrate",
|
"Hashrate",
|
||||||
"Temperature",
|
"Temperature",
|
||||||
|
"Total Chips",
|
||||||
|
"Nominal Chips",
|
||||||
|
"Left Board",
|
||||||
|
"Center Board",
|
||||||
|
"Right Board",
|
||||||
"Pool User",
|
"Pool User",
|
||||||
"Pool 1",
|
"Pool 1",
|
||||||
"Pool 1 User",
|
"Pool 1 User",
|
||||||
|
|||||||
@@ -92,6 +92,15 @@ TABLE_HEADERS = {
|
|||||||
"Pool User",
|
"Pool User",
|
||||||
"Wattage",
|
"Wattage",
|
||||||
],
|
],
|
||||||
|
"BOARDS": [
|
||||||
|
"IP",
|
||||||
|
"Model",
|
||||||
|
"Total Chips",
|
||||||
|
"Nominal Chips",
|
||||||
|
"Left Board",
|
||||||
|
"Center Board",
|
||||||
|
"Right Board",
|
||||||
|
],
|
||||||
"CMD": ["IP", "Model", "Output"],
|
"CMD": ["IP", "Model", "Output"],
|
||||||
"POOLS_ALL": [
|
"POOLS_ALL": [
|
||||||
"IP",
|
"IP",
|
||||||
@@ -117,6 +126,7 @@ TABLE_HEADERS = {
|
|||||||
TABLE_KEYS = {
|
TABLE_KEYS = {
|
||||||
"table": [
|
"table": [
|
||||||
"scan_table",
|
"scan_table",
|
||||||
|
"boards_table",
|
||||||
"pools_table",
|
"pools_table",
|
||||||
"pools_1_table",
|
"pools_1_table",
|
||||||
"pools_2_table",
|
"pools_2_table",
|
||||||
@@ -164,6 +174,8 @@ TEMP_COL_WIDTH = 8
|
|||||||
USER_COL_WIDTH = 33
|
USER_COL_WIDTH = 33
|
||||||
WATTAGE_COL_WIDTH = 10
|
WATTAGE_COL_WIDTH = 10
|
||||||
SPLIT_COL_WIDTH = 8
|
SPLIT_COL_WIDTH = 8
|
||||||
|
TOTAL_CHIP_WIDTH = 14
|
||||||
|
NOMINAL_CHIP_WIDTH = 16
|
||||||
SCAN_COL_WIDTHS = [
|
SCAN_COL_WIDTHS = [
|
||||||
IP_COL_WIDTH,
|
IP_COL_WIDTH,
|
||||||
MODEL_COL_WIDTH,
|
MODEL_COL_WIDTH,
|
||||||
@@ -260,6 +272,70 @@ def get_scan_layout():
|
|||||||
return scan_layout
|
return scan_layout
|
||||||
|
|
||||||
|
|
||||||
|
def get_boards_layout():
|
||||||
|
BOARDS_COL_WIDTHS = [
|
||||||
|
IP_COL_WIDTH,
|
||||||
|
MODEL_COL_WIDTH,
|
||||||
|
TOTAL_CHIP_WIDTH,
|
||||||
|
NOMINAL_CHIP_WIDTH,
|
||||||
|
]
|
||||||
|
add_length = TABLE_TOTAL_WIDTH - sum(BOARDS_COL_WIDTHS)
|
||||||
|
for i in range(3):
|
||||||
|
BOARDS_COL_WIDTHS.append(round(add_length / 3))
|
||||||
|
boards_layout = [
|
||||||
|
[sg.Text("", pad=((0, 0), (10, 1)))],
|
||||||
|
[
|
||||||
|
sg.Button(
|
||||||
|
"ALL",
|
||||||
|
key="boards_all",
|
||||||
|
border_width=BTN_BORDER,
|
||||||
|
disabled_button_color=BTN_DISABLED,
|
||||||
|
pad=((0, 5), (1, 1)),
|
||||||
|
),
|
||||||
|
sg.Button(
|
||||||
|
"REFRESH DATA",
|
||||||
|
key="boards_refresh",
|
||||||
|
border_width=BTN_BORDER,
|
||||||
|
disabled_button_color=BTN_DISABLED,
|
||||||
|
),
|
||||||
|
sg.Button(
|
||||||
|
"OPEN IN WEB",
|
||||||
|
key="boards_web",
|
||||||
|
border_width=BTN_BORDER,
|
||||||
|
disabled_button_color=BTN_DISABLED,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
[
|
||||||
|
sg.Table(
|
||||||
|
values=[],
|
||||||
|
headings=[heading for heading in TABLE_HEADERS["BOARDS"]],
|
||||||
|
auto_size_columns=False,
|
||||||
|
max_col_width=15,
|
||||||
|
justification="center",
|
||||||
|
key="boards_table",
|
||||||
|
col_widths=BOARDS_COL_WIDTHS,
|
||||||
|
background_color=TABLE_BG,
|
||||||
|
text_color=TABLE_TEXT,
|
||||||
|
header_background_color=TABLE_HEADERS_COLOR,
|
||||||
|
header_text_color=TABLE_HEADERS_TEXT_COLOR,
|
||||||
|
border_width=TABLE_BORDER,
|
||||||
|
header_border_width=TABLE_HEADER_BORDER,
|
||||||
|
sbar_trough_color=SCROLLBAR_TROUGH_COLOR,
|
||||||
|
sbar_background_color=SCROLLBAR_BACKGROUND_COLOR,
|
||||||
|
sbar_arrow_color=SCROLLBAR_ARROW_COLOR,
|
||||||
|
sbar_width=SCROLLBAR_WIDTH,
|
||||||
|
sbar_arrow_width=SCROLLBAR_ARROW_WIDTH,
|
||||||
|
sbar_relief=SCROLLBAR_RELIEF,
|
||||||
|
size=(TABLE_TOTAL_WIDTH, TABLE_HEIGHT),
|
||||||
|
expand_x=True,
|
||||||
|
enable_click_events=True,
|
||||||
|
pad=TABLE_PAD,
|
||||||
|
)
|
||||||
|
],
|
||||||
|
]
|
||||||
|
return boards_layout
|
||||||
|
|
||||||
|
|
||||||
def get_command_layout():
|
def get_command_layout():
|
||||||
data = sg.TreeData()
|
data = sg.TreeData()
|
||||||
col_widths = [
|
col_widths = [
|
||||||
@@ -634,6 +710,14 @@ layout = [
|
|||||||
pad=TAB_PAD,
|
pad=TAB_PAD,
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
|
[
|
||||||
|
sg.Tab(
|
||||||
|
"Boards",
|
||||||
|
get_boards_layout(),
|
||||||
|
background_color=MAIN_TABS_BG,
|
||||||
|
pad=TAB_PAD,
|
||||||
|
)
|
||||||
|
],
|
||||||
[
|
[
|
||||||
sg.Tab(
|
sg.Tab(
|
||||||
"Pools",
|
"Pools",
|
||||||
|
|||||||
@@ -84,6 +84,7 @@ 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],
|
||||||
|
"BOARDS": [["" for _ in TABLE_HEADERS["BOARDS"]] for _ in self.data],
|
||||||
"POOLS_ALL": [["" for _ in TABLE_HEADERS["POOLS_ALL"]] 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_1": [["" for _ in TABLE_HEADERS["POOLS_1"]] for _ in self.data],
|
||||||
"POOLS_2": [["" for _ in TABLE_HEADERS["POOLS_2"]] for _ in self.data],
|
"POOLS_2": [["" for _ in TABLE_HEADERS["POOLS_2"]] for _ in self.data],
|
||||||
@@ -97,6 +98,7 @@ class TableManager(metaclass=Singleton):
|
|||||||
|
|
||||||
table_names = {
|
table_names = {
|
||||||
"SCAN": "scan_table",
|
"SCAN": "scan_table",
|
||||||
|
"BOARDS": "boards_table",
|
||||||
"POOLS_ALL": "pools_table",
|
"POOLS_ALL": "pools_table",
|
||||||
"POOLS_1": "pools_1_table",
|
"POOLS_1": "pools_1_table",
|
||||||
"POOLS_2": "pools_2_table",
|
"POOLS_2": "pools_2_table",
|
||||||
@@ -144,6 +146,7 @@ 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["boards_table"].update(tables["BOARDS"])
|
||||||
window["pools_table"].update(tables["POOLS_ALL"])
|
window["pools_table"].update(tables["POOLS_ALL"])
|
||||||
window["pools_1_table"].update(tables["POOLS_1"])
|
window["pools_1_table"].update(tables["POOLS_1"])
|
||||||
window["pools_2_table"].update(tables["POOLS_2"])
|
window["pools_2_table"].update(tables["POOLS_2"])
|
||||||
|
|||||||
@@ -110,7 +110,6 @@ async def ui():
|
|||||||
mgr.update_sort_key(table.heading(event[2][1])["text"])
|
mgr.update_sort_key(table.heading(event[2][1])["text"])
|
||||||
|
|
||||||
# scan tab
|
# scan tab
|
||||||
|
|
||||||
if event == "scan_all":
|
if event == "scan_all":
|
||||||
_table = "scan_table"
|
_table = "scan_table"
|
||||||
btn_all(_table, value[_table])
|
btn_all(_table, value[_table])
|
||||||
@@ -123,6 +122,17 @@ async def ui():
|
|||||||
if event == "btn_scan":
|
if event == "btn_scan":
|
||||||
asyncio.create_task(btn_scan(value["scan_ip"]))
|
asyncio.create_task(btn_scan(value["scan_ip"]))
|
||||||
|
|
||||||
|
# boards tab
|
||||||
|
if event == "boards_all":
|
||||||
|
_table = "boards_table"
|
||||||
|
btn_all(_table, value[_table])
|
||||||
|
if event == "boards_web":
|
||||||
|
_table = "boards_table"
|
||||||
|
btn_web(_table, value[_table])
|
||||||
|
if event == "boards_refresh":
|
||||||
|
_table = "boards_table"
|
||||||
|
asyncio.create_task(btn_refresh(_table, value[_table]))
|
||||||
|
|
||||||
# pools tab
|
# pools tab
|
||||||
if event == "pools_all":
|
if event == "pools_all":
|
||||||
_table = "pools_table"
|
_table = "pools_table"
|
||||||
|
|||||||
Reference in New Issue
Block a user