3 * Bacula® - The Network Backup Solution
4 * Baculum - Bacula web interface
6 * Copyright (C) 2013-2014 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.Portlets');
27 class JobRunList extends Portlets {
29 public $ShowID, $windowTitle, $oldDirector;
31 private $jobTypes = array('B' => 'Backup', 'M' => 'Migrated', 'V' => 'Verify', 'R' => 'Restore', 'I' => 'Internal', 'D' => 'Admin', 'A' => 'Archive', 'C' => 'Copy', 'g' => 'Migration');
35 public function onLoad($param) {
36 parent::onLoad($param);
40 public function setWindowTitle($param) {
41 $this->windowTitle = $param;
44 public function prepareData($forceReload = false) {
45 $allowedButtons = array('JobRunBtn');
46 if($this->Page->IsPostBack || $this->Page->IsCallBack || $forceReload) {
47 if(in_array($this->getPage()->CallBackEventTarget->ID, $allowedButtons) || $forceReload) {
48 $params = $this->getUrlParams(array('jobs', 'tasks'), $this->getPage()->JobRunWindow->ID);
49 $jobTasks = $this->Application->getModule('api')->get($params)->output;
50 $jobs = $this->prepareJobs($jobTasks);
51 $isDetailView = $_SESSION['view' . $this->getPage()->JobRunWindow->ID] == 'details';
52 $this->RepeaterShow->Visible = !$isDetailView;
53 $this->Repeater->DataSource = $isDetailView === false ? $jobs : array();
54 $this->Repeater->dataBind();
55 $this->DataGridShow->Visible = $isDetailView;
56 $this->DataGrid->DataSource = $isDetailView === true ? $jobs : array();
57 $this->DataGrid->dataBind();
62 private function prepareJobs($jobTasks) {
64 foreach($jobTasks as $director => $tasks) {
65 for($i = 0; $i < count($tasks); $i++) {
66 $jobs[] = array('name' => $tasks[$i], 'director' => $director);
72 public function sortDataGrid($sender, $param) {
73 $params = $this->getUrlParams(array('jobs', 'tasks'), $this->getPage()->JobRunWindow->ID);
74 $data = $this->Application->getModule('api')->get($params)->output;
75 $data = $this->prepareJobs($data);
76 $this->DataGrid->DataSource = $this->sortData($data, $param->SortExpression, $sender->UniqueID);
77 $this->DataGrid->dataBind();
80 public function setShowID($ShowID) {
81 $this->ShowID = $this->getMaster()->ShowID = $ShowID;
84 public function getShowID() {
88 public function configure($sender, $param) {
89 if($this->Page->IsCallBack) {
90 $this->getPage()->JobRunConfiguration->configure($param->CallbackParameter);