many changes
This commit is contained in:
@@ -82,7 +82,8 @@ def init():
|
|||||||
try:
|
try:
|
||||||
db.connect()
|
db.connect()
|
||||||
break
|
break
|
||||||
except:
|
except Exception as e:
|
||||||
|
print(e)
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
print("Checking & creating tables...")
|
print("Checking & creating tables...")
|
||||||
db.create_tables([location, office, item, component, user])
|
db.create_tables([location, office, item, component, user])
|
||||||
@@ -95,7 +96,7 @@ def init():
|
|||||||
#print(type(add))
|
#print(type(add))
|
||||||
for itm in add:
|
for itm in add:
|
||||||
try:
|
try:
|
||||||
itm["location"] = item.select().where(item.barcode==itm["barcode"])[0].loc.name
|
itm["location"] = fancy_location(item.select().where(item.barcode==itm["barcode"])[0].loc)
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
#print(itm)
|
#print(itm)
|
||||||
@@ -104,6 +105,7 @@ def init():
|
|||||||
print('.',end='',flush=True)
|
print('.',end='',flush=True)
|
||||||
print(" " + str(len(add)), "items added.")
|
print(" " + str(len(add)), "items added.")
|
||||||
print("Cache build complete.")
|
print("Cache build complete.")
|
||||||
|
# locations_list()
|
||||||
|
|
||||||
def search_item(query, filters: dict={}):
|
def search_item(query, filters: dict={}):
|
||||||
#print(filters)
|
#print(filters)
|
||||||
@@ -132,7 +134,26 @@ def search_item(query, filters: dict={}):
|
|||||||
return search.search(query, "")["hits"]
|
return search.search(query, "")["hits"]
|
||||||
|
|
||||||
def find_item(barcode):
|
def find_item(barcode):
|
||||||
return search.get_barcode(barcode)
|
res = search.get_barcode(barcode)
|
||||||
|
try:
|
||||||
|
res["location"] = fancy_location(get_location(res["location"].split(' -> ')[-1]))
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
return res
|
||||||
|
|
||||||
|
def fancy_location(loc):
|
||||||
|
try:
|
||||||
|
loc_str = [loc.name]
|
||||||
|
while loc.parent:
|
||||||
|
loc_str.append(loc.parent.name)
|
||||||
|
loc = loc.parent
|
||||||
|
loc_str.reverse()
|
||||||
|
# print(loc_str)
|
||||||
|
out = " -> ".join(loc_str)
|
||||||
|
# print(out)
|
||||||
|
return out
|
||||||
|
except:
|
||||||
|
return loc.name
|
||||||
|
|
||||||
def find_item_location(barcode):
|
def find_item_location(barcode):
|
||||||
try:
|
try:
|
||||||
@@ -158,7 +179,7 @@ def create_item(fullname, serial, officename, barcode, locationid=None, descript
|
|||||||
itm.save(force_insert=True)
|
itm.save(force_insert=True)
|
||||||
itmdict= item.select().where(item.barcode==barcode).dicts()[0]
|
itmdict= item.select().where(item.barcode==barcode).dicts()[0]
|
||||||
try:
|
try:
|
||||||
itmdict["location"] = loc.name
|
itmdict["location"] = fancy_location(loc)
|
||||||
#print(locationid)
|
#print(locationid)
|
||||||
#print(itmdict["location"])
|
#print(itmdict["location"])
|
||||||
except:
|
except:
|
||||||
@@ -189,7 +210,7 @@ def update_item(fullname, serial, officename, barcode, locationid=None, descript
|
|||||||
itm.save()
|
itm.save()
|
||||||
itmdict= item.select().where(item.barcode==barcode).dicts()[0]
|
itmdict= item.select().where(item.barcode==barcode).dicts()[0]
|
||||||
try:
|
try:
|
||||||
itmdict["location"] = loc.name
|
itmdict["location"] = fancy_location(loc)
|
||||||
#print(locationid)
|
#print(locationid)
|
||||||
#print(itmdict["location"])
|
#print(itmdict["location"])
|
||||||
except:
|
except:
|
||||||
@@ -295,6 +316,8 @@ def checkin(user, barcode, loc=None):
|
|||||||
|
|
||||||
def create_location(name, barcode, parent=None, description=None):
|
def create_location(name, barcode, parent=None, description=None):
|
||||||
try:
|
try:
|
||||||
|
if name == "" or barcode == "":
|
||||||
|
return False
|
||||||
loc = location(name=name, locationid=barcode, parent=parent, description=description)
|
loc = location(name=name, locationid=barcode, parent=parent, description=description)
|
||||||
loc.save(force_insert=True)
|
loc.save(force_insert=True)
|
||||||
print(loc.name, loc.locationid)
|
print(loc.name, loc.locationid)
|
||||||
@@ -367,6 +390,20 @@ def check_db_connection():
|
|||||||
# require the query to fire by checking it's return length
|
# require the query to fire by checking it's return length
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def locations_list():
|
||||||
|
query = location.select()
|
||||||
|
for entry in query:
|
||||||
|
if entry.parent:
|
||||||
|
p = entry.parent.name
|
||||||
|
else:
|
||||||
|
p=""
|
||||||
|
|
||||||
|
if entry.name == "":
|
||||||
|
entry.delete_instance()
|
||||||
|
else:
|
||||||
|
print(entry.name, "Parent:", p)
|
||||||
|
|
||||||
def test():
|
def test():
|
||||||
costa = create_user("Costa Aralis", "caralpwtwfpis", "12345")
|
costa = create_user("Costa Aralis", "caralpwtwfpis", "12345")
|
||||||
costa.username = "caralis"
|
costa.username = "caralis"
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ class AddLocationPage(rio.Component):
|
|||||||
if get_location_id(self.parent) != False:
|
if get_location_id(self.parent) != False:
|
||||||
self.parent_code = self.parent
|
self.parent_code = self.parent
|
||||||
print("Found location " + get_location_id(self.parent).name)
|
print("Found location " + get_location_id(self.parent).name)
|
||||||
self.parent = get_location_id(self.parent).name
|
self.parent = '*' + get_location_id(self.parent).name
|
||||||
|
|
||||||
async def add_part(self):
|
async def add_part(self):
|
||||||
if self.code == "":
|
if self.code == "":
|
||||||
@@ -88,16 +88,19 @@ class AddLocationPage(rio.Component):
|
|||||||
),
|
),
|
||||||
rio.TextInput(
|
rio.TextInput(
|
||||||
label="Barcode",
|
label="Barcode",
|
||||||
text=self.bind().code
|
text=self.bind().code,
|
||||||
|
on_confirm=self._add_part_enter
|
||||||
),
|
),
|
||||||
rio.TextInput(
|
rio.TextInput(
|
||||||
label="Parent Location (optional)",
|
label="Parent Location (optional)",
|
||||||
text=self.bind().parent,
|
text=self.bind().parent,
|
||||||
on_change=self._update_location
|
on_change=self._update_location,
|
||||||
|
on_confirm=self._add_part_enter
|
||||||
),
|
),
|
||||||
rio.TextInput(
|
rio.TextInput(
|
||||||
label="Location Name",
|
label="Location Name",
|
||||||
text=self.bind().name
|
text=self.bind().name,
|
||||||
|
on_confirm=self._add_part_enter
|
||||||
),
|
),
|
||||||
rio.MultiLineTextInput(
|
rio.MultiLineTextInput(
|
||||||
label="Description (optional)",
|
label="Description (optional)",
|
||||||
|
|||||||
@@ -81,8 +81,11 @@ class AddPage(rio.Component):
|
|||||||
self.popup_message = "\n Duplicate barcode! \n\n"
|
self.popup_message = "\n Duplicate barcode! \n\n"
|
||||||
self.popup_show = True
|
self.popup_show = True
|
||||||
self.popup_color = 'warning'
|
self.popup_color = 'warning'
|
||||||
await asyncio.sleep(2)
|
await asyncio.sleep(5)
|
||||||
self.popup_show = False
|
self.popup_show = False
|
||||||
|
self.session.navigate_to("/")
|
||||||
|
await asyncio.sleep(0.01)
|
||||||
|
self.session.navigate_to("/add")
|
||||||
else:
|
else:
|
||||||
self.popup_message = "\n Part added! \n\n"
|
self.popup_message = "\n Part added! \n\n"
|
||||||
self.popup_show = True
|
self.popup_show = True
|
||||||
@@ -99,8 +102,12 @@ class AddPage(rio.Component):
|
|||||||
self.description: str = ""
|
self.description: str = ""
|
||||||
self.location: str = ""
|
self.location: str = ""
|
||||||
self.location_code: str = ""
|
self.location_code: str = ""
|
||||||
await asyncio.sleep(2)
|
await asyncio.sleep(1)
|
||||||
|
self.session.navigate_to("/")
|
||||||
|
await asyncio.sleep(0.01)
|
||||||
|
self.session.navigate_to("/add")
|
||||||
self.popup_show = False
|
self.popup_show = False
|
||||||
|
#self.session.navigate_to("/add",replace=True)
|
||||||
|
|
||||||
|
|
||||||
async def _add_part_enter(self, event: rio.TextInputConfirmEvent):
|
async def _add_part_enter(self, event: rio.TextInputConfirmEvent):
|
||||||
@@ -134,7 +141,7 @@ class AddPage(rio.Component):
|
|||||||
if get_location_id(self.location) != False:
|
if get_location_id(self.location) != False:
|
||||||
self.location_code = self.location
|
self.location_code = self.location
|
||||||
print("Found location " + get_location_id(self.location).name)
|
print("Found location " + get_location_id(self.location).name)
|
||||||
self.location = get_location_id(self.location).name
|
self.location = '*' + get_location_id(self.location).name
|
||||||
|
|
||||||
|
|
||||||
def _update_partnum(self, event: rio.TextInputChangeEvent):
|
def _update_partnum(self, event: rio.TextInputChangeEvent):
|
||||||
@@ -230,7 +237,8 @@ class AddPage(rio.Component):
|
|||||||
),
|
),
|
||||||
rio.TextInput(
|
rio.TextInput(
|
||||||
label="Barcode",
|
label="Barcode",
|
||||||
text=self.bind().code
|
text=self.bind().code,
|
||||||
|
auto_focus=True
|
||||||
),
|
),
|
||||||
rio.TextInput(
|
rio.TextInput(
|
||||||
label="Full part number",
|
label="Full part number",
|
||||||
|
|||||||
@@ -146,7 +146,7 @@ class BrowsePage(rio.Component):
|
|||||||
self.edit_show = False
|
self.edit_show = False
|
||||||
self.info_show = True
|
self.info_show = True
|
||||||
self.force_refresh()
|
self.force_refresh()
|
||||||
await delete_item_id(self.ibarcode)
|
delete_item_id(self.ibarcode)
|
||||||
await self._search()
|
await self._search()
|
||||||
await asyncio.sleep(1)
|
await asyncio.sleep(1)
|
||||||
self.popup_show = False
|
self.popup_show = False
|
||||||
@@ -230,7 +230,7 @@ class BrowsePage(rio.Component):
|
|||||||
if get_location_id(self.elocation) != False:
|
if get_location_id(self.elocation) != False:
|
||||||
self.elocation_code = self.elocation
|
self.elocation_code = self.elocation
|
||||||
print("Found location " + get_location_id(self.elocation).name)
|
print("Found location " + get_location_id(self.elocation).name)
|
||||||
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)
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
peewee
|
peewee
|
||||||
pymysql
|
pymysql
|
||||||
#rio-ui==0.10.4
|
#rio-ui==0.10.4
|
||||||
rio-ui==0.11.1
|
rio-ui==0.11.2rc7
|
||||||
meilisearch #==0.31.5
|
meilisearch #==0.31.5
|
||||||
mac-vendor-lookup
|
mac-vendor-lookup
|
||||||
|
cryptography
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user