FirstStart angepasst

This commit is contained in:
2024-11-25 15:17:20 +01:00
parent 304f9cabc5
commit 93efaabe6d
18 changed files with 1619 additions and 325 deletions

View File

@@ -22,255 +22,79 @@ import "../js/qmldict.js" as Qmldict
Item
{
ColumnLayout
anchors.fill: parent
StackView
{
id: firstStart
anchors.fill: parent
TabBar
initialItem: "DbConfiguration.qml"
}
RowLayout
{
anchors.bottom: parent.bottom
anchors.margins: 9
width: parent.width
Item
{
id: bar
Layout.fillWidth: true
}
TabButton
Button
{
id: cancelBtn
text: qsTr("Abbrechen")
onClicked:
{
text: qsTr("Benutzer erstellen")
}
TabButton
{
id: dbTab
text: qsTr("Datenbank einrichten")
}
onCurrentIndexChanged:
{
submitBtn.text = currentIndex === 0? "Weiter" : "Speichern"
Qt.quit()
}
}
StackLayout
Button
{
Layout.fillWidth: true
Layout.fillHeight: true
currentIndex: bar.currentIndex
Layout.margins: 9
id: stackl
Item
id: submitBtn
text: qsTr("Speichern")
property var grids: firstStart.currentItem
property var pyqcrm_conf: ({})
property var admin: Boolean
onClicked:
{
id: createUser
Layout.fillWidth: parent.width
GridLayout
if (firstStart.currentItem.name === "database")
{
id: createUserGrid
columns: 2
columnSpacing: 5
rowSpacing: 9
anchors.fill: parent
Layout.margins: 9
property string name: "pyqcrm"
Label
pyqcrm_conf = Qmldict.func(submitBtn.grids)
if (pyqcrm_conf)
{
text: qsTr("Benutzername:")
Layout.alignment: Qt.AlignRight
}
TextField
{
id: benutzerName
placeholderText: qsTr("Hier Benutzername eingeben")
Layout.fillWidth: true
height: 3
property string name: "PYQCRM_ADMIN"
}
Label
{
text: qsTr("Passwort:")
Layout.alignment: Qt.AlignRight
}
TextField
{
id: password
echoMode: TextInput.Password
placeholderText: qsTr("Hier Passwort eingeben")
Layout.fillWidth: true
property string name: "PYQCRM_ADMIN_PASS"
}
Label
{
text: qsTr("Info:")
Layout.alignment: Qt.AlignRight
}
TextField
{
id: gecos
placeholderText: qsTr("Zusätzliche Info")
Layout.fillWidth: true
property string name: "PYQCRM_ADMIN_INFO"
}
Item
{
Layout.fillHeight: true
}
}
}
Item
{
id: settingsDB
Layout.fillWidth: parent.width
GridLayout
{
id: dbGrid
columns: 2
columnSpacing: 5
rowSpacing: 9
anchors.fill: parent
property string name: "database"
Label
{
text: qsTr("DB-Host:")
Layout.alignment: Qt.AlignRight
}
TextField
{
id: dbHost
placeholderText: qsTr("Hier Host eingeben")
Layout.fillWidth: true
property string name: "DB_HOST"
}
Label
{
text: qsTr("DB-Port:")
Layout.alignment: Qt.AlignRight
}
TextField
{
id: dbPort
placeholderText: qsTr("Hier DB-Port eingeben")
Layout.fillWidth: true
property string name: "DB_PORT"
}
Label
{
text: qsTr("DB-Name:")
Layout.alignment: Qt.AlignRight
}
TextField
{
id: dbName
placeholderText: qsTr("Hier DB-Name eingeben")
Layout.fillWidth: true
property string name: "DB_NAME"
}
Label
{
text: qsTr("DB-Benutzername:")
Layout.alignment: Qt.AlignRight
}
TextField
{
id: dbUserName
placeholderText: qsTr("Hier DB-Benutzername eingeben")
Layout.fillWidth: true
property string name: "DB_USER"
}
Label
{
text: qsTr("DB-Passwort:")
Layout.alignment: Qt.AlignRight
}
TextField
{
id: dbPassword
echoMode: TextInput.Password
placeholderText: qsTr("Hier DB-Passwort eingeben")
Layout.fillWidth: true
property string name: "DB_PASS"
}
Item
{
Layout.fillHeight: true
}
}
}
}
RowLayout
{
Layout.margins: 9
Item
{
Layout.fillWidth: true
}
Button
{
id: cancelBtn
text: qsTr("Abbrechen")
onClicked:
{
Qt.quit()
}
}
Button
{
id: submitBtn
text: qsTr("Weiter")
property var grids: [createUserGrid, dbGrid]
property var pyqcrm_conf: ({})
onClicked:
{
if (bar.itemAt(bar.currentIndex) !== dbTab)
{
bar.currentIndex = 1
}
else
{
pyqcrm_conf = Qmldict.func(submitBtn.grids)
if (pyqcrm_conf)
admin = config.setConfig(pyqcrm_conf)
if (admin)
{
config.setConfig(pyqcrm_conf)
appLoader.source = "Dashboard.qml"
topBar.visible = true
firstStart.push("EncryptionKey.qml")
}
else
{
firstStart.push("AdminUserConfig.qml")
}
}
}
else
{
pyqcrm_conf = Qmldict.func(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")
}
}
}
}
}
}
Component.onCompleted:
{
appLoader.window.title = "PYQCRM - Einstellungen"
}
}