added saving the list of clients for wireguard
- added error handling when getting/saving a list of clients
This commit is contained in:
parent
8c137ecc52
commit
a7030cdcb9
5 changed files with 87 additions and 53 deletions
|
|
@ -21,11 +21,15 @@ void ClientManagementModel::setContent(const QVector<QVariant> &data)
|
|||
endResetModel();
|
||||
}
|
||||
|
||||
QJsonObject ClientManagementModel::getContent()
|
||||
QJsonObject ClientManagementModel::getContent(Proto protocol)
|
||||
{
|
||||
QJsonObject clientsTable;
|
||||
for (const auto &item : m_content) {
|
||||
clientsTable[item.toJsonObject()["openvpnCertId"].toString()] = item.toJsonObject();
|
||||
if (protocol == Proto::OpenVpn) {
|
||||
clientsTable[item.toJsonObject()["openvpnCertId"].toString()] = item.toJsonObject();
|
||||
} else if (protocol == Proto::WireGuard) {
|
||||
clientsTable[item.toJsonObject()["wireguardPublicKey"].toString()] = item.toJsonObject();
|
||||
}
|
||||
}
|
||||
return clientsTable;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ public:
|
|||
|
||||
void clearData();
|
||||
void setContent(const QVector<QVariant> &data);
|
||||
QJsonObject getContent();
|
||||
QJsonObject getContent(Proto protocol);
|
||||
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
||||
void setData(const QModelIndex &index, QVariant data, int role = Qt::DisplayRole);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue