<table id="main">
  <tr id="cluster_title_row" {{bindAttr style=Pcs.manage_page}}><td id="page_header" colspan=3 style="vertical-align:middle;">
      <table id="manage_cluster_commands"><tr>
	  <td>
	    MANAGE CLUSTERS
	  </td>
	  </td>
	  <td>
	      <a href="#" class="x sprites"></a>
	    <div class="link">
	      <a id="manage_remove_cluster" href="#manage" onclick="verify_remove('cluster','You must select at least one cluster to remove', 'Remove Cluster(s)','Cluster Removal');">Remove</a>
	    </div>
	  </td>
	  <td>
	    <a href="#manage" class="plus sprites"></a>
	    <div class="link">
	      <a id="manage_add_cluster" href="#manage" onclick="add_existing_dialog();">
		Add Existing
	      </a>
	    </div>
	  </td>
	  <td>
	    <a href="#manage" class="plus sprites"></a>
	    <div class="link">
	      <a id="manage_create_cluster" href="#manage" onclick="create_cluster_dialog();">Create New</a>
	    </div>
	  </td>
	</tr>
      </table>
    </td>
  </tr>
  <tr id="cluster_header_row" {{bindAttr style="Pcs.manage_page"}}>
    <td class="borderbottom" colspan=3>
    </td>
  </tr>
  <tr id="cluster_list_row" {{bindAttr style="Pcs.manage_page"}}>
    <td id="cluster_list" class="node_list" style="width:400px;">
      <%= erb :_cluster_list %>
    </td>
    <td id="node_info" colspan=2>
      <div id="node_info_header">
	<div id="node_info_header_title">INFORMATION ABOUT CLUSTERS</div>
      </div>
      <div id="node_sub_info">
	<div id="no_cluster_selected">Select a cluster to view more detailed cluster information</div>
	<% @clusters.each do |c| %>
	  <div id="cluster_info_<%=c.name%>" style="display:none;">
	    <table>
	      <tr><td style="text-align:right"><b>Cluster:</b>&nbsp;</td><td><%=c.name%></td></tr>
	      <% first = true %>
	      <% c.nodes.each { |n| %>
		<%= '<tr><td style="text-align:right"><b>Nodes:</b>&nbsp;</td>' if first %>
		<%= "<tr><td></td>" if not first %>
		  <td><%=n%></td></tr>
		<% first = false %>
	      <% } %>
	    </table>
	  </div>
	<% end %>
      </div>
    </td>
  </tr>
</table>
<div id="verify_remove" style="display: none;">
  <p style="font-size:12px;">Are you sure you want to remove the following cluster(s) from the GUI? (This only removes the cluster from the GUI, it does not stop the cluster from running)</p>
  <span id="resource_to_remove"></span>
</div>
<div id="add_existing_cluster" style="display: none;">
  <form id="add_existing_cluster_form" action="/manage/existingcluster" method="post">
    <br>
    Enter the hostname/IP of a node in a cluster that you would like to manage:
    <br>
    <br>
    <table>
      <tr><td align=center style="color: red" colspan=2"><span id="unable_to_connect_error_msg_ae" style="display:none;">Unable to contact node.<br>Please make sure pcsd is started and authenticated.<br/></span>
	  <span id="add_existing_cluster_error_msg" style="display:none;">
	  </span>
      </td></tr>
      <tr><td align=right>Node Name/IP:</td><td><input size="50" name="node-name" type="text"></td></tr>
    </table>
  </form>
</div>
</div>
<div id="create_new_cluster" style="display: none;">
  <form id="create_new_cluster_form" action="/manage/newcluster" method="post">
    <br>
    Enter the hostnames of the nodes you would like to use to create a cluster:
    <br>
    <br>
    <table>
      <tr><td align=right>Cluster Name:</td><td><input size="50" name="clustername" type="text"></input></td></tr>
      <tr><td align=right>Node 1:</td><td><input size="50" name="node-1" type="text"></input></td></tr>
      <tr><td align=right>Node 2:</td><td><input size="50" name="node-2" type="text"></input></td></tr>
      <tr><td align=right>Node 3:</td><td><input size="50" name="node-3" type="text"></input></td></tr>
      <tr><td></td><td id="manage_more_nodes" onclick="create_cluster_add_nodes();" style="color: #2B85DB;">More nodes...</td></tr>
      <tr><td align=center style="color: red" colspan=2"><span id="unable_to_connect_error_msg" style="display:none;">Unable to contact nodes highlighted in red.<br>Please make sure pcsd is started on all nodes.</span></td></tr>
      <tr><td align=center style="color: red" colspan=2"><span id="at_least_one_node_error_msg" style="display:none;">At least one valid node must be entered.</span></td></tr>
      <tr><td align=center style="color: red" colspan=2"><span id="bad_cluster_name_error_msg" style="display:none;">You may not leave the cluster name field blank</span></td></tr>
    </table>
  </form>
</div>
<div id="manage_error" style="display: none;">
  <br>
  <% if @error == "badclustername" %>
    The cluster name, '<%=@errorval%>' has not yet been configured in pcsd.  Use 'Add Existing' to add a node which is part of the cluster.
  <% end %>
  <% if @error == "duplicatename" %>
    The cluster name, '<%=@errorval%>' has already been added to pcsd.  You may not add two clusters with the same name into pcsd.
  <% end %>
  <% if @error == "duplicatenodename" %>
    The node, '<%=@errorval%>' is already configured in pcsd.  You may not add a node to two different clusters in pcsd.
  <% end %>
</div>
<% if @error %>
  <script type="text/javascript">
    $(function() {
      $("#manage_error").dialog({
	title: "Bad Cluster Name",
	buttons: {
	  Ok: function() {
	    $(this).dialog("close");
	  }
	},
	autoOpen:true
      });
    });
  </script>
<% end %>
