arreglando script de solicitud de permisos
Browse files- app/main.py +18 -18
app/main.py
CHANGED
|
@@ -135,13 +135,13 @@ if bot:
|
|
| 135 |
|
| 136 |
def main(page: ft.Page):
|
| 137 |
page.title = "MAKERSPACE DATABASE"
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
|
| 146 |
def mostrar_notificacion(texto, color="blue"):
|
| 147 |
# Notificación en la app (SnackBar)
|
|
@@ -149,15 +149,15 @@ def main(page: ft.Page):
|
|
| 149 |
page.overlay.append(snack)
|
| 150 |
snack.open = True
|
| 151 |
|
| 152 |
-
# Notificación de Sistema/Navegador
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
|
| 162 |
page.update()
|
| 163 |
|
|
@@ -207,7 +207,7 @@ def main(page: ft.Page):
|
|
| 207 |
content=ft.Column([
|
| 208 |
ft.Text(f"ESTADO: {i.get('status_loan', 'PENDING')}", color=status_color, weight="bold"),
|
| 209 |
ft.Divider(),
|
| 210 |
-
ft.Text(f"
|
| 211 |
ft.Text(f"ITEM: {i['item']}", weight="bold"),
|
| 212 |
ft.Text(f"CANTIDAD: {i['cantidad']}"),
|
| 213 |
ft.Divider(),
|
|
@@ -359,7 +359,7 @@ def main(page: ft.Page):
|
|
| 359 |
ft.Row([
|
| 360 |
ft.Text("SOLICITAR PRÉSTAMO", size=18, weight="bold"),
|
| 361 |
ft.ElevatedButton("🔔 ACTIVAR ALERTAS", icon=ft.Icons.NOTIFICATIONS_ACTIVE,
|
| 362 |
-
on_click=
|
| 363 |
], alignment=ft.MainAxisAlignment.SPACE_BETWEEN),
|
| 364 |
|
| 365 |
nombre,
|
|
|
|
| 135 |
|
| 136 |
def main(page: ft.Page):
|
| 137 |
page.title = "MAKERSPACE DATABASE"
|
| 138 |
+
# Solicitar permiso para notificaciones de navegador/sistema (vía JS)
|
| 139 |
+
def pedir_permiso_notif(e=None):
|
| 140 |
+
page.run_javascript("""
|
| 141 |
+
if ("Notification" in window) {
|
| 142 |
+
Notification.requestPermission();
|
| 143 |
+
}
|
| 144 |
+
""")
|
| 145 |
|
| 146 |
def mostrar_notificacion(texto, color="blue"):
|
| 147 |
# Notificación en la app (SnackBar)
|
|
|
|
| 149 |
page.overlay.append(snack)
|
| 150 |
snack.open = True
|
| 151 |
|
| 152 |
+
# Notificación de Sistema/Navegador (vía JS)
|
| 153 |
+
page.run_javascript(f"""
|
| 154 |
+
if ("Notification" in window && Notification.permission === "granted") {{
|
| 155 |
+
new Notification("MAKER STATION", {{
|
| 156 |
+
body: "{texto}",
|
| 157 |
+
icon: "/icon192x192.png"
|
| 158 |
+
}});
|
| 159 |
+
}}
|
| 160 |
+
""")
|
| 161 |
|
| 162 |
page.update()
|
| 163 |
|
|
|
|
| 207 |
content=ft.Column([
|
| 208 |
ft.Text(f"ESTADO: {i.get('status_loan', 'PENDING')}", color=status_color, weight="bold"),
|
| 209 |
ft.Divider(),
|
| 210 |
+
ft.Text(f"SOLICITANTE: {i.get('Solicitante', i.get('alumno', '---'))}", size=16),
|
| 211 |
ft.Text(f"ITEM: {i['item']}", weight="bold"),
|
| 212 |
ft.Text(f"CANTIDAD: {i['cantidad']}"),
|
| 213 |
ft.Divider(),
|
|
|
|
| 359 |
ft.Row([
|
| 360 |
ft.Text("SOLICITAR PRÉSTAMO", size=18, weight="bold"),
|
| 361 |
ft.ElevatedButton("🔔 ACTIVAR ALERTAS", icon=ft.Icons.NOTIFICATIONS_ACTIVE,
|
| 362 |
+
on_click=pedir_permiso_notif, bgcolor=ft.Colors.BLUE_GREY_900)
|
| 363 |
], alignment=ft.MainAxisAlignment.SPACE_BETWEEN),
|
| 364 |
|
| 365 |
nombre,
|