Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
dfranco committed Mar 2, 2018
2 parents f5f76e4 + 78ed99e commit cd38775
Show file tree
Hide file tree
Showing 86 changed files with 2,492 additions and 1,721 deletions.
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/vendor
/application/view/cache/*.tpl
/application/view/cache/*.php
/application/views/cache/*.tpl
/application/views/cache/*.php
/application/config/config.php
/application/assets/protected/application.db
docs/_build
.htpasswd
5 changes: 0 additions & 5 deletions .htaccess

This file was deleted.

4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[![Documentation Status](https://readthedocs.org/projects/bacula-web/badge/?version=master)](http://docs.bacula-web.org/en/master/?badge=master)
[![Code Climate](https://codeclimate.com/github/bacula-web/bacula-web/badges/gpa.svg)](https://codeclimate.com/github/bacula-web/bacula-web)
[![Documentation Status](https://readthedocs.org/projects/bacula-web/badge/?version=latest)](http://docs.bacula-web.org/en/master/?badge=latest)
[![Maintainability](https://api.codeclimate.com/v1/badges/db37b493624cee584d85/maintainability)](https://codeclimate.com/github/bacula-web/bacula-web/maintainability)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/bacula-web/bacula-web/badges/quality-score.png?b=develop)](https://scrutinizer-ci.com/g/bacula-web/bacula-web/?branch=develop)

## About
Expand Down
2 changes: 2 additions & 0 deletions application/assets/css/default.css
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,5 @@ img {
}

.page-header { margin-top: 15px; }

.form-signin { margin-top: 100px; }
Binary file added application/assets/images/bacula-web-logo.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions application/assets/protected/.htaccess
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Options -Indexes -MultiViews
<Files "application.db">
Order Allow,Deny
Deny from all
</Files>
16 changes: 16 additions & 0 deletions application/config/application.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

$app = [ 'name' => 'Bacula-Web', 'version' => '8.0.0-rc1',
'routes' => [ 'home' => 'Dashboard',
'test' => 'Test',
'jobs' => 'Jobs',
'joblogs' => 'JobLogs',
'volumes' => 'Volumes',
'pools' => 'Pools',
'client' => 'Client',
'backupjob' => 'BackupJob',
'login' => 'Login',
'usersettings' => 'UserSettings',
'settings' => 'Settings',
'directors' => 'Directors'],
'defaultview' => 'DashboardView' ];
13 changes: 7 additions & 6 deletions application/libs/fileconfig.class.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/*
+-------------------------------------------------------------------------+
| Copyright 2010-2017, Davide Franco |
| Copyright 2010-2018, Davide Franco |
| |
| This program is free software; you can redistribute it and/or |
| modify it under the terms of the GNU General Public License |
Expand Down Expand Up @@ -64,27 +64,28 @@ public static function count_Catalogs()
// Function: get_Value()
// Parameters: configuration parameter or false (if not defined)
// $catalog_id (optional)
// Return: parameter value
// Return: parameter value or NULL if does not exist
// ==================================================================================

public static function get_Value($parameter, $catalog_id = null)
{
// Check if the $global_config have been already set first
if (!isset(self::$config_file)) {
throw new Exception("The configuration is missing or ther's something wrong in it");
throw new Exception("The configuration is missing or there's something wrong in it");
}


// If $catalog_id is not null, get value from this catalog
if (!is_null($catalog_id)) {
if (is_array(parent::$config[$catalog_id])) {
return parent::$config[$catalog_id][$parameter];
} else {
throw new Exception("Configuration error: the catalog id <$catalog_id> do not exist");
throw new Exception("Configuration error: catalog id <$catalog_id> is empty or does not exist");
}
} else {
if (isset(parent::$config[$parameter])) {
return parent::$config[$parameter];
} else {
return false;
return NULL;
}
}
} // end function
Expand Down
4 changes: 2 additions & 2 deletions application/models/clients.model.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/*
+-------------------------------------------------------------------------+
| Copyright 2010-2017, Davide Franco |
| Copyright 2010-2018, Davide Franco |
| |
| This program is free software; you can redistribute it and/or |
| modify it under the terms of the GNU General Public License |
Expand Down Expand Up @@ -44,7 +44,7 @@ public function getClients()

$statment = array( 'table' => $table, 'fields' => $fields, 'orderby' => $orderby );

if (FileConfig::get_Value('show_inactive_clients')) {
if (FileConfig::get_Value('show_inactive_clients') != NULL) {
$statment['where'] = "FileRetention > '0' AND JobRetention > '0' ";
}

Expand Down
4 changes: 2 additions & 2 deletions application/models/database.model.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/*
+-------------------------------------------------------------------------+
| Copyright 2010-2017, Davide Franco |
| Copyright 2010-2018, Davide Franco |
| |
| This program is free software; you can redistribute it and/or |
| modify it under the terms of the GNU General Public License |
Expand Down Expand Up @@ -43,7 +43,7 @@ public function get_Size($catalog_id)
$db_size = $db_size['dbsize'] * 1024 * 1024;
return CUtils::Get_Human_Size($db_size);
} else {
echo 'Not supported ('.CDB::getServerVersion().') <br />';
echo 'Not supported ('. $this->cdb->getServerVersion().') <br />';
}
break;
case 'pgsql':
Expand Down
2 changes: 1 addition & 1 deletion application/models/filesets.model.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/*
+-------------------------------------------------------------------------+
| Copyright 2010-2017, Davide Franco |
| Copyright 2010-2018, Davide Franco |
| |
| This program is free software; you can redistribute it and/or |
| modify it under the terms of the GNU General Public License |
Expand Down
2 changes: 1 addition & 1 deletion application/models/jobs.model.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/*
+-------------------------------------------------------------------------+
| Copyright 2010-2017, Davide Franco |
| Copyright 2010-2018, Davide Franco |
| |
| This program is free software; you can redistribute it and/or |
| modify it under the terms of the GNU General Public License |
Expand Down
2 changes: 1 addition & 1 deletion application/models/pools.model.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/*
+-------------------------------------------------------------------------+
| Copyright 2010-2017, Davide Franco |
| Copyright 2010-2018, Davide Franco |
| |
| This program is free software; you can redistribute it and/or |
| modify it under the terms of the GNU General Public License |
Expand Down
2 changes: 1 addition & 1 deletion application/models/volumes.model.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/*
+-------------------------------------------------------------------------+
| Copyright 2010-2017, Davide Franco |
| Copyright 2010-2018, Davide Franco |
| |
| This program is free software; you can redistribute it and/or |
| modify it under the terms of the GNU General Public License |
Expand Down
202 changes: 202 additions & 0 deletions application/views/backupjob.view.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,202 @@
<?php
/*
+-------------------------------------------------------------------------+
| Copyright 2010-2018, Davide Franco |
| |
| This program is free software; you can redistribute it and/or |
| modify it under the terms of the GNU General Public License |
| as published by the Free Software Foundation; either version 2 |
| 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 General Public License for more details. |
+-------------------------------------------------------------------------+
*/

