moved handling of connection states from qml in connectionController
- added a check for already installed containers before installing the server/container - added a button to scan the server for installed containers - added separation for read/write and readonly servers for pageHome
This commit is contained in:
parent
3a264e6baf
commit
249be451f7
21 changed files with 466 additions and 245 deletions
|
@ -268,5 +268,6 @@
|
||||||
<file>images/controls/github.svg</file>
|
<file>images/controls/github.svg</file>
|
||||||
<file>images/controls/mail.svg</file>
|
<file>images/controls/mail.svg</file>
|
||||||
<file>images/controls/telegram.svg</file>
|
<file>images/controls/telegram.svg</file>
|
||||||
|
<file>ui/qml/Controls2/TextTypes/SmallTextType.qml</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
|
|
@ -6,39 +6,27 @@
|
||||||
|
|
||||||
ConnectionController::ConnectionController(const QSharedPointer<ServersModel> &serversModel,
|
ConnectionController::ConnectionController(const QSharedPointer<ServersModel> &serversModel,
|
||||||
const QSharedPointer<ContainersModel> &containersModel,
|
const QSharedPointer<ContainersModel> &containersModel,
|
||||||
const QSharedPointer<VpnConnection> &vpnConnection,
|
const QSharedPointer<VpnConnection> &vpnConnection, QObject *parent)
|
||||||
QObject *parent)
|
: QObject(parent), m_serversModel(serversModel), m_containersModel(containersModel), m_vpnConnection(vpnConnection)
|
||||||
: QObject(parent)
|
|
||||||
, m_serversModel(serversModel)
|
|
||||||
, m_containersModel(containersModel)
|
|
||||||
, m_vpnConnection(vpnConnection)
|
|
||||||
{
|
{
|
||||||
connect(m_vpnConnection.get(),
|
connect(m_vpnConnection.get(), &VpnConnection::connectionStateChanged, this,
|
||||||
&VpnConnection::connectionStateChanged,
|
&ConnectionController::onConnectionStateChanged);
|
||||||
this,
|
connect(this, &ConnectionController::connectToVpn, m_vpnConnection.get(), &VpnConnection::connectToVpn,
|
||||||
&ConnectionController::connectionStateChanged);
|
|
||||||
connect(this,
|
|
||||||
&ConnectionController::connectToVpn,
|
|
||||||
m_vpnConnection.get(),
|
|
||||||
&VpnConnection::connectToVpn,
|
|
||||||
Qt::QueuedConnection);
|
Qt::QueuedConnection);
|
||||||
connect(this,
|
connect(this, &ConnectionController::disconnectFromVpn, m_vpnConnection.get(), &VpnConnection::disconnectFromVpn,
|
||||||
&ConnectionController::disconnectFromVpn,
|
|
||||||
m_vpnConnection.get(),
|
|
||||||
&VpnConnection::disconnectFromVpn,
|
|
||||||
Qt::QueuedConnection);
|
Qt::QueuedConnection);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConnectionController::openConnection()
|
void ConnectionController::openConnection()
|
||||||
{
|
{
|
||||||
int serverIndex = m_serversModel->getDefaultServerIndex();
|
int serverIndex = m_serversModel->getDefaultServerIndex();
|
||||||
ServerCredentials credentials = qvariant_cast<ServerCredentials>(
|
ServerCredentials credentials =
|
||||||
m_serversModel->data(serverIndex, ServersModel::ServersModelRoles::CredentialsRole));
|
qvariant_cast<ServerCredentials>(m_serversModel->data(serverIndex, ServersModel::Roles::CredentialsRole));
|
||||||
|
|
||||||
DockerContainer container = m_containersModel->getDefaultContainer();
|
DockerContainer container = m_containersModel->getDefaultContainer();
|
||||||
QModelIndex containerModelIndex = m_containersModel->index(container);
|
QModelIndex containerModelIndex = m_containersModel->index(container);
|
||||||
const QJsonObject &containerConfig = qvariant_cast<QJsonObject>(m_containersModel->data(containerModelIndex,
|
const QJsonObject &containerConfig =
|
||||||
ContainersModel::Roles::ConfigRole));
|
qvariant_cast<QJsonObject>(m_containersModel->data(containerModelIndex, ContainersModel::Roles::ConfigRole));
|
||||||
|
|
||||||
if (container == DockerContainer::None) {
|
if (container == DockerContainer::None) {
|
||||||
emit connectionErrorOccurred(tr("VPN Protocols is not installed.\n Please install VPN container at first"));
|
emit connectionErrorOccurred(tr("VPN Protocols is not installed.\n Please install VPN container at first"));
|
||||||
|
@ -59,13 +47,65 @@ QString ConnectionController::getLastConnectionError()
|
||||||
return errorString(m_vpnConnection->lastError());
|
return errorString(m_vpnConnection->lastError());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ConnectionController::isConnected()
|
void ConnectionController::onConnectionStateChanged(Vpn::ConnectionState state)
|
||||||
|
{
|
||||||
|
m_isConnected = false;
|
||||||
|
m_connectionStateText = tr("Connection...");
|
||||||
|
switch (state) {
|
||||||
|
case Vpn::ConnectionState::Connected: {
|
||||||
|
m_isConnectionInProgress = false;
|
||||||
|
m_isConnected = true;
|
||||||
|
m_connectionStateText = tr("Disconnect");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case Vpn::ConnectionState::Connecting: {
|
||||||
|
m_isConnectionInProgress = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case Vpn::ConnectionState::Reconnecting: {
|
||||||
|
m_isConnectionInProgress = true;
|
||||||
|
m_connectionStateText = tr("Reconnection...");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case Vpn::ConnectionState::Disconnected: {
|
||||||
|
m_isConnectionInProgress = false;
|
||||||
|
m_connectionStateText = tr("Connect");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case Vpn::ConnectionState::Disconnecting: {
|
||||||
|
m_isConnectionInProgress = true;
|
||||||
|
m_connectionStateText = tr("Disconnection...");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case Vpn::ConnectionState::Preparing: {
|
||||||
|
m_isConnectionInProgress = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case Vpn::ConnectionState::Error: {
|
||||||
|
m_isConnectionInProgress = false;
|
||||||
|
emit connectionErrorOccurred(getLastConnectionError());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case Vpn::ConnectionState::Unknown: {
|
||||||
|
m_isConnectionInProgress = false;
|
||||||
|
emit connectionErrorOccurred(getLastConnectionError());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
emit connectionStateChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
QString ConnectionController::connectionStateText() const
|
||||||
|
{
|
||||||
|
return m_connectionStateText;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ConnectionController::isConnectionInProgress() const
|
||||||
|
{
|
||||||
|
return m_isConnectionInProgress;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ConnectionController::isConnected() const
|
||||||
{
|
{
|
||||||
return m_isConnected;
|
return m_isConnected;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConnectionController::setIsConnected(bool isConnected)
|
|
||||||
{
|
|
||||||
m_isConnected = isConnected;
|
|
||||||
emit isConnectedChanged();
|
|
||||||
}
|
|
||||||
|
|
|
@ -11,28 +11,30 @@ class ConnectionController : public QObject
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Q_PROPERTY(bool isConnected READ isConnected WRITE setIsConnected NOTIFY isConnectedChanged)
|
Q_PROPERTY(bool isConnected READ isConnected NOTIFY connectionStateChanged)
|
||||||
|
Q_PROPERTY(bool isConnectionInProgress READ isConnectionInProgress NOTIFY connectionStateChanged)
|
||||||
|
Q_PROPERTY(QString connectionStateText READ connectionStateText NOTIFY connectionStateChanged)
|
||||||
|
|
||||||
explicit ConnectionController(const QSharedPointer<ServersModel> &serversModel,
|
explicit ConnectionController(const QSharedPointer<ServersModel> &serversModel,
|
||||||
const QSharedPointer<ContainersModel> &containersModel,
|
const QSharedPointer<ContainersModel> &containersModel,
|
||||||
const QSharedPointer<VpnConnection> &vpnConnection,
|
const QSharedPointer<VpnConnection> &vpnConnection,
|
||||||
QObject *parent = nullptr);
|
QObject *parent = nullptr);
|
||||||
|
|
||||||
bool isConnected();
|
bool isConnected() const;
|
||||||
void setIsConnected(bool isConnected); //todo take state from vpnconnection?
|
bool isConnectionInProgress() const;
|
||||||
|
QString connectionStateText() const;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void openConnection();
|
void openConnection();
|
||||||
void closeConnection();
|
void closeConnection();
|
||||||
|
|
||||||
QString getLastConnectionError();
|
QString getLastConnectionError();
|
||||||
Vpn::ConnectionState connectionState(){return {};}; //todo update ConnectButton text on page change
|
void onConnectionStateChanged(Vpn::ConnectionState state);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void connectToVpn(int serverIndex, const ServerCredentials &credentials, DockerContainer container, const QJsonObject &containerConfig);
|
void connectToVpn(int serverIndex, const ServerCredentials &credentials, DockerContainer container, const QJsonObject &containerConfig);
|
||||||
void disconnectFromVpn();
|
void disconnectFromVpn();
|
||||||
void connectionStateChanged(Vpn::ConnectionState state);
|
void connectionStateChanged();
|
||||||
void isConnectedChanged();
|
|
||||||
|
|
||||||
void connectionErrorOccurred(QString errorMessage);
|
void connectionErrorOccurred(QString errorMessage);
|
||||||
|
|
||||||
|
@ -43,6 +45,8 @@ private:
|
||||||
QSharedPointer<VpnConnection> m_vpnConnection;
|
QSharedPointer<VpnConnection> m_vpnConnection;
|
||||||
|
|
||||||
bool m_isConnected = false;
|
bool m_isConnected = false;
|
||||||
|
bool m_isConnectionInProgress = false;
|
||||||
|
QString m_connectionStateText = tr("Connect");
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CONNECTIONCONTROLLER_H
|
#endif // CONNECTIONCONTROLLER_H
|
||||||
|
|
|
@ -44,7 +44,7 @@ void ExportController::generateConnectionConfig()
|
||||||
{
|
{
|
||||||
int serverIndex = m_serversModel->getCurrentlyProcessedServerIndex();
|
int serverIndex = m_serversModel->getCurrentlyProcessedServerIndex();
|
||||||
ServerCredentials credentials = qvariant_cast<ServerCredentials>(
|
ServerCredentials credentials = qvariant_cast<ServerCredentials>(
|
||||||
m_serversModel->data(serverIndex, ServersModel::ServersModelRoles::CredentialsRole));
|
m_serversModel->data(serverIndex, ServersModel::Roles::CredentialsRole));
|
||||||
|
|
||||||
DockerContainer container = static_cast<DockerContainer>(
|
DockerContainer container = static_cast<DockerContainer>(
|
||||||
m_containersModel->getCurrentlyProcessedContainerIndex());
|
m_containersModel->getCurrentlyProcessedContainerIndex());
|
||||||
|
|
|
@ -89,7 +89,7 @@ void ImportController::importConfig()
|
||||||
|
|
||||||
if (!m_config.value(config_key::containers).toArray().isEmpty()) {
|
if (!m_config.value(config_key::containers).toArray().isEmpty()) {
|
||||||
auto newServerIndex = m_serversModel->index(m_serversModel->getServersCount() - 1);
|
auto newServerIndex = m_serversModel->index(m_serversModel->getServersCount() - 1);
|
||||||
m_serversModel->setData(newServerIndex, true, ServersModel::ServersModelRoles::IsDefaultRole);
|
m_serversModel->setData(newServerIndex, true, ServersModel::Roles::IsDefaultRole);
|
||||||
}
|
}
|
||||||
|
|
||||||
emit importFinished();
|
emit importFinished();
|
||||||
|
|
|
@ -2,40 +2,54 @@
|
||||||
|
|
||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
|
|
||||||
#include "core/servercontroller.h"
|
|
||||||
#include "core/errorstrings.h"
|
#include "core/errorstrings.h"
|
||||||
|
#include "core/servercontroller.h"
|
||||||
|
#include "utilities.h"
|
||||||
|
|
||||||
InstallController::InstallController(const QSharedPointer<ServersModel> &serversModel,
|
InstallController::InstallController(const QSharedPointer<ServersModel> &serversModel,
|
||||||
const QSharedPointer<ContainersModel> &containersModel,
|
const QSharedPointer<ContainersModel> &containersModel,
|
||||||
const std::shared_ptr<Settings> &settings,
|
const std::shared_ptr<Settings> &settings, QObject *parent)
|
||||||
QObject *parent) : QObject(parent), m_serversModel(serversModel), m_containersModel(containersModel), m_settings(settings)
|
: QObject(parent), m_serversModel(serversModel), m_containersModel(containersModel), m_settings(settings)
|
||||||
{}
|
{
|
||||||
|
}
|
||||||
|
|
||||||
void InstallController::install(DockerContainer container, int port, TransportProto transportProto)
|
void InstallController::install(DockerContainer container, int port, TransportProto transportProto)
|
||||||
{
|
{
|
||||||
Proto mainProto = ContainerProps::defaultProtocol(container);
|
Proto mainProto = ContainerProps::defaultProtocol(container);
|
||||||
|
|
||||||
QJsonObject containerConfig {
|
QJsonObject containerConfig { { config_key::port, QString::number(port) },
|
||||||
{ config_key::port, QString::number(port) },
|
{ config_key::transport_proto,
|
||||||
{ config_key::transport_proto, ProtocolProps::transportProtoToString(transportProto, mainProto) }
|
ProtocolProps::transportProtoToString(transportProto, mainProto) } };
|
||||||
};
|
QJsonObject config { { config_key::container, ContainerProps::containerToString(container) },
|
||||||
QJsonObject config {
|
{ ProtocolProps::protoToString(mainProto), containerConfig } };
|
||||||
{ config_key::container, ContainerProps::containerToString(container) },
|
|
||||||
{ ProtocolProps::protoToString(mainProto), containerConfig }
|
|
||||||
};
|
|
||||||
|
|
||||||
if (m_shouldCreateServer) {
|
if (m_shouldCreateServer) {
|
||||||
|
if (isServerAlreadyExists()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
installServer(container, config);
|
installServer(container, config);
|
||||||
} else {
|
} else {
|
||||||
installContainer(container, config);
|
installContainer(container, config);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void InstallController::installServer(DockerContainer container, QJsonObject& config)
|
void InstallController::installServer(DockerContainer container, QJsonObject &config)
|
||||||
{
|
{
|
||||||
//todo check if container already installed
|
|
||||||
ServerController serverController(m_settings);
|
ServerController serverController(m_settings);
|
||||||
ErrorCode errorCode = serverController.setupContainer(m_currentlyInstalledServerCredentials, container, config);
|
|
||||||
|
QMap<DockerContainer, QJsonObject> installedContainers;
|
||||||
|
ErrorCode errorCode =
|
||||||
|
serverController.getAlreadyInstalledContainers(m_currentlyInstalledServerCredentials, installedContainers);
|
||||||
|
if (!installedContainers.contains(container)) {
|
||||||
|
errorCode = serverController.setupContainer(m_currentlyInstalledServerCredentials, container, config);
|
||||||
|
installedContainers.insert(container, config);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isInstalledContainerFound = false;
|
||||||
|
if (!installedContainers.isEmpty()) {
|
||||||
|
isInstalledContainerFound = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (errorCode == ErrorCode::NoError) {
|
if (errorCode == ErrorCode::NoError) {
|
||||||
QJsonObject server;
|
QJsonObject server;
|
||||||
server.insert(config_key::hostName, m_currentlyInstalledServerCredentials.hostName);
|
server.insert(config_key::hostName, m_currentlyInstalledServerCredentials.hostName);
|
||||||
|
@ -44,43 +58,123 @@ void InstallController::installServer(DockerContainer container, QJsonObject& co
|
||||||
server.insert(config_key::port, m_currentlyInstalledServerCredentials.port);
|
server.insert(config_key::port, m_currentlyInstalledServerCredentials.port);
|
||||||
server.insert(config_key::description, m_settings->nextAvailableServerName());
|
server.insert(config_key::description, m_settings->nextAvailableServerName());
|
||||||
|
|
||||||
server.insert(config_key::containers, QJsonArray{ config });
|
QJsonArray containerConfigs;
|
||||||
|
for (const QJsonObject &containerConfig : qAsConst(installedContainers)) {
|
||||||
|
containerConfigs.append(containerConfig);
|
||||||
|
}
|
||||||
|
|
||||||
|
server.insert(config_key::containers, containerConfigs);
|
||||||
server.insert(config_key::defaultContainer, ContainerProps::containerToString(container));
|
server.insert(config_key::defaultContainer, ContainerProps::containerToString(container));
|
||||||
|
|
||||||
m_serversModel->addServer(server);
|
m_serversModel->addServer(server);
|
||||||
auto newServerIndex = m_serversModel->index(m_serversModel->getServersCount() - 1);
|
auto newServerIndex = m_serversModel->index(m_serversModel->getServersCount() - 1);
|
||||||
m_serversModel->setData(newServerIndex, true, ServersModel::ServersModelRoles::IsDefaultRole);
|
m_serversModel->setData(newServerIndex, true, ServersModel::Roles::IsDefaultRole);
|
||||||
|
|
||||||
emit installServerFinished();
|
emit installServerFinished(isInstalledContainerFound);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
emit installationErrorOccurred(errorString(errorCode));
|
emit installationErrorOccurred(errorString(errorCode));
|
||||||
}
|
}
|
||||||
|
|
||||||
void InstallController::installContainer(DockerContainer container, QJsonObject& config)
|
void InstallController::installContainer(DockerContainer container, QJsonObject &config)
|
||||||
{
|
{
|
||||||
//todo check if container already installed
|
|
||||||
int serverIndex = m_serversModel->getCurrentlyProcessedServerIndex();
|
int serverIndex = m_serversModel->getCurrentlyProcessedServerIndex();
|
||||||
ServerCredentials serverCredentials = qvariant_cast<ServerCredentials>(
|
ServerCredentials serverCredentials =
|
||||||
m_serversModel->data(serverIndex, ServersModel::ServersModelRoles::CredentialsRole));
|
qvariant_cast<ServerCredentials>(m_serversModel->data(serverIndex, ServersModel::Roles::CredentialsRole));
|
||||||
|
|
||||||
ServerController serverController(m_settings);
|
ServerController serverController(m_settings);
|
||||||
ErrorCode errorCode = serverController.setupContainer(serverCredentials, container, config);
|
|
||||||
|
QMap<DockerContainer, QJsonObject> installedContainers;
|
||||||
|
ErrorCode errorCode = serverController.getAlreadyInstalledContainers(serverCredentials, installedContainers);
|
||||||
|
|
||||||
|
bool isInstalledContainerFound = false;
|
||||||
|
if (!installedContainers.isEmpty()) {
|
||||||
|
isInstalledContainerFound = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!installedContainers.contains(container)) {
|
||||||
|
errorCode = serverController.setupContainer(serverCredentials, container, config);
|
||||||
|
installedContainers.insert(container, config);
|
||||||
|
}
|
||||||
|
|
||||||
if (errorCode == ErrorCode::NoError) {
|
if (errorCode == ErrorCode::NoError) {
|
||||||
m_containersModel->setData(m_containersModel->index(container), config, ContainersModel::Roles::ConfigRole);
|
for (auto iterator = installedContainers.begin(); iterator != installedContainers.end(); iterator++) {
|
||||||
emit installContainerFinished();
|
auto modelIndex = m_containersModel->index(iterator.key());
|
||||||
|
QJsonObject containerConfig =
|
||||||
|
qvariant_cast<QJsonObject>(m_containersModel->data(modelIndex, ContainersModel::Roles::ConfigRole));
|
||||||
|
if (containerConfig.isEmpty()) {
|
||||||
|
m_containersModel->setData(m_containersModel->index(iterator.key()), iterator.value(),
|
||||||
|
ContainersModel::Roles::ConfigRole);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
emit installContainerFinished(isInstalledContainerFound);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
emit installationErrorOccurred(errorString(errorCode));
|
emit installationErrorOccurred(errorString(errorCode));
|
||||||
}
|
}
|
||||||
|
|
||||||
void InstallController::setCurrentlyInstalledServerCredentials(const QString &hostName, const QString &userName, const QString &secretData)
|
bool InstallController::isServerAlreadyExists()
|
||||||
|
{
|
||||||
|
for (int i = 0; i < m_serversModel->getServersCount(); i++) {
|
||||||
|
auto modelIndex = m_serversModel->index(i);
|
||||||
|
const ServerCredentials credentials =
|
||||||
|
qvariant_cast<ServerCredentials>(m_serversModel->data(modelIndex, ServersModel::Roles::CredentialsRole));
|
||||||
|
if (m_currentlyInstalledServerCredentials.hostName == credentials.hostName
|
||||||
|
&& m_currentlyInstalledServerCredentials.port == credentials.port) {
|
||||||
|
emit serverAlreadyExists(i);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void InstallController::scanServerForInstalledContainers()
|
||||||
|
{
|
||||||
|
int serverIndex = m_serversModel->getCurrentlyProcessedServerIndex();
|
||||||
|
ServerCredentials serverCredentials =
|
||||||
|
qvariant_cast<ServerCredentials>(m_serversModel->data(serverIndex, ServersModel::Roles::CredentialsRole));
|
||||||
|
|
||||||
|
ServerController serverController(m_settings);
|
||||||
|
|
||||||
|
QMap<DockerContainer, QJsonObject> installedContainers;
|
||||||
|
ErrorCode errorCode = serverController.getAlreadyInstalledContainers(serverCredentials, installedContainers);
|
||||||
|
|
||||||
|
if (errorCode == ErrorCode::NoError) {
|
||||||
|
bool isInstalledContainerAddedToGui = false;
|
||||||
|
|
||||||
|
for (auto iterator = installedContainers.begin(); iterator != installedContainers.end(); iterator++) {
|
||||||
|
auto modelIndex = m_containersModel->index(iterator.key());
|
||||||
|
QJsonObject containerConfig =
|
||||||
|
qvariant_cast<QJsonObject>(m_containersModel->data(modelIndex, ContainersModel::Roles::ConfigRole));
|
||||||
|
if (containerConfig.isEmpty()) {
|
||||||
|
m_containersModel->setData(m_containersModel->index(iterator.key()), iterator.value(),
|
||||||
|
ContainersModel::Roles::ConfigRole);
|
||||||
|
isInstalledContainerAddedToGui = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
emit scanServerFinished(isInstalledContainerAddedToGui);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
emit installationErrorOccurred(errorString(errorCode));
|
||||||
|
}
|
||||||
|
|
||||||
|
QRegularExpression InstallController::ipAddressPortRegExp()
|
||||||
|
{
|
||||||
|
return Utils::ipAddressPortRegExp();
|
||||||
|
}
|
||||||
|
|
||||||
|
void InstallController::setCurrentlyInstalledServerCredentials(const QString &hostName, const QString &userName,
|
||||||
|
const QString &secretData)
|
||||||
{
|
{
|
||||||
m_currentlyInstalledServerCredentials.hostName = hostName;
|
m_currentlyInstalledServerCredentials.hostName = hostName;
|
||||||
if (m_currentlyInstalledServerCredentials.hostName.contains(":")) {
|
if (m_currentlyInstalledServerCredentials.hostName.contains(":")) {
|
||||||
m_currentlyInstalledServerCredentials.port = m_currentlyInstalledServerCredentials.hostName.split(":").at(1).toInt();
|
m_currentlyInstalledServerCredentials.port =
|
||||||
|
m_currentlyInstalledServerCredentials.hostName.split(":").at(1).toInt();
|
||||||
m_currentlyInstalledServerCredentials.hostName = m_currentlyInstalledServerCredentials.hostName.split(":").at(0);
|
m_currentlyInstalledServerCredentials.hostName = m_currentlyInstalledServerCredentials.hostName.split(":").at(0);
|
||||||
}
|
}
|
||||||
m_currentlyInstalledServerCredentials.userName = userName;
|
m_currentlyInstalledServerCredentials.userName = userName;
|
||||||
|
|
|
@ -3,10 +3,10 @@
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
#include "core/defs.h"
|
|
||||||
#include "containers/containers_defs.h"
|
#include "containers/containers_defs.h"
|
||||||
#include "ui/models/servers_model.h"
|
#include "core/defs.h"
|
||||||
#include "ui/models/containers_model.h"
|
#include "ui/models/containers_model.h"
|
||||||
|
#include "ui/models/servers_model.h"
|
||||||
|
|
||||||
class InstallController : public QObject
|
class InstallController : public QObject
|
||||||
{
|
{
|
||||||
|
@ -14,22 +14,32 @@ class InstallController : public QObject
|
||||||
public:
|
public:
|
||||||
explicit InstallController(const QSharedPointer<ServersModel> &serversModel,
|
explicit InstallController(const QSharedPointer<ServersModel> &serversModel,
|
||||||
const QSharedPointer<ContainersModel> &containersModel,
|
const QSharedPointer<ContainersModel> &containersModel,
|
||||||
const std::shared_ptr<Settings> &settings,
|
const std::shared_ptr<Settings> &settings, QObject *parent = nullptr);
|
||||||
QObject *parent = nullptr);
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void install(DockerContainer container, int port, TransportProto transportProto);
|
void install(DockerContainer container, int port, TransportProto transportProto);
|
||||||
void setCurrentlyInstalledServerCredentials(const QString &hostName, const QString &userName, const QString &secretData);
|
void setCurrentlyInstalledServerCredentials(const QString &hostName, const QString &userName,
|
||||||
|
const QString &secretData);
|
||||||
void setShouldCreateServer(bool shouldCreateServer);
|
void setShouldCreateServer(bool shouldCreateServer);
|
||||||
|
|
||||||
|
void scanServerForInstalledContainers();
|
||||||
|
|
||||||
|
QRegularExpression ipAddressPortRegExp();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void installContainerFinished();
|
void installContainerFinished(bool isInstalledContainerFound);
|
||||||
void installServerFinished();
|
void installServerFinished(bool isInstalledContainerFound);
|
||||||
|
|
||||||
|
void scanServerFinished(bool isInstalledContainerFound);
|
||||||
|
|
||||||
void installationErrorOccurred(QString errorMessage);
|
void installationErrorOccurred(QString errorMessage);
|
||||||
|
|
||||||
|
void serverAlreadyExists(int serverIndex);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void installServer(DockerContainer container, QJsonObject& config);
|
void installServer(DockerContainer container, QJsonObject &config);
|
||||||
void installContainer(DockerContainer container, QJsonObject& config);
|
void installContainer(DockerContainer container, QJsonObject &config);
|
||||||
|
bool isServerAlreadyExists();
|
||||||
|
|
||||||
QSharedPointer<ServersModel> m_serversModel;
|
QSharedPointer<ServersModel> m_serversModel;
|
||||||
QSharedPointer<ContainersModel> m_containersModel;
|
QSharedPointer<ContainersModel> m_containersModel;
|
||||||
|
|
|
@ -10,7 +10,7 @@ QString PageController::getInitialPage()
|
||||||
if (m_serversModel->getServersCount()) {
|
if (m_serversModel->getServersCount()) {
|
||||||
if (m_serversModel->getDefaultServerIndex() < 0) {
|
if (m_serversModel->getDefaultServerIndex() < 0) {
|
||||||
auto defaultServerIndex = m_serversModel->index(0);
|
auto defaultServerIndex = m_serversModel->index(0);
|
||||||
m_serversModel->setData(defaultServerIndex, true, ServersModel::ServersModelRoles::IsDefaultRole);
|
m_serversModel->setData(defaultServerIndex, true, ServersModel::Roles::IsDefaultRole);
|
||||||
}
|
}
|
||||||
return getPagePath(PageLoader::PageEnum::PageStart);
|
return getPagePath(PageLoader::PageEnum::PageStart);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -40,14 +40,9 @@ namespace PageLoader
|
||||||
};
|
};
|
||||||
Q_ENUM_NS(PageEnum)
|
Q_ENUM_NS(PageEnum)
|
||||||
|
|
||||||
static void declareQmlPageEnum() {
|
static void declareQmlPageEnum()
|
||||||
qmlRegisterUncreatableMetaObject(
|
{
|
||||||
PageLoader::staticMetaObject,
|
qmlRegisterUncreatableMetaObject(PageLoader::staticMetaObject, "PageEnum", 1, 0, "PageEnum", "Error: only enums");
|
||||||
"PageEnum",
|
|
||||||
1, 0,
|
|
||||||
"PageEnum",
|
|
||||||
"Error: only enums"
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,8 +50,7 @@ class PageController : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit PageController(const QSharedPointer<ServersModel> &serversModel,
|
explicit PageController(const QSharedPointer<ServersModel> &serversModel, QObject *parent = nullptr);
|
||||||
QObject *parent = nullptr);
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
QString getInitialPage();
|
QString getInitialPage();
|
||||||
|
@ -64,9 +58,11 @@ public slots:
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void goToPageHome();
|
void goToPageHome();
|
||||||
|
void goToPageSettings();
|
||||||
void restorePageHomeState(bool isContainerInstalled = false);
|
void restorePageHomeState(bool isContainerInstalled = false);
|
||||||
void replaceStartPage();
|
void replaceStartPage();
|
||||||
void showErrorMessage(QString errorMessage);
|
void showErrorMessage(QString errorMessage);
|
||||||
|
void showInfoMessage(QString message);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QSharedPointer<ServersModel> m_serversModel;
|
QSharedPointer<ServersModel> m_serversModel;
|
||||||
|
|
|
@ -2,7 +2,8 @@
|
||||||
|
|
||||||
#include "core/servercontroller.h"
|
#include "core/servercontroller.h"
|
||||||
|
|
||||||
ContainersModel::ContainersModel(std::shared_ptr<Settings> settings, QObject *parent) : m_settings(settings), QAbstractListModel(parent)
|
ContainersModel::ContainersModel(std::shared_ptr<Settings> settings, QObject *parent)
|
||||||
|
: m_settings(settings), QAbstractListModel(parent)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,25 +22,25 @@ bool ContainersModel::setData(const QModelIndex &index, const QVariant &value, i
|
||||||
DockerContainer container = ContainerProps::allContainers().at(index.row());
|
DockerContainer container = ContainerProps::allContainers().at(index.row());
|
||||||
|
|
||||||
switch (role) {
|
switch (role) {
|
||||||
case NameRole:
|
case NameRole:
|
||||||
// return ContainerProps::containerHumanNames().value(container);
|
// return ContainerProps::containerHumanNames().value(container);
|
||||||
case DescRole:
|
case DescRole:
|
||||||
// return ContainerProps::containerDescriptions().value(container);
|
// return ContainerProps::containerDescriptions().value(container);
|
||||||
case ConfigRole: //todo save to model also
|
case ConfigRole: {
|
||||||
m_settings->setContainerConfig(m_currentlyProcessedServerIndex,
|
m_settings->setContainerConfig(m_currentlyProcessedServerIndex, container, value.toJsonObject());
|
||||||
container,
|
m_containers = m_settings->containers(m_currentlyProcessedServerIndex);
|
||||||
value.toJsonObject());
|
}
|
||||||
case ServiceTypeRole:
|
case ServiceTypeRole:
|
||||||
// return ContainerProps::containerService(container);
|
// return ContainerProps::containerService(container);
|
||||||
case DockerContainerRole:
|
case DockerContainerRole:
|
||||||
// return container;
|
// return container;
|
||||||
case IsInstalledRole:
|
case IsInstalledRole:
|
||||||
// return m_settings->containers(m_currentlyProcessedServerIndex).contains(container);
|
// return m_settings->containers(m_currentlyProcessedServerIndex).contains(container);
|
||||||
case IsDefaultRole: {
|
case IsDefaultRole: {
|
||||||
m_settings->setDefaultContainer(m_currentlyProcessedServerIndex, container);
|
m_settings->setDefaultContainer(m_currentlyProcessedServerIndex, container);
|
||||||
m_defaultContainerIndex = container;
|
m_defaultContainerIndex = container;
|
||||||
emit defaultContainerChanged();
|
emit defaultContainerChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
emit dataChanged(index, index);
|
emit dataChanged(index, index);
|
||||||
|
@ -48,40 +49,30 @@ bool ContainersModel::setData(const QModelIndex &index, const QVariant &value, i
|
||||||
|
|
||||||
QVariant ContainersModel::data(const QModelIndex &index, int role) const
|
QVariant ContainersModel::data(const QModelIndex &index, int role) const
|
||||||
{
|
{
|
||||||
if (!index.isValid() || index.row() < 0
|
if (!index.isValid() || index.row() < 0 || index.row() >= ContainerProps::allContainers().size()) {
|
||||||
|| index.row() >= ContainerProps::allContainers().size()) {
|
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
DockerContainer container = ContainerProps::allContainers().at(index.row());
|
DockerContainer container = ContainerProps::allContainers().at(index.row());
|
||||||
|
|
||||||
switch (role) {
|
switch (role) {
|
||||||
case NameRole:
|
case NameRole: return ContainerProps::containerHumanNames().value(container);
|
||||||
return ContainerProps::containerHumanNames().value(container);
|
case DescRole: return ContainerProps::containerDescriptions().value(container);
|
||||||
case DescRole:
|
case ConfigRole: {
|
||||||
return ContainerProps::containerDescriptions().value(container);
|
if (container == DockerContainer::None) {
|
||||||
case ConfigRole: {
|
return QJsonObject();
|
||||||
if (container == DockerContainer::None) return QJsonObject();
|
|
||||||
return m_containers.value(container);
|
|
||||||
}
|
}
|
||||||
case ServiceTypeRole:
|
return m_containers.value(container);
|
||||||
return ContainerProps::containerService(container);
|
}
|
||||||
case DockerContainerRole:
|
case ServiceTypeRole: return ContainerProps::containerService(container);
|
||||||
return container;
|
case DockerContainerRole: return container;
|
||||||
case IsEasySetupContainerRole:
|
case IsEasySetupContainerRole: return ContainerProps::isEasySetupContainer(container);
|
||||||
return ContainerProps::isEasySetupContainer(container);
|
case EasySetupHeaderRole: return ContainerProps::easySetupHeader(container);
|
||||||
case EasySetupHeaderRole:
|
case EasySetupDescriptionRole: return ContainerProps::easySetupDescription(container);
|
||||||
return ContainerProps::easySetupHeader(container);
|
case IsInstalledRole: return m_containers.contains(container);
|
||||||
case EasySetupDescriptionRole:
|
case IsCurrentlyProcessedRole: return container == static_cast<DockerContainer>(m_currentlyProcessedContainerIndex);
|
||||||
return ContainerProps::easySetupDescription(container);
|
case IsDefaultRole: return container == m_defaultContainerIndex;
|
||||||
case IsInstalledRole:
|
case IsSupportedRole: return ContainerProps::isSupportedByCurrentPlatform(container);
|
||||||
return m_containers.contains(container);
|
|
||||||
case IsCurrentlyProcessedRole:
|
|
||||||
return container == static_cast<DockerContainer>(m_currentlyProcessedContainerIndex);
|
|
||||||
case IsDefaultRole:
|
|
||||||
return container == m_defaultContainerIndex;
|
|
||||||
case IsSupportedRole:
|
|
||||||
return ContainerProps::isSupportedByCurrentPlatform(container);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
@ -130,7 +121,7 @@ void ContainersModel::removeAllContainers()
|
||||||
endResetModel();
|
endResetModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
//todo process errors
|
// todo process errors
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContainersModel::clearCachedProfiles()
|
void ContainersModel::clearCachedProfiles()
|
||||||
|
@ -141,7 +132,8 @@ void ContainersModel::clearCachedProfiles()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QHash<int, QByteArray> ContainersModel::roleNames() const {
|
QHash<int, QByteArray> ContainersModel::roleNames() const
|
||||||
|
{
|
||||||
QHash<int, QByteArray> roles;
|
QHash<int, QByteArray> roles;
|
||||||
roles[NameRole] = "name";
|
roles[NameRole] = "name";
|
||||||
roles[DescRole] = "description";
|
roles[DescRole] = "description";
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#include "servers_model.h"
|
#include "servers_model.h"
|
||||||
|
|
||||||
ServersModel::ServersModel(std::shared_ptr<Settings> settings, QObject *parent) : m_settings(settings), QAbstractListModel(parent)
|
ServersModel::ServersModel(std::shared_ptr<Settings> settings, QObject *parent)
|
||||||
|
: m_settings(settings), QAbstractListModel(parent)
|
||||||
{
|
{
|
||||||
m_servers = m_settings->serversArray();
|
m_servers = m_settings->serversArray();
|
||||||
m_defaultServerIndex = m_settings->defaultServerIndex();
|
m_defaultServerIndex = m_settings->defaultServerIndex();
|
||||||
|
@ -14,8 +15,7 @@ int ServersModel::rowCount(const QModelIndex &parent) const
|
||||||
|
|
||||||
bool ServersModel::setData(const QModelIndex &index, const QVariant &value, int role)
|
bool ServersModel::setData(const QModelIndex &index, const QVariant &value, int role)
|
||||||
{
|
{
|
||||||
if (!index.isValid() || index.row() < 0
|
if (!index.isValid() || index.row() < 0 || index.row() >= static_cast<int>(m_servers.size())) {
|
||||||
|| index.row() >= static_cast<int>(m_servers.size())) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,8 +29,7 @@ bool ServersModel::setData(const QModelIndex &index, const QVariant &value, int
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case IsDefaultRole: {
|
case IsDefaultRole: {
|
||||||
m_settings->setDefaultServer(index.row());
|
setDefaultServerIndex(index.row());
|
||||||
m_defaultServerIndex = m_settings->defaultServerIndex();
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
|
@ -58,16 +57,11 @@ QVariant ServersModel::data(const QModelIndex &index, int role) const
|
||||||
}
|
}
|
||||||
return description;
|
return description;
|
||||||
}
|
}
|
||||||
case HostNameRole:
|
case HostNameRole: return server.value(config_key::hostName).toString();
|
||||||
return server.value(config_key::hostName).toString();
|
case CredentialsRole: return QVariant::fromValue(m_settings->serverCredentials(index.row()));
|
||||||
case CredentialsRole:
|
case CredentialsLoginRole: return m_settings->serverCredentials(index.row()).userName;
|
||||||
return QVariant::fromValue(m_settings->serverCredentials(index.row()));
|
case IsDefaultRole: return index.row() == m_defaultServerIndex;
|
||||||
case CredentialsLoginRole:
|
case IsCurrentlyProcessedRole: return index.row() == m_currenlyProcessedServerIndex;
|
||||||
return m_settings->serverCredentials(index.row()).userName;
|
|
||||||
case IsDefaultRole:
|
|
||||||
return index.row() == m_defaultServerIndex;
|
|
||||||
case IsCurrentlyProcessedRole:
|
|
||||||
return index.row() == m_currenlyProcessedServerIndex;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
@ -92,6 +86,7 @@ const int ServersModel::getServersCount()
|
||||||
void ServersModel::setCurrentlyProcessedServerIndex(int index)
|
void ServersModel::setCurrentlyProcessedServerIndex(int index)
|
||||||
{
|
{
|
||||||
m_currenlyProcessedServerIndex = index;
|
m_currenlyProcessedServerIndex = index;
|
||||||
|
emit currentlyProcessedServerIndexChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
int ServersModel::getCurrentlyProcessedServerIndex()
|
int ServersModel::getCurrentlyProcessedServerIndex()
|
||||||
|
@ -104,6 +99,12 @@ bool ServersModel::isDefaultServerCurrentlyProcessed()
|
||||||
return m_defaultServerIndex == m_currenlyProcessedServerIndex;
|
return m_defaultServerIndex == m_currenlyProcessedServerIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ServersModel::isCurrentlyProcessedServerHasWriteAccess()
|
||||||
|
{
|
||||||
|
auto credentials = m_settings->serverCredentials(m_currenlyProcessedServerIndex);
|
||||||
|
return (!credentials.userName.isEmpty() && !credentials.secretData.isEmpty());
|
||||||
|
}
|
||||||
|
|
||||||
void ServersModel::addServer(const QJsonObject &server)
|
void ServersModel::addServer(const QJsonObject &server)
|
||||||
{
|
{
|
||||||
beginResetModel();
|
beginResetModel();
|
||||||
|
@ -119,18 +120,19 @@ void ServersModel::removeServer()
|
||||||
m_servers = m_settings->serversArray();
|
m_servers = m_settings->serversArray();
|
||||||
|
|
||||||
if (m_settings->defaultServerIndex() == m_currenlyProcessedServerIndex) {
|
if (m_settings->defaultServerIndex() == m_currenlyProcessedServerIndex) {
|
||||||
m_settings->setDefaultServer(0);
|
setDefaultServerIndex(0);
|
||||||
} else if (m_settings->defaultServerIndex() > m_currenlyProcessedServerIndex) {
|
} else if (m_settings->defaultServerIndex() > m_currenlyProcessedServerIndex) {
|
||||||
m_settings->setDefaultServer(m_settings->defaultServerIndex() - 1);
|
setDefaultServerIndex(m_settings->defaultServerIndex() - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_settings->serversCount() == 0) {
|
if (m_settings->serversCount() == 0) {
|
||||||
m_settings->setDefaultServer(-1);
|
setDefaultServerIndex(-1);
|
||||||
}
|
}
|
||||||
endResetModel();
|
endResetModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
QHash<int, QByteArray> ServersModel::roleNames() const {
|
QHash<int, QByteArray> ServersModel::roleNames() const
|
||||||
|
{
|
||||||
QHash<int, QByteArray> roles;
|
QHash<int, QByteArray> roles;
|
||||||
roles[NameRole] = "name";
|
roles[NameRole] = "name";
|
||||||
roles[HostNameRole] = "hostName";
|
roles[HostNameRole] = "hostName";
|
||||||
|
@ -140,3 +142,9 @@ QHash<int, QByteArray> ServersModel::roleNames() const {
|
||||||
roles[IsCurrentlyProcessedRole] = "isCurrentlyProcessed";
|
roles[IsCurrentlyProcessedRole] = "isCurrentlyProcessed";
|
||||||
return roles;
|
return roles;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ServersModel::setDefaultServerIndex(const int index)
|
||||||
|
{
|
||||||
|
m_settings->setDefaultServer(index);
|
||||||
|
m_defaultServerIndex = m_settings->defaultServerIndex();
|
||||||
|
}
|
||||||
|
|
|
@ -5,7 +5,8 @@
|
||||||
|
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
|
|
||||||
struct ServerModelContent {
|
struct ServerModelContent
|
||||||
|
{
|
||||||
QString desc;
|
QString desc;
|
||||||
QString address;
|
QString address;
|
||||||
bool isDefault;
|
bool isDefault;
|
||||||
|
@ -15,7 +16,7 @@ class ServersModel : public QAbstractListModel
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
enum ServersModelRoles {
|
enum Roles {
|
||||||
NameRole = Qt::UserRole + 1,
|
NameRole = Qt::UserRole + 1,
|
||||||
HostNameRole,
|
HostNameRole,
|
||||||
CredentialsRole,
|
CredentialsRole,
|
||||||
|
@ -35,6 +36,7 @@ public:
|
||||||
public slots:
|
public slots:
|
||||||
const int getDefaultServerIndex();
|
const int getDefaultServerIndex();
|
||||||
bool isDefaultServerCurrentlyProcessed();
|
bool isDefaultServerCurrentlyProcessed();
|
||||||
|
bool isCurrentlyProcessedServerHasWriteAccess();
|
||||||
|
|
||||||
const int getServersCount();
|
const int getServersCount();
|
||||||
|
|
||||||
|
@ -47,7 +49,12 @@ public slots:
|
||||||
protected:
|
protected:
|
||||||
QHash<int, QByteArray> roleNames() const override;
|
QHash<int, QByteArray> roleNames() const override;
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void currentlyProcessedServerIndexChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void setDefaultServerIndex(const int index);
|
||||||
|
|
||||||
QJsonArray m_servers;
|
QJsonArray m_servers;
|
||||||
|
|
||||||
std::shared_ptr<Settings> m_settings;
|
std::shared_ptr<Settings> m_settings;
|
||||||
|
|
|
@ -15,7 +15,7 @@ Button {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
text: qsTr("Connect")
|
text: ConnectionController.connectionStateText
|
||||||
|
|
||||||
background: Item {
|
background: Item {
|
||||||
clip: true
|
clip: true
|
||||||
|
@ -26,13 +26,21 @@ Button {
|
||||||
Image {
|
Image {
|
||||||
id: border
|
id: border
|
||||||
|
|
||||||
source: connectionProccess.running ? "/images/connectionProgress.svg" :
|
source: {
|
||||||
ConnectionController.isConnected ? "/images/connectionOff.svg" : "/images/connectionOn.svg"
|
if (ConnectionController.isConnectionInProgress) {
|
||||||
|
return "/images/connectionProgress.svg"
|
||||||
|
} else if (ConnectionController.isConnected) {
|
||||||
|
return "/images/connectionOff.svg"
|
||||||
|
} else {
|
||||||
|
return "/images/connectionOn.svg"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
RotationAnimator {
|
RotationAnimator {
|
||||||
id: connectionProccess
|
id: connectionProccess
|
||||||
|
|
||||||
target: border
|
target: border
|
||||||
running: false
|
running: ConnectionController.isConnectionInProgress
|
||||||
from: 0
|
from: 0
|
||||||
to: 360
|
to: 360
|
||||||
loops: Animation.Infinite
|
loops: Animation.Infinite
|
||||||
|
@ -67,63 +75,12 @@ Button {
|
||||||
}
|
}
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
connectionProccess.running ? ConnectionController.closeConnection() : ConnectionController.openConnection()
|
if (ConnectionController.isConnectionInProgress) {
|
||||||
}
|
ConnectionController.closeConnection()
|
||||||
|
} else if (ConnectionController.isConnected) {
|
||||||
Connections {
|
ConnectionController.closeConnection()
|
||||||
target: ConnectionController
|
} else {
|
||||||
function onConnectionStateChanged(state) {
|
ConnectionController.openConnection()
|
||||||
switch(state) {
|
|
||||||
case ConnectionState.Unknown: {
|
|
||||||
console.log("Unknown")
|
|
||||||
break
|
|
||||||
}
|
|
||||||
case ConnectionState.Disconnected: {
|
|
||||||
console.log("Disconnected")
|
|
||||||
connectionProccess.running = false
|
|
||||||
root.text = qsTr("Connect")
|
|
||||||
ConnectionController.isConnected = false
|
|
||||||
break
|
|
||||||
}
|
|
||||||
case ConnectionState.Preparing: {
|
|
||||||
console.log("Preparing")
|
|
||||||
connectionProccess.running = true
|
|
||||||
root.text = qsTr("Connection...")
|
|
||||||
break
|
|
||||||
}
|
|
||||||
case ConnectionState.Connecting: {
|
|
||||||
console.log("Connecting")
|
|
||||||
connectionProccess.running = true
|
|
||||||
root.text = qsTr("Connection...")
|
|
||||||
break
|
|
||||||
}
|
|
||||||
case ConnectionState.Connected: {
|
|
||||||
console.log("Connected")
|
|
||||||
connectionProccess.running = false
|
|
||||||
root.text = qsTr("Disconnect")
|
|
||||||
ConnectionController.isConnected = true
|
|
||||||
break
|
|
||||||
}
|
|
||||||
case ConnectionState.Disconnecting: {
|
|
||||||
console.log("Disconnecting")
|
|
||||||
connectionProccess.running = true
|
|
||||||
root.text = qsTr("Disconnection...")
|
|
||||||
break
|
|
||||||
}
|
|
||||||
case ConnectionState.Reconnecting: {
|
|
||||||
console.log("Reconnecting")
|
|
||||||
connectionProccess.running = true
|
|
||||||
root.text = qsTr("Reconnection...")
|
|
||||||
break
|
|
||||||
}
|
|
||||||
case ConnectionState.Error: {
|
|
||||||
console.log("Error")
|
|
||||||
connectionProccess.running = false
|
|
||||||
root.text = qsTr("Connect")
|
|
||||||
PageController.showErrorMessage(ConnectionController.getLastConnectionError())
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -141,6 +141,7 @@ DrawerType {
|
||||||
Layout.bottomMargin: 16
|
Layout.bottomMargin: 16
|
||||||
|
|
||||||
padding: 0
|
padding: 0
|
||||||
|
leftPadding: 0
|
||||||
height: 24
|
height: 24
|
||||||
|
|
||||||
color: "#D7D8DB"
|
color: "#D7D8DB"
|
||||||
|
|
|
@ -2,6 +2,8 @@ import QtQuick
|
||||||
import QtQuick.Controls
|
import QtQuick.Controls
|
||||||
import QtQuick.Layouts
|
import QtQuick.Layouts
|
||||||
|
|
||||||
|
import "TextTypes"
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
|
@ -34,15 +36,10 @@ Item {
|
||||||
anchors.fill: backgroud
|
anchors.fill: backgroud
|
||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
|
|
||||||
Text {
|
LabelTextType {
|
||||||
text: root.headerText
|
text: root.headerText
|
||||||
color: "#878b91"
|
color: "#878b91"
|
||||||
font.pixelSize: 13
|
|
||||||
font.weight: 400
|
|
||||||
font.family: "PT Root UI VF"
|
|
||||||
font.letterSpacing: 0.02
|
|
||||||
|
|
||||||
height: 16
|
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.rightMargin: 16
|
Layout.rightMargin: 16
|
||||||
Layout.leftMargin: 16
|
Layout.leftMargin: 16
|
||||||
|
|
12
client/ui/qml/Controls2/TextTypes/SmallTextType.qml
Normal file
12
client/ui/qml/Controls2/TextTypes/SmallTextType.qml
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
import QtQuick
|
||||||
|
|
||||||
|
Text {
|
||||||
|
height: 20
|
||||||
|
|
||||||
|
color: "#D7D8DB"
|
||||||
|
font.pixelSize: 14
|
||||||
|
font.weight: Font.Normal
|
||||||
|
font.family: "PT Root UI VF"
|
||||||
|
|
||||||
|
wrapMode: Text.WordWrap
|
||||||
|
}
|
|
@ -21,8 +21,8 @@ PageType {
|
||||||
|
|
||||||
property string borderColor: "#2C2D30"
|
property string borderColor: "#2C2D30"
|
||||||
|
|
||||||
property string currentServerName: serversMenuContent.currentItem.delegateData.name
|
property string currentServerName
|
||||||
property string currentServerHostName: serversMenuContent.currentItem.delegateData.hostName
|
property string currentServerHostName
|
||||||
property string currentContainerName
|
property string currentContainerName
|
||||||
|
|
||||||
ConnectButton {
|
ConnectButton {
|
||||||
|
@ -93,7 +93,15 @@ PageType {
|
||||||
Layout.bottomMargin: 44
|
Layout.bottomMargin: 44
|
||||||
Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
|
Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
|
||||||
|
|
||||||
text: root.currentContainerName + " | " + root.currentServerHostName
|
text: {
|
||||||
|
var string = ""
|
||||||
|
if (SettingsController.isAmneziaDnsEnabled()) {
|
||||||
|
string += "Amnezia DNS | "
|
||||||
|
}
|
||||||
|
|
||||||
|
string += root.currentContainerName + " | " + root.currentServerHostName
|
||||||
|
return string
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -153,6 +161,8 @@ PageType {
|
||||||
headerBackButtonImage: "qrc:/images/controls/arrow-left.svg"
|
headerBackButtonImage: "qrc:/images/controls/arrow-left.svg"
|
||||||
|
|
||||||
rootButtonClickedFunction: function() {
|
rootButtonClickedFunction: function() {
|
||||||
|
// todo check if server index changed before set Currently processed
|
||||||
|
// todo make signal slot for change server index in containersModel
|
||||||
ServersModel.setCurrentlyProcessedServerIndex(serversMenuContent.currentIndex)
|
ServersModel.setCurrentlyProcessedServerIndex(serversMenuContent.currentIndex)
|
||||||
ContainersModel.setCurrentlyProcessedServerIndex(serversMenuContent.currentIndex)
|
ContainersModel.setCurrentlyProcessedServerIndex(serversMenuContent.currentIndex)
|
||||||
containersDropDown.menuVisible = true
|
containersDropDown.menuVisible = true
|
||||||
|
@ -161,20 +171,45 @@ PageType {
|
||||||
listView: HomeContainersListView {
|
listView: HomeContainersListView {
|
||||||
rootWidth: root.width
|
rootWidth: root.width
|
||||||
|
|
||||||
|
Connections {
|
||||||
|
target: ServersModel
|
||||||
|
|
||||||
|
function onCurrentlyProcessedServerIndexChanged() {
|
||||||
|
updateContainersModelFilters()
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateContainersModelFilters() {
|
||||||
|
if (ServersModel.isCurrentlyProcessedServerHasWriteAccess()) {
|
||||||
|
proxyContainersModel.filters = [serviceTypeFilter, supportedFilter]
|
||||||
|
} else {
|
||||||
|
proxyContainersModel.filters = installedFilter
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ValueFilter {
|
||||||
|
id: serviceTypeFilter
|
||||||
|
roleName: "serviceType"
|
||||||
|
value: ProtocolEnum.Vpn
|
||||||
|
}
|
||||||
|
ValueFilter {
|
||||||
|
id: supportedFilter
|
||||||
|
roleName: "isSupported"
|
||||||
|
value: true
|
||||||
|
}
|
||||||
|
ValueFilter {
|
||||||
|
id: installedFilter
|
||||||
|
roleName: "isInstalled"
|
||||||
|
value: true
|
||||||
|
}
|
||||||
|
|
||||||
model: SortFilterProxyModel {
|
model: SortFilterProxyModel {
|
||||||
id: proxyContainersModel
|
id: proxyContainersModel
|
||||||
sourceModel: ContainersModel
|
sourceModel: ContainersModel
|
||||||
filters: [
|
|
||||||
ValueFilter {
|
Component.onCompleted: updateContainersModelFilters()
|
||||||
roleName: "serviceType"
|
|
||||||
value: ProtocolEnum.Vpn
|
|
||||||
},
|
|
||||||
ValueFilter {
|
|
||||||
roleName: "isSupported"
|
|
||||||
value: true
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
currentIndex: ContainersModel.getDefaultContainer()
|
currentIndex: ContainersModel.getDefaultContainer()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -272,6 +307,9 @@ PageType {
|
||||||
|
|
||||||
isDefault = true
|
isDefault = true
|
||||||
ContainersModel.setCurrentlyProcessedServerIndex(index)
|
ContainersModel.setCurrentlyProcessedServerIndex(index)
|
||||||
|
|
||||||
|
root.currentServerName = name
|
||||||
|
root.currentServerHostName = hostName
|
||||||
}
|
}
|
||||||
|
|
||||||
MouseArea {
|
MouseArea {
|
||||||
|
@ -302,6 +340,13 @@ PageType {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Component.onCompleted: {
|
||||||
|
if (serversMenuContent.currentIndex === index) {
|
||||||
|
root.currentServerName = name
|
||||||
|
root.currentServerHostName = hostName
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,21 @@ import "../Components"
|
||||||
PageType {
|
PageType {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
|
Connections {
|
||||||
|
target: InstallController
|
||||||
|
|
||||||
|
function onScanServerFinished(isInstalledContainerFound) {
|
||||||
|
var message = ""
|
||||||
|
if (isInstalledContainerFound) {
|
||||||
|
message = qsTr("All installed containers have been added to the application")
|
||||||
|
} else {
|
||||||
|
message = qsTr("Не найдено установленных контейнеров")
|
||||||
|
}
|
||||||
|
|
||||||
|
PageController.showErrorMessage(message)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
FlickableType {
|
FlickableType {
|
||||||
id: fl
|
id: fl
|
||||||
anchors.top: parent.top
|
anchors.top: parent.top
|
||||||
|
@ -30,8 +45,8 @@ PageType {
|
||||||
LabelWithButtonType {
|
LabelWithButtonType {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
|
|
||||||
text: "Clear Amnezia cache"
|
text: qsTr("Clear Amnezia cache")
|
||||||
descriptionText: "May be needed when changing other settings"
|
descriptionText: qsTr("May be needed when changing other settings")
|
||||||
|
|
||||||
clickedFunction: function() {
|
clickedFunction: function() {
|
||||||
questionDrawer.headerText = qsTr("Clear cached profiles?")
|
questionDrawer.headerText = qsTr("Clear cached profiles?")
|
||||||
|
@ -52,6 +67,19 @@ PageType {
|
||||||
|
|
||||||
DividerType {}
|
DividerType {}
|
||||||
|
|
||||||
|
LabelWithButtonType {
|
||||||
|
Layout.fillWidth: true
|
||||||
|
|
||||||
|
text: qsTr("Проверить сервер на наличие ранее установленных сервисов Amnezia")
|
||||||
|
descriptionText: qsTr("Добавим их в приложение, если они не отображались")
|
||||||
|
|
||||||
|
clickedFunction: function() {
|
||||||
|
InstallController.scanServerForInstalledContainers()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
DividerType {}
|
||||||
|
|
||||||
LabelWithButtonType {
|
LabelWithButtonType {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ import PageEnum 1.0
|
||||||
import "./"
|
import "./"
|
||||||
import "../Controls2"
|
import "../Controls2"
|
||||||
import "../Config"
|
import "../Config"
|
||||||
|
import "../Controls2/TextTypes"
|
||||||
|
|
||||||
PageType {
|
PageType {
|
||||||
id: root
|
id: root
|
||||||
|
@ -42,28 +43,32 @@ PageType {
|
||||||
HeaderType {
|
HeaderType {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
|
|
||||||
headerText: "Подключение к серверу"
|
headerText: qsTr("Server connection")
|
||||||
}
|
}
|
||||||
|
|
||||||
TextFieldWithHeaderType {
|
TextFieldWithHeaderType {
|
||||||
id: hostname
|
id: hostname
|
||||||
|
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
headerText: "Server IP address [:port]"
|
headerText: qsTr("Server IP address [:port]")
|
||||||
|
textFieldPlaceholderText: qsTr("Enter the address in the format 255.255.255.255:88")
|
||||||
|
textField.validator: RegularExpressionValidator {
|
||||||
|
regularExpression: InstallController.ipAddressPortRegExp()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TextFieldWithHeaderType {
|
TextFieldWithHeaderType {
|
||||||
id: username
|
id: username
|
||||||
|
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
headerText: "Login to connect via SSH"
|
headerText: qsTr("Login to connect via SSH")
|
||||||
}
|
}
|
||||||
|
|
||||||
TextFieldWithHeaderType {
|
TextFieldWithHeaderType {
|
||||||
id: secretData
|
id: secretData
|
||||||
|
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
headerText: "Password / Private key"
|
headerText: qsTr("Password / Private key")
|
||||||
textField.echoMode: TextInput.Password
|
textField.echoMode: TextInput.Password
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,7 +76,7 @@ PageType {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.topMargin: 24
|
Layout.topMargin: 24
|
||||||
|
|
||||||
text: qsTr("Настроить сервер простым образом")
|
text: qsTr("Set up a server the easy way")
|
||||||
|
|
||||||
onClicked: function() {
|
onClicked: function() {
|
||||||
InstallController.setShouldCreateServer(true)
|
InstallController.setShouldCreateServer(true)
|
||||||
|
@ -92,7 +97,7 @@ PageType {
|
||||||
textColor: "#D7D8DB"
|
textColor: "#D7D8DB"
|
||||||
borderWidth: 1
|
borderWidth: 1
|
||||||
|
|
||||||
text: qsTr("Выбрать протокол для установки")
|
text: qsTr("Select protocol to install")
|
||||||
|
|
||||||
onClicked: function() {
|
onClicked: function() {
|
||||||
InstallController.setShouldCreateServer(true)
|
InstallController.setShouldCreateServer(true)
|
||||||
|
|
|
@ -24,7 +24,7 @@ PageType {
|
||||||
PageController.showErrorMessage(errorMessage)
|
PageController.showErrorMessage(errorMessage)
|
||||||
}
|
}
|
||||||
|
|
||||||
function onInstallContainerFinished() {
|
function onInstallContainerFinished(isInstalledContainerFound) {
|
||||||
goToStartPage()
|
goToStartPage()
|
||||||
if (stackView.currentItem.objectName === PageController.getPagePath(PageEnum.PageHome)) {
|
if (stackView.currentItem.objectName === PageController.getPagePath(PageEnum.PageHome)) {
|
||||||
PageController.restorePageHomeState(true)
|
PageController.restorePageHomeState(true)
|
||||||
|
@ -34,9 +34,15 @@ PageType {
|
||||||
} else {
|
} else {
|
||||||
goToPage(PageEnum.PageHome)
|
goToPage(PageEnum.PageHome)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isInstalledContainerFound) {
|
||||||
|
//todo change to info message
|
||||||
|
PageController.showErrorMessage(qsTr("The container you are trying to install is already installed on the server. " +
|
||||||
|
"All installed containers have been added to the application"))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function onInstallServerFinished() {
|
function onInstallServerFinished(isInstalledContainerFound) {
|
||||||
goToStartPage()
|
goToStartPage()
|
||||||
if (stackView.currentItem.objectName === PageController.getPagePath(PageEnum.PageHome)) {
|
if (stackView.currentItem.objectName === PageController.getPagePath(PageEnum.PageHome)) {
|
||||||
PageController.restorePageHomeState()
|
PageController.restorePageHomeState()
|
||||||
|
@ -46,6 +52,19 @@ PageType {
|
||||||
var pagePath = PageController.getPagePath(PageEnum.PageStart)
|
var pagePath = PageController.getPagePath(PageEnum.PageStart)
|
||||||
stackView.replace(pagePath, { "objectName" : pagePath })
|
stackView.replace(pagePath, { "objectName" : pagePath })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isInstalledContainerFound) {
|
||||||
|
PageController.showErrorMessage(qsTr("The container you are trying to install is already installed on the server. " +
|
||||||
|
"All installed containers have been added to the application"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function onServerAlreadyExists(serverIndex) {
|
||||||
|
goToStartPage()
|
||||||
|
ServersModel.setCurrentlyProcessedServerIndex(serverIndex)
|
||||||
|
goToPage(PageEnum.PageSettingsServerInfo, false)
|
||||||
|
|
||||||
|
PageController.showErrorMessage(qsTr("The server has already been added to the application"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,11 @@ PageType {
|
||||||
tabBarStackView.goToTabBarPage(PageController.getPagePath(PageEnum.PageHome))
|
tabBarStackView.goToTabBarPage(PageController.getPagePath(PageEnum.PageHome))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function onGoToPageSettings() {
|
||||||
|
tabBar.currentIndex = 2
|
||||||
|
tabBarStackView.goToTabBarPage(PageController.getPagePath(PageEnum.PageSettings))
|
||||||
|
}
|
||||||
|
|
||||||
function onShowErrorMessage(errorMessage) {
|
function onShowErrorMessage(errorMessage) {
|
||||||
popupErrorMessage.popupErrorMessageText = errorMessage
|
popupErrorMessage.popupErrorMessageText = errorMessage
|
||||||
popupErrorMessage.open()
|
popupErrorMessage.open()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue