Add container size

pull/2/head
Michael Crosby 2013-06-19 12:18:54 -09:00
parent b069616da2
commit 2d199eec5d
3 changed files with 15 additions and 1 deletions

View File

@ -22,6 +22,8 @@ DockerUI currently supports the v1.1 Remote API
###Stack ###Stack
* Angular.js * Angular.js
* Flatstrap ( Flat Twitter Bootstrap ) * Flatstrap ( Flat Twitter Bootstrap )
* Spin.js
* Ace editor
###Todo: ###Todo:

View File

@ -53,10 +53,20 @@ angular.module('dockerui.filters', [])
return ''; return '';
}; };
}) })
.filter('humansize', function() {
return function(bytes) {
var sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB'];
if (bytes == 0) {
return 'n/a';
}
var i = parseInt(Math.floor(Math.log(bytes) / Math.log(1024)));
return Math.round(bytes / Math.pow(1024, i), 2) + ' ' + sizes[[i]];
};
})
.filter('getdate', function() { .filter('getdate', function() {
return function(data) { return function(data) {
//Multiply by 1000 for the unix format //Multiply by 1000 for the unix format
var date = new Date(data * 1000); var date = new Date(data * 1000);
return date.toDateString(); return date.toDateString();
}; };
}); });

View File

@ -11,6 +11,7 @@
<th>Image</th> <th>Image</th>
<th>Command</th> <th>Command</th>
<th>Created</th> <th>Created</th>
<th>Size</th>
<th>Status</th> <th>Status</th>
</tr> </tr>
</thead> </thead>
@ -20,6 +21,7 @@
<td><a href="/#/images/{{ container.Image }}/">{{ container.Image }}</a></td> <td><a href="/#/images/{{ container.Image }}/">{{ container.Image }}</a></td>
<td>{{ container.Command|truncate:40 }}</td> <td>{{ container.Command|truncate:40 }}</td>
<td>{{ container.Created|getdate }}</td> <td>{{ container.Created|getdate }}</td>
<td>{{ container.SizeRw|humansize }}</td>
<td><span class="label label-{{ container.Status|statusbadge }}">{{ container.Status }}</span></td> <td><span class="label label-{{ container.Status|statusbadge }}">{{ container.Status }}</span></td>
</tr> </tr>
</tbody> </tbody>