AAAAAAAAAAAAAAA
This commit is contained in:
parent
dae929607f
commit
19631b035e
|
|
@ -14,22 +14,22 @@ from PyQt5 import QtCore, QtGui, QtWidgets
|
||||||
class Ui_Connection(object):
|
class Ui_Connection(object):
|
||||||
def setupUi(self, Connection):
|
def setupUi(self, Connection):
|
||||||
Connection.setObjectName("Connection")
|
Connection.setObjectName("Connection")
|
||||||
Connection.resize(249, 252)
|
Connection.resize(245, 243)
|
||||||
self.label = QtWidgets.QLabel(Connection)
|
self.label = QtWidgets.QLabel(Connection)
|
||||||
self.label.setGeometry(QtCore.QRect(20, 10, 101, 16))
|
self.label.setGeometry(QtCore.QRect(20, 10, 101, 16))
|
||||||
self.label.setObjectName("label")
|
self.label.setObjectName("label")
|
||||||
self.label_2 = QtWidgets.QLabel(Connection)
|
self.portLabel = QtWidgets.QLabel(Connection)
|
||||||
self.label_2.setGeometry(QtCore.QRect(20, 70, 49, 16))
|
self.portLabel.setGeometry(QtCore.QRect(20, 70, 49, 16))
|
||||||
self.label_2.setObjectName("label_2")
|
self.portLabel.setObjectName("portLabel")
|
||||||
self.label_3 = QtWidgets.QLabel(Connection)
|
self.userLabel = QtWidgets.QLabel(Connection)
|
||||||
self.label_3.setGeometry(QtCore.QRect(20, 100, 61, 16))
|
self.userLabel.setGeometry(QtCore.QRect(20, 100, 61, 16))
|
||||||
self.label_3.setObjectName("label_3")
|
self.userLabel.setObjectName("userLabel")
|
||||||
self.label_4 = QtWidgets.QLabel(Connection)
|
self.passLabel = QtWidgets.QLabel(Connection)
|
||||||
self.label_4.setGeometry(QtCore.QRect(20, 130, 81, 16))
|
self.passLabel.setGeometry(QtCore.QRect(20, 130, 81, 16))
|
||||||
self.label_4.setObjectName("label_4")
|
self.passLabel.setObjectName("passLabel")
|
||||||
self.label_5 = QtWidgets.QLabel(Connection)
|
self.databaseLabel = QtWidgets.QLabel(Connection)
|
||||||
self.label_5.setGeometry(QtCore.QRect(20, 160, 61, 16))
|
self.databaseLabel.setGeometry(QtCore.QRect(20, 160, 61, 16))
|
||||||
self.label_5.setObjectName("label_5")
|
self.databaseLabel.setObjectName("databaseLabel")
|
||||||
self.portInput = QtWidgets.QLineEdit(Connection)
|
self.portInput = QtWidgets.QLineEdit(Connection)
|
||||||
self.portInput.setGeometry(QtCore.QRect(100, 70, 131, 21))
|
self.portInput.setGeometry(QtCore.QRect(100, 70, 131, 21))
|
||||||
self.portInput.setText("")
|
self.portInput.setText("")
|
||||||
|
|
@ -56,9 +56,9 @@ class Ui_Connection(object):
|
||||||
self.returnLabel = QtWidgets.QLabel(Connection)
|
self.returnLabel = QtWidgets.QLabel(Connection)
|
||||||
self.returnLabel.setGeometry(QtCore.QRect(20, 220, 211, 16))
|
self.returnLabel.setGeometry(QtCore.QRect(20, 220, 211, 16))
|
||||||
self.returnLabel.setObjectName("returnLabel")
|
self.returnLabel.setObjectName("returnLabel")
|
||||||
self.label_6 = QtWidgets.QLabel(Connection)
|
self.ipLabel = QtWidgets.QLabel(Connection)
|
||||||
self.label_6.setGeometry(QtCore.QRect(20, 40, 101, 16))
|
self.ipLabel.setGeometry(QtCore.QRect(20, 40, 101, 16))
|
||||||
self.label_6.setObjectName("label_6")
|
self.ipLabel.setObjectName("ipLabel")
|
||||||
self.ipInput = QtWidgets.QLineEdit(Connection)
|
self.ipInput = QtWidgets.QLineEdit(Connection)
|
||||||
self.ipInput.setGeometry(QtCore.QRect(100, 40, 131, 21))
|
self.ipInput.setGeometry(QtCore.QRect(100, 40, 131, 21))
|
||||||
self.ipInput.setText("")
|
self.ipInput.setText("")
|
||||||
|
|
@ -66,6 +66,9 @@ class Ui_Connection(object):
|
||||||
self.dbtypeCombo = QtWidgets.QComboBox(Connection)
|
self.dbtypeCombo = QtWidgets.QComboBox(Connection)
|
||||||
self.dbtypeCombo.setGeometry(QtCore.QRect(100, 10, 131, 22))
|
self.dbtypeCombo.setGeometry(QtCore.QRect(100, 10, 131, 22))
|
||||||
self.dbtypeCombo.setObjectName("dbtypeCombo")
|
self.dbtypeCombo.setObjectName("dbtypeCombo")
|
||||||
|
self.dbPath = QtWidgets.QFileDialog(Connection)
|
||||||
|
self.dbPath.setGeometry(QtCore.QRect(100, 15, 131, 22))
|
||||||
|
self.dbPath.setObjectName("dbPath")
|
||||||
|
|
||||||
self.retranslateUi(Connection)
|
self.retranslateUi(Connection)
|
||||||
self.ipInput.returnPressed.connect(self.portInput.setFocus) # type: ignore
|
self.ipInput.returnPressed.connect(self.portInput.setFocus) # type: ignore
|
||||||
|
|
@ -86,11 +89,11 @@ class Ui_Connection(object):
|
||||||
_translate = QtCore.QCoreApplication.translate
|
_translate = QtCore.QCoreApplication.translate
|
||||||
Connection.setWindowTitle(_translate("Connection", "Form"))
|
Connection.setWindowTitle(_translate("Connection", "Form"))
|
||||||
self.label.setText(_translate("Connection", "Database"))
|
self.label.setText(_translate("Connection", "Database"))
|
||||||
self.label_2.setText(_translate("Connection", "Port"))
|
self.portLabel.setText(_translate("Connection", "Port"))
|
||||||
self.label_3.setText(_translate("Connection", "Username"))
|
self.userLabel.setText(_translate("Connection", "Username"))
|
||||||
self.label_4.setText(_translate("Connection", "Password"))
|
self.passLabel.setText(_translate("Connection", "Password"))
|
||||||
self.label_5.setText(_translate("Connection", "Database"))
|
self.databaseLabel.setText(_translate("Connection", "Database"))
|
||||||
self.testButton.setText(_translate("Connection", "Test Connection"))
|
self.testButton.setText(_translate("Connection", "Test Connection"))
|
||||||
self.saveButton.setText(_translate("Connection", "Save"))
|
self.saveButton.setText(_translate("Connection", "Save"))
|
||||||
self.returnLabel.setText(_translate("Connection", "Connection ... / Saved..."))
|
self.returnLabel.setText(_translate("Connection", "Connection ... / Saved..."))
|
||||||
self.label_6.setText(_translate("Connection", "IP"))
|
self.ipLabel.setText(_translate("Connection", "IP"))
|
||||||
|
|
|
||||||
|
|
@ -6,8 +6,8 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>249</width>
|
<width>245</width>
|
||||||
<height>252</height>
|
<height>243</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
|
|
@ -26,7 +26,7 @@
|
||||||
<string>Database</string>
|
<string>Database</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QLabel" name="label_2">
|
<widget class="QLabel" name="portLabel">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>20</x>
|
<x>20</x>
|
||||||
|
|
@ -39,7 +39,7 @@
|
||||||
<string>Port</string>
|
<string>Port</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QLabel" name="label_3">
|
<widget class="QLabel" name="userLabel">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>20</x>
|
<x>20</x>
|
||||||
|
|
@ -52,7 +52,7 @@
|
||||||
<string>Username</string>
|
<string>Username</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QLabel" name="label_4">
|
<widget class="QLabel" name="passLabel">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>20</x>
|
<x>20</x>
|
||||||
|
|
@ -65,7 +65,7 @@
|
||||||
<string>Password</string>
|
<string>Password</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QLabel" name="label_5">
|
<widget class="QLabel" name="databaseLabel">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>20</x>
|
<x>20</x>
|
||||||
|
|
@ -172,7 +172,7 @@
|
||||||
<string>Connection ... / Saved...</string>
|
<string>Connection ... / Saved...</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QLabel" name="label_6">
|
<widget class="QLabel" name="ipLabel">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>20</x>
|
<x>20</x>
|
||||||
|
|
|
||||||
50
gui/main.py
50
gui/main.py
|
|
@ -3,7 +3,7 @@ import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from PyQt5.QtCore import QObject, QThread, pyqtSignal
|
from PyQt5.QtCore import QObject, QThread, pyqtSignal
|
||||||
from PyQt5.QtWidgets import QApplication, QMainWindow, QDialog, QTableWidgetItem, QTableWidget
|
from PyQt5.QtWidgets import QApplication, QMainWindow, QDialog, QTableWidgetItem, QTableWidget, QFileDialog
|
||||||
|
|
||||||
import modules.aisql as aisql
|
import modules.aisql as aisql
|
||||||
|
|
||||||
|
|
@ -16,8 +16,8 @@ configfile = "config.json"
|
||||||
|
|
||||||
dbtypes = {
|
dbtypes = {
|
||||||
0: "PostgreSQL",
|
0: "PostgreSQL",
|
||||||
1: "MySQL",
|
1: "SQLite",
|
||||||
2: "SQLite"
|
2: "MySQL"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Load DB Config from file but check if file exists and create if not
|
# Load DB Config from file but check if file exists and create if not
|
||||||
|
|
@ -267,14 +267,7 @@ class ConnectionWindow(QDialog):
|
||||||
|
|
||||||
|
|
||||||
# Load DB Config from file
|
# Load DB Config from file
|
||||||
with open(os.path.join(configfolder, configfile), "r") as f:
|
self.dbtype, self.dbip, self.dbport, self.dbuser, self.dbpass, self.dbname, apikey = load_config()
|
||||||
self.config = json.load(f)
|
|
||||||
self.dbtype = self.config["database"]["dbtype"]
|
|
||||||
self.dbip = self.config["database"]["ip"]
|
|
||||||
self.dbport = self.config["database"]["port"]
|
|
||||||
self.dbuser = self.config["database"]["user"]
|
|
||||||
self.dbpass = self.config["database"]["password"]
|
|
||||||
self.dbname = self.config["database"]["database"]
|
|
||||||
|
|
||||||
self.ui.dbtypeCombo.addItems(dbtypes.values())
|
self.ui.dbtypeCombo.addItems(dbtypes.values())
|
||||||
self.ui.dbtypeCombo.setCurrentIndex(self.dbtype)
|
self.ui.dbtypeCombo.setCurrentIndex(self.dbtype)
|
||||||
|
|
@ -284,17 +277,15 @@ class ConnectionWindow(QDialog):
|
||||||
self.ui.passwordInput.setText(self.dbpass)
|
self.ui.passwordInput.setText(self.dbpass)
|
||||||
self.ui.databaseInput.setText(self.dbname)
|
self.ui.databaseInput.setText(self.dbname)
|
||||||
|
|
||||||
if (self.ui.ipInput or self.ui.portInput or self.ui.databaseInput) == "":
|
if self.ui.ipInput == "":
|
||||||
self.ui.saveButton.setEnabled(False)
|
self.ui.saveButton.setEnabled(False)
|
||||||
self.ui.testButton.setEnabled(False)
|
self.ui.testButton.setEnabled(False)
|
||||||
else:
|
else:
|
||||||
self.ui.saveButton.setEnabled(True)
|
self.ui.saveButton.setEnabled(True)
|
||||||
self.ui.testButton.setEnabled(True)
|
self.ui.testButton.setEnabled(True)
|
||||||
# Unlock Buttons if ip, port and database is not empty
|
|
||||||
|
|
||||||
|
# Unlock Buttons if ip, port and database is not empty
|
||||||
self.ui.ipInput.textChanged.connect(self.on_text_changed)
|
self.ui.ipInput.textChanged.connect(self.on_text_changed)
|
||||||
self.ui.portInput.textChanged.connect(self.on_text_changed)
|
|
||||||
self.ui.databaseInput.textChanged.connect(self.on_text_changed)
|
|
||||||
|
|
||||||
# Pressed Save Button
|
# Pressed Save Button
|
||||||
self.ui.saveButton.clicked.connect(self.on_save_button_clicked)
|
self.ui.saveButton.clicked.connect(self.on_save_button_clicked)
|
||||||
|
|
@ -302,14 +293,41 @@ class ConnectionWindow(QDialog):
|
||||||
# Pressed Test Button
|
# Pressed Test Button
|
||||||
self.ui.testButton.clicked.connect(self.start_db_test_thread)
|
self.ui.testButton.clicked.connect(self.start_db_test_thread)
|
||||||
|
|
||||||
|
# If SQLite3 is selected, disable ip, port, username and password
|
||||||
|
self.ui.dbtypeCombo.currentIndexChanged.connect(self.on_dbtype_changed)
|
||||||
|
|
||||||
def on_text_changed(self):
|
def on_text_changed(self):
|
||||||
if self.ui.ipInput.text() == "" or self.ui.portInput.text() == "" or self.ui.databaseInput.text() == "":
|
if self.ui.ipInput.text() == "":
|
||||||
self.ui.saveButton.setEnabled(False)
|
self.ui.saveButton.setEnabled(False)
|
||||||
self.ui.testButton.setEnabled(False)
|
self.ui.testButton.setEnabled(False)
|
||||||
else:
|
else:
|
||||||
self.ui.saveButton.setEnabled(True)
|
self.ui.saveButton.setEnabled(True)
|
||||||
self.ui.testButton.setEnabled(True)
|
self.ui.testButton.setEnabled(True)
|
||||||
|
|
||||||
|
def on_dbtype_changed(self):
|
||||||
|
if self.ui.dbtypeCombo.currentIndex() == 1:
|
||||||
|
self.ui.ipInput.hide()
|
||||||
|
self.ui.portInput.hide()
|
||||||
|
self.ui.usernameInput.hide()
|
||||||
|
self.ui.passwordInput.hide()
|
||||||
|
self.ui.databaseInput.hide()
|
||||||
|
self.ui.ipLabel.hide()
|
||||||
|
self.ui.portLabel.hide()
|
||||||
|
self.ui.userLabel.hide()
|
||||||
|
self.ui.passLabel.hide()
|
||||||
|
self.ui.databaseLabel.hide()
|
||||||
|
else:
|
||||||
|
self.ui.ipInput.show()
|
||||||
|
self.ui.portInput.show()
|
||||||
|
self.ui.usernameInput.show()
|
||||||
|
self.ui.passwordInput.show()
|
||||||
|
self.ui.databaseInput.show()
|
||||||
|
self.ui.ipLabel.show()
|
||||||
|
self.ui.portLabel.show()
|
||||||
|
self.ui.userLabel.show()
|
||||||
|
self.ui.passLabel.show()
|
||||||
|
self.ui.databaseLabel.show()
|
||||||
|
|
||||||
def on_save_button_clicked(self):
|
def on_save_button_clicked(self):
|
||||||
self.dbtype = self.ui.dbtypeCombo.currentIndex()
|
self.dbtype = self.ui.dbtypeCombo.currentIndex()
|
||||||
self.dbip = self.ui.ipInput.text()
|
self.dbip = self.ui.ipInput.text()
|
||||||
|
|
|
||||||
24
webgui/main.py
Normal file
24
webgui/main.py
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
import justpy as jp
|
||||||
|
|
||||||
|
class ButtonDiv(jp.Div):
|
||||||
|
|
||||||
|
def __init__(self, **kwargs):
|
||||||
|
|
||||||
|
super().__init__(**kwargs)
|
||||||
|
for i in range(1,6):
|
||||||
|
b = jp.Button(text=f'Button {i}', a=self, classes=f' m-{i} p-{i} border text-blue text-lg')
|
||||||
|
b.num = i
|
||||||
|
b.on('click', self.button_clicked)
|
||||||
|
self.info_div = jp.Div(text='info will go here', classes='m-2 p-2 border', a=self)
|
||||||
|
|
||||||
|
def button_clicked(self, msg):
|
||||||
|
print(self)
|
||||||
|
print(msg.target)
|
||||||
|
self.info_div.text = f'Button {msg.target.num} was clicked'
|
||||||
|
|
||||||
|
def target_test():
|
||||||
|
wp = jp.WebPage()
|
||||||
|
ButtonDiv(a=wp)
|
||||||
|
return wp
|
||||||
|
|
||||||
|
jp.justpy(target_test)
|
||||||
Loading…
Reference in New Issue
Block a user