Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changed Job Filters To GET Requests. Links in Dashboard #13

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 9 additions & 3 deletions application/models/volumes.model.php
Expand Up @@ -54,9 +54,15 @@ public function getDiskUsage()
// Return: list of volumes (array)
// ==================================================================================

public function getVolumes( $pool_id = null, $orderby = 'Name', $orderasc = 'DESC') {
public function getVolumes( $pool_id = null, $orderby = 'Name', $orderasc = 'DESC', $orderby_extra = '', $orderasc_extra='DESC' ) {
$volumes_list = array();
$where = '';

if ( !empty($orderby_extra) && $orderby != $orderby_extra ) {
$order = $orderby .' '. $orderasc . ',' . $orderby_extra . ' ' . $orderasc_extra;
} else {
$order = $orderby .' '. $orderasc;
}

if( !is_null($pool_id) ) {
$this->addParameter( 'pool_id', $pool_id);
Expand All @@ -65,8 +71,8 @@ public function getVolumes( $pool_id = null, $orderby = 'Name', $orderasc = 'DES

$query = "SELECT Media.volumename, Media.volbytes, Media.voljobs, Media.volstatus, Media.mediatype, Media.lastwritten,
Media.volretention, Media.slot, Media.inchanger, Pool.Name AS pool_name
FROM Media LEFT JOIN Pool ON Media.poolid = Pool.poolid $where ORDER BY $orderby $orderasc";

FROM Media LEFT JOIN Pool ON Media.poolid = Pool.poolid $where ORDER BY $order";
$result = $this->run_query($query);

foreach ($result->fetchAll() as $volume) {
Expand Down
12 changes: 6 additions & 6 deletions application/views/templates/dashboard.tpl
Expand Up @@ -36,27 +36,27 @@
</a>
<table class="table table-condensed">
<tr>
<td><h5>{t}Running jobs{/t}</h5></td>
<td><h5><a href="index.php?page=jobs&job_status_filter=1">{t}Running jobs{/t}</a></h5></td>
<td class="text-center"> <h4><span class="label label-default">{$running_jobs}</span></h4> </td>
</tr>
<tr>
<td><h5>{t}Completed job(s){/t}</h5></td>
<td><h5><a href="index.php?page=jobs&job_status_filter=3">{t}Completed job(s){/t}</a></h5></td>
<td class="text-center"> <h4><span class="label label-success">{$completed_jobs}</span></h4> </td>
</tr>
<tr>
<td><h5>{t}Completed with errors job(s){/t}
<td><h5><a href="index.php?page=jobs&job_status_filter=4">{t}Completed with errors job(s){/t}</a>
<td class="text-center"> <h4><span style="background-color: #FFD700;" class="label label-default">{$completed_with_errors_jobs}</span></h4> </td>
</tr>
<tr>
<td> <h5>{t}Waiting jobs(s){/t}</h5></td>
<td> <h5><a href="index.php?page=jobs&job_status_filter=2">{t}Waiting jobs(s){/t}</a></h5></td>
<td class="text-center"> <h4><span class="label label-primary">{$waiting_jobs}</span></h4> </td>
</tr>
<tr>
<td> <h5>{t}Failed job(s){/t}</h5></td>
<td> <h5><a href="index.php?page=jobs&job_status_filter=5">{t}Failed job(s){/t}</a></h5></td>
<td class="text-center"> <h4><span class="label label-danger">{$failed_jobs}</span></h4> </td>
</tr>
<tr>
<td> <h5>{t}Canceled job(s){/t}</h5></td>
<td> <h5><a href="index.php?page=jobs&job_status_filter=6">{t}Canceled job(s){/t}</a></h5></td>
<td class="text-center"> <h4><span class="label label-warning">{$canceled_jobs}</span></h4> </td>
</tr>
<tr>
Expand Down
3 changes: 2 additions & 1 deletion application/views/templates/jobs.tpl
Expand Up @@ -8,7 +8,8 @@
<!-- Filter jobs form -->
<div class="col-xs-12 col-sm-3 col-sm-push-9 col-lg-2 col-lg-push-10">

<form class="form" role="form" action="index.php?page=jobs" method="post">
<form class="form" role="form" action="index.php" method="get">
<input type="hidden" name="page" value="jobs" />

<span class="help-block">{t}Filter{/t}</span>

Expand Down
18 changes: 14 additions & 4 deletions application/views/templates/volumes.tpl
Expand Up @@ -5,22 +5,32 @@
</div>

<div class="row">
<div class="col-xs-12 col-md-8">
<div class="col-xs-12 col-md-6">
</div>

<div class="col-xs-12 col-md-4">
<div class="col-xs-12 col-md-6">
<!-- Options -->
<form class="form-inline" role="form" action="index.php?page=volumes" method="post">
<form class="form-inline" role="form" action="index.php" method="get">
<input type="hidden" name="page" value="volumes" />
<span class="help-block">{t}Options{/t}</span>
<div class="form-group">
<label>{t}Order by{/t}</label>
{html_options class="form-control input-sm" name=orderby options=$orderby selected=$orderby_selected}
</div>
<!--/div>-->
<div class="checkbox">
<label>
<input type="checkbox" name="orderby_asc" value="{t}Asc{/t}" {$orderby_asc_checked}> Asc
</label>
</div>
<!--div class="form-group">-->
<label>{t}Order by Extra{/t}</label>
{html_options class="form-control input-sm" name=orderby_extra options=$orderby_extra selected=$orderby_extra_selected}
</div>
<div class="checkbox">
<label>
<input type="checkbox" name="orderby_asc_extra" value="{t}Asc{/t}" {$orderby_asc_extra_checked}> Asc
</label>
</div>
<button type="submit" class="btn btn-primary btn-sm pull-right" title="{t}Apply filter and options{/t}">{t}Apply{/t}</button>
</form>
</div> <!-- end div class="col-x... -->
Expand Down
30 changes: 26 additions & 4 deletions application/views/volumes.view.php
Expand Up @@ -43,12 +43,34 @@ public function prepare() {
'Error' => 'fa-times-circle',
'Busy' => 'fa-clock-o' );

$orderby = array('Name' => 'Name', 'MediaId' => 'Id', 'VolBytes' => 'Bytes', 'VolJobs' => 'Jobs');
$orderby = array('Name' => 'Name', 'MediaId' => 'Id', 'VolBytes' => 'Bytes', 'VolJobs' => 'Jobs', 'InChanger' => 'InChanger');
$this->assign( 'orderby', $orderby);

$volume_orderby_filter = 'Name';
$volume_orderby_asc = 'DESC';

$orderby_extra = array('Name' => 'Name', 'MediaId' => 'Id', 'VolBytes' => 'Bytes', 'VolJobs' => 'Jobs', 'InChanger' => 'InChanger', '' => 'null');
$this->assign ( 'orderby_extra', $orderby);

$volume_orderby_filter_extra = '';
$volume_orderby_asc_extra = 'DESC';


if( !is_null(CHttpRequest::get_Value('orderby_extra')) ) {
if( array_key_exists(CHttpRequest::get_Value('orderby_extra'), $orderby_extra) ) {
$volume_orderby_filter_extra = CHttpRequest::get_Value('orderby_extra');
}else{
throw new Exception("Critical: Provided orderby_extra parameter is not correct");
}
}

if( !is_null(CHttpRequest::get_Value('orderby_asc_extra')) ) {
$volume_orderby_asc_extra = 'ASC';
$this->assign( 'orderby_asc_extra_checked', 'checked');
}

$this->assign( 'orderby_extra_selected', $volume_orderby_filter_extra);

if( !is_null(CHttpRequest::get_Value('orderby')) ) {
if( array_key_exists(CHttpRequest::get_Value('orderby'), $orderby) ) {
$volume_orderby_filter = CHttpRequest::get_Value('orderby');
Expand All @@ -61,17 +83,17 @@ public function prepare() {
$volume_orderby_asc = 'ASC';
$this->assign( 'orderby_asc_checked', 'checked');
}

$this->assign( 'orderby_selected', $volume_orderby_filter);

$poolid = CHttpRequest::get_Value('pool_id');

// If pool_id have been passed in GET request
if (!is_numeric($poolid) && !is_null($poolid)) {
throw new Exception('Invalid pool id (not numeric) provided in Volumes report page');
}

foreach ($volumes->getVolumes( $poolid, $volume_orderby_filter, $volume_orderby_asc) as $volume) {
foreach ($volumes->getVolumes( $poolid, $volume_orderby_filter, $volume_orderby_asc, $volume_orderby_filter_extra, $volume_orderby_asc_extra) as $volume) {
// Calculate volume expiration
// If volume have already been used
if ($volume['lastwritten'] != "0000-00-00 00:00:00") {
Expand Down