]> git.sur5r.net Git - bacula/bacula/commitdiff
baculum: Enable support for Verify jobs
authorMarcin Haba <marcin.haba@bacula.pl>
Tue, 9 Dec 2014 21:21:24 +0000 (22:21 +0100)
committerMarcin Haba <marcin.haba@bacula.pl>
Tue, 9 Dec 2014 21:21:24 +0000 (22:21 +0100)
13 files changed:
gui/baculum/protected/Class/Miscellaneous.php
gui/baculum/protected/Lang/en/messages.mo
gui/baculum/protected/Lang/en/messages.po
gui/baculum/protected/Lang/pl/messages.mo
gui/baculum/protected/Lang/pl/messages.po
gui/baculum/protected/Pages/API/JobRun.php
gui/baculum/protected/Portlets/JobConfiguration.php
gui/baculum/protected/Portlets/JobConfiguration.tpl
gui/baculum/protected/Portlets/JobList.php
gui/baculum/protected/Portlets/JobList.tpl
gui/baculum/protected/Portlets/JobRunConfiguration.php
gui/baculum/protected/Portlets/JobRunConfiguration.tpl
gui/baculum/themes/Baculum-v1/style.css

index b167b94b4242a1388cdf31afe136784568b77873..ad0b61021ec4a77c08a460a984b51617b6879334 100644 (file)
@@ -4,7 +4,59 @@ class Miscellaneous extends TModule {
 
        const LICENCE_FILE = 'LICENSE';
 
-       private $jobLevels = array('F' => 'Full', 'I' => 'Incremental', 'D'=> 'Differential', 'B' => 'Base', 'f' => 'VirtualFull');
+       private $jobTypes = array(
+               'B' => 'Backup',
+               'M' => 'Migrated',
+               'V' => 'Verify',
+               'R' => 'Restore',
+               'I' => 'Internal',
+               'D' => 'Admin',
+               'A' => 'Archive',
+               'C' => 'Copy',
+               'g' => 'Migration'
+       );
+
+       private $jobLevels = array(
+               'F' => 'Full',
+               'I' => 'Incremental',
+               'D' => 'Differential',
+               'B' => 'Base',
+               'f' => 'VirtualFull',
+               'V' => 'InitCatalog',
+               'C' => 'Catalog',
+               'O' => 'VolumeToCatalog',
+               'd' => 'DiskToCatalog'
+       );
+
+       private $jobStates =  array(
+               'C' => array('value' => 'Created', 'description' =>'Created but not yet running'),
+               'R' => array('value' => 'Running', 'description' => 'Running'),
+               'B' => array('value' => 'Blocked', 'description' => 'Blocked'),
+               'T' => array('value' => 'Terminated', 'description' =>'Terminated normally'),
+               'W' => array('value' => 'Terminated with warnings', 'description' =>'Terminated normally with warnings'),
+               'E' => array('value' => 'Error', 'description' =>'Terminated in Error'),
+               'e' => array('value' => 'Non-fatal error', 'description' =>'Non-fatal error'),
+               'f' => array('value' => 'Fatal error', 'description' =>'Fatal error'),
+               'D' => array('value' => 'Verify Diff.', 'description' =>'Verify Differences'),
+               'A' => array('value' => 'Canceled by user', 'description' =>'Canceled by the user'),
+               'I' => array('value' => 'Incomplete', 'description' =>'Incomplete Job'),
+               'F' => array('value' => 'Waiting on FD', 'description' =>'Waiting on the File daemon'),
+               'S' => array('value' => 'Waiting on SD', 'description' =>'Waiting on the Storage daemon'),
+               'm' => array('value' => 'Waiting for new vol.', 'description' =>'Waiting for a new Volume to be mounted'),
+               'M' => array('value' => 'Waiting for mount', 'description' =>'Waiting for a Mount'),
+               's' => array('value' => 'Waiting for storage', 'description' =>'Waiting for Storage resource'),
+               'j' => array('value' => 'Waiting for job', 'description' =>'Waiting for Job resource'),
+               'c' => array('value' => 'Waiting for client', 'description' =>'Waiting for Client resource'),
+               'd' => array('value' => 'Waiting for Max. jobs', 'description' =>'Wating for Maximum jobs'),
+               't' => array('value' => 'Waiting for start', 'description' =>'Waiting for Start Time'),
+               'p' => array('value' => 'Waiting for higher priority', 'description' =>'Waiting for higher priority job to finish'),
+               'i' => array('value' => 'Batch insert', 'description' =>'Doing batch insert file records'),
+               'a' => array('value' => 'Despooling attributes', 'description' =>'SD despooling attributes'),
+               'l' => array('value' => 'Data despooling', 'description' =>'Doing data despooling'),
+               'L' => array('value' => 'Commiting data', 'description' =>'Committing data (last despool)')
+       );
+
+       private $runningJobStates = array('C', 'R');
 
        /**
         * Getting the licence from file.
@@ -20,6 +72,32 @@ class Miscellaneous extends TModule {
                return $this->jobLevels;
        }
 
+       public function getJobState($jobStateLetter = null) {
+               $state;
+               if(is_null($jobStateLetter)) {
+                       $state = $this->jobStates;
+               } else {
+                       $state = array_key_exists($jobStateLetter, $this->jobStates) ? $this->jobStates[$jobStateLetter] : null;
+               }
+               return $state;
+       }
+
+       public function getRunningJobStates() {
+               return $this->runningJobStates;
+       }
+
+
+       public function getJobType($jobTypeLetter = null) {
+               $type;
+               if(is_null($jobTypeLetter)) {
+                       $type = $this->jobTypes;
+               } else {
+                       $type = array_key_exists($jobTypeLetter, $this->jobTypes) ? $this->jobTypes[$jobTypeLetter] : null;
+               }
+               return $type;
+
+       }
+
        public function isValidJobLevel($jobLevel) {
                return array_key_exists($jobLevel, $this->getJobLevels());
        }
@@ -140,4 +218,4 @@ class Miscellaneous extends TModule {
                return $elements;
        }
 }
-?>
\ No newline at end of file
+?>
index 0a2bde78893a042367266cc5eaa7d303cc31d224..5b75739980b5aaad03e2be27292fb2e34ecab2d3 100755 (executable)
Binary files a/gui/baculum/protected/Lang/en/messages.mo and b/gui/baculum/protected/Lang/en/messages.mo differ
index dbb62f7e26a909fd5927ec2317bae5a6364530b0..a2457c489571184d78b239923cb38286ed370476 100755 (executable)
@@ -986,3 +986,20 @@ msgstr "Vol. Use Duration (in sec.):"
 msgid "Yes"
 msgstr "Yes"
 
+msgid "JobId to Verify:"
+msgstr "JobId to Verify:"
+
+msgid "JobId to Verify value must be integer greather than 0."
+msgstr "JobId to Verify value must be integer greather than 0."
+
+msgid "Job to Verify:"
+msgstr "Job to Verify:"
+
+msgid "Verify by Job Name"
+msgstr "Verify by Job Name"
+
+msgid "Verify by JobId"
+msgstr "Verify by JobId"
+
+msgid "Verify option:"
+msgstr "Verify option:"
index a1da8d1dc274395139f4c787cb8dec29f47175fc..f05d48bc1e07b6ed7189fb3aa96334fabe209bcf 100755 (executable)
Binary files a/gui/baculum/protected/Lang/pl/messages.mo and b/gui/baculum/protected/Lang/pl/messages.mo differ
index b4ea2f6bb9a6750fec887d8079ed52f9fe35a2ab..b0d5575c49e373819b3042d067f54f518e54c3a5 100644 (file)
@@ -321,10 +321,10 @@ msgid "Database file path (SQLite only):"
 msgstr "Lokalizacja pliku DB (tylko SQLite):"
 
 msgid "Delete job"
-msgstr "Usuń zadanie"
+msgstr "Usuń"
 
 msgid "Cancel job"
-msgstr "Anuluj zadanie"
+msgstr "Przerwij"
 
 msgid "select pool"
 msgstr "wybierz pulę"
@@ -459,7 +459,7 @@ msgid "Jobs for run"
 msgstr "Zadania do uruchomienia"
 
 msgid "Job status"
-msgstr "Status zadania"
+msgstr "Status"
 
 msgid "Run job again"
 msgstr "Uruchom ponownie"
@@ -987,3 +987,21 @@ msgstr "Zadanie do przywrócenia:"
 msgid "Step 7 - Finish"
 msgstr "Krok 7 - Podsumowanie"
 
+msgid "JobId to Verify:"
+msgstr "JobId do weryfikacji:"
+
+msgid "JobId to Verify value must be integer greather than 0."
+msgstr "JobId do weryfikacji musi być liczbą całkowitą większą od 0."
+
+msgid "Job to Verify:"
+msgstr "Zadanie do weryfikacji:"
+
+msgid "Verify by Job Name"
+msgstr "Weryfikuj na podstawie nazwy zadania"
+
+msgid "Verify by JobId"
+msgstr "Weryfikuj na podstawie JobId"
+
+msgid "Verify option:"
+msgstr "Opcja weryfikacji:"
+
index 30b430969398b38b824780cb170eb08ba7bf9ffd..d54d5cf9fd29bde3c31e288d33eea18c483502d2 100644 (file)
@@ -33,6 +33,9 @@ class JobRun extends BaculumAPI {
                $poolid = property_exists($params, 'poolid') ? intval($params->poolid) : null;
                $pool = $this->getModule('pool')->getPoolById($poolid);
                $priority = property_exists($params, 'priority') ? intval($params->priority) : 10; // default priority is set to 10
+               $jobid = property_exists($params, 'jobid') ? 'jobid="' . intval($params->jobid) . '"' : '';
+               // @TODO: Move Job name pattern in more appropriate place
+               $verifyjob = property_exists($params, 'verifyjob')  && preg_match('/^[\w\d\.\-\s]+$/', $params->verifyjob) === 1 ? 'verifyjob="' . ($params->verifyjob) . '"' : '';
                
                if(!is_null($job)) {
                        $isValidLevel = $this->getModule('misc')->isValidJobLevel($params->level);
@@ -42,7 +45,7 @@ class JobRun extends BaculumAPI {
                                                if(!is_null($storage)) {
                                                        if(!is_null($pool)) {
                                                                $joblevels  = $this->getModule('misc')->getJobLevels();
-                                                               $run = $this->getModule('bconsole')->bconsoleCommand($this->director, array('run', 'job="' . $job . '"', 'level="' . $joblevels[$level] . '"', 'fileset="' . $fileset . '"', 'client="' . $client->name . '"', 'storage="' . $storage->name . '"', 'pool="' . $pool->name . '"' , 'priority="' . $priority . '"', 'yes'), $this->user);
+                                                               $run = $this->getModule('bconsole')->bconsoleCommand($this->director, array('run', 'job="' . $job . '"', 'level="' . $joblevels[$level] . '"', 'fileset="' . $fileset . '"', 'client="' . $client->name . '"', 'storage="' . $storage->name . '"', 'pool="' . $pool->name . '"' , 'priority="' . $priority . '"',  $jobid , $verifyjob, 'yes'), $this->user);
                                                                $this->output = $run->output;
                                                                $this->error = (integer)$run->exitcode;
                                                        } else {
@@ -72,4 +75,4 @@ class JobRun extends BaculumAPI {
        }
 }
 
-?>
\ No newline at end of file
+?>
index e08869d22749111ff63bde11eba1c479c91bd12a..f0b19fbb9a351d68e253e1252cc67520fdd68d9d 100644 (file)
  * Bacula® is a registered trademark of Kern Sibbald.
  */
 
+Prado::using('System.Web.UI.ActiveControls.TActivePanel');
 Prado::using('Application.Portlets.Portlets');
 
 class JobConfiguration extends Portlets {
 
        const DEFAULT_JOB_PRIORITY = 10;
 
-       private $runningJobStates = array('C', 'R');
+
+       public $jobToVerify = array('C', 'O', 'd');
+
+       public $verifyOptions = array('jobname' => 'Verify by Job Name', 'jobid' => 'Verify by JobId');
 
        public function configure($jobId) {
                $jobdata = $this->Application->getModule('api')->get(array('jobs', $jobId))->output;
@@ -36,6 +40,32 @@ class JobConfiguration extends Portlets {
                $this->Level->SelectedValue = $jobdata->level;
                $this->Level->dataBind();
 
+               $isVerifyOption = in_array($jobdata->level, $this->jobToVerify);
+               $this->JobToVerifyOptionsLine->Display = ($isVerifyOption === true) ? 'Dynamic' : 'None';
+               $this->JobToVerifyJobNameLine->Display = ($isVerifyOption === true) ? 'Dynamic' : 'None';
+               $this->JobToVerifyJobIdLine->Display = 'None';
+               $this->AccurateLine->Display = ($isVerifyOption === true) ? 'None' : 'Dynamic';
+               $this->EstimateLine->Display = ($isVerifyOption === true) ? 'None' : 'Dynamic';
+
+               $verifyValues = array();
+
+               foreach($this->verifyOptions as $value => $text) {
+                       $verifyValues[$value] = Prado::localize($text);
+               }
+
+               $this->JobToVerifyOptions->dataSource = $verifyValues;
+               $this->JobToVerifyOptions->dataBind();
+
+               $jobTasks = $this->Application->getModule('api')->get(array('jobs', 'tasks'))->output;
+
+               $jobsAllDirs = array();
+               foreach($jobTasks as $director => $tasks) {
+                       $jobsAllDirs = array_merge($jobsAllDirs, $tasks);
+               }
+
+               $this->JobToVerifyJobName->dataSource = array_combine($jobsAllDirs, $jobsAllDirs);
+               $this->JobToVerifyJobName->dataBind();
+
                $clients = $this->Application->getModule('api')->get(array('clients'))->output;
                $clientsList = array();
                foreach($clients as $client) {
@@ -74,9 +104,11 @@ class JobConfiguration extends Portlets {
                $this->Storage->dataSource = $storagesList;
                $this->Storage->dataBind();
 
+               $runningJobStates = $this->Application->getModule('misc')->getRunningJobStates();
+
                $this->Priority->Text = ($jobdata->priorjobid == 0) ? self::DEFAULT_JOB_PRIORITY : $jobdata->priorjobid;
                $this->DeleteButton->Visible = true;
-               $this->CancelButton->Visible = in_array($jobdata->jobstatus, $this->runningJobStates);
+               $this->CancelButton->Visible = in_array($jobdata->jobstatus, $runningJobStates);
        }
 
        public function status($sender, $param) {
@@ -106,6 +138,16 @@ class JobConfiguration extends Portlets {
                $params['storageid'] = $this->Storage->SelectedValue;
                $params['poolid'] = $this->Pool->SelectedValue;
                $params['priority'] = $this->Priority->Text;
+
+               if (in_array($this->Level->SelectedItem->Value, $this->jobToVerify)) {
+                       $verifyVals = $this->getVerifyVals();
+                       if ($this->JobToVerifyOptions->SelectedItem->Value == $verifyVals['jobname']) {
+                               $params['verifyjob'] = $this->JobToVerifyJobName->SelectedValue;
+                       } elseif ($this->JobToVerifyOptions->SelectedItem->Value == $verifyVals['jobid']) {
+                               $params['jobid'] = $this->JobToVerifyJobId->Text;
+                       }
+               }
+
                $result = $this->Application->getModule('api')->create(array('jobs', 'run'), $params)->output;
                $this->Estimation->Text = implode(PHP_EOL, $result);
        }
@@ -125,5 +167,22 @@ class JobConfiguration extends Portlets {
                $isValid = preg_match('/^[0-9]+$/',$this->Priority->Text) === 1 && $this->Priority->Text > 0;
                $param->setIsValid($isValid);
        }
+
+       public function jobIdToVerifyValidator($sender, $param) {
+               $verifyVals = $this->getVerifyVals();
+               if(in_array($this->Level->SelectedValue, $this->jobToVerify) && $this->JobToVerifyOptions->SelectedItem->Value == $verifyVals['jobid']) {
+                       $isValid = preg_match('/^[0-9]+$/',$this->JobToVerifyJobId->Text) === 1 && $this->JobToVerifyJobId->Text > 0;
+               } else {
+                       $isValid = true;
+               }
+               $param->setIsValid($isValid);
+               return $isValid;
+       }
+
+       private function getVerifyVals() {
+               $verifyOpt = array_keys($this->verifyOptions);
+               $verifyVals = array_combine($verifyOpt, $verifyOpt);
+               return $verifyVals;
+       }
 }
 ?>
index 298d5fe4ac7cb490a50dae4e1436c752bb59c000..1052462f13f31e6d1627208c962ff1061135b902 100644 (file)
                <div class="line">
                        <div class="text"><com:TLabel ForControl="Level" Text="<%[ Level: ]%>" /></div>
                        <div class="field">
-                               <com:TActiveDropDownList ID="Level" AutoPostBack="false" CssClass="textbox-auto" />
+                               <com:TActiveDropDownList ID="Level" AutoPostBack="false" CssClass="textbox-auto">
+                                       <prop:Attributes.onchange>
+                                               var job_to_verify = $('<%=$this->JobToVerifyOptionsLine->ClientID%>');
+                                               var verify_options = $('<%=$this->JobToVerifyOptionsLine->ClientID%>');
+                                               var verify_by_job_name = $('<%=$this->JobToVerifyJobNameLine->ClientID%>');
+                                               var verify_by_jobid = $('<%=$this->JobToVerifyJobIdLine->ClientID%>');
+                                               var accurate = $('<%=$this->AccurateLine->ClientID%>');
+                                               var estimate = $('<%=$this->EstimateLine->ClientID%>');
+                                               var verify_current_opt = $('<%=$this->JobToVerifyOptions->ClientID%>').value;
+                                               if(/^(<%=implode('|', $this->jobToVerify)%>)$/.test(this.value)) {
+                                                       accurate.hide();
+                                                       estimate.hide();
+                                                       verify_options.show();
+                                                       job_to_verify.show();
+                                                       if (verify_current_opt == 'jobid') {
+                                                               verify_by_job_name.hide();
+                                                               verify_by_jobid.show();
+                                                       } else if (verify_current_opt == 'jobname') {
+                                                               verify_by_job_name.show();
+                                                               verify_by_jobid.hide();
+                                                       }
+                                               } else if (job_to_verify.visible()) {
+                                                       job_to_verify.hide();
+                                                       verify_options.hide();
+                                                       verify_by_job_name.hide();
+                                                       verify_by_jobid.hide();
+                                                       accurate.show();
+                                                       estimate.show();
+                                               }
+                                       </prop:Attributes.onchange>
+                               </com:TActiveDropDownList>
                        </div>
                </div>
+               <com:TActivePanel ID="JobToVerifyOptionsLine" CssClass="line">
+                       <div class="text"><com:TLabel ForControl="JobToVerifyOptions" Text="<%[ Verify option: ]%>" /></div>
+                       <div class="field">
+                               <com:TActiveDropDownList ID="JobToVerifyOptions" AutoPostBack="false" CssClass="textbox-auto">
+                                       <prop:Attributes.onchange>
+                                               var verify_by_job_name = $('<%=$this->JobToVerifyJobNameLine->ClientID%>');
+                                               var verify_by_jobid = $('<%=$this->JobToVerifyJobIdLine->ClientID%>');
+                                               if (this.value == 'jobname') {
+                                                       verify_by_jobid.hide();
+                                                       verify_by_job_name.show();
+                                               } else if (this.value == 'jobid') {
+                                                       verify_by_job_name.hide();
+                                                       verify_by_jobid.show();
+                                               } else {
+                                                       verify_by_job_name.hide();
+                                                       verify_by_jobid.hide();
+                                               }
+                                       </prop:Attributes.onchange>
+                               </com:TActiveDropDownList>
+                       </div>
+               </com:TActivePanel>
+               <com:TActivePanel ID="JobToVerifyJobNameLine" CssClass="line">
+                       <div class="text"><com:TLabel ForControl="JobToVerifyJobName" Text="<%[ Job to Verify: ]%>" /></div>
+                       <div class="field">
+                               <com:TActiveDropDownList ID="JobToVerifyJobName" AutoPostBack="false" CssClass="textbox-auto" />
+                       </div>
+               </com:TActivePanel>
+               <com:TActivePanel ID="JobToVerifyJobIdLine" CssClass="line">
+                       <div class="text"><com:TLabel ForControl="JobToVerifyJobId" Text="<%[ JobId to Verify: ]%>" /></div>
+                       <div class="field">
+                               <com:TActiveTextBox ID="JobToVerifyJobId" CssClass="textbox-auto" AutoPostBack="false" />
+                               <com:TActiveCustomValidator ID="JobToVerifyJobIdValidator" ValidationGroup="JobGroup" ControlToValidate="JobToVerifyJobId" ErrorMessage="<%[ JobId to Verify value must be integer greather than 0. ]%>" ControlCssClass="validation-error" Display="None" OnServerValidate="jobIdToVerifyValidator" />
+                       </div>
+               </com:TActivePanel>
                <div class="line">
                        <div class="text"><com:TLabel ForControl="Client" Text="<%[ Client: ]%>" /></div>
                        <div class="field">
                <div class="field-full" style="min-height: 166px">
                        <com:TActiveTextBox ID="Estimation" TextMode="MultiLine" CssClass="textbox-auto" Style="height: 145px" ReadOnly="true" />
                </div>
-               <div class="line">
+               <com:TActivePanel ID="AccurateLine" CssClass="line">
                        <div class="text"><com:TLabel ForControl="Accurate" Text="<%[ Accurate: ]%>" /></div>
                        <div class="field"><com:TActiveCheckBox ID="Accurate" AutoPostBack="false" /></div>
-               </div>
-               <div class="button">
+               </com:TActivePanel>
+               <com:TActivePanel ID="EstimateLine" CssClass="button">
                        <com:BActiveButton ID="Estimate" Text="<%[ Estimate job ]%>" OnClick="estimate" ClientSide.OnSuccess="ConfigurationWindow.getObj('JobWindow').progress(false);job_callback_func();" />
-               </div>
+               </com:TActivePanel>
        </com:TActivePanel>
 </com:TContent>
index 1748575f0ac9857920d34186575b785de47d13b6..12cd790a5b712d7fe5b8f3bfc00ce83d835b2db1 100644 (file)
@@ -31,18 +31,8 @@ class JobList extends Portlets implements ISlideWindow {
        public $buttonID;
        public $windowTitle;
        public $jobLevels;
-       private $jobStates;
-       private $jobTypes = array(
-               'B' => 'Backup',
-               'M' => 'Migrated',
-               'V' => 'Verify',
-               'R' => 'Restore',
-               'I' => 'Internal',
-               'D' => 'Admin',
-               'A' => 'Archive',
-               'C' => 'Copy',
-               'g' => 'Migration'
-       );
+       public $jobStates;
+       public $jobTypes;
 
        public function setID($id) {
                $this->ID = $id;
@@ -71,42 +61,10 @@ class JobList extends Portlets implements ISlideWindow {
        public function onLoad($param) {
                parent::onLoad($param);
                $this->prepareData();
-               $this->jobLevels = $this->Application->getModule('misc')->getJobLevels();
-       }
-
-       public function getJobType($jobLetter) {
-               return array_key_exists($jobLetter, $this->jobTypes) ? $this->jobTypes[$jobLetter] : null;
-       }
-
-       public function getJobState($jobStateLetter) {
-               $jobstates =  array(
-               'C' => (object)array('value' => 'Created', 'description' =>'Created but not yet running'),
-               'R' => (object)array('value' => 'Running', 'description' => 'Running'),
-               'B' => (object)array('value' => 'Blocked', 'description' => 'Blocked'),
-               'T' => (object)array('value' => 'Terminated', 'description' =>'Terminated normally'),
-               'W' => (object)array('value' => 'Terminated with warnings', 'description' =>'Terminated normally with warnings'),
-               'E' => (object)array('value' => 'Error', 'description' =>'Terminated in Error'),
-               'e' => (object)array('value' => 'Non-fatal error', 'description' =>'Non-fatal error'),
-               'f' => (object)array('value' => 'Fatal error', 'description' =>'Fatal error'),
-               'D' => (object)array('value' => 'Verify', 'description' =>'Verify Differences'),
-               'A' => (object)array('value' => 'Canceled by user', 'description' =>'Canceled by the user'),
-               'I' => (object)array('value' => 'Incomplete', 'description' =>'Incomplete Job'),
-               'F' => (object)array('value' => 'Waiting on FD', 'description' =>'Waiting on the File daemon'),
-               'S' => (object)array('value' => 'Waiting on SD', 'description' =>'Waiting on the Storage daemon'),
-               'm' => (object)array('value' => 'Waiting for new vol.', 'description' =>'Waiting for a new Volume to be mounted'),
-               'M' => (object)array('value' => 'Waiting for mount', 'description' =>'Waiting for a Mount'),
-               's' => (object)array('value' => 'Waiting for storage', 'description' =>'Waiting for Storage resource'),
-               'j' => (object)array('value' => 'Waiting for job', 'description' =>'Waiting for Job resource'),
-               'c' => (object)array('value' => 'Waiting for client', 'description' =>'Waiting for Client resource'),
-               'd' => (object)array('value' => 'Waiting for Max. jobs', 'description' =>'Wating for Maximum jobs'),
-               't' => (object)array('value' => 'Waiting for start', 'description' =>'Waiting for Start Time'),
-               'p' => (object)array('value' => 'Waiting for higher priority', 'description' =>'Waiting for higher priority job to finish'),
-               'i' => (object)array('value' => 'Batch insert', 'description' =>'Doing batch insert file records'),
-               'a' => (object)array('value' => 'Despooling attributes', 'description' =>'SD despooling attributes'),
-               'l' => (object)array('value' => 'Data despooling', 'description' =>'Doing data despooling'),
-               'L' => (object)array('value' => 'Commiting data', 'description' =>'Committing data (last despool)')
-       );
-               return array_key_exists($jobStateLetter, $jobstates) ? $jobstates[$jobStateLetter] : null;
+               $misc = $this->Application->getModule('misc');
+               $this->jobLevels = $misc->getJobLevels();
+               $this->jobStates = $misc->getJobState();
+               $this->jobTypes = $misc->getJobType();
        }
 
        public function prepareData($forceReload = false) {
index 5b8d800f18a0a05a33716b39703e4f1770176a04..cdde59509b843cc2acecaf8c991bbaa745256483 100644 (file)
                                 <input type="hidden" name="<%=$this->getParent()->ClientID%>" value="<%=$this->getParent()->Data['jobid']%>" />
                        </prop:ItemTemplate>
                </com:TActiveTemplateColumn>
-               <com:TActiveTemplateColumn ItemTemplate="<%=$this->getPage()->JobWindow->getJobType($this->getParent()->Data['type'])%>" SortExpression="type">
+               <com:TActiveTemplateColumn ItemTemplate="<%=isset($this->getPage()->JobWindow->jobTypes[$this->getParent()->Data['type']]) ? $this->getPage()->JobWindow->jobTypes[$this->getParent()->Data['type']] : ''%>" SortExpression="type">
                        <prop:HeaderText>
                                <span title="<%=Prado::localize('Type')%>" style="cursor: help">T</span>
                        </prop:HeaderText>
                </com:TActiveTemplateColumn>
-               <com:TActiveTemplateColumn ItemTemplate="<%=array_key_exists($this->getParent()->Data['level'], $this->getPage()->JobWindow->jobLevels) ? mb_substr($this->getPage()->JobWindow->jobLevels[$this->getParent()->Data['level']], 0, 4) : ''%>" SortExpression="level">
+               <com:TActiveTemplateColumn ItemTemplate="<%=array_key_exists($this->getParent()->Data['level'], $this->getPage()->JobWindow->jobLevels) ? $this->getPage()->JobWindow->jobLevels[$this->getParent()->Data['level']] : ''%>" SortExpression="level">
                        <prop:HeaderText>
                                <span title="<%=Prado::localize('Level')%>" style="cursor: help">L</span>
                        </prop:HeaderText>
                </com:TActiveTemplateColumn>
                <com:TActiveTemplateColumn HeaderText="<%[ Job status ]%>" SortExpression="jobstatus">
                        <prop:ItemTemplate>
-                               <div class="job-status-<%=$this->getParent()->Data['jobstatus']%>" title="<%=isset($this->getPage()->JobWindow->getJobState($this->getParent()->Data['jobstatus'])->description) ? $this->getPage()->JobWindow->getJobState($this->getParent()->Data['jobstatus'])->description : ''%>"><%=isset($this->getPage()->JobWindow->getJobState($this->getParent()->Data['jobstatus'])->value) ? $this->getPage()->JobWindow->getJobState($this->getParent()->Data['jobstatus'])->value : ''%></div>
+                               <div class="job-status-<%=isset($this->getParent()->Data['jobstatus']) ? $this->getParent()->Data['jobstatus'] : ''%>" title="<%=isset($this->getPage()->JobWindow->jobStates[$this->getParent()->Data['jobstatus']]['description']) ? $this->getPage()->JobWindow->jobStates[$this->getParent()->Data['jobstatus']]['description'] : ''%>"><%=isset($this->getPage()->JobWindow->jobStates[$this->getParent()->Data['jobstatus']]['value']) ? $this->getPage()->JobWindow->jobStates[$this->getParent()->Data['jobstatus']]['value'] : ''%></div>
                        </prop:ItemTemplate>
                </com:TActiveTemplateColumn>
                <com:TActiveBoundColumn
index 345a28e91f971796f9ab7cb588ab11283068b9d1..15e671d5b5991e52693b1c2a8f49eb4ea33574f6 100644 (file)
  * Bacula® is a registered trademark of Kern Sibbald.
  */
 
+Prado::using('System.Web.UI.ActiveControls.TActivePanel');
 Prado::using('Application.Portlets.Portlets');
 
 class JobRunConfiguration extends Portlets {
 
        const DEFAULT_JOB_PRIORITY = 10;
 
+       public $jobToVerify = array('C', 'O', 'd');
+
+       public $verifyOptions = array('jobname' => 'Verify by Job Name', 'jobid' => 'Verify by JobId');
+
        public function configure($jobname) {
                $this->JobName->Text = $jobname;
                $this->Estimation->Text = '';
@@ -30,6 +35,31 @@ class JobRunConfiguration extends Portlets {
                $this->Level->dataSource = $this->Application->getModule('misc')->getJobLevels();
                $this->Level->dataBind();
 
+               $this->JobToVerifyOptionsLine->Display = 'None';
+               $this->JobToVerifyJobNameLine->Display = 'None';
+               $this->JobToVerifyJobIdLine->Display = 'None';
+               $this->AccurateLine->Display = 'Dynamic';
+               $this->EstimateLine->Display = 'Dynamic';
+
+               $verifyValues = array();
+
+               foreach($this->verifyOptions as $value => $text) {
+                       $verifyValues[$value] = Prado::localize($text);
+               }
+
+               $this->JobToVerifyOptions->dataSource = $verifyValues;
+               $this->JobToVerifyOptions->dataBind();
+
+               $jobTasks = $this->Application->getModule('api')->get(array('jobs', 'tasks'))->output;
+
+               $jobsAllDirs = array();
+               foreach($jobTasks as $director => $tasks) {
+                       $jobsAllDirs = array_merge($jobsAllDirs, $tasks);
+               }
+
+               $this->JobToVerifyJobName->dataSource = array_combine($jobsAllDirs, $jobsAllDirs);
+               $this->JobToVerifyJobName->dataBind();
+
                $clients = $this->Application->getModule('api')->get(array('clients'))->output;
                $clientsList = array();
                foreach($clients as $client) {
@@ -77,6 +107,16 @@ class JobRunConfiguration extends Portlets {
                $params['storageid'] = $this->Storage->SelectedValue;
                $params['poolid'] = $this->Pool->SelectedValue;
                $params['priority'] = $this->Priority->Text;
+
+               if (in_array($this->Level->SelectedItem->Value, $this->jobToVerify)) {
+                       $verifyVals = $this->getVerifyVals();
+                       if ($this->JobToVerifyOptions->SelectedItem->Value == $verifyVals['jobname']) {
+                               $params['verifyjob'] = $this->JobToVerifyJobName->SelectedValue;
+                       } elseif ($this->JobToVerifyOptions->SelectedItem->Value == $verifyVals['jobid']) {
+                               $params['jobid'] = $this->JobToVerifyJobId->Text;
+                       }
+               }
+
                $result = $this->Application->getModule('api')->create(array('jobs', 'run'), $params)->output;
                $this->Estimation->Text = implode(PHP_EOL, $result);
        }
@@ -96,5 +136,22 @@ class JobRunConfiguration extends Portlets {
                $isValid = preg_match('/^[0-9]+$/', $this->Priority->Text) === 1 && $this->Priority->Text > 0;
                $param->setIsValid($isValid);
        }
+
+       public function jobIdToVerifyValidator($sender, $param) {
+               $verifyVals = $this->getVerifyVals();
+               if(in_array($this->Level->SelectedValue, $this->jobToVerify) && $this->JobToVerifyOptions->SelectedItem->Value == $verifyVals['jobid']) {
+                       $isValid = preg_match('/^[0-9]+$/',$this->JobToVerifyJobId->Text) === 1 && $this->JobToVerifyJobId->Text > 0;
+               } else {
+                       $isValid = true;
+               }
+               $param->setIsValid($isValid);
+               return $isValid;
+       }
+
+       private function getVerifyVals() {
+               $verifyOpt = array_keys($this->verifyOptions);
+               $verifyVals = array_combine($verifyOpt, $verifyOpt);
+               return $verifyVals;
+       }
 }
 ?>
index d83f29a540f79a0a2f2c8d57c0e9a2b3c0dbe18e..e0500c994da1ec0a17393b3e055dcaff2a0d90d3 100644 (file)
                <div class="line">
                        <div class="text"><com:TLabel ForControl="Level" Text="<%[ Level: ]%>" /></div>
                        <div class="field">
-                               <com:TActiveDropDownList ID="Level" AutoPostBack="false" CssClass="textbox-auto" />
+                               <com:TActiveDropDownList ID="Level" AutoPostBack="false" CssClass="textbox-auto">
+                                       <prop:Attributes.onchange>
+                                               var job_to_verify = $('<%=$this->JobToVerifyOptionsLine->ClientID%>');
+                                               var verify_options = $('<%=$this->JobToVerifyOptionsLine->ClientID%>');
+                                               var verify_by_job_name = $('<%=$this->JobToVerifyJobNameLine->ClientID%>');
+                                               var verify_by_jobid = $('<%=$this->JobToVerifyJobIdLine->ClientID%>');
+                                               var accurate = $('<%=$this->AccurateLine->ClientID%>');
+                                               var estimate = $('<%=$this->EstimateLine->ClientID%>');
+                                               var verify_current_opt = $('<%=$this->JobToVerifyOptions->ClientID%>').value;
+                                               if(/^(<%=implode('|', $this->jobToVerify)%>)$/.test(this.value)) {
+                                                       accurate.hide();
+                                                       estimate.hide();
+                                                       verify_options.show();
+                                                       job_to_verify.show();
+                                                       if (verify_current_opt == 'jobid') {
+                                                               verify_by_job_name.hide();
+                                                               verify_by_jobid.show();
+                                                       } else if (verify_current_opt == 'jobname') {
+                                                               verify_by_job_name.show();
+                                                               verify_by_jobid.hide();
+                                                       }
+                                               } else if (job_to_verify.visible()) {
+                                                       job_to_verify.hide();
+                                                       verify_options.hide();
+                                                       verify_by_job_name.hide();
+                                                       verify_by_jobid.hide();
+                                                       accurate.show();
+                                                       estimate.show();
+                                               }
+                                       </prop:Attributes.onchange>
+                               </com:TActiveDropDownList>
                        </div>
                </div>
+               <com:TActivePanel ID="JobToVerifyOptionsLine" CssClass="line">
+                       <div class="text"><com:TLabel ForControl="JobToVerifyOptions" Text="<%[ Verify option: ]%>" /></div>
+                       <div class="field">
+                               <com:TActiveDropDownList ID="JobToVerifyOptions" AutoPostBack="false" CssClass="textbox-auto">
+                                       <prop:Attributes.onchange>
+                                               var verify_by_job_name = $('<%=$this->JobToVerifyJobNameLine->ClientID%>');
+                                               var verify_by_jobid = $('<%=$this->JobToVerifyJobIdLine->ClientID%>');
+                                               if (this.value == 'jobname') {
+                                                       verify_by_jobid.hide();
+                                                       verify_by_job_name.show();
+                                               } else if (this.value == 'jobid') {
+                                                       verify_by_job_name.hide();
+                                                       verify_by_jobid.show();
+                                               } else {
+                                                       verify_by_job_name.hide();
+                                                       verify_by_jobid.hide();
+                                               }
+                                       </prop:Attributes.onchange>
+                               </com:TActiveDropDownList>
+                       </div>
+               </com:TActivePanel>
+               <com:TActivePanel ID="JobToVerifyJobNameLine" CssClass="line">
+                       <div class="text"><com:TLabel ForControl="JobToVerifyJobName" Text="<%[ Job to Verify: ]%>" /></div>
+                       <div class="field">
+                               <com:TActiveDropDownList ID="JobToVerifyJobName" AutoPostBack="false" CssClass="textbox-auto" />
+                       </div>
+               </com:TActivePanel>
+               <com:TActivePanel ID="JobToVerifyJobIdLine" CssClass="line">
+                       <div class="text"><com:TLabel ForControl="JobToVerifyJobId" Text="<%[ JobId to Verify: ]%>" /></div>
+                       <div class="field">
+                               <com:TActiveTextBox ID="JobToVerifyJobId" CssClass="textbox-auto" AutoPostBack="false" />
+                               <com:TActiveCustomValidator ID="JobToVerifyJobIdValidator" ValidationGroup="JobRunGroup" ControlToValidate="JobToVerifyJobId" ErrorMessage="<%[ JobId to Verify value must be integer greather than 0. ]%>" ControlCssClass="validation-error" Display="None" OnServerValidate="jobIdToVerifyValidator" />
+                       </div>
+               </com:TActivePanel>
                <div class="line">
                        <div class="text"><com:TLabel ForControl="Client" Text="<%[ Client: ]%>" /></div>
                        <div class="field">
                <div class="field-full" style="min-height: 90px">
                        <com:TActiveTextBox ID="Estimation" TextMode="MultiLine" CssClass="textbox-auto" Style="height: 116px; font-size: 11px;" ReadOnly="true" />
                </div>
-               <div class="line">
+               <com:TPanel ID="AccurateLine" CssClass="line">
                        <div class="text"><com:TLabel ForControl="Accurate" Text="<%[ Accurate: ]%>" /></div>
                        <div class="field"><com:TActiveCheckBox ID="Accurate" AutoPostBack="false" /></div>
-               </div>
-               <div class="button">
+               </com:TPanel>
+               <com:TPanel ID="EstimateLine" CssClass="button">
                        <com:Application.Portlets.BActiveButton ID="Estimate" Text="<%[ Estimate job ]%>" OnClick="estimate"  ClientSide.OnSuccess="ConfigurationWindow.getObj('JobRunWindow').progress(false);jobrun_callback_func();" />
-               </div>
+               </com:TPanel>
        </com:TActivePanel>
 </com:TContent>
index ee37ff74256ae7d102245712432fea47b08ae82b..181a3b73893d10c91a207ee8d024f86aeff50059 100644 (file)
@@ -424,7 +424,7 @@ tr.slide-window-element:hover td, tr.slide-window-element-alternating:hover td{
 table.window-section-detail, table.file-browser-detail {
        background-color: rgba(0,0,0,0.5);
        width: 100%;
-       font-size: 11px;
+       font-size: 10px;
        font-weight: normal;
 }
 
@@ -675,7 +675,7 @@ div.job-status-W {
 }
 
 div.job-status-D {
-       background-color: blue;
+       background-color: #CB4A2C;
 }
 
 /*