Add comments for clarity
This commit is contained in:
parent
f636f0cba9
commit
bc2eb35b6f
1 changed files with 19 additions and 16 deletions
33
src/main.py
33
src/main.py
|
@ -1,19 +1,20 @@
|
||||||
import flet as ft
|
|
||||||
import json
|
import json
|
||||||
import keyring
|
|
||||||
import pickle
|
import pickle
|
||||||
import base64
|
import base64
|
||||||
import gettext
|
import gettext
|
||||||
|
import keyring
|
||||||
import threading
|
import threading
|
||||||
|
import flet as ft
|
||||||
from i18n import *
|
from i18n import *
|
||||||
from pages.home import *
|
from pages.home import *
|
||||||
from pages.grades import *
|
from pathlib import Path
|
||||||
from pages.timetable import *
|
|
||||||
from pages.homework import *
|
|
||||||
from pages.exams import *
|
from pages.exams import *
|
||||||
from pages.attendance import *
|
from pages.grades import *
|
||||||
from pages.behaviour import *
|
from pages.homework import *
|
||||||
from pages.settings import *
|
from pages.settings import *
|
||||||
|
from pages.timetable import *
|
||||||
|
from pages.behaviour import *
|
||||||
|
from pages.attendance import *
|
||||||
from sdk.src.interfaces.prometheus.context import *
|
from sdk.src.interfaces.prometheus.context import *
|
||||||
from sdk.src.interfaces.prometheus.interface import *
|
from sdk.src.interfaces.prometheus.interface import *
|
||||||
|
|
||||||
|
@ -45,14 +46,11 @@ def sync():
|
||||||
student = int(keyring.get_password("Fuji", "Student_Index"))
|
student = int(keyring.get_password("Fuji", "Student_Index"))
|
||||||
interface.select_student(students[student].context)
|
interface.select_student(students[student].context)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
auth_context = interface.get_auth_context()
|
auth_context = interface.get_auth_context()
|
||||||
jsoncontext = auth_context.model_dump_json()
|
jsoncontext = auth_context.model_dump_json()
|
||||||
saveauth("Fuji", "Auth Context", jsoncontext)
|
saveauth("Fuji", "Auth Context", jsoncontext)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def loadauth(service, username):
|
def loadauth(service, username):
|
||||||
try:
|
try:
|
||||||
count = int(keyring.get_password(service, f"{username}_count"))
|
count = int(keyring.get_password(service, f"{username}_count"))
|
||||||
|
@ -62,8 +60,7 @@ def loadauth(service, username):
|
||||||
|
|
||||||
|
|
||||||
def main(page: ft.Page):
|
def main(page: ft.Page):
|
||||||
#run Page settings
|
# Page settings
|
||||||
|
|
||||||
page.title = "Fuji"
|
page.title = "Fuji"
|
||||||
page.theme = ft.Theme(
|
page.theme = ft.Theme(
|
||||||
color_scheme_seed=ft.Colors.RED,
|
color_scheme_seed=ft.Colors.RED,
|
||||||
|
@ -74,12 +71,12 @@ def main(page: ft.Page):
|
||||||
windows=ft.PageTransitionTheme.NONE
|
windows=ft.PageTransitionTheme.NONE
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
# Sync
|
|
||||||
|
|
||||||
|
# Sync
|
||||||
s = threading.Thread(target=sync)
|
s = threading.Thread(target=sync)
|
||||||
s.start()
|
s.start()
|
||||||
|
|
||||||
# Page routing
|
# Page routing
|
||||||
def change_page(route):
|
def change_page(route):
|
||||||
routes = {
|
routes = {
|
||||||
"/": HomePage(),
|
"/": HomePage(),
|
||||||
|
@ -103,6 +100,7 @@ def main(page: ft.Page):
|
||||||
def on_route_change(e):
|
def on_route_change(e):
|
||||||
change_page(e.route)
|
change_page(e.route)
|
||||||
|
|
||||||
|
# Navigation bar
|
||||||
bar = ft.NavigationRail(
|
bar = ft.NavigationRail(
|
||||||
selected_index=0,
|
selected_index=0,
|
||||||
label_type=ft.NavigationRailLabelType.ALL,
|
label_type=ft.NavigationRailLabelType.ALL,
|
||||||
|
@ -137,6 +135,7 @@ def main(page: ft.Page):
|
||||||
|
|
||||||
|
|
||||||
def login(page: ft.Page):
|
def login(page: ft.Page):
|
||||||
|
# Page settings
|
||||||
page.title = "Log in"
|
page.title = "Log in"
|
||||||
page.theme = ft.Theme(
|
page.theme = ft.Theme(
|
||||||
color_scheme_seed=ft.Colors.RED,
|
color_scheme_seed=ft.Colors.RED,
|
||||||
|
@ -153,6 +152,7 @@ def login(page: ft.Page):
|
||||||
interface = None
|
interface = None
|
||||||
data = {"usr": None, "passwd": None}
|
data = {"usr": None, "passwd": None}
|
||||||
|
|
||||||
|
# Saving credentials
|
||||||
def changeusr(e):
|
def changeusr(e):
|
||||||
global usr
|
global usr
|
||||||
|
|
||||||
|
@ -165,6 +165,7 @@ def login(page: ft.Page):
|
||||||
data["passwd"] = e.control.value
|
data["passwd"] = e.control.value
|
||||||
#print(passwd)
|
#print(passwd)
|
||||||
|
|
||||||
|
# Login event
|
||||||
def loginev(e):
|
def loginev(e):
|
||||||
global interface
|
global interface
|
||||||
|
|
||||||
|
@ -178,6 +179,7 @@ def login(page: ft.Page):
|
||||||
else:
|
else:
|
||||||
print("No credentials!")
|
print("No credentials!")
|
||||||
|
|
||||||
|
# Students fetching, dropdown and selection
|
||||||
def students():
|
def students():
|
||||||
global interface
|
global interface
|
||||||
|
|
||||||
|
@ -215,7 +217,7 @@ def login(page: ft.Page):
|
||||||
return dropdown
|
return dropdown
|
||||||
|
|
||||||
|
|
||||||
|
# Page routing
|
||||||
def route_change(route):
|
def route_change(route):
|
||||||
page.views.clear()
|
page.views.clear()
|
||||||
|
|
||||||
|
@ -357,6 +359,7 @@ def login(page: ft.Page):
|
||||||
page.go("/login")
|
page.go("/login")
|
||||||
|
|
||||||
|
|
||||||
|
# App configuration
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
try:
|
try:
|
||||||
with open("config.json", "r") as file:
|
with open("config.json", "r") as file:
|
||||||
|
|
Loading…
Add table
Reference in a new issue