]> git.sur5r.net Git - bacula/bacula/blob - gui/baculum/protected/Portlets/ClientList.php
5d3d5dadda0248747de2e2d76800a17662eb1782
[bacula/bacula] / gui / baculum / protected / Portlets / ClientList.php
1 <?php\r
2 /**\r
3  * Bacula® - The Network Backup Solution\r
4  * Baculum - Bacula web interface\r
5  *\r
6  * Copyright (C) 2013-2014 Marcin Haba\r
7  *\r
8  * The main author of Baculum is Marcin Haba.\r
9  * The main author of Bacula is Kern Sibbald, with contributions from many\r
10  * others, a complete list can be found in the file AUTHORS.\r
11  *\r
12  * You may use this file and others of this release according to the\r
13  * license defined in the LICENSE file, which includes the Affero General\r
14  * Public License, v3.0 ("AGPLv3") and some additional permissions and\r
15  * terms pursuant to its AGPLv3 Section 7.\r
16  *\r
17  * Bacula® is a registered trademark of Kern Sibbald.\r
18  */\r
19  \r
20 Prado::using('System.Web.UI.ActiveControls.TActiveRepeater');\r
21 Prado::using('System.Web.UI.ActiveControls.TActiveDataGrid');\r
22 Prado::using('Application.Portlets.Portlets');\r
23 \r
24 class ClientList extends Portlets {
25 \r
26         public $ShowID, $windowTitle;\r
27 \r
28         public function onLoad($param) {
29                 parent::onLoad($param);\r
30                 $this->prepareData();\r
31         }\r
32 \r
33         public function setWindowTitle($param) {\r
34                 $this->windowTitle = $param;\r
35         }\r
36 \r
37         public function prepareData($forceReload = false) {\r
38                 $allowedButtons = array('ClientBtn', 'ReloadClients');
39                 if($this->Page->IsPostBack || $this->Page->IsCallBack || $forceReload) {\r
40                         if(in_array($this->getPage()->CallBackEventTarget->ID, $allowedButtons) || $forceReload) {\r
41                                 $params = $this->getUrlParams('clients', $this->getPage()->ClientWindow->ID);\r
42                                 $clients = $this->Application->getModule('api')->get($params);\r
43                                 $isDetailView = $this->Session['view' . $this->getPage()->ClientWindow->ID] == 'details';\r
44                                 $clientsList = $this->Application->getModule('misc')->objectToArray($clients->output);\r
45                                 $this->RepeaterShow->Visible = !$isDetailView;\r
46                                 $this->Repeater->DataSource = $isDetailView === false ? $clientsList : array();\r
47                                 $this->Repeater->dataBind();\r
48                                 $this->DataGridShow->Visible = $isDetailView;\r
49                                 $this->DataGrid->DataSource = $isDetailView === true ?  $clientsList : array();\r
50                                 $this->DataGrid->dataBind();\r
51                         }\r
52                 }
53         }\r
54 \r
55         public function sortDataGrid($sender, $param) {\r
56                 $params = $this->getUrlParams('clients', $this->getPage()->ClientWindow->ID);\r
57                 $data = $this->Application->getModule('api')->get($params)->output;\r
58                 $data = $this->Application->getModule('misc')->objectToArray($data);\r
59                 $this->DataGrid->DataSource = $this->sortData($data, $param->SortExpression, $sender->UniqueID);\r
60                 $this->DataGrid->dataBind();\r
61         }\r
62 \r
63 \r
64         public function setShowID($ShowID) {\r
65                 $this->ShowID = $this->getMaster()->ShowID = $ShowID;\r
66         }\r
67 \r
68         public function getShowID() {\r
69                 return $this->ShowID;\r
70         }\r
71 \r
72         public function configure($sender, $param) {\r
73                 if($this->Page->IsCallBack) {\r
74                         $this->getPage()->ClientConfiguration->configure($param->CallbackParameter);\r
75                 }\r
76         }\r
77 }\r
78 ?>