Minor refactoring for API authentication.
This commit is contained in:
@ -39,7 +39,7 @@ GenericCore::GenericCore() {
|
||||
m_modelUndoStack = new QUndoStack(this);
|
||||
|
||||
setupModels();
|
||||
setupServerConfiguration();
|
||||
setupServerCommunication();
|
||||
}
|
||||
|
||||
GenericCore::~GenericCore() { qDebug() << "Destroying core..."; }
|
||||
@ -129,7 +129,7 @@ void GenericCore::applySettings(QVariantMap settingMap, QString group) {
|
||||
SettingsHandler::saveSettings(settingMap, group);
|
||||
|
||||
if (group == "Server") {
|
||||
setupServerConfiguration();
|
||||
applyServerConfiguration();
|
||||
}
|
||||
}
|
||||
|
||||
@ -157,6 +157,7 @@ void GenericCore::saveItems() {
|
||||
emit displayStatusMessage(QString("Error: Items couldn't be saved."));
|
||||
}
|
||||
}
|
||||
|
||||
void GenericCore::onSendItemTriggered(const QByteArray& jsonData) {
|
||||
m_serverCommunicator->postItems(jsonData);
|
||||
}
|
||||
@ -246,7 +247,7 @@ QString GenericCore::getMaintenanceToolFilePath() const {
|
||||
return filePath;
|
||||
}
|
||||
|
||||
void GenericCore::setupServerConfiguration() {
|
||||
void GenericCore::setupServerCommunication() {
|
||||
m_serverCommunicator = make_unique<ServerCommunicator>(this);
|
||||
/// request connections
|
||||
connect(this, &GenericCore::fetchItemsFromServer, m_serverCommunicator.get(),
|
||||
@ -275,6 +276,7 @@ void GenericCore::setupServerConfiguration() {
|
||||
void GenericCore::applyServerConfiguration() {
|
||||
const QVariantMap serverSettings = SettingsHandler::getSettings("Server");
|
||||
const QString urlValue = serverSettings.value("url").toString();
|
||||
// NEXT if urlValue is empty -> remove authToken from settings?
|
||||
if (!urlValue.isEmpty()) {
|
||||
const QString emailValue = serverSettings.value("email").toString();
|
||||
const QString passwordValue = serverSettings.value("password").toString();
|
||||
|
||||
@ -67,7 +67,7 @@ class GenericCore : public QObject {
|
||||
|
||||
/// Network communication
|
||||
std::unique_ptr<ServerCommunicator> m_serverCommunicator;
|
||||
void setupServerConfiguration();
|
||||
void setupServerCommunication();
|
||||
void applyServerConfiguration();
|
||||
};
|
||||
|
||||
|
||||
@ -27,6 +27,7 @@ QString GeneralSortFilterModel::getUuid(const QModelIndex& itemIndex) const {
|
||||
return data(itemIndex, IdRole).toString();
|
||||
}
|
||||
|
||||
// NEXT remove when deprecated
|
||||
QByteArray GeneralSortFilterModel::jsonDataForServer(const QModelIndex& proxyIndex) {
|
||||
const QModelIndex sourceIndex = mapToSource(proxyIndex);
|
||||
return m_tableModel->jsonDataForServer(sourceIndex);
|
||||
|
||||
Reference in New Issue
Block a user