2016-08-22 09:41:25 +00:00
|
|
|
module VolumeHelper
|
2016-09-20 12:13:24 +00:00
|
|
|
|
2016-10-02 12:38:57 +00:00
|
|
|
def html_volume_info(volume, index)
|
2016-09-23 09:28:53 +00:00
|
|
|
params = ['Type', 'Volume ID', 'Status', 'Number of Bricks', 'Transport-type', 'Bricks', 'Options Reconfigured', 'Mount State', 'Mount Point']
|
2016-09-29 06:53:08 +00:00
|
|
|
arrow = ((index == 0) ? "up" : "down")
|
|
|
|
display = ((index != 0) ? "style='display: none;'" : "")
|
|
|
|
lights = []
|
|
|
|
lights << ((volume['Status'].eql? " Stopped" or volume['Status'].eql? " Created") ? "red" : "")
|
|
|
|
lights << ((!volume['Mount State'].eql? "mounted" and volume['Status'].eql? " Started") ? "blue" : "")
|
|
|
|
lights << ((volume['Mount State'].eql? "mounted") ? "green" : "")
|
2016-09-20 12:13:24 +00:00
|
|
|
html = ''
|
2016-09-29 06:53:08 +00:00
|
|
|
html << "<div class='col-md-6 col-sm-6 col-xs-12'>"
|
|
|
|
html << "<div class='x_panel'>"
|
|
|
|
html << "<div class='x_title'>"
|
|
|
|
# left title
|
2016-09-30 09:30:21 +00:00
|
|
|
html << "<h2>Infomation <small>#{volume['Volume Name']}</small></h2>"
|
2016-09-29 06:53:08 +00:00
|
|
|
# right title
|
|
|
|
html << "<ul class='nav navbar-right panel_toolbox'>"
|
|
|
|
html << "<li><a class='collapse-link'>"
|
|
|
|
html << "<i class='fa fa-chevron-#{arrow}'></i></a></li>"
|
|
|
|
html << "<li class='dropdown'>"
|
|
|
|
html << "<a class='dropdown-toggle' data-toggle='dropdown' role='button' aria-expanded='false'><i class='fa fa-wrench'></i></a>"
|
|
|
|
html << "<ul class='dropdown-menu' role='menu'>"
|
|
|
|
html << "<li><a href='#'>Settings 1</a></li>"
|
|
|
|
html << "<li><a href='#'>Settings 2</a></li>"
|
|
|
|
html << "</ul>"
|
|
|
|
html << "</li>"
|
2016-09-30 09:30:21 +00:00
|
|
|
html << "<ul class='nav panel_toolbox lights'>"
|
2016-09-29 06:53:08 +00:00
|
|
|
html << "<li><a><i class='fa fa-circle #{lights[2]}'></i></a></li>"
|
|
|
|
html << "<li><a><i class='fa fa-circle #{lights[1]}'></i></a></li>"
|
|
|
|
html << "<li><a><i class='fa fa-circle #{lights[0]}'></i></a></li>"
|
|
|
|
html << "</ul>"
|
2016-09-30 09:30:21 +00:00
|
|
|
html << "</ul>"
|
2016-09-29 06:53:08 +00:00
|
|
|
html << "<div class='clearfix'></div>"
|
|
|
|
html << "</div>"
|
2016-09-30 09:30:21 +00:00
|
|
|
html << "<div class='x_content'#{display}>"
|
2016-09-29 06:53:08 +00:00
|
|
|
# left content
|
|
|
|
html << "<div class='col-md-6 col-sm-6 col-xs-12'>"
|
|
|
|
html << "<div style='margin: 10px'>"
|
|
|
|
html << "<p class='text-muted font-13 m-b-30'><span class='badge bg-blue'>Volume Info</span></p>"
|
|
|
|
# volume_info
|
2016-09-20 12:13:24 +00:00
|
|
|
html << "<div>"
|
|
|
|
params.each do |t|
|
|
|
|
next if volume[t].nil?
|
|
|
|
html << "<p>"
|
|
|
|
html << t + " : " + volume[t]
|
|
|
|
html << "</p>"
|
|
|
|
end
|
|
|
|
html << "</div>"
|
2016-09-29 06:53:08 +00:00
|
|
|
html << "</div>"
|
|
|
|
# buttons
|
|
|
|
if volume["Mount State"] == "mounted"
|
2016-09-30 09:30:21 +00:00
|
|
|
html << "<button class='btn-volume-unmount btn btn-app' data-name='#{volume['Volume Name']}'>"
|
|
|
|
html << "<i class='fa fa-upload'></i> Unmount"
|
|
|
|
html << "</button>"
|
2016-09-29 06:53:08 +00:00
|
|
|
elsif volume["Status"] == " Started"
|
2016-09-30 09:30:21 +00:00
|
|
|
html << "<button class='btn-volume-stop btn btn-app' data-name='#{volume['Volume Name']}'>"
|
2016-09-29 06:53:08 +00:00
|
|
|
html << "<i class='fa fa-pause' style='color:#d9534f;'></i>"
|
|
|
|
html << "<p style='color:#d9534f;'>Stop</p>"
|
2016-09-29 08:44:41 +00:00
|
|
|
html << "</button>"
|
2016-09-30 09:30:21 +00:00
|
|
|
# need to fix this a tag to button
|
|
|
|
html << "<a class='btn-volume-mount btn btn-app' href='?volume_name=#{volume['Volume Name'].delete(' ')}#popup_mount'>"
|
|
|
|
html << "<i class='fa fa-download'></i> Mount"
|
|
|
|
html << "</a>"
|
2016-09-29 06:53:08 +00:00
|
|
|
else
|
2016-09-30 09:30:21 +00:00
|
|
|
html << "<button class='btn-volume-start btn btn-app' data-name='#{volume['Volume Name']}'>"
|
2016-09-29 06:53:08 +00:00
|
|
|
html << "<i class='fa fa-play' style='color:#26B99A;'></i>"
|
|
|
|
html << "<p style='color:#26B99A;'>Start</p>"
|
2016-09-29 08:44:41 +00:00
|
|
|
html << "</button>"
|
2016-09-30 09:30:21 +00:00
|
|
|
html << "<button class='btn-volume-delete btn btn-app' data-name='#{volume['Volume Name']}'>"
|
2016-09-29 06:53:08 +00:00
|
|
|
html << "<i class='fa fa-trash'></i> Delete"
|
2016-09-30 09:30:21 +00:00
|
|
|
html << "</button>"
|
2016-09-29 06:53:08 +00:00
|
|
|
end
|
|
|
|
html << "</div>"
|
|
|
|
|
|
|
|
# right content
|
|
|
|
html << "<div class='col-md-6 col-sm-6 col-xs-12'>"
|
|
|
|
|
|
|
|
if volume["Mount State"] == "mounted"
|
|
|
|
html << "<p class='text-muted font-13 m-b-30'><span class='badge bg-green'>Uploader</span> Activated</p>"
|
|
|
|
html << "<form action='/file_upload/#{volume['Volume Name'].delete(' ')}' method='post' enctype='multipart/form-data' class='dropzone' style='border: 1px solid #e5e5e5; height: 300px; overflow:auto;'>"
|
|
|
|
html << "</form>"
|
|
|
|
html << "<br/>"
|
|
|
|
else
|
|
|
|
html << "<p class='text-muted font-13 m-b-30'><span class='badge bg-red'>Uploader</span> Inactivated</p>"
|
|
|
|
html << "<form style='border: 1px solid #e5e5e5; height: 300px; overflow:auto;'>"
|
|
|
|
html << "</form>"
|
|
|
|
html << "<br/>"
|
|
|
|
end
|
|
|
|
|
|
|
|
html << "</div>"
|
|
|
|
html << "</div>"
|
|
|
|
html << "</div>"
|
|
|
|
html << "</div>"
|
2016-09-30 09:30:21 +00:00
|
|
|
|
|
|
|
return html
|
2016-09-20 12:13:24 +00:00
|
|
|
end
|
2016-09-28 09:15:06 +00:00
|
|
|
|
2016-10-02 12:38:57 +00:00
|
|
|
def html_mount_table(dir = @current_dir, id = "mount_table", class_option = "table table-striped table-bordered jambo_table")
|
2016-09-28 08:41:13 +00:00
|
|
|
html = String.new
|
|
|
|
html << "<table id='#{id}' class='#{class_option}'>"
|
|
|
|
html << "<thead>"
|
|
|
|
html << "<tr class='headings'>"
|
|
|
|
html << "<th>Name</th>"
|
|
|
|
html << "<th>auth</th>"
|
|
|
|
html << "<th></th>"
|
|
|
|
html << "</tr>"
|
|
|
|
html << "</thead>"
|
|
|
|
html << "<tbody id='#{id}_body'>"
|
|
|
|
html << "<tr>"
|
|
|
|
html << "<td>"
|
2016-10-02 12:38:57 +00:00
|
|
|
html << "<a class='chupper' style='cursor: pointer'><i class='fa fa-reply'></i></a> <span>#{@current_dir}</span>"
|
2016-09-28 08:41:13 +00:00
|
|
|
html << "</td>"
|
|
|
|
html << "<td></td>"
|
|
|
|
html << "<td></td>"
|
|
|
|
html << "</tr>"
|
|
|
|
|
|
|
|
files(dir).each do |file|
|
|
|
|
if file["auth"][0]=='d'
|
|
|
|
html << "<td style='color:#0d8ade;'><i class='fa fa-folder-open-o'></i>"
|
|
|
|
html << "<a class='chdir' style='cursor: pointer'> #{file['name']}</a>"
|
|
|
|
html << "</td>"
|
|
|
|
html << "<td>#{file['auth']}"
|
|
|
|
html << "</td>"
|
|
|
|
html << "<td>"
|
|
|
|
html << "<form data-parsley-validate>"
|
2016-09-28 09:15:06 +00:00
|
|
|
html << "<input type='hidden' value='#{@current_dir}/#{file["name"]}'>"
|
2016-09-28 08:41:13 +00:00
|
|
|
html << "<button type='submit' class='btn btn-primary pull-right'>select</button>"
|
|
|
|
html << "</form>"
|
|
|
|
html << "</td>"
|
|
|
|
html << "</tr>"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
html << "</tbody>"
|
|
|
|
html << "</table>"
|
|
|
|
return html
|
|
|
|
end
|
2016-09-28 09:15:06 +00:00
|
|
|
|
|
|
|
end
|