Fix checkin/out pages, add location refresh, and misc bugfix
This commit is contained in:
@@ -51,6 +51,9 @@ class AddLocationPage(rio.Component):
|
||||
self.popup_show = True
|
||||
self.popup_color = 'warning'
|
||||
await asyncio.sleep(2)
|
||||
self.session.navigate_to("/")
|
||||
await asyncio.sleep(0.01)
|
||||
self.session.navigate_to("/addlocation")
|
||||
self.popup_show = False
|
||||
else:
|
||||
self.popup_message = "\n Location added! \n\n"
|
||||
@@ -61,7 +64,10 @@ class AddLocationPage(rio.Component):
|
||||
self.description: str = ""
|
||||
self.parent_code: str = ""
|
||||
self.parent: str = ""
|
||||
await asyncio.sleep(2)
|
||||
await asyncio.sleep(1)
|
||||
self.session.navigate_to("/")
|
||||
await asyncio.sleep(0.01)
|
||||
self.session.navigate_to("/addlocation")
|
||||
self.popup_show = False
|
||||
|
||||
|
||||
@@ -89,7 +95,8 @@ class AddLocationPage(rio.Component):
|
||||
rio.TextInput(
|
||||
label="Barcode",
|
||||
text=self.bind().code,
|
||||
on_confirm=self._add_part_enter
|
||||
on_confirm=self._add_part_enter,
|
||||
auto_focus=True
|
||||
),
|
||||
rio.TextInput(
|
||||
label="Parent Location (optional)",
|
||||
@@ -104,7 +111,8 @@ class AddLocationPage(rio.Component):
|
||||
),
|
||||
rio.MultiLineTextInput(
|
||||
label="Description (optional)",
|
||||
text=self.bind().description
|
||||
text=self.bind().description,
|
||||
on_confirm=self._add_part_enter
|
||||
),
|
||||
rio.Button(
|
||||
content="Add",
|
||||
|
||||
@@ -7,7 +7,7 @@ import rio
|
||||
import datetime
|
||||
from mac_vendor_lookup import AsyncMacLookup, MacLookup
|
||||
mac = MacLookup()
|
||||
print("Updating vendors...")
|
||||
print("Updating MAC vendors...")
|
||||
try:
|
||||
mac.update_vendors()
|
||||
print("Update complete!")
|
||||
|
||||
@@ -124,7 +124,8 @@ class BrowsePage(rio.Component):
|
||||
|
||||
async def _close_edit_popup(self):
|
||||
await self._open_info_popup(self.ibarcode)
|
||||
self.force_refresh()
|
||||
# self._search(self.searchtext)
|
||||
# self.force_refresh()
|
||||
|
||||
async def _save_edit_popup(self):
|
||||
self.edit_show = False
|
||||
@@ -133,11 +134,11 @@ class BrowsePage(rio.Component):
|
||||
await self._add_part_button()
|
||||
await asyncio.sleep(1)
|
||||
await self._open_info_popup(self.ibarcode, skip_display=True)
|
||||
await self._search()
|
||||
await self._search(self.searchtext)
|
||||
await asyncio.sleep(1)
|
||||
self.popup_show = False
|
||||
await self._open_info_popup(self.ibarcode, skip_display=True)
|
||||
await self._search()
|
||||
await self._search(self.searchtext)
|
||||
|
||||
|
||||
|
||||
@@ -149,10 +150,10 @@ class BrowsePage(rio.Component):
|
||||
self.info_show = False
|
||||
self.force_refresh()
|
||||
delete_item_id(self.ibarcode)
|
||||
await self._search()
|
||||
await self._search(self.searchtext)
|
||||
await asyncio.sleep(1)
|
||||
self.popup_show = False
|
||||
await self._search()
|
||||
await self._search(self.searchtext)
|
||||
|
||||
|
||||
async def _open_edit_popup(self, code: str) -> str | None:
|
||||
|
||||
@@ -15,8 +15,8 @@ class CheckinPage(rio.Component):
|
||||
popup_message: str = ""
|
||||
popup_show: bool = False
|
||||
popup_color: str = 'warning'
|
||||
name: str = ""
|
||||
user_code: str = ""
|
||||
name: str = ""
|
||||
loc_code: str = ""
|
||||
loc: str = ""
|
||||
|
||||
@@ -25,35 +25,43 @@ class CheckinPage(rio.Component):
|
||||
if get_location_id(self.loc) != False:
|
||||
self.loc_code = self.loc
|
||||
print("Found location " + get_location_id(self.loc).name)
|
||||
self.loc = get_location_id(self.loc).name
|
||||
self.loc = '* ' + fancy_location(get_location_id(self.loc))
|
||||
|
||||
async def _update_user(self, event: rio.TextInputChangeEvent):
|
||||
print("Checking " + self.name)
|
||||
if get_location_id(self.name) != False:
|
||||
if get_user(self.name) != False:
|
||||
self.user_code = self.name
|
||||
print("Found user " + get_user(self.name).name)
|
||||
self.name = get_user(self.name).name
|
||||
self.name = '* ' + get_user(self.name).name
|
||||
|
||||
async def _checkin_item_enter(self, event: rio.TextInputConfirmEvent):
|
||||
await self.check_in()
|
||||
|
||||
async def check_in(self):
|
||||
if checkin(get_user(self.user_code), self.code, get_location_id(self.loc_code)):
|
||||
user = get_user(self.user_code)
|
||||
loc = get_location_id(self.loc_code)
|
||||
if user is not False and checkin(user, self.code, loc):
|
||||
self.popup_message = "\n Item checked in! \n\n"
|
||||
self.popup_show = True
|
||||
self.popup_color = 'success'
|
||||
self.name: str = ""
|
||||
self.user_code: str = ""
|
||||
self.name: str = ""
|
||||
self.code: str = ""
|
||||
self.loc_code: str = ""
|
||||
self.loc: str = ""
|
||||
await asyncio.sleep(2)
|
||||
await asyncio.sleep(0.5)
|
||||
self.session.navigate_to("/")
|
||||
await asyncio.sleep(0.01)
|
||||
self.session.navigate_to("/in")
|
||||
self.popup_show = False
|
||||
else:
|
||||
self.popup_message = "\n Error! Check item & location! \n\n"
|
||||
self.popup_show = True
|
||||
self.popup_color = 'warning'
|
||||
await asyncio.sleep(2)
|
||||
self.session.navigate_to("/")
|
||||
await asyncio.sleep(0.01)
|
||||
self.session.navigate_to("/in")
|
||||
self.popup_show = False
|
||||
|
||||
def build(self) -> rio.Component:
|
||||
@@ -73,7 +81,8 @@ class CheckinPage(rio.Component):
|
||||
),
|
||||
rio.TextInput(
|
||||
label="Barcode",
|
||||
text=self.bind().code
|
||||
text=self.bind().code,
|
||||
auto_focus=True
|
||||
),
|
||||
rio.TextInput(
|
||||
label="New location",
|
||||
@@ -83,10 +92,17 @@ class CheckinPage(rio.Component):
|
||||
rio.TextInput(
|
||||
label="User",
|
||||
text=self.bind().name,
|
||||
on_confirm=self._checkin_item_enter
|
||||
on_confirm=self.check_in,
|
||||
on_change=self._update_user
|
||||
),
|
||||
# rio.TextInput(
|
||||
# label="N/A",
|
||||
# text="",
|
||||
# on_confirm=self.check_in,
|
||||
# ),
|
||||
rio.Button(
|
||||
content="Go"
|
||||
content="Go",
|
||||
on_press=self.check_in
|
||||
),
|
||||
|
||||
spacing=2,
|
||||
|
||||
@@ -26,20 +26,22 @@ class CheckoutPage(rio.Component):
|
||||
if get_location_id(self.loc) != False:
|
||||
self.loc_code = self.loc
|
||||
print("Found location " + get_location_id(self.loc).name)
|
||||
self.loc = get_location_id(self.loc).name
|
||||
self.loc = '* ' + fancy_location(get_location_id(self.loc))
|
||||
|
||||
async def _update_user(self, event: rio.TextInputChangeEvent):
|
||||
print("Checking " + self.name)
|
||||
if get_location_id(self.name) != False:
|
||||
if get_user(self.name) != False:
|
||||
self.user_code = self.name
|
||||
print("Found user " + get_user(self.name).name)
|
||||
self.name = get_user(self.name).name
|
||||
self.name = '* ' + get_user(self.name).name
|
||||
|
||||
async def _checkout_item_enter(self, event: rio.TextInputConfirmEvent):
|
||||
await self.check_out()
|
||||
|
||||
async def check_out(self):
|
||||
if checkout(get_user(self.user_code), self.code, get_location_id(self.loc_code)):
|
||||
user = get_user(self.user_code)
|
||||
loc = get_location_id(self.loc_code)
|
||||
if user is not False and checkout(user, self.code, loc):
|
||||
self.popup_message = "\n Item checked out! \n\n"
|
||||
self.popup_show = True
|
||||
self.popup_color = 'success'
|
||||
@@ -48,13 +50,19 @@ class CheckoutPage(rio.Component):
|
||||
self.code: str = ""
|
||||
self.loc_code: str = ""
|
||||
self.loc: str = ""
|
||||
await asyncio.sleep(2)
|
||||
await asyncio.sleep(0.5)
|
||||
self.session.navigate_to("/")
|
||||
await asyncio.sleep(0.01)
|
||||
self.session.navigate_to("/out")
|
||||
self.popup_show = False
|
||||
else:
|
||||
self.popup_message = "\n Error! Check item & location! \n\n"
|
||||
self.popup_show = True
|
||||
self.popup_color = 'warning'
|
||||
await asyncio.sleep(2)
|
||||
self.session.navigate_to("/")
|
||||
await asyncio.sleep(0.01)
|
||||
self.session.navigate_to("/out")
|
||||
self.popup_show = False
|
||||
|
||||
def build(self) -> rio.Component:
|
||||
@@ -74,7 +82,8 @@ class CheckoutPage(rio.Component):
|
||||
),
|
||||
rio.TextInput(
|
||||
label="Barcode",
|
||||
text=self.bind().code
|
||||
text=self.bind().code,
|
||||
auto_focus=True
|
||||
),
|
||||
rio.TextInput(
|
||||
label="New location",
|
||||
@@ -84,10 +93,17 @@ class CheckoutPage(rio.Component):
|
||||
rio.TextInput(
|
||||
label="User",
|
||||
text=self.bind().name,
|
||||
on_confirm=self._checkout_item_enter
|
||||
on_confirm=self.check_out,
|
||||
on_change=self._update_user
|
||||
),
|
||||
# rio.TextInput(
|
||||
# label="N/A",
|
||||
# text="",
|
||||
# on_confirm=self.check_out,
|
||||
# ),
|
||||
rio.Button(
|
||||
content="Go"
|
||||
content="Go",
|
||||
on_press=self.check_out,
|
||||
),
|
||||
|
||||
spacing=2,
|
||||
|
||||
Reference in New Issue
Block a user