From b97c484ff821693640490f32ad60883b9214f41e Mon Sep 17 00:00:00 2001 From: kyg516 <kyg_516@naver.com> Date: Wed, 14 Sep 2016 16:23:13 +0900 Subject: [PATCH] Add 'gem thin': WebBrick is deprecated --- Gemfile | 2 +- Gemfile.lock | 9 ++- app/controllers/application_controller.rb | 1 + app/controllers/volume_controller.rb | 4 +- app/views/volume/index.html.erb | 84 ++++++++--------------- 5 files changed, 41 insertions(+), 59 deletions(-) diff --git a/Gemfile b/Gemfile index e82371e..5538447 100644 --- a/Gemfile +++ b/Gemfile @@ -35,6 +35,7 @@ gem 'sdoc', '~> 0.4.0', group: :doc # Use Capistrano for deployment # gem 'capistrano-rails', group: :development +gem 'thin' group :development, :test do # Call 'byebug' anywhere in the code to stop execution and get a debugger console @@ -48,4 +49,3 @@ group :development do # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring gem 'spring' end - diff --git a/Gemfile.lock b/Gemfile.lock index b9951a8..12bf38b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -61,6 +61,7 @@ GEM execjs coffee-script-source (1.10.0) concurrent-ruby (1.0.1) + daemons (1.2.4) debug_inspector (0.0.2) devise (4.2.0) bcrypt (~> 3.0) @@ -69,6 +70,7 @@ GEM responders warden (~> 1.2.3) erubis (2.7.0) + eventmachine (1.2.0.1) execjs (2.6.0) font-awesome-rails (4.6.3.1) railties (>= 3.2, < 5.1) @@ -148,6 +150,10 @@ GEM activesupport (>= 4.0) sprockets (>= 3.0.0) sqlite3 (1.3.11) + thin (1.7.0) + daemons (~> 1.0, >= 1.0.9) + eventmachine (~> 1.0, >= 1.0.4) + rack (>= 1, < 3) thor (0.19.1) thread_safe (0.3.5) tilt (2.0.2) @@ -182,9 +188,10 @@ DEPENDENCIES sdoc (~> 0.4.0) spring sqlite3 + thin turbolinks uglifier (>= 1.3.0) web-console (~> 2.0) BUNDLED WITH - 1.12.5 + 1.13.0 diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index db49794..0a0a93f 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -2,6 +2,7 @@ class ApplicationController < ActionController::Base # Prevent CSRF attacks by raising an exception. # For APIs, you may want to use :null_session instead. # protect_from_forgery with: :exception + helper_method :volume_mount, :volume_unmount, :volume_create, :volume_delete, :volume_start, :volume_stop def get_conf @config = Hash.new diff --git a/app/controllers/volume_controller.rb b/app/controllers/volume_controller.rb index e520764..63b9313 100644 --- a/app/controllers/volume_controller.rb +++ b/app/controllers/volume_controller.rb @@ -101,7 +101,7 @@ class VolumeController < ApplicationController command << "force" puts command `#{command}` - # redirect_to '/volume/index' + redirect_to '/volume/index' end def volume_stop @@ -132,7 +132,7 @@ class VolumeController < ApplicationController command << "-p " + @config["host_port"].to_s + " " end command << @config["host_user"].to_s + "@" + @config["host_ip"].to_s - command << " gluster volume start " + volume_name + command << " gluster volume start " + volume_name.to_s puts command `#{command}` redirect_to '/volume/index' diff --git a/app/views/volume/index.html.erb b/app/views/volume/index.html.erb index 538f090..0e5095a 100644 --- a/app/views/volume/index.html.erb +++ b/app/views/volume/index.html.erb @@ -3,9 +3,7 @@ <div class="popup"> <h2> Choose mount point </h2> <a class="close" href="#">×</a> - <form id="form_volume_create" data-parsley-validate class="form-horizontal form-label-left"> - <div class="form-group"> <label class="control-label col-md-3 col-sm-3 col-xs-12" for="volume-name">Volume Name <span class="required">*</span> </label> @@ -13,7 +11,6 @@ <input type="text" required="required" class="form-control col-md-7 col-xs-12"> </div> </div> - <div class="form-group"> <label class="control-label col-md-3 col-sm-3 col-xs-12">Volume Type <span class="required">*</span> </label> @@ -25,7 +22,6 @@ </select> </div> </div> - <div class="form-group"> <label class="control-label col-md-3 col-sm-3 col-xs-12">Number of brick <span class="required">*</span> </label> @@ -37,7 +33,6 @@ </select> </div> </div> - <div class="form-group"> <div class="row" style="margin:0 0 10px 0"> <label class="control-label col-md-3 col-sm-3 col-xs-12">Bricks <span class="required">*</span> @@ -56,9 +51,7 @@ </div> </div> </div> - <div class="ln_solid"></div> - <div class="form-group"> <div class="col-md-6 col-sm-6 col-xs-12 col-md-offset-3"> <a href="#" class="btn btn-primary">Cancel</a> @@ -66,7 +59,6 @@ </div> </div> </form> - </div> </div> @@ -97,7 +89,10 @@ </td> <td><%=t["auth"]%></td> <td> - <button class="btn btn-primary pull-right" onclick="volume_mount('<%=@current_dir + "/" + t["name"]%>')">select</botton> + <form data-parsley-validate> + <input type="hidden" value='<%=@current_dir + "/" + t["name"]%>'> + <button type="submit" class="btn btn-primary pull-right">select</botton> + </form> </td> </tr> <%end%> @@ -153,7 +148,7 @@ <div class="col-md-6 col-sm-6 col-xs-12"> <div style="margin: 10px"> - <p class="text-muted font-13 m-b-30"><code>Volume Info</code></p> + <p class="text-muted font-13 m-b-30"><span class="badge bg-blue">Volume Info</span></p> Type : <%=t["Type"]%> <br> Volume ID : <%=t["Volume ID"]%> <br> Status : <%=t["Status"]%> <br> @@ -189,12 +184,15 @@ <!-- right content --> <div class="col-md-6 col-sm-6 col-xs-12"> <% if t["Mount State"] == "mounted" %> - <p>Drag multiple files to the box below for multi upload or click to select files.</p> + <p class="text-muted font-13 m-b-30"><span class="badge bg-green">Uploader</span> Activated</p> <form action="/file_upload" method="post" enctype="multipart/form-data" class="dropzone" style="border: 1px solid #e5e5e5; height: 300px; overflow:auto;"> </form> <br/> - <% elsif t["Status"] == " Started" %> <% else %> + <p class="text-muted font-13 m-b-30"><span class="badge bg-red">Uploader</span> Inactivated</p> + <form style="border: 1px solid #e5e5e5; height: 300px; overflow:auto;"> + </form> + <br/> <% end %> </div> </div> @@ -205,33 +203,7 @@ </div> <!-- /page content --> - <!-- volume functions --> - <script> - function volume_mount(mnt_point) { - var url = window.location + ''; - var vol_name = url.match(/volume_name=([^#]+)/)[1]; - $.ajax({ - type: 'post', - url: '/volume/mount', - data: {mount_point: mnt_point, volume_name: vol_name}, - success: function(data){ - console.log("mount success"); - window.location.replace(url.split("?")[0]); - } - }); - } - </script> - - - <!-- data table handler --> - <script type="text/javascript"> - $(document).ready(function() { - $('#datatable').dataTable(); - }); - </script> - - - <!-- file manager functions --> + <!-- File manager functions --> <script> function change_upper(directory){ if(directory == "/") return; @@ -248,7 +220,7 @@ $("#datatable_body").empty(); var new_tr = ""; new_tr += "<tr role='row' class='odd'> <td><i class='fa fa-reply'></i>"; - nrailew_tr += "<a style='cursor: pointer' onclick='change_upper(" + '"' + directory + '"' +")'> ..</a>"; + new_tr += "<a style='cursor: pointer' onclick='change_upper(" + '"' + directory + '"' +")'> ..</a>"; new_tr += "</td><td> </td><td> </td><td> </td></tr>"; for( var i = 0; i < result.file.length; i++){ if(result.file[i].auth[0] != "d") continue; @@ -262,12 +234,26 @@ new_tr += "</tr>"; } $("#datatable_body").append(new_tr); - $('#datatable').dataTable(); } }) } </script> - + <!-- Mount overlay functions --> + <script> + $("#popup_mount #datatable_body form").submit(function(){ + var mnt_point = $(this).find("input").val(); + var url = window.location + ''; + var vol_name = url.match(/volume_name=([^#]+)/)[1]; + $.ajax({ + type: 'post', + url: '/volume/mount', + data: {mount_point: mnt_point, volume_name: vol_name}, + success: function(result){ + } + }); + }) + </script> + <!-- Create overlay functions --> <script> // Volume type changed $("#form_volume_create .form-group").eq(1).change(function (){ @@ -276,7 +262,6 @@ case "Distribute": case "Stripe": case "Replica": - case "Arbiter": case "Disperse": case "Disperse-data": case "Redundancy": @@ -287,7 +272,6 @@ break; } }) - // Number of bricks changed $("#form_volume_create .form-group").eq(2).change(function (){ var $num_of_brick = $(this).find("option:selected").val(); @@ -316,14 +300,12 @@ } $body.append(new_body); }) - + // Volume create $("#form_volume_create").submit(function(){ var volume_name = $(this).find(".form-group:eq(0) input").val(); var volume_type = $(this).find(".form-group:eq(1) option:selected").val(); var num_of_brick = $(this).find(".form-group:eq(2) option:selected").val() * 1; // convert to Number type var bricks = []; - - // error check if(volume_name.indexOf(' ') >= 0){ alert("Volume name can't contains white spaces"); return; @@ -334,11 +316,9 @@ return; } <% end %> - for(var i = 0; i < num_of_brick; i++){ var server_name = $(this).find(".form-group .row").eq(i).find("option:selected").val(); var brick_name = $(this).find(".form-group .row").eq(i).find("input").val(); - if(brick_name.indexOf(' ') >= 0) { alert("Brick name can't contain white spaces"); return; @@ -347,7 +327,6 @@ alert("Brick name can't start with slash"); return; } - var brick = ""; if(server_name == "<%=@config['server_name']%>"){ brick += "<%=@config['host_ip']%>"; @@ -361,17 +340,12 @@ return; } } - - console.log("Create volume.."); - $.ajax({ method: "POST", url: "/volume/create", data: { volume_name : volume_name, volume_type : volume_type, num_of_brick : num_of_brick, bricks : bricks }, success : function(result){ - console.log("volume create success"); } }) - }); </script>