2023-12-27 20:59:22 +00:00
|
|
|
// SPDX-FileCopyrightText: 2023 Yury Gubich <blue@macaw.me>
|
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
2023-12-17 00:06:04 +00:00
|
|
|
import QtQuick
|
|
|
|
import QtQuick.Controls
|
|
|
|
|
|
|
|
import magpie.API
|
2023-12-21 18:03:44 +00:00
|
|
|
import magpie.Components as Components
|
2023-12-17 00:06:04 +00:00
|
|
|
|
|
|
|
Column {
|
|
|
|
signal register()
|
2023-12-26 23:31:55 +00:00
|
|
|
signal loggingIn(value: bool)
|
2023-12-17 00:06:04 +00:00
|
|
|
|
2023-12-21 18:03:44 +00:00
|
|
|
function login(login, password) {
|
|
|
|
if (modal.inProgress)
|
|
|
|
return;
|
|
|
|
|
2023-12-26 23:31:55 +00:00
|
|
|
loggingIn(true);
|
2023-12-21 18:03:44 +00:00
|
|
|
loginField.text = login;
|
|
|
|
passwordField.text = password;
|
|
|
|
|
|
|
|
modal.inProgress = true;
|
|
|
|
modal.status = qsTr("Logging in as") + " " + login + "...";
|
|
|
|
modal.open();
|
|
|
|
|
|
|
|
API.sendLogin(login, password, function (err, result) {
|
|
|
|
if (!modal.inProgress)
|
|
|
|
return;
|
|
|
|
|
|
|
|
modal.inProgress = false;
|
|
|
|
if (err)
|
|
|
|
modal.status = err;
|
|
|
|
else
|
|
|
|
modal.status = qsTr("Success");
|
|
|
|
|
2023-12-26 23:31:55 +00:00
|
|
|
loggingIn(false);
|
2023-12-21 18:03:44 +00:00
|
|
|
if (!!result)
|
|
|
|
modal.close();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2023-12-17 20:10:27 +00:00
|
|
|
spacing: 5
|
2023-12-17 00:06:04 +00:00
|
|
|
|
|
|
|
Label {
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
text: qsTr("Please, log in to your account")
|
|
|
|
font {
|
|
|
|
pixelSize: 14
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Grid {
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
columns: 2
|
|
|
|
columnSpacing: 10
|
|
|
|
rowSpacing: 5
|
|
|
|
verticalItemAlignment: Grid.AlignVCenter
|
|
|
|
horizontalItemAlignment: Grid.AlignRight
|
|
|
|
|
|
|
|
Label {
|
|
|
|
text: qsTr("Login") + ":";
|
|
|
|
}
|
|
|
|
|
|
|
|
TextField {
|
2023-12-21 18:03:44 +00:00
|
|
|
id: loginField
|
2023-12-17 00:06:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Label {
|
|
|
|
text: qsTr("Password") + ":";
|
|
|
|
}
|
|
|
|
|
|
|
|
TextField {
|
2023-12-21 18:03:44 +00:00
|
|
|
id: passwordField
|
2023-12-17 00:06:04 +00:00
|
|
|
echoMode: TextField.Password
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Button {
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
text: qsTr("Login")
|
2023-12-21 18:03:44 +00:00
|
|
|
onClicked: login(loginField.text, passwordField.text)
|
|
|
|
}
|
|
|
|
|
|
|
|
Components.Modal {
|
|
|
|
id: modal
|
2023-12-17 00:06:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Row {
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
spacing: 5
|
|
|
|
topPadding: 10
|
|
|
|
|
|
|
|
Label {
|
|
|
|
text: qsTr("Don't have account?")
|
|
|
|
}
|
|
|
|
Label {
|
|
|
|
text: qsTr("Sign up") + "!"
|
|
|
|
font {
|
|
|
|
italic: true
|
|
|
|
underline: true
|
|
|
|
}
|
|
|
|
|
|
|
|
MouseArea {
|
|
|
|
anchors.fill: parent
|
|
|
|
onClicked: register()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|