Skip to content

Commit

Permalink
Close #36 - view of java.util.Date as readable date
Browse files Browse the repository at this point in the history
  • Loading branch information
andrehertwig committed Apr 7, 2018
1 parent a451345 commit 2ce2681
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 25 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package de.chandre.admintool;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.Date;

import org.springframework.stereotype.Component;

import de.chandre.admintool.core.AdminToolConfig;

@Component
public class ExampleMXBean implements AdminToolConfig {

public Date getDate() {
return new Date();
}

public LocalDate getLocalDate() {
return LocalDate.now();
}

public LocalDateTime getLocalDateTime() {
return LocalDateTime.now();
}

public Double getDouble() {
return Double.valueOf(123.456d);
}

public double getPrimitiveDouble() {
return 654.321d;
}

@Override
public void printConfig() {

}

@Override
public boolean isEnabled() {
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ $.extend(AdminTool.Jmx.prototype, {
name : 'adminToolJmx',

postInit: function() {
this.debug=false;
this.initJsTree()
},

Expand Down Expand Up @@ -60,9 +61,11 @@ $.extend(AdminTool.Jmx.prototype, {
var selectedNode = data.instance.get_node(data.selected[0]);
if (selectedNode.type == 'attributes') {

console.log('The selected node is: ' + selectedNode.text);
console.log('The selected parent is: ' + selectedNode.parent);
console.log('The selected parents parent is: ' + data.instance.get_node(selectedNode.parent).parent);
if (console && this.debug) {
console.log('The selected node is: ' + selectedNode.text);
console.log('The selected parent is: ' + selectedNode.parent);
console.log('The selected parents parent is: ' + data.instance.get_node(selectedNode.parent).parent);
}

var domain = this.getParent(data, selectedNode.parent);
var queryData = {
Expand All @@ -71,17 +74,11 @@ $.extend(AdminTool.Jmx.prototype, {
'server' : this.getParent(data, domain)
};

console.log(queryData);

this.sendRequest({
url: "/admintool/jmx/attributes",
requestType:'POST',
dataType: "json",
data: JSON.stringify(queryData),
my: this
},
$.proxy(this.viewAttributeList, this));

if (console && this.debug) {
console.log(queryData);
}
this.loadAttribute("attributes", queryData);

} else if (selectedNode.type == 'attribute' || selectedNode.type == 'operation') {

console.log('The selected node is: ' + selectedNode.text);
Expand All @@ -99,10 +96,11 @@ $.extend(AdminTool.Jmx.prototype, {
'domain' : domain,
'server' : server
};
console.log(queryData);

if (console && this.debug) {
console.log(queryData);
}
if(isAttribute) {
this.loadAttribute(queryData);
this.loadAttribute("attribute", queryData);
} else {
this.sendRequest({
url: "/admintool/jmx/operation",
Expand All @@ -115,7 +113,9 @@ $.extend(AdminTool.Jmx.prototype, {
}

} catch (e) {
console.log(e)
if (console) {
console.log(e)
}
}
}
}
Expand All @@ -132,15 +132,17 @@ $.extend(AdminTool.Jmx.prototype, {
return data.instance.get_node(currentNode).parent;
},

loadAttribute: function(queryData) {
loadAttribute: function(urlSuffix, queryData) {

this.sendRequest({
url: "/admintool/jmx/attribute",
url: "/admintool/jmx/" + urlSuffix,
requestType:'POST',
dataType: "json",
data: JSON.stringify(queryData),
showModalOnError: true,
showXHRErrorInModal: true,
my: this,
urlSuffix: urlSuffix
},
$.proxy(this.viewAttributeList, this));
},
Expand All @@ -156,6 +158,8 @@ $.extend(AdminTool.Jmx.prototype, {

} else if (Array.isArray(method.value) || typeof method.value === 'object') {
data.methods[i].value = JSON.stringify(method.value, null, "\t");
} else if (method.type == "java.util.Date" || method.type == "java.sql.Date") {
data.methods[i].value = new Date(method.value) + " (TS: "+method.value+")"
}
}

Expand All @@ -167,11 +171,18 @@ $.extend(AdminTool.Jmx.prototype, {
}
}
$('#jmxView').html(result);
$('#jmxView').find('#refreshView').on('click', $.proxy(this.loadAttribute, this, orgData));
$('#jmxView').find('#refreshView').on('click', $.proxy(this.loadAttribute, this, query.urlSuffix, orgData));

clearTimeout(this.loadTimout);
this.loadTimout = window.setTimeout(function() {
$('.fa-refresh').removeClass("fa-spin")
}, 800);
},

viewOperation: function(data, query) {
console.log(data)
if (console && this.debug) {
console.log(data);
}

var result = "";
if (data && data.methods && data.methods.length > 0) {
Expand Down Expand Up @@ -203,7 +214,8 @@ $.extend(AdminTool.Jmx.prototype, {

var msg = $('#jmxView').find('#save_success');
if (msg && msg.length > 0) {
window.setTimeout(function() {
clearTimeout(this.saveTimout);
this.saveTimout = window.setTimeout(function() {
$("#save_success").fadeTo(500, 0).slideUp(500, function(){
$(this).remove();
});
Expand Down Expand Up @@ -245,7 +257,7 @@ $.pluginMaker(AdminTool.Jmx);
var attributeListTpl =
'<div class="row">'+
'<div class="col-xs-10 col-md-11"><h4>{{headline}}</h4></div>'+
'<div class="col-xs-2 col-md-1"><a class="pull-right" id="refreshView"><i class="fa fa-refresh"></i></a></div>'+
'<div class="col-xs-2 col-md-1"><a class="pull-right" id="refreshView"><i class="fa fa-refresh fa-spin"></i></a></div>'+
'</div>'+
'<div class="table-responsive"><table class="table no-margin table-hover">'+
'<tbody>' +
Expand All @@ -261,7 +273,7 @@ Mustache.parse(attributeListTpl);
var attributeTpl =
'<div class="row">'+
'<div class="col-xs-10 col-md-11"><h4>{{name}}</h4></div>'+
'<div class="col-xs-2 col-md-1"><a class="pull-right" id="refreshView"><i class="fa fa-refresh"></i></a></div>'+
'<div class="col-xs-2 col-md-1"><a class="pull-right" id="refreshView"><i class="fa fa-refresh fa-spin"></i></a></div>'+
'</div>'+
'<div class="table-responsive"><table class="table no-margin table-hover"><tbody>' +
'<tr id="dec_{{name}}">' +
Expand Down

0 comments on commit 2ce2681

Please sign in to comment.