diff --git a/src/sunstone/public/js/plugins/vms-tab.js b/src/sunstone/public/js/plugins/vms-tab.js index d1362e0dcd..c27822cf95 100644 --- a/src/sunstone/public/js/plugins/vms-tab.js +++ b/src/sunstone/public/js/plugins/vms-tab.js @@ -289,15 +289,14 @@ var vm_actions = { //update the tab and pop it up again var log_lines = res.split("\n"); var colored_log = ''; - for (line in log_lines){ + for (var line = 0; line < log_lines.length;++line){ line = log_lines[line]; - if (typeof line == "string") { - if (line.match(/\[E\]/)){ - line = ''+line+'' - } - colored_log += line + "\n"; + if (line.match(/\[E\]/)){ + line = ''+line+''; } + colored_log += line + "\n"; } + var log_tab = { title: "VM log", content: '
'+colored_log+'
' diff --git a/src/sunstone/public/js/plugins/vnets-tab.js b/src/sunstone/public/js/plugins/vnets-tab.js index 927461c1e1..e5a66e37c6 100644 --- a/src/sunstone/public/js/plugins/vnets-tab.js +++ b/src/sunstone/public/js/plugins/vnets-tab.js @@ -381,7 +381,7 @@ function updateVNetworkInfo(request,vn){ \ Leases information\ '+ - prettyPrintJSON(vn_info.LEASES)+ + prettyPrintJSON(vn_info.LEASES.LEASE)+ ''; } diff --git a/src/sunstone/public/js/sunstone-util.js b/src/sunstone/public/js/sunstone-util.js index 5e2ba6d22b..44f51a0c99 100644 --- a/src/sunstone/public/js/sunstone-util.js +++ b/src/sunstone/public/js/sunstone-util.js @@ -198,59 +198,75 @@ function notifyMessage(msg){ // It recursively explores objects function prettyPrintJSON(template_json,padding,weight, border_bottom,padding_top_bottom){ var str = "" + if (!template_json){ return "Not defined";} if (!padding) {padding=0}; if (!weight) {weight="bold";} if (!border_bottom) {border_bottom = "1px solid #CCCCCC";} if (!padding_top_bottom) {padding_top_bottom=6;} + var field = null; - for (field in template_json) { - if (typeof template_json[field] == 'object'){ - //name of field row - str += '\ - ' - +field+ - '\ - \ - \ - '; - //attributes rows - //empty row - prettyprint - empty row - str += '\ - \ - \ - ' + - prettyPrintJSON(template_json[field],padding+25,"normal","0",1) + - '\ - \ - \ - '; - } else { - str += '\ - '+ - field+ - '\ - '+ - template_json[field]+ - '\ + if (template_json.constructor == Array){ + for (field = 0; field < template_json.length; ++field){ + str += prettyPrintRowJSON(field,template_json[field],padding,weight, border_bottom,padding_top_bottom); + } + } else { + for (field in template_json) { + str += prettyPrintRowJSON(field,template_json[field],padding,weight, border_bottom,padding_top_bottom); + } + } + return str; +} + +function prettyPrintRowJSON(field,value,padding,weight, border_bottom,padding_top_bottom){ + var str=""; + + if (typeof value == 'object'){ + //name of field row + str += '\ + ' + +field+ + '\ + \ + \ '; - }; + //attributes rows + //empty row - prettyprint - empty row + str += '\ + \ + \ + ' + + prettyPrintJSON(value,padding+25,"normal","0",1) + + '\ + \ + \ + '; + } else { + str += '\ + '+ + field+ + '\ + '+ + value+ + '\ + '; }; + return str; } @@ -336,7 +352,7 @@ function onError(request,error_json) { var value; rows = ["method","action","object","id","reason"]; message = ""; - for (i in rows){ + for (i = 0; i