diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..2cb9731 Binary files /dev/null and b/.DS_Store differ diff --git a/__pycache__/dashboard.cpython-312 (conflicted copy 2024-10-07 175853).pyc b/__pycache__/dashboard.cpython-312 (conflicted copy 2024-10-07 175853).pyc new file mode 100644 index 0000000..38ab533 Binary files /dev/null and b/__pycache__/dashboard.cpython-312 (conflicted copy 2024-10-07 175853).pyc differ diff --git a/__pycache__/dashboard.cpython-312.pyc b/__pycache__/dashboard.cpython-312.pyc index 2427b14..9681cb3 100644 Binary files a/__pycache__/dashboard.cpython-312.pyc and b/__pycache__/dashboard.cpython-312.pyc differ diff --git a/__pycache__/main.cpython-312.pyc b/__pycache__/main.cpython-312.pyc index e1ec0ad..d59814d 100644 Binary files a/__pycache__/main.cpython-312.pyc and b/__pycache__/main.cpython-312.pyc differ diff --git a/__pycache__/theme.cpython-312.pyc b/__pycache__/theme.cpython-312.pyc index d7a1975..3ed0075 100644 Binary files a/__pycache__/theme.cpython-312.pyc and b/__pycache__/theme.cpython-312.pyc differ diff --git a/__pycache__/utils.cpython-312.pyc b/__pycache__/utils.cpython-312.pyc index ebd76fd..ba935ff 100644 Binary files a/__pycache__/utils.cpython-312.pyc and b/__pycache__/utils.cpython-312.pyc differ diff --git a/assets/awana-clubs.png b/assets/awana-clubs.png new file mode 100644 index 0000000..835f5ce Binary files /dev/null and b/assets/awana-clubs.png differ diff --git a/dashboard (conflicted copy 2024-10-07 175852).py b/dashboard (conflicted copy 2024-10-07 175852).py new file mode 100644 index 0000000..c9138fe --- /dev/null +++ b/dashboard (conflicted copy 2024-10-07 175852).py @@ -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') + diff --git a/dashboard.py b/dashboard.py index 04a2c46..8ee05d6 100644 --- a/dashboard.py +++ b/dashboard.py @@ -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') diff --git a/main.py b/main.py index 283541f..9a047f1 100644 --- a/main.py +++ b/main.py @@ -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(':') diff --git a/memorization_tasks.db b/memorization_tasks.db index 3a245b7..f7496bd 100644 Binary files a/memorization_tasks.db and b/memorization_tasks.db differ diff --git a/theme.py b/theme.py index ed2d119..60a8026 100644 --- a/theme.py +++ b/theme.py @@ -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() diff --git a/utils.py b/utils.py index 4c84671..b0f3ef4 100644 --- a/utils.py +++ b/utils.py @@ -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()