Skip to content

Commit

Permalink
refactor: fix css rules for table
Browse files Browse the repository at this point in the history
  • Loading branch information
datawhores committed Dec 30, 2024
1 parent bd0601d commit 4b7b080
Show file tree
Hide file tree
Showing 3 changed files with 118 additions and 108 deletions.
7 changes: 4 additions & 3 deletions ofscraper/classes/table/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,13 @@ def __call__(self, *args, **kwargs):
self.run()

def compose(self):
return composer(read_args.retriveArgs())
try:
return composer()
except Exception as e:
pass

def on_ready(self) -> None:
self.init_table()
self.query_one("#options_sidebar").toggle_class("-hidden")
self.query_one("#page_option_sidebar").toggle_class("-hidden")
logger.add_widget(self.query_one("#console_page").query_one(OutConsole))


Expand Down
137 changes: 68 additions & 69 deletions ofscraper/classes/table/compose.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from textual.containers import Container, Horizontal, Vertical
from textual.containers import Container, Horizontal, Vertical,HorizontalGroup,VerticalGroup
from textual.widgets import Button, ContentSwitcher, Rule,Static

from ofscraper.classes.table.fields.datefield import DateField
Expand All @@ -16,81 +16,80 @@
from ofscraper.classes.table.const import AMOUNT_PER_PAGE,START_PAGE


def composer(args):
def composer():
with Horizontal(id="buttons"):
yield Button("DataTable", id="table")
yield Button("Console", id="console")

with ContentSwitcher(initial="table_page"):
with Vertical(id="table_page"):
with Horizontal():
with Vertical(classes="table_info"):
yield Static("[bold blue]Toggle Sidebar for search[/bold blue]: Ctrl+S",markup=True)
yield Static("[bold blue]Toggle Page Selection[/bold blue]: Ctrl+T",markup=True)
yield Rule( orientation="vertical")
with Vertical(classes="table_info"):
yield Static("[bold blue]Navigate Table[/bold blue]: Arrows",markup=True)
yield Static('[bold blue]Filter Table via Cell[/bold blue]: ; or \'',markup=True)
yield Static("[bold blue]Add to Cart[/bold blue]: Click cell in \'download cart\' Column",markup=True)
with VerticalGroup(id="table_page"):
with Container(id="table_header"):
with Horizontal():
with Vertical(classes="table_info"):
yield Static("[bold blue]Toggle Sidebar for search[/bold blue]: Ctrl+S",markup=True)
yield Static("[bold blue]Toggle Page Selection[/bold blue]: Ctrl+T",markup=True)
yield Rule( orientation="vertical")
with Vertical(classes="table_info"):
yield Static("[bold blue]Navigate Table[/bold blue]: Arrows",markup=True)
yield Static('[bold blue]Filter Table via Cell[/bold blue]: ; or \'',markup=True)
yield Static("[bold blue]Add to Cart[/bold blue]: Click cell in \'download cart\' Column",markup=True)
yield Rule()
for _ in range(3):
yield Static("",classes="search_info",shrink=True,markup=True)
yield Rule()
for _ in range(3):
yield Static("",classes="search_info",shrink=True,markup=True)
yield Rule()
with Horizontal(id="data"):
yield Button("Reset", id="reset")
yield Button(
">> Send Downloads to OF-Scraper", id="send_downloads"
)


with Container(id="table_main"):
with Sidebar(id="page_option_sidebar"):
yield Button("Enter", id="page_enter")
for ele in ["Page"]:
yield PostiveNumField(ele, default=START_PAGE)
for ele in ["Num_Per_Page"]:
yield PostiveNumField(ele, default=AMOUNT_PER_PAGE)
yield Button("Enter", id="page_enter2")

with Sidebar(id="options_sidebar"):
with Container(id="main_options"):
yield Button("Filter", id="filter")
yield Rule()
for ele in ["Text"]:
yield TextSearch(ele)
yield Rule()

