Skip to content

Commit a097e13

Browse files
committed
Populate a datatables with dummy data (moniker, location, speed, status, price, protocol, type). We should implement all the sort methods (by column). Note: what about the price denom? up and down with ascii icon? Location should be the city? Login for speedometer? #65
1 parent 3f89598 commit a097e13

File tree

1 file changed

+42
-71
lines changed

1 file changed

+42
-71
lines changed

tests/v2/main_screen.py

Lines changed: 42 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ def __init__(self, **kwargs):
167167
self.build()
168168

169169
def build(self):
170-
import random
170+
import random, string
171171

172172
countries = [
173173
"France",
@@ -217,82 +217,49 @@ def build(self):
217217

218218
self.data_tables = MDDataTable(
219219
use_pagination=True,
220-
check=True,
220+
check=False,
221221
column_data=[
222-
("No.", dp(30)),
223-
("Status", dp(30)),
224-
("Signal Name", dp(60), self.sort_on_signal),
225-
("Severity", dp(30)),
226-
("Stage", dp(30)),
227-
("Schedule", dp(30), self.sort_on_schedule),
228-
("Team Lead", dp(30), self.sort_on_team),
222+
("Moniker", dp(45)),
223+
("Location", dp(20)),
224+
("Speed", dp(50)),
225+
("Status", dp(20)),
226+
("Price", dp(40)),
227+
("Protocol", dp(20)),
228+
("Type", dp(20)),
229229
],
230-
row_data=[
231-
(
232-
"1",
233-
("alert", [255 / 256, 165 / 256, 0, 1], "No Signal"),
234-
"Astrid: NE shared managed",
235-
"Medium",
236-
"Triaged",
237-
"0:33",
238-
"Chase Nguyen",
239-
),
240-
(
241-
"2",
242-
("alert-circle", [1, 0, 0, 1], "Offline"),
243-
"Cosmo: prod shared ares",
244-
"Huge",
245-
"Triaged",
246-
"0:39",
247-
"Brie Furman",
248-
),
249-
(
250-
"3",
251-
(
252-
"checkbox-marked-circle",
253-
[39 / 256, 174 / 256, 96 / 256, 1],
254-
"Online",
255-
),
256-
"Phoenix: prod shared lyra-lists",
257-
"Minor",
258-
"Not Triaged",
259-
"3:12",
260-
"Jeremy lake",
261-
),
262-
(
263-
"4",
264-
(
265-
"checkbox-marked-circle",
266-
[39 / 256, 174 / 256, 96 / 256, 1],
267-
"Online",
268-
),
269-
"Sirius: NW prod shared locations",
270-
"Negligible",
271-
"Triaged",
272-
"13:18",
273-
"Angelica Howards",
274-
),
275-
(
276-
"5",
277-
(
278-
"checkbox-marked-circle",
279-
[39 / 256, 174 / 256, 96 / 256, 1],
280-
"Online",
281-
),
282-
"Sirius: prod independent account",
283-
"Negligible",
284-
"Triaged",
285-
"22:06",
286-
"Diane Okuma",
287-
),
288-
],
289-
sorted_on="Schedule",
230+
sorted_on="Moniker",
290231
sorted_order="ASC",
291232
elevation=2,
233+
rows_num=10
292234
)
293-
self.data_tables.bind(on_row_press=self.on_row_press)
294-
self.data_tables.bind(on_check_press=self.on_check_press)
295235

236+
row_data = []
237+
for _ in range(0, 150):
238+
upload = random.uniform(100, 900)
239+
download = random.uniform(100, 900)
240+
bandwith = "speedometer-medium"
241+
if upload + download > 1200:
242+
bandwith = "speedometer"
243+
elif upload + download < 400:
244+
bandwith = "speedometer-slow"
245+
246+
healthcheck = random.choice([True, False])
247+
248+
row_data.append(
249+
(
250+
''.join(random.choices(string.printable[:-6], k=random.randint(5, 15))), # Moniker
251+
random.choice(countries),
252+
(bandwith, [1, 1, 1, 1] ,f"[size=12][color=#00FF00]up[/color] {round(upload, 2)}mb/s[color=#f44336]down[/color] {round(download, 2)}mb/s[/size]"),
253+
("shield-plus", [39 / 256, 174 / 256, 96 / 256, 1], "Health") if healthcheck is True else ("emoticon-sick", [1, 0, 0, 1], "Sick"),
254+
f"[size=12]{random.randint(1, 100)}dvpn, {random.randint(1, 100)}atom, {random.randint(1, 100)}osmo, {random.randint(1, 100)}srct, {random.randint(1, 100)}dec[/size]",
255+
random.choice(["Wireguard", "V2RAY"]),
256+
random.choice(["Residential", "Datacenter", "Unknown"])
257+
)
258+
)
259+
260+
self.data_tables.row_data = row_data
261+
262+
self.data_tables.bind(on_row_press=self.on_row_press)
296263
self.ids.servers_datatable.add_widget(self.data_tables)
297264

298265
def on_row_press(self, instance_table, instance_row):
@@ -344,6 +311,10 @@ class Test(MDApp):
344311
def build(self):
345312
Window.size = (1280, 720)
346313

314+
# TODO: review this values
315+
self.theme_cls.theme_style = "Dark" # (?)
316+
self.theme_cls.primary_palette = "Orange" # (?)
317+
347318
manager = WindowManager()
348319
manager.add_widget(MainScreen())
349320
return manager

0 commit comments

Comments
 (0)