- -
-
-

Volume

-
-
- -
-
- -
- -
- <%@volumes.each do |t|%> -
-
-
-

Infomation <%=t["Volume Name"]%>

- -
-
- -
style="display: none;" <%end%> > - - -
- -
-

Volume Info

- Type : <%=t["Type"]%>
- Volume ID : <%=t["Volume ID"]%>
- Status : <%=t["Status"]%>
- Number of Bricks : <%=t["Number of Bricks"]%>
- Transport-type : <%=t["Transport-type"]%>
- Bricks : <%=t["Bricks"]%>
- Bricks1 : <%=t["Brick1"]%>
- Options Reconfigured : <%=t["Options Reconfigured"]%>
- performance.readdir-ahead : <%=t["performance.readdir-ahead"]%>
- mount state: <%=t["Mount State"]%>
+
+ +
+
- - - <% if t["Mount State"] == "Mounted" %> - Unmount - <% elsif t["Status"] == " Stopped" %> - - -

Start

-
- - Delete - - <% else %> - - -

Stop

-
- - Mount - <% end %> -
- - - -
-

Drag multiple files to the box below for multi upload or click to select files.

-
-
-
-
-
-
-
- <%end%> -
-
- - - - - - - + + + + - - - - + + + + - - + + \ No newline at end of file + + // Number of bricks changed + $("#form_volume_create .form-group").eq(2).change(function (){ + var $num_of_brick = $(this).find("option:selected").val(); + var $body = $("#form_volume_create .form-group").eq(3); + $body.empty(); + var new_body = ""; + for(var i = 0; i < $num_of_brick; ++i) { + new_body += "
"; + new_body += ""; + new_body += "
"; + new_body += ""; + new_body += "
"; + new_body += "
" + new_body += "" + new_body += "
" + new_body += "
"; + new_body += ""; + new_body += "
"; + new_body += "
"; + } + $body.append(new_body); + }) + + $("#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; + } + <% @volumes.each do |t| %> + if(volume_name == "<%=t["Volume Name"].delete(' ')%>"){ + alert("Already has a volume which name is same"); + 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; + } + if(brick_name.indexOf('/') == 0) { + alert("Brick name can't start with slash"); + return; + } + + var brick = ""; + if(server_name == "<%=@config['server_name']%>"){ + brick += "<%=@config['host_ip']%>"; + brick += "/"; + brick += brick_name; + bricks.push(brick); + console.log(brick); + } + else{ + alert("Something goes wrong!"); + return; + } + } + + console.log("Create volume.."); + + $.ajax({ + method: "POST", + url: "/volume/create", + data: { volume_name : volume_name, bricks : bricks }, + success : function(result){ + console.log("volume create success"); + } + }) + + }); + diff --git a/config/routes.rb b/config/routes.rb index 2639ddb..c3e6156 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -7,29 +7,30 @@ Rails.application.routes.draw do root 'home#index' post 'application/changeDir' => 'application#checkDir' - + get 'index' => 'plainpage#index' - + #Home get 'home/index' => 'home#index' post 'home/mkdir' => 'home#make_directory' post 'home/delete' => 'home#delete_file' - - + + #Volume get 'volume/index' => 'volume#index' post 'file_upload' => 'volume#file_upload' post 'volume/mount' => "volume#volume_mount" + post 'volume/create' => "volume#volume_create" get 'volume/unmount/:volume_name' => "volume#volume_unmount" get 'volume/start/:volume_name' => "volume#volume_start" get 'volume/stop/:volume_name' => "volume#volume_stop" get 'volume/delete/:volume_name' => "volume#volume_delete" - + #Peer get 'peer/index' => 'peer#index' - - - + + + # Example of regular route: # get 'products/:id' => 'catalog#view'