Skip to content

Commit

Permalink
Fix edit user dialog regression
Browse files Browse the repository at this point in the history
  • Loading branch information
Fanda Vacek committed Aug 30, 2024
1 parent d0afca9 commit 006fbf2
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
2 changes: 1 addition & 1 deletion shvspy/src/appversion.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#pragma once

#define APP_VERSION "1.9.6"
#define APP_VERSION "1.9.7"

19 changes: 12 additions & 7 deletions shvspy/src/dlguserseditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ void DlgUsersEditor::listUsers()
}
});

m_rpcConnection->callShvMethod(rqid, aclEtcUsersNodePath(), shv::chainpack::Rpc::METH_LS);
m_rpcConnection->callShvMethod(rqid, aclAccessUsersPath(), shv::chainpack::Rpc::METH_LS);
}

QString DlgUsersEditor::selectedUser()
Expand All @@ -100,7 +100,7 @@ QString DlgUsersEditor::selectedUser()

void DlgUsersEditor::onAddUserClicked()
{
auto dlg = new DlgAddEditUser(this, m_rpcConnection, aclEtcUsersNodePath(), DlgAddEditUser::DialogType::Add);
auto dlg = new DlgAddEditUser(this, m_rpcConnection, aclAccessPath(), DlgAddEditUser::DialogType::Add);
connect(dlg, &QDialog::finished, dlg, [this, dlg] (int result) {
if (result == QDialog::Accepted){
listUsers();
Expand Down Expand Up @@ -141,7 +141,7 @@ void DlgUsersEditor::onDelUserClicked()
});

shv::chainpack::RpcValue::List params{user.toStdString(), {}};
m_rpcConnection->callShvMethod(rqid, aclEtcUsersNodePath(), SET_VALUE_METHOD, params);
m_rpcConnection->callShvMethod(rqid, aclAccessUsersPath(), SET_VALUE_METHOD, params);
}
}

Expand All @@ -156,7 +156,7 @@ void DlgUsersEditor::onEditUserClicked()

ui->lblStatus->setText("");

auto dlg = new DlgAddEditUser(this, m_rpcConnection, aclEtcUsersNodePath(), DlgAddEditUser::DialogType::Edit);
auto dlg = new DlgAddEditUser(this, m_rpcConnection, aclAccessPath(), DlgAddEditUser::DialogType::Edit);
dlg->setUser(user);

connect(dlg, &QDialog::finished, dlg, [this, dlg] (int result) {
Expand All @@ -175,11 +175,16 @@ void DlgUsersEditor::onTableUsersDoubleClicked(QModelIndex ix)
onEditUserClicked();
}

std::string DlgUsersEditor::aclEtcUsersNodePath()
std::string DlgUsersEditor::aclAccessPath()
{
switch (m_rpcConnection->shvApiVersion()) {
case shv::chainpack::IRpcConnection::ShvApiVersion::V2: return ".broker/etc/acl/users";
case shv::chainpack::IRpcConnection::ShvApiVersion::V3: return ".broker/access/users";
case shv::chainpack::IRpcConnection::ShvApiVersion::V2: return ".broker/etc/acl";
case shv::chainpack::IRpcConnection::ShvApiVersion::V3: return ".broker/access";
}
return "";
}

std::string DlgUsersEditor::aclAccessUsersPath()
{
return aclAccessPath() + "/users";
}
3 changes: 2 additions & 1 deletion shvspy/src/dlguserseditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ class DlgUsersEditor : public QDialog
void onEditUserClicked();
void onTableUsersDoubleClicked(QModelIndex ix);

std::string aclEtcUsersNodePath();
std::string aclAccessPath();
std::string aclAccessUsersPath();
void setFilter(const QString &filter);
private:
shv::iotqt::rpc::ClientConnection *m_rpcConnection = nullptr;
Expand Down

0 comments on commit 006fbf2

Please sign in to comment.