Author: david
Date: Wed Aug 24 16:21:04 2011
New Revision: 9590
Log:
Add disk usage progress bar and percentage usage display
Modified:
trunk/apps/qubit/modules/repository/actions/contextMenuComponent.class.php
trunk/apps/qubit/modules/repository/templates/_contextMenu.php
Modified:
trunk/apps/qubit/modules/repository/actions/contextMenuComponent.class.php
==============================================================================
--- trunk/apps/qubit/modules/repository/actions/contextMenuComponent.class.php
Wed Aug 24 16:20:23 2011 (r9589)
+++ trunk/apps/qubit/modules/repository/actions/contextMenuComponent.class.php
Wed Aug 24 16:21:04 2011 (r9590)
@@ -43,6 +43,39 @@
// Filter draft descriptions
$criteria = QubitAcl::addFilterDraftsCriteria($criteria);
+
+ // Disk usage display value
+ $du = floatval($this->resource->getDiskUsage()) / pow(2, 30);
+ if (0 < $du && 0.1 > $du)
+ {
+ $this->diskUsage = '< 0.1';
+ }
+ else
+ {
+ $this->diskUsage = round($du, 1);
+ }
+
+ $this->barColor = '#390'; // Default progress bar color is green
+
+ // Calculate disk usage percentages
+ $dup = $du / floatval(sfConfig::get('app_repository_quota')) * 100;
+ if (0 < $dup && 1 > $dup)
+ {
+ $this->diskUsagePercent = '< 1';
+ $this->barPixels = '1';
+ }
+ else if (100 < $dup)
+ {
+ $this->diskUsagePercent = '> 100';
+ $this->barPixels = 200;
+ $this->barColor = '#C33'; // RED!
+ }
+ else
+ {
+ $this->diskUsagePercent = round($dup, 0);
+ $this->barPixels = round($dup * 2, 0);
+ }
+
// Paginate holdings list
$this->pager = new QubitPager('QubitInformationObject');
$this->pager->setCriteria($criteria);
Modified: trunk/apps/qubit/modules/repository/templates/_contextMenu.php
==============================================================================
--- trunk/apps/qubit/modules/repository/templates/_contextMenu.php Wed Aug
24 16:20:23 2011 (r9589)
+++ trunk/apps/qubit/modules/repository/templates/_contextMenu.php Wed Aug
24 16:21:04 2011 (r9590)
@@ -1,10 +1,13 @@
-<?php if (0 < intval(sfConfig::get('app_repository_quota'))): ?>
+<?php if (0 < floatval(sfConfig::get('app_repository_quota'))): ?>
<div>
<h3><?php echo __('Disk quota used') ?></h3>
<div>
- <?php echo __('%1% of %2% <a
href="http://en.wikipedia.org/wiki/Gigabyte">GB</a>', array('%1%' =>
$resource->getDiskUsage(), '%2%' => sfConfig::get('app_repository_quota'))) ?>
+ <div class="usageBar" style="margin-top: 5px; background-color: #CCC;
height: 10px; width: 200px">
+ <div style="height: 10px; width: <?php echo $barPixels ?>px;
background-color: <?php echo $barColor ?>;"></div>
+ </div>
+ <?php echo __('%1% of %2% <a
href="http://en.wikipedia.org/wiki/Gigabyte">GB</a> allowed (%3%%)',
array('%1%' => $diskUsage, '%2%' => sfConfig::get('app_repository_quota'),
'%3%' => $diskUsagePercent)) ?>
</div>
</div>
--
You received this message because you are subscribed to the Google Groups
"Qubit Toolkit Commits" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/qubit-commits?hl=en.