1
0
Fork 0
mirror of https://github.com/HenkKalkwater/harbour-sailfin.git synced 2024-11-01 07:35:17 +00:00
harbour-sailfin/qtquick/qml/pages/setup/LoginPage.qml

82 lines
2 KiB
QML
Raw Normal View History

2021-03-07 15:26:13 +00:00
import QtQuick 2.12
import QtQuick.Controls 2.12
2021-03-24 19:04:03 +00:00
import nl.netsoj.chris.Jellyfin 1.0 as J
import "../../components"
2021-03-07 15:26:13 +00:00
import "../../.."
2021-03-24 19:04:03 +00:00
import "../.."
2021-03-07 15:26:13 +00:00
Page {
property string loginMessage
property StackView stackView: StackView.view
2021-03-07 15:26:13 +00:00
header: ToolBar {
Label {
anchors.horizontalCenter: parent.horizontalCenter
font.pixelSize: SailfinStyle.fontSizeLarge
text: qsTr("Log in")
}
}
Column {
anchors.horizontalCenter: parent.horizontalCenter
width: Math.min(80 * SailfinStyle.unit, parent.width - SailfinStyle.largePadding * 2)
spacing: SailfinStyle.mediumPadding
TextField {
id: usernameField
width: parent.width
placeholderText: qsTr("Username")
2021-03-07 15:26:13 +00:00
EnterKey.type: Qt.EnterKeyNext
}
TextField {
id: passwordField
width: parent.width
placeholderText: qsTr("Password")
echoMode: TextInput.Password
}
Label {
id: loginError
width: parent.width
wrapMode: Text.WordWrap
text: qsTr("Invalid username/password")
visible: false
}
Button {
text: qsTr("Login")
onClicked: login()
2021-03-07 15:26:13 +00:00
}
Label {
width: parent.width
text: loginMessage
wrapMode: Text.WordWrap
}
}
BusyDialog {
id: busyDialog
anchors.centerIn: Overlay.overlay
title: qsTr("Logging in as %1").arg(usernameField.text)
}
function login() {
busyDialog.open()
ApiClient.authenticate(usernameField.text, passwordField.text, true)
}
Connections {
target: ApiClient
onAuthenticatedChanged: {
busyDialog.close()
if (authenticated) {
stackView.replace(null, Qt.resolvedUrl("../MainPage.qml"), {})
}
}
onAuthenticationError: {
busyDialog.close()
loginError.visible = true
}
}
2021-03-07 15:26:13 +00:00
}