Skip to content

Commit

Permalink
Merge pull request #697 from subutai-io/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
crioto authored Mar 7, 2018
2 parents ba17a72 + ef3b2bc commit 90514cf
Show file tree
Hide file tree
Showing 18 changed files with 90 additions and 40 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Change Log

## [6.7.2] 7/3/2018
* Renaming files
* Several environment bugs fixed

## [6.7.1] 6/3/2018
* Renaming
* Bug Fixes
Expand Down
2 changes: 1 addition & 1 deletion SubutaiControlCenter.pro
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ win32: {
DEFINES += CURRENT_OS=OS_WIN
DEFINES += RT_OS_WINDOWS
LIBS += -lws2_32 -L$$PWD/libssh2/lib/win32 -llibssh2
RC_FILE = tray.rc
RC_FILE = control-center.rc
# LIBS += -lpthread
# QMAKE_LFLAGS += -static-libstdc++ -static-libgcc
}
Expand Down
File renamed without changes.
26 changes: 18 additions & 8 deletions hub/forms/DlgTransferFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ void DlgTransferFile::Init() {


ui->btn_upload_file->setToolTip("Upload selected files");
ui->btn_upload_file->setIcon(QIcon(":/hub/upload-0.png"));
ui->btn_download_file->setToolTip("Download selected files");
ui->btn_download_file->setIcon(QIcon(":/hub/download.png"));

ui->btn_refresh_local->setToolTip("Refresh current local directory");
ui->btn_refresh_remote->setToolTip("Refresh current remote directory");
Expand Down Expand Up @@ -206,6 +208,12 @@ void DlgTransferFile::set_buttons_enabled(bool enabled) {
ui->btn_remote_back->setEnabled(enabled);
}

void DlgTransferFile::set_remote_button_enabled(bool enabled){
ui->btn_refresh_remote->setEnabled(enabled);
ui->btn_remote_back->setEnabled(enabled);
ui->btn_download_file->setEnabled(enabled);
}

void DlgTransferFile::transfer_finished(int tw_row, system_call_wrapper_error_t res, QStringList output) {
static QIcon transfer_finished_icon(":/hub/GOOD");
static QIcon transfer_failed_icon(":/hub/BAD");
Expand All @@ -232,10 +240,12 @@ void DlgTransferFile::transfer_finished(int tw_row, system_call_wrapper_error_t
else {
file_to_transfer.setTransferFileStatus(FIlE_FAILED_TO_UPLOAD);
if(res == SCWE_PERMISSION_DENIED)
twi_operation_status->setText("Permision denied");
twi_operation_status->setToolTip("Permision denied");
else
twi_operation_status->setText("Failed to upload");
twi_operation_status->setToolTip("Failed to upload");
twi_operation_status->setIcon(transfer_failed_icon);
if(file_to_transfer.fileInfo().fileName().contains("\\"))
twi_operation_status->setText("Invalid file name");
twi_operation_status->setToolTip(
output.join(",") +
" Error Code: " + CSystemCallWrapper::scwe_error_to_str(res));
Expand All @@ -255,8 +265,9 @@ void DlgTransferFile::transfer_finished(int tw_row, system_call_wrapper_error_t
else
twi_operation_status->setText("Failed to download");
twi_operation_status->setIcon(transfer_failed_icon);
twi_operation_status->setToolTip(
output.join(",") +
if(file_to_transfer.fileInfo().fileName().contains("\\"))
twi_operation_status->setText("Invalid file name");
twi_operation_status->setToolTip(output.join(",") +
" Error Code: " + CSystemCallWrapper::scwe_error_to_str(res));
}
}
Expand Down Expand Up @@ -596,7 +607,7 @@ void DlgTransferFile::local_back() {
}

void DlgTransferFile::remote_back() {
set_buttons_enabled(false);
set_remote_button_enabled(false);
QStringList pwd = current_remote_dir.split("/");
QString new_dir = "";
// EXAMPLE: current_remote_dir= '/usr/bin/'
Expand All @@ -607,7 +618,6 @@ void DlgTransferFile::remote_back() {
new_dir.append("/");
current_remote_dir = new_dir;
refresh_remote_file_system();
set_buttons_enabled(true);
}

////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -703,7 +713,7 @@ void DlgTransferFile::refresh_remote_file_system() {
<< "Refresh remote file system"
<< current_remote_dir;

ui->btn_refresh_remote->setEnabled(false);
set_remote_button_enabled(false);
ui->lbl_remote_files->setMovie(remote_movie);
remote_movie->start();

Expand Down Expand Up @@ -731,7 +741,7 @@ void DlgTransferFile::output_from_remote_command(system_call_wrapper_error_t res
add_file_remote(file_info);
}
remote_movie->stop();
ui->btn_refresh_remote->setEnabled(true);
set_remote_button_enabled(true);
if (res == SCWE_SUCCESS) {
ui->lbl_remote_files->setStyleSheet("");
ui->lbl_remote_files->setText("Remote");
Expand Down
1 change: 1 addition & 0 deletions hub/forms/DlgTransferFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,7 @@ class DlgTransferFile : public QDialog

void file_was_dropped(const QString &file_path);
void set_buttons_enabled(bool enabled);
void set_remote_button_enabled(bool enabled);
void transfer_finished(int tw_row, system_call_wrapper_error_t res, QStringList output);
void transfer_file(int tw_row);
void start_transfer_files();
Expand Down
20 changes: 12 additions & 8 deletions hub/forms/DlgTransferFile.ui
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
<string/>
</property>
<property name="icon">
<iconset theme=":/hub/upload">
<normaloff>:/hub/upload.ico</normaloff>:/hub/upload.ico</iconset>
<iconset resource="../../resources/resources.qrc">
<normaloff>:/hub/upload-0.png</normaloff>:/hub/upload-0.png</iconset>
</property>
</widget>
</item>
Expand All @@ -41,7 +41,7 @@
<string/>
</property>
<property name="icon">
<iconset theme=":/hub/download">
<iconset resource="../../resources/resources.qrc">
<normaloff>:/hub/download.png</normaloff>:/hub/download.png</iconset>
</property>
</widget>
Expand All @@ -62,7 +62,7 @@
<string/>
</property>
<property name="icon">
<iconset>
<iconset resource="../../resources/resources.qrc">
<normaloff>:/hub/back.png</normaloff>:/hub/back.png</iconset>
</property>
</widget>
Expand All @@ -86,7 +86,7 @@
<string/>
</property>
<property name="icon">
<iconset>
<iconset resource="../../resources/resources.qrc">
<normaloff>:/hub/refresh.png</normaloff>:/hub/refresh.png</iconset>
</property>
</widget>
Expand All @@ -100,7 +100,7 @@
<string/>
</property>
<property name="icon">
<iconset>
<iconset resource="../../resources/resources.qrc">
<normaloff>:/hub/refresh.png</normaloff>:/hub/refresh.png</iconset>
</property>
</widget>
Expand Down Expand Up @@ -187,7 +187,7 @@
<string/>
</property>
<property name="icon">
<iconset>
<iconset resource="../../resources/resources.qrc">
<normaloff>:/hub/back.png</normaloff>:/hub/back.png</iconset>
</property>
</widget>
Expand All @@ -209,6 +209,10 @@
<header location="global">DlgTransferFile.h</header>
</customwidget>
</customwidgets>
<resources/>
<resources>
<include location="../../resources/resources.qrc"/>
<include location="../../resources/resources.qrc"/>
<include location="../../resources/resources.qrc"/>
</resources>
<connections/>
</ui>
3 changes: 2 additions & 1 deletion hub/include/DlgEnvironment.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class DlgEnvironment : public QDialog
Ui::DlgEnvironment *ui;
CEnvironment env;
std::map<QString,QCheckBox*> selected_conts;
std::map<QString,QLabel*> dekstops_info;
std::map<QString,QLabel*> desktops_info;

void addContainer(const CHubContainer*cont);
void check_container_status(const CHubContainer *cont);
Expand All @@ -33,6 +33,7 @@ class DlgEnvironment : public QDialog
void desktop_selected();
void ssh_selected();
void select_all(bool checked);
void check_buttons();

signals:
void ssh_to_container_sig(const CEnvironment*, const CHubContainer*);
Expand Down
3 changes: 2 additions & 1 deletion hub/include/SystemCallWrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ enum system_call_wrapper_error_t {
SCWE_WHICH_CALL_FAILED,
SCWE_PROCESS_CRASHED,
SCWE_LAST,
SCWE_PERMISSION_DENIED
SCWE_PERMISSION_DENIED,
SCWE_WRONG_FILE_NAME
};
////////////////////////////////////////////////////////////////////////////

Expand Down
41 changes: 36 additions & 5 deletions hub/src/DlgEnvironment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,10 @@ void DlgEnvironment::addContainer(const CHubContainer *cont) {
ui->cont_desktop_info->addWidget(cont_desktop_info);
ui->cont_select->addWidget(cont_select);
selected_conts[cont->id()] = cont_select;
desktops_info[cont->id()] = cont_desktop_info;
connect(cont_select, &QCheckBox::stateChanged, [this](){
this->check_buttons();
});
}

/////////////////////////////////////////////////////////////////////////
Expand All @@ -158,22 +162,17 @@ void DlgEnvironment::change_cont_status(const CHubContainer *cont, int status) {
QCheckBox *cont_checkbox = selected_conts[cont->id()];
if (status == 0)
{
cont_checkbox->setCheckable(true);
cont_checkbox->setText(tr("READY"));
cont_checkbox->setStyleSheet("QCheckBox {color : green;}");
}
else
if (status == 1)
{
//cont_checkbox->setCheckable(false);
//cont_checkbox->setChecked(false);
cont_checkbox->setText(tr("CONNECTING"));
cont_checkbox->setStyleSheet("QCheckBox {color : blue;}");
}
else
if (status == 2){
//cont_checkbox->setCheckable(false);
//cont_checkbox->setChecked(false);
cont_checkbox->setText(tr("FAILED"));
cont_checkbox->setStyleSheet("QCheckBox {color : red;}");
}
Expand All @@ -185,6 +184,7 @@ void DlgEnvironment::check_container_status(const CHubContainer *cont) {
qDebug() << "Checking the status of container: " << cont->name() << " in " << env.name();
P2PController::P2P_CONNETION_STATUS
cont_status = P2PController::Instance().is_ready(env, *cont);
desktops_info[cont->id()]->setText(QString(cont->is_desktop() ? cont->desk_env().isEmpty() ? "MATE" : cont->desk_env() : "No Desktop"));
change_cont_status(cont, cont_status != P2PController::CONNECTION_SUCCESS);
}

Expand All @@ -209,8 +209,39 @@ void DlgEnvironment::check_environment_status() {
change_cont_status(&cont, 2);
}
}
check_buttons();
}

////////////////////////////////////////////////////////////////////////////
void DlgEnvironment::check_buttons() {
qDebug()
<< "Checking which button I can press" << env.name();
bool not_empty = false;
bool upload = true, ssh = true, desktop = true;
P2PController::P2P_CONNETION_STATUS
swarm_status = P2PController::Instance().is_swarm_connected(env);
bool connected_to_swarm = (env.healthy() & (swarm_status == P2PController::CONNECTION_SUCCESS));
if(connected_to_swarm){
for (CHubContainer cont : env.containers()) {
QCheckBox *current_check_box = selected_conts[cont.id()];
if(current_check_box->checkState() == Qt::Checked){
if(current_check_box->text() != "READY"){
upload = ssh = desktop = false;
break;
}
if(!cont.is_desktop())
desktop = false;
not_empty = true;
}
}
}
else{
upload = ssh = desktop = false;
}
ui->btn_desktop_selected->setEnabled(desktop & not_empty);
ui->btn_upload_selected->setEnabled(upload & not_empty);
ui->btn_ssh_selected->setEnabled(ssh & not_empty);
}
////////////////////////////////////////////////////////////////////////////

DlgEnvironment::~DlgEnvironment() {
Expand Down
6 changes: 3 additions & 3 deletions hub/src/RestWorker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ void CRestWorker::update_my_peers() {

connect(timer, &QTimer::timeout, [reply](){
CNotificationObserver::Instance()->
Info("Connection timeout, can't connect to hub", DlgNotification::N_NO_ACTION);
Info("Connection timeout, can't connect to bazaar", DlgNotification::N_NO_ACTION);
if (reply)
reply->close();
});
Expand Down Expand Up @@ -273,7 +273,7 @@ void CRestWorker::update_environments() {

connect(timer, &QTimer::timeout, [reply](){
CNotificationObserver::Instance()->
Info("Connection timeout, can't connect to hub", DlgNotification::N_NO_ACTION);
Info("Connection timeout, can't connect to bazaar", DlgNotification::N_NO_ACTION);
if (reply)
reply->close();
});
Expand Down Expand Up @@ -305,7 +305,7 @@ void CRestWorker::update_balance() {

connect(timer, &QTimer::timeout, [reply](){
CNotificationObserver::Instance()->
Info("Connection timeout, can't connect to hub", DlgNotification::N_NO_ACTION);
Info("Connection timeout, can't connect to bazaar", DlgNotification::N_NO_ACTION);
if (reply)
reply->close();
});
Expand Down
6 changes: 3 additions & 3 deletions hub/src/SettingsManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ static void qvar_to_map_string_qvariant(const QVariant& var, void* field) {

static const int DEFAULT_REFRESH_TIMEOUT_SEC = 20;
static QString settings_file_path() {
static const QString settings_file = "subutai_tray.ini";
static const QString settings_file = "subutai_control.ini";

QStringList lst_config=
QStandardPaths::standardLocations(QStandardPaths::ConfigLocation);
Expand Down Expand Up @@ -148,7 +148,7 @@ static QString subutai_path() {
}
}

dir_path = dir_path + QDir::separator() + QString("tray");
dir_path = dir_path + QDir::separator() + QString("control-center");
QDir dir_tray(dir_path);
if (!dir_tray.exists()) {
if (!dir_tray.mkdir(dir_path)) {
Expand All @@ -157,7 +157,7 @@ static QString subutai_path() {
}
}

return QDir::homePath() +QDir::separator() + QString(".subutai") + QDir::separator() + QString("tray");
return QDir::homePath() +QDir::separator() + QString(".subutai") + QDir::separator() + QString("control-center");
}
////////////////////////////////////////////////////////////////////////////

Expand Down
7 changes: 2 additions & 5 deletions hub/src/SystemCallWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,13 +213,11 @@ std::pair<system_call_wrapper_error_t, QStringList> CSystemCallWrapper::upload_f
<< "-S" << CSettingsManager::Instance().ssh_path()
<< "-i" << ssh_info.second
<< file_path
<< QString("%1@%2:%3").arg(remote_user, ip, destination);
<< QString("%1@%2:\"%3\"").arg(remote_user, ip, destination);
qDebug() << "ARGS=" << args;

system_call_res_t res = ssystem_th(cmd, args, true, true, 97);
if (res.res == SCWE_SUCCESS && res.exit_code != 0) {
// if(res.exit_code == 1)
// return std::make_pair(SCWE_PERMISSION_DENIED, res.out);
return std::make_pair(SCWE_CREATE_PROCESS, res.out);
}
return std::make_pair(res.res, res.out);
Expand All @@ -239,10 +237,9 @@ std::pair<system_call_wrapper_error_t, QStringList> CSystemCallWrapper::download
<< QString("%1@%2:\"%3\"").arg(remote_user, ip, remote_file_path)
<< local_destination;
qDebug() << "ARGS=" << args;

system_call_res_t res = ssystem_th(cmd, args, true, true, 97);
if (res.res == SCWE_SUCCESS && res.exit_code != 0) {
//if(res.exit_code == 1)
// return std::make_pair(SCWE_PERMISSION_DENIED, res.out);
return std::make_pair(SCWE_CREATE_PROCESS, res.out);
}
return std::make_pair(res.res, res.out);
Expand Down
6 changes: 3 additions & 3 deletions hub/src/updater/IUpdaterComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ const QString IUpdaterComponent::P2P = "p2p";
const QString IUpdaterComponent::P2P = "p2p.exe";
#endif
#ifndef RT_OS_WINDOWS
const QString IUpdaterComponent::TRAY = "SubutaiTray";
const QString IUpdaterComponent::TRAY = "SubutaiControlCenter";
#else
const QString IUpdaterComponent::TRAY = "SubutaiTray.exe";
const QString IUpdaterComponent::TRAY = "SubutaiControlCenter.exe";
#endif

const QString IUpdaterComponent::RH = "resource_host";
Expand All @@ -23,7 +23,7 @@ const QString &
IUpdaterComponent::component_id_to_user_view(const QString& id) {
static std::map<QString, QString> dct = {
{P2P, "p2p"},
{TRAY, "tray application"},
{TRAY, "ControlCenter"},
{RH, "resource host"},
{RHMANAGEMENT, "resource host management"}
};
Expand Down
2 changes: 1 addition & 1 deletion main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ main(int argc, char *argv[]) {

if (is_first && !QApplication::arguments().contains(CCommons::RESTARTED_ARG)) {
QMessageBox* msg_box = new QMessageBox(QMessageBox::Information, QObject::tr("Already running"),
QObject::tr("One instance of tray application is already running"),
QObject::tr("One instance of control center application is already running"),
QMessageBox::Ok);
QObject::connect(msg_box, &QMessageBox::finished, msg_box, &QMessageBox::deleteLater);
msg_box->exec();
Expand Down
Empty file added neo\matrix
Empty file.
Loading

0 comments on commit 90514cf

Please sign in to comment.