|
|
@ -11,6 +11,7 @@ from .add_page import AddPage
|
|
|
|
from db_classes import *
|
|
|
|
from db_classes import *
|
|
|
|
import functools
|
|
|
|
import functools
|
|
|
|
import asyncio
|
|
|
|
import asyncio
|
|
|
|
|
|
|
|
from time import time
|
|
|
|
|
|
|
|
|
|
|
|
class BrowsePage(rio.Component):
|
|
|
|
class BrowsePage(rio.Component):
|
|
|
|
searchtext: str = ""
|
|
|
|
searchtext: str = ""
|
|
|
@ -48,16 +49,27 @@ class BrowsePage(rio.Component):
|
|
|
|
icheckout_times: str =""
|
|
|
|
icheckout_times: str =""
|
|
|
|
ibarcode: str =""
|
|
|
|
ibarcode: str =""
|
|
|
|
idesc: str =""
|
|
|
|
idesc: str =""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
loading_text: str = "Loading..."
|
|
|
|
|
|
|
|
|
|
|
|
@rio.event.on_populate
|
|
|
|
@rio.event.on_populate
|
|
|
|
async def _search(self, query=searchtext):
|
|
|
|
async def _search(self, query=searchtext):
|
|
|
|
|
|
|
|
self.loading_text = "Searching..."
|
|
|
|
|
|
|
|
start = time()
|
|
|
|
self.office = self.session[comps.Settings].office
|
|
|
|
self.office = self.session[comps.Settings].office
|
|
|
|
#print("Office:",self.office)
|
|
|
|
#print("Office:",self.office)
|
|
|
|
self.filters['office'] = self.office
|
|
|
|
self.filters['office'] = self.office
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.items = search_item(query, self.filters)
|
|
|
|
self.items = search_item(query, self.filters)
|
|
|
|
|
|
|
|
mid = time()
|
|
|
|
|
|
|
|
self.loading_text = "Loading data..."
|
|
|
|
await self.force_refresh()
|
|
|
|
await self.force_refresh()
|
|
|
|
|
|
|
|
end = time()
|
|
|
|
|
|
|
|
self.loading_text = ""
|
|
|
|
|
|
|
|
render = str(int((end - mid) * 1000)) + "ms"
|
|
|
|
|
|
|
|
search = str(int((mid - start) * 1000)) + "ms"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.loading_text = search + " search, " + render + " load and render"
|
|
|
|
|
|
|
|
|
|
|
|
@rio.event.periodic(1)
|
|
|
|
@rio.event.periodic(1)
|
|
|
|
async def set_office_init(self):
|
|
|
|
async def set_office_init(self):
|
|
|
@ -68,6 +80,7 @@ class BrowsePage(rio.Component):
|
|
|
|
await self._search()
|
|
|
|
await self._search()
|
|
|
|
|
|
|
|
|
|
|
|
async def _search_trigger(self, event: rio.TextInputChangeEvent):
|
|
|
|
async def _search_trigger(self, event: rio.TextInputChangeEvent):
|
|
|
|
|
|
|
|
self.loading_text = "Loading..."
|
|
|
|
await self._search(event.text)
|
|
|
|
await self._search(event.text)
|
|
|
|
|
|
|
|
|
|
|
|
async def copy_info(self, text: str):
|
|
|
|
async def copy_info(self, text: str):
|
|
|
@ -220,8 +233,20 @@ class BrowsePage(rio.Component):
|
|
|
|
self.elocation = get_location_id(self.elocation).name
|
|
|
|
self.elocation = get_location_id(self.elocation).name
|
|
|
|
|
|
|
|
|
|
|
|
def build(self) -> rio.Component:
|
|
|
|
def build(self) -> rio.Component:
|
|
|
|
searchview: rio.ListView = rio.ListView(grow_y=True)
|
|
|
|
searchview: rio.ListView = rio.ListView(grow_y=True)
|
|
|
|
|
|
|
|
check = False
|
|
|
|
|
|
|
|
if len(self.searchtext) > 2:
|
|
|
|
|
|
|
|
check = True
|
|
|
|
|
|
|
|
ref = self.searchtext.lower()
|
|
|
|
|
|
|
|
icon_ref = rio.Icon("material/stars", fill=rio.Color.from_hex("#3FBF3F"))
|
|
|
|
|
|
|
|
|
|
|
|
for item in self.items:
|
|
|
|
for item in self.items:
|
|
|
|
|
|
|
|
icon = None
|
|
|
|
|
|
|
|
if check:
|
|
|
|
|
|
|
|
# if the search has an exact match anywhere
|
|
|
|
|
|
|
|
for val in item.values():
|
|
|
|
|
|
|
|
if type(val) is str and val.lower() == ref:
|
|
|
|
|
|
|
|
icon=icon_ref
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
loc = item["location"]
|
|
|
|
loc = item["location"]
|
|
|
|
except:
|
|
|
|
except:
|
|
|
@ -230,46 +255,50 @@ class BrowsePage(rio.Component):
|
|
|
|
checkout = item["checkout_user"] + " - " + loc
|
|
|
|
checkout = item["checkout_user"] + " - " + loc
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
checkout = loc
|
|
|
|
checkout = loc
|
|
|
|
icon = None
|
|
|
|
|
|
|
|
if len(self.searchtext) > 2:
|
|
|
|
searchview.add(rio.SimpleListItem(text=item["fullname"],
|
|
|
|
for key, val in item.items():
|
|
|
|
secondary_text=(item["manufacturer"] + " - Serial: " + item["serial"] + "\n" + checkout),
|
|
|
|
if val == self.searchtext:
|
|
|
|
left_child=icon,
|
|
|
|
# if the search has an exact match anywhere
|
|
|
|
on_press=functools.partial(
|
|
|
|
icon=rio.Icon("material/stars", fill=rio.Color.from_hex("#3FBF3F"))
|
|
|
|
self.click_item_dialog,
|
|
|
|
|
|
|
|
code=item["barcode"]
|
|
|
|
searchview.add(rio.SimpleListItem(text=item["fullname"],secondary_text=(item["manufacturer"] + " - Serial: " + item["serial"] + "\n" + checkout), left_child=icon, on_press=functools.partial(
|
|
|
|
)
|
|
|
|
self.click_item_dialog,
|
|
|
|
)
|
|
|
|
code=item["barcode"])))
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
details = rio.ListView(grow_y=True, min_width=40)
|
|
|
|
details = rio.ListView(grow_y=True, min_width=40)
|
|
|
|
|
|
|
|
if self.info_show:
|
|
|
|
details.add(rio.SimpleListItem(text=self.iname, on_press=functools.partial(self.copy_info, text=self.iname)))
|
|
|
|
details.add(rio.SimpleListItem(text=self.iname, on_press=functools.partial(self.copy_info, text=self.iname)))
|
|
|
|
details.add(rio.SimpleListItem(text=self.imanu, on_press=functools.partial(self.copy_info, text=self.imanu)))
|
|
|
|
details.add(rio.SimpleListItem(text=self.imanu, on_press=functools.partial(self.copy_info, text=self.imanu)))
|
|
|
|
details.add(rio.SimpleListItem(text="Serial",secondary_text=self.iserial, on_press=functools.partial(self.copy_info, text=self.iserial)))
|
|
|
|
details.add(rio.SimpleListItem(text="Serial",secondary_text=self.iserial, on_press=functools.partial(self.copy_info, text=self.iserial)))
|
|
|
|
details.add(rio.SimpleListItem(text="MAC",secondary_text=self.imac, on_press=functools.partial(self.copy_info, text=self.imac)))
|
|
|
|
details.add(rio.SimpleListItem(text="MAC",secondary_text=self.imac, on_press=functools.partial(self.copy_info, text=self.imac)))
|
|
|
|
details.add(rio.SimpleListItem(text="FW Version",secondary_text=self.ifw, on_press=functools.partial(self.copy_info, text=self.ifw)))
|
|
|
|
details.add(rio.SimpleListItem(text="FW Version",secondary_text=self.ifw, on_press=functools.partial(self.copy_info, text=self.ifw)))
|
|
|
|
details.add(rio.SimpleListItem(text="Location",secondary_text=self.iloc, on_press=functools.partial(self.copy_info, text=self.iloc)))
|
|
|
|
details.add(rio.SimpleListItem(text="Location",secondary_text=self.iloc, on_press=functools.partial(self.copy_info, text=self.iloc)))
|
|
|
|
details.add(rio.SimpleListItem(text="Checked out?",secondary_text=self.icheckouts, on_press=functools.partial(self.copy_info, text=self.icheckouts)))
|
|
|
|
details.add(rio.SimpleListItem(text="Checked out?",secondary_text=self.icheckouts, on_press=functools.partial(self.copy_info, text=self.icheckouts)))
|
|
|
|
details.add(rio.SimpleListItem(text="Checkout start/end",secondary_text=self.icheckout_times, on_press=functools.partial(self.copy_info, text=self.icheckout_times)))
|
|
|
|
details.add(rio.SimpleListItem(text="Checkout start/end",secondary_text=self.icheckout_times, on_press=functools.partial(self.copy_info, text=self.icheckout_times)))
|
|
|
|
#details.add(rio.SimpleListItem(text="Office",secondary_text=office, on_press=functools.partial(copy_info, text=office)))
|
|
|
|
#details.add(rio.SimpleListItem(text="Office",secondary_text=office, on_press=functools.partial(copy_info, text=office)))
|
|
|
|
details.add(rio.SimpleListItem(text="Barcode",secondary_text=self.ibarcode, on_press=functools.partial(self.copy_info, text=self.ibarcode)))
|
|
|
|
details.add(rio.SimpleListItem(text="Barcode",secondary_text=self.ibarcode, on_press=functools.partial(self.copy_info, text=self.ibarcode)))
|
|
|
|
details.add(rio.SimpleListItem(text="Description",secondary_text=self.idesc, on_press=functools.partial(self.copy_info, text=self.idesc)))
|
|
|
|
details.add(rio.SimpleListItem(text="Description",secondary_text=self.idesc, on_press=functools.partial(self.copy_info, text=self.idesc)))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return rio.Column(
|
|
|
|
return rio.Column(
|
|
|
|
rio.Row(
|
|
|
|
rio.TextInput(
|
|
|
|
rio.TextInput(
|
|
|
|
text=self.bind().searchtext,
|
|
|
|
text=self.bind().searchtext,
|
|
|
|
on_change=self._search_trigger,
|
|
|
|
on_change=self._search_trigger,
|
|
|
|
label="Search"
|
|
|
|
label="Search"
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
rio.Text(
|
|
|
|
|
|
|
|
text=self.bind().loading_text,
|
|
|
|
|
|
|
|
style='heading3',
|
|
|
|
|
|
|
|
align_x = 0.5,
|
|
|
|
|
|
|
|
align_y = 0,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
|
|
rio.Popup(
|
|
|
|
rio.Popup(
|
|
|
|
anchor=rio.Text(
|
|
|
|
anchor=rio.Text(
|
|
|
|
text="",
|
|
|
|
text="",
|
|
|
|
style='heading1',
|
|
|
|
style='heading3',
|
|
|
|
align_x = 0.5,
|
|
|
|
align_x = 0.5,
|
|
|
|
align_y = 0,
|
|
|
|
align_y = 0,
|
|
|
|
),
|
|
|
|
),
|
|
|
@ -304,7 +333,7 @@ class BrowsePage(rio.Component):
|
|
|
|
rio.Popup(
|
|
|
|
rio.Popup(
|
|
|
|
anchor=rio.Text(
|
|
|
|
anchor=rio.Text(
|
|
|
|
text="",
|
|
|
|
text="",
|
|
|
|
style='heading1',
|
|
|
|
style='heading3',
|
|
|
|
align_x = 0.5,
|
|
|
|
align_x = 0.5,
|
|
|
|
align_y = 0,
|
|
|
|
align_y = 0,
|
|
|
|
),
|
|
|
|
),
|
|
|
@ -380,7 +409,7 @@ class BrowsePage(rio.Component):
|
|
|
|
rio.Popup(
|
|
|
|
rio.Popup(
|
|
|
|
anchor=rio.Text(
|
|
|
|
anchor=rio.Text(
|
|
|
|
text="",
|
|
|
|
text="",
|
|
|
|
style='heading1',
|
|
|
|
style='heading3',
|
|
|
|
align_x = 0.5
|
|
|
|
align_x = 0.5
|
|
|
|
),
|
|
|
|
),
|
|
|
|
color=self.popup_color,
|
|
|
|
color=self.popup_color,
|
|
|
|