diff --git a/admin-tools-demo-core/src/main/java/de/chandre/admintool/ExampleMXBean.java b/admin-tools-demo-core/src/main/java/de/chandre/admintool/ExampleMXBean.java new file mode 100644 index 0000000..80130ea --- /dev/null +++ b/admin-tools-demo-core/src/main/java/de/chandre/admintool/ExampleMXBean.java @@ -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; + } +} diff --git a/admin-tools-jminix/src/main/resources/static/admintool/jmx/js/jmx.js b/admin-tools-jminix/src/main/resources/static/admintool/jmx/js/jmx.js index 54a6f87..359f4bd 100644 --- a/admin-tools-jminix/src/main/resources/static/admintool/jmx/js/jmx.js +++ b/admin-tools-jminix/src/main/resources/static/admintool/jmx/js/jmx.js @@ -11,6 +11,7 @@ $.extend(AdminTool.Jmx.prototype, { name : 'adminToolJmx', postInit: function() { + this.debug=false; this.initJsTree() }, @@ -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 = { @@ -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); @@ -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", @@ -115,7 +113,9 @@ $.extend(AdminTool.Jmx.prototype, { } } catch (e) { - console.log(e) + if (console) { + console.log(e) + } } } } @@ -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)); }, @@ -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+")" } } @@ -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) { @@ -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(); }); @@ -245,7 +257,7 @@ $.pluginMaker(AdminTool.Jmx); var attributeListTpl = '
'+ '