Add basic CSV export, mac db update
This commit is contained in:
@@ -404,6 +404,18 @@ def locations_list():
|
||||
entry.delete_instance()
|
||||
else:
|
||||
print(entry.name, "Parent:", p)
|
||||
|
||||
|
||||
def dump_csv():
|
||||
out = "Barcode,Part Number,Serial,MAC,FW Version,Manufacturer,Description,Location,Office,Checked out,Checkout location,Checkout user,Checkout start time,Checkout end time\r\n"
|
||||
query = item.select()
|
||||
for itm in query:
|
||||
out += f"\"{itm.barcode}\",\"{itm.fullname}\",\"{itm.serial}\",\"{itm.mac}\",\"{itm.fwver}\",\"{itm.manufacturer}\",\"{itm.description}\",\"{itm.loc}\",\"{itm.office}\",\"{itm.checkout}\",\"{itm.checkout_loc}\",\"{itm.checkout_user}\",\"{itm.checkout_start}\",\"{itm.checkout_end}\"\r\n"
|
||||
|
||||
return out
|
||||
|
||||
def test2():
|
||||
print(dump_csv())
|
||||
|
||||
def test():
|
||||
costa = create_user("Costa Aralis", "caralpwtwfpis", "12345")
|
||||
@@ -434,4 +446,4 @@ def test():
|
||||
|
||||
if __name__ == "__main__":
|
||||
init()
|
||||
test()
|
||||
test2()
|
||||
|
||||
@@ -74,6 +74,11 @@ app = rio.App(
|
||||
url_segment='out',
|
||||
build=pages.CheckoutPage,
|
||||
),
|
||||
rio.ComponentPage(
|
||||
name="ExportPage",
|
||||
url_segment='export-page',
|
||||
build=pages.ExportPage,
|
||||
),
|
||||
],
|
||||
# You can optionally provide a root component for the app. By default,
|
||||
# a simple `rio.PageView` is used. By providing your own component, you
|
||||
|
||||
@@ -156,6 +156,18 @@ class Navbar(rio.Component):
|
||||
),
|
||||
"/settings-page",
|
||||
),
|
||||
rio.Link(
|
||||
rio.Button(
|
||||
"Export",
|
||||
icon="material/download",
|
||||
style=(
|
||||
"major"
|
||||
if active_page_url_segment == "export-page"
|
||||
else "plain-text"
|
||||
),
|
||||
),
|
||||
"/export-page",
|
||||
),
|
||||
spacing=1,
|
||||
margin=1,
|
||||
),
|
||||
|
||||
@@ -7,3 +7,4 @@ from .login_page import LoginPage
|
||||
from .item_page import ItemPage
|
||||
from .checkin_page import CheckinPage
|
||||
from .checkout_page import CheckoutPage
|
||||
from .export_page import ExportPage
|
||||
@@ -5,8 +5,15 @@ from typing import * # type: ignore
|
||||
|
||||
import rio
|
||||
import datetime
|
||||
from mac_vendor_lookup import AsyncMacLookup
|
||||
|
||||
from mac_vendor_lookup import AsyncMacLookup, MacLookup
|
||||
mac = MacLookup()
|
||||
print("Updating vendors...")
|
||||
try:
|
||||
mac.update_vendors()
|
||||
print("Update complete!")
|
||||
except:
|
||||
print("Update failed, no internet?")
|
||||
pass
|
||||
# from db_classes import *
|
||||
from db_classes import get_location_id, create_item, fancy_location
|
||||
from .. import components as comps
|
||||
|
||||
43
inventory/pages/export_page.py
Normal file
43
inventory/pages/export_page.py
Normal file
@@ -0,0 +1,43 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import * # type: ignore
|
||||
|
||||
import rio
|
||||
|
||||
from db_classes import *
|
||||
from .. import components as comps
|
||||
import asyncio
|
||||
|
||||
class ExportPage(rio.Component):
|
||||
code: str = ""
|
||||
popup_message: str = ""
|
||||
popup_show: bool = False
|
||||
popup_color: str = 'warning'
|
||||
description: str = ""
|
||||
name: str = ""
|
||||
parent_code: str = ""
|
||||
parent: str = ""
|
||||
|
||||
@rio.event.periodic(1)
|
||||
def set_office_init(self):
|
||||
self.office = self.session[comps.Settings].office
|
||||
#print("Populated:", self.office)
|
||||
|
||||
def build(self) -> rio.Component:
|
||||
return rio.Column(
|
||||
rio.Text(
|
||||
text="Database CSV Below:",
|
||||
style='heading1',
|
||||
align_x = 0.5
|
||||
),
|
||||
rio.MultiLineTextInput(
|
||||
label="CSV",
|
||||
text=dump_csv()
|
||||
),
|
||||
spacing=2,
|
||||
min_width=60,
|
||||
margin_bottom=4,
|
||||
align_x=0.5,
|
||||
align_y=0,
|
||||
)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
peewee
|
||||
pymysql
|
||||
#rio-ui==0.10.4
|
||||
rio-ui==0.11.2rc7
|
||||
# rio-ui==0.11.2rc7
|
||||
rio-ui==0.12.0
|
||||
meilisearch #==0.31.5
|
||||
mac-vendor-lookup
|
||||
cryptography
|
||||
|
||||
Reference in New Issue
Block a user