[ARVADOS] updated: 2d03682c2dbc5ee4567ed93e5f2cba770b8ba65e
git at public.curoverse.com
git at public.curoverse.com
Tue Jan 14 09:16:35 EST 2014
Summary of changes:
apps/workbench/app/helpers/application_helper.rb | 33 ++++++++++++++++---
apps/workbench/app/views/collections/show.html.erb | 23 ++++++-------
2 files changed, 38 insertions(+), 18 deletions(-)
via 2d03682c2dbc5ee4567ed93e5f2cba770b8ba65e (commit)
from 7aff46a6515cfb7531eaad04495430b0487d8375 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
commit 2d03682c2dbc5ee4567ed93e5f2cba770b8ba65e
Author: Peter Amstutz <peter.amstutz at curoverse.com>
Date: Tue Jan 14 09:17:12 2014 -0500
Moved "size" column to last and added SI order of magnitude suffixes instead of showing raw byte counts.
diff --git a/apps/workbench/app/helpers/application_helper.rb b/apps/workbench/app/helpers/application_helper.rb
index c67b314..3760109 100644
--- a/apps/workbench/app/helpers/application_helper.rb
+++ b/apps/workbench/app/helpers/application_helper.rb
@@ -13,13 +13,34 @@ module ApplicationHelper
def human_readable_bytes_html(n)
return h(n) unless n.is_a? Fixnum
- raw = n.to_s
- cooked = ''
- while raw.length > 3
- cooked = ',' + raw[-3..-1] + cooked
- raw = raw[0..-4]
+
+ orders = {
+ 1 => "bytes",
+ 1024 => "KiB",
+ (1024*1024) => "MiB",
+ (1024*1024*1024) => "GiB",
+ (1024*1024*1024*1024) => "TiB"
+ }
+
+ orders.each do |k, v|
+ sig = (n.to_f/k)
+ if sig >=1 and sig < 1024
+ if v == 'bytes'
+ return "%i #{v}" % sig
+ else
+ return "%0.1f #{v}" % sig
+ end
+ end
end
- cooked = raw + cooked
+
+ return h(n)
+ #raw = n.to_s
+ #cooked = ''
+ #while raw.length > 3
+ # cooked = ',' + raw[-3..-1] + cooked
+ # raw = raw[0..-4]
+ #end
+ #cooked = raw + cooked
end
def resource_class_for_uuid(attrvalue, opts={})
diff --git a/apps/workbench/app/views/collections/show.html.erb b/apps/workbench/app/views/collections/show.html.erb
index 057ced8..0c5795d 100644
--- a/apps/workbench/app/views/collections/show.html.erb
+++ b/apps/workbench/app/views/collections/show.html.erb
@@ -30,34 +30,33 @@
<table class="table table-bordered" style="table-layout: fixed">
<thead>
<tr>
- <th style="width: 10em; text-align:right">size</th>
- <th>
- path
- </th>
- <th>
- file
- </th>
- <th style="width:2em">
- </th>
+ <th>path</th>
+ <th>file</th>
+ <th style="width:1.5em">d/l</th>
+ <th style="width: 7em; text-align:right">size</th>
</tr>
</thead><tbody>
<% if @object then @object.files.sort_by{|f|f[1]}.each do |file| %>
<% file_path = "#{file[0]}/#{file[1]}" %>
<tr>
- <td style="text-align:right">
- <%= raw(human_readable_bytes_html(file[2])) %>
- </td>
<td>
<%= file[0] %>
</td>
+
<td>
<%= link_to file[1], {controller: 'collections', action: 'show_file', uuid: @object.uuid, file: file_path, size: file[2], disposition: 'inline'}, {title: 'View in browser'} %>
</td>
+
<td>
<div style="display:inline-block">
<%= link_to raw('<i class="icon-download"></i>'), {controller: 'collections', action: 'show_file', uuid: @object.uuid, file: file_path, size: file[2], disposition: 'attachment'}, {class: 'label label-info', title: 'Download'} %>
</div>
</td>
+
+ <td style="text-align:right">
+ <%= raw(human_readable_bytes_html(file[2])) %>
+ </td>
+
</tr>
<% end; end %>
</tbody>
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list