Improve bytes, gb, and mb angular filters

Bug #1447818 reported by Matthew D. Wood
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Dashboard (Horizon)
New
Wishlist
Unassigned

Bug Description

In the horizon/static/horizon/js/angular/filters/filters.js file, there's 3 filters that deal with disk-sizings: bytes, gb, and mb.

The bytes filter should likely accept a "target unit" input parameter and lock all output to that unit instead of auto-determining the unit.

We should also probably complete the whole set of kb, mb, gb, tb, pb.

Also, the existing gb and mb filters are pretty naive and simplistic. They should likely do more than just check for numbers and append "MB" or "GB" to the value. Candidate improvements include:

    A) Checking for a string that is already of the correct format
    B) ???

Changed in horizon:
assignee: nobody → Matthew D. Wood (woodm1979)
Changed in horizon:
importance: Undecided → Wishlist
Changed in horizon:
status: New → In Progress
Revision history for this message
Matthew D. Wood (woodm1979) wrote :

Completed the whole set of filters kb, mb, gb, tb, and pb.

Revision history for this message
Matthew D. Wood (woodm1979) wrote :

Checking for a string that is already of the correct format may require a rewrite of sorts. Because of gettext reasons, we can't really slice the input string intelligently, nor slice the interpolate string. If we didn't need to use gettext this would be easy.

... or maybe there's another way entirely?

Revision history for this message
Matthew D. Wood (woodm1979) wrote :

bytes now accepts a label.

Maintained 100% test coverage in all patch-sets!

Revision history for this message
Matthew D. Wood (woodm1979) wrote :

After some discussion with Thai and Travis, we're going to add a "toBytes" filter which will down-convert things to bytes, which will allow this type of chained filter:

input_value | toBytes:MB | bytes # convert from MB into a more appropriate unit.
or
input_value | toBytes:MB | bytes:GB # convert from MB to GB

I'm going to see if I can't make this into a single filter, but the syntax may be a bit confusing.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Change abandoned on horizon (master)

Change abandoned by Matthew D. Wood (<email address hidden>) on branch: master
Review: https://review.openstack.org/177572

Akihiro Motoki (amotoki)
Changed in horizon:
assignee: Matthew D. Wood (woodm1979) → nobody
status: In Progress → New
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.