{= # # # get_subnodes.cfv # # # Called from client to add rows (subnodes) of a specific node # # include "templates.util.base_util"; include "templates.util.encoding"; debug_message("\n\n\n#### get_subnodes.cfv START \n"); bool is_root_admin = get_is_root_admin(); if (is_root_admin) then ( # # # Assemble rows in javascript object # # node n; # The root node is not automatically scanned and loaded like other nodes, so do it manually. if (v.fp.node_path eq "") then ( n = node_parent("internal"); # Get the contents of LogAnalysisInfo v.dircontents = ""; get_directory_contents(LOGANALYSISINFO_DIRECTORY, 'v.dircontents'); # debug_message(node_as_string('v.dircontents')); # Iterate through LogAnalysisInfo node item; foreach item 'v.dircontents' ( # Get the filename of this item string filename = replace_first(@item{'pathname'}, LOGANALYSISINFO_DIRECTORY, ""); # debug_message("filename: " . filename); # Compute the nodename of this item string nodename; if (@item{'is_directory'}) then ( debug_message("DIR pathname: " . filename); nodename = filename; ); else if (matches_regular_expression(filename, '^(.*)[.][cC][fF][gG]$')) then ( debug_message("CFG pathname: " . filename); nodename = $1; ); # If this is a value nodename, check if it exists. Just checking for existence will load # the node and attach it to the root, which is what we're trying to do. if (length(nodename) != 0) then bool exists = ?nodename; ); # foreach item ); # if "" else n = v.fp.node_path; node item; string path_id; string page_name; string events; string item_dat; string subnodes_dat = "["; node subn; foreach subn n ( debug_message("Subnode: " . subn . "\n"); item_dat = "{"; item_dat .= add_json("name", node_name(subn), "string"); item_dat .= add_json("value", node_value(subn), "string"); item_dat .= add_json("fullname", subn, "string"); item_dat .= add_json("has_subnodes", (num_subnodes(subn) != 0), "bool"); # item_dat .= add_json("expanded", "false", "bool"); item_dat = close_json(item_dat) . ","; subnodes_dat .= item_dat; ); subnodes_dat = replace_last(subnodes_dat, ",", "]"); # # # Send response # # string dat = "{"; dat .= add_json("expandedNodePath", n, "string"); dat .= add_json("subnodes", subnodes_dat, "obj"); dat = close_json(dat); debug_message("\n\n#### get_subnodes response dat:\n". dat . "\n\n"); # "alert('calling expandNodeResponse(): dat=" . dat . "')\n"; "nodeEditor.expandNodeResponse(" . dat . ")\n"; ) else ( # No permission to view this resource (URL) display_no_permission_html(); ); =}