From d2b2dc79255abfa2887bd40262c129a15635450a Mon Sep 17 00:00:00 2001 From: Ben Roberts Date: Sat, 6 Aug 2011 23:11:15 +0100 Subject: [PATCH] Add output filesize to jobs summary page --- source/lib/RippingCluster/Job.class.php | 15 ++++++++++++++- source/lib/RippingCluster/Main.class.php | 10 ++++++---- webui/source/templates/jobs.tpl | 7 ++++++- 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/source/lib/RippingCluster/Job.class.php b/source/lib/RippingCluster/Job.class.php index 390d151..37de6f2 100644 --- a/source/lib/RippingCluster/Job.class.php +++ b/source/lib/RippingCluster/Job.class.php @@ -271,7 +271,20 @@ class RippingCluster_Job { return $new_status; } - + + public function isFinished() { + $current_status = $this->currentStatus()->status(); + return ($current_status == RippingCluster_JobStatus::COMPLETE || $current_status == RippingCluster_JobStatus::FAILED); + } + + public function outputFilesize() { + if (file_exists($this->destination_filename)) { + return filesize($this->destination_filename); + } + + return null; + } + public function calculateETA() { $current_status = $this->currentStatus(); if ($current_status->status() != RippingCluster_JobStatus::RUNNING) { diff --git a/source/lib/RippingCluster/Main.class.php b/source/lib/RippingCluster/Main.class.php index 6145515..88a25a0 100644 --- a/source/lib/RippingCluster/Main.class.php +++ b/source/lib/RippingCluster/Main.class.php @@ -18,13 +18,15 @@ class RippingCluster_Main extends SihnonFramework_Main { switch (HBC_File) { case 'index': { + $smarty_tmp = '/tmp/ripping-cluster'; $this->smarty = new Smarty(); - $this->smarty->template_dir = './source/templates'; - $this->smarty->compile_dir = './tmp/templates'; - $this->smarty->cache_dir = './tmp/cache'; - $this->smarty->config_dir = './config'; + $this->smarty->template_dir = static::makeAbsolutePath('./source/templates'); + $this->smarty->compile_dir = static::makeAbsolutePath($smarty_tmp . '/tmp/templates'); + $this->smarty->cache_dir = static::makeAbsolutePath($smarty_tmp . '/tmp/cache'); + $this->smarty->config_dir = static::makeAbsolutePath($smarty_tmp . '/config'); $this->smarty->registerPlugin('modifier', 'formatDuration', array('RippingCluster_Main', 'formatDuration')); + $this->smarty->registerPlugin('modifier', 'formatFilesize', array('RippingCluster_Main', 'formatFilesize')); $this->smarty->assign('version', '0.1'); $this->smarty->assign('messages', array()); diff --git a/webui/source/templates/jobs.tpl b/webui/source/templates/jobs.tpl index 74773f9..3f0e337 100644 --- a/webui/source/templates/jobs.tpl +++ b/webui/source/templates/jobs.tpl @@ -43,7 +43,12 @@ {assign var=current_status value=$job->currentStatus()} {$job->name()} - {$job->destinationFilename()} + + {$job->destinationFilename()} + {if $job->isFinished()} + ({$job->outputFilesize()|formatFilesize}) + {/if} + {$job->title()} {$current_status->statusName()}