1
0
Fork 0
forked from Fuji/Fuji

Add new pages for grades, timetable, homework, exams, attendance, behaviour, and settings; update navigation to support routing and improved login functionality ( that doesnt work )

This commit is contained in:
Maarceeli 2025-02-15 12:51:50 +01:00
parent ca98a9ac7a
commit d309906d3d
10 changed files with 159 additions and 100 deletions

View file

@ -4,6 +4,13 @@ import keyring
import pickle import pickle
import base64 import base64
from pages.home import * from pages.home import *
from pages.grades import *
from pages.timetable import *
from pages.homework import *
from pages.exams import *
from pages.attendance import *
from pages.behaviour import *
from pages.settings 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 *
@ -14,80 +21,77 @@ def loadauth(service, username):
except (TypeError, ValueError): except (TypeError, ValueError):
return None return None
def main(page: ft.Page): def main(page: ft.Page):
# 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,
font_family="Roboto", font_family="Roboto",
page_transitions=ft.PageTransitionsTheme( page_transitions=ft.PageTransitionsTheme(
android=ft.PageTransitionTheme.PREDICTIVE, macos=ft.PageTransitionTheme.NONE,
ios=ft.PageTransitionTheme.PREDICTIVE, linux=ft.PageTransitionTheme.NONE,
macos=ft.PageTransitionTheme.PREDICTIVE, windows=ft.PageTransitionTheme.NONE
linux=ft.PageTransitionTheme.PREDICTIVE,
windows=ft.PageTransitionTheme.PREDICTIVE
) )
) )
def changePage(index):
pages = [
# Home page
HomePage(),
# Grades page # Eduvulcan login
ft.Column([
ft.Text(" Grades", size=30, weight="bold"),
ft.Placeholder()
]),
# Timetable page interface = PrometheusInterface(
ft.Column([ auth_context=PrometheusAuthContext(
ft.Text(" Timetable", size=30, weight="bold"), prometheus_web_credentials=PrometheusWebCredentials(
ft.Placeholder() username=" ", password=" "
]), )
),
student_context=None,
)
# Homework page auth_context_raw = loadauth("Fuji", "Auth Context")
ft.Column([ auth_context = interface.get_auth_context()
ft.Text(" Homework", size=30, weight="bold"), auth_context.model_validate_json(auth_context_raw)
ft.Placeholder()
]),
# Exams page interface = PrometheusInterface(
ft.Column([ auth_context=auth_context,
ft.Text(" Exams", size=30, weight="bold"), student_context=None,
ft.Placeholder() )
]),
# Attendance page r = interface.login()
ft.Column([
ft.Text(" Attendance", size=30, weight="bold"),
ft.Placeholder()
]),
# Behaviour page if r:
ft.Column([ print(r)
ft.Text(" Behaviour Notes", size=30, weight="bold"), if not r:
ft.Placeholder() pass
]),
# Settings page students = interface.get_students()
ft.Column([
ft.Text(" Settings", size=30, weight="bold"),
ft.Placeholder()
]),
]
return pages[index]
# Function to switch content student = int(keyring.get_password("Fuji", "Student_Index"))
def update_content(index): interface.select_student(students[student].context)
main_container.content = changePage(index)
# Page routing
def change_page(route):
routes = {
"/": HomePage(),
"/grades": GradesPage(),
"/timetable": TimetablePage(),
"/homework": HomeworkPage(),
"/exams": ExamsPage(),
"/attendance": AttendancePage(),
"/behaviour": BehaviourPage(),
"/settings": SettingsPage()
}
page.views.clear()
page.views.append(ft.View(route, [
ft.Row([
bar,
ft.Container(content=routes.get(route, HomePage()), expand=True)
], expand=True)
]))
page.update() page.update()
# Initial content display container def on_route_change(e):
main_container = ft.Container( change_page(e.route)
content=changePage(0),
expand=True,
)
# Navigation Rail
bar = ft.NavigationRail( bar = ft.NavigationRail(
selected_index=0, selected_index=0,
label_type=ft.NavigationRailLabelType.ALL, label_type=ft.NavigationRailLabelType.ALL,
@ -96,43 +100,30 @@ def main(page: ft.Page):
min_extended_width=400, min_extended_width=400,
group_alignment=0, group_alignment=0,
destinations=[ destinations=[
ft.NavigationRailDestination( ft.NavigationRailDestination(icon=ft.Icons.HOME_OUTLINED, selected_icon=ft.Icons.HOME, label="Home"),
icon=ft.Icons.HOME_OUTLINED, selected_icon=ft.Icons.HOME, label="Home" ft.NavigationRailDestination(icon=ft.Icons.LOOKS_6_OUTLINED, selected_icon=ft.Icons.LOOKS_6, label="Grades"),
), ft.NavigationRailDestination(icon=ft.Icons.BACKPACK_OUTLINED, selected_icon=ft.Icons.BACKPACK, label="Timetable"),
ft.NavigationRailDestination( ft.NavigationRailDestination(icon=ft.Icons.BOOK_OUTLINED, selected_icon=ft.Icons.BOOK, label="Homework"),
icon=ft.Icons.LOOKS_6_OUTLINED, selected_icon=ft.Icons.LOOKS_6, label="Grades" ft.NavigationRailDestination(icon=ft.Icons.CALENDAR_TODAY_OUTLINED, selected_icon=ft.Icons.CALENDAR_TODAY, label="Exams"),
), ft.NavigationRailDestination(icon=ft.Icons.EVENT_NOTE_OUTLINED, selected_icon=ft.Icons.EVENT_NOTE, label="Attendance"),
ft.NavigationRailDestination( ft.NavigationRailDestination(icon=ft.Icons.STICKY_NOTE_2_OUTLINED, selected_icon=ft.Icons.STICKY_NOTE_2, label="Behaviour"),
icon=ft.Icons.BACKPACK_OUTLINED, selected_icon=ft.Icons.BACKPACK, label="Timetable" ft.NavigationRailDestination(icon=ft.Icons.SETTINGS_OUTLINED, selected_icon=ft.Icons.SETTINGS_ROUNDED, label="Settings"),
),
ft.NavigationRailDestination(
icon=ft.Icons.BOOK_OUTLINED, selected_icon=ft.Icons.BOOK, label="Homework"
),
ft.NavigationRailDestination(
icon=ft.Icons.CALENDAR_TODAY_OUTLINED, selected_icon=ft.Icons.CALENDAR_TODAY, label="Exams"
),
ft.NavigationRailDestination(
icon=ft.Icons.EVENT_NOTE_OUTLINED, selected_icon=ft.Icons.EVENT_NOTE, label="Attendance"
),
ft.NavigationRailDestination(
icon=ft.Icons.STICKY_NOTE_2_OUTLINED, selected_icon=ft.Icons.STICKY_NOTE_2, label="Behaviour"
),
ft.NavigationRailDestination(
icon=ft.Icons.SETTINGS_OUTLINED, selected_icon=ft.Icons.SETTINGS_ROUNDED, label="Settings"
),
], ],
on_change=lambda e: update_content(e.control.selected_index), on_change=lambda e: page.go([
"/",
"/grades",
"/timetable",
"/homework",
"/exams",
"/attendance",
"/behaviour",
"/settings"
][e.control.selected_index])
) )
page.add( page.on_route_change = on_route_change
ft.Row( page.go("/")
[
bar,
main_container,
],
expand=True,
)
)
def login(page: ft.Page): def login(page: ft.Page):
page.title = "Log in" page.title = "Log in"
@ -192,7 +183,10 @@ def login(page: ft.Page):
def on_change(e): def on_change(e):
selected_index = next((i for i, student in enumerate(students) if student.full_name == e.control.value), -1) selected_index = next((i for i, student in enumerate(students) if student.full_name == e.control.value), -1)
interface.select_student(students[selected_index].context) interface.select_student(students[selected_index].context)
keyring.set_password("Fuji", "Student_Index", str(selected_index))
auth_context = interface.get_auth_context() auth_context = interface.get_auth_context()
jsoncontext = auth_context.model_dump_json() jsoncontext = auth_context.model_dump_json()

