some improvements in the cloud login
This commit is contained in:
parent
a443e0f712
commit
4381b70a2f
@ -40,22 +40,41 @@ void NymeaDiscovery::setDiscovering(bool discovering)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
m_discovering = discovering;
|
m_discovering = discovering;
|
||||||
// For zeroconf we'll ignore it as zeroconf doesn't do active discovery but just listens for changes in the net all the time
|
// If we have zeroconf skip upnp. ZeroConf will not do an active discovery and if it's available it'll always have good data
|
||||||
|
if (!m_zeroConf->available()) {
|
||||||
|
if (discovering) {
|
||||||
|
m_upnp->discover();
|
||||||
|
} else {
|
||||||
|
m_upnp->stopDiscovery();
|
||||||
|
}
|
||||||
|
}
|
||||||
if (discovering) {
|
if (discovering) {
|
||||||
m_upnp->discover();
|
// If there's no Zeroconf, use UPnP instead
|
||||||
|
if (!m_zeroConf->available()) {
|
||||||
|
m_upnp->discover();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Always start Bluetooth discovery if HW is available
|
||||||
if (m_bluetooth) {
|
if (m_bluetooth) {
|
||||||
m_bluetooth->discover();
|
m_bluetooth->discover();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// start polling cloud
|
||||||
|
m_cloudPollTimer.start();
|
||||||
|
// If we're logged in, poll right away
|
||||||
if (Engine::instance()->awsClient()->isLoggedIn()) {
|
if (Engine::instance()->awsClient()->isLoggedIn()) {
|
||||||
syncCloudDevices();
|
syncCloudDevices();
|
||||||
Engine::instance()->awsClient()->fetchDevices();
|
Engine::instance()->awsClient()->fetchDevices();
|
||||||
}
|
}
|
||||||
m_cloudPollTimer.start();
|
|
||||||
} else {
|
} else {
|
||||||
m_upnp->stopDiscovery();
|
if (!m_zeroConf->available()) {
|
||||||
|
m_upnp->stopDiscovery();
|
||||||
|
}
|
||||||
|
|
||||||
if (m_bluetooth) {
|
if (m_bluetooth) {
|
||||||
m_bluetooth->stopDiscovery();
|
m_bluetooth->stopDiscovery();
|
||||||
}
|
}
|
||||||
|
|
||||||
m_cloudPollTimer.stop();
|
m_cloudPollTimer.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -376,6 +376,7 @@ ApplicationWindow {
|
|||||||
}
|
}
|
||||||
|
|
||||||
KeyboardLoader {
|
KeyboardLoader {
|
||||||
|
id: keyboardRect
|
||||||
anchors { left: parent.left; bottom: parent.bottom; right: parent.right }
|
anchors { left: parent.left; bottom: parent.bottom; right: parent.right }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -154,13 +154,29 @@ Page {
|
|||||||
Layout.leftMargin: app.margins; Layout.rightMargin: app.margins; Layout.topMargin: app.margins
|
Layout.leftMargin: app.margins; Layout.rightMargin: app.margins; Layout.topMargin: app.margins
|
||||||
text: qsTr("Password")
|
text: qsTr("Password")
|
||||||
}
|
}
|
||||||
TextField {
|
RowLayout {
|
||||||
id: passwordTextField
|
|
||||||
Layout.leftMargin: app.margins; Layout.rightMargin: app.margins
|
Layout.leftMargin: app.margins; Layout.rightMargin: app.margins
|
||||||
Layout.fillWidth: true
|
TextField {
|
||||||
echoMode: TextInput.Password
|
id: passwordTextField
|
||||||
|
Layout.fillWidth: true
|
||||||
|
echoMode: hiddenPassword ? TextInput.Password : TextInput.Normal
|
||||||
|
property bool hiddenPassword: true
|
||||||
|
}
|
||||||
|
ColorIcon {
|
||||||
|
Layout.preferredHeight: app.iconSize
|
||||||
|
Layout.preferredWidth: app.iconSize
|
||||||
|
name: "../images/eye.svg"
|
||||||
|
color: passwordTextField.hiddenPassword ? keyColor : app.accentColor
|
||||||
|
MouseArea {
|
||||||
|
anchors.fill: parent
|
||||||
|
onClicked: {
|
||||||
|
passwordTextField.hiddenPassword = !passwordTextField.hiddenPassword
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Button {
|
Button {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.leftMargin: app.margins; Layout.rightMargin: app.margins; Layout.topMargin: app.margins
|
Layout.leftMargin: app.margins; Layout.rightMargin: app.margins; Layout.topMargin: app.margins
|
||||||
@ -225,81 +241,87 @@ Page {
|
|||||||
onBackPressed: pageStack.pop()
|
onBackPressed: pageStack.pop()
|
||||||
}
|
}
|
||||||
|
|
||||||
ColumnLayout {
|
Flickable {
|
||||||
anchors { left: parent.left; top: parent.top; right: parent.right }
|
anchors.fill: parent
|
||||||
|
contentHeight: signupColumn.height
|
||||||
|
interactive: contentHeight > height
|
||||||
|
|
||||||
Label {
|
ColumnLayout {
|
||||||
Layout.fillWidth: true
|
id: signupColumn
|
||||||
Layout.leftMargin: app.margins; Layout.rightMargin: app.margins; Layout.topMargin: app.margins
|
anchors { left: parent.left; top: parent.top; right: parent.right }
|
||||||
wrapMode: Text.WordWrap
|
|
||||||
text: qsTr("Welcome to %1:cloud.").arg(app.systemName)
|
|
||||||
color: app.accentColor
|
|
||||||
font.pixelSize: app.largeFont
|
|
||||||
}
|
|
||||||
|
|
||||||
Label {
|
Label {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.leftMargin: app.margins; Layout.rightMargin: app.margins; Layout.topMargin: app.margins
|
Layout.leftMargin: app.margins; Layout.rightMargin: app.margins; Layout.topMargin: app.margins
|
||||||
wrapMode: Text.WordWrap
|
wrapMode: Text.WordWrap
|
||||||
text: qsTr("Please enter your email address and pick a password in order to create a new account.")
|
text: qsTr("Welcome to %1:cloud.").arg(app.systemName)
|
||||||
}
|
color: app.accentColor
|
||||||
|
font.pixelSize: app.largeFont
|
||||||
Label {
|
|
||||||
Layout.fillWidth: true
|
|
||||||
Layout.leftMargin: app.margins; Layout.rightMargin: app.margins; Layout.topMargin: app.margins
|
|
||||||
text: "Username (e-mail)"
|
|
||||||
}
|
|
||||||
TextField {
|
|
||||||
id: usernameTextField
|
|
||||||
Layout.fillWidth: true
|
|
||||||
Layout.leftMargin: app.margins; Layout.rightMargin: app.margins
|
|
||||||
placeholderText: "john.smith@cooldomain.com"
|
|
||||||
inputMethodHints: Qt.ImhEmailCharactersOnly
|
|
||||||
validator: RegExpValidator { regExp:/\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/ }
|
|
||||||
}
|
|
||||||
Label {
|
|
||||||
Layout.fillWidth: true
|
|
||||||
Layout.leftMargin: app.margins; Layout.rightMargin: app.margins; Layout.topMargin: app.margins
|
|
||||||
text: qsTr("Password")
|
|
||||||
}
|
|
||||||
AWSPasswordTextField {
|
|
||||||
id: passwordTextField
|
|
||||||
Layout.leftMargin: app.margins; Layout.rightMargin: app.margins
|
|
||||||
Layout.fillWidth: true
|
|
||||||
}
|
|
||||||
|
|
||||||
Button {
|
|
||||||
Layout.fillWidth: true
|
|
||||||
Layout.leftMargin: app.margins; Layout.rightMargin: app.margins; Layout.topMargin: app.margins
|
|
||||||
text: qsTr("Sign Up")
|
|
||||||
enabled: usernameTextField.acceptableInput && passwordTextField.isValidPassword
|
|
||||||
onClicked: {
|
|
||||||
Engine.awsClient.signup(usernameTextField.text, passwordTextField.password)
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
Connections {
|
Label {
|
||||||
target: Engine.awsClient
|
Layout.fillWidth: true
|
||||||
onSignupResult: {
|
Layout.leftMargin: app.margins; Layout.rightMargin: app.margins; Layout.topMargin: app.margins
|
||||||
switch (error) {
|
wrapMode: Text.WordWrap
|
||||||
case AWSClient.LoginErrorNoError:
|
text: qsTr("Please enter your email address and pick a password in order to create a new account.")
|
||||||
signUpResultLabel.text = ""
|
}
|
||||||
pageStack.push(enterCodeComponent)
|
|
||||||
break;
|
Label {
|
||||||
case AWSClient.LoginErrorInvalidUserOrPass:
|
Layout.fillWidth: true
|
||||||
signUpResultLabel.text = qsTr("The given username or password are not valid.")
|
Layout.leftMargin: app.margins; Layout.rightMargin: app.margins; Layout.topMargin: app.margins
|
||||||
break;
|
text: "Username (e-mail)"
|
||||||
default:
|
}
|
||||||
signUpResultLabel.text = qsTr("Uh oh, something went wrong. Please try again.")
|
TextField {
|
||||||
|
id: usernameTextField
|
||||||
|
Layout.fillWidth: true
|
||||||
|
Layout.leftMargin: app.margins; Layout.rightMargin: app.margins
|
||||||
|
placeholderText: "john.smith@cooldomain.com"
|
||||||
|
inputMethodHints: Qt.ImhEmailCharactersOnly
|
||||||
|
validator: RegExpValidator { regExp:/\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/ }
|
||||||
|
}
|
||||||
|
Label {
|
||||||
|
Layout.fillWidth: true
|
||||||
|
Layout.leftMargin: app.margins; Layout.rightMargin: app.margins; Layout.topMargin: app.margins
|
||||||
|
text: qsTr("Password")
|
||||||
|
}
|
||||||
|
AWSPasswordTextField {
|
||||||
|
id: passwordTextField
|
||||||
|
Layout.leftMargin: app.margins; Layout.rightMargin: app.margins
|
||||||
|
Layout.fillWidth: true
|
||||||
|
}
|
||||||
|
|
||||||
|
Button {
|
||||||
|
Layout.fillWidth: true
|
||||||
|
Layout.leftMargin: app.margins; Layout.rightMargin: app.margins; Layout.topMargin: app.margins
|
||||||
|
text: qsTr("Sign Up")
|
||||||
|
enabled: usernameTextField.acceptableInput && passwordTextField.isValidPassword
|
||||||
|
onClicked: {
|
||||||
|
busyOverlay.shown = true;
|
||||||
|
Engine.awsClient.signup(usernameTextField.text, passwordTextField.password)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Label {
|
|
||||||
id: signUpResultLabel
|
Connections {
|
||||||
Layout.fillWidth: true
|
target: Engine.awsClient
|
||||||
Layout.leftMargin: app.margins; Layout.rightMargin: app.margins; Layout.topMargin: app.margins
|
onSignupResult: {
|
||||||
wrapMode: Text.WordWrap
|
busyOverlay.shown = false;
|
||||||
|
var text;
|
||||||
|
switch (error) {
|
||||||
|
case AWSClient.LoginErrorNoError:
|
||||||
|
pageStack.push(enterCodeComponent)
|
||||||
|
return;
|
||||||
|
case AWSClient.LoginErrorInvalidUserOrPass:
|
||||||
|
text = qsTr("The given username or password are not valid.")
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
text = qsTr("Uh oh, something went wrong. Please try again.")
|
||||||
|
}
|
||||||
|
var errorDialog = Qt.createComponent(Qt.resolvedUrl("../components/ErrorDialog.qml"));
|
||||||
|
var popup = errorDialog.createObject(app, {text: text})
|
||||||
|
popup.open()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -335,6 +357,7 @@ Page {
|
|||||||
Layout.leftMargin: app.margins; Layout.rightMargin: app.margins; Layout.topMargin: app.margins
|
Layout.leftMargin: app.margins; Layout.rightMargin: app.margins; Layout.topMargin: app.margins
|
||||||
text: qsTr("OK")
|
text: qsTr("OK")
|
||||||
onClicked: {
|
onClicked: {
|
||||||
|
busyOverlay.shown = true;
|
||||||
Engine.awsClient.confirmRegistration(confirmationCodeTextField.text)
|
Engine.awsClient.confirmRegistration(confirmationCodeTextField.text)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -342,29 +365,28 @@ Page {
|
|||||||
Connections {
|
Connections {
|
||||||
target: Engine.awsClient
|
target: Engine.awsClient
|
||||||
onConfirmationResult: {
|
onConfirmationResult: {
|
||||||
|
busyOverlay.shown = false;
|
||||||
|
var text
|
||||||
switch (error) {
|
switch (error) {
|
||||||
case AWSClient.LoginErrorNoError:
|
case AWSClient.LoginErrorNoError:
|
||||||
confirmResultLabel.text = ""
|
|
||||||
pageStack.pop(root)
|
pageStack.pop(root)
|
||||||
break;
|
return;
|
||||||
case AWSClient.LoginErrorUserExists:
|
case AWSClient.LoginErrorUserExists:
|
||||||
confirmResultLabel.text = qsTr("The given user already exists. Did you forget the password?")
|
text = qsTr("The given user already exists. Did you forget the password?")
|
||||||
break;
|
break;
|
||||||
case AWSClient.LoginErrorInvalidCode:
|
case AWSClient.LoginErrorInvalidCode:
|
||||||
confirmResultLabel.text = qsTr("That wasn't the right code. Please try again.")
|
text = qsTr("That wasn't the right code. Please try again.")
|
||||||
break;
|
break;
|
||||||
case AWSClient.LoginErrorUnknownError:
|
case AWSClient.LoginErrorUnknownError:
|
||||||
confirmResultLabel.text = qsTr("Uh oh, something went wrong. Please try again.")
|
text = qsTr("Uh oh, something went wrong. Please try again.")
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
var errorDialog = Qt.createComponent(Qt.resolvedUrl("../components/ErrorDialog.qml"));
|
||||||
}
|
var popup = errorDialog.createObject(app, {text: text})
|
||||||
|
popup.open()
|
||||||
|
return;
|
||||||
|
|
||||||
Label {
|
}
|
||||||
id: confirmResultLabel
|
|
||||||
Layout.fillWidth: true
|
|
||||||
Layout.leftMargin: app.margins; Layout.rightMargin: app.margins; Layout.topMargin: app.margins
|
|
||||||
wrapMode: Text.WordWrap
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,13 +16,31 @@ ColumnLayout {
|
|||||||
readonly property bool hasSpecialChar: passwordTextField.text.search(/[\*!"$%&/()=?`'+#'¡^°²³¼\[\]|{}\\@]/) >= 0
|
readonly property bool hasSpecialChar: passwordTextField.text.search(/[\*!"$%&/()=?`'+#'¡^°²³¼\[\]|{}\\@]/) >= 0
|
||||||
readonly property bool confirmationMatches: passwordTextField.text === confirmationPasswordTextField.text
|
readonly property bool confirmationMatches: passwordTextField.text === confirmationPasswordTextField.text
|
||||||
|
|
||||||
TextField {
|
property bool hiddenPassword: true
|
||||||
id: passwordTextField
|
|
||||||
Layout.fillWidth: true
|
RowLayout {
|
||||||
echoMode: TextInput.Password
|
|
||||||
placeholderText: qsTr("Pick a password")
|
TextField {
|
||||||
|
id: passwordTextField
|
||||||
|
Layout.fillWidth: true
|
||||||
|
echoMode: root.hiddenPassword ? TextInput.Password : TextInput.Normal
|
||||||
|
placeholderText: qsTr("Pick a password")
|
||||||
|
}
|
||||||
|
ColorIcon {
|
||||||
|
Layout.preferredHeight: app.iconSize
|
||||||
|
Layout.preferredWidth: app.iconSize
|
||||||
|
name: "../images/eye.svg"
|
||||||
|
color: root.hiddenPassword ? keyColor : app.accentColor
|
||||||
|
MouseArea {
|
||||||
|
anchors.fill: parent
|
||||||
|
onClicked: {
|
||||||
|
root.hiddenPassword = !root.hiddenPassword
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Label {
|
Label {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
wrapMode: Text.WordWrap
|
wrapMode: Text.WordWrap
|
||||||
@ -38,13 +56,30 @@ ColumnLayout {
|
|||||||
font.pixelSize: app.smallFont
|
font.pixelSize: app.smallFont
|
||||||
}
|
}
|
||||||
|
|
||||||
TextField {
|
RowLayout {
|
||||||
id: confirmationPasswordTextField
|
|
||||||
Layout.fillWidth: true
|
TextField {
|
||||||
echoMode: TextInput.Password
|
id: confirmationPasswordTextField
|
||||||
placeholderText: qsTr("Confirm password")
|
Layout.fillWidth: true
|
||||||
|
echoMode: root.hiddenPassword ? TextInput.Password : TextInput.Normal
|
||||||
|
placeholderText: qsTr("Confirm password")
|
||||||
|
}
|
||||||
|
|
||||||
|
ColorIcon {
|
||||||
|
Layout.preferredHeight: app.iconSize
|
||||||
|
Layout.preferredWidth: app.iconSize
|
||||||
|
name: "../images/eye.svg"
|
||||||
|
color: root.hiddenPassword ? keyColor : app.accentColor
|
||||||
|
MouseArea {
|
||||||
|
anchors.fill: parent
|
||||||
|
onClicked: {
|
||||||
|
root.hiddenPassword = !root.hiddenPassword
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Label {
|
Label {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
wrapMode: Text.WordWrap
|
wrapMode: Text.WordWrap
|
||||||
|
|||||||
Reference in New Issue
Block a user