3 * Bacula® - 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 main author of Bacula is Kern Sibbald, with contributions from many
10 * 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 * Bacula® is a registered trademark of Kern Sibbald.
20 Prado::using('System.Web.UI.ActiveControls.TActiveDataGrid');
21 Prado::using('System.Web.UI.ActiveControls.TActiveRepeater');
22 Prado::using('System.Web.UI.ActiveControls.TActiveLinkButton');
23 Prado::using('System.Web.UI.ActiveControls.TActivePanel');
24 Prado::using('System.Web.UI.ActiveControls.TCallback');
25 Prado::using('Application.Portlets.ISlideWindow');
26 Prado::using('Application.Portlets.Portlets');
28 class JobRunList extends Portlets implements ISlideWindow {
35 private $jobTypes = array(
47 public function setID($id) {
51 public function getID($hideAutoID = true) {
55 public function setButtonID($id) {
56 $this->buttonID = $id;
59 public function getButtonID() {
60 return $this->buttonID;
63 public function setWindowTitle($param) {
64 $this->windowTitle = $param;
67 public function getWindowTitle() {
68 return $this->windowTitle;
71 public function onLoad($param) {
72 parent::onLoad($param);
76 public function prepareData($forceReload = false) {
77 $allowedButtons = array('JobRunBtn');
78 if($this->Page->IsPostBack || $this->Page->IsCallBack || $forceReload) {
79 if(in_array($this->getPage()->CallBackEventTarget->ID, $allowedButtons) || $forceReload) {
80 $params = $this->getUrlParams(array('jobs', 'tasks'), $this->getPage()->JobRunWindow->ID);
81 $jobTasks = $this->Application->getModule('api')->get($params)->output;
82 $jobs = $this->prepareJobs($jobTasks);
83 $isDetailView = $_SESSION['view' . $this->getPage()->JobRunWindow->ID] == 'details';
85 if($isDetailView === true) {
86 $this->RepeaterShow->Visible = false;
87 $this->DataGridShow->Visible = true;
88 $this->DataGrid->DataSource = $jobs;
89 $this->DataGrid->dataBind();
91 $this->RepeaterShow->Visible = true;
92 $this->DataGridShow->Visible = false;
93 $this->Repeater->DataSource = $jobs;
94 $this->Repeater->dataBind();
100 private function prepareJobs($jobTasks) {
102 foreach($jobTasks as $director => $tasks) {
103 for($i = 0; $i < count($tasks); $i++) {
104 $jobs[] = array('name' => $tasks[$i], 'director' => $director);
110 public function sortDataGrid($sender, $param) {
111 $params = $this->getUrlParams(array('jobs', 'tasks'), $this->getPage()->JobRunWindow->ID);
112 $data = $this->Application->getModule('api')->get($params)->output;
113 $data = $this->prepareJobs($data);
114 $this->DataGrid->DataSource = $this->sortData($data, $param->SortExpression, $sender->UniqueID);
115 $this->DataGrid->dataBind();
118 public function configure($sender, $param) {
119 if($this->Page->IsCallBack) {
120 $this->getPage()->JobRunConfiguration->configure($param->CallbackParameter);