Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
webui: add jobotals controller to api module
- Loading branch information
1 parent
d49991d
commit 00efe0c
Showing
1 changed file
with
77 additions
and
0 deletions.
There are no files selected for viewing
77 changes: 77 additions & 0 deletions
77
webui/module/Api/src/Api/Controller/JobTotalsController.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
<?php | ||
|
||
/** | ||
* | ||
* bareos-webui - Bareos Web-Frontend | ||
* | ||
* @link https://github.com/bareos/bareos for the canonical source repository | ||
* @copyright Copyright (c) 2013-2023 Bareos GmbH & Co. KG (http://www.bareos.org/) | ||
* @license GNU Affero General Public License (http://www.gnu.org/licenses/) | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
* | ||
*/ | ||
|
||
namespace Api\Controller; | ||
|
||
use Zend\Mvc\Controller\AbstractRestfulController; | ||
use Zend\View\Model\JsonModel; | ||
use Exception; | ||
|
||
class JobTotalsController extends AbstractRestfulController | ||
{ | ||
protected $bsock = null; | ||
protected $jobModel = null; | ||
protected $result = null; | ||
|
||
public function getList() | ||
{ | ||
$this->RequestURIPlugin()->setRequestURI(); | ||
|
||
if (!$this->SessionTimeoutPlugin()->isValid()) { | ||
return $this->redirect()->toRoute( | ||
'auth', | ||
array( | ||
'action' => 'login' | ||
), | ||
array( | ||
'query' => array( | ||
'req' => $this->RequestURIPlugin()->getRequestURI(), | ||
'dird' => $_SESSION['bareos']['director'] | ||
) | ||
) | ||
); | ||
} | ||
|
||
$this->bsock = $this->getServiceLocator()->get('director'); | ||
|
||
try{ | ||
$this->result = $this->getJobModel()->getJobTotals($this->bsock); | ||
} catch(Exception $e) { | ||
$this->getResponse()->setStatusCode(500); | ||
error_log($e); | ||
} | ||
|
||
return new JsonModel($this->result); | ||
} | ||
|
||
public function getJobModel() | ||
{ | ||
if (!$this->jobModel) { | ||
$sm = $this->getServiceLocator(); | ||
$this->jobModel = $sm->get('Job\Model\JobModel'); | ||
} | ||
return $this->jobModel; | ||
} | ||
} |