blob: 593b0e9948976c1ea9cd3cee9e64fd5fcbe4afe9 [file] [log] [blame]
<!DOCTYPE HTML>
<html>
<body>
<section>
<h2>Cluster <span id="id"></div></h2>
<h3>Nodes</h3>
<table id="nodes" class="display">
<thead>
<th>Roles</th><th>Hosts</th>
</thead>
<tbody>
</tbody>
</table>
<h3>Software</h3>
<table id="software" class="display">
<thead>
<th>Software Stack</th><th>Version</th>
</thead>
<tbody>
</tbody>
</table>
<p/>
</section>
<p/>
<form class="form">
<p>Delete Cluster Procedures</p>
<p><input type=text id="manifest" value="" size="80"></p>
<p>
<button type="submit" id="decommission" onClick="return confirmDeleteCluster()" value="Delete">Delete</button>
<button type="submit" id="cancel" onclick="javascript:window.location='/';">Cancel</button>
</p>
</form>
<script type="text/javascript">
function confirmDeleteCluster() {
var question = "Delete cluster "+$.getUrlVar('cluster')+"?";
if(confirm(question)) {
deleteCluster($.getUrlVar('cluster'));
return false;
} else {
return false;
}
}
function deleteCluster(cluster) {
var decommissionUrl = $('#manifest').val();
var data = '{"cmd":"delete","dry-run":"false","clusterManifest":{"@clusterName":"'+cluster+'","nodes":{"@url":null},"software":null,"config":{"@url":"'+decommissionUrl+'"}}}';
$.ajax({
type: 'POST',
url: '/v1/controller/delete/cluster',
contentType: "application/json; charset=utf-8",
data: data,
success: function(data) {
var url = '/?func=status-command&cmd='+data['output'];
window.location.href = url;
},
dataType:'json'
});
}
function renderRole(role) {
var buffer = [];
var i = 0;
buffer[i++] = role['name'];
buffer[i++] = role['host'].join(" ");
return buffer;
}
function render(cluster) {
var id = $.getUrlVar('cluster');
$('#id').text(id);
for(var roles in cluster['nodes']['roles']) {
$('#nodes').dataTable().fnAddData(renderRole(cluster['nodes']['roles'][roles]));
}
$('#software').dataTable().fnAddData([ cluster['software']['name'], cluster['software']['version'] ]);
}
$(document).ready(function() {
$.extend({
getUrlVars: function(){
var vars = [], hash;
var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
for(var i = 0; i < hashes.length; i++) {
hash = hashes[i].split('=');
vars.push(hash[0]);
vars[hash[0]] = hash[1];
}
return vars;
},
getUrlVar: function(name){
return $.getUrlVars()[name];
}
});
var cluster = $.getUrlVar('cluster');
jQuery.getJSON('/v1/cluster/status/'+cluster,
function(cluster) {
render(cluster);
}
);
var prefix = window.location.protocol+'//'+window.location.hostname+':'+window.location.port;
$('#manifest').val(prefix+'/v1/config/manifest/delete-cluster');
$('#nodes').dataTable({"bJQueryUI": true});
$('#software').dataTable({"bJQueryUI": true});
});
</script>
</body>
</html>