added a button to cancel installation if the package manager on the server is busy
This commit is contained in:
parent
dd233f77fc
commit
3defb09da9
7 changed files with 29 additions and 4 deletions
|
|
@ -634,9 +634,9 @@ QString ServerController::checkSshConnection(const ServerCredentials &credential
|
||||||
return stdOut;
|
return stdOut;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerController::setCancelInstallation(const bool cancel)
|
void ServerController::cancelInstallation()
|
||||||
{
|
{
|
||||||
m_cancelInstallation = cancel;
|
m_cancelInstallation = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
ErrorCode ServerController::setupServerFirewall(const ServerCredentials &credentials)
|
ErrorCode ServerController::setupServerFirewall(const ServerCredentials &credentials)
|
||||||
|
|
@ -737,6 +737,7 @@ ErrorCode ServerController::isUserInSudo(const ServerCredentials &credentials, D
|
||||||
|
|
||||||
ErrorCode ServerController::isServerDpkgBusy(const ServerCredentials &credentials, DockerContainer container)
|
ErrorCode ServerController::isServerDpkgBusy(const ServerCredentials &credentials, DockerContainer container)
|
||||||
{
|
{
|
||||||
|
m_cancelInstallation = false;
|
||||||
QString stdOut;
|
QString stdOut;
|
||||||
auto cbReadStdOut = [&](const QString &data, libssh::Client &) {
|
auto cbReadStdOut = [&](const QString &data, libssh::Client &) {
|
||||||
stdOut += data + "\n";
|
stdOut += data + "\n";
|
||||||
|
|
@ -784,7 +785,6 @@ ErrorCode ServerController::isServerDpkgBusy(const ServerCredentials &credential
|
||||||
watcher.setFuture(future);
|
watcher.setFuture(future);
|
||||||
wait.exec();
|
wait.exec();
|
||||||
|
|
||||||
m_cancelInstallation = false;
|
|
||||||
emit serverIsBusy(false);
|
emit serverIsBusy(false);
|
||||||
|
|
||||||
return future.result();
|
return future.result();
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@ public:
|
||||||
|
|
||||||
QString checkSshConnection(const ServerCredentials &credentials, ErrorCode *errorCode = nullptr);
|
QString checkSshConnection(const ServerCredentials &credentials, ErrorCode *errorCode = nullptr);
|
||||||
|
|
||||||
void setCancelInstallation(const bool cancel);
|
void cancelInstallation();
|
||||||
|
|
||||||
ErrorCode getDecryptedPrivateKey(const ServerCredentials &credentials, QString &decryptedPrivateKey,
|
ErrorCode getDecryptedPrivateKey(const ServerCredentials &credentials, QString &decryptedPrivateKey,
|
||||||
const std::function<QString()> &callback);
|
const std::function<QString()> &callback);
|
||||||
|
|
|
||||||
|
|
@ -130,6 +130,7 @@ void InstallController::installServer(DockerContainer container, QJsonObject &co
|
||||||
{
|
{
|
||||||
ServerController serverController(m_settings);
|
ServerController serverController(m_settings);
|
||||||
connect(&serverController, &ServerController::serverIsBusy, this, &InstallController::serverIsBusy);
|
connect(&serverController, &ServerController::serverIsBusy, this, &InstallController::serverIsBusy);
|
||||||
|
connect(this, &InstallController::cancelInstallation, &serverController, &ServerController::cancelInstallation);
|
||||||
|
|
||||||
QMap<DockerContainer, QJsonObject> installedContainers;
|
QMap<DockerContainer, QJsonObject> installedContainers;
|
||||||
ErrorCode errorCode =
|
ErrorCode errorCode =
|
||||||
|
|
@ -181,6 +182,7 @@ void InstallController::installContainer(DockerContainer container, QJsonObject
|
||||||
|
|
||||||
ServerController serverController(m_settings);
|
ServerController serverController(m_settings);
|
||||||
connect(&serverController, &ServerController::serverIsBusy, this, &InstallController::serverIsBusy);
|
connect(&serverController, &ServerController::serverIsBusy, this, &InstallController::serverIsBusy);
|
||||||
|
connect(this, &InstallController::cancelInstallation, &serverController, &ServerController::cancelInstallation);
|
||||||
|
|
||||||
QMap<DockerContainer, QJsonObject> installedContainers;
|
QMap<DockerContainer, QJsonObject> installedContainers;
|
||||||
ErrorCode errorCode = serverController.getAlreadyInstalledContainers(serverCredentials, installedContainers);
|
ErrorCode errorCode = serverController.getAlreadyInstalledContainers(serverCredentials, installedContainers);
|
||||||
|
|
@ -282,6 +284,7 @@ void InstallController::updateContainer(QJsonObject config)
|
||||||
|
|
||||||
ServerController serverController(m_settings);
|
ServerController serverController(m_settings);
|
||||||
connect(&serverController, &ServerController::serverIsBusy, this, &InstallController::serverIsBusy);
|
connect(&serverController, &ServerController::serverIsBusy, this, &InstallController::serverIsBusy);
|
||||||
|
connect(this, &InstallController::cancelInstallation, &serverController, &ServerController::cancelInstallation);
|
||||||
|
|
||||||
auto errorCode = serverController.updateContainer(serverCredentials, container, oldContainerConfig, config);
|
auto errorCode = serverController.updateContainer(serverCredentials, container, oldContainerConfig, config);
|
||||||
if (errorCode == ErrorCode::NoError) {
|
if (errorCode == ErrorCode::NoError) {
|
||||||
|
|
|
||||||
|
|
@ -65,6 +65,7 @@ signals:
|
||||||
void passphraseRequestFinished();
|
void passphraseRequestFinished();
|
||||||
|
|
||||||
void serverIsBusy(const bool isBusy);
|
void serverIsBusy(const bool isBusy);
|
||||||
|
void cancelInstallation();
|
||||||
|
|
||||||
void currentContainerUpdated();
|
void currentContainerUpdated();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@ PageType {
|
||||||
|
|
||||||
property bool isTimerRunning: true
|
property bool isTimerRunning: true
|
||||||
property string progressBarText: qsTr("Usually it takes no more than 5 minutes")
|
property string progressBarText: qsTr("Usually it takes no more than 5 minutes")
|
||||||
|
property bool isCancelButtonVisible: false
|
||||||
|
|
||||||
Connections {
|
Connections {
|
||||||
target: InstallController
|
target: InstallController
|
||||||
|
|
@ -61,11 +62,13 @@ PageType {
|
||||||
|
|
||||||
function onServerIsBusy(isBusy) {
|
function onServerIsBusy(isBusy) {
|
||||||
if (isBusy) {
|
if (isBusy) {
|
||||||
|
root.isCancelButtonVisible = true
|
||||||
root.progressBarText = qsTr("Amnezia has detected that your server is currently ") +
|
root.progressBarText = qsTr("Amnezia has detected that your server is currently ") +
|
||||||
qsTr("busy installing other software. Amnezia installation ") +
|
qsTr("busy installing other software. Amnezia installation ") +
|
||||||
qsTr("will pause until the server finishes installing other software")
|
qsTr("will pause until the server finishes installing other software")
|
||||||
root.isTimerRunning = false
|
root.isTimerRunning = false
|
||||||
} else {
|
} else {
|
||||||
|
root.isCancelButtonVisible = false
|
||||||
root.progressBarText = qsTr("Usually it takes no more than 5 minutes")
|
root.progressBarText = qsTr("Usually it takes no more than 5 minutes")
|
||||||
root.isTimerRunning = true
|
root.isTimerRunning = true
|
||||||
}
|
}
|
||||||
|
|
@ -150,6 +153,22 @@ PageType {
|
||||||
|
|
||||||
text: root.progressBarText
|
text: root.progressBarText
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BasicButtonType {
|
||||||
|
id: cancelIntallationButton
|
||||||
|
|
||||||
|
Layout.fillWidth: true
|
||||||
|
Layout.topMargin: 24
|
||||||
|
|
||||||
|
visible: root.isCancelButtonVisible
|
||||||
|
|
||||||
|
text: qsTr("Cancel installation")
|
||||||
|
|
||||||
|
onClicked: {
|
||||||
|
InstallController.cancelInstallation()
|
||||||
|
PageController.showBusyIndicator(true)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -60,6 +60,7 @@ PageType {
|
||||||
target: InstallController
|
target: InstallController
|
||||||
|
|
||||||
function onInstallationErrorOccurred(errorMessage) {
|
function onInstallationErrorOccurred(errorMessage) {
|
||||||
|
PageController.showBusyIndicator(false)
|
||||||
PageController.showErrorMessage(errorMessage)
|
PageController.showErrorMessage(errorMessage)
|
||||||
|
|
||||||
var currentPageName = stackView.currentItem.objectName
|
var currentPageName = stackView.currentItem.objectName
|
||||||
|
|
|
||||||
|
|
@ -82,6 +82,7 @@ PageType {
|
||||||
target: InstallController
|
target: InstallController
|
||||||
|
|
||||||
function onInstallationErrorOccurred(errorMessage) {
|
function onInstallationErrorOccurred(errorMessage) {
|
||||||
|
PageController.showBusyIndicator(false)
|
||||||
PageController.showErrorMessage(errorMessage)
|
PageController.showErrorMessage(errorMessage)
|
||||||
|
|
||||||
var needCloseCurrentPage = false
|
var needCloseCurrentPage = false
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue