added client management panel
- added classes for displaying the client management panel - added class for displaying the client info - added page to display a list of clients - added page to display OpenVpn client information - added diagram with OpenVpn certificate revocation process
This commit is contained in:
parent
3f257af7a9
commit
a42beb86c0
19 changed files with 771 additions and 102 deletions
75
client/ui/models/clientManagementModel.cpp
Normal file
75
client/ui/models/clientManagementModel.cpp
Normal file
|
@ -0,0 +1,75 @@
|
|||
#include "clientManagementModel.h"
|
||||
|
||||
ClientManagementModel::ClientManagementModel(std::shared_ptr<Settings> settings, QObject *parent) :
|
||||
m_settings(settings),
|
||||
QAbstractListModel(parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void ClientManagementModel::clearData()
|
||||
{
|
||||
beginResetModel();
|
||||
m_content.clear();
|
||||
endResetModel();
|
||||
}
|
||||
|
||||
void ClientManagementModel::setContent(const QVector<ClientInfo> &data)
|
||||
{
|
||||
beginResetModel();
|
||||
m_content = data;
|
||||
endResetModel();
|
||||
}
|
||||
|
||||
int ClientManagementModel::rowCount(const QModelIndex &parent) const
|
||||
{
|
||||
Q_UNUSED(parent);
|
||||
return static_cast<int>(m_content.size());
|
||||
}
|
||||
|
||||
QVariant ClientManagementModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if (!index.isValid() || index.row() < 0
|
||||
|| index.row() >= static_cast<int>(m_content.size())) {
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
if (role == NameRole) {
|
||||
return m_content[index.row()].name;
|
||||
}
|
||||
if (role == CertIdRole) {
|
||||
return m_content[index.row()].certId;
|
||||
}
|
||||
if (role == CertDataRole) {
|
||||
return m_content[index.row()].certData;
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
void ClientManagementModel::setData(const QModelIndex &index, QVariant data, int role)
|
||||
{
|
||||
if (!index.isValid() || index.row() < 0
|
||||
|| index.row() >= static_cast<int>(m_content.size())) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (role == NameRole) {
|
||||
m_content[index.row()].name = data.toString();
|
||||
}
|
||||
if (role == CertIdRole) {
|
||||
m_content[index.row()].certId = data.toString();
|
||||
}
|
||||
if (role == CertDataRole) {
|
||||
m_content[index.row()].certData = data.toString();
|
||||
}
|
||||
emit dataChanged(index, index);
|
||||
}
|
||||
|
||||
QHash<int, QByteArray> ClientManagementModel::roleNames() const
|
||||
{
|
||||
QHash<int, QByteArray> roles;
|
||||
roles[NameRole] = "clientName";
|
||||
roles[CertIdRole] = "certId";
|
||||
roles[CertDataRole] = "certData";
|
||||
return roles;
|
||||
}
|
42
client/ui/models/clientManagementModel.h
Normal file
42
client/ui/models/clientManagementModel.h
Normal file
|
@ -0,0 +1,42 @@
|
|||
#ifndef CLIENTMANAGEMENTMODEL_H
|
||||
#define CLIENTMANAGEMENTMODEL_H
|
||||
|
||||
#include <QAbstractListModel>
|
||||
|
||||
#include "settings.h"
|
||||
|
||||
class ClientManagementModel : public QAbstractListModel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum ClientRoles {
|
||||
NameRole = Qt::UserRole + 1,
|
||||
CertIdRole,
|
||||
CertDataRole
|
||||
};
|
||||
|
||||
struct ClientInfo
|
||||
{
|
||||
QString name;
|
||||
QString certId;
|
||||
QString certData;
|
||||
};
|
||||
|
||||
ClientManagementModel(std::shared_ptr<Settings> settings, QObject *parent = nullptr);
|
||||
|
||||
void clearData();
|
||||
void setContent(const QVector<ClientInfo> &data);
|
||||
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);
|
||||
|
||||
protected:
|
||||
QHash<int, QByteArray> roleNames() const override;
|
||||
|
||||
private:
|
||||
std::shared_ptr<Settings> m_settings; //TODO remove this?
|
||||
QVector<ClientInfo> m_content;
|
||||
};
|
||||
|
||||
#endif // CLIENTMANAGEMENTMODEL_H
|
Loading…
Add table
Add a link
Reference in a new issue