Sending register, handling register result, sending login
This commit is contained in:
parent
89aa830bfa
commit
73e91e658f
15 changed files with 295 additions and 90 deletions
|
@ -1,8 +1,9 @@
|
|||
qt_add_qml_module(magpieForms
|
||||
URI "qml.Forms"
|
||||
URI magpie.Forms
|
||||
VERSION 1.0
|
||||
STATIC
|
||||
RESOURCE_PREFIX /
|
||||
OUTPUT_DIRECTORY ../magpie/Forms
|
||||
NO_PLUGIN
|
||||
QML_FILES
|
||||
Login.qml
|
||||
|
|
|
@ -2,10 +2,37 @@ import QtQuick
|
|||
import QtQuick.Controls
|
||||
|
||||
import magpie.API
|
||||
import magpie.Components as Components
|
||||
|
||||
Column {
|
||||
signal register()
|
||||
|
||||
function login(login, password) {
|
||||
if (modal.inProgress)
|
||||
return;
|
||||
|
||||
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");
|
||||
|
||||
if (!!result)
|
||||
modal.close();
|
||||
});
|
||||
}
|
||||
|
||||
spacing: 5
|
||||
|
||||
Label {
|
||||
|
@ -29,7 +56,7 @@ Column {
|
|||
}
|
||||
|
||||
TextField {
|
||||
id: login
|
||||
id: loginField
|
||||
}
|
||||
|
||||
Label {
|
||||
|
@ -37,7 +64,7 @@ Column {
|
|||
}
|
||||
|
||||
TextField {
|
||||
id: password
|
||||
id: passwordField
|
||||
echoMode: TextField.Password
|
||||
}
|
||||
}
|
||||
|
@ -45,9 +72,11 @@ Column {
|
|||
Button {
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
text: qsTr("Login")
|
||||
onClicked: function () {
|
||||
console.log("Not implemented");
|
||||
}
|
||||
onClicked: login(loginField.text, passwordField.text)
|
||||
}
|
||||
|
||||
Components.Modal {
|
||||
id: modal
|
||||
}
|
||||
|
||||
Row {
|
||||
|
|
|
@ -2,9 +2,11 @@ import QtQuick
|
|||
import QtQuick.Controls
|
||||
|
||||
import magpie.API
|
||||
import magpie.Components as Components
|
||||
|
||||
Column {
|
||||
signal login()
|
||||
signal success(login: string, password: string)
|
||||
|
||||
spacing: 5
|
||||
|
||||
|
@ -45,12 +47,35 @@ Column {
|
|||
Button {
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
text: qsTr("Register")
|
||||
onClicked: API.sendRegister(newLogin.text, newPassword.text, function (err, result) {
|
||||
if (err)
|
||||
console.error("err")
|
||||
onClicked: modal.check()
|
||||
}
|
||||
|
||||
console.log(result);
|
||||
})
|
||||
Components.Modal {
|
||||
id: modal
|
||||
function check () {
|
||||
if (inProgress)
|
||||
return;
|
||||
|
||||
inProgress = true;
|
||||
status = qsTr("Registering") + " " + newLogin.text + "...";
|
||||
open()
|
||||
|
||||
API.sendRegister(newLogin.text, newPassword.text, function (err, result) {
|
||||
if (!modal.inProgress)
|
||||
return;
|
||||
|
||||
modal.inProgress = false;
|
||||
if (err)
|
||||
modal.status = err;
|
||||
else
|
||||
modal.status = qsTr("Success");
|
||||
|
||||
if (!!result) {
|
||||
modal.close();
|
||||
success(newLogin.text, newPassword.text);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Row {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue