|
|
|
|
@ -110,12 +110,29 @@ def page_login() -> None:
|
|
|
|
|
|
|
|
|
|
if app.storage.user.get('authenticated', False): |
|
|
|
|
return RedirectResponse('/') |
|
|
|
|
ui.add_head_html(''' |
|
|
|
|
<link rel="manifest" href="/manifest.json"> |
|
|
|
|
''') |
|
|
|
|
with ui.card().classes('absolute-center items-center'): |
|
|
|
|
ui.image('assets/logo.svg') |
|
|
|
|
ui.label('Let\'s Swing Admin').classes('text-2xl') |
|
|
|
|
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) |
|
|
|
|
|
|
|
|
|
ui.add_body_html('''<script>if ('serviceWorker' in navigator) { |
|
|
|
|
window.addEventListener('load', function() { |
|
|
|
|
navigator.serviceWorker.register('/static/service-worker.js').then(function(registration) { |
|
|
|
|
// Registration was successful |
|
|
|
|
console.log('ServiceWorker registration successful with scope: ', registration.scope); |
|
|
|
|
}, function(err) { |
|
|
|
|
// registration failed :( |
|
|
|
|
console.log('ServiceWorker registration failed: ', err); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
}</script>''') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# PWA conversion |
|
|
|
|
@ui.page('/manifest.json') |
|
|
|
|
def manifest_json() -> None: |
|
|
|
|
|