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
|
2021-03-19 19:57:04 +00:00
|
|
|
|
|
|
|
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
|
2021-03-19 19:57:04 +00:00
|
|
|
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
|
2021-03-19 19:57:04 +00:00
|
|
|
placeholderText: qsTr("Username")
|
2021-03-07 15:26:13 +00:00
|
|
|
EnterKey.type: Qt.EnterKeyNext
|
|
|
|
}
|
|
|
|
TextField {
|
|
|
|
id: passwordField
|
|
|
|
width: parent.width
|
2021-03-19 19:57:04 +00:00
|
|
|
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
|
|
|
|
}
|
|
|
|
}
|
2021-03-19 19:57:04 +00:00
|
|
|
|
|
|
|
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
|
|
|
}
|