Browse Source

1.1.4

master
enne2 2 years ago
parent
commit
d7c2d12a55
  1. 25
      main.py

25
main.py

@ -114,8 +114,7 @@ def page_login() -> None:
ui.add_head_html('''
<link rel="manifest" href="/manifest.json">
''')
ui.add_body_html(''' <button id="btnAdd" style="display: none;">Install our app!</button>
ui.add_body_html('''
<script>
let deferredPrompt;
@ -128,25 +127,12 @@ def page_login() -> None:
btnAdd.style.display = 'block';
});
btnAdd.addEventListener('click', (e) => {
// hide our user interface that shows our A2HS button
btnAdd.style.display = 'none';
// Show the prompt
deferredPrompt.prompt();
// Wait for the user to respond to the prompt
deferredPrompt.userChoice.then((choiceResult) => {
if (choiceResult.outcome === 'accepted') {
console.log('User accepted the A2HS prompt');
} else {
console.log('User dismissed the A2HS prompt');
}
deferredPrompt = null;
});
});
</script>''')
async def alert():
await ui.run_javascript('''
// Show the prompt
if(!deferredPrompt)
alert("Browser non compatibile");
deferredPrompt.prompt();
// Wait for the user to respond to the prompt
deferredPrompt.userChoice.then((choiceResult) => {
@ -156,12 +142,13 @@ def page_login() -> None:
console.log('User dismissed the A2HS prompt');
}
deferredPrompt = null;
});''', respond=False)
with ui.card().classes('absolute-center items-center'):
ui.button('Install App', on_click=alert)
ui.button('Installa App', on_click=alert)
ui.image('assets/logo.svg')
ui.label('Let\'s Swing Admin').classes('text-2xl')
ui.label('Let\'s Swing Admin').classes('text-2xl').style("text-align:center")
username = ui.input('Username').on('keydown.enter', try_login).classes('w-full')
password = ui.input('Password', password=True, password_toggle_button=True).on('keydown.enter', try_login)
ui.button('Log in', on_click=try_login)

Loading…
Cancel
Save