Some code organisation and recovery procedure fix
This commit is contained in:
@@ -11,113 +11,6 @@ Item
|
||||
{
|
||||
property string recpass: ""
|
||||
property bool adminAvailable: true
|
||||
Component.onCompleted:
|
||||
{
|
||||
config.dbConnectionError.connect(onDbConnectionError)
|
||||
config.adminUserError.connect(onAdminUserError)
|
||||
config.backupEncryptionKey.connect(onBackupEncryptionKey)
|
||||
|
||||
}
|
||||
|
||||
function onBackupEncryptionKey()
|
||||
{
|
||||
recoveryDialog.open()
|
||||
}
|
||||
|
||||
function onDbConnectionError(msg, success)
|
||||
{
|
||||
if (!success)
|
||||
conErrDialog.open()
|
||||
}
|
||||
|
||||
function onAdminUserError(msg, success)
|
||||
{
|
||||
if (success)
|
||||
{
|
||||
encryptPwDialog.open()
|
||||
}
|
||||
else
|
||||
{
|
||||
adminAvailable = false
|
||||
firstStart.push("AdminUserConfig.qml")
|
||||
}
|
||||
|
||||
}
|
||||
MessageDialog
|
||||
{
|
||||
id: recoveryDialog
|
||||
|
||||
text: qsTr("Diesen Wiederherstellungscode musst du sicher aufbewahren!\nMöchtest du das jetzt machen?")
|
||||
title: qsTr("Wiederherstellen")
|
||||
buttons: MessageDialog.Yes | MessageDialog.No
|
||||
onAccepted: saveRecoveryDialog.open()
|
||||
|
||||
}
|
||||
FileDialog
|
||||
{
|
||||
id: saveRecoveryDialog
|
||||
title: qsTr("Wiederherstellungsdatei")
|
||||
fileMode: adminAvailable? FileDialog.OpenFile: FileDialog.SaveFile
|
||||
nameFilters: ["PYQCRM Recovery files (*.pyqrec)"]
|
||||
currentFolder: StandardPaths.standardLocations(StandardPaths.DocumentsLocation)[0]
|
||||
onAccepted:
|
||||
{
|
||||
if (!adminAvailable) config.saveRecoveryKey(saveRecoveryDialog.currentFile, recpass)
|
||||
else
|
||||
{
|
||||
config.getRecoveryKey(saveRecoveryDialog.currentFile, recpass)
|
||||
|
||||
}
|
||||
appLoader.source = "Dashboard.qml"
|
||||
topBar.visible = true
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
MessageDialog
|
||||
{
|
||||
id: conErrDialog
|
||||
text: qsTr("Datenbankverbindung fehlgeschlagen")
|
||||
|
||||
title: qsTr("Datenbank Verbindung")
|
||||
|
||||
|
||||
}
|
||||
Dialog
|
||||
{
|
||||
id: encryptPwDialog
|
||||
modal: true
|
||||
title: qsTr("Wiederherstellung")
|
||||
anchors.centerIn: parent
|
||||
standardButtons: Dialog.Ok | Dialog.Cancel
|
||||
onAccepted:
|
||||
{
|
||||
recpass = encryptPassword.text
|
||||
saveRecoveryDialog.open()
|
||||
|
||||
}
|
||||
ColumnLayout
|
||||
{
|
||||
RowLayout
|
||||
{
|
||||
Label
|
||||
{
|
||||
text: qsTr("Wiederherstellungspasswort eingeben: ")
|
||||
}
|
||||
|
||||
TextField
|
||||
{
|
||||
id: encryptPassword
|
||||
echoMode: TextInput.Password
|
||||
implicitWidth: 300
|
||||
placeholderText: qsTr("Hier Wiederherstellungspasswort eingeben")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
anchors.fill: parent
|
||||
StackView
|
||||
@@ -125,15 +18,14 @@ Item
|
||||
id: firstStart
|
||||
anchors.fill: parent
|
||||
initialItem: "DbConfiguration.qml"
|
||||
//initialItem: "AdminUserConfig.qml"
|
||||
}
|
||||
|
||||
RowLayout
|
||||
{
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.margins: 9
|
||||
width: parent.width
|
||||
|
||||
|
||||
Item
|
||||
{
|
||||
Layout.fillWidth: true
|
||||
@@ -164,28 +56,125 @@ Item
|
||||
if (pyqcrm_conf)
|
||||
{
|
||||
config.setConfig(pyqcrm_conf)
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
pyqcrm_conf = Qmldict.firstConf(submitBtn.grids)
|
||||
if (pyqcrm_conf)
|
||||
{
|
||||
admin = config.addAdminUser(pyqcrm_conf)
|
||||
if (admin)
|
||||
{
|
||||
//appLoader.source = "Dashboard.qml"
|
||||
//topBar.visible = true
|
||||
}
|
||||
else
|
||||
{
|
||||
console.log("Konfiguration Admin fehlgeschlagen")
|
||||
}
|
||||
}
|
||||
|
||||
if (pyqcrm_conf) config.addAdminUser(pyqcrm_conf)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MessageDialog
|
||||
{
|
||||
id: recoveryDialog
|
||||
|
||||
text: qsTr("Diesen Wiederherstellungscode musst du sicher aufbewahren!\nMöchtest du das jetzt machen?")
|
||||
title: qsTr("Wiederherstellen")
|
||||
buttons: MessageDialog.Yes | MessageDialog.No
|
||||
onAccepted: recoveryPaswordDialog.open()
|
||||
onRejected: gotoLogin()
|
||||
}
|
||||
|
||||
MessageDialog
|
||||
{
|
||||
id: conErrDialog
|
||||
text: qsTr("Datenbankverbindung fehlgeschlagen")
|
||||
title: qsTr("Datenbank Verbindung")
|
||||
}
|
||||
|
||||
Dialog
|
||||
{
|
||||
id: recoveryPaswordDialog
|
||||
modal: true
|
||||
title: qsTr("Wiederherstellung")
|
||||
anchors.centerIn: parent
|
||||
standardButtons: Dialog.Ok | Dialog.Cancel
|
||||
onAccepted:
|
||||
{
|
||||
recpass = recoveryPaswordInput.text
|
||||
saveRecoveryDialog.open()
|
||||
}
|
||||
|
||||
ColumnLayout
|
||||
{
|
||||
RowLayout
|
||||
{
|
||||
Label
|
||||
{
|
||||
text: qsTr("Wiederherstellungspasswort eingeben: ")
|
||||
}
|
||||
|
||||
TextField
|
||||
{
|
||||
id: recoveryPaswordInput
|
||||
text: ""
|
||||
echoMode: TextInput.Password
|
||||
implicitWidth: 300
|
||||
placeholderText: qsTr("Hier Wiederherstellungspasswort eingeben")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FileDialog
|
||||
{
|
||||
id: saveRecoveryDialog
|
||||
title: qsTr("Wiederherstellungsdatei")
|
||||
fileMode: adminAvailable? FileDialog.OpenFile: FileDialog.SaveFile
|
||||
nameFilters: ["PYQCRM Recovery files (*.pyqrec)"]
|
||||
currentFolder: StandardPaths.standardLocations(StandardPaths.DocumentsLocation)[0]
|
||||
onAccepted:
|
||||
{
|
||||
if (!adminAvailable) config.saveRecoveryKey(saveRecoveryDialog.currentFile, recpass)
|
||||
else config.getRecoveryKey(saveRecoveryDialog.currentFile, recpass)
|
||||
|
||||
gotoLogin()
|
||||
}
|
||||
|
||||
onRejected:
|
||||
{
|
||||
if (adminAvailable) quit()
|
||||
}
|
||||
}
|
||||
|
||||
Component.onCompleted:
|
||||
{
|
||||
config.dbConnectionError.connect(onDbConnectionError)
|
||||
config.adminUserError.connect(onAdminUserError)
|
||||
config.backupEncryptionKey.connect(onBackupEncryptionKey)
|
||||
}
|
||||
|
||||
function gotoLogin()
|
||||
{
|
||||
appLoader.source= "LoginScreen.qml"
|
||||
topBar.visible = true
|
||||
}
|
||||
|
||||
function onBackupEncryptionKey()
|
||||
{
|
||||
recoveryDialog.open()
|
||||
}
|
||||
|
||||
function onDbConnectionError(msg, success)
|
||||
{
|
||||
if (!success)
|
||||
conErrDialog.open()
|
||||
}
|
||||
|
||||
function onAdminUserError(msg, success)
|
||||
{
|
||||
if (success)
|
||||
{
|
||||
recoveryPaswordDialog.open()
|
||||
}
|
||||
else
|
||||
{
|
||||
adminAvailable = false
|
||||
firstStart.push("AdminUserConfig.qml")
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user