Skip to content

Commit

Permalink
Merge pull request #1082
Browse files Browse the repository at this point in the history
webui: analytics module: show stored data per jobname in treemap
  • Loading branch information
pstorz committed Mar 11, 2022
2 parents 00d9264 + 576334c commit eda7cdd
Show file tree
Hide file tree
Showing 14 changed files with 20,937 additions and 85 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ and since Bareos version 20 this project adheres to [Semantic Versioning](https:
- docs: Add chapter for mariabackup db plugin [PR #1016]
- dird: extend the list command to be able to query volumes and pools by ID [PR #1041]
- systemtests: wait for mariadb shutdown [PR #1048]
- webui: analytics module: show stored data per jobname in treemap [PR #1082]

### Changed
- webui: remove an unnecessary .bvfs_get_jobids and buildSubtree() call [PR #1050]
Expand Down
6 changes: 6 additions & 0 deletions docs/manuals/source/IntroductionAndTutorial/BareosWebui.rst
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@ the module will not work.
:exclude: {11: '-'}
:file: ../../../../webui/module/Application/config/commands.csv

.. csv-filter:: Analytics Module
:header-rows: 1
:included_cols: 0,12
:exclude: {12: '-'}
:file: ../../../../webui/module/Application/config/commands.csv

A complete overview of bconsole command usage in the |webui| can be found in
the Developer Guide chapter ":ref:`section-dev-webui-command-usage-in-modules`".

Expand Down
3 changes: 2 additions & 1 deletion webui/config/application.config.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* bareos-webui - Bareos Web-Frontend
*
* @link https://github.com/bareos/bareos for the canonical source repository
* @copyright Copyright (C) 2013-2019 Bareos GmbH & Co. KG (http://www.bareos.org/)
* @copyright Copyright (C) 2013-2022 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
Expand Down Expand Up @@ -39,6 +39,7 @@
'Restore',
'Auth',
'Console',
'Analytics'
);

// Use the $env value to determine which module to load
Expand Down
65 changes: 65 additions & 0 deletions webui/module/Analytics/Module.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?php

/**
*
* bareos-webui - Bareos Web-Frontend
*
* @link https://github.com/bareos/bareos for the canonical source repository
* @copyright Copyright (c) 2013-2022 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 Analytics;

use Analytics\Model\Analytics;
use Analytics\Model\AnalyticsModel;

class Module
{

public function getAutoloaderConfig()
{
return array(
'Zend\Loader\ClassMapAutoloader' => array(
__DIR__ . '/autoload_classmap.php',
),
'Zend\Loader\StandardAutoloader' => array(
'namespaces' => array(
__NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__,
),
),
);
}

public function getConfig()
{
return include __DIR__ . '/config/module.config.php';
}

public function getServiceConfig()
{
return array(
'factories' => array(
'Analytics\Model\AnalyticsModel' => function() {
$model = new AnalyticsModel();
return $model;
}
)
);
}

}
26 changes: 26 additions & 0 deletions webui/module/Analytics/autoload_classmap.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

/**
*
* bareos-webui - Bareos Web-Frontend
*
* @link https://github.com/bareos/bareos for the canonical source repository
* @copyright Copyright (c) 2013-2022 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/>.
*
*/

return array();
62 changes: 62 additions & 0 deletions webui/module/Analytics/config/module.config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?php

/**
*
* bareos-webui - Bareos Web-Frontend
*
* @link https://github.com/bareos/bareos for the canonical source repository
* @copyright Copyright (C) 2013-2022 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/>.
*
*/

return array(

'controllers' => array(
'invokables' => array(
'Analytics\Controller\Analytics' => 'Analytics\Controller\AnalyticsController',
),
),
'controller_plugins' => array(
'invokables' => array(
'SessionTimeoutPlugin' => 'Application\Controller\Plugin\SessionTimeoutPlugin',
),
),
'router' => array(
'routes' => array(
'analytics' => array(
'type' => 'segment',
'options' => array(
'route' => '/analytics[/][:action][/][:id]',
'constraints' => array(
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
'id' => '[a-zA-Z0-9][a-zA-Z0-9\._-]*',
),
'defaults' => array(
'controller' => 'Analytics\Controller\Analytics',
'action' => 'index',
),
),
),
),
),
'view_manager' => array(
'template_path_stack' => array(
'analytics' => __DIR__ . '/../view',
),
),

);
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
<?php

/**
*
* bareos-webui - Bareos Web-Frontend
*
* @link https://github.com/bareos/bareos for the canonical source repository
* @copyright Copyright (c) 2013-2022 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 Analytics\Controller;

use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;
use Zend\Json\Json;

class AnalyticsController extends AbstractActionController
{

protected $analyticsModel = null;

public function indexAction()
{
$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']
)
)
);
}

$module_config = $this->getServiceLocator()->get('ModuleManager')->getModule('Application')->getConfig();
$invalid_commands = $this->CommandACLPlugin()->getInvalidCommands(
$module_config['console_commands']['Analytics']['mandatory']
);

if(count($invalid_commands) > 0) {
$this->acl_alert = true;
return new ViewModel(
array(
'acl_alert' => $this->acl_alert,
'invalid_commands' => implode(",", $invalid_commands)
)
);
}

return new ViewModel();
}

public function getDataAction()
{
$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']
)
)
);
}

$result = null;

$data = $this->params()->fromQuery('data');

if($data == "jobtotals") {
try {
$this->bsock = $this->getServiceLocator()->get('director');
$result = $this->getAnalyticsModel()->getJobTotals($this->bsock);
$this->bsock->disconnect();
}
catch(Exception $e) {
echo $e->getMessage();
}
}
elseif($data == "overall-jobtotals") {
try {
$this->bsock = $this->getServiceLocator()->get('director');
$result = $this->getAnalyticsModel()->getOverallJobTotals($this->bsock);
$this->bsock->disconnect();
}
catch(Exception $e) {
echo $e->getMessage();
}
}

$response = $this->getResponse();
$response->getHeaders()->addHeaderLine('Content-Type', 'application/json');

if(isset($result)) {
$response->setContent(JSON::encode($result));
}

return $response;

}

public function getAnalyticsModel()
{
if(!$this->analyticsModel) {
$sm = $this->getServiceLocator();
$this->analyticsModel = $sm->get('Analytics\Model\AnalyticsModel');
}
return $this->analyticsModel;
}

}
30 changes: 30 additions & 0 deletions webui/module/Analytics/src/Analytics/Model/Analytics.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

/**
*
* bareos-webui - Bareos Web-Frontend
*
* @link https://github.com/bareos/bareos for the canonical source repository
* @copyright Copyright (c) 2013-2022 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 Analytics\Model;

class Analytics
{
}

0 comments on commit eda7cdd

Please sign in to comment.