Some good progresspython main.py Started the edit verse functionality. The cards on dashboard now pull dynamically based on the users in the db. Will need to add 'start up' functions that allow you to input your children so everything is scalable. Need to look into auth too.

This commit is contained in:
Norm Rasmussen
2024-10-07 18:14:27 -04:00
parent a05d842a5a
commit 61094c1aac
13 changed files with 73 additions and 42 deletions

BIN
.DS_Store vendored Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
assets/awana-clubs.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

View File

@ -0,0 +1,28 @@
import theme
from nicegui import ui
from main import checked_data
import data
from utils import Utils
print(theme.tnt)
@ui.page('/dashboard')
def dashboard():
with theme.frame('Dashboard'):
pass
with ui.grid().style('grid-template-columns: repeat(2, minmax(1px, 1fr));'):
peoples = Utils.get_unique_people()
for ppl in peoples:
pl = ''.join(ppl)
card_info = Utils.get_persons_incomplete(pl)
for item in card_info:
vcard = ui.label(item[1]).classes('hidden')
pcard = ui.label(item[2]).classes('hidden')
club = ui.label(item[3]).classes('hidden')
clubcolor = ui.label(f'{theme.club.text}')
with ui.card().classes('grid justify-items-center').style(f'border: 2px solid {clubcolor.text}'):
ui.label(pl).classes('absolute top-0 left-0 font-thin text-sm')
ui.label(vcard.text).classes('text-center')
ui.label(pcard.text).classes('font-bold')

View File

@ -2,36 +2,26 @@ import theme
from nicegui import ui
from main import checked_data
import data
from utils import Utils
db = data.CON
cur = db.cursor()
color = {'tnt': theme.tnt, 'cubbies': theme.cubbies, 'sparks': theme.sparks}
@ui.page('/dashboard')
def dashboard():
with theme.frame('Dashboard'):
pass
with ui.grid().style('grid-template-columns: repeat(2, minmax(1px, 1fr));'): #(columns='auto 99px 1fr 2fr').classes('w-full gap-3'):
res = cur.execute(f"select person,verse,verse_passage,status from tasks where status = '0'")
information = res.fetchall()
for info in information:
if info[0] == 'hannah':
hvc = ui.label(info[1]).classes('hidden')
hpc = ui.label(info[2]).classes('hidden')
with ui.card().classes('grid justify-items-center').style('border: 2px solid rgba(0, 255, 0, .25)'):
ui.label('Hannah').classes('absolute top-0 left-0 font-thin text-sm')
ui.label(hvc.text).classes('text-center')
ui.label(hpc.text).classes('font-bold')
elif info[0] == 'fiona':
fvc = ui.label(info[1]).classes('hidden')
fpc = ui.label(info[2]).classes('hidden')
with ui.card().classes('grid justify-items-center').style('border: 2px solid rgba(255, 55, 0, .25)'):
ui.label(fvc.text).classes('text-center')
ui.label(fpc.text).classes('font-bold')
else:
lvc = ui.label(info[1]).classes('hidden')
lpc = ui.label(info[2]).classes('hidden')
with ui.card().classes('grid justify-items-center').style('border: 2px solid rgba(0, 0, 255, .25)'):
ui.label(lvc.text).classes('text-center')
ui.label(lpc.text).classes('font-bold')
with ui.grid().style('grid-template-columns: repeat(2, minmax(1px, 1fr));'):
peoples = Utils.get_unique_people()
for ppl in peoples:
pl = ''.join(ppl)
card_info = Utils.get_persons_incomplete(pl)
for item in card_info:
vcard = ui.label(item[1]).classes('hidden')
pcard = ui.label(item[2]).classes('hidden')
club = ui.label(item[3]).classes('hidden')
with ui.card().classes('grid justify-items-center').style(f'border: 2px solid {color[club.text.lower()]}'):
ui.label(pl).classes('absolute top-0 left-0 font-thin text-sm')
ui.label(vcard.text).classes('text-center')
ui.label(pcard.text).classes('font-bold')

29
main.py
View File

