Skip to content
This repository was archived by the owner on Sep 10, 2021. It is now read-only.

Commit 5f87f26

Browse files
committed
ENH: refs #0377. Add pie chart to the storage quota view
1 parent 40c5005 commit 5f87f26

File tree

3 files changed

+44
-2
lines changed

3 files changed

+44
-2
lines changed

modules/sizequota/controllers/ConfigController.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,17 @@ public function folderAction()
119119
}
120120
$usedSpace = $this->Folder->getSizeFiltered($folder, $this->userSession->Dao);
121121
$this->view->usedSpace = $usedSpace[0]->size;
122+
$this->view->hUsedSpace = UtilityComponent::formatSize($this->view->usedSpace);
123+
if($this->view->quota == '')
124+
{
125+
$this->view->hQuota = $this->t('Unlimited');
126+
$this->view->hFreeSpace = '';
127+
}
128+
else
129+
{
130+
$this->view->hQuota = UtilityComponent::formatSize($this->view->quota);
131+
$this->view->hFreeSpace = UtilityComponent::formatSize($this->view->quota - $this->view->usedSpace);
132+
}
122133
$this->view->configForm = $formArray;
123134
$this->view->folder = $folder;
124135
$this->view->isAdmin = $this->userSession->Dao->isAdmin();

modules/sizequota/public/js/config/config.folder.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,28 @@ $(document).ready(function() {
5555

5656
$('input[name="usedefault"]').change(midas.sizequota.folder.radioButtonChanged);
5757
midas.sizequota.folder.radioButtonChanged();
58+
59+
var quota = parseInt($('#quotaValue').html());
60+
var used = parseInt($('#usedSpaceValue').html());
61+
var free = quota - used;
62+
var hUsed = $('#hUsedSpaceValue').html();
63+
var hFree = $('#hFreeSpaceValue').html();
64+
65+
var data = [['Used space (' + hUsed + ')' , used], ['Free space (' + hFree + ')', free]];
66+
if(quota != '' && quota != 0)
67+
{
68+
$('#quotaChart').show();
69+
$.jqplot('quotaChart', [data], {
70+
seriesDefaults: {
71+
renderer: $.jqplot.PieRenderer,
72+
rendererOptions: {
73+
showDataLabels: true
74+
}
75+
},
76+
legend: {
77+
show: true,
78+
location: 'e'
79+
}
80+
});
81+
}
5882
});

modules/sizequota/views/config/folder.phtml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,22 @@
1919
=========================================================================*/
2020

2121
echo '<script type="text/javascript" src="'.$this->coreWebroot.'/public/js/jquery/jquery.form.js"></script>';
22+
echo '<script type="text/javascript" src="'.$this->coreWebroot.'/public/js/jquery/jquery.jqplot.min.js"></script>';
23+
echo '<script type="text/javascript" src="'.$this->coreWebroot.'/public/js/jquery/jqplot/jqplot.pieRenderer.min.js"></script>';
2224
echo '<script type="text/javascript" src="'.$this->moduleWebroot.'/public/js/config/config.folder.js"></script>';
2325
?>
2426
<link type="text/css" rel="stylesheet" href="<?php echo $this->moduleWebroot?>/public/css/config/config.folder.css" />
2527
<link type="text/css" rel="stylesheet" href="<?php echo $this->coreWebroot?>/public/css/common/common.genericPage.css" />
28+
<link rel="stylesheet" type="text/css" href="<?php echo $this->coreWebroot?>/public/css/jquery/jquery.jqplot.css" />
2629

2730
</div>
28-
<span><?php echo 'Current used space: '.$this->usedSpace; ?></span>
31+
<span><?php echo $this->t('Current used space:'); ?> <span id='hUsedSpaceValue'><?php echo $this->hUsedSpace; ?></span></span>
2932
<br />
30-
<span><?php echo 'Total space: '.$this->quota; ?></span>
33+
<span><?php echo $this->t('Total space:'); ?> <span id='hQuotaValue'><?php echo $this->hQuota; ?></span></span>
34+
<span style="display: none;" id="hFreeSpaceValue"><?php echo $this->hFreeSpace; ?></span>
35+
<span style="display: none;" id="quotaValue"><?php echo $this->quota; ?></span>
36+
<span style="display: none;" id="usedSpaceValue"><?php echo $this->usedSpace; ?></span>
37+
<div id='quotaChart' style="height: 200px; width: 400px; display: none;"></div>
3138
<br />
3239
<?php
3340
if($this->isAdmin)

0 commit comments

Comments
 (0)