Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes #3683 display free and available space in vSphere datastore selection #1039

Closed
wants to merge 3 commits into from
Closed

fixes #3683 display free and available space in vSphere datastore selection #1039

wants to merge 3 commits into from

Conversation

mmatuska
Copy link
Contributor

No description provided.

@ohadlevy
Copy link
Member

[test]

@@ -1,5 +1,5 @@
<div class="fields">
<%= selectable_f f, :datastore, compute_resource.datastores, { }, :class => "span2", :label => _("Data Store"), :disabled => !new %>
<%= select_f f, :datastore, compute_resource.datastores, :name, :to_label, { }, :class => "span2", :label => _("Data Store"), :disabled => !new %>
<%= text_f f, :name, :class => "input-mini", :label => "Name", :disabled => !new %>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not move the ds_ext to a simple helper? this way you dont need to extend any core object?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mmatuska
Copy link
Contributor Author

I have submitted a fog pull request: fog/fog#2402
When fog supports "uncommitted", we will also be able to display total provisioned space.

@mmatuska
Copy link
Contributor Author

Update: fog as accepted my pull request and will support the "uncommitted" attribute from the next version.
fog/fog#2402

@domcleal
Copy link
Contributor

I don't think we need to reimplement the human size bit on Integer here, as Rails already has a number_to_human_size helper which we use elsewhere. To use this, you could use selectable_f and generate your label inline, e.g.

  <%= selectable_f f, :datastore, compute_resource.datastores.map { |ds| "#{ds.name} (#{number_to_human_size(ds.freespace)})", ds.id] }, { }, :class => "span2 disable-unsupported", :label => _("Data Store") %>

extend ActiveSupport::Concern
def to_label
if freespace and capacity
"#{name} (#{freespace.to_human_size} / #{capacity.to_human_size})"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure if it's just me, but I read number / larger number as used / total rather than free / total...

@mmatuska
Copy link
Contributor Author

I have updated the diff, now everything is implemented in _volume.html.erb

{ },
:class => "span2",
:label => _("Data Store"),
:disabled => !new %>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is needed since f9a7731

<%= selectable_f f, :datastore, compute_resource.datastores, { }, :class => "span2 disable-unsupported", :label => _("Data Store") %>
<%= selectable_f f, :datastore,
compute_resource.datastores.map {
|ds| [ds.freespace && ds.capacity ? "#{ds.name} (#{_('free')}: #{number_to_human_size(ds.freespace)}, #{_('total')}: #{number_to_human_size(ds.capacity)})" : ds.name, ds.name]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we should use a helper?

@domcleal
Copy link
Contributor

Thanks for the patch @mmatuska, merged as 5257110 for Foreman 1.4.0.

@domcleal domcleal closed this Nov 22, 2013
@mmatuska mmatuska deleted the vsphere-datastore branch February 11, 2014 11:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants