# # # # profiles_dashboard_util.cfv # # # include "templates.util.encoding"; # # # get_profiles_dashboard_view_column_profiles_dat() # # subroutine(get_profiles_dashboard_view_column_profiles_dat( node column_profiles), ( string column_profiles_dat = "["; node item; string item_dat; string profile_name; string report_field_name; foreach item column_profiles ( # Make sure the profile exists profile_name = @item{"profile_name"}; if (?("profiles." . profile_name)) then ( report_field_name = @item{"report_field"}; item_dat = "{"; item_dat .= add_json("profile_name", profile_name, "string"); item_dat .= add_json("show_label", (@item{"show_label"}), "bool"); item_dat .= add_json("label", (@item{"label"}), "string"); item_dat .= add_json("report_field", report_field_name, "string"); item_dat .= add_json("expression", (@item{"expression"}), "string"); # item_dat .= add_json("date_filter", (@item{"date_filter"}), "string"); item_dat = close_json(item_dat); column_profiles_dat .= item_dat . ","; ); ); if (column_profiles_dat ne "[") then ( column_profiles_dat = replace_last(column_profiles_dat, ",", "]"); ) else ( column_profiles_dat .= "]"; ); # debug_message("#### column_profiles_dat: " . column_profiles_dat . "\n"); # return column_profiles_dat; )); # # # get_profiles_dashboard_view_column_dat() # # subroutine(get_profiles_dashboard_view_column_dat( node column), ( string profile_name = @column{"profile_name"}; bool show_column_label = @column{"show_column_label"}; string column_label = @column{"column_label"}; bool show_cell_labels = @column{"show_cell_labels"}; bool cell_label = @column{"cell_label"}; string expression = @column{"expression"}; # string date_filter = @column{"date_filter"}; string report_field_name; string report_field_label; # Make sure the profile exists and get the column label if (profile_name ne "") then ( if (?("profiles." . profile_name)) then ( report_field_name = @column{"report_field"}; # Check report field existence if (report_field_name ne "" and ?("profiles." . profile_name . ".statistics.report_fields." . report_field_name)) then ( # Check if we need the report_field label if (show_column_label and column_label eq "") then ( # Show report field label node report_field_item = "profiles." . profile_name . ".statistics.report_fields." . report_field_name; if (@report_field_item{"column_label"} ne "") then ( report_field_label = @report_field_item{"column_label"}; ) else ( report_field_label = @report_field_item{"label"}; ); report_field_label = get_expanded_label(report_field_label); ); ) else ( # Reset report field report_field_name = ""; ); ) else ( profile_name = ""; ); ); string profiles_dat = get_profiles_dashboard_view_column_profiles_dat(column{"profiles"}); string columns_dat = "{"; columns_dat .= add_json("profile_name", profile_name, "string"); columns_dat .= add_json("show_column_label", show_column_label, "bool"); columns_dat .= add_json("column_label", column_label, "string"); columns_dat .= add_json("show_cell_labels", show_cell_labels, "bool"); columns_dat .= add_json("cell_label", cell_label, "string"); columns_dat .= add_json("report_field", report_field_name, "string"); columns_dat .= add_json("report_field_label", report_field_label, "string"); columns_dat .= add_json("expression", expression, "string"); # columns_dat .= add_json("date_filter", date_filter, "string"); columns_dat .= add_json("profiles", profiles_dat, "obj"); columns_dat = close_json(columns_dat); # return columns_dat; )); # # # get_profiles_dashboard_view_dat() # # subroutine(get_profiles_dashboard_view_dat, ( # This returns profiles_dashboard.cfg as JSON object. # The node LogAnalysisInfo/profiles_dashboard.cfg may not yet exist. node profiles_dashboard; if (?("profiles_dashboard")) then ( profiles_dashboard = "profiles_dashboard"; ) else ( profiles_dashboard = new_node(); ); bool show_database_info = if (profiles_dashboard?{"show_database_info"}) then (@profiles_dashboard{"show_database_info"}) else (false); string date_filter = if (profiles_dashboard?{"date_filter"}) then (@profiles_dashboard{"date_filter"}) else (""); string columns_dat = "["; if (profiles_dashboard?{"columns"}) then ( node columns = profiles_dashboard{"columns"}; node column; string column_dat; foreach column columns ( column_dat = get_profiles_dashboard_view_column_dat(column); columns_dat .= column_dat . ","; ); ); if (columns_dat eq "[") then ( columns_dat .= "]"; ) else ( columns_dat = replace_last(columns_dat, ",", "]"); ); string dashboard_view_dat = "{"; dashboard_view_dat .= add_json("show_database_info", show_database_info, "bool"); dashboard_view_dat .= add_json("date_filter", date_filter, "string"); dashboard_view_dat .= add_json("columns", columns_dat, "obj"); dashboard_view_dat = close_json(dashboard_view_dat); # return dashboard_view_dat; ));