added display of a notification that the server is busy installing third-party software

- refactoring doInstallAction functions
This commit is contained in:
vladimir.kuznetsov 2023-01-01 21:48:20 +03:00
parent 3f257af7a9
commit 08a8eadb49
22 changed files with 398 additions and 346 deletions

View file

@ -1,7 +1,10 @@
#include "OpenVpnLogic.h"
#include "core/servercontroller.h"
#include <functional>
#include "../../uilogic.h"
#include "core/servercontroller.h"
#include "ui/uilogic.h"
#include "ui/pages_logic/ServerConfiguringProgressLogic.h"
using namespace amnezia;
using namespace PageEnumNS;
@ -98,40 +101,59 @@ void OpenVpnLogic::onPushButtonProtoOpenVpnSaveClicked()
QJsonObject newContainerConfig = containerConfig;
newContainerConfig.insert(ProtocolProps::protoToString(Proto::OpenVpn), protocolConfig);
UiLogic::PageFunc page_proto_openvpn;
page_proto_openvpn.setEnabledFunc = [this] (bool enabled) -> void {
ServerConfiguringProgressLogic::PageFunc pageFunc;
pageFunc.setEnabledFunc = [this] (bool enabled) -> void {
set_pageEnabled(enabled);
};
UiLogic::ButtonFunc pushButton_proto_openvpn_save;
pushButton_proto_openvpn_save.setVisibleFunc = [this] (bool visible) ->void {
ServerConfiguringProgressLogic::ButtonFunc saveButtonFunc;
saveButtonFunc.setVisibleFunc = [this] (bool visible) -> void {
set_pushButtonSaveVisible(visible);
};
UiLogic::LabelFunc label_proto_openvpn_info;
label_proto_openvpn_info.setVisibleFunc = [this] (bool visible) ->void {
ServerConfiguringProgressLogic::LabelFunc waitInfoFunc;
waitInfoFunc.setVisibleFunc = [this] (bool visible) -> void {
set_labelProtoOpenVpnInfoVisible(visible);
};
label_proto_openvpn_info.setTextFunc = [this] (const QString& text) ->void {
waitInfoFunc.setTextFunc = [this] (const QString& text) -> void {
set_labelProtoOpenVpnInfoText(text);
};
UiLogic::ProgressFunc progressBar_proto_openvpn_reset;
progressBar_proto_openvpn_reset.setVisibleFunc = [this] (bool visible) ->void {
ServerConfiguringProgressLogic::ProgressFunc progressBarFunc;
progressBarFunc.setVisibleFunc = [this] (bool visible) -> void {
set_progressBarResetVisible(visible);
};
progressBar_proto_openvpn_reset.setValueFunc = [this] (int value) ->void {
progressBarFunc.setValueFunc = [this] (int value) -> void {
set_progressBarResetValue(value);
};
progressBar_proto_openvpn_reset.getValueFunc = [this] (void) -> int {
progressBarFunc.getValueFunc = [this] (void) -> int {
return progressBarResetValue();
};
progressBar_proto_openvpn_reset.getMaximiumFunc = [this] (void) -> int {
progressBarFunc.getMaximiumFunc = [this] (void) -> int {
return progressBarResetMaximium();
};
progressBarFunc.setTextVisibleFunc = [this] (bool visible) -> void {
set_progressBarTextVisible(visible);
};
progressBarFunc.setTextFunc = [this] (const QString& text) -> void {
set_progressBarText(text);
};
ErrorCode e = uiLogic()->doInstallAction([this, containerConfig, &newContainerConfig](){
return m_serverController->updateContainer(m_settings->serverCredentials(uiLogic()->selectedServerIndex), uiLogic()->selectedDockerContainer, containerConfig, newContainerConfig);
ServerConfiguringProgressLogic::LabelFunc busyInfoFuncy;
busyInfoFuncy.setTextFunc = [this] (const QString& text) -> void {
set_labelServerBusyText(text);
};
busyInfoFuncy.setVisibleFunc = [this] (bool visible) -> void {
set_labelServerBusyVisible(visible);
};
progressBarFunc.setTextVisibleFunc(true);
progressBarFunc.setTextFunc(QString("Configuring..."));
ErrorCode e = uiLogic()->pageLogic<ServerConfiguringProgressLogic>()->doInstallAction([this, containerConfig, &newContainerConfig](){
return m_serverController->updateContainer(m_settings->serverCredentials(uiLogic()->selectedServerIndex),
uiLogic()->selectedDockerContainer,
containerConfig,
newContainerConfig);
},
page_proto_openvpn, progressBar_proto_openvpn_reset,
pushButton_proto_openvpn_save, label_proto_openvpn_info);
pageFunc, progressBarFunc,
saveButtonFunc, waitInfoFunc, busyInfoFuncy);
if (!e) {
m_settings->setContainerConfig(uiLogic()->selectedServerIndex, uiLogic()->selectedDockerContainer, newContainerConfig);