]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/qt-console/joblist/joblist.cpp
First cut of bat rerun a Job from Jobs Run
[bacula/bacula] / bacula / src / qt-console / joblist / joblist.cpp
index d131b0bdf9c9366a168c78720de0a56aa0e11a24..2cffc47ef170edfa342e8811ded318836f76dd04 100644 (file)
@@ -6,7 +6,7 @@
    The main author of Bacula is Kern Sibbald, with contributions from
    many others, a complete list can be found in the file AUTHORS.
    This program is Free Software; you can redistribute it and/or
-   modify it under the terms of version two of the GNU General Public
+   modify it under the terms of version three of the GNU Affero General Public
    License as published by the Free Software Foundation and included
    in the file LICENSE.
 
@@ -15,7 +15,7 @@
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
    General Public License for more details.
 
-   You should have received a copy of the GNU General Public License
+   You should have received a copy of the GNU Affero General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
@@ -56,7 +56,6 @@ JobList::JobList(const QString &mediaName, const QString &clientName,
    m_clientName = clientName;
    m_jobName = jobName;
    m_filesetName = filesetName;
-   m_filesetName = filesetName;
    pgInitialize("", parentTreeWidgetItem);
    QTreeWidgetItem* thisitem = mainWin->getFromHash(this);
    thisitem->setIcon(0,QIcon(QString::fromUtf8(":images/emblem-system.png")));
@@ -134,6 +133,10 @@ void JobList::populateTable()
    m_startIndex = headerlist.indexOf(tr("Job Starttime"));
    m_filesIndex = headerlist.indexOf(tr("Job Files"));
    m_bytesIndex = headerlist.indexOf(tr("Job Bytes"));
+   m_levelIndex = headerlist.indexOf(tr("Job Level"));
+   m_nameIndex = headerlist.indexOf(tr("Job Name"));
+   m_filesetIndex = headerlist.indexOf(tr("File Set"));
+   m_clientIndex = headerlist.indexOf(tr("Client"));
 
    /* Initialize the QTableWidget */
    m_checkCurrentWidget = false;
@@ -353,7 +356,9 @@ void JobList::PgSeltreeWidgetClicked()
          m_splitter->setSizes(sizes);
       }
    }
-   dockPage();
+   if (!isOnceDocked()) {
+      dockPage();
+   }
 }
 
 /*
@@ -413,6 +418,7 @@ void JobList::createConnections()
    connect(actionListFilesOnJob, SIGNAL(triggered()), this, SLOT(consoleListFilesOnJob()));
    connect(actionListJobMedia, SIGNAL(triggered()), this, SLOT(consoleListJobMedia()));
    connect(actionDeleteJob, SIGNAL(triggered()), this, SLOT(consoleDeleteJob()));
+   connect(actionRestartJob, SIGNAL(triggered()), this, SLOT(consoleRestartJob()));
    connect(actionPurgeFiles, SIGNAL(triggered()), this, SLOT(consolePurgeFiles()));
    connect(actionRestoreFromJob, SIGNAL(triggered()), this, SLOT(preRestoreFromJob()));
    connect(actionRestoreFromTime, SIGNAL(triggered()), this, SLOT(preRestoreFromTime()));
@@ -451,6 +457,7 @@ void JobList::consoleListJobTotals()
    if (mainWin->m_longList) { cmd.prepend("l"); }
    consoleCommand(cmd);
 }
+
 void JobList::consoleDeleteJob()
 {
    if (QMessageBox::warning(this, "Bat",
@@ -470,6 +477,23 @@ void JobList::consoleDeleteJob()
    consoleCommand(cmd, false);
    populateTable();
 }
+
+void JobList::consoleRestartJob()
+{
+   QString cmd;
+
+   cmd = tr("run job=\"%1\" client=\"%2\" level=%3").arg(m_jobName).arg(m_clientName).arg(m_levelName);
+   if (m_filesetName != "" && m_filesetName != "*None*") {
+      cmd += tr(" fileset=\"%1\"").arg(m_filesetName);
+   }
+
+   if (mainWin->m_commandDebug) Pmsg1(000, "Run cmd : %s\n",cmd.toUtf8().data());
+   consoleCommand(cmd, false);
+   populateTable();
+}
+
+
+
 void JobList::consolePurgeFiles()
 {
    if (QMessageBox::warning(this, "Bat",
@@ -637,6 +661,7 @@ void JobList::selectionChanged()
    if (m_selectedJobsCount == 1) {
       mp_tableWidget->addAction(actionListFilesOnJob);
       mp_tableWidget->addAction(actionListJobMedia);
+      mp_tableWidget->addAction(actionRestartJob);
       mp_tableWidget->addAction(actionRestoreFromJob);
       mp_tableWidget->addAction(actionRestoreFromTime);
       mp_tableWidget->addAction(actionShowLogForJob);
@@ -651,7 +676,19 @@ void JobList::selectionChanged()
    if (m_checkCurrentWidget) {
       int row = mp_tableWidget->currentRow();
       QTableWidgetItem* jobitem = mp_tableWidget->item(row, 0);
-      m_currentJob = jobitem->text();
+      m_currentJob = jobitem->text();    /* get JobId */
+      jobitem = mp_tableWidget->item(row, m_clientIndex);
+      m_clientName = jobitem->text();    /* get Client Name */
+      jobitem = mp_tableWidget->item(row, m_nameIndex);
+      m_jobName = jobitem->text();    /* get Job Name */
+      jobitem = mp_tableWidget->item(row, m_levelIndex);
+      m_levelName = jobitem->text();    /* get level */
+      jobitem = mp_tableWidget->item(row, m_filesetIndex);
+      if (jobitem) {
+         m_filesetName = jobitem->text();    /* get FileSet Name */
+      } else {
+         m_filesetName = "";
+      }
 
       /* include purged action or not */
       jobitem = mp_tableWidget->item(row, m_purgedIndex);
@@ -660,6 +697,7 @@ void JobList::selectionChanged()
       if (purged == tr("No") ) {
          mp_tableWidget->addAction(actionPurgeFiles);
       }*/
+
       /* include restore from time and job action or not */
       jobitem = mp_tableWidget->item(row, m_typeIndex);
       QString type = jobitem->text();
@@ -671,6 +709,7 @@ void JobList::selectionChanged()
             mp_tableWidget->addAction(actionRestoreFromTime);
          }
       }
+
       /* include cancel action or not */
       jobitem = mp_tableWidget->item(row, m_statusIndex);
       QString status = jobitem->text();