You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

102 lines
3.4 KiB
Python

4 months ago
from __future__ import annotations
from dataclasses import KW_ONLY, field
from typing import * # type: ignore
import rio
from .. import components as comps
from db_classes import *
import functools
class ItemPage(rio.Component):
itm: dict = {}
barcode: str = ""
@rio.event.on_populate
async def _get(self):
self.barcode = self.session[comps.Settings].selected_item
self.itm = find_item(self.barcode)
#print(find_item(self.barcode))
#print(self.itm)
await self.force_refresh()
def build(self) -> rio.Component:
if 'barcode' in self.itm:
if self.itm["loc"] is not None:
loc = self.itm["loc"]["name"]
else:
loc = ""
if self.itm["checkout"]:
checkout = self.itm["checkout_user"] + " - " + loc
else:
checkout = loc
# searchview.add(rio.SimpleListItem(text=item["fullname"],secondary_text=(item["manufacturer"] + " - Serial: " + item["serial"] + "\n" + checkout), on_press=functools.partial(
# self.click_item,
# file=item["barcode"])))
return rio.Column(
rio.Text(
text=str(self.itm["fullname"]),
style='heading1',
align_x = 0.5
),
rio.Text(
text=str(self.itm["manufacturer"]),
style='heading2',
align_x = 0.5
),
rio.Text(
text="Serial: " + str(self.itm["serial"]),
style='heading2',
align_x = 0.5
),
rio.Text(
text="MAC: " + str(self.itm["mac"]),
style='heading2',
align_x = 0.5
),
rio.Text(
text="FW Version: " + str(self.itm["fwver"]),
style='heading2',
align_x = 0.5
),
rio.Text(
text="Location: " + str(checkout),
style='heading2',
align_x = 0.5
),
rio.Text(
text="Checked out?: " + str(self.itm["checkout"]),
style='heading2',
align_x = 0.5
),
rio.Text(
text="Checkout start/end: " + str(self.itm["checkout_start"]) + " to " + str(self.itm["checkout_end"]),
style='heading2',
align_x = 0.5
),
rio.Text(
text="Office: " + str(self.itm["office"]),
style='heading2',
align_x = 0.5
),
rio.Text(
text="Barcode: " + str(self.itm["barcode"]),
style='heading2',
align_x = 0.5
),
rio.Text(
text="Description: " + str(self.itm["description"]),
style='heading2',
align_x = 0.5,
),
spacing=2,
min_width=60,
4 months ago
align_x=0.5,
align_y=0,
)
else:
return rio.Text("This item does not exist!")