feature/api-controller-improvements (#567)
* added error handler for api controller * while downloading the config from the api, the Connecting status is now displayed * added a button to delete container config for api servers * added crc check to avoid re-import of api configs * fixed currentIndex of serversMenuContent after DefaultServerIndexChanged * added closing the import window after re-importing the config from api
This commit is contained in:
parent
dba05aab07
commit
e0863a58aa
20 changed files with 275 additions and 113 deletions
|
|
@ -53,7 +53,7 @@ QVariant ContainersModel::data(const int index, int role) const
|
|||
return data(modelIndex, role);
|
||||
}
|
||||
|
||||
void ContainersModel::updateModel(QJsonArray &containers)
|
||||
void ContainersModel::updateModel(const QJsonArray &containers)
|
||||
{
|
||||
beginResetModel();
|
||||
m_containers.clear();
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ public:
|
|||
QVariant data(const int index, int role) const;
|
||||
|
||||
public slots:
|
||||
void updateModel(QJsonArray &containers);
|
||||
void updateModel(const QJsonArray &containers);
|
||||
|
||||
DockerContainer getDefaultContainer();
|
||||
void setDefaultContainer(const int containerIndex);
|
||||
|
|
|
|||
|
|
@ -331,6 +331,11 @@ QJsonObject ServersModel::getDefaultServerConfig()
|
|||
return m_servers.at(m_defaultServerIndex).toObject();
|
||||
}
|
||||
|
||||
QJsonObject ServersModel::getCurrentlyProcessedServerConfig()
|
||||
{
|
||||
return m_servers.at(m_currentlyProcessedServerIndex).toObject();
|
||||
}
|
||||
|
||||
void ServersModel::reloadContainerConfig()
|
||||
{
|
||||
QJsonObject server = m_servers.at(m_currentlyProcessedServerIndex).toObject();
|
||||
|
|
@ -544,3 +549,18 @@ bool ServersModel::isDefaultServerFromApi()
|
|||
return m_settings->server(m_defaultServerIndex).value(config_key::configVersion).toInt();
|
||||
}
|
||||
|
||||
bool ServersModel::isCurrentlyProcessedServerFromApi()
|
||||
{
|
||||
return m_settings->server(m_currentlyProcessedServerIndex).value(config_key::configVersion).toInt();
|
||||
}
|
||||
|
||||
bool ServersModel::isServerFromApiAlreadyExists(const quint16 crc)
|
||||
{
|
||||
for (const auto &server : qAsConst(m_servers)) {
|
||||
if (static_cast<quint16>(server.toObject().value(config_key::crc).toInt()) == crc) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -78,6 +78,7 @@ public slots:
|
|||
bool isAmneziaDnsContainerInstalled(const int serverIndex);
|
||||
|
||||
QJsonObject getDefaultServerConfig();
|
||||
QJsonObject getCurrentlyProcessedServerConfig();
|
||||
|
||||
void reloadContainerConfig();
|
||||
void updateContainerConfig(const int containerIndex, const QJsonObject config);
|
||||
|
|
@ -99,6 +100,9 @@ public slots:
|
|||
void toggleAmneziaDns(bool enabled);
|
||||
|
||||
bool isDefaultServerFromApi();
|
||||
bool isCurrentlyProcessedServerFromApi();
|
||||
|
||||
bool isServerFromApiAlreadyExists(const quint16 crc);
|
||||
|
||||
protected:
|
||||
QHash<int, QByteArray> roleNames() const override;
|
||||
|
|
@ -109,7 +113,7 @@ signals:
|
|||
void defaultServerNameChanged();
|
||||
void defaultServerDescriptionChanged();
|
||||
|
||||
void containersUpdated(QJsonArray &containers);
|
||||
void containersUpdated(const QJsonArray &containers);
|
||||
void defaultContainerChanged(const int containerIndex);
|
||||
|
||||
private:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue