{= # # # # get_initial_report_data.cfv # This loads the initial report structure with report # and report element labels. # # include "templates.util.base_util"; include "templates.util.rbac.rbac_util"; include "templates.util.encoding"; include "templates.config_pages.reports.get_report_data_util"; string profile_name = internal.profile_name; string session_id = volatile.session_id; bool is_root_admin = get_is_root_admin(); string page_token = v.fp.page_token; # # Check RBAC permissions # if ((is_root_admin or get_config_feature_permission(session_id, profile_name, "reports", "view")) and get_is_valid_page_token(session_id, "reports", page_token)) then ( node profile = "profiles." . profile_name; # # # Create query_fields data etc. while initial report data becomes loaded # # # string cmd = ""; # # v.options.1 = "background"; # # v.options.2 = "-dp"; # v.options.3 = "templates.config_pages.reports.create_basic_report_data"; # # v.options.4 = "-p"; # v.options.5 = profile_name; # # v.options.6 = "volatile.user_node_name"; # v.options.7 = node_name(volatile.authenticated_user_node_path); # # v.options.8 = "volatile.session_id"; # v.options.9 = session_id; # # v.options.10 = "volatile.page_token"; # v.options.11 = page_token; # # # # We will we use the task_id later to check if there is any error # # if cached data are not available # # string task_id = exec(cmd, "v.options", false); # # # Assemble basic reports data # which contains only structure with labels # # string reports_dat = "["; delete_node("v.temp_empty"); v.temp_empty = ""; node reports = if (?(profile . ".statistics.reports")) then (profile . ".statistics.reports") else ("v.temp_empty"); node reports_menu = if (?(profile . ".statistics.reports_menu")) then (profile . ".statistics.reports_menu") else ("v.temp_empty"); if (num_subnodes(reports_menu) > 0) then ( # # # "v.all_reports" # # # Get all reports in a temporary node to recheck if all reports are covered by the reports menu. # Each report processed in the reports menu will be deleted from "v.all_reports", so any # remaining report in "v.all_reports" will then be added at the end of the menu # THIS PART HAS BEEN REMOVED BECAUSE WE ASSUME THE REPORTS MENU TO BE COMPLETE # TODO - this must be resolved, any report has to be shown, regardless if it exists in the reports_menu. # Otherwise we may loose reports upon save or get conflicts with report node names! # delete_node("v.all_reports"); # node report_item; # foreach report_item reports ( # "v.all_reports." . node_name(report_item) = true; # ); # # # Get report groups and reports from reports menu # # node item; string main_item_dat; bool is_report_group; foreach item reports_menu ( is_report_group = !item?{"report"}; if (is_report_group) then ( main_item_dat = get_report_data_create_report_menu_group_item_dat(reports, item); ) else ( main_item_dat = get_report_data_create_report_menu_item_dat(reports, item); ); reports_dat .= main_item_dat . ","; ); ); if (reports_dat ne "[") then ( # Report groups and/or reports exist reports_dat = replace_last(reports_dat, ",", "]"); ) else ( # There are no reports reports_dat .= "]"; ); # # # Response # # string dat = '{'; dat .= add_json("reportsDb", reports_dat, "obj"); # dat .= add_json("createBasicReportDataTaskId", task_id, "string"); dat = close_json(dat); # debug_message("#### dat:\n" . dat . "\n"); "reports.getInitialReportDataResponse(" . dat . ")\n"; ) else ( # No permission to access this resource (URL) display_no_permission_html(); ); =}