3 * Bacula(R) - The Network Backup Solution
4 * Baculum - Bacula web interface
6 * Copyright (C) 2013-2017 Kern Sibbald
8 * The main author of Baculum is Marcin Haba.
9 * The original author of Bacula is Kern Sibbald, with contributions
10 * from many others, a complete list can be found in the file AUTHORS.
12 * You may use this file and others of this release according to the
13 * license defined in the LICENSE file, which includes the Affero General
14 * Public License, v3.0 ("AGPLv3") and some additional permissions and
15 * terms pursuant to its AGPLv3 Section 7.
17 * This notice must be preserved when any source code is
18 * conveyed and/or propagated.
20 * Bacula(R) is a registered trademark of Kern Sibbald.
23 Prado::using('System.Web.UI.ActiveControls.TActiveDataGrid');
24 Prado::using('System.Web.UI.ActiveControls.TActiveRepeater');
25 Prado::using('System.Web.UI.ActiveControls.TActivePanel');
26 Prado::using('System.Web.UI.ActiveControls.TCallback');
27 Prado::using('Application.Web.Portlets.ISlideWindow');
28 Prado::using('Application.Web.Portlets.Portlets');
30 class JobList extends Portlets implements ISlideWindow {
37 public $runningJobStates;
40 public function setID($id) {
44 public function getID($hideAutoID = true) {
48 public function setButtonID($id) {
49 $this->buttonID = $id;
52 public function getButtonID() {
53 return $this->buttonID;
56 public function setWindowTitle($param) {
57 $this->windowTitle = $param;
60 public function getWindowTitle() {
61 return $this->windowTitle;
64 public function onLoad($param) {
65 parent::onLoad($param);
66 $misc = $this->Application->getModule('misc');
67 $this->jobLevels = $misc->getJobLevels();
68 $this->jobStates = $misc->getJobState();
69 $this->jobTypes = $misc->job_types;
70 $this->runningJobStates = $misc->getRunningJobStates();
73 public function prepareData($sender, $param) {
74 $params = $this->getUrlParams('jobs', $this->getPage()->JobWindow->ID);
75 $jobs = $this->Application->getModule('api')->get($params);
76 $isDetailView = $_SESSION['view' . $this->getPage()->JobWindow->ID] == 'details';
77 if($isDetailView === true) {
78 $this->RepeaterShow->Visible = false;
79 $this->DataGridShow->Visible = true;
80 $this->DataGrid->DataSource = $this->Application->getModule('misc')->objectToArray($jobs->output);
81 $this->DataGrid->dataBind();
83 $this->RepeaterShow->Visible = true;
84 $this->DataGridShow->Visible = false;
85 $this->Repeater->DataSource = $jobs->output;
86 $this->Repeater->dataBind();
90 public function sortDataGrid($sender, $param) {
91 $params = $this->getUrlParams('jobs', $this->getPage()->JobWindow->ID);
92 $data = $this->Application->getModule('api')->get($params)->output;
93 $data = $this->Application->getModule('misc')->objectToArray($data);
94 $this->DataGrid->DataSource = $this->sortData($data, $param->SortExpression, $sender->UniqueID);
95 $this->DataGrid->dataBind();
98 public function configure($sender, $param) {
99 if($this->Page->IsCallBack) {
100 $this->getPage()->JobConfiguration->configure($param->CallbackParameter);
104 public function run_again($sender, $param) {
105 if($this->Page->IsCallBack) {
106 $this->getPage()->JobConfiguration->run_again(null, $param->CallbackParameter);
110 public function executeAction($action) {
111 $params = explode(';', $this->CheckedValues->Value);
115 for($i = 0; $i < count($params); $i++) {
116 $cmd = array('delete');
117 $cmd[] = 'jobid="' . $params[$i] . '"';
120 $commands[] = implode(' ', $cmd);
122 $this->getPage()->Console->CommandLine->Text = implode(' ', $commands);
123 $this->getPage()->Console->sendCommand(null, null);
127 $this->CheckedValues->Value = "";
130 public function formatJobName($name) {
131 if (strlen($name) > 24) {
132 $name = substr($name, 0, 10) . '...' . substr($name, -11);
137 public function getJobStatusLetter($job) {
139 if (array_key_exists('jobstatus', $job)) {
140 $errors = intval($job['joberrors']);
141 if ($job['jobstatus'] === 'T' && $errors > 0) {
142 $job['jobstatus'] = 'W';
144 $statusLetter = $job['jobstatus'];
146 return $statusLetter;
149 public function getJobStatusValue($job) {
151 $jobLetter = $this->getJobStatusLetter($job);
152 if (array_key_exists($jobLetter, $this->jobStates)) {
153 $statusValue = $this->jobStates[$jobLetter]['value'];
158 public function getJobStatusDescription($job) {
159 $statusDescription = '';
160 $jobLetter = $this->getJobStatusLetter($job);
161 if (array_key_exists($jobLetter, $this->jobStates)) {
162 $statusDescription = $this->jobStates[$jobLetter]['description'];
164 return $statusDescription;