From: Dirk H Bartley Date: Tue, 17 Apr 2007 02:00:28 +0000 (+0000) Subject: Add a feature to be able to get a list of jobs of a specific client. This is X-Git-Tag: Release-7.0.0~6565 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=f75c7dd62a692005b16e09f7d0c68399fe609498;p=bacula%2Fbacula Add a feature to be able to get a list of jobs of a specific client. This is accomplished from a context sensitive menu in the client list window. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@4563 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/src/qt-console/clients/clients.cpp b/bacula/src/qt-console/clients/clients.cpp index af3b0614c3..c7a5a1ef26 100644 --- a/bacula/src/qt-console/clients/clients.cpp +++ b/bacula/src/qt-console/clients/clients.cpp @@ -148,7 +148,7 @@ void Clients::treeItemChanged(QTreeWidgetItem *currentwidgetitem, QTreeWidgetIte if (previouswidgetitem) { /* avoid a segfault if first time */ int treedepth = previouswidgetitem->data(0, Qt::UserRole).toInt(); if (treedepth == 1){ -// mp_treeWidget->removeAction(actionEditVolume); + mp_treeWidget->removeAction(actionListJobsofClient); } } @@ -156,8 +156,8 @@ void Clients::treeItemChanged(QTreeWidgetItem *currentwidgetitem, QTreeWidgetIte if (treedepth == 1){ /* set a hold variable to the client name in case the context sensitive * menu is used */ - m_currentlyselected=currentwidgetitem->text(1); -// mp_treeWidget->addAction(actionEditVolume); + m_currentlyselected=currentwidgetitem->text(0); + mp_treeWidget->addAction(actionListJobsofClient); } } } @@ -177,6 +177,18 @@ void Clients::createContextMenu() /* connect to the action specific to this pages class */ connect(actionRefreshClients, SIGNAL(triggered()), this, SLOT(populateTree())); + connect(actionListJobsofClient, SIGNAL(triggered()), this, + SLOT(showJobs())); +} + +/* + * Function responding to actionListJobsofClient which calls mainwin function + * to create a window of a list of jobs of this client. + */ +void Clients::showJobs() +{ + QString emptymedia(""); + mainWin->createPageJobList(emptymedia, m_currentlyselected); } /* diff --git a/bacula/src/qt-console/clients/clients.h b/bacula/src/qt-console/clients/clients.h index 4e03ad4b52..53b5361d82 100644 --- a/bacula/src/qt-console/clients/clients.h +++ b/bacula/src/qt-console/clients/clients.h @@ -54,6 +54,7 @@ public slots: private slots: void populateTree(); + void showJobs(); private: void createContextMenu(); diff --git a/bacula/src/qt-console/clients/clients.ui b/bacula/src/qt-console/clients/clients.ui index 3ae91719d5..7df98614bd 100644 --- a/bacula/src/qt-console/clients/clients.ui +++ b/bacula/src/qt-console/clients/clients.ui @@ -34,6 +34,14 @@ Requery the director for the list of clients. + + + ../images/unmark.png + + + List Jobs of Client + + diff --git a/bacula/src/qt-console/joblist/joblist.cpp b/bacula/src/qt-console/joblist/joblist.cpp index dd09f5a37b..587d0912f9 100644 --- a/bacula/src/qt-console/joblist/joblist.cpp +++ b/bacula/src/qt-console/joblist/joblist.cpp @@ -40,13 +40,15 @@ /* * Constructor for the class */ -JobList::JobList(QStackedWidget *parent, Console *console, QString &medianame) +JobList::JobList(QStackedWidget *parent, Console *console, QString &medianame, + QString &clientname) { setupUi(this); /* Store passed variables in member variables */ mp_console = console; m_parent = parent; m_medianame = medianame; + m_clientname = clientname; m_resultCount = 0; m_populated = false; m_closeable = false; @@ -68,26 +70,33 @@ void JobList::populateTable() /* Set up query QString and header QStringList */ QString query(""); - query += "SELECT j.Jobid,j.Name,j.Starttime,j.Type,j.Level,j.Jobfiles," - "j.JobBytes,j.JobStatus" - " FROM job j, jobmedia jm, media m" - " WHERE jm.jobid=j.jobid and jm.mediaid=m.mediaid"; + query += "SELECT Job.Jobid AS Id, Job.Name AS JobName, Client.Name AS Client," + " Job.Starttime AS JobStart, Job.Type AS JobType," + " Job.Level AS BackupLevel, Job.Jobfiles AS FileCount," + " Job.JobBytes AS Bytes, Job.JobStatus AS Status" + " FROM Job, JobMedia, Media, Client" + " WHERE JobMedia.JobId=Job.JobId and JobMedia.MediaId=Media.MediaId" + " and Client.ClientId=Job.ClientId"; if (m_medianame != "") { - query += " and m.VolumeName='" + m_medianame + "'"; + query += " and Media.VolumeName='" + m_medianame + "'"; m_closeable=true; } - query += " ORDER BY j.Starttime"; + if (m_clientname != "") { + query += " and Client.Name='" + m_clientname + "'"; + m_closeable=true; + } + query += " ORDER BY Job.Starttime"; QStringList headerlist = (QStringList() - << "Job Id" << "Job Name" << "Job Starttime" << "Job Type" << "Job Level" - << "Job Files" << "Job Bytes" << "Job Status"); + << "Job Id" << "Job Name" << "Client" << "Job Starttime" << "Job Type" + << "Job Level" << "Job Files" << "Job Bytes" << "Job Status" ); /* Initialize the QTableWidget */ mp_tableWidget->clear(); mp_tableWidget->setColumnCount(headerlist.size()); mp_tableWidget->setHorizontalHeaderLabels(headerlist); - /* This could be a debug message?? */ - /* printf("Query cmd : %s\n",query.toUtf8().data()); */ + /* This could be a user preference debug message?? */ + printf("Query cmd : %s\n",query.toUtf8().data()); if (mp_console->sql_cmd(query, results)) { m_resultCount = results.count(); @@ -113,16 +122,18 @@ void JobList::populateTable() } } if ((m_medianame != "") && (m_resultCount == 0)){ - /* for context sensitive searches, let the user know if there were no results */ - QMessageBox::warning(this, tr("Bat"), tr("The Jobs query returned no results.\n" + /* for context sensitive searches, let the user know if there were no + * results */ + QMessageBox::warning(this, tr("Bat"), + tr("The Jobs query returned no results.\n" "Press OK to continue?"), QMessageBox::Ok ); } } /* - * * When the treeWidgetItem in the page selector tree is singleclicked, Make sure - * * The tree has been populated. - * */ + * When the treeWidgetItem in the page selector tree is singleclicked, Make sure + * The tree has been populated. + */ void JobList::PgSeltreeWidgetClicked() { if (!m_populated) { @@ -132,7 +143,8 @@ void JobList::PgSeltreeWidgetClicked() } /* - * Virtual function which is called when this page is visible on the stack + * Virtual function override of pages function which is called when this page + * is visible on the stack */ void JobList::currentStackItem() { diff --git a/bacula/src/qt-console/joblist/joblist.h b/bacula/src/qt-console/joblist/joblist.h index c2769dc559..03b5d128fd 100644 --- a/bacula/src/qt-console/joblist/joblist.h +++ b/bacula/src/qt-console/joblist/joblist.h @@ -43,7 +43,7 @@ class JobList : public Pages, public Ui::JobListForm Q_OBJECT public: - JobList(QStackedWidget *parent, Console *console, QString &medianame); + JobList(QStackedWidget *parent, Console *console, QString &medianame, QString &clientname); virtual void PgSeltreeWidgetClicked(); virtual void currentStackItem(); int m_resultCount; @@ -54,6 +54,7 @@ public slots: private: Console *mp_console; QString m_medianame; + QString m_clientname; bool m_populated; }; diff --git a/bacula/src/qt-console/mainwin.cpp b/bacula/src/qt-console/mainwin.cpp index f2f8e914f7..a3fe6f26ab 100644 --- a/bacula/src/qt-console/mainwin.cpp +++ b/bacula/src/qt-console/mainwin.cpp @@ -98,8 +98,8 @@ void MainWin::createPages() * under each director */ createPagebRestore(); createPageMediaList(); - QString emptymedia(""); - createPageJobList(emptymedia); + QString emptymedia(""), emptyclient(""); + createPageJobList(emptymedia, emptyclient); createPageClients(); treeWidget->expandItem(m_topItem); @@ -131,23 +131,28 @@ void MainWin::createPageMediaList() /* * create an instance of the the joblist class on the stack */ -void MainWin::createPageJobList(QString &media) +void MainWin::createPageJobList(QString &media, QString &client) { QTreeWidgetItem *item, *holdItem; /* save current tree widget item in case query produces no results */ holdItem = treeWidget->currentItem(); - if (media == "") { + if ((media == "") && (client == "")) { item=createPage("All Jobs", m_topItem); } else { - QString desc("Jobs on "); - desc += media; + QString desc("Jobs "); + if (media != "" ) { + desc += "on Volume " + media; + } + if (client != "" ) { + desc += "of Client " + client; + } item=createPage(desc.toUtf8().data(), m_topItem); - } - JobList* joblist = new JobList(stackedWidget, m_console, media); + } + JobList* joblist = new JobList(stackedWidget, m_console, media, client); hashInsert(item, joblist); joblist->dockPage(); /* If this is a query of jobs on a specific media */ - if (media != "") { + if ((media != "") || (client != "")) { stackedWidget->setCurrentWidget(joblist); treeWidget->setCurrentItem(item); /* did query produce results, if not close window and set back to hold */ diff --git a/bacula/src/qt-console/mainwin.h b/bacula/src/qt-console/mainwin.h index c9054dda95..36fe8938a8 100644 --- a/bacula/src/qt-console/mainwin.h +++ b/bacula/src/qt-console/mainwin.h @@ -75,7 +75,7 @@ public: QHash m_pagehash; /* This hash is to get the page selector widget when the page is known */ QHash m_widgethash; - void createPageJobList(QString &); + void createPageJobList(QString &, QString &); public slots: void input_line(); diff --git a/bacula/src/qt-console/medialist/medialist.cpp b/bacula/src/qt-console/medialist/medialist.cpp index 056082e3b4..eecbb5d6d5 100644 --- a/bacula/src/qt-console/medialist/medialist.cpp +++ b/bacula/src/qt-console/medialist/medialist.cpp @@ -166,7 +166,8 @@ void MediaList::editMedia() */ void MediaList::showJobs() { - mainWin->createPageJobList(m_currentlyselected); + QString emptyclient(""); + mainWin->createPageJobList(m_currentlyselected, emptyclient); } /*