Skip to content

Commit

Permalink
Merge pull request #679 from subutai-io/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
crioto authored Mar 1, 2018
2 parents e38d27f + ae311d6 commit 7c11780
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 28 deletions.
62 changes: 54 additions & 8 deletions hub/forms/DlgTransferFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -371,15 +371,18 @@ void DlgTransferFile::clear_files() {

QString DlgTransferFile::parseDate(const QString &month, const QString &day, const QString &year_or_time) {
QString result;
result.append(day);
result.append("/");

static std::map <QString, QString> month_converter {
{"Jan", "01"}, {"Feb", "02"}, {"Mar", "03"}, {"Apr", "04"}, {"May", "05"}, {"Jun", "06"},
{"Jul", "07"}, {"Aug", "08"}, {"Sep", "09"}, {"Oct", "10"}, {"Nov", "11"}, {"Dec", "12"},
};
if(month_converter.find(month) == month_converter.end()) result.append("01");
else result.append(month_converter[month]);
result.append("/");

result.append(day);
result.append("/");

if (year_or_time.contains(":")) result.append(QDate::currentDate().toString("yyyy"));
else result.append(year_or_time);
return result;
Expand Down Expand Up @@ -456,7 +459,7 @@ void DlgTransferFile::add_file_to_file_system_tw(QTableWidget *file_system_tw, i
file_system_tw->insertRow(row);
QTableWidgetItem *wi_file_name;
QTableWidgetItem *wi_file_size = new QTableWidgetItem(QString::number(file.fileSize()));
QTableWidgetItem *wi_file_modified = new QTableWidgetItem(file.created().toString("dd/mm/yyyy"));
QTableWidgetItem *wi_file_modified = new QTableWidgetItem(file.created().toString("MM/dd/yyyy"));
QTableWidgetItem *wi_file_path = new QTableWidgetItem(file.filePath());
if (file.fileType() == FILE_TYPE_DIRECTORY) wi_file_name = new QTableWidgetItem(directory_icon, file.fileName());
else wi_file_name = new QTableWidgetItem(file_icon, file.fileName());
Expand Down Expand Up @@ -627,8 +630,8 @@ void DlgTransferFile::add_file_local(const QFileInfo &fi) {

void DlgTransferFile::add_file_remote(const QString &file_info) {
// Parsing the string
QString new_file_info = file_info;
QStringList splitted = new_file_info.trimmed().replace(QRegExp(" +"), " ").split(" ");
QStringList splitted;
DlgTransferFile::parse_remote_file(file_info, splitted);
if (splitted.size() < 9)
return;

Expand All @@ -648,7 +651,7 @@ void DlgTransferFile::add_file_remote(const QString &file_info) {
file_path.chop(1); // remove last character, which is `*`

QDateTime created = QDateTime::fromString(parseDate(file_month, file_day, file_year_or_time),
"dd/mm/yyyy");
"MM/d/yyyy");

OneFile remote_file(file_name,
file_path,
Expand All @@ -674,9 +677,7 @@ void DlgTransferFile::refresh_button_local() {
}

void DlgTransferFile::refresh_button_remote() {
set_buttons_enabled(false);
refresh_remote_file_system();
set_buttons_enabled(true);
}

////////////////////////////////////////////////////////////////////////////////
Expand All @@ -697,6 +698,12 @@ void DlgTransferFile::refresh_local_file_system() {
}

void DlgTransferFile::refresh_remote_file_system() {

qDebug()
<< "Refresh remote file system"
<< current_remote_dir;

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

Expand All @@ -718,9 +725,13 @@ void DlgTransferFile::refresh_remote_file_system() {

void DlgTransferFile::output_from_remote_command(system_call_wrapper_error_t res, const QStringList &output) {
for (QString file_info : output) {
qDebug()
<< "files from remote: "
<< file_info;
add_file_remote(file_info);
}
remote_movie->stop();
ui->btn_refresh_remote->setEnabled(true);
if (res == SCWE_SUCCESS) {
ui->lbl_remote_files->setStyleSheet("");
ui->lbl_remote_files->setText("Remote");
Expand All @@ -732,6 +743,41 @@ void DlgTransferFile::output_from_remote_command(system_call_wrapper_error_t res
}
////////////////////////////////////////////////////////////////////////////////////////

void DlgTransferFile::parse_remote_file(const QString &file_info, QStringList &splitted){
int counter = 0;
bool reading_file = false;
bool reading_file_name = false;
int number_strings_parsed = 0;
QString st = "";
while(counter != file_info.size()){
if(reading_file_name == true){
st+=file_info[counter];
}
else {
if(reading_file == true){
if(file_info[counter] == ' '){
reading_file = false;
splitted.push_back(st);
st="";
number_strings_parsed++;
}
else st+=file_info[counter];
}
else{
if(file_info[counter] != ' '){
reading_file = true;
st+=file_info[counter];
if (number_strings_parsed == 8)
reading_file_name = true;
}
}
}
counter++;
}
if(reading_file == true) splitted.push_back(st);
}
////////////////////////////////////////////////////////////////////////////////////////

DlgTransferFile::~DlgTransferFile()
{
delete ui;
Expand Down
1 change: 1 addition & 0 deletions hub/forms/DlgTransferFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,7 @@ class DlgTransferFile : public QDialog
void addSSHKey(const QString &key);
void addIPPort(const QString &ip, const QString &port);
void addUser(const QString &user);
void parse_remote_file(const QString &file_info, QStringList &splitted);

private:
QMovie *local_movie;
Expand Down
1 change: 0 additions & 1 deletion hub/src/HubController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,6 @@ ssh_desktop_launch_error_t CHubController::ssh_to_container_internal(const CEnvi

ssh_desktop_launch_error_t CHubController::ssh_to_container(const CEnvironment &env, const CHubContainer &cont) {
QString key = get_env_key(env.id());
CNotificationObserver::Instance()->Info(key, DlgNotification::N_NO_ACTION);
return ssh_to_container_internal(env, cont, key);
}

Expand Down
5 changes: 1 addition & 4 deletions hub/src/SystemCallWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,6 @@ std::pair<system_call_wrapper_error_t, QStringList> CSystemCallWrapper::upload_f
QString cmd
= CSettingsManager::Instance().scp_path();
QStringList args;
CNotificationObserver::Instance()->Info(file_path, DlgNotification::N_NO_ACTION);
args<< "-rp"
<< "-o StrictHostKeyChecking=no"
<< "-P" << ssh_info.first
Expand Down Expand Up @@ -237,7 +236,7 @@ std::pair<system_call_wrapper_error_t, QStringList> CSystemCallWrapper::download
<< "-P" << ssh_info.first
<< "-S" << CSettingsManager::Instance().ssh_path()
<< "-i" << ssh_info.second
<< QString("%1@%2:%3").arg(remote_user, ip, remote_file_path)
<< 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);
Expand Down Expand Up @@ -596,8 +595,6 @@ system_call_wrapper_error_t run_sshkey_in_terminal_internal<Os2Type<OS_WIN> >(co
.arg(port);

if (!key.isEmpty()) {
CNotificationObserver::Instance()->Info(
QObject::tr("Using %1 ssh key").arg(key), DlgNotification::N_NO_ACTION);
str_command += QString(" -i \"%1\" ").arg(key);
}

Expand Down
15 changes: 1 addition & 14 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ main(int argc, char *argv[]) {
}

QCommandLineParser cmd_parser;
cmd_parser.setApplicationDescription(QObject::tr("This tray application should help users to work with hub"));
cmd_parser.setApplicationDescription(QObject::tr("This Control Center application should help users to work with hub"));
QCommandLineOption log_level_opt("l",
"Log level can be DEBUG (0), WARNING (1), CRITICAL (2), FATAL (3), INFO (4). Trace is most detailed logs.",
"log_level",
Expand Down Expand Up @@ -147,19 +147,6 @@ main(int argc, char *argv[]) {
P2PController::Instance().init();
P2PStatus_checker::Instance().update_status();

if (!CSystemCallWrapper::p2p_daemon_check()) {
CNotificationObserver::Error(QObject::tr("Can't operate without the p2p daemon. "
"Either change the path setting in Settings or install the daemon if it is not installed. "
"You can get the %1 daemon from <a href=\"%2\">here</a>.").
arg(current_branch_name()).arg(p2p_package_url()), DlgNotification::N_SETTINGS);

/*send signal about p2p_status *new feature* */
if(CCommons::IsApplicationLaunchable(CSettingsManager::Instance().p2p_path()))
emit P2PStatus_checker::Instance().p2p_status(P2PStatus_checker::P2P_READY);
else
emit P2PStatus_checker::Instance().p2p_status(P2PStatus_checker::P2P_FAIL);
}

result = app.exec();
} while (0);
} catch (std::exception& ge) {
Expand Down
2 changes: 1 addition & 1 deletion version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6.7.0
6.7.1

0 comments on commit 7c11780

Please sign in to comment.