9
src/pages/attendance.py Normal file
View file

@ -0,0 +1,9 @@
import flet as ft
def AttendancePage():
return ft.Column([
ft.Text(" Attendance", size=30, weight="bold"),
ft.Placeholder()
])

9
src/pages/behaviour.py Normal file
View file

@ -0,0 +1,9 @@
import flet as ft
def BehaviourPage():
return ft.Column([
ft.Text(" Behaviour", size=30, weight="bold"),
ft.Placeholder()
])

9
src/pages/exams.py Normal file
View file

@ -0,0 +1,9 @@
import flet as ft
def ExamsPage():
return ft.Column([
ft.Text(" Exams", size=30, weight="bold"),
ft.Placeholder()
])

9
src/pages/grades.py Normal file
View file

@ -0,0 +1,9 @@
import flet as ft
def GradesPage():
return ft.Column([
ft.Text(" Grades", size=30, weight="bold"),
ft.Placeholder()
])

9
src/pages/homework.py Normal file
View file

@ -0,0 +1,9 @@
import flet as ft
def HomeworkPage():
return ft.Column([
ft.Text(" Homework", size=30, weight="bold"),
ft.Placeholder()
])

9
src/pages/settings.py Normal file
View file

@ -0,0 +1,9 @@
import flet as ft
def SettingsPage():
return ft.Column([
ft.Text(" Settings", size=30, weight="bold"),
ft.Placeholder()
])

9
src/pages/timetable.py Normal file
View file

@ -0,0 +1,9 @@
import flet as ft
def TimetablePage():
return ft.Column([
ft.Text(" Timetable", size=30, weight="bold"),
ft.Placeholder()
])

View file

@ -57,6 +57,7 @@ class PrometheusWebClient:
"alias": username, "alias": username,
"__RequestVerificationToken": request_verification_token, "__RequestVerificationToken": request_verification_token,
}, },
headers=HEADERS,
) )
data = response.json()["data"] data = response.json()["data"]
return data["ExtraMessage"], data["ShowCaptcha"] return data["ExtraMessage"], data["ShowCaptcha"]

View file

@ -73,6 +73,7 @@ class PrometheusInterface(CoreInterface):
def login(self, captcha: str | None = None): def login(self, captcha: str | None = None):
if not self._prometheus_web_client.is_logged(): if not self._prometheus_web_client.is_logged():
result = self._login_prometheus(captcha) result = self._login_prometheus(captcha)
print("dupa")
if result: if result:
return result return result
self._efeb_clients = {} self._efeb_clients = {}