@ -16,7 +16,9 @@ HEADERS = { 'Authorization': APIKEY}
def index_page() -> None:
with theme.frame('Homepage'):
with ui.dialog().props('persistent') as addverse:
pass
pass
with ui.dialog().props('persistent') as editverse:
pass
with ui.grid(columns=1).classes('self-center justify-items-center content-center p-2 m-2 rounded-xl'):
users = Utils.get_unique_people()
@ -60,10 +62,10 @@ def index_page() -> None:
label_verse = ui.label(text=item[0]).classes('hidden')
label_passage = ui.label(text=item[1]).classes('hidden')
label_status = ui.label(text=item[2]).classes('hidden')
ui.label(label_verse.text).classes('font-bold')
ui.label(label_verse.text).classes('font-bold text-center')
with ui.row():
ui.label(label_passage.text).classes('text-wrap')
ui.chip("Edit Verse", selectable=True, icon="edit", color="white", on_selection_change=lambda label_verse=label_verse: edit_verse(label_verse.text))
ui.chip("Edit Verse", selectable=True, icon="edit", color="white", on_selection_change=lambda label_verse=label_verse: edit_verse(label_verse.text, person, label_passage.text))
if label_status.text == '1':
ui.chip('Complete',
selectable=True, icon="add", color="positive",
@ -79,20 +81,17 @@ def index_page() -> None:
ui.separator().classes('col-span-5 h-2')
else:
showperson.clear()
addverse.close()
def edit_verse(verse):
ui.notify(f"Edit Verse function is running for {verse}")
# def toggle_completion(verse, person, status):
# ins = cur.execute(f"update tasks set status = '{status}' where person = '{person.value.lower()}' and verse = '{verse}'")
# print(f"update tasks set status = '{status}' where person = '{person.value.lower()}' and verse = '{verse}'")
# db.commit()
# show_person.refresh
# show_person(person)
def edit_verse(verse, person, passage):
editverse.open()
with editverse:
with ui.card().classes('flex-wrap items-center'):
editing = ui.textarea(label="Edit Below", placeholder=passage)
with ui.row().classes('justify-content-center'):
ui.button().props('push glossy icon=add_circle color=secondary').on('click', lambda: submit_verse(result, person))
def add_verse(person):
# TODO: Add check of existing verses so that a user can't add duplicates.
if person.value is None:
ui.notify("Oops! You haven't selected a person")
else:
@ -114,7 +113,7 @@ def index_page() -> None:
# Verify the format of a Bible Verse
if not re.match(r'((^\d\s\w{1,}\s|^\w{1,}\s)(\d{1,2}:)(\d{1,2}-\d{1,2}|\d{1,2}))', result.value):
ui.notify("Verse was input incorrectly.")
addverse.clear()
addverse.close()
else:
# Split up the string for later
colon = result.value.split(':')

Binary file not shown.

View File

@ -1,12 +1,17 @@
from contextlib import contextmanager
from nicegui import ui
#Club Colors
tnt='rgba(30, 206, 0, 0.25)'
cubbies='rgba(25, 39, 255, 0.25)'
sparks='rgba(255, 0, 0, 0.25)'
@contextmanager
def frame(navigation_title: str):
"""Custom page frame to share the same styling and behavior across all pages"""
ui.colors(primary='#023047', secondary='#219ebc', accent='#8ecae6', positive='#ffb703', negative='#fb8500')
with ui.header():
ui.colors(primary='#023047', secondary='#219ebc', accent='#8ecae6', positive='#ffb703', negative='#fb8500', header="#abb8c3", tnt='rgba(30, 206, 0, 0.25)', cubbies='rgba(25, 39, 255, 0.25)', sparks='rgba(255, 0, 0, 0.25)')
with ui.header().style('background-color: #abb8c3'):
ui.image('./assets/awana-clubs.png').classes('w-16')
ui.label('Awana Verse Practice').classes('font-bold font-16')
ui.space()
ui.space()

View File

@ -21,3 +21,12 @@ class Utils():
def toggle_completion(verse, person, status):
ins = cur.execute(f"update tasks set status = '{status}' where person = '{person.value}' and verse = '{verse}'")
db.commit()
def get_persons_incomplete(person):
inc = cur.execute(f"select person, verse, verse_passage, club from tasks where status = '0' and person = '{person}'")
incret = inc.fetchall()
return incret
def edit_verse(person, verse):
vedit = cur.execute(f"update tasks set verse_passage = '{verse_text}' where person = '{person.value} and verse = '{verse}'")
db.commit()