application_parameter = {
applications : null
};
function application_list() {
$('#content').html('');
$.ajax({
type : 'get',
dataType : 'json',
contentType : 'application/json; charset=utf-8',
url : '../jaxrs/applications',
xhrFields : {
'withCredentials' : true
},
crossDomain : true
}).done(function(data) {
if (data.type == 'success') {
if (data.data && data.data.applicationTypes) {
application_parameter.applications = data.data;
var str = '
';
str += '| host | port | contextPath | available | weight | operate |
';
$.each(data.data.applicationTypes, function(index, item) {
str += '| ' + item.type + ' |
';
$.each(item.applications, function(index, o) {
str += '';
str += '| ' + o.host + ' | ';
str += '' + o.port + ' | ';
str += '' + o.contextPath + ' | ';
str += '' + o.available + ' | ';
str += '' + o.weight + ' | ';
str += '';
str += 'edit ';
str += ' | ';
str += '
';
});
});
str += '
';
$('#content').html(str);
}
} else {
failure(data);
}
$('#result').html(JSON.stringify(data.data, null, 4));
});
}
function application_edit(token) {
$('#result').html('');
var str = '';
$('#content').html(str);
$('#put', '#content').click(function() {
application_put(token);
});
$.each(application_parameter.applications.applicationTypes, function(index, item) {
$.each(item.applications, function(index, o) {
if (o.token == token) {
$('#token', '#content').html(o.token);
$('#available', '#content').html(o.available + '');
$('#reportDate', '#content').html(o.reportDate);
$('#contextPath', '#content').html(o.contextPath);
$('#enable', '#content').val(o.enable + '');
$('#host', '#content').val(o.host);
$('#port', '#content').val(o.port);
$('#weight', '#content').val(o.weight);
}
});
});
}
function application_put(token) {
$('#result').html('');
$.ajax({
type : 'put',
dataType : 'json',
url : '../jaxrs/application/' + token,
contentType : 'application/json; charset=utf-8',
data : JSON.stringify({
enable : $('#enable', '#content').val(),
host : $('#host', '#content').val(),
port : $('#port', '#content').val(),
weight : $('#weight', '#content').val()
}),
xhrFields : {
'withCredentials' : true
},
crossDomain : true
}).done(function(data) {
if (data.type == 'success') {
application_list();
} else {
failure(data);
}
});
}