Publish to git
This commit is contained in:
101
inventory/pages/item_page.py
Normal file
101
inventory/pages/item_page.py
Normal file
@@ -0,0 +1,101 @@
|
||||
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,
|
||||
width=60,
|
||||
align_x=0.5,
|
||||
align_y=0,
|
||||
)
|
||||
else:
|
||||
return rio.Text("This item does not exist!")
|
||||
|
Reference in New Issue
Block a user