for ele in ["Media_ID"]:
yield NumField(ele, default=args.media_id)
for ele in ["Post_ID"]:
yield NumField(ele, default=args.post_id)
yield Rule()
for ele in ["Post_Media_Count"]:
yield NumField(ele)
yield Rule()
for ele in ["Price"]:
yield PriceField(ele)
yield Rule()
for ele in ["Post_Date"]:
yield DateField(ele)
yield Rule()
for ele in ["Length"]:
yield TimeField(ele)
yield Rule()
yield SelectField("Downloaded")
yield SelectField("Unlocked")
yield Rule()
for ele in ["Mediatype"]:
yield MediaField(ele)
for ele in ["Responsetype"]:
yield ResponseField(ele)
yield Rule()
for ele in ["username"]:
yield StrInput(id=ele)
yield Rule()
yield Button("Filter", id="filter2")
with HorizontalGroup(id="data"):
yield Button("Reset", id="reset")
yield Button(
">> Send Downloads to OF-Scraper", id="send_downloads"
)
with VerticalGroup(id="table_main"):
yield DataTable(id="data_table")
yield DataTable(id="data_table_hidden")

with Sidebar(id="page_option_sidebar",classes="-hidden"):
yield Button("Enter", id="page_enter")
for ele in ["Page"]:
yield PostiveNumField(ele, default=START_PAGE)
for ele in ["Num_Per_Page"]:
yield PostiveNumField(ele, default=AMOUNT_PER_PAGE)
yield Button("Enter", id="page_enter2")

with Sidebar(id="options_sidebar",classes="-hidden"):
with Container(id="main_options"):
yield Button("Filter", id="filter")
yield Rule()
for ele in ["Text"]:
yield TextSearch(ele)
yield Rule()

for ele in ["Media_ID"]:
yield NumField(ele)
for ele in ["Post_ID"]:
yield NumField(ele)
yield Rule()
for ele in ["Post_Media_Count"]:
yield NumField(ele)
yield Rule()
for ele in ["Price"]:
yield PriceField(ele)
yield Rule()
for ele in ["Post_Date"]:
yield DateField(ele)
yield Rule()
for ele in ["Length"]:
yield TimeField(ele)
yield Rule()
yield SelectField("Downloaded")
yield SelectField("Unlocked")
yield Rule()
for ele in ["Mediatype"]:
yield MediaField(ele)
for ele in ["Responsetype"]:
yield ResponseField(ele)
yield Rule()
for ele in ["username"]:
yield StrInput(id=ele)
yield Rule()
yield Button("Filter", id="filter2")
with Vertical(id="console_page"):
yield OutConsole()
yield OutConsole(id="console_page", classes="-hidden")
82 changes: 46 additions & 36 deletions ofscraper/classes/table/css.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,60 @@
CSS = """
Screen {
Widgets="""
Sidebar.-hidden {
display: none;
}
Widget {
column-span:4;
row-span:2;
}
Screen {
layers: sidebar;
overflow: hidden;
overflow-y:scroll;
overflow-x:scroll;
}
Button{
height:3;
}
"""

Table="""
#data_table{
margin-bottom:5;
margin-top:2;
height:70%;
min-height:40;
}
#data_table_hidden {
display:None;
}
#table_main{
height:70%;
min-height:50;
}
#table_header{
height:30%;
max-height:18;
min-height:15;
}
.table_info,Static{
max-width:45;
width:30vw;
min-width:20;
}
"""

#options_sidebar, #page_option_sidebar{
Options="""
#options_sidebar, #page_option_sidebar{
width: 45%;
dock: left;
layer: sidebar;
overflow-y:scroll;
overflow-x:scroll;
height: 100%;
height: 100vh;
}
Expand All @@ -35,38 +73,10 @@
margin-top:2;
}
#buttons{
height:15vh;
}
Sidebar.-hidden {
display: none;
}
#data_table {
margin-bottom:2;
height:95vh;
width:100vw;
}
#data_table_holder {
overflow-x:scroll;
overflow-y:scroll;
width:80%;
height:80%;
}
"""

Widget {
column-span:4;
row-span:2;
}
CSS="""
#post_id,#media_id{
column-span:2;
}
#table_main{
height:6fr;
}
"""
""" + Widgets+Table+Options

0 comments on commit 4b7b080

Please sign in to comment.