3 * Bacula(R) - The Network Backup Solution
4 * Baculum - Bacula web interface
6 * Copyright (C) 2013-2015 Marcin Haba
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.Portlets.ISlideWindow');
28 Prado::using('Application.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 $allowedButtons = array('JobBtn', 'ReloadJobs', 'Run', 'RunJobAgain');
67 if($this->Page->IsPostBack || $this->Page->IsCallBack) {
68 if(in_array($this->getPage()->CallBackEventTarget->ID, $allowedButtons)) {
72 $misc = $this->Application->getModule('misc');
73 $this->jobLevels = $misc->getJobLevels();
74 $this->jobStates = $misc->getJobState();
75 $this->jobTypes = $misc->getJobType();
76 $this->runningJobStates = $misc->getRunningJobStates();
79 public function prepareData($forceReload = false) {
80 $allowedButtons = array('JobBtn', 'ReloadJobs', 'Run', 'RunJobAgain');
81 if($this->Page->IsPostBack || $this->Page->IsCallBack || $forceReload) {
82 if(in_array($this->getPage()->CallBackEventTarget->ID, $allowedButtons) || $forceReload) {
83 $params = $this->getUrlParams('jobs', $this->getPage()->JobWindow->ID);
84 $jobs = $this->Application->getModule('api')->get($params);
85 $isDetailView = $_SESSION['view' . $this->getPage()->JobWindow->ID] == 'details';
86 if($isDetailView === true) {
87 $this->RepeaterShow->Visible = false;
88 $this->DataGridShow->Visible = true;
89 $this->DataGrid->DataSource = $this->Application->getModule('misc')->objectToArray($jobs->output);
90 $this->DataGrid->dataBind();
92 $this->RepeaterShow->Visible = true;
93 $this->DataGridShow->Visible = false;
94 $this->Repeater->DataSource = $jobs->output;
95 $this->Repeater->dataBind();
101 public function sortDataGrid($sender, $param) {
102 $params = $this->getUrlParams('jobs', $this->getPage()->JobWindow->ID);
103 $data = $this->Application->getModule('api')->get($params)->output;
104 $data = $this->Application->getModule('misc')->objectToArray($data);
105 $this->DataGrid->DataSource = $this->sortData($data, $param->SortExpression, $sender->UniqueID);
106 $this->DataGrid->dataBind();
109 public function configure($sender, $param) {
110 if($this->Page->IsCallBack) {
111 $this->getPage()->JobConfiguration->configure($param->CallbackParameter);
115 public function run_again($sender, $param) {
116 if($this->Page->IsCallBack) {
117 $this->getPage()->JobConfiguration->run_again(null, $param->CallbackParameter);
121 public function executeAction($action) {
122 $params = explode(';', $this->CheckedValues->Value);
126 for($i = 0; $i < count($params); $i++) {
127 $cmd = array('delete');
128 $cmd[] = 'jobid="' . $params[$i] . '"';
131 $commands[] = implode(' ', $cmd);
133 $this->getPage()->Console->CommandLine->Text = implode(' ', $commands);
134 $this->getPage()->Console->sendCommand(null, null);
138 $this->CheckedValues->Value = "";