header “Storage volume”

subheader storage_volume.id

%div{ :'data-role' => :content, :'data-theme' => 'c'}

%l{ :'data-role' => :listview , :'data-inset' => :true, :'data-divider-theme' => 'd'}
  %i{ :'data-role' => 'list-divider'} Name
  %{ :'data-role' => 'fieldcontain'}=storage_volume.id
  %i
    %{ :'data-role' => 'fieldcontain'}=(storage_volume.name ? storage_volume.name : storage_volume.id)
  %i{ :'data-role' => 'list-divider'} Created
  %i
    %{ :'data-role' => 'fieldcontain'}=storage_volume.created
  %i{ :'data-role' => 'list-divider'} Capacity
  %i
    %{ :'data-role' => 'fieldcontain'}=storage_volume.capacity
  %i{ :'data-role' => 'list-divider'} Realm
  %i
    %{ :'data-role' => 'fieldcontain'}=storage_volume.realm_id
  %i{ :'data-role' => 'list-divider'} State
  %i
    %{ :'data-role' => 'fieldcontain'}=storage_volume.state
  %i{ :'data-role' => 'list-divider'} Attached to
  %i
    - if storage_volume.instance_id
      %{ :href => instance_url( storage_volume.instance_id)}
        = storage_volume.instance_id
    - elsif storage_volume.state and storage_volume.state != "IN-USE"
      %{ :'data-role' => 'fieldcontain'}= 'none (detached)'
    -else
      %{ :'data-role' => 'fieldcontain'}= 'unknown'
  %i{ :'data-role' => 'list-divider'} Device
  %i
    %{ :'data-role' => 'fieldcontain'}= storage_volume.device
  %i{ :'data-role' => 'list-divider'} Actions
  %i
    %iv{ :'data-role' => 'controlgroup', :'data-type' => "horizontal" }
      - if ["AVAILABLE", "IN-USE"].include?(storage_volume.state)
        =link_to_action "Snapshot...", url_for("storage_snapshots/new?volume_id=#{storage_volume.id}"), :get
        - unless storage_volume.instance_id
          =link_to_action "Delete", url_for("storage_volumes/#{storage_volume.id}"), :delete
          =link_to_action "Attach...", url_for("storage_volumes/#{storage_volume.id}/attach_instance"), :get
        - if storage_volume.instance_id
          =link_to_action "Detach", url_for("storage_volumes/#{storage_volume.id}/detach"), :post