class BackupJobView extends CView {

public function __construct() {

$this->templateName = 'backupjob-report.tpl';
$this->name = 'Backup job report';
$this->title = 'Report per Bacula backup job name';

parent::init();
}

public function prepare() {

require_once('core/const.inc.php');

$backupjob_name = "";
$backupjob_bytes = 0;
$backupjob_files = 0;
$interval = array();
$interval[1] = NOW;

$days = array();
$days_stored_bytes = array();
$days_stored_files = array();

// Period list
$periods_list = array( '7' => "Last week", '14' => "Last 2 weeks", '30' => "Last month");
$this->assign('periods_list', $periods_list);

// Stored Bytes on the defined period
$jobs = new Jobs_Model();

// Get backup job(s) list
$jobslist = $jobs->get_Jobs_List(null, 'B');
$this->assign('jobs_list', $jobslist);

// Check backup job name from $_POST request
$backupjob_name = CHttpRequest::get_value('backupjob_name');

if (($backupjob_name === NULL) && (empty($backupjob_name)) ) {
$this->assign( 'no_report_options', 'true');

// Set selected period
$this->assign( 'selected_period', 7);
}else{
$this->assign( 'no_report_options', 'false');

// Make sure provided backupjob_name exist
if( !in_array( $backupjob_name, $jobslist)) {
throw new Exception("Critical: provided backupjob_name is not valid");
}

$this->assign( 'selected_jobname', $backupjob_name);

// Generate Backup Job report period string
$backupjob_period = CHttpRequest::get_value('period');

// Set default backup job period to 7 if not set in user request
if( $backupjob_period === NULL) {
$backupjob_period = '7';
}

// Set selected period
$this->assign( 'selected_period', $backupjob_period);

switch( $backupjob_period ) {
case '7':
$periodDesc = "From " . date( $_SESSION['datetime_format_short'], (NOW - WEEK)) . " to " . date( $_SESSION['datetime_format_short'], NOW);
$interval[0] = NOW-WEEK;
break;
case '14':
$periodDesc = "From " . date( $_SESSION['datetime_format_short'], (NOW - (2 * WEEK))) . " to " . date( $_SESSION['datetime_format_short'], NOW);
$interval[0] = NOW-(2*WEEK);
break;
case '30':
$periodDesc = "From " . date( $_SESSION['datetime_format_short'], (NOW - MONTH)) . " to " . date( $_SESSION['datetime_format_short'], NOW);
$interval[0] = NOW-MONTH;
}

// Get start and end datetime for backup jobs report and charts
$periods = CDBQuery::get_Timestamp_Interval($jobs->get_driver_name(), $interval);

$backupjob_bytes = $jobs->getStoredBytes( $interval, $backupjob_name);
$backupjob_bytes = CUtils::Get_Human_Size($backupjob_bytes);

// Stored files on the defined period
$backupjob_files = $jobs->getStoredFiles( $interval, $backupjob_name);
$backupjob_files = CUtils::format_Number($backupjob_files);

// Get the last 7 days interval (start and end)
$days = DateTimeUtil::getLastDaysIntervals($backupjob_period);

// Last 7 days stored files chart
foreach ($days as $day) {
$stored_files = $jobs->getStoredFiles(array($day['start'], $day['end']), $backupjob_name);
$days_stored_files[] = array(date("m-d", $day['start']), $stored_files);
}

$stored_files_chart = new Chart( array( 'type' => 'bar',
'name' => 'chart_storedfiles',
'data' => $days_stored_files,
'ylabel' => 'Files' )
);

$this->assign('stored_files_chart_id', $stored_files_chart->name);
$this->assign('stored_files_chart', $stored_files_chart->render());

unset($stored_files_chart);

// Last 7 days stored bytes chart
foreach ($days as $day) {
$stored_bytes = $jobs->getStoredBytes(array($day['start'], $day['end']), $backupjob_name);
$days_stored_bytes[] = array(date("m-d", $day['start']), $stored_bytes);
}

$stored_bytes_chart = new Chart( array( 'type' => 'bar',
'name' => 'chart_storedbytes',
'uniformize_data' => true,
'data' => $days_stored_bytes,
'ylabel' => 'Bytes' )
);

$this->assign('stored_bytes_chart_id', $stored_bytes_chart->name);
$this->assign('stored_bytes_chart', $stored_bytes_chart->render());
unset($stored_bytes_chart);

// Get last jobs list
$query = "SELECT JobId, Level, JobFiles, JobBytes, ReadBytes, JobStatus, StartTime, EndTime, Name ";
$query .= "FROM Job ";
$query .= "WHERE Name = '$backupjob_name' AND Type = 'B' AND ";
$query .= '(EndTime BETWEEN ' . $periods['starttime'] . ' AND ' . $periods['endtime'] . ') ';
$query .= "ORDER BY EndTime DESC ";

$joblist = array();
$joblevel = array('I' => 'Incr', 'D' => 'Diff', 'F' => 'Full');
$result = $jobs->run_query($query);

foreach ($result->fetchAll() as $job) {
// Job level description
$job['joblevel'] = $joblevel[$job['level']];

// Job execution execution time
$job['elapsedtime'] = DateTimeUtil::Get_Elapsed_Time($job['starttime'], $job['endtime']);

// Compression
if ($job['jobbytes'] > 0) {
$compression = (1-($job['jobbytes'] / $job['readbytes']));
$job['compression'] = number_format($compression, 2);
}else{
$job['compression'] = 'N/A';
}

// Job speed
$start = $job['starttime'];
$end = $job['endtime'];
$seconds = DateTimeUtil::get_ElaspedSeconds($end, $start);

if ($seconds !== false && $seconds > 0) {
$speed = $job['jobbytes'] / $seconds;
$job['speed'] = CUtils::Get_Human_Size($speed, 2) . '/s';
} else {
$job['speed'] = 'N/A';
}

// Job bytes more easy to read
$job['jobbytes'] = CUtils::Get_Human_Size($job['jobbytes']);
$job['jobfiles'] = CUtils::format_Number($job['jobfiles']);

// Format date/time
$job['starttime'] = date( $_SESSION['datetime_format'], strtotime($job['starttime']));
$job['endtime'] = date( $_SESSION['datetime_format'], strtotime($job['endtime']));

$joblist[] = $job;
} // end while

$this->assign('jobs', $joblist);
$this->assign('backupjob_name', $backupjob_name);
$this->assign('periodDesc', $periodDesc);
$this->assign('backupjob_bytes', $backupjob_bytes);
$this->assign('backupjob_files', $backupjob_files);
} // end else

} // end of prepare() method
} // end of class

File renamed without changes.

0 comments on commit cd38775

Please sign in to comment.