From: Eric Bollengier Date: Mon, 20 Dec 2010 20:57:07 +0000 (+0100) Subject: Modify Job view to follow backup progress in real-time X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=036d4345007abbaf5063b8ae709617b2803fd33b;p=bacula%2Fbacula Modify Job view to follow backup progress in real-time --- diff --git a/bacula/src/qt-console/job/job.cpp b/bacula/src/qt-console/job/job.cpp index c9db572e62..73926fc091 100644 --- a/bacula/src/qt-console/job/job.cpp +++ b/bacula/src/qt-console/job/job.cpp @@ -40,13 +40,17 @@ Job::Job(QString &jobId, QTreeWidgetItem *parentTreeWidgetItem) thisitem->setIcon(0,QIcon(QString::fromUtf8(":images/joblog.png"))); m_cursor = new QTextCursor(textJobLog->document()); + m_bwlimit = 0; m_jobId = jobId; + m_timer = NULL; getFont(); connect(pbRefresh, SIGNAL(clicked()), this, SLOT(populateAll())); connect(pbDelete, SIGNAL(clicked()), this, SLOT(deleteJob())); + connect(pbCancel, SIGNAL(clicked()), this, SLOT(cancelJob())); connect(pbRun, SIGNAL(clicked()), this, SLOT(rerun())); connect(list_Volume, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(showInfoVolume(QListWidgetItem *))); + connect(spin_Bwlimit, SIGNAL(valueChanged(int)), this, SLOT(storeBwLimit(int))); populateAll(); dockPage(); @@ -92,6 +96,18 @@ void Job::deleteJob() closeStackPage(); } +void Job::cancelJob() +{ + if (QMessageBox::warning(this, "Bat", + tr("Are you sure you want to cancel this job?"), + QMessageBox::Ok | QMessageBox::Cancel) + == QMessageBox::Cancel) { return; } + + QString cmd("cancel jobid="); + cmd += m_jobId; + consoleCommand(cmd, false); +} + void Job::getFont() { QFont font = textJobLog->font(); @@ -208,6 +224,100 @@ void Job::populateText() } +void Job::storeBwLimit(int val) +{ + m_bwlimit = val; +} + +void Job::updateRunInfo() +{ + QString cmd; + QStringList results; + QStringList lst; + bool parseit=false; + QChar equal = '='; + + if (m_bwlimit >= 100) { + cmd = QString("setbandwidth limit=" + QString::number(m_bwlimit) + + " jobid=" + m_jobId); + m_console->dir_cmd(cmd, results); + results.clear(); + m_bwlimit = 0; + } + + cmd = QString(".status client=\"" + m_client + "\" running"); + + if (m_console->dir_cmd(cmd, results)) { + foreach (QString mline, results) { + foreach (QString line, mline.split("\n")) { + line = line.trimmed(); + lst = line.split(equal); + if (lst.count() != 2) { + Pmsg1(0, "bad count=%d\n",lst.count()); + continue; + } + + if (lst[0] == "JobId") { + if (lst[1] == m_jobId) { + parseit = true; + } else { + parseit = false; + } + } + if (!parseit) { + continue; + } + +// } else if (lst[0] == "Job") { +// grpRun->setTitle(lst[1]); + +// +// } else if (lst[0] == "VSS") { + +// } else if (lst[0] == "Level") { +// Info->setText(lst[1]); +// +// } else if (lst[0] == "JobType") { +// +// } else if (lst[0] == "JobStarted") { +// Started->setText(lst[1]); + + if (lst[0] == "Bwlimit") { + int val = lst[1].toInt(); + if (val > 0) { + chk_Bwlimit->setChecked(true); + spin_Bwlimit->setEnabled(true); + spin_Bwlimit->setValue(lst[1].toInt()/1024); + } else { + chk_Bwlimit->setEnabled(false); + spin_Bwlimit->setEnabled(false); + spin_Bwlimit->setValue(0); + } + +// } else if (lst[0] == "Errors") { +// Errors->setText(lst[1]); + + } else if (lst[0] == "Bytes/sec") { + label_Speed->setText(convertBytesSI(lst[1].toULongLong())+"/s"); + + } else if (lst[0] == "Files") { + label_JobFiles->setText(lst[1]); + + } else if (lst[0] == "Bytes") { + label_JobBytes->setText(convertBytesSI(lst[1].toULongLong())); + + } else if (lst[0] == "FilesExamined") { + label_FilesExamined->setText(lst[1]); + + } else if (lst[0] == "ProcessingFile") { + label_CurrentFile->setText(lst[1]); + + } + } + } + } +} + /* * Populate the text in the window */ @@ -216,10 +326,12 @@ void Job::populateForm() QString stat, err; char buf[256]; QString query = - "SELECT JobId, Job.Name, Level, Client.Name, Pool.Name, FileSet, SchedTime, StartTime, EndTime, " - "EndTime-StartTime AS Duration, JobBytes, JobFiles, JobErrors, JobStatus, PurgedFiles " - "FROM Job JOIN Client USING (ClientId) LEFT JOIN Pool ON (Job.PoolId = Pool.PoolId) " - "LEFT JOIN FileSet ON (Job.FileSetId = FileSet.FileSetId)" + "SELECT JobId, Job.Name, Level, Client.Name, Pool.Name, FileSet," + "SchedTime, StartTime, EndTime, EndTime-StartTime AS Duration, " + "JobBytes, JobFiles, JobErrors, JobStatus, PurgedFiles " + "FROM Job JOIN Client USING (ClientId) " + "LEFT JOIN Pool ON (Job.PoolId = Pool.PoolId) " + "LEFT JOIN FileSet ON (Job.FileSetId = FileSet.FileSetId)" "WHERE JobId=" + m_jobId; QStringList results; if (m_console->sql_cmd(query, results)) { @@ -234,7 +346,8 @@ void Job::populateForm() label_Level->setText(job_level_to_str(fld.next()[0].toAscii())); - label_Client->setText(fld.next()); + m_client = fld.next(); + label_Client->setText(m_client); label_Pool->setText(fld.next()); label_FileSet->setText(fld.next()); label_SchedTime->setText(fld.next()); @@ -260,6 +373,26 @@ void Job::populateForm() if (stat == "T" && err.toInt() > 0) { stat = "W"; } + if (stat == "R") { + pbDelete->setVisible(false); + pbCancel->setVisible(true); + grpRun->setVisible(true); + if (!m_timer) { + m_timer = new QTimer(this); + connect(m_timer, SIGNAL(timeout()), this, SLOT(populateAll())); + m_timer->start(30000); + } + updateRunInfo(); + } else { + pbDelete->setVisible(true); + pbCancel->setVisible(false); + grpRun->setVisible(false); + if (m_timer) { + m_timer->stop(); + delete m_timer; + m_timer = NULL; + } + } label_JobStatus->setPixmap(QPixmap(":/images/" + stat + ".png")); jobstatus_to_ascii_gui(stat[0].toAscii(), buf, sizeof(buf)); stat = buf; diff --git a/bacula/src/qt-console/job/job.h b/bacula/src/qt-console/job/job.h index 154ad6fc4e..263b7a40d7 100644 --- a/bacula/src/qt-console/job/job.h +++ b/bacula/src/qt-console/job/job.h @@ -42,19 +42,24 @@ public: public slots: void populateAll(); void deleteJob(); + void cancelJob(); void showInfoVolume(QListWidgetItem *); void rerun(); + void storeBwLimit(int val); private slots: private: + void updateRunInfo(); void populateText(); void populateForm(); void populateVolumes(); - void getFont(); QTextCursor *m_cursor; QString m_jobId; + QString m_client; + QTimer *m_timer; + int m_bwlimit; }; #endif /* _JOB_H_ */ diff --git a/bacula/src/qt-console/job/job.ui b/bacula/src/qt-console/job/job.ui index 750f909ec7..a189c2671c 100644 --- a/bacula/src/qt-console/job/job.ui +++ b/bacula/src/qt-console/job/job.ui @@ -1,159 +1,182 @@ - + + JobForm - - + + 0 0 - 1064 - 629 + 975 + 631 - + Form - + - + - + - - + + + Cancel + + + + :/images/A.png:/images/A.png + + + true + + + + + + Delete - - :/images/purge.png + + + :/images/purge.png:/images/purge.png - + true - - + + false - + View errors for this Job - + Errors - - :/images/zoom.png + + + :/images/zoom.png:/images/zoom.png - + true - - + + false - + Media - - :/images/zoom.png + + + :/images/zoom.png:/images/zoom.png - + true - - + + false - + History - - :/images/zoom.png + + + :/images/zoom.png:/images/zoom.png - + true - - - + + + 0 0 - + Run again - - :/images/R.png + + + :/images/R.png:/images/R.png - + true - - + + false - + Read doc - + true - - + + false - + FileSet - - :/images/zoom.png + + + :/images/zoom.png:/images/zoom.png - + true - - + + false - + Stats - - :/images/zoom.png + + + :/images/zoom.png:/images/zoom.png - + true - - + + Refresh - - :/images/view-refresh.png + + + :/images/view-refresh.png:/images/view-refresh.png - + true @@ -162,10 +185,10 @@ - + Qt::Horizontal - + 40 20 @@ -176,130 +199,130 @@ - + - - - + + + 0 0 - + 230 180 - + 230 180 - + Basic Information - - - - + + + + JobId: - - - + + + 2 - - Qt::LinksAccessibleByMouse|Qt::NoTextInteraction|Qt::TextSelectableByMouse + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse - - - + + + Job Name: - - - + + + Test - - Qt::LinksAccessibleByMouse|Qt::NoTextInteraction|Qt::TextSelectableByMouse + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse - - - + + + Level: - - - + + + VirtualFull - - Qt::LinksAccessibleByMouse|Qt::NoTextInteraction|Qt::TextSelectableByMouse + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse - - - + + + Client: - - - + + + client-fd - - Qt::LinksAccessibleByMouse|Qt::NoTextInteraction|Qt::TextSelectableByMouse + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse - - - + + + FileSet: - - - + + + TheFileSet - - Qt::LinksAccessibleByMouse|Qt::NoTextInteraction|Qt::TextSelectableByMouse + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse - - - + + + Pool: - - - + + + ThePool - - Qt::LinksAccessibleByMouse|Qt::NoTextInteraction|Qt::TextSelectableByMouse + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse @@ -307,116 +330,116 @@ - - - + + + 0 0 - + 160 180 - + 160 180 - + Status - - - - + + + + Status: - - - + + + - - :/images/T.png + + :/images/T.png - + false - - - + + + Errors: - - - + + + 0 - - Qt::LinksAccessibleByMouse|Qt::NoTextInteraction|Qt::TextSelectableByMouse + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse - - - + + + Files: - - - + + + 1,924 - - Qt::LinksAccessibleByMouse|Qt::NoTextInteraction|Qt::TextSelectableByMouse + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse - - - + + + Bytes: - - - + + + 109 MB - - Qt::LinksAccessibleByMouse|Qt::NoTextInteraction|Qt::TextSelectableByMouse + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse - - - + + + Purged: - - - + + + false - + - + true @@ -425,94 +448,94 @@ - - - + + + 0 0 - + 260 180 - + 260 180 - + Times - - - - + + + + Sched Time: - - - + + + 2009-07-31 00:10:00 - - Qt::LinksAccessibleByMouse|Qt::NoTextInteraction|Qt::TextSelectableByMouse + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse - - - + + + Start Time: - - - + + + 2009-07-31 00:10:00 - - Qt::LinksAccessibleByMouse|Qt::NoTextInteraction|Qt::TextSelectableByMouse + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse - - - + + + End Time: - - - + + + 2009-07-31 00:20:00 - - Qt::LinksAccessibleByMouse|Qt::NoTextInteraction|Qt::TextSelectableByMouse + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse - - - + + + Duration: - - - + + + 00:10:00 - - Qt::LinksAccessibleByMouse|Qt::NoTextInteraction|Qt::TextSelectableByMouse + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse @@ -520,67 +543,68 @@ - - - + + + 0 0 - + 170 181 - + 170 181 - + 170 180 - + Volume Used - + - - - + + + 0 0 - + 149 140 - + 149 140 - + 149 140 - + Vol0001 - - :/images/inflag1.png + + + :/images/inflag1.png:/images/inflag1.png @@ -590,10 +614,122 @@ - + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + true + + + + 500 + 0 + + + + Running Information + + + + + + Speed: + + + + + + + Files Examined: + + + + + + + Current File: + + + + + + + + 250 + 0 + + + + /var/www/bacula/spool + + + + + + + 100,000 + + + + + + + 100 MB/s + + + + + + + false + + + kB/s + + + 100 + + + 200000 + + + 100 + + + 200000 + + + + + + + Bandwidth Limit: + + + + + + + + + Qt::Horizontal - + 40 20 @@ -604,19 +740,37 @@ - - - <html><head><meta name="qrichtext" content="1" /><style type="text/css"> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'Sans Serif'; font-size:10pt; font-weight:400; font-style:normal;"> -<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'DejaVu Sans';"></p></body></html> +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'DejaVu Sans'; font-size:10pt;"></p></body></html> - + - + + + chk_Bwlimit + clicked(bool) + spin_Bwlimit + setEnabled(bool) + + + 51 + 324 + + + 302 + 328 + + + +