Commit e157df20 authored by Florian Kaiser's avatar Florian Kaiser
Browse files

add percent quota used column

parent 7b7848dc
......@@ -15,7 +15,7 @@ class UsageDAO {
$dbPlatform = $this->db->getDatabasePlatform();
$join_storage_expr = $dbPlatform->getConcatExpression('"home::"', '*PREFIX*preferences.userid');
$sql = 'SELECT *PREFIX*preferences.userid AS username, *PREFIX*preferences.configvalue as quotavalue, *PREFIX*filecache.size as bytes, sub.num as objects
$sql = 'SELECT *PREFIX*preferences.userid AS username, *PREFIX*preferences.configvalue as quotastring, *PREFIX*filecache.size as bytes, sub.num as objects
FROM *PREFIX*preferences
LEFT JOIN *PREFIX*storages ON (*PREFIX*storages.id=' . $join_storage_expr . ')
LEFT JOIN *PREFIX*filecache ON (*PREFIX*storages.numeric_id=*PREFIX*filecache.storage)
......@@ -27,10 +27,15 @@ class UsageDAO {
$stmt = $this->db->prepare($sql);
$stmt->execute();
$result = $stmt->fetchAll(\PDO::FETCH_NUM);
$result = $stmt->fetchAll(\PDO::FETCH_ASSOC);
$stmt->closeCursor();
for ($i=0; $i < count($result); ++$i) {
$result[$i]['bytes'] = intval($result[$i]['bytes']);
$result[$i]['quotavalue'] = \OCP\Util::computerFileSize($result[$i]['quotastring']);
}
return $result;
}
......
......@@ -11,20 +11,10 @@
(function ($, OC) {
$(document).ready(function () {
$('#hello').click(function () {
alert('Hello from your script file');
});
$('#echo').click(function () {
var url = OC.generateUrl('/apps/storageusage/echo');
var data = {
echo: $('#echo-content').val()
};
$.post(url, data).success(function (response) {
$('#echo-result').text(response.echo);
});
$(".storageusage-progress").each(function() {
$(this).progressbar({
value: parseInt( $(this).attr("storageusage-percent") )
});
});
});
......
......@@ -31,6 +31,7 @@
<th>Objects</th>
<th>Space</th>
<th>Quota</th>
<th>% Used</th>
<tr>
</thead>
<tbody>
......@@ -38,15 +39,15 @@
<?php $alt=false; ?>
<?php foreach($_['data'] as $row){ ?>
<tr class="<?php if ($alt=!$alt) echo 'alt';?>">
<td><?php p($row[0]); ?></td>
<td><?php p($row[3]); ?></td>
<td><?php p($this->human_file_size($row[2])); ?></td>
<td><?php p($row[1]); ?></td>
<td><?php p($row['username']); ?></td>
<td><?php p($row['objects']); ?></td>
<td><?php p($this->human_file_size($row['bytes'])); ?></td>
<td><?php p($row['quotastring']); ?></td>
<td><div class="storageusage-progress" storageusage-percent="<?php p($row['bytes'] / $row['quotavalue']); ?>"></div></td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment