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/mail.svg</file>
|
||||
<file>images/controls/telegram.svg</file>
|
||||
<file>ui/qml/Controls2/TextTypes/SmallTextType.qml</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
|
|
@ -6,39 +6,27 @@
|
|||
|
||||
ConnectionController::ConnectionController(const QSharedPointer<ServersModel> &serversModel,
|
||||
const QSharedPointer<ContainersModel> &containersModel,
|
||||
const QSharedPointer<VpnConnection> &vpnConnection,
|
||||
QObject *parent)
|
||||
: QObject(parent)
|
||||
, m_serversModel(serversModel)
|
||||
, m_containersModel(containersModel)
|
||||
, m_vpnConnection(vpnConnection)
|
||||
const QSharedPointer<VpnConnection> &vpnConnection, QObject *parent)
|
||||
: QObject(parent), m_serversModel(serversModel), m_containersModel(containersModel), m_vpnConnection(vpnConnection)
|
||||
{
|
||||
connect(m_vpnConnection.get(),
|
||||
&VpnConnection::connectionStateChanged,
|
||||
this,
|
||||
&ConnectionController::connectionStateChanged);
|
||||
connect(this,
|
||||
&ConnectionController::connectToVpn,
|
||||
m_vpnConnection.get(),
|
||||
&VpnConnection::connectToVpn,
|
||||
connect(m_vpnConnection.get(), &VpnConnection::connectionStateChanged, this,
|
||||
&ConnectionController::onConnectionStateChanged);
|
||||
connect(this, &ConnectionController::connectToVpn, m_vpnConnection.get(), &VpnConnection::connectToVpn,
|
||||
Qt::QueuedConnection);
|
||||
connect(this,
|
||||
&ConnectionController::disconnectFromVpn,
|
||||
m_vpnConnection.get(),
|
||||
&VpnConnection::disconnectFromVpn,
|
||||
connect(this, &ConnectionController::disconnectFromVpn, m_vpnConnection.get(), &VpnConnection::disconnectFromVpn,
|
||||
Qt::QueuedConnection);
|
||||
}
|
||||
|
||||
void ConnectionController::openConnection()
|
||||
{
|
||||
int serverIndex = m_serversModel->getDefaultServerIndex();
|
||||
ServerCredentials credentials = qvariant_cast<ServerCredentials>(
|
||||
m_serversModel->data(serverIndex, ServersModel::ServersModelRoles::CredentialsRole));
|
||||
ServerCredentials credentials =
|
||||
qvariant_cast<ServerCredentials>(m_serversModel->data(serverIndex, ServersModel::Roles::CredentialsRole));
|
||||
|
||||
DockerContainer container = m_containersModel->getDefaultContainer();
|
||||
QModelIndex containerModelIndex = m_containersModel->index(container);
|
||||
const QJsonObject &containerConfig = qvariant_cast<QJsonObject>(m_containersModel->data(containerModelIndex,
|
||||
ContainersModel::Roles::ConfigRole));
|
||||
const QJsonObject &containerConfig =
|
||||
qvariant_cast<QJsonObject>(m_containersModel->data(containerModelIndex, ContainersModel::Roles::ConfigRole));
|
||||
|
||||
if (container == DockerContainer::None) {
|
||||
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());
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
void ConnectionController::setIsConnected(bool isConnected)
|
||||
{
|
||||
m_isConnected = isConnected;
|
||||
emit isConnectedChanged();
|
||||
}
|
||||
|
|
|
@ -11,28 +11,30 @@ class ConnectionController : public QObject
|
|||
Q_OBJECT
|
||||
|
||||
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,
|
||||
const QSharedPointer<ContainersModel> &containersModel,
|
||||
const QSharedPointer<VpnConnection> &vpnConnection,
|
||||
QObject *parent = nullptr);
|
||||
|
||||
bool isConnected();
|
||||
void setIsConnected(bool isConnected); //todo take state from vpnconnection?
|
||||
bool isConnected() const;
|
||||
bool isConnectionInProgress() const;
|
||||
QString connectionStateText() const;
|
||||
|
||||
public slots:
|
||||
void openConnection();
|
||||
void closeConnection();
|
||||
|
||||
QString getLastConnectionError();
|
||||
Vpn::ConnectionState connectionState(){return {};}; //todo update ConnectButton text on page change
|
||||
void onConnectionStateChanged(Vpn::ConnectionState state);
|
||||
|
||||
signals:
|
||||
void connectToVpn(int serverIndex, const ServerCredentials &credentials, DockerContainer container, const QJsonObject &containerConfig);
|
||||
void disconnectFromVpn();
|
||||
void connectionStateChanged(Vpn::ConnectionState state);
|
||||
void isConnectedChanged();
|
||||
void connectionStateChanged();
|
||||
|
||||
void connectionErrorOccurred(QString errorMessage);
|
||||
|
||||
|
@ -43,6 +45,8 @@ private:
|
|||
QSharedPointer<VpnConnection> m_vpnConnection;
|
||||
|
||||
bool m_isConnected = false;
|
||||
bool m_isConnectionInProgress = false;
|
||||
QString m_connectionStateText = tr("Connect");
|
||||
};
|
||||
|
||||
#endif // CONNECTIONCONTROLLER_H
|
||||
|
|
|
@ -44,7 +44,7 @@ void ExportController::generateConnectionConfig()
|
|||
{
|
||||
int serverIndex = m_serversModel->getCurrentlyProcessedServerIndex();
|
||||
ServerCredentials credentials = qvariant_cast<ServerCredentials>(
|
||||
m_serversModel->data(serverIndex, ServersModel::ServersModelRoles::CredentialsRole));
|
||||
m_serversModel->data(serverIndex, ServersModel::Roles::CredentialsRole));
|
||||
|
||||
DockerContainer container = static_cast<DockerContainer>(
|
||||
m_containersModel->getCurrentlyProcessedContainerIndex());
|
||||
|
|
|
@ -89,7 +89,7 @@ void ImportController::importConfig()
|
|||
|
||||
if (!m_config.value(config_key::containers).toArray().isEmpty()) {
|
||||
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();
|
||||
|
|
|
@ -2,29 +2,31 @@
|
|||
|
||||
#include <QJsonObject>
|
||||
|
||||
#include "core/servercontroller.h"
|
||||
#include "core/errorstrings.h"
|
||||
#include "core/servercontroller.h"
|
||||
#include "utilities.h"
|
||||
|
||||
InstallController::InstallController(const QSharedPointer<ServersModel> &serversModel,
|
||||
const QSharedPointer<ContainersModel> &containersModel,
|
||||
const std::shared_ptr<Settings> &settings,
|
||||
QObject *parent) : QObject(parent), m_serversModel(serversModel), m_containersModel(containersModel), m_settings(settings)
|
||||
{}
|
||||
const std::shared_ptr<Settings> &settings, QObject *parent)
|
||||
: QObject(parent), m_serversModel(serversModel), m_containersModel(containersModel), m_settings(settings)
|
||||
{
|
||||
}
|
||||
|
||||
void InstallController::install(DockerContainer container, int port, TransportProto transportProto)
|
||||
{
|
||||
Proto mainProto = ContainerProps::defaultProtocol(container);
|
||||
|
||||
QJsonObject containerConfig {
|
||||
{ config_key::port, QString::number(port) },
|
||||
{ config_key::transport_proto, ProtocolProps::transportProtoToString(transportProto, mainProto) }
|
||||
};
|
||||
QJsonObject config {
|
||||
{ config_key::container, ContainerProps::containerToString(container) },
|
||||
{ ProtocolProps::protoToString(mainProto), containerConfig }
|
||||
};
|
||||
QJsonObject containerConfig { { config_key::port, QString::number(port) },
|
||||
{ config_key::transport_proto,
|
||||
ProtocolProps::transportProtoToString(transportProto, mainProto) } };
|
||||
QJsonObject config { { config_key::container, ContainerProps::containerToString(container) },
|
||||
{ ProtocolProps::protoToString(mainProto), containerConfig } };
|
||||
|
||||
if (m_shouldCreateServer) {
|
||||
if (isServerAlreadyExists()) {
|
||||
return;
|
||||
}
|
||||
installServer(container, config);
|
||||
} else {
|
||||
installContainer(container, config);
|
||||
|
@ -33,9 +35,21 @@ void InstallController::install(DockerContainer container, int port, TransportPr
|
|||
|
||||
void InstallController::installServer(DockerContainer container, QJsonObject &config)
|
||||
{
|
||||
//todo check if container already installed
|
||||
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) {
|
||||
QJsonObject server;
|
||||
server.insert(config_key::hostName, m_currentlyInstalledServerCredentials.hostName);
|
||||
|
@ -44,14 +58,19 @@ void InstallController::installServer(DockerContainer container, QJsonObject& co
|
|||
server.insert(config_key::port, m_currentlyInstalledServerCredentials.port);
|
||||
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));
|
||||
|
||||
m_serversModel->addServer(server);
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -60,27 +79,102 @@ void InstallController::installServer(DockerContainer container, QJsonObject& co
|
|||
|
||||
void InstallController::installContainer(DockerContainer container, QJsonObject &config)
|
||||
{
|
||||
//todo check if container already installed
|
||||
int serverIndex = m_serversModel->getCurrentlyProcessedServerIndex();
|
||||
ServerCredentials serverCredentials = qvariant_cast<ServerCredentials>(
|
||||
m_serversModel->data(serverIndex, ServersModel::ServersModelRoles::CredentialsRole));
|
||||
ServerCredentials serverCredentials =
|
||||
qvariant_cast<ServerCredentials>(m_serversModel->data(serverIndex, ServersModel::Roles::CredentialsRole));
|
||||
|
||||
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) {
|
||||
m_containersModel->setData(m_containersModel->index(container), config, ContainersModel::Roles::ConfigRole);
|
||||
emit installContainerFinished();
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
emit installContainerFinished(isInstalledContainerFound);
|
||||
return;
|
||||
}
|
||||
|
||||
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;
|
||||
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.userName = userName;
|
||||
|
|
|
@ -3,10 +3,10 @@
|
|||
|
||||
#include <QObject>
|
||||
|
||||
#include "core/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/servers_model.h"
|
||||
|
||||
class InstallController : public QObject
|
||||
{
|
||||
|
@ -14,22 +14,32 @@ class InstallController : public QObject
|
|||
public:
|
||||
explicit InstallController(const QSharedPointer<ServersModel> &serversModel,
|
||||
const QSharedPointer<ContainersModel> &containersModel,
|
||||
const std::shared_ptr<Settings> &settings,
|
||||
QObject *parent = nullptr);
|
||||
const std::shared_ptr<Settings> &settings, QObject *parent = nullptr);
|
||||
|
||||
public slots:
|
||||
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 scanServerForInstalledContainers();
|
||||
|
||||
QRegularExpression ipAddressPortRegExp();
|
||||
|
||||
signals:
|
||||
void installContainerFinished();
|
||||
void installServerFinished();
|
||||
void installContainerFinished(bool isInstalledContainerFound);
|
||||
void installServerFinished(bool isInstalledContainerFound);
|
||||
|
||||
void scanServerFinished(bool isInstalledContainerFound);
|
||||
|
||||
void installationErrorOccurred(QString errorMessage);
|
||||
|
||||
void serverAlreadyExists(int serverIndex);
|
||||
|
||||
private:
|
||||
void installServer(DockerContainer container, QJsonObject &config);
|
||||
void installContainer(DockerContainer container, QJsonObject &config);
|
||||
bool isServerAlreadyExists();
|
||||
|
||||
QSharedPointer<ServersModel> m_serversModel;
|
||||
QSharedPointer<ContainersModel> m_containersModel;
|
||||
|
|
|
@ -10,7 +10,7 @@ QString PageController::getInitialPage()
|
|||
if (m_serversModel->getServersCount()) {
|
||||
if (m_serversModel->getDefaultServerIndex() < 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);
|
||||
} else {
|
||||
|
|
|
@ -40,14 +40,9 @@ namespace PageLoader
|
|||
};
|
||||
Q_ENUM_NS(PageEnum)
|
||||
|
||||
static void declareQmlPageEnum() {
|
||||
qmlRegisterUncreatableMetaObject(
|
||||
PageLoader::staticMetaObject,
|
||||
"PageEnum",
|
||||
1, 0,
|
||||
"PageEnum",
|
||||
"Error: only enums"
|
||||
);
|
||||
static void declareQmlPageEnum()
|
||||
{
|
||||
qmlRegisterUncreatableMetaObject(PageLoader::staticMetaObject, "PageEnum", 1, 0, "PageEnum", "Error: only enums");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -55,8 +50,7 @@ class PageController : public QObject
|
|||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit PageController(const QSharedPointer<ServersModel> &serversModel,
|
||||
QObject *parent = nullptr);
|
||||
explicit PageController(const QSharedPointer<ServersModel> &serversModel, QObject *parent = nullptr);
|
||||
|
||||
public slots:
|
||||
QString getInitialPage();
|
||||
|
@ -64,9 +58,11 @@ public slots:
|
|||
|
||||
signals:
|
||||
void goToPageHome();
|
||||
void goToPageSettings();
|
||||
void restorePageHomeState(bool isContainerInstalled = false);
|
||||
void replaceStartPage();
|
||||
void showErrorMessage(QString errorMessage);
|
||||
void showInfoMessage(QString message);
|
||||
|
||||
private:
|
||||
QSharedPointer<ServersModel> m_serversModel;
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
|
||||
#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)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -25,10 +26,10 @@ bool ContainersModel::setData(const QModelIndex &index, const QVariant &value, i
|
|||
// return ContainerProps::containerHumanNames().value(container);
|
||||
case DescRole:
|
||||
// return ContainerProps::containerDescriptions().value(container);
|
||||
case ConfigRole: //todo save to model also
|
||||
m_settings->setContainerConfig(m_currentlyProcessedServerIndex,
|
||||
container,
|
||||
value.toJsonObject());
|
||||
case ConfigRole: {
|
||||
m_settings->setContainerConfig(m_currentlyProcessedServerIndex, container, value.toJsonObject());
|
||||
m_containers = m_settings->containers(m_currentlyProcessedServerIndex);
|
||||
}
|
||||
case ServiceTypeRole:
|
||||
// return ContainerProps::containerService(container);
|
||||
case DockerContainerRole:
|
||||
|
@ -48,40 +49,30 @@ bool ContainersModel::setData(const QModelIndex &index, const QVariant &value, i
|
|||
|
||||
QVariant ContainersModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if (!index.isValid() || index.row() < 0
|
||||
|| index.row() >= ContainerProps::allContainers().size()) {
|
||||
if (!index.isValid() || index.row() < 0 || index.row() >= ContainerProps::allContainers().size()) {
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
DockerContainer container = ContainerProps::allContainers().at(index.row());
|
||||
|
||||
switch (role) {
|
||||
case NameRole:
|
||||
return ContainerProps::containerHumanNames().value(container);
|
||||
case DescRole:
|
||||
return ContainerProps::containerDescriptions().value(container);
|
||||
case NameRole: return ContainerProps::containerHumanNames().value(container);
|
||||
case DescRole: return ContainerProps::containerDescriptions().value(container);
|
||||
case ConfigRole: {
|
||||
if (container == DockerContainer::None) return QJsonObject();
|
||||
if (container == DockerContainer::None) {
|
||||
return QJsonObject();
|
||||
}
|
||||
return m_containers.value(container);
|
||||
}
|
||||
case ServiceTypeRole:
|
||||
return ContainerProps::containerService(container);
|
||||
case DockerContainerRole:
|
||||
return container;
|
||||
case IsEasySetupContainerRole:
|
||||
return ContainerProps::isEasySetupContainer(container);
|
||||
case EasySetupHeaderRole:
|
||||
return ContainerProps::easySetupHeader(container);
|
||||
case EasySetupDescriptionRole:
|
||||
return ContainerProps::easySetupDescription(container);
|
||||
case IsInstalledRole:
|
||||
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);
|
||||
case ServiceTypeRole: return ContainerProps::containerService(container);
|
||||
case DockerContainerRole: return container;
|
||||
case IsEasySetupContainerRole: return ContainerProps::isEasySetupContainer(container);
|
||||
case EasySetupHeaderRole: return ContainerProps::easySetupHeader(container);
|
||||
case EasySetupDescriptionRole: return ContainerProps::easySetupDescription(container);
|
||||
case IsInstalledRole: 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();
|
||||
|
@ -141,7 +132,8 @@ void ContainersModel::clearCachedProfiles()
|
|||
}
|
||||
}
|
||||
|
||||
QHash<int, QByteArray> ContainersModel::roleNames() const {
|
||||
QHash<int, QByteArray> ContainersModel::roleNames() const
|
||||
{
|
||||
QHash<int, QByteArray> roles;
|
||||
roles[NameRole] = "name";
|
||||
roles[DescRole] = "description";
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#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_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)
|
||||
{
|
||||
if (!index.isValid() || index.row() < 0
|
||||
|| index.row() >= static_cast<int>(m_servers.size())) {
|
||||
if (!index.isValid() || index.row() < 0 || index.row() >= static_cast<int>(m_servers.size())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -29,8 +29,7 @@ bool ServersModel::setData(const QModelIndex &index, const QVariant &value, int
|
|||
break;
|
||||
}
|
||||
case IsDefaultRole: {
|
||||
m_settings->setDefaultServer(index.row());
|
||||
m_defaultServerIndex = m_settings->defaultServerIndex();
|
||||
setDefaultServerIndex(index.row());
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
|
@ -58,16 +57,11 @@ QVariant ServersModel::data(const QModelIndex &index, int role) const
|
|||
}
|
||||
return description;
|
||||
}
|
||||
case HostNameRole:
|
||||
return server.value(config_key::hostName).toString();
|
||||
case CredentialsRole:
|
||||
return QVariant::fromValue(m_settings->serverCredentials(index.row()));
|
||||
case CredentialsLoginRole:
|
||||
return m_settings->serverCredentials(index.row()).userName;
|
||||
case IsDefaultRole:
|
||||
return index.row() == m_defaultServerIndex;
|
||||
case IsCurrentlyProcessedRole:
|
||||
return index.row() == m_currenlyProcessedServerIndex;
|
||||
case HostNameRole: return server.value(config_key::hostName).toString();
|
||||
case CredentialsRole: return QVariant::fromValue(m_settings->serverCredentials(index.row()));
|
||||
case CredentialsLoginRole: return m_settings->serverCredentials(index.row()).userName;
|
||||
case IsDefaultRole: return index.row() == m_defaultServerIndex;
|
||||
case IsCurrentlyProcessedRole: return index.row() == m_currenlyProcessedServerIndex;
|
||||
}
|
||||
|
||||
return QVariant();
|
||||
|
@ -92,6 +86,7 @@ const int ServersModel::getServersCount()
|
|||
void ServersModel::setCurrentlyProcessedServerIndex(int index)
|
||||
{
|
||||
m_currenlyProcessedServerIndex = index;
|
||||
emit currentlyProcessedServerIndexChanged();
|
||||
}
|
||||
|
||||
int ServersModel::getCurrentlyProcessedServerIndex()
|
||||
|
@ -104,6 +99,12 @@ bool ServersModel::isDefaultServerCurrentlyProcessed()
|
|||
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)
|
||||
{
|
||||
beginResetModel();
|
||||
|
@ -119,18 +120,19 @@ void ServersModel::removeServer()
|
|||
m_servers = m_settings->serversArray();
|
||||
|
||||
if (m_settings->defaultServerIndex() == m_currenlyProcessedServerIndex) {
|
||||
m_settings->setDefaultServer(0);
|
||||
setDefaultServerIndex(0);
|
||||
} else if (m_settings->defaultServerIndex() > m_currenlyProcessedServerIndex) {
|
||||
m_settings->setDefaultServer(m_settings->defaultServerIndex() - 1);
|
||||
setDefaultServerIndex(m_settings->defaultServerIndex() - 1);
|
||||
}
|
||||
|
||||
if (m_settings->serversCount() == 0) {
|
||||
m_settings->setDefaultServer(-1);
|
||||
setDefaultServerIndex(-1);
|
||||
}
|
||||
endResetModel();
|
||||
}
|
||||
|
||||
QHash<int, QByteArray> ServersModel::roleNames() const {
|
||||
QHash<int, QByteArray> ServersModel::roleNames() const
|
||||
{
|
||||
QHash<int, QByteArray> roles;
|
||||
roles[NameRole] = "name";
|
||||
roles[HostNameRole] = "hostName";
|
||||
|
@ -140,3 +142,9 @@ QHash<int, QByteArray> ServersModel::roleNames() const {
|
|||
roles[IsCurrentlyProcessedRole] = "isCurrentlyProcessed";
|
||||
return roles;
|
||||
}
|
||||
|
||||
void ServersModel::setDefaultServerIndex(const int index)
|
||||
{
|
||||
m_settings->setDefaultServer(index);
|
||||
m_defaultServerIndex = m_settings->defaultServerIndex();
|
||||
}
|
||||
|
|
|
@ -5,7 +5,8 @@
|
|||
|
||||
#include "settings.h"
|
||||
|
||||
struct ServerModelContent {
|
||||
struct ServerModelContent
|
||||
{
|
||||
QString desc;
|
||||
QString address;
|
||||
bool isDefault;
|
||||
|
@ -15,7 +16,7 @@ class ServersModel : public QAbstractListModel
|
|||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum ServersModelRoles {
|
||||
enum Roles {
|
||||
NameRole = Qt::UserRole + 1,
|
||||
HostNameRole,
|
||||
CredentialsRole,
|
||||
|
@ -35,6 +36,7 @@ public:
|
|||
public slots:
|
||||
const int getDefaultServerIndex();
|
||||
bool isDefaultServerCurrentlyProcessed();
|
||||
bool isCurrentlyProcessedServerHasWriteAccess();
|
||||
|
||||
const int getServersCount();
|
||||
|
||||
|
@ -47,7 +49,12 @@ public slots:
|
|||
protected:
|
||||
QHash<int, QByteArray> roleNames() const override;
|
||||
|
||||
signals:
|
||||
void currentlyProcessedServerIndexChanged();
|
||||
|
||||
private:
|
||||
void setDefaultServerIndex(const int index);
|
||||
|
||||
QJsonArray m_servers;
|
||||
|
||||
std::shared_ptr<Settings> m_settings;
|
||||
|
|
|
@ -15,7 +15,7 @@ Button {
|
|||
}
|
||||
}
|
||||
|
||||
text: qsTr("Connect")
|
||||
text: ConnectionController.connectionStateText
|
||||
|
||||
background: Item {
|
||||
clip: true
|
||||
|
@ -26,13 +26,21 @@ Button {
|
|||
Image {
|
||||
id: border
|
||||
|
||||
source: connectionProccess.running ? "/images/connectionProgress.svg" :
|
||||
ConnectionController.isConnected ? "/images/connectionOff.svg" : "/images/connectionOn.svg"
|
||||
source: {
|
||||
if (ConnectionController.isConnectionInProgress) {
|
||||
return "/images/connectionProgress.svg"
|
||||
} else if (ConnectionController.isConnected) {
|
||||
return "/images/connectionOff.svg"
|
||||
} else {
|
||||
return "/images/connectionOn.svg"
|
||||
}
|
||||
}
|
||||
|
||||
RotationAnimator {
|
||||
id: connectionProccess
|
||||
|
||||
target: border
|
||||
running: false
|
||||
running: ConnectionController.isConnectionInProgress
|
||||
from: 0
|
||||
to: 360
|
||||
loops: Animation.Infinite
|
||||
|
@ -67,63 +75,12 @@ Button {
|
|||
}
|
||||
|
||||
onClicked: {
|
||||
connectionProccess.running ? ConnectionController.closeConnection() : ConnectionController.openConnection()
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: ConnectionController
|
||||
function onConnectionStateChanged(state) {
|
||||
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
|
||||
}
|
||||
}
|
||||
if (ConnectionController.isConnectionInProgress) {
|
||||
ConnectionController.closeConnection()
|
||||
} else if (ConnectionController.isConnected) {
|
||||
ConnectionController.closeConnection()
|
||||
} else {
|
||||
ConnectionController.openConnection()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -141,6 +141,7 @@ DrawerType {
|
|||
Layout.bottomMargin: 16
|
||||
|
||||
padding: 0
|
||||
leftPadding: 0
|
||||
height: 24
|
||||
|
||||
color: "#D7D8DB"
|
||||
|
|
|
@ -2,6 +2,8 @@ import QtQuick
|
|||
import QtQuick.Controls
|
||||
import QtQuick.Layouts
|
||||
|
||||
import "TextTypes"
|
||||
|
||||
Item {
|
||||
id: root
|
||||
|
||||
|
@ -34,15 +36,10 @@ Item {
|
|||
anchors.fill: backgroud
|
||||
ColumnLayout {
|
||||
|
||||
Text {
|
||||
LabelTextType {
|
||||
text: root.headerText
|
||||
color: "#878b91"
|
||||
font.pixelSize: 13
|
||||
font.weight: 400
|
||||
font.family: "PT Root UI VF"
|
||||
font.letterSpacing: 0.02
|
||||
|
||||
height: 16
|
||||
Layout.fillWidth: true
|
||||
Layout.rightMargin: 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 currentServerName: serversMenuContent.currentItem.delegateData.name
|
||||
property string currentServerHostName: serversMenuContent.currentItem.delegateData.hostName
|
||||
property string currentServerName
|
||||
property string currentServerHostName
|
||||
property string currentContainerName
|
||||
|
||||
ConnectButton {
|
||||
|
@ -93,7 +93,15 @@ PageType {
|
|||
Layout.bottomMargin: 44
|
||||
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"
|
||||
|
||||
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)
|
||||
ContainersModel.setCurrentlyProcessedServerIndex(serversMenuContent.currentIndex)
|
||||
containersDropDown.menuVisible = true
|
||||
|
@ -161,20 +171,45 @@ PageType {
|
|||
listView: HomeContainersListView {
|
||||
rootWidth: root.width
|
||||
|
||||
model: SortFilterProxyModel {
|
||||
id: proxyContainersModel
|
||||
sourceModel: ContainersModel
|
||||
filters: [
|
||||
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 {
|
||||
id: proxyContainersModel
|
||||
sourceModel: ContainersModel
|
||||
|
||||
Component.onCompleted: updateContainersModelFilters()
|
||||
}
|
||||
|
||||
currentIndex: ContainersModel.getDefaultContainer()
|
||||
}
|
||||
}
|
||||
|
@ -272,6 +307,9 @@ PageType {
|
|||
|
||||
isDefault = true
|
||||
ContainersModel.setCurrentlyProcessedServerIndex(index)
|
||||
|
||||
root.currentServerName = name
|
||||
root.currentServerHostName = hostName
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
|
@ -302,6 +340,13 @@ PageType {
|
|||
Layout.fillWidth: true
|
||||
}
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
if (serversMenuContent.currentIndex === index) {
|
||||
root.currentServerName = name
|
||||
root.currentServerHostName = hostName
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,6 +14,21 @@ import "../Components"
|
|||
PageType {
|
||||
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 {
|
||||
id: fl
|
||||
anchors.top: parent.top
|
||||
|
@ -30,8 +45,8 @@ PageType {
|
|||
LabelWithButtonType {
|
||||
Layout.fillWidth: true
|
||||
|
||||
text: "Clear Amnezia cache"
|
||||
descriptionText: "May be needed when changing other settings"
|
||||
text: qsTr("Clear Amnezia cache")
|
||||
descriptionText: qsTr("May be needed when changing other settings")
|
||||
|
||||
clickedFunction: function() {
|
||||
questionDrawer.headerText = qsTr("Clear cached profiles?")
|
||||
|
@ -52,6 +67,19 @@ PageType {
|
|||
|
||||
DividerType {}
|
||||
|
||||
LabelWithButtonType {
|
||||
Layout.fillWidth: true
|
||||
|
||||
text: qsTr("Проверить сервер на наличие ранее установленных сервисов Amnezia")
|
||||
descriptionText: qsTr("Добавим их в приложение, если они не отображались")
|
||||
|
||||
clickedFunction: function() {
|
||||
InstallController.scanServerForInstalledContainers()
|
||||
}
|
||||
}
|
||||
|
||||
DividerType {}
|
||||
|
||||
LabelWithButtonType {
|
||||
Layout.fillWidth: true
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@ import PageEnum 1.0
|
|||
import "./"
|
||||
import "../Controls2"
|
||||
import "../Config"
|
||||
import "../Controls2/TextTypes"
|
||||
|
||||
PageType {
|
||||
id: root
|
||||
|
@ -42,28 +43,32 @@ PageType {
|
|||
HeaderType {
|
||||
Layout.fillWidth: true
|
||||
|
||||
headerText: "Подключение к серверу"
|
||||
headerText: qsTr("Server connection")
|
||||
}
|
||||
|
||||
TextFieldWithHeaderType {
|
||||
id: hostname
|
||||
|
||||
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 {
|
||||
id: username
|
||||
|
||||
Layout.fillWidth: true
|
||||
headerText: "Login to connect via SSH"
|
||||
headerText: qsTr("Login to connect via SSH")
|
||||
}
|
||||
|
||||
TextFieldWithHeaderType {
|
||||
id: secretData
|
||||
|
||||
Layout.fillWidth: true
|
||||
headerText: "Password / Private key"
|
||||
headerText: qsTr("Password / Private key")
|
||||
textField.echoMode: TextInput.Password
|
||||
}
|
||||
|
||||
|
@ -71,7 +76,7 @@ PageType {
|
|||
Layout.fillWidth: true
|
||||
Layout.topMargin: 24
|
||||
|
||||
text: qsTr("Настроить сервер простым образом")
|
||||
text: qsTr("Set up a server the easy way")
|
||||
|
||||
onClicked: function() {
|
||||
InstallController.setShouldCreateServer(true)
|
||||
|
@ -92,7 +97,7 @@ PageType {
|
|||
textColor: "#D7D8DB"
|
||||
borderWidth: 1
|
||||
|
||||
text: qsTr("Выбрать протокол для установки")
|
||||
text: qsTr("Select protocol to install")
|
||||
|
||||
onClicked: function() {
|
||||
InstallController.setShouldCreateServer(true)
|
||||
|
|
|
@ -24,7 +24,7 @@ PageType {
|
|||
PageController.showErrorMessage(errorMessage)
|
||||
}
|
||||
|
||||
function onInstallContainerFinished() {
|
||||
function onInstallContainerFinished(isInstalledContainerFound) {
|
||||
goToStartPage()
|
||||
if (stackView.currentItem.objectName === PageController.getPagePath(PageEnum.PageHome)) {
|
||||
PageController.restorePageHomeState(true)
|
||||
|
@ -34,9 +34,15 @@ PageType {
|
|||
} else {
|
||||
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()
|
||||
if (stackView.currentItem.objectName === PageController.getPagePath(PageEnum.PageHome)) {
|
||||
PageController.restorePageHomeState()
|
||||
|
@ -46,6 +52,19 @@ PageType {
|
|||
var pagePath = PageController.getPagePath(PageEnum.PageStart)
|
||||
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))
|
||||
}
|
||||
|
||||
function onGoToPageSettings() {
|
||||
tabBar.currentIndex = 2
|
||||
tabBarStackView.goToTabBarPage(PageController.getPagePath(PageEnum.PageSettings))
|
||||
}
|
||||
|
||||
function onShowErrorMessage(errorMessage) {
|
||||
popupErrorMessage.popupErrorMessageText = errorMessage
|
||||
popupErrorMessage.